From 96cc074ea0752165d2eb9281c9affeda8e5be5b1 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Tue, 26 Apr 2016 14:44:01 +0200 Subject: DM: Create engine and detection with dummy data --- engines/dm/configure.engine | 3 +++ engines/dm/detection.cpp | 55 ++++++++++++++++++++++++++++++++++++++++ engines/dm/dm.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++ engines/dm/dm.h | 38 ++++++++++++++++++++++++++++ engines/dm/module.mk | 17 +++++++++++++ 5 files changed, 174 insertions(+) create mode 100644 engines/dm/configure.engine create mode 100644 engines/dm/detection.cpp create mode 100644 engines/dm/dm.cpp create mode 100644 engines/dm/dm.h create mode 100644 engines/dm/module.mk diff --git a/engines/dm/configure.engine b/engines/dm/configure.engine new file mode 100644 index 0000000000..50a3d9975c --- /dev/null +++ b/engines/dm/configure.engine @@ -0,0 +1,3 @@ +# This file is included from the main "configure" script +# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] +add_engine dm "Dungeon Master" yes diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp new file mode 100644 index 0000000000..4c970e32c9 --- /dev/null +++ b/engines/dm/detection.cpp @@ -0,0 +1,55 @@ +#include "dm/dm.h" + +#include "common/config-manager.h" +#include "common/error.h" +#include "common/fs.h" + +#include "engines/advancedDetector.h" +namespace DM { +static const PlainGameDescriptor DMGames[] = { + {0, 0} +}; + +static const ADGameDescription gameDescriptions[] = { + AD_TABLE_END_MARKER +}; + +static const ADExtraGuiOptionsMap optionsList[] = { + AD_EXTRA_GUI_OPTIONS_TERMINATOR +}; + + +class DMMetaEngine : public AdvancedMetaEngine { +public: + + + DMMetaEngine() : AdvancedMetaEngine(DM::gameDescriptions, sizeof(ADGameDescription), DMGames, optionsList) { + _singleId = "Dummy"; + } + + virtual const char *getName() const { + return "Dummy"; + } + + virtual const char *getOriginalCopyright() const { + return "Dummy"; + } + + virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { return gameDescriptions; } + virtual bool hasFeature(MetaEngineFeature f) const { return false; } + virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { + *engine = new DM::DMEngine(syst); + return true; + } + virtual int getMaximumSaveSlot() const { return 99; } + virtual SaveStateList listSaves(const char *target) const { return SaveStateList(); } + SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { return SaveStateDescriptor(); } + virtual void removeSaveState(const char *target, int slot) const {} +}; + +} +#if PLUGIN_ENABLED_DYNAMIC(DM) +REGISTER_PLUGIN_DYNAMIC(DM, PLUGIN_TYPE_ENGINE, DM::DMMetaEngine); +#else +REGISTER_PLUGIN_STATIC(DM, PLUGIN_TYPE_ENGINE, DM::DMMetaEngine); +#endif diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp new file mode 100644 index 0000000000..b0c281a12b --- /dev/null +++ b/engines/dm/dm.cpp @@ -0,0 +1,61 @@ +#include "common/scummsys.h" + +#include "common/config-manager.h" +#include "common/debug.h" +#include "common/debug-channels.h" +#include "common/error.h" +#include "gui/EventRecorder.h" +#include "common/file.h" +#include "common/fs.h" + +#include "engines/util.h" + +#include "dm/dm.h" + +namespace DM { + +DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { + // Do not load data files + // Do not initialize graphics here + // Do not initialize audio devices here + // Do these from run + + //Specify all default directories + const Common::FSNode gameDataDir(ConfMan.get("example")); + SearchMan.addSubDirectoryMatching(gameDataDir, "example2"); + + DebugMan.addDebugChannel(kDMDebugExample, "example", "example desc"); + + // regiser random source + _rnd = new Common::RandomSource("quux"); + + debug("DMEngine::DMEngine"); +} + +DMEngine::~DMEngine() { + debug("DMEngine::~DMEngine"); + + // dispose of resources + delete _rnd; + + // clear debug channels + DebugMan.clearAllDebugChannels(); +} + +Common::Error DMEngine::run() { + // Init graphics + initGraphics(320, 200, false); + + // Create debug console (it requirese GFX to be inited) + _console = new Console(this); + + // Additional setup + debug("DMEngine::init"); + + // Run main loop + debug("DMEngine:: start main loop"); + + return Common::kNoError; +} + +} // End of namespace DM diff --git a/engines/dm/dm.h b/engines/dm/dm.h new file mode 100644 index 0000000000..79deb299da --- /dev/null +++ b/engines/dm/dm.h @@ -0,0 +1,38 @@ +#ifndef DM_H +#define DM_H + +#include "common/random.h" +#include "engines/engine.h" +#include "gui/debugger.h" + + +namespace DM { + +class Console; + +enum { + // engine debug channels + kDMDebugExample = 1 << 0 +}; + +class DMEngine : public Engine { +public: + DMEngine(OSystem *syst); + ~DMEngine(); + + virtual Common::Error run(); + +private: + Console *_console; + Common::RandomSource *_rnd; +}; + +class Console : public GUI::Debugger { +public: + Console(DMEngine *vm) {} + virtual ~Console(void) {} +}; + +} // End of namespace DM + +#endif diff --git a/engines/dm/module.mk b/engines/dm/module.mk new file mode 100644 index 0000000000..808b4e5c52 --- /dev/null +++ b/engines/dm/module.mk @@ -0,0 +1,17 @@ +MODULE := engines/dm + +MODULE_OBJS := \ + detection.o \ + dm.o + +MODULE_DIRS += \ + engines/dm + +# This module can be built as a plugin +ifeq ($(ENABLE_DM), DYNAMIC_PLUGIN) +PLUGIN := 1 +endif + +# Include common rules +include $(srcdir)/rules.mk + -- cgit v1.2.3 From 5ae7d3a84b04336b65b93e2efe1c988c795e1752 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Tue, 26 Apr 2016 23:33:03 +0200 Subject: DM: Add detection for Amiga v2.0 English --- engines/dm/detection.cpp | 33 +++++++++++++++++++++++++++------ engines/dm/dm.cpp | 8 +++++--- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp index 4c970e32c9..443d2dba78 100644 --- a/engines/dm/detection.cpp +++ b/engines/dm/detection.cpp @@ -7,13 +7,35 @@ #include "engines/advancedDetector.h" namespace DM { static const PlainGameDescriptor DMGames[] = { + {"dm", "Dungeon Master"}, {0, 0} }; static const ADGameDescription gameDescriptions[] = { + { + "dm", "Amiga 2.0v English", + { + {"graphics.dat", 0, "6A2F135B53C2220F0251FA103E2A6E7E", 411960}, + {"Dungeon.dat", 0, "30028FB6A301ECB20127EF0B3AF32B05", 25006}, + AD_LISTEND + }, + Common::EN_GRB, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) + }, + AD_TABLE_END_MARKER }; +static ADGameDescription fallbackDesc = { + "dm", + "Unknown version", + AD_ENTRY1(0, 0), // This should always be AD_ENTRY1(0, 0) in the fallback descriptor + Common::UNK_LANG, + Common::kPlatformDOS, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) +}; + + static const ADExtraGuiOptionsMap optionsList[] = { AD_EXTRA_GUI_OPTIONS_TERMINATOR }; @@ -21,14 +43,12 @@ static const ADExtraGuiOptionsMap optionsList[] = { class DMMetaEngine : public AdvancedMetaEngine { public: - - DMMetaEngine() : AdvancedMetaEngine(DM::gameDescriptions, sizeof(ADGameDescription), DMGames, optionsList) { - _singleId = "Dummy"; + _singleId = "dm"; } virtual const char *getName() const { - return "Dummy"; + return "Dungeon Master"; } virtual const char *getOriginalCopyright() const { @@ -38,8 +58,9 @@ public: virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { return gameDescriptions; } virtual bool hasFeature(MetaEngineFeature f) const { return false; } virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { - *engine = new DM::DMEngine(syst); - return true; + if(desc) + *engine = new DM::DMEngine(syst); + return desc != nullptr; } virtual int getMaximumSaveSlot() const { return 99; } virtual SaveStateList listSaves(const char *target) const { return SaveStateList(); } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index b0c281a12b..ba6c326db8 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -21,9 +21,8 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { // Do these from run //Specify all default directories - const Common::FSNode gameDataDir(ConfMan.get("example")); - SearchMan.addSubDirectoryMatching(gameDataDir, "example2"); - + //const Common::FSNode gameDataDir(ConfMan.get("example")); + //SearchMan.addSubDirectoryMatching(gameDataDir, "example2"); DebugMan.addDebugChannel(kDMDebugExample, "example", "example desc"); // regiser random source @@ -55,6 +54,9 @@ Common::Error DMEngine::run() { // Run main loop debug("DMEngine:: start main loop"); + while (true) + debug("Run!"); + return Common::kNoError; } -- cgit v1.2.3 From 055e789d0461f881b13cb4fe6e3331b1872eb633 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Mon, 2 May 2016 20:58:55 +0200 Subject: DM: Create DisplayMan, add support parsing IMG0 files Add display manager named DisplayMan with functions: setUpScreens(), loadGraphics() (which loads graphics from the graphics.dat file), setPalette(..), loadIntoBitmap(..) which loads the requested image into a bitmap and blitToScreen(..) --- engines/dm/detection.cpp | 4 +- engines/dm/dm.cpp | 49 +++++++++++++----- engines/dm/dm.h | 3 ++ engines/dm/gfx.cpp | 126 +++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/gfx.h | 38 ++++++++++++++ engines/dm/module.mk | 3 +- 6 files changed, 207 insertions(+), 16 deletions(-) create mode 100644 engines/dm/gfx.cpp create mode 100644 engines/dm/gfx.h diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp index 443d2dba78..855d1284b9 100644 --- a/engines/dm/detection.cpp +++ b/engines/dm/detection.cpp @@ -15,8 +15,8 @@ static const ADGameDescription gameDescriptions[] = { { "dm", "Amiga 2.0v English", { - {"graphics.dat", 0, "6A2F135B53C2220F0251FA103E2A6E7E", 411960}, - {"Dungeon.dat", 0, "30028FB6A301ECB20127EF0B3AF32B05", 25006}, + {"graphics.dat", 0, "c2205f6225bde728417de29394f97d55", 411960}, + {"Dungeon.dat", 0, "43a213da8eda413541dd12f90ce202f6", 25006}, AD_LISTEND }, Common::EN_GRB, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index ba6c326db8..d6fc1f3d7d 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -1,16 +1,17 @@ #include "common/scummsys.h" +#include "common/system.h" -#include "common/config-manager.h" #include "common/debug.h" #include "common/debug-channels.h" #include "common/error.h" -#include "gui/EventRecorder.h" -#include "common/file.h" -#include "common/fs.h" #include "engines/util.h" +#include "engines/engine.h" +#include "graphics/palette.h" +#include "common/file.h" #include "dm/dm.h" +#include "dm/gfx.h" namespace DM { @@ -36,26 +37,48 @@ DMEngine::~DMEngine() { // dispose of resources delete _rnd; + delete _console; + delete _displayMan; // clear debug channels DebugMan.clearAllDebugChannels(); } Common::Error DMEngine::run() { - // Init graphics initGraphics(320, 200, false); - - // Create debug console (it requirese GFX to be inited) _console = new Console(this); + _displayMan = new DisplayMan(this); + _displayMan->setUpScreens(320, 200); + _displayMan->loadGraphics(); + + + byte *palette = new byte[256 * 3]; + for (int i = 0; i < 16; ++i) + palette[i * 3] = palette[i * 3 + 1] = palette[i * 3 + 2] = i * 16; + + _displayMan->setPalette(palette, 16); + + byte *buffer = new byte[320 * 200]; + for (int i = 0; i < 320 * 100; ++i) + buffer[i] = 4; + for (int i = 320 * 100; i < 320 * 200; ++i) + buffer[i] = 6; + + _system->copyRectToScreen(buffer, 320, 0, 0, 320, 200); + _system->updateScreen(); + + + uint16 width = _displayMan->getImageWidth(75); + uint16 height = _displayMan->getImageHeight(75); + byte *cleanByteImg0Data = new byte[width * height]; + _displayMan->loadIntoBitmap(75, cleanByteImg0Data); + _displayMan->blitToScreen(cleanByteImg0Data, width, height, 30, 30); - // Additional setup - debug("DMEngine::init"); - // Run main loop - debug("DMEngine:: start main loop"); + while (true) { + _displayMan->updateScreen(); + } - while (true) - debug("Run!"); return Common::kNoError; } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 79deb299da..6820640d18 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -9,6 +9,7 @@ namespace DM { class Console; +class DisplayMan; enum { // engine debug channels @@ -21,10 +22,12 @@ public: ~DMEngine(); virtual Common::Error run(); + Common::Error go(); private: Console *_console; Common::RandomSource *_rnd; + DisplayMan *_displayMan; }; class Console : public GUI::Debugger { diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp new file mode 100644 index 0000000000..53abbbfc76 --- /dev/null +++ b/engines/dm/gfx.cpp @@ -0,0 +1,126 @@ +#include "gfx.h" +#include "engines/util.h" +#include "common/system.h" +#include "common/file.h" +#include "graphics/palette.h" +#include "common/endian.h" + +using namespace DM; + +DisplayMan::DisplayMan(DMEngine *dmEngine) : + _vm(dmEngine), _currPalette(NULL), _screenWidth(0), _screenHeight(0), + _vgaBuffer(0), _itemCount(0), _indexBytePos(NULL), _compressedData(NULL) {} + +DisplayMan::~DisplayMan() { + delete[] _compressedData; + delete[] _indexBytePos; + delete[] _currPalette; +} + +void DisplayMan::setUpScreens(uint16 width, uint16 height) { + _currPalette = new byte[256 * 2]; + _screenWidth = width; + _screenHeight = height; + _vgaBuffer = new byte[_screenWidth * _screenHeight]; + memset(_vgaBuffer, 0, width * height); +} + +void DisplayMan::loadGraphics() { + Common::File f; + f.open("graphics.dat"); + + _itemCount = f.readUint16BE(); + _indexBytePos = new uint32[_itemCount + 1]; + _indexBytePos[0] = 0; + for (uint16 i = 1; i < _itemCount + 1; ++i) + _indexBytePos[i] = f.readUint16BE() + _indexBytePos[i - 1]; + + _compressedData = new uint8[_indexBytePos[_itemCount]]; + + f.seek(2 + _itemCount * 4); + for (uint32 i = 0; i < _indexBytePos[_itemCount]; ++i) + _compressedData[i] = f.readByte(); + + f.close(); +} + +void DisplayMan::setPalette(byte *buff, uint16 colorCount) { + memcpy(_currPalette, buff, sizeof(byte) * colorCount * 3); + _vm->_system->getPaletteManager()->setPalette(buff, 0, colorCount); +} + +#define TOBE2(byte1, byte2) ((((uint16)(byte1)) << 8) | (uint16)(byte2)) + +void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { + uint8 *data = _compressedData + _indexBytePos[index]; + uint16 width = TOBE2(data[0], data[1]); + uint16 height = TOBE2(data[2], data[3]); + uint16 nextByteIndex = 4; + for (uint16 k = 0; k < width * height;) { + uint8 nextByte = data[nextByteIndex++]; + uint8 nibble1 = (nextByte & 0xF0) >> 4; + uint8 nibble2 = (nextByte & 0x0F); + if (nibble1 <= 7) { + for (int j = 0; j < nibble1 + 1; ++j) + destBitmap[k++] = nibble2; + } else if (nibble1 == 0x8) { + uint8 byte1 = data[nextByteIndex++]; + for (int j = 0; j < byte1 + 1; ++j) + destBitmap[k++] = nibble2; + } else if (nibble1 == 0xC) { + uint16 word1 = TOBE2(data[nextByteIndex], data[nextByteIndex + 1]); + nextByteIndex += 2; + for (int j = 0; j < word1 + 1; ++j) + destBitmap[k++] = nibble2; + } else if (nibble1 == 0xB) { + uint8 byte1 = data[nextByteIndex++]; + for (int j = 0; j < byte1 + 1; ++j, ++k) + destBitmap[k] = destBitmap[k - width]; + destBitmap[k++] = nibble2; + } else if (nibble1 == 0xF) { + uint16 word1 = TOBE2(data[nextByteIndex], data[nextByteIndex + 1]); + nextByteIndex += 2; + for (int j = 0; j < word1 + 1; ++j, ++k) + destBitmap[k] = destBitmap[k - width]; + destBitmap[k++] = nibble2; + } else if (nibble1 == 9) { + uint8 byte1 = data[nextByteIndex++]; + if (byte1 % 2) + byte1++; + else + destBitmap[k++] = nibble2; + + for (int j = 0; j < byte1 / 2; ++j) { + uint8 byte2 = data[nextByteIndex++]; + destBitmap[k++] = byte2 & 0x0F; + destBitmap[k++] = (byte2 & 0xF0) >> 4; + } + } + } +} + +void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, uint16 destX, uint16 destY) { + for (uint16 y = 0; y < srcHeight; ++y) + memcpy(getCurrentVgaBuffer() + ((y + destY) * _screenWidth + destX), srcBitmap + y * srcWidth, srcWidth * sizeof(byte)); + +} + +void DisplayMan::updateScreen() { + _vm->_system->copyRectToScreen(_vgaBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight); + _vm->_system->updateScreen(); +} + +byte *DisplayMan::getCurrentVgaBuffer() { + return _vgaBuffer; +} + +uint16 DisplayMan::getImageWidth(uint16 index) { + uint8 *data = _compressedData + _indexBytePos[index]; + return TOBE2(data[0], data[1]); +} + +uint16 DisplayMan::getImageHeight(uint16 index) { + uint8 *data = _compressedData + _indexBytePos[index]; + return TOBE2(data[2], data[3]); +} + diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h new file mode 100644 index 0000000000..91cf7e1ca2 --- /dev/null +++ b/engines/dm/gfx.h @@ -0,0 +1,38 @@ +#ifndef GFX_H +#define GFX_H + +#include "common/scummsys.h" +#include "dm/dm.h" + +namespace DM { + +class DisplayMan { + DMEngine *_vm; + byte *_currPalette; + uint16 _screenWidth; + uint16 _screenHeight; + byte *_vgaBuffer; + uint16 _itemCount; + uint32 *_indexBytePos; + uint8 *_compressedData; + DisplayMan(const DMEngine &dmEngine); // no implementation on purpose + void operator=(const DisplayMan &rhs); // no implementation on purpose +public: + DisplayMan(DMEngine *dmEngine); + ~DisplayMan(); + void setUpScreens(uint16 width, uint16 height); + void loadGraphics(); + void setPalette(byte *buff, uint16 colorCount); + void loadIntoBitmap(uint16 index, byte *destBitmap); + uint16 getImageWidth(uint16 index); + uint16 getImageHeight(uint16 index); + void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, uint16 destX, uint16 destY); + byte *getCurrentVgaBuffer(); + void updateScreen(); +}; + +} + + + +#endif diff --git a/engines/dm/module.mk b/engines/dm/module.mk index 808b4e5c52..3fad4ee9f4 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -2,7 +2,8 @@ MODULE := engines/dm MODULE_OBJS := \ detection.o \ - dm.o + dm.o \ + gfx.o MODULE_DIRS += \ engines/dm -- cgit v1.2.3 From cdf377f7a7a43521403c38014bb1406b1ce15721 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Tue, 3 May 2016 17:55:04 +0200 Subject: DM: Add support for Dungeon.dat uncompression Add DungeonMan class with support for loading and uncompressing Dungeon.dat file into memory --- engines/dm/dm.cpp | 8 +++++- engines/dm/dm.h | 2 ++ engines/dm/dungeonman.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/dungeonman.h | 22 +++++++++++++++++ engines/dm/gfx.h | 2 +- 5 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 engines/dm/dungeonman.cpp create mode 100644 engines/dm/dungeonman.h diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index d6fc1f3d7d..61e68dfaa7 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -12,6 +12,7 @@ #include "dm/dm.h" #include "dm/gfx.h" +#include "dm/dungeonman.h" namespace DM { @@ -39,17 +40,23 @@ DMEngine::~DMEngine() { delete _rnd; delete _console; delete _displayMan; + delete _dungeonMan; // clear debug channels DebugMan.clearAllDebugChannels(); } + Common::Error DMEngine::run() { initGraphics(320, 200, false); _console = new Console(this); _displayMan = new DisplayMan(this); + _dungeonMan = new DungeonMan(this); _displayMan->setUpScreens(320, 200); _displayMan->loadGraphics(); + _dungeonMan->loadDungeonFile(); + + byte *palette = new byte[256 * 3]; @@ -79,7 +86,6 @@ Common::Error DMEngine::run() { _displayMan->updateScreen(); } - return Common::kNoError; } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 6820640d18..705939cc63 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -10,6 +10,7 @@ namespace DM { class Console; class DisplayMan; +class DungeonMan; enum { // engine debug channels @@ -28,6 +29,7 @@ private: Console *_console; Common::RandomSource *_rnd; DisplayMan *_displayMan; + DungeonMan *_dungeonMan; }; class Console : public GUI::Debugger { diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp new file mode 100644 index 0000000000..6ddf966eb9 --- /dev/null +++ b/engines/dm/dungeonman.cpp @@ -0,0 +1,62 @@ +#include "dungeonman.h" +#include "common/file.h" + + +namespace DM { +DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _dungeonDataSize(0), _dungeonData(NULL) {} +DungeonMan::~DungeonMan() { delete[] _dungeonData; } +void DungeonMan::loadDungeonFile() { + Common::File f; + f.open("Dungeon.dat"); + if (f.readUint16BE() == 0x8104) { + _dungeonDataSize = f.readUint32BE(); + _dungeonData = new byte[_dungeonDataSize]; + f.readUint16BE(); + byte common[4]; + for (uint16 i = 0; i < 4; ++i) + common[i] = f.readByte(); + byte lessCommon[16]; + for (uint16 i = 0; i < 16; ++i) + lessCommon[i] = f.readByte(); + + // start unpacking + uint32 uncompIndex = 0; + uint8 bitsUsedInWord = 0; + uint16 wordBuff = f.readUint16BE(); + uint8 bitsLeftInByte = 8; + byte byteBuff = f.readByte(); + while (uncompIndex < _dungeonDataSize) { + while (bitsUsedInWord != 0) { + uint8 shiftVal; + if (f.eos()) { + shiftVal = bitsUsedInWord; + wordBuff <<= shiftVal; + } else { + shiftVal = MIN(bitsLeftInByte, bitsUsedInWord); + wordBuff <<= shiftVal; + wordBuff |= (byteBuff >> (8 - shiftVal)); + byteBuff <<= shiftVal; + bitsLeftInByte -= shiftVal; + if (!bitsLeftInByte) { + byteBuff = f.readByte(); + bitsLeftInByte = 8; + } + } + bitsUsedInWord -= shiftVal; + } + if (((wordBuff >> 15) & 1) == 0) { + _dungeonData[uncompIndex++] = common[(wordBuff >> 13) & 3]; + bitsUsedInWord += 3; + } else if (((wordBuff >> 14) & 3) == 2) { + _dungeonData[uncompIndex++] = lessCommon[(wordBuff >> 10) & 15]; + bitsUsedInWord += 6; + } else if (((wordBuff >> 14) & 3) == 3) { + _dungeonData[uncompIndex++] = (wordBuff >> 6) & 255; + bitsUsedInWord += 10; + } + } + } + f.close(); +} + +} \ No newline at end of file diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h new file mode 100644 index 0000000000..b820bb2b58 --- /dev/null +++ b/engines/dm/dungeonman.h @@ -0,0 +1,22 @@ +#ifndef DUNGEONMAN_H +#define DUNGEONMAN_H + +#include "dm.h" + +namespace DM { + +class DungeonMan { + DMEngine *_vm; + uint32 _dungeonDataSize; + byte *_dungeonData; + DungeonMan(const DungeonMan &other); // no implementation on purpose + void operator=(const DungeonMan &rhs); // no implementation on purpose +public: + DungeonMan(DMEngine *dmEngine); + ~DungeonMan(); + void loadDungeonFile(); +}; + +} + +#endif diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 91cf7e1ca2..98d035be2c 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -15,7 +15,7 @@ class DisplayMan { uint16 _itemCount; uint32 *_indexBytePos; uint8 *_compressedData; - DisplayMan(const DMEngine &dmEngine); // no implementation on purpose + DisplayMan(const DisplayMan &other); // no implementation on purpose void operator=(const DisplayMan &rhs); // no implementation on purpose public: DisplayMan(DMEngine *dmEngine); -- cgit v1.2.3 From b7987d84c1de7c7f6c40b9995026009058d43ab3 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Wed, 4 May 2016 11:16:41 +0200 Subject: DM: Fix memory leak in dm.cpp and gfx.cpp --- engines/dm/dm.cpp | 4 ++++ engines/dm/gfx.cpp | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 61e68dfaa7..24ebfbfff6 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -86,6 +86,10 @@ Common::Error DMEngine::run() { _displayMan->updateScreen(); } + + delete[] buffer; + delete[] cleanByteImg0Data; + return Common::kNoError; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 53abbbfc76..577251cf21 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -15,10 +15,11 @@ DisplayMan::~DisplayMan() { delete[] _compressedData; delete[] _indexBytePos; delete[] _currPalette; + delete[] _vgaBuffer; } void DisplayMan::setUpScreens(uint16 width, uint16 height) { - _currPalette = new byte[256 * 2]; + _currPalette = new byte[256 * 3]; _screenWidth = width; _screenHeight = height; _vgaBuffer = new byte[_screenWidth * _screenHeight]; -- cgit v1.2.3 From 66c55db9f056a1c5c74e82e84650ac7fbbe4d899 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Wed, 4 May 2016 11:23:52 +0200 Subject: DM: Fix typos and whitespace --- engines/dm/dm.cpp | 2 +- engines/dm/dungeonman.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 24ebfbfff6..aac8336581 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -27,7 +27,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { //SearchMan.addSubDirectoryMatching(gameDataDir, "example2"); DebugMan.addDebugChannel(kDMDebugExample, "example", "example desc"); - // regiser random source + // register random source _rnd = new Common::RandomSource("quux"); debug("DMEngine::DMEngine"); diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 6ddf966eb9..292ca023e7 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -4,7 +4,11 @@ namespace DM { DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _dungeonDataSize(0), _dungeonData(NULL) {} -DungeonMan::~DungeonMan() { delete[] _dungeonData; } + +DungeonMan::~DungeonMan() { + delete[] _dungeonData; +} + void DungeonMan::loadDungeonFile() { Common::File f; f.open("Dungeon.dat"); -- cgit v1.2.3 From 4a8b34e993729dd90d12b1717977d8c4945e9325 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Wed, 4 May 2016 12:50:06 +0200 Subject: DM: Add the original palettes, edit palette loading accordingly --- engines/dm/dm.cpp | 31 +++++++------------------------ engines/dm/dm.h | 1 - engines/dm/gfx.cpp | 32 +++++++++++++++++++++++++------- engines/dm/gfx.h | 18 ++++++++++++++++-- 4 files changed, 48 insertions(+), 34 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index aac8336581..53ed3de574 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -16,6 +16,7 @@ namespace DM { + DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { // Do not load data files // Do not initialize graphics here @@ -56,38 +57,20 @@ Common::Error DMEngine::run() { _displayMan->loadGraphics(); _dungeonMan->loadDungeonFile(); + _displayMan->loadPalette(palCredits); - - - byte *palette = new byte[256 * 3]; - for (int i = 0; i < 16; ++i) - palette[i * 3] = palette[i * 3 + 1] = palette[i * 3 + 2] = i * 16; - - _displayMan->setPalette(palette, 16); - - byte *buffer = new byte[320 * 200]; - for (int i = 0; i < 320 * 100; ++i) - buffer[i] = 4; - for (int i = 320 * 100; i < 320 * 200; ++i) - buffer[i] = 6; - - _system->copyRectToScreen(buffer, 320, 0, 0, 320, 200); - _system->updateScreen(); - - - uint16 width = _displayMan->getImageWidth(75); - uint16 height = _displayMan->getImageHeight(75); + uint16 width = _displayMan->getImageWidth(1); + uint16 height = _displayMan->getImageHeight(1); byte *cleanByteImg0Data = new byte[width * height]; - _displayMan->loadIntoBitmap(75, cleanByteImg0Data); - _displayMan->blitToScreen(cleanByteImg0Data, width, height, 30, 30); + _displayMan->loadIntoBitmap(1, cleanByteImg0Data); + _displayMan->blitToScreen(cleanByteImg0Data, width, height, 0, 0); while (true) { _displayMan->updateScreen(); + _system->delayMillis(10); } - - delete[] buffer; delete[] cleanByteImg0Data; return Common::kNoError; diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 705939cc63..35f6493129 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -23,7 +23,6 @@ public: ~DMEngine(); virtual Common::Error run(); - Common::Error go(); private: Console *_console; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 577251cf21..846f4bc931 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -7,21 +7,35 @@ using namespace DM; +// this is for the Amiga version, later when we add support for more versions, this will have to be renamed +uint16 dmPalettes[10][16] = { + {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}, + {0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF}, + {0x006, 0x0AA, 0xFF6, 0x840, 0xFF8, 0x000, 0x080, 0xA00, 0xC84, 0xFFA, 0xF84, 0xFC0, 0xFA0, 0x000, 0x620, 0xFFC}, + {0x000, 0x666, 0x888, 0x840, 0xCA8, 0x0C0, 0x080, 0x0A0, 0x864, 0xF00, 0xA86, 0x642, 0x444, 0xAAA, 0x620, 0xFFF}, + {0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x444, 0xAAA, 0x00F, 0xFFF}, + {0x000, 0x444, 0x666, 0x620, 0x0CC, 0x820, 0x060, 0x0A0, 0xC00, 0x000, 0x000, 0xFC0, 0x222, 0x888, 0x00C, 0xCCC}, + {0x000, 0x222, 0x444, 0x420, 0x0CC, 0x620, 0x040, 0x080, 0xA00, 0x000, 0x000, 0xFA0, 0x000, 0x666, 0x00A, 0xAAA}, + {0x000, 0x000, 0x222, 0x200, 0x0CC, 0x420, 0x020, 0x060, 0x800, 0x000, 0x000, 0xC80, 0x000, 0x444, 0x008, 0x888}, + {0x000, 0x000, 0x000, 0x000, 0x0CC, 0x200, 0x000, 0x040, 0x600, 0x000, 0x000, 0xA60, 0x000, 0x222, 0x006, 0x666}, + {0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444} +}; + + DisplayMan::DisplayMan(DMEngine *dmEngine) : - _vm(dmEngine), _currPalette(NULL), _screenWidth(0), _screenHeight(0), + _vm(dmEngine), _currPalette(palSwoosh), _screenWidth(0), _screenHeight(0), _vgaBuffer(0), _itemCount(0), _indexBytePos(NULL), _compressedData(NULL) {} DisplayMan::~DisplayMan() { delete[] _compressedData; delete[] _indexBytePos; - delete[] _currPalette; delete[] _vgaBuffer; } void DisplayMan::setUpScreens(uint16 width, uint16 height) { - _currPalette = new byte[256 * 3]; _screenWidth = width; _screenHeight = height; + loadPalette(palSwoosh); _vgaBuffer = new byte[_screenWidth * _screenHeight]; memset(_vgaBuffer, 0, width * height); } @@ -45,9 +59,14 @@ void DisplayMan::loadGraphics() { f.close(); } -void DisplayMan::setPalette(byte *buff, uint16 colorCount) { - memcpy(_currPalette, buff, sizeof(byte) * colorCount * 3); - _vm->_system->getPaletteManager()->setPalette(buff, 0, colorCount); +void DisplayMan::loadPalette(dmPaletteEnum palette) { + byte colorPalette[16 * 3]; + for (int i = 0; i < 16; ++i) { + colorPalette[i * 3] = (dmPalettes[palette][i] >> 8) * (256 / 16); + colorPalette[i * 3 + 1] = (dmPalettes[palette][i] >> 4) * (256 / 16); + colorPalette[i * 3 + 2] = dmPalettes[palette][i] * (256 / 16); + } + _vm->_system->getPaletteManager()->setPalette(colorPalette, 0, 16); } #define TOBE2(byte1, byte2) ((((uint16)(byte1)) << 8) | (uint16)(byte2)) @@ -103,7 +122,6 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, uint16 destX, uint16 destY) { for (uint16 y = 0; y < srcHeight; ++y) memcpy(getCurrentVgaBuffer() + ((y + destY) * _screenWidth + destX), srcBitmap + y * srcWidth, srcWidth * sizeof(byte)); - } void DisplayMan::updateScreen() { diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 98d035be2c..acdabfa77c 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -6,9 +6,23 @@ namespace DM { +enum dmPaletteEnum { + palSwoosh = 0, + palMousePointer = 1, + palCredits = 2, + palEntrance = 3, + palDungeonView0 = 4, + palDungeonView1 = 5, + palDungeonView2 = 6, + palDungeonView3 = 7, + palDungeonView4 = 8, + palDungeonView5 = 9, +}; + + class DisplayMan { DMEngine *_vm; - byte *_currPalette; + dmPaletteEnum _currPalette; uint16 _screenWidth; uint16 _screenHeight; byte *_vgaBuffer; @@ -22,7 +36,7 @@ public: ~DisplayMan(); void setUpScreens(uint16 width, uint16 height); void loadGraphics(); - void setPalette(byte *buff, uint16 colorCount); + void loadPalette(dmPaletteEnum palette); void loadIntoBitmap(uint16 index, byte *destBitmap); uint16 getImageWidth(uint16 index); uint16 getImageHeight(uint16 index); -- cgit v1.2.3 From 77cd7df08d31aecaae7390f7f12151f82e47dbac Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Thu, 5 May 2016 18:11:11 +0200 Subject: DM: Add support for drawing portions of bitmaps Create Frame structure and drawFrame(..) convenience method, also DisplayMan unpacks all the bitmaps with unpackGraphics() --- engines/dm/dm.cpp | 5 ++- engines/dm/gfx.cpp | 98 +++++++++++++++++++++++++++++++++++++++++++++--------- engines/dm/gfx.h | 20 +++++++++-- 3 files changed, 103 insertions(+), 20 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 53ed3de574..e30aaced2c 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -57,6 +57,7 @@ Common::Error DMEngine::run() { _displayMan->loadGraphics(); _dungeonMan->loadDungeonFile(); + /* _displayMan->loadPalette(palCredits); uint16 width = _displayMan->getImageWidth(1); @@ -64,14 +65,16 @@ Common::Error DMEngine::run() { byte *cleanByteImg0Data = new byte[width * height]; _displayMan->loadIntoBitmap(1, cleanByteImg0Data); _displayMan->blitToScreen(cleanByteImg0Data, width, height, 0, 0); + delete[] cleanByteImg0Data; + */ while (true) { + _displayMan->drawDungeon(); _displayMan->updateScreen(); _system->delayMillis(10); } - delete[] cleanByteImg0Data; return Common::kNoError; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 846f4bc931..52cc787596 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -5,7 +5,8 @@ #include "graphics/palette.h" #include "common/endian.h" -using namespace DM; + +namespace DM { // this is for the Amiga version, later when we add support for more versions, this will have to be renamed uint16 dmPalettes[10][16] = { @@ -21,15 +22,36 @@ uint16 dmPalettes[10][16] = { {0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444} }; +enum GraphicIndice { + FloorGraphIndice = 75, + CeilingGraphIndice = 76 +}; + +struct Frame { + /* this might have to be removed, depends on if the game uses frames with multiple bitmaps + If so, then GraphIndice enum will have to be moved to be available from outside gfx.cpp*/ + GraphicIndice graphIndice; + // srcWidth and srcHeight (present in the original sources) is redundant here, can be deduced from gaphicsIndice + uint16 srcFromX, srcToX, srcFromY, srcToY; + uint16 destX, destY; +}; + +Frame ceilingFrame = {CeilingGraphIndice, 0, 223, 0, 28, 0, 0}; + +} + +using namespace DM; DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine), _currPalette(palSwoosh), _screenWidth(0), _screenHeight(0), - _vgaBuffer(0), _itemCount(0), _indexBytePos(NULL), _compressedData(NULL) {} + _vgaBuffer(NULL), _itemCount(0), _packedItemPos(NULL), _packedBitmaps(NULL), + _unpackedBitmaps(NULL) {} DisplayMan::~DisplayMan() { - delete[] _compressedData; - delete[] _indexBytePos; + delete[] _packedBitmaps; + delete[] _packedItemPos; delete[] _vgaBuffer; + delete[] _unpackedBitmaps; } void DisplayMan::setUpScreens(uint16 width, uint16 height) { @@ -45,21 +67,47 @@ void DisplayMan::loadGraphics() { f.open("graphics.dat"); _itemCount = f.readUint16BE(); - _indexBytePos = new uint32[_itemCount + 1]; - _indexBytePos[0] = 0; + _packedItemPos = new uint32[_itemCount + 1]; + _packedItemPos[0] = 0; for (uint16 i = 1; i < _itemCount + 1; ++i) - _indexBytePos[i] = f.readUint16BE() + _indexBytePos[i - 1]; + _packedItemPos[i] = f.readUint16BE() + _packedItemPos[i - 1]; - _compressedData = new uint8[_indexBytePos[_itemCount]]; + _packedBitmaps = new uint8[_packedItemPos[_itemCount]]; f.seek(2 + _itemCount * 4); - for (uint32 i = 0; i < _indexBytePos[_itemCount]; ++i) - _compressedData[i] = f.readByte(); + for (uint32 i = 0; i < _packedItemPos[_itemCount]; ++i) + _packedBitmaps[i] = f.readByte(); f.close(); + + unpackGraphics(); +} + +void DisplayMan::unpackGraphics() { + uint32 unpackedBitmapsSize = 0; + for (uint16 i = 0; i <= 20; ++i) + unpackedBitmapsSize += getImageWidth(i) * getImageHeight(i); + for (uint16 i = 22; i <= 532; ++i) + unpackedBitmapsSize += getImageWidth(i) * getImageHeight(i); + _unpackedBitmaps = new byte*[533]; + // graphics items go from 0-20 and 22-532 inclusive, _unpackedItemPos 21 and 22 are there for indexing convenience + _unpackedBitmaps[0] = new byte[unpackedBitmapsSize]; + loadIntoBitmap(0, _unpackedBitmaps[0]); + for (uint16 i = 1; i <= 20; ++i) { + _unpackedBitmaps[i] = _unpackedBitmaps[i - 1] + getImageWidth(i - 1) * getImageHeight(i - 1); + loadIntoBitmap(i, _unpackedBitmaps[i]); + } + _unpackedBitmaps[22] = _unpackedBitmaps[20] + getImageWidth(20) * getImageHeight(20); + for (uint16 i = 23; i < 533; ++i) { + _unpackedBitmaps[i] = _unpackedBitmaps[i - 1] + getImageWidth(i - 1) * getImageHeight(i - 1); + loadIntoBitmap(i, _unpackedBitmaps[i]); + } } void DisplayMan::loadPalette(dmPaletteEnum palette) { + if (_currPalette == palette) + return; + byte colorPalette[16 * 3]; for (int i = 0; i < 16; ++i) { colorPalette[i * 3] = (dmPalettes[palette][i] >> 8) * (256 / 16); @@ -67,12 +115,13 @@ void DisplayMan::loadPalette(dmPaletteEnum palette) { colorPalette[i * 3 + 2] = dmPalettes[palette][i] * (256 / 16); } _vm->_system->getPaletteManager()->setPalette(colorPalette, 0, 16); + _currPalette = palette; } #define TOBE2(byte1, byte2) ((((uint16)(byte1)) << 8) | (uint16)(byte2)) void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { - uint8 *data = _compressedData + _indexBytePos[index]; + uint8 *data = _packedBitmaps + _packedItemPos[index]; uint16 width = TOBE2(data[0], data[1]); uint16 height = TOBE2(data[2], data[3]); uint16 nextByteIndex = 4; @@ -119,9 +168,18 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { } } -void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, uint16 destX, uint16 destY) { - for (uint16 y = 0; y < srcHeight; ++y) - memcpy(getCurrentVgaBuffer() + ((y + destY) * _screenWidth + destX), srcBitmap + y * srcWidth, srcWidth * sizeof(byte)); +void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, + int16 srcWidth, uint16 destX, uint16 destY, + byte *destBitmap, uint16 destWidth) { + for (uint16 y = 0; y < srcToY - srcFromY; ++y) + memcpy(destBitmap + destWidth * (y + destY) + destX, + srcBitmap + srcWidth * (y + srcFromY) + srcFromX, + sizeof(byte) * (srcToX - srcFromX)); +} + +void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, + int16 srcWidth, uint16 destX, uint16 destY) { + blitToBitmap(srcBitmap, srcFromX, srcToX, srcFromY, srcToY, srcWidth, destX, destY, getCurrentVgaBuffer(), _screenWidth); } void DisplayMan::updateScreen() { @@ -134,12 +192,20 @@ byte *DisplayMan::getCurrentVgaBuffer() { } uint16 DisplayMan::getImageWidth(uint16 index) { - uint8 *data = _compressedData + _indexBytePos[index]; + byte *data = _packedBitmaps + _packedItemPos[index]; return TOBE2(data[0], data[1]); } uint16 DisplayMan::getImageHeight(uint16 index) { - uint8 *data = _compressedData + _indexBytePos[index]; + uint8 *data = _packedBitmaps + _packedItemPos[index]; return TOBE2(data[2], data[3]); } +void DisplayMan::drawFrame(Frame &f) { + blitToScreen(_unpackedBitmaps[f.graphIndice], f.srcFromX, f.srcToX, f.srcFromY, f.srcToY, getImageWidth(f.graphIndice), f.destX, f.destY); +} + +void DisplayMan::drawDungeon() { + loadPalette(palDungeonView0); + drawFrame(ceilingFrame); +} \ No newline at end of file diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index acdabfa77c..f52381e3a4 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -6,6 +6,8 @@ namespace DM { +struct Frame; + enum dmPaletteEnum { palSwoosh = 0, palMousePointer = 1, @@ -27,22 +29,34 @@ class DisplayMan { uint16 _screenHeight; byte *_vgaBuffer; uint16 _itemCount; - uint32 *_indexBytePos; - uint8 *_compressedData; + // TODO: will probably be redundant + uint32 *_packedItemPos; + // TODO: will probably be reundant + byte *_packedBitmaps; // TODO: this doesn't not contaion graphics exclusively, will have to be moved DisplayMan(const DisplayMan &other); // no implementation on purpose void operator=(const DisplayMan &rhs); // no implementation on purpose + + + byte **_unpackedBitmaps; + void unpackGraphics(); + void drawFrame(Frame &f); public: DisplayMan(DMEngine *dmEngine); ~DisplayMan(); void setUpScreens(uint16 width, uint16 height); void loadGraphics(); void loadPalette(dmPaletteEnum palette); + // TODO: will probably be redundant with public visibility void loadIntoBitmap(uint16 index, byte *destBitmap); uint16 getImageWidth(uint16 index); uint16 getImageHeight(uint16 index); - void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, uint16 destX, uint16 destY); + void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, + int16 srcWidth, uint16 destX, uint16 destY, byte *destBitmap, uint16 destWidth); + inline void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, + int16 srcWidth, uint16 destX, uint16 destY); byte *getCurrentVgaBuffer(); void updateScreen(); + void drawDungeon(); }; } -- cgit v1.2.3 From cb2bb82b32ade022eb626c6b8cc580abc5b9df8d Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Thu, 5 May 2016 18:36:02 +0200 Subject: DM: Add support for transparency in blitting --- engines/dm/gfx.cpp | 20 ++++++++++++-------- engines/dm/gfx.h | 23 +++++++++++++++++++++-- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 52cc787596..e3faf945f8 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -22,6 +22,7 @@ uint16 dmPalettes[10][16] = { {0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444} }; + enum GraphicIndice { FloorGraphIndice = 75, CeilingGraphIndice = 76 @@ -34,9 +35,10 @@ struct Frame { // srcWidth and srcHeight (present in the original sources) is redundant here, can be deduced from gaphicsIndice uint16 srcFromX, srcToX, srcFromY, srcToY; uint16 destX, destY; + Color transparent; }; -Frame ceilingFrame = {CeilingGraphIndice, 0, 223, 0, 28, 0, 0}; +Frame ceilingFrame = {CeilingGraphIndice, 0, 223, 0, 28, 0, 0, colorFlesh}; } @@ -170,16 +172,18 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, int16 srcWidth, uint16 destX, uint16 destY, - byte *destBitmap, uint16 destWidth) { + byte *destBitmap, uint16 destWidth, Color transparent) { for (uint16 y = 0; y < srcToY - srcFromY; ++y) - memcpy(destBitmap + destWidth * (y + destY) + destX, - srcBitmap + srcWidth * (y + srcFromY) + srcFromX, - sizeof(byte) * (srcToX - srcFromX)); + for (uint16 x = 0; x < srcToX - srcFromX; ++x) { + byte srcPixel = srcBitmap[srcWidth*(y + srcFromY) + srcFromX + x]; + if (srcPixel != transparent) + destBitmap[destWidth * (y + destY) + destX + x] = srcPixel; + } } void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, - int16 srcWidth, uint16 destX, uint16 destY) { - blitToBitmap(srcBitmap, srcFromX, srcToX, srcFromY, srcToY, srcWidth, destX, destY, getCurrentVgaBuffer(), _screenWidth); + int16 srcWidth, uint16 destX, uint16 destY, Color transparent) { + blitToBitmap(srcBitmap, srcFromX, srcToX, srcFromY, srcToY, srcWidth, destX, destY, getCurrentVgaBuffer(), _screenWidth, transparent); } void DisplayMan::updateScreen() { @@ -202,7 +206,7 @@ uint16 DisplayMan::getImageHeight(uint16 index) { } void DisplayMan::drawFrame(Frame &f) { - blitToScreen(_unpackedBitmaps[f.graphIndice], f.srcFromX, f.srcToX, f.srcFromY, f.srcToY, getImageWidth(f.graphIndice), f.destX, f.destY); + blitToScreen(_unpackedBitmaps[f.graphIndice], f.srcFromX, f.srcToX, f.srcFromY, f.srcToY, getImageWidth(f.graphIndice), f.destX, f.destY, f.transparent); } void DisplayMan::drawDungeon() { diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index f52381e3a4..3ecffb1aba 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -7,6 +7,25 @@ namespace DM { struct Frame; +enum Color { + colorNoTransparency = 255, + colorBlack = 0, + colorDarkGary = 1, + colorLightGray = 2, + colorDarkBrown = 3, + colorCyan = 4, + colorLightBrown = 5, + colorDarkGreen = 6, + colorLightGreen = 7, + colorRed = 8, + colorGold = 9, + colorFlesh = 10, + colorYellow = 11, + colorDarkestGray = 12, + colorLightestGray = 13, + colorBlue = 14, + colorWhite = 15 +}; enum dmPaletteEnum { palSwoosh = 0, @@ -51,9 +70,9 @@ public: uint16 getImageWidth(uint16 index); uint16 getImageHeight(uint16 index); void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, - int16 srcWidth, uint16 destX, uint16 destY, byte *destBitmap, uint16 destWidth); + int16 srcWidth, uint16 destX, uint16 destY, byte *destBitmap, uint16 destWidth, Color transparent = colorNoTransparency); inline void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, - int16 srcWidth, uint16 destX, uint16 destY); + int16 srcWidth, uint16 destX, uint16 destY, Color transparent = colorNoTransparency); byte *getCurrentVgaBuffer(); void updateScreen(); void drawDungeon(); -- cgit v1.2.3 From 18ff2e9940f584041798af670a07c381a02918aa Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Thu, 5 May 2016 19:49:26 +0200 Subject: DM: Refactor DisplayMan::DrawFrame and Frame POD --- engines/dm/dm.cpp | 4 ++-- engines/dm/gfx.cpp | 25 ++++++++++++++++--------- engines/dm/gfx.h | 6 ++++-- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index e30aaced2c..1909b7e84e 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -57,9 +57,9 @@ Common::Error DMEngine::run() { _displayMan->loadGraphics(); _dungeonMan->loadDungeonFile(); - /* _displayMan->loadPalette(palCredits); + /* uint16 width = _displayMan->getImageWidth(1); uint16 height = _displayMan->getImageHeight(1); byte *cleanByteImg0Data = new byte[width * height]; @@ -68,8 +68,8 @@ Common::Error DMEngine::run() { delete[] cleanByteImg0Data; */ - while (true) { + _displayMan->clearScreen(colorBlack); _displayMan->drawDungeon(); _displayMan->updateScreen(); _system->delayMillis(10); diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index e3faf945f8..f441214b82 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -29,16 +29,15 @@ enum GraphicIndice { }; struct Frame { - /* this might have to be removed, depends on if the game uses frames with multiple bitmaps - If so, then GraphIndice enum will have to be moved to be available from outside gfx.cpp*/ - GraphicIndice graphIndice; // srcWidth and srcHeight (present in the original sources) is redundant here, can be deduced from gaphicsIndice + // these coorinates are inclusive boundaries, when blitting you gotta add +1 to srcTo fields uint16 srcFromX, srcToX, srcFromY, srcToY; + uint16 srcWidth, srcHeight; uint16 destX, destY; - Color transparent; }; -Frame ceilingFrame = {CeilingGraphIndice, 0, 223, 0, 28, 0, 0, colorFlesh}; +Frame ceilingFrame = {0, 223, 0, 28, 224, 29, 0, 0}; +Frame floorFrame = {0, 223, 66, 135, 224, 70, 0, 0}; } @@ -61,7 +60,7 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) { _screenHeight = height; loadPalette(palSwoosh); _vgaBuffer = new byte[_screenWidth * _screenHeight]; - memset(_vgaBuffer, 0, width * height); + clearScreen(colorBlack); } void DisplayMan::loadGraphics() { @@ -205,11 +204,19 @@ uint16 DisplayMan::getImageHeight(uint16 index) { return TOBE2(data[2], data[3]); } -void DisplayMan::drawFrame(Frame &f) { - blitToScreen(_unpackedBitmaps[f.graphIndice], f.srcFromX, f.srcToX, f.srcFromY, f.srcToY, getImageWidth(f.graphIndice), f.destX, f.destY, f.transparent); +void DisplayMan::drawFrameToScreen(byte *bitmap, Frame &f, Color transparent) { + blitToScreen(bitmap, f.srcFromX, f.srcToX + 1, f.srcFromY, f.srcToY + 1, f.srcWidth, f.destX, f.destY, transparent); +} + +void DisplayMan::drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, byte *destBitmap, uint16 destWidth) { + blitToBitmap(bitmap, f.srcFromX, f.srcToX + 1, f.srcFromY, f.srcToY + 1, f.srcWidth, f.destX, f.destY, destBitmap, destWidth, transparent); } void DisplayMan::drawDungeon() { loadPalette(palDungeonView0); - drawFrame(ceilingFrame); + drawFrameToScreen(_unpackedBitmaps[CeilingGraphIndice], ceilingFrame, colorFlesh); +} + +void DisplayMan::clearScreen(Color color) { + memset(getCurrentVgaBuffer(), color, sizeof(byte) * _screenWidth * _screenHeight); } \ No newline at end of file diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 3ecffb1aba..e479c6cfc4 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -58,7 +58,8 @@ class DisplayMan { byte **_unpackedBitmaps; void unpackGraphics(); - void drawFrame(Frame &f); + inline void drawFrameToScreen(byte *bitmap, Frame &f, Color transparent); + inline void drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, byte *destBitmap, uint16 destWidth); public: DisplayMan(DMEngine *dmEngine); ~DisplayMan(); @@ -72,10 +73,11 @@ public: void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, int16 srcWidth, uint16 destX, uint16 destY, byte *destBitmap, uint16 destWidth, Color transparent = colorNoTransparency); inline void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, - int16 srcWidth, uint16 destX, uint16 destY, Color transparent = colorNoTransparency); + int16 srcWidth, uint16 destX, uint16 destY, Color transparent = colorNoTransparency); byte *getCurrentVgaBuffer(); void updateScreen(); void drawDungeon(); + void clearScreen(Color color); }; } -- cgit v1.2.3 From c725fdec9eececc155d0c39bf905910100baeea0 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Thu, 5 May 2016 22:18:51 +0200 Subject: DM: Add horizontal and vertical bitmap flipping --- engines/dm/gfx.cpp | 38 ++++++++++++++++++++++++++++++++++++++ engines/dm/gfx.h | 11 +++++++---- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index f441214b82..761585cc26 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -180,6 +180,30 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, u } } + +void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) { + for(uint16 y = 0; y < height / 2; ++y) + for (uint16 x = 0; x < width; ++x) { + byte tmp; + tmp = bitmap[y*width + x]; + bitmap[y*width + x] = bitmap[y*width + width - 1 - x]; + bitmap[y*width + width - 1 - x] = tmp; + } +} + +void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) { + byte *tmp = new byte[width]; + + for (uint16 y = 0; y < height / 2; ++y) { + memcpy(tmp, bitmap + y * width, sizeof(byte) * width); + memcpy(bitmap + y * width, bitmap + (height - 1 - y) * width, sizeof(byte) * width); + memcpy(bitmap + y * width, tmp, sizeof(byte) * width); + memcpy(bitmap + (height - 1 - y) * width, tmp, sizeof(byte) * width); + } + + delete[] tmp; +} + void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, int16 srcWidth, uint16 destX, uint16 destY, Color transparent) { blitToBitmap(srcBitmap, srcFromX, srcToX, srcFromY, srcToY, srcWidth, destX, destY, getCurrentVgaBuffer(), _screenWidth, transparent); @@ -212,11 +236,25 @@ void DisplayMan::drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, by blitToBitmap(bitmap, f.srcFromX, f.srcToX + 1, f.srcFromY, f.srcToY + 1, f.srcWidth, f.destX, f.destY, destBitmap, destWidth, transparent); } + void DisplayMan::drawDungeon() { loadPalette(palDungeonView0); + drawFrameToScreen(_unpackedBitmaps[CeilingGraphIndice], ceilingFrame, colorFlesh); + + byte *tmpBitmap = new byte[305 * 111]; // because original source reasons + clearBitmap(tmpBitmap, 111, 305, colorBlack); + blitToBitmap(_unpackedBitmaps[FloorGraphIndice], 0, getImageWidth(FloorGraphIndice), 0, getImageHeight(FloorGraphIndice), getImageWidth(FloorGraphIndice), 0, 0, tmpBitmap, 305); + flipBitmapHorizontal(tmpBitmap, 305, 111); + drawFrameToScreen(tmpBitmap, floorFrame, colorFlesh); + + delete[] tmpBitmap; } void DisplayMan::clearScreen(Color color) { memset(getCurrentVgaBuffer(), color, sizeof(byte) * _screenWidth * _screenHeight); +} + +void DisplayMan::clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color) { + memset(bitmap, color, sizeof(byte) * width * height); } \ No newline at end of file diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index e479c6cfc4..39cfff9783 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -58,8 +58,8 @@ class DisplayMan { byte **_unpackedBitmaps; void unpackGraphics(); - inline void drawFrameToScreen(byte *bitmap, Frame &f, Color transparent); - inline void drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, byte *destBitmap, uint16 destWidth); + void drawFrameToScreen(byte *bitmap, Frame &f, Color transparent); + void drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, byte *destBitmap, uint16 destWidth); public: DisplayMan(DMEngine *dmEngine); ~DisplayMan(); @@ -72,8 +72,11 @@ public: uint16 getImageHeight(uint16 index); void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, int16 srcWidth, uint16 destX, uint16 destY, byte *destBitmap, uint16 destWidth, Color transparent = colorNoTransparency); - inline void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, - int16 srcWidth, uint16 destX, uint16 destY, Color transparent = colorNoTransparency); + void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, + int16 srcWidth, uint16 destX, uint16 destY, Color transparent = colorNoTransparency); + void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); + void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); + void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color); byte *getCurrentVgaBuffer(); void updateScreen(); void drawDungeon(); -- cgit v1.2.3 From 64371787e28fba114dc5dff27c5c7d61bb2bc293 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Fri, 6 May 2016 18:13:23 +0200 Subject: DM: Rewrite blitting methods, revise FRAME POD --- engines/dm/dm.cpp | 14 ++---- engines/dm/dm.h | 7 +++ engines/dm/gfx.cpp | 125 ++++++++++++++++++++++++++++++----------------------- engines/dm/gfx.h | 43 ++++++++++-------- 4 files changed, 105 insertions(+), 84 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 1909b7e84e..a1b8dc0fc5 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -59,20 +59,12 @@ Common::Error DMEngine::run() { _displayMan->loadPalette(palCredits); - /* - uint16 width = _displayMan->getImageWidth(1); - uint16 height = _displayMan->getImageHeight(1); - byte *cleanByteImg0Data = new byte[width * height]; - _displayMan->loadIntoBitmap(1, cleanByteImg0Data); - _displayMan->blitToScreen(cleanByteImg0Data, width, height, 0, 0); - delete[] cleanByteImg0Data; - */ - + uint16 i = 0; //TODO: testing, please delete me while (true) { _displayMan->clearScreen(colorBlack); - _displayMan->drawDungeon(); + _displayMan->drawDungeon(kDirNorth, i++, 0); _displayMan->updateScreen(); - _system->delayMillis(10); + _system->delayMillis(1000); //TODO: testing, please set me to 10 } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 35f6493129..22ef1ec072 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -8,6 +8,13 @@ namespace DM { +enum direction { + kDirNorth = 0, + kDirEast = 1, + kDirSouth = 2, + kDirWest = 3 +}; + class Console; class DisplayMan; class DungeonMan; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 761585cc26..afed9bbf03 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -8,7 +8,7 @@ namespace DM { -// this is for the Amiga version, later when we add support for more versions, this will have to be renamed +// TODO: this is ONLY for the Amiga version, name will have to be refactored uint16 dmPalettes[10][16] = { {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}, {0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF}, @@ -24,20 +24,19 @@ uint16 dmPalettes[10][16] = { enum GraphicIndice { - FloorGraphIndice = 75, - CeilingGraphIndice = 76 + floorIndice = 75, + ceilingIndice = 76 }; struct Frame { + // FIXME: these bundaries are inclusive, workaround by adding +1 in the drawFrame methods + uint16 destFromX, destToX, destFromY, destToY; // srcWidth and srcHeight (present in the original sources) is redundant here, can be deduced from gaphicsIndice - // these coorinates are inclusive boundaries, when blitting you gotta add +1 to srcTo fields - uint16 srcFromX, srcToX, srcFromY, srcToY; - uint16 srcWidth, srcHeight; - uint16 destX, destY; + uint16 srcX, srcY; }; -Frame ceilingFrame = {0, 223, 0, 28, 224, 29, 0, 0}; -Frame floorFrame = {0, 223, 66, 135, 224, 70, 0, 0}; +Frame ceilingFrame = {0, 223, 0, 28, 0, 0}; +Frame floorFrame = {0, 223, 66, 135, 0, 0}; } @@ -46,13 +45,13 @@ using namespace DM; DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine), _currPalette(palSwoosh), _screenWidth(0), _screenHeight(0), _vgaBuffer(NULL), _itemCount(0), _packedItemPos(NULL), _packedBitmaps(NULL), - _unpackedBitmaps(NULL) {} + _bitmaps(NULL) {} DisplayMan::~DisplayMan() { delete[] _packedBitmaps; delete[] _packedItemPos; delete[] _vgaBuffer; - delete[] _unpackedBitmaps; + delete[] _bitmaps; } void DisplayMan::setUpScreens(uint16 width, uint16 height) { @@ -87,21 +86,21 @@ void DisplayMan::loadGraphics() { void DisplayMan::unpackGraphics() { uint32 unpackedBitmapsSize = 0; for (uint16 i = 0; i <= 20; ++i) - unpackedBitmapsSize += getImageWidth(i) * getImageHeight(i); + unpackedBitmapsSize += width(i) * height(i); for (uint16 i = 22; i <= 532; ++i) - unpackedBitmapsSize += getImageWidth(i) * getImageHeight(i); - _unpackedBitmaps = new byte*[533]; + unpackedBitmapsSize += width(i) * height(i); // graphics items go from 0-20 and 22-532 inclusive, _unpackedItemPos 21 and 22 are there for indexing convenience - _unpackedBitmaps[0] = new byte[unpackedBitmapsSize]; - loadIntoBitmap(0, _unpackedBitmaps[0]); + _bitmaps = new byte*[533]; + _bitmaps[0] = new byte[unpackedBitmapsSize]; + loadIntoBitmap(0, _bitmaps[0]); for (uint16 i = 1; i <= 20; ++i) { - _unpackedBitmaps[i] = _unpackedBitmaps[i - 1] + getImageWidth(i - 1) * getImageHeight(i - 1); - loadIntoBitmap(i, _unpackedBitmaps[i]); + _bitmaps[i] = _bitmaps[i - 1] + width(i - 1) * height(i - 1); + loadIntoBitmap(i, _bitmaps[i]); } - _unpackedBitmaps[22] = _unpackedBitmaps[20] + getImageWidth(20) * getImageHeight(20); + _bitmaps[22] = _bitmaps[20] + width(20) * height(20); for (uint16 i = 23; i < 533; ++i) { - _unpackedBitmaps[i] = _unpackedBitmaps[i - 1] + getImageWidth(i - 1) * getImageHeight(i - 1); - loadIntoBitmap(i, _unpackedBitmaps[i]); + _bitmaps[i] = _bitmaps[i - 1] + width(i - 1) * height(i - 1); + loadIntoBitmap(i, _bitmaps[i]); } } @@ -169,21 +168,33 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { } } -void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, - int16 srcWidth, uint16 destX, uint16 destY, - byte *destBitmap, uint16 destWidth, Color transparent) { - for (uint16 y = 0; y < srcToY - srcFromY; ++y) - for (uint16 x = 0; x < srcToX - srcFromX; ++x) { - byte srcPixel = srcBitmap[srcWidth*(y + srcFromY) + srcFromX + x]; +void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, + byte *destBitmap, uint16 destWidth, + uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, + Color transparent) { + for (uint16 y = 0; y < destToY - destFromY; ++y) + for (uint16 x = 0; x < destToX - destFromX; ++x) { + byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x]; if (srcPixel != transparent) - destBitmap[destWidth * (y + destY) + destX + x] = srcPixel; + destBitmap[destWidth * (y + destFromY) + destFromX + x] = srcPixel; } } +void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, + uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, + Color transparent) { + blitToBitmap(srcBitmap, srcWidth, srcX, srcY, + getCurrentVgaBuffer(), _screenWidth, destFromX, destToX, destFromY, destToY, transparent); +} -void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) { - for(uint16 y = 0; y < height / 2; ++y) - for (uint16 x = 0; x < width; ++x) { +void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX, uint16 destY) { + for (uint16 y = 0; y < srcHeight; ++y) + memcpy(destBitmap + destWidth*(y + destY) + destX, srcBitmap + y * srcWidth, sizeof(byte)* srcWidth); +} + +void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) { + for (uint16 y = 0; y < height; ++y) + for (uint16 x = 0; x < width / 2; ++x) { byte tmp; tmp = bitmap[y*width + x]; bitmap[y*width + x] = bitmap[y*width + width - 1 - x]; @@ -191,23 +202,19 @@ void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) { } } -void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) { +void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) { byte *tmp = new byte[width]; for (uint16 y = 0; y < height / 2; ++y) { - memcpy(tmp, bitmap + y * width, sizeof(byte) * width); - memcpy(bitmap + y * width, bitmap + (height - 1 - y) * width, sizeof(byte) * width); - memcpy(bitmap + y * width, tmp, sizeof(byte) * width); - memcpy(bitmap + (height - 1 - y) * width, tmp, sizeof(byte) * width); + memcpy(tmp, bitmap + y * width, width); + memcpy(bitmap + y * width, bitmap + (height - 1 - y) * width, width); + memcpy(bitmap + (height - 1 - y) * width, tmp, width); } delete[] tmp; } -void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, - int16 srcWidth, uint16 destX, uint16 destY, Color transparent) { - blitToBitmap(srcBitmap, srcFromX, srcToX, srcFromY, srcToY, srcWidth, destX, destY, getCurrentVgaBuffer(), _screenWidth, transparent); -} + void DisplayMan::updateScreen() { _vm->_system->copyRectToScreen(_vgaBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight); @@ -218,35 +225,43 @@ byte *DisplayMan::getCurrentVgaBuffer() { return _vgaBuffer; } -uint16 DisplayMan::getImageWidth(uint16 index) { +uint16 DisplayMan::width(uint16 index) { byte *data = _packedBitmaps + _packedItemPos[index]; return TOBE2(data[0], data[1]); } -uint16 DisplayMan::getImageHeight(uint16 index) { +uint16 DisplayMan::height(uint16 index) { uint8 *data = _packedBitmaps + _packedItemPos[index]; return TOBE2(data[2], data[3]); } -void DisplayMan::drawFrameToScreen(byte *bitmap, Frame &f, Color transparent) { - blitToScreen(bitmap, f.srcFromX, f.srcToX + 1, f.srcFromY, f.srcToY + 1, f.srcWidth, f.destX, f.destY, transparent); +void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth) { + blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX + 1, f.destFromY, f.destToY + 1, colorFlesh); } -void DisplayMan::drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, byte *destBitmap, uint16 destWidth) { - blitToBitmap(bitmap, f.srcFromX, f.srcToX + 1, f.srcFromY, f.srcToY + 1, f.srcWidth, f.destX, f.destY, destBitmap, destWidth, transparent); -} -void DisplayMan::drawDungeon() { +void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) { loadPalette(palDungeonView0); + // TODO: this is a global variable, set from here + bool flippedWallAndFootprints = (posX + posY + dir) & 1; + + // NOTE: this can hold every bitmap, width and height is "flexible" + byte *tmpBitmap = new byte[305 * 111]; + clearBitmap(tmpBitmap, 305, 111, colorBlack); + + if (flippedWallAndFootprints) { + blitToBitmap(_bitmaps[floorIndice], width(floorIndice), height(floorIndice), tmpBitmap, width(floorIndice)); + flipBitmapHorizontal(tmpBitmap, width(floorIndice), height(floorIndice)); + drawWallSetBitmap(tmpBitmap, floorFrame, width(floorIndice)); + drawWallSetBitmap(_bitmaps[ceilingIndice], ceilingFrame, width(ceilingIndice)); + } else { + blitToBitmap(_bitmaps[ceilingIndice], width(ceilingIndice), height(ceilingIndice), tmpBitmap, width(ceilingIndice)); + flipBitmapHorizontal(tmpBitmap, width(ceilingIndice), height(ceilingIndice)); + drawWallSetBitmap(tmpBitmap, ceilingFrame, width(ceilingIndice)); + drawWallSetBitmap(_bitmaps[floorIndice], floorFrame, width(floorIndice)); + } - drawFrameToScreen(_unpackedBitmaps[CeilingGraphIndice], ceilingFrame, colorFlesh); - - byte *tmpBitmap = new byte[305 * 111]; // because original source reasons - clearBitmap(tmpBitmap, 111, 305, colorBlack); - blitToBitmap(_unpackedBitmaps[FloorGraphIndice], 0, getImageWidth(FloorGraphIndice), 0, getImageHeight(FloorGraphIndice), getImageWidth(FloorGraphIndice), 0, 0, tmpBitmap, 305); - flipBitmapHorizontal(tmpBitmap, 305, 111); - drawFrameToScreen(tmpBitmap, floorFrame, colorFlesh); delete[] tmpBitmap; } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 39cfff9783..f4d74abba3 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -41,6 +41,8 @@ enum dmPaletteEnum { }; + + class DisplayMan { DMEngine *_vm; dmPaletteEnum _currPalette; @@ -48,39 +50,44 @@ class DisplayMan { uint16 _screenHeight; byte *_vgaBuffer; uint16 _itemCount; - // TODO: will probably be redundant uint32 *_packedItemPos; - // TODO: will probably be reundant byte *_packedBitmaps; // TODO: this doesn't not contaion graphics exclusively, will have to be moved DisplayMan(const DisplayMan &other); // no implementation on purpose void operator=(const DisplayMan &rhs); // no implementation on purpose - - byte **_unpackedBitmaps; + byte **_bitmaps; + byte *getCurrentVgaBuffer(); + void loadIntoBitmap(uint16 index, byte *destBitmap); void unpackGraphics(); - void drawFrameToScreen(byte *bitmap, Frame &f, Color transparent); - void drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, byte *destBitmap, uint16 destWidth); + void drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth); public: DisplayMan(DMEngine *dmEngine); ~DisplayMan(); void setUpScreens(uint16 width, uint16 height); void loadGraphics(); void loadPalette(dmPaletteEnum palette); - // TODO: will probably be redundant with public visibility - void loadIntoBitmap(uint16 index, byte *destBitmap); - uint16 getImageWidth(uint16 index); - uint16 getImageHeight(uint16 index); - void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, - int16 srcWidth, uint16 destX, uint16 destY, byte *destBitmap, uint16 destWidth, Color transparent = colorNoTransparency); - void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, - int16 srcWidth, uint16 destX, uint16 destY, Color transparent = colorNoTransparency); - void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); + + /// Gives the width of an IMG0 type item + uint16 width(uint16 index); + /// Gives the height of an IMG1 type item + uint16 height(uint16 index); + + void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, + byte *destBitmap, uint16 destWidth, + uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, + Color transparent = colorNoTransparency); + void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0); + void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, + uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, + Color transparent = colorNoTransparency); + void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); + void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); + void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color); - byte *getCurrentVgaBuffer(); - void updateScreen(); - void drawDungeon(); void clearScreen(Color color); + void drawDungeon(direction dir, uint16 posX, uint16 posY); + void updateScreen(); }; } -- cgit v1.2.3 From 9823845c990bc23010c985706a26b491c2d0c21e Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Fri, 6 May 2016 18:20:30 +0200 Subject: DM: Fix constant and global variable names according to coding conventions --- engines/dm/dm.cpp | 4 ++-- engines/dm/gfx.cpp | 36 ++++++++++++++++----------------- engines/dm/gfx.h | 58 +++++++++++++++++++++++++++--------------------------- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index a1b8dc0fc5..8f6f294551 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -57,11 +57,11 @@ Common::Error DMEngine::run() { _displayMan->loadGraphics(); _dungeonMan->loadDungeonFile(); - _displayMan->loadPalette(palCredits); + _displayMan->loadPalette(kPalCredits); uint16 i = 0; //TODO: testing, please delete me while (true) { - _displayMan->clearScreen(colorBlack); + _displayMan->clearScreen(kColorBlack); _displayMan->drawDungeon(kDirNorth, i++, 0); _displayMan->updateScreen(); _system->delayMillis(1000); //TODO: testing, please set me to 10 diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index afed9bbf03..b8e3ad62d7 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -24,8 +24,8 @@ uint16 dmPalettes[10][16] = { enum GraphicIndice { - floorIndice = 75, - ceilingIndice = 76 + gFloorIndice = 75, + gCeilingIndice = 76 }; struct Frame { @@ -35,15 +35,15 @@ struct Frame { uint16 srcX, srcY; }; -Frame ceilingFrame = {0, 223, 0, 28, 0, 0}; -Frame floorFrame = {0, 223, 66, 135, 0, 0}; +Frame gCeilingFrame = {0, 223, 0, 28, 0, 0}; +Frame gFloorFrame = {0, 223, 66, 135, 0, 0}; } using namespace DM; DisplayMan::DisplayMan(DMEngine *dmEngine) : - _vm(dmEngine), _currPalette(palSwoosh), _screenWidth(0), _screenHeight(0), + _vm(dmEngine), _currPalette(kPalSwoosh), _screenWidth(0), _screenHeight(0), _vgaBuffer(NULL), _itemCount(0), _packedItemPos(NULL), _packedBitmaps(NULL), _bitmaps(NULL) {} @@ -57,9 +57,9 @@ DisplayMan::~DisplayMan() { void DisplayMan::setUpScreens(uint16 width, uint16 height) { _screenWidth = width; _screenHeight = height; - loadPalette(palSwoosh); + loadPalette(kPalSwoosh); _vgaBuffer = new byte[_screenWidth * _screenHeight]; - clearScreen(colorBlack); + clearScreen(kColorBlack); } void DisplayMan::loadGraphics() { @@ -236,30 +236,30 @@ uint16 DisplayMan::height(uint16 index) { } void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth) { - blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX + 1, f.destFromY, f.destToY + 1, colorFlesh); + blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX + 1, f.destFromY, f.destToY + 1, kColorFlesh); } void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) { - loadPalette(palDungeonView0); + loadPalette(kPalDungeonView0); // TODO: this is a global variable, set from here bool flippedWallAndFootprints = (posX + posY + dir) & 1; // NOTE: this can hold every bitmap, width and height is "flexible" byte *tmpBitmap = new byte[305 * 111]; - clearBitmap(tmpBitmap, 305, 111, colorBlack); + clearBitmap(tmpBitmap, 305, 111, kColorBlack); if (flippedWallAndFootprints) { - blitToBitmap(_bitmaps[floorIndice], width(floorIndice), height(floorIndice), tmpBitmap, width(floorIndice)); - flipBitmapHorizontal(tmpBitmap, width(floorIndice), height(floorIndice)); - drawWallSetBitmap(tmpBitmap, floorFrame, width(floorIndice)); - drawWallSetBitmap(_bitmaps[ceilingIndice], ceilingFrame, width(ceilingIndice)); + blitToBitmap(_bitmaps[gFloorIndice], width(gFloorIndice), height(gFloorIndice), tmpBitmap, width(gFloorIndice)); + flipBitmapHorizontal(tmpBitmap, width(gFloorIndice), height(gFloorIndice)); + drawWallSetBitmap(tmpBitmap, gFloorFrame, width(gFloorIndice)); + drawWallSetBitmap(_bitmaps[gCeilingIndice], gCeilingFrame, width(gCeilingIndice)); } else { - blitToBitmap(_bitmaps[ceilingIndice], width(ceilingIndice), height(ceilingIndice), tmpBitmap, width(ceilingIndice)); - flipBitmapHorizontal(tmpBitmap, width(ceilingIndice), height(ceilingIndice)); - drawWallSetBitmap(tmpBitmap, ceilingFrame, width(ceilingIndice)); - drawWallSetBitmap(_bitmaps[floorIndice], floorFrame, width(floorIndice)); + blitToBitmap(_bitmaps[gCeilingIndice], width(gCeilingIndice), height(gCeilingIndice), tmpBitmap, width(gCeilingIndice)); + flipBitmapHorizontal(tmpBitmap, width(gCeilingIndice), height(gCeilingIndice)); + drawWallSetBitmap(tmpBitmap, gCeilingFrame, width(gCeilingIndice)); + drawWallSetBitmap(_bitmaps[gFloorIndice], gFloorFrame, width(gFloorIndice)); } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index f4d74abba3..79a4afd426 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -8,36 +8,36 @@ namespace DM { struct Frame; enum Color { - colorNoTransparency = 255, - colorBlack = 0, - colorDarkGary = 1, - colorLightGray = 2, - colorDarkBrown = 3, - colorCyan = 4, - colorLightBrown = 5, - colorDarkGreen = 6, - colorLightGreen = 7, - colorRed = 8, - colorGold = 9, - colorFlesh = 10, - colorYellow = 11, - colorDarkestGray = 12, - colorLightestGray = 13, - colorBlue = 14, - colorWhite = 15 + kColorNoTransparency = 255, + kColorBlack = 0, + kColorDarkGary = 1, + kColorLightGray = 2, + kColorDarkBrown = 3, + kColorCyan = 4, + kColorLightBrown = 5, + kColorDarkGreen = 6, + kColorLightGreen = 7, + kColorRed = 8, + kColorGold = 9, + kColorFlesh = 10, + kColorYellow = 11, + kColorDarkestGray = 12, + kColorLightestGray = 13, + kColorBlue = 14, + kColorWhite = 15 }; enum dmPaletteEnum { - palSwoosh = 0, - palMousePointer = 1, - palCredits = 2, - palEntrance = 3, - palDungeonView0 = 4, - palDungeonView1 = 5, - palDungeonView2 = 6, - palDungeonView3 = 7, - palDungeonView4 = 8, - palDungeonView5 = 9, + kPalSwoosh = 0, + kPalMousePointer = 1, + kPalCredits = 2, + kPalEntrance = 3, + kPalDungeonView0 = 4, + kPalDungeonView1 = 5, + kPalDungeonView2 = 6, + kPalDungeonView3 = 7, + kPalDungeonView4 = 8, + kPalDungeonView5 = 9, }; @@ -75,11 +75,11 @@ public: void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte *destBitmap, uint16 destWidth, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - Color transparent = colorNoTransparency); + Color transparent = kColorNoTransparency); void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0); void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - Color transparent = colorNoTransparency); + Color transparent = kColorNoTransparency); void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); -- cgit v1.2.3 From 98a43792448fc937fa48dffd79adc0b1dda6cbf0 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Fri, 6 May 2016 18:25:23 +0200 Subject: DM: Delete TOBE2 macro, use READ_BE_UINT16 instead --- engines/dm/gfx.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index b8e3ad62d7..52e2e200c3 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -118,12 +118,11 @@ void DisplayMan::loadPalette(dmPaletteEnum palette) { _currPalette = palette; } -#define TOBE2(byte1, byte2) ((((uint16)(byte1)) << 8) | (uint16)(byte2)) void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { uint8 *data = _packedBitmaps + _packedItemPos[index]; - uint16 width = TOBE2(data[0], data[1]); - uint16 height = TOBE2(data[2], data[3]); + uint16 width = READ_BE_UINT16(data); + uint16 height = READ_BE_UINT16(data + 2); uint16 nextByteIndex = 4; for (uint16 k = 0; k < width * height;) { uint8 nextByte = data[nextByteIndex++]; @@ -137,7 +136,7 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { for (int j = 0; j < byte1 + 1; ++j) destBitmap[k++] = nibble2; } else if (nibble1 == 0xC) { - uint16 word1 = TOBE2(data[nextByteIndex], data[nextByteIndex + 1]); + uint16 word1 = READ_BE_UINT16(data + nextByteIndex); nextByteIndex += 2; for (int j = 0; j < word1 + 1; ++j) destBitmap[k++] = nibble2; @@ -147,7 +146,7 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { destBitmap[k] = destBitmap[k - width]; destBitmap[k++] = nibble2; } else if (nibble1 == 0xF) { - uint16 word1 = TOBE2(data[nextByteIndex], data[nextByteIndex + 1]); + uint16 word1 = READ_BE_UINT16(data + nextByteIndex); nextByteIndex += 2; for (int j = 0; j < word1 + 1; ++j, ++k) destBitmap[k] = destBitmap[k - width]; @@ -227,12 +226,12 @@ byte *DisplayMan::getCurrentVgaBuffer() { uint16 DisplayMan::width(uint16 index) { byte *data = _packedBitmaps + _packedItemPos[index]; - return TOBE2(data[0], data[1]); + return READ_BE_UINT16(data); } uint16 DisplayMan::height(uint16 index) { uint8 *data = _packedBitmaps + _packedItemPos[index]; - return TOBE2(data[2], data[3]); + return READ_BE_UINT16(data + 2); } void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth) { -- cgit v1.2.3 From a8434fc165266fb6a788618cdf334b01be53c25e Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Fri, 6 May 2016 18:55:09 +0200 Subject: DM: Add support for viewports with blitting --- engines/dm/gfx.cpp | 13 ++++++++----- engines/dm/gfx.h | 12 ++++++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 52e2e200c3..0ae3b251fd 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -38,6 +38,9 @@ struct Frame { Frame gCeilingFrame = {0, 223, 0, 28, 0, 0}; Frame gFloorFrame = {0, 223, 66, 135, 0, 0}; +extern Viewport gDefultViewPort = {0, 0}; +extern Viewport gDungeonViewport = {0, 64}; + } using namespace DM; @@ -170,20 +173,20 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte *destBitmap, uint16 destWidth, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - Color transparent) { + Color transparent, Viewport &destViewport) { for (uint16 y = 0; y < destToY - destFromY; ++y) for (uint16 x = 0; x < destToX - destFromX; ++x) { byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x]; if (srcPixel != transparent) - destBitmap[destWidth * (y + destFromY) + destFromX + x] = srcPixel; + destBitmap[destWidth * (y + destFromY + destViewport.posY) + destFromX + x + destViewport.posX] = srcPixel; } } void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - Color transparent) { + Color transparent, Viewport &viewport) { blitToBitmap(srcBitmap, srcWidth, srcX, srcY, - getCurrentVgaBuffer(), _screenWidth, destFromX, destToX, destFromY, destToY, transparent); + getCurrentVgaBuffer(), _screenWidth, destFromX, destToX, destFromY, destToY, transparent, viewport); } void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX, uint16 destY) { @@ -235,7 +238,7 @@ uint16 DisplayMan::height(uint16 index) { } void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth) { - blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX + 1, f.destFromY, f.destToY + 1, kColorFlesh); + blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX + 1, f.destFromY, f.destToY + 1, kColorFlesh, gDungeonViewport); } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 79a4afd426..34bb8cf991 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -7,6 +7,7 @@ namespace DM { struct Frame; + enum Color { kColorNoTransparency = 255, kColorBlack = 0, @@ -40,6 +41,13 @@ enum dmPaletteEnum { kPalDungeonView5 = 9, }; +struct Viewport { + // TODO: should probably add width and height, seems redundant right meow + uint16 posX, posY; +}; + +extern Viewport gDefultViewPort; +extern Viewport gDungeonViewport; @@ -75,11 +83,11 @@ public: void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte *destBitmap, uint16 destWidth, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - Color transparent = kColorNoTransparency); + Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort); void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0); void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - Color transparent = kColorNoTransparency); + Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort); void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); -- cgit v1.2.3 From 4f9182507afb365638b33341fb797d82c3a50df0 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Sat, 7 May 2016 20:53:35 +0200 Subject: DM: Implement Dungeon.dat file parsing, add relevant structures --- engines/dm/dungeonman.cpp | 227 ++++++++++++++++++++++++++++++++++++++++++++-- engines/dm/dungeonman.h | 125 ++++++++++++++++++++++++- engines/dm/gfx.cpp | 2 +- 3 files changed, 341 insertions(+), 13 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 292ca023e7..e33895db5a 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1,20 +1,49 @@ #include "dungeonman.h" #include "common/file.h" +#include "common/memstream.h" + namespace DM { -DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _dungeonDataSize(0), _dungeonData(NULL) {} +// TODO: refactor direction into a class +int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; +int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; + +void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } + + +} + +using namespace DM; + + +void DungeonMan::mapCoordsAfterRelMovement(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 &posX, uint16 &posY) { + posX += dirIntoStepCountEast[dir] * stepsForward; + posY += dirIntoStepCountNorth[dir] * stepsForward; + turnDirRight(dir); + posX += dirIntoStepCountEast[dir] * stepsRight; + posY += dirIntoStepCountNorth[dir] * stepsRight; +} + +DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) {} DungeonMan::~DungeonMan() { - delete[] _dungeonData; + delete[] _rawDunFileData; + delete[] _maps; + delete[] _dunData.dunMapsFirstColumnIndex; + delete[] _dunData.dunColumnsCumulativeSquareThingCount; + delete[] _dunData.squareFirstThings; + delete[] _dunData.dunTextData; + delete[] _dunData.dungeonMapData; } -void DungeonMan::loadDungeonFile() { +void DungeonMan::decompressDungeonFile() { Common::File f; f.open("Dungeon.dat"); if (f.readUint16BE() == 0x8104) { - _dungeonDataSize = f.readUint32BE(); - _dungeonData = new byte[_dungeonDataSize]; + _rawDunFileDataSize = f.readUint32BE(); + if (_rawDunFileData) delete[] _rawDunFileData; + _rawDunFileData = new byte[_rawDunFileDataSize]; f.readUint16BE(); byte common[4]; for (uint16 i = 0; i < 4; ++i) @@ -29,7 +58,7 @@ void DungeonMan::loadDungeonFile() { uint16 wordBuff = f.readUint16BE(); uint8 bitsLeftInByte = 8; byte byteBuff = f.readByte(); - while (uncompIndex < _dungeonDataSize) { + while (uncompIndex < _rawDunFileDataSize) { while (bitsUsedInWord != 0) { uint8 shiftVal; if (f.eos()) { @@ -49,18 +78,198 @@ void DungeonMan::loadDungeonFile() { bitsUsedInWord -= shiftVal; } if (((wordBuff >> 15) & 1) == 0) { - _dungeonData[uncompIndex++] = common[(wordBuff >> 13) & 3]; + _rawDunFileData[uncompIndex++] = common[(wordBuff >> 13) & 3]; bitsUsedInWord += 3; } else if (((wordBuff >> 14) & 3) == 2) { - _dungeonData[uncompIndex++] = lessCommon[(wordBuff >> 10) & 15]; + _rawDunFileData[uncompIndex++] = lessCommon[(wordBuff >> 10) & 15]; bitsUsedInWord += 6; } else if (((wordBuff >> 14) & 3) == 3) { - _dungeonData[uncompIndex++] = (wordBuff >> 6) & 255; + _rawDunFileData[uncompIndex++] = (wordBuff >> 6) & 255; bitsUsedInWord += 10; } } + } else { + // TODO: if the dungeon is uncompressed, read it here } f.close(); } + +uint8 gAdditionalThingCounts[16] = { + 0, /* Door */ + 0, /* Teleporter */ + 0, /* Text String */ + 0, /* Sensor */ + 75, /* Group */ + 100, /* Weapon */ + 120, /* Armour */ + 0, /* Scroll */ + 5, /* Potion */ + 0, /* Container */ + 140, /* Junk */ + 0, /* Unused */ + 0, /* Unused */ + 0, /* Unused */ + 60, /* Projectile */ + 50 /* Explosion */ +}; // @ G0236_auc_Graphic559_AdditionalThingCounts + +// TODO: refactor THINGS into classes +unsigned char gThingDataByteCount[16] = { + 4, /* Door */ + 6, /* Teleporter */ + 4, /* Text String */ + 8, /* Sensor */ + 16, /* Group */ + 4, /* Weapon */ + 4, /* Armour */ + 4, /* Scroll */ + 4, /* Potion */ + 8, /* Container */ + 4, /* Junk */ + 0, /* Unused */ + 0, /* Unused */ + 0, /* Unused */ + 8, /* Projectile */ + 4 /* Explosion */ +}; // @ G0235_auc_Graphic559_ThingDataByteCount + +const Thing Thing::specThingNone(0, 0, 0); + + +void DungeonMan::loadDungeonFile() { + if (_messages.newGame) + decompressDungeonFile(); + + Common::MemoryReadStream dunDataStream(_rawDunFileData, _fileHeader.rawMapDataSize, DisposeAfterUse::NO); + + // initialize _fileHeader + _fileHeader.dungeonId = _fileHeader.ornamentRandomSeed = dunDataStream.readUint16BE(); + _fileHeader.rawMapDataSize = dunDataStream.readUint16BE(); + _fileHeader.mapCount = dunDataStream.readByte(); + dunDataStream.readByte(); // discard 1 byte + _fileHeader.textDataWordCount = dunDataStream.readUint16BE(); + uint16 partyPosition = dunDataStream.readUint16BE(); + _fileHeader.partyStartDir = (direction)((partyPosition >> 10) & 3); + _fileHeader.partyStartPosY = (partyPosition >> 5) & 0x1F; + _fileHeader.partyStartPosX = (partyPosition >> 0) & 0x1F; + _fileHeader.squareFirstThingCount = dunDataStream.readUint16BE(); + for (uint16 i = 0; i < kThingTypeTotal; ++i) + _fileHeader.thingCounts[i] = dunDataStream.readUint16BE(); + + // init party position and mapindex + if (_messages.newGame) { + _dunData.partyDir = _fileHeader.partyStartDir; + _dunData.partyPosX = _fileHeader.partyStartPosX; + _dunData.partyPosY = _fileHeader.partyStartPosY; + _dunData.currMapIndex = 0; + } + + // load map data + if (_maps) delete[] _maps; + + _maps = new Map[_fileHeader.mapCount]; + for (uint16 i = 0; i < _fileHeader.mapCount; ++i) { + _maps[i].rawDunDataOffset = dunDataStream.readUint16BE(); + dunDataStream.readUint32BE(); // discard 4 bytes + _maps[i].offsetMapX = dunDataStream.readByte(); + _maps[i].offsetMapY = dunDataStream.readByte(); + + uint16 tmp = dunDataStream.readUint16BE(); + _maps[i].height = tmp >> 11; + _maps[i].width = (tmp >> 6) & 0x1F; + _maps[i].level = tmp & 0x1F; // Only used in DMII + + tmp = dunDataStream.readUint16BE(); + _maps[i].randFloorOrnCount = tmp >> 12; + _maps[i].floorOrnCount = (tmp >> 8) & 0xF; + _maps[i].randWallOrnCount = (tmp >> 4) & 0xF; + _maps[i].wallOrnCount = tmp & 0xF; + + tmp = dunDataStream.readUint16BE(); + _maps[i].difficulty = tmp >> 12; + _maps[i].creatureTypeCount = (tmp >> 4) & 0xF; + _maps[i].doorOrnCount = tmp & 0xF; + + tmp = dunDataStream.readUint16BE(); + _maps[i].doorSet1 = (tmp >> 12) & 0xF; + _maps[i].doorSet0 = (tmp >> 8) & 0xF; + _maps[i].wallSet = (tmp >> 4) & 0xF; + _maps[i].floorSet = tmp & 0xF; + } + + // TODO: ??? is this - begin + if (_dunData.dunMapsFirstColumnIndex) delete[] _dunData.dunMapsFirstColumnIndex; + + _dunData.dunMapsFirstColumnIndex = new uint16[_fileHeader.mapCount]; + uint16 columCount = 0; + for (uint16 i = 0; i < _fileHeader.mapCount; ++i) { + _dunData.dunMapsFirstColumnIndex[i] = columCount; + columCount += _maps[i].width + 1; + } + _dunData.dunColumCount = columCount; + // TODO: ??? is this - end + + if (_messages.newGame) // TODO: what purpose does this serve? + _fileHeader.squareFirstThingCount += 300; + + // TODO: ??? is this - begin + if (_dunData.dunColumnsCumulativeSquareThingCount) + delete[] _dunData.dunColumnsCumulativeSquareThingCount; + _dunData.dunColumnsCumulativeSquareThingCount = new uint16[columCount]; + for (uint16 i = 0; i < columCount; ++i) + _dunData.dunColumnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE(); + // TODO: ??? is this - end + + // TODO: ??? is this - begin + if (_dunData.squareFirstThings) + delete[] _dunData.squareFirstThings; + _dunData.squareFirstThings = new Thing[_fileHeader.squareFirstThingCount]; + for (uint16 i = 0; i < _fileHeader.squareFirstThingCount; ++i) { + uint16 tmp = dunDataStream.readUint16BE(); + _dunData.squareFirstThings[i].cell = tmp >> 14; + _dunData.squareFirstThings[i].type = (tmp >> 10) & 0xF; + _dunData.squareFirstThings[i].index = tmp & 0x1FF; + } + if (_messages.newGame) + for (uint16 i = 0; i < 300; ++i) + _dunData.squareFirstThings[i] = Thing::specThingNone; + + // TODO: ??? is this - end + + // load text data + if (_dunData.dunTextData) + delete[] _dunData.dunTextData; + _dunData.dunTextData = new uint16[_fileHeader.textDataWordCount]; + for (uint16 i = 0; i < _fileHeader.textDataWordCount; ++i) + _dunData.dunTextData[i] = dunDataStream.readUint16BE(); + + // TODO: ??? what this + if (_messages.newGame) + _dunData.eventMaximumCount = 100; + + // load 'Things' + // TODO: implement load things + // this is a temporary workaround to seek to raw map data + for (uint16 i = 0; i < kThingTypeTotal; ++i) + dunDataStream.skip(_fileHeader.thingCounts[i] * gThingDataByteCount[i]); + + _rawMapData = _rawDunFileData + dunDataStream.pos(); + + if (_dunData.dungeonMapData) delete[] _dunData.dungeonMapData; + + if (_messages.restartGameRequest) { + uint8 mapCount = _fileHeader.mapCount; + _dunData.dungeonMapData = new byte**[_dunData.dunColumCount + mapCount]; + byte **colFirstSquares = _dunData.dungeonMapData[mapCount]; + for (uint8 i = 0; i < mapCount; ++i) { + _dunData.dungeonMapData[i] = colFirstSquares; + byte *square = _rawMapData + _maps[i].rawDunDataOffset; + *colFirstSquares++ = square; + for (uint16 w = 0; w <= _maps[i].width; ++w) { + square += _maps[w].height + 1; + *colFirstSquares++ = square; + } + } + } } \ No newline at end of file diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index b820bb2b58..b26d56fc4c 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -5,16 +5,135 @@ namespace DM { +class DungeonMan; + +enum ThingType { + kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value + kDoorThingType = 0, + kTeleporterThingType = 1, + kTextstringType = 2, + kSensorThingType = 3, + kGroupThingType = 4, + kWeaponThingType = 5, + kArmourThingType = 6, + kScrollThingType = 7, + kPotionThingType = 8, + kContainerThingType = 9, + kJunkThingType = 10, + kProjectileThingType = 14, + kExplosionThingType = 15, + kThingTypeTotal = 16 // +1 than the last +}; // @ C[00..15]_THING_TYPE_... + + +class DungeonFileHeader { + friend class DungeonMan; + + uint16 dungeonId; // @ G0526_ui_DungeonID + // equal to dungeonId + uint16 ornamentRandomSeed; + uint32 rawMapDataSize; + uint8 mapCount; + uint16 textDataWordCount; + direction partyStartDir; // @ InitialPartyLocation + uint16 partyStartPosX, partyStartPosY; + uint16 squareFirstThingCount; // @ SquareFirstThingCount + uint16 thingCounts[16]; // @ ThingCount[16] +}; // @ DUNGEON_HEADER + +class Thing { + friend class DungeonMan; + + static const Thing specThingNone; + + Thing(uint8 cell, uint8 type, uint8 index) : cell(cell), type(type), index(index) {} + Thing() {} + + uint8 cell; + uint8 type; + uint8 index; +}; // @ THING + +class DungeonData { + friend class DungeonMan; + + direction partyDir; // @ G0308_i_PartyDirection + uint16 partyPosX; // @ G0306_i_PartyMapX + uint16 partyPosY; // @ G0307_i_PartyMapY + uint8 currMapIndex; // @ G0309_i_PartyMapIndex + + // I have no idea the heck is this + uint16 *dunMapsFirstColumnIndex = NULL; // @ G0281_pui_DungeonMapsFirstColumnIndex + uint16 dunColumCount; // @ G0282_ui_DungeonColumnCount + + // I have no idea the heck is this + uint16 *dunColumnsCumulativeSquareThingCount = NULL; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount + Thing *squareFirstThings = NULL; // @ G0283_pT_SquareFirstThings + uint16 *dunTextData = NULL; // @ G0260_pui_DungeonTextData + + byte *rawThingData[16] = {NULL}; // @ G0284_apuc_ThingData + + byte ***dungeonMapData = NULL; // @ G0279_pppuc_DungeonMapData + + uint16 eventMaximumCount; // @ G0369_ui_EventMaximumCount +}; // @ AGGREGATE + +struct Messages { + friend class DungeonMan; + +private: + bool newGame = true; // @ G0298_B_NewGame + bool restartGameRequest = false; // @ G0523_B_RestartGameRequested +}; // @ AGGREGATE + +class Map { + friend class DungeonMan; + + uint32 rawDunDataOffset; + uint8 offsetMapX, offsetMapY; + + uint8 level; // only used in DMII + uint8 width, height; // THESRE ARE INCLUSIVE BOUNDARIES + // orn short for Ornament + uint8 wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */ + uint8 randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */ + uint8 floorOrnCount; /* May be used in a Sensor on a Pit, open Fake Wall, Corridor or Teleporter square */ + uint8 randFloorOrnCount; /* Used only on some Corridor squares and some open Fake Wall squares */ + + uint8 doorOrnCount; + uint8 creatureTypeCount; + uint8 difficulty; + + uint8 floorSet, wallSet, doorSet0, doorSet1; + +}; // @ MAP + + + class DungeonMan { DMEngine *_vm; - uint32 _dungeonDataSize; - byte *_dungeonData; + + uint32 _rawDunFileDataSize; + byte *_rawDunFileData; // @ ??? + DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader + + DungeonData _dunData; // @ NONE + Map *_maps; // @ G0277_ps_DungeonMaps + // does not have to be freed + byte *_rawMapData; // @ G0276_puc_DungeonRawMapData + Messages _messages; // @ NONE + DungeonMan(const DungeonMan &other); // no implementation on purpose void operator=(const DungeonMan &rhs); // no implementation on purpose + + void mapCoordsAfterRelMovement(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 &posX, uint16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement + + void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon public: DungeonMan(DMEngine *dmEngine); ~DungeonMan(); - void loadDungeonFile(); + // TODO: this does stuff other than load the file! + void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC }; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 0ae3b251fd..0c2efc6b71 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -39,7 +39,7 @@ Frame gCeilingFrame = {0, 223, 0, 28, 0, 0}; Frame gFloorFrame = {0, 223, 66, 135, 0, 0}; extern Viewport gDefultViewPort = {0, 0}; -extern Viewport gDungeonViewport = {0, 64}; +extern Viewport gDungeonViewport = {0, 64}; // TODO: I guessed the numbers } -- cgit v1.2.3 From 68f13e8462bfb6ca85b45273696173acdf112910 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Sat, 7 May 2016 21:59:59 +0200 Subject: DM: Implement F0173_DUNGEON_SetCurrentMap --- engines/dm/dm.cpp | 2 ++ engines/dm/dungeonman.cpp | 63 ++++++++++++++++++++++++++++------------------- engines/dm/dungeonman.h | 39 ++++++++++++++++++++--------- 3 files changed, 67 insertions(+), 37 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 8f6f294551..a27506d5f4 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -59,6 +59,8 @@ Common::Error DMEngine::run() { _displayMan->loadPalette(kPalCredits); + _dungeonMan->setCurrentMap(0); + uint16 i = 0; //TODO: testing, please delete me while (true) { _displayMan->clearScreen(kColorBlack); diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index e33895db5a..07c52a78dc 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -30,11 +30,11 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL DungeonMan::~DungeonMan() { delete[] _rawDunFileData; delete[] _maps; - delete[] _dunData.dunMapsFirstColumnIndex; - delete[] _dunData.dunColumnsCumulativeSquareThingCount; + delete[] _dunData.mapsFirstColumnIndex; + delete[] _dunData.columnsCumulativeSquareThingCount; delete[] _dunData.squareFirstThings; - delete[] _dunData.dunTextData; - delete[] _dunData.dungeonMapData; + delete[] _dunData.textData; + delete[] _dunData.mapData; } void DungeonMan::decompressDungeonFile() { @@ -159,10 +159,10 @@ void DungeonMan::loadDungeonFile() { // init party position and mapindex if (_messages.newGame) { - _dunData.partyDir = _fileHeader.partyStartDir; - _dunData.partyPosX = _fileHeader.partyStartPosX; - _dunData.partyPosY = _fileHeader.partyStartPosY; - _dunData.currMapIndex = 0; + _currMap.partyDir = _fileHeader.partyStartDir; + _currMap.partyPosX = _fileHeader.partyStartPosX; + _currMap.partyPosY = _fileHeader.partyStartPosY; + _currMap.currPartyMapIndex = 0; } // load map data @@ -199,26 +199,26 @@ void DungeonMan::loadDungeonFile() { } // TODO: ??? is this - begin - if (_dunData.dunMapsFirstColumnIndex) delete[] _dunData.dunMapsFirstColumnIndex; + if (_dunData.mapsFirstColumnIndex) delete[] _dunData.mapsFirstColumnIndex; - _dunData.dunMapsFirstColumnIndex = new uint16[_fileHeader.mapCount]; + _dunData.mapsFirstColumnIndex = new uint16[_fileHeader.mapCount]; uint16 columCount = 0; for (uint16 i = 0; i < _fileHeader.mapCount; ++i) { - _dunData.dunMapsFirstColumnIndex[i] = columCount; + _dunData.mapsFirstColumnIndex[i] = columCount; columCount += _maps[i].width + 1; } - _dunData.dunColumCount = columCount; + _dunData.columCount = columCount; // TODO: ??? is this - end if (_messages.newGame) // TODO: what purpose does this serve? _fileHeader.squareFirstThingCount += 300; // TODO: ??? is this - begin - if (_dunData.dunColumnsCumulativeSquareThingCount) - delete[] _dunData.dunColumnsCumulativeSquareThingCount; - _dunData.dunColumnsCumulativeSquareThingCount = new uint16[columCount]; + if (_dunData.columnsCumulativeSquareThingCount) + delete[] _dunData.columnsCumulativeSquareThingCount; + _dunData.columnsCumulativeSquareThingCount = new uint16[columCount]; for (uint16 i = 0; i < columCount; ++i) - _dunData.dunColumnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE(); + _dunData.columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE(); // TODO: ??? is this - end // TODO: ??? is this - begin @@ -238,11 +238,11 @@ void DungeonMan::loadDungeonFile() { // TODO: ??? is this - end // load text data - if (_dunData.dunTextData) - delete[] _dunData.dunTextData; - _dunData.dunTextData = new uint16[_fileHeader.textDataWordCount]; + if (_dunData.textData) + delete[] _dunData.textData; + _dunData.textData = new uint16[_fileHeader.textDataWordCount]; for (uint16 i = 0; i < _fileHeader.textDataWordCount; ++i) - _dunData.dunTextData[i] = dunDataStream.readUint16BE(); + _dunData.textData[i] = dunDataStream.readUint16BE(); // TODO: ??? what this if (_messages.newGame) @@ -256,14 +256,14 @@ void DungeonMan::loadDungeonFile() { _rawMapData = _rawDunFileData + dunDataStream.pos(); - if (_dunData.dungeonMapData) delete[] _dunData.dungeonMapData; + if (_dunData.mapData) delete[] _dunData.mapData; - if (_messages.restartGameRequest) { + if (!_messages.restartGameRequest) { uint8 mapCount = _fileHeader.mapCount; - _dunData.dungeonMapData = new byte**[_dunData.dunColumCount + mapCount]; - byte **colFirstSquares = _dunData.dungeonMapData[mapCount]; + _dunData.mapData = new byte**[_dunData.columCount + mapCount]; + byte **colFirstSquares = (byte**)_dunData.mapData + mapCount; for (uint8 i = 0; i < mapCount; ++i) { - _dunData.dungeonMapData[i] = colFirstSquares; + _dunData.mapData[i] = colFirstSquares; byte *square = _rawMapData + _maps[i].rawDunDataOffset; *colFirstSquares++ = square; for (uint16 w = 0; w <= _maps[i].width; ++w) { @@ -272,4 +272,17 @@ void DungeonMan::loadDungeonFile() { } } } +} + +void DungeonMan::setCurrentMap(uint16 mapIndex) { + if (_currMap.index == mapIndex) + return; + + _currMap.index = mapIndex; + _currMap.data = _dunData.mapData[mapIndex]; + _currMap.map = _maps + mapIndex; + _currMap.width = _maps[mapIndex].width + 1; + _currMap.height = _maps[mapIndex].height + 1; + _currMap.colCumulativeSquareFirstThingCount + = &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]]; } \ No newline at end of file diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index b26d56fc4c..213a76dad6 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -6,6 +6,7 @@ namespace DM { class DungeonMan; +class Map; enum ThingType { kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value @@ -57,27 +58,39 @@ class Thing { class DungeonData { friend class DungeonMan; - direction partyDir; // @ G0308_i_PartyDirection - uint16 partyPosX; // @ G0306_i_PartyMapX - uint16 partyPosY; // @ G0307_i_PartyMapY - uint8 currMapIndex; // @ G0309_i_PartyMapIndex - // I have no idea the heck is this - uint16 *dunMapsFirstColumnIndex = NULL; // @ G0281_pui_DungeonMapsFirstColumnIndex - uint16 dunColumCount; // @ G0282_ui_DungeonColumnCount + uint16 *mapsFirstColumnIndex = NULL; // @ G0281_pui_DungeonMapsFirstColumnIndex + uint16 columCount; // @ G0282_ui_DungeonColumnCount // I have no idea the heck is this - uint16 *dunColumnsCumulativeSquareThingCount = NULL; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount + uint16 *columnsCumulativeSquareThingCount = NULL; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount Thing *squareFirstThings = NULL; // @ G0283_pT_SquareFirstThings - uint16 *dunTextData = NULL; // @ G0260_pui_DungeonTextData + uint16 *textData = NULL; // @ G0260_pui_DungeonTextData byte *rawThingData[16] = {NULL}; // @ G0284_apuc_ThingData - byte ***dungeonMapData = NULL; // @ G0279_pppuc_DungeonMapData + byte ***mapData = NULL; // @ G0279_pppuc_DungeonMapData + // TODO: ??? is this doing here uint16 eventMaximumCount; // @ G0369_ui_EventMaximumCount }; // @ AGGREGATE +class CurrMapData { + friend class DungeonMan; + + direction partyDir; // @ G0308_i_PartyDirection + uint16 partyPosX; // @ G0306_i_PartyMapX + uint16 partyPosY; // @ G0307_i_PartyMapY + uint8 currPartyMapIndex; // @ G0309_i_PartyMapIndex + + uint8 index; // @ G0272_i_CurrentMapIndex + byte **data; // @ G0271_ppuc_CurrentMapData + Map *map; // @ G0269_ps_CurrentMap + uint16 width; // @ G0273_i_CurrentMapWidth + uint16 height; // @ G0274_i_CurrentMapHeight + uint16 *colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount +}; // @ AGGREGATE + struct Messages { friend class DungeonMan; @@ -93,7 +106,7 @@ class Map { uint8 offsetMapX, offsetMapY; uint8 level; // only used in DMII - uint8 width, height; // THESRE ARE INCLUSIVE BOUNDARIES + uint8 width, height; // !!! THESRE ARE INCLUSIVE BOUNDARIES // orn short for Ornament uint8 wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */ uint8 randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */ @@ -113,11 +126,12 @@ class Map { class DungeonMan { DMEngine *_vm; - uint32 _rawDunFileDataSize; + uint32 _rawDunFileDataSize; // @ probably NONE byte *_rawDunFileData; // @ ??? DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader DungeonData _dunData; // @ NONE + CurrMapData _currMap; // @ NONE Map *_maps; // @ G0277_ps_DungeonMaps // does not have to be freed byte *_rawMapData; // @ G0276_puc_DungeonRawMapData @@ -134,6 +148,7 @@ public: ~DungeonMan(); // TODO: this does stuff other than load the file! void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC + void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap }; } -- cgit v1.2.3 From 8172a07d1ad933b228313f164b7d6a5b1bf3951e Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Sat, 7 May 2016 22:48:19 +0200 Subject: DM: Add square query in DungeonMan --- engines/dm/dungeonman.cpp | 15 +++++++++++++++ engines/dm/dungeonman.h | 17 +++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 07c52a78dc..87188aebf8 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -285,4 +285,19 @@ void DungeonMan::setCurrentMap(uint16 mapIndex) { _currMap.height = _maps[mapIndex].height + 1; _currMap.colCumulativeSquareFirstThingCount = &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]]; +} + +byte DungeonMan::getSquare(uint16 mapX, uint16 mapY) { + bool isInXBounds = (mapX >= 0) && (mapX < _currMap.width); + bool isInYBounds = (mapY >= 0) && (mapY < _currMap.height); + + if (isInXBounds && isInYBounds) + return _currMap.data[mapX][mapY]; + else + return kWallSquareType; +} + +byte DungeonMan::getRelSquare(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY) { + mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY); + return getSquare(posX, posY); } \ No newline at end of file diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 213a76dad6..c88c08d478 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -26,6 +26,16 @@ enum ThingType { kThingTypeTotal = 16 // +1 than the last }; // @ C[00..15]_THING_TYPE_... +enum SquareType { + kWallSquareType = 0, + kCorridorSquareType = 1, + kPitSquareType = 2, + kStairsSquareType = 3, + kDoorSquareType = 4, + kTeleporterSquareType = 5, + kFakeWallSquareType = 6 +}; // @ C[00..06]_ELEMENT_... + class DungeonFileHeader { friend class DungeonMan; @@ -141,6 +151,10 @@ class DungeonMan { void operator=(const DungeonMan &rhs); // no implementation on purpose void mapCoordsAfterRelMovement(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 &posX, uint16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement + byte getSquare(uint16 mapX, uint16 mapY); // @ F0151_DUNGEON_GetSquare + byte getRelSquare(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY); // @ F0152_DUNGEON_GetRelativeSquare + + SquareType getSquareType(uint16 square) { return (SquareType)(square << 5); } // @ M34_SQUARE_TYPE void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon public: @@ -149,6 +163,9 @@ public: // TODO: this does stuff other than load the file! void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap + SquareType getRelSquareType(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY) { + return getSquareType(getRelSquare(dir, stepsForward, stepsRight, posX, posY)); + }// @ F0153_DUNGEON_GetRelativeSquareType }; } -- cgit v1.2.3 From 853b87f19e2ad99db495be9e86a312d8775ed37c Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Sat, 7 May 2016 23:27:16 +0200 Subject: DM: Add drawDungeon test code --- engines/dm/dm.h | 1 + engines/dm/gfx.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 22ef1ec072..d5d748754f 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -34,6 +34,7 @@ public: private: Console *_console; Common::RandomSource *_rnd; +public: DisplayMan *_displayMan; DungeonMan *_dungeonMan; }; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 0c2efc6b71..fd3b28169a 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -4,6 +4,7 @@ #include "common/file.h" #include "graphics/palette.h" #include "common/endian.h" +#include "dm/dungeonman.h" namespace DM { @@ -37,6 +38,8 @@ struct Frame { Frame gCeilingFrame = {0, 223, 0, 28, 0, 0}; Frame gFloorFrame = {0, 223, 66, 135, 0, 0}; +Frame gWallFrameD3L2 = {0, 15, 25, 73, 0, 0}; // @ FRAME G0711_s_Graphic558_Frame_Wall_D3L2 +Frame gWallFrameD3R2 = {208, 223, 25, 73, 0, 0}; // @ G0712_s_Graphic558_Frame_Wall_D3R2 extern Viewport gDefultViewPort = {0, 0}; extern Viewport gDungeonViewport = {0, 64}; // TODO: I guessed the numbers @@ -264,6 +267,13 @@ void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) { drawWallSetBitmap(_bitmaps[gFloorIndice], gFloorFrame, width(gFloorIndice)); } + // TODO: CRUDE TEST CODE AT BEST + if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallSquareType) + drawWallSetBitmap(_bitmaps[77 + 12], gWallFrameD3L2, width(77 + 12)); + // TODO CRUDE TEST CODE AT BEST + + + delete[] tmpBitmap; } -- cgit v1.2.3 From bf78e63d2e900b73c592c8087156ea261cd35354 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Thu, 12 May 2016 10:16:00 +0200 Subject: DM: Add missing cross-references in gfx.h --- engines/dm/gfx.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 34bb8cf991..3199fb8b99 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -65,9 +65,10 @@ class DisplayMan { byte **_bitmaps; byte *getCurrentVgaBuffer(); - void loadIntoBitmap(uint16 index, byte *destBitmap); + // the original functions has two position parameters, but they are always set to zero + void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap void unpackGraphics(); - void drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth); + void drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap public: DisplayMan(DMEngine *dmEngine); ~DisplayMan(); @@ -94,7 +95,7 @@ public: void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color); void clearScreen(Color color); - void drawDungeon(direction dir, uint16 posX, uint16 posY); + void drawDungeon(direction dir, uint16 posX, uint16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); }; -- cgit v1.2.3 From 16199b4091e4fae39a6569d985e2b460c7d2516b Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Thu, 12 May 2016 20:46:37 +0200 Subject: DM: Add loadWallSet(..) and loadFloorSet(..) --- engines/dm/dm.cpp | 2 ++ engines/dm/gfx.cpp | 72 +++++++++++++++++++++++++++++++++++++++++++++++------- engines/dm/gfx.h | 26 ++++++++++++++++++-- 3 files changed, 89 insertions(+), 11 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index a27506d5f4..60b2b2a3cb 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -56,6 +56,8 @@ Common::Error DMEngine::run() { _displayMan->setUpScreens(320, 200); _displayMan->loadGraphics(); _dungeonMan->loadDungeonFile(); + _displayMan->loadFloorSet(kFloorSetStone); + _displayMan->loadWallSet(kWallSetStone); _displayMan->loadPalette(kPalCredits); diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index fd3b28169a..11c2d81875 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -24,6 +24,7 @@ uint16 dmPalettes[10][16] = { }; + enum GraphicIndice { gFloorIndice = 75, gCeilingIndice = 76 @@ -50,7 +51,7 @@ using namespace DM; DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine), _currPalette(kPalSwoosh), _screenWidth(0), _screenHeight(0), - _vgaBuffer(NULL), _itemCount(0), _packedItemPos(NULL), _packedBitmaps(NULL), + _vgaBuffer(NULL), _packedItemCount(0), _packedItemPos(NULL), _packedBitmaps(NULL), _bitmaps(NULL) {} DisplayMan::~DisplayMan() { @@ -58,6 +59,8 @@ DisplayMan::~DisplayMan() { delete[] _packedItemPos; delete[] _vgaBuffer; delete[] _bitmaps; + delete[] _wallSetBitMaps[13]; // copy of another bitmap, just flipped + delete[] _wallSetBitMaps[14]; // copy of another bitmap, just flipped } void DisplayMan::setUpScreens(uint16 width, uint16 height) { @@ -72,16 +75,16 @@ void DisplayMan::loadGraphics() { Common::File f; f.open("graphics.dat"); - _itemCount = f.readUint16BE(); - _packedItemPos = new uint32[_itemCount + 1]; + _packedItemCount = f.readUint16BE(); + _packedItemPos = new uint32[_packedItemCount + 1]; _packedItemPos[0] = 0; - for (uint16 i = 1; i < _itemCount + 1; ++i) + for (uint16 i = 1; i < _packedItemCount + 1; ++i) _packedItemPos[i] = f.readUint16BE() + _packedItemPos[i - 1]; - _packedBitmaps = new uint8[_packedItemPos[_itemCount]]; + _packedBitmaps = new uint8[_packedItemPos[_packedItemCount]]; - f.seek(2 + _itemCount * 4); - for (uint32 i = 0; i < _packedItemPos[_itemCount]; ++i) + f.seek(2 + _packedItemCount * 4); + for (uint32 i = 0; i < _packedItemPos[_packedItemCount]; ++i) _packedBitmaps[i] = f.readByte(); f.close(); @@ -245,17 +248,35 @@ void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth) { } +enum WallSetIndices { + kDoorFrameFront = 0, // @ G0709_puc_Bitmap_WallSet_DoorFrameFront + kDoorFrameLeft_D1C = 1, // @ G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C + kFameLeft_D2C = 2, // @ G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C + kDoorFrameLeft_D3C = 3, // @ G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C + kDoorFrameLeft_D3L = 4, // @ G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L + kDoorFrameTop_D1LCR = 5, // @ G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR + kDoorFrameTop_D2LCR = 6, // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR + kWall_D0R = 7, // @ G0702_puc_Bitmap_WallSet_Wall_D0R + kWall_D0L = 8, // @ G0701_puc_Bitmap_WallSet_Wall_D0L + kWall_D1LCR = 9, // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR + kWall_D2LCR = 10, // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR + kWall_D3LCR = 11, // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR + kWall_D3L2 = 12, // @ G0697_puc_Bitmap_WallSet_Wall_D3L2 + + kWall_D3R2 = 13, // @ G0696_puc_Bitmap_WallSet_Wall_D3R2 + kDoorFrameRight_D1C = 14// @ G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C +}; void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) { loadPalette(kPalDungeonView0); // TODO: this is a global variable, set from here - bool flippedWallAndFootprints = (posX + posY + dir) & 1; + bool flippedFloorCeiling = (posX + posY + dir) & 1; // NOTE: this can hold every bitmap, width and height is "flexible" byte *tmpBitmap = new byte[305 * 111]; clearBitmap(tmpBitmap, 305, 111, kColorBlack); - if (flippedWallAndFootprints) { + if (flippedFloorCeiling) { blitToBitmap(_bitmaps[gFloorIndice], width(gFloorIndice), height(gFloorIndice), tmpBitmap, width(gFloorIndice)); flipBitmapHorizontal(tmpBitmap, width(gFloorIndice), height(gFloorIndice)); drawWallSetBitmap(tmpBitmap, gFloorFrame, width(gFloorIndice)); @@ -284,4 +305,37 @@ void DisplayMan::clearScreen(Color color) { void DisplayMan::clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color) { memset(bitmap, color, sizeof(byte) * width * height); +} + + +void DisplayMan::loadWallSet(WallSet set) { + // there are 2 bitmaps per set, first one is at 75 + GraphicIndice indice = (GraphicIndice)(75 + (2 * set)); + _floorBitmap = _bitmaps[indice]; + _ceilingBitmap = _bitmaps[indice + 1]; +} + +void DisplayMan::loadFloorSet(FloorSet set) { + // there are 13 bitmaps perset, first one is at 77 + uint16 firstIndice = (set * 13) + 77; + for (uint16 i = 0; i < 13; ++i) { + _wallSetBitMaps[i] = _bitmaps[i + firstIndice]; + } + + + uint16 leftDoorIndice = firstIndice + kDoorFrameLeft_D1C; + uint16 w = width(leftDoorIndice), h = height(leftDoorIndice); + if (_wallSetBitMaps[kDoorFrameRight_D1C]) + delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; + _wallSetBitMaps[kDoorFrameRight_D1C] = new byte[w * h]; + blitToBitmap(_wallSetBitMaps[kDoorFrameLeft_D1C], w, h, _wallSetBitMaps[kDoorFrameRight_D1C], w); + flipBitmapHorizontal(_wallSetBitMaps[kDoorFrameRight_D1C], w, h); + + uint16 leftWallIndice = firstIndice + kWall_D3L2; + w = width(leftWallIndice), h = height(leftWallIndice); + if (_wallSetBitMaps[kWall_D3R2]) + delete[] _wallSetBitMaps[kWall_D3R2]; + _wallSetBitMaps[kWall_D3R2] = new byte[w * h]; + blitToBitmap(_wallSetBitMaps[kWall_D3L2], w, h, _wallSetBitMaps[kWall_D3R2], w); + flipBitmapHorizontal(_wallSetBitMaps[kWall_D3R2], w, h); } \ No newline at end of file diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 3199fb8b99..45b1bb78b3 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -7,6 +7,13 @@ namespace DM { struct Frame; +enum WallSet { + kWallSetStone = 0 // @ C0_WALL_SET_STONE +}; + +enum FloorSet { + kFloorSetStone = 0 // @ C0_FLOOR_SET_STONE +}; enum Color { kColorNoTransparency = 255, @@ -57,13 +64,24 @@ class DisplayMan { uint16 _screenWidth; uint16 _screenHeight; byte *_vgaBuffer; - uint16 _itemCount; + + uint16 _packedItemCount; uint32 *_packedItemPos; byte *_packedBitmaps; // TODO: this doesn't not contaion graphics exclusively, will have to be moved + + byte **_bitmaps; + + + // the last two pointers are owned by this array + byte *_wallSetBitMaps[15] = {NULL}; // @G[0696..0710]_puc_Bitmap_WallSet_... + + // pointers are not owned by these fields + byte *_floorBitmap; + byte *_ceilingBitmap; + DisplayMan(const DisplayMan &other); // no implementation on purpose void operator=(const DisplayMan &rhs); // no implementation on purpose - byte **_bitmaps; byte *getCurrentVgaBuffer(); // the original functions has two position parameters, but they are always set to zero void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap @@ -73,7 +91,11 @@ public: DisplayMan(DMEngine *dmEngine); ~DisplayMan(); void setUpScreens(uint16 width, uint16 height); + void loadGraphics(); + void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet + void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet + void loadPalette(dmPaletteEnum palette); /// Gives the width of an IMG0 type item -- cgit v1.2.3 From af6e6ca4682981e6d193968e508531055e18c52e Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Thu, 12 May 2016 21:10:45 +0200 Subject: DM: Refactor Frame POD --- engines/dm/gfx.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 11c2d81875..603021e8a1 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -30,17 +30,22 @@ enum GraphicIndice { gCeilingIndice = 76 }; +// The frames in the orignal sources contain inclusive boundaries and byte widths, not pixel widths struct Frame { - // FIXME: these bundaries are inclusive, workaround by adding +1 in the drawFrame methods uint16 destFromX, destToX, destFromY, destToY; - // srcWidth and srcHeight (present in the original sources) is redundant here, can be deduced from gaphicsIndice + uint16 srcWidth, srcHeight; uint16 srcX, srcY; + + Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, + uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY): + destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1), + srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {} }; -Frame gCeilingFrame = {0, 223, 0, 28, 0, 0}; -Frame gFloorFrame = {0, 223, 66, 135, 0, 0}; -Frame gWallFrameD3L2 = {0, 15, 25, 73, 0, 0}; // @ FRAME G0711_s_Graphic558_Frame_Wall_D3L2 -Frame gWallFrameD3R2 = {208, 223, 25, 73, 0, 0}; // @ G0712_s_Graphic558_Frame_Wall_D3R2 +Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); +Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); +Frame gWallFrameD3L2(0, 15, 25, 73, 8, 49, 0, 0); // @ FRAME G0711_s_Graphic558_Frame_Wall_D3L2 +Frame gWallFrameD3R2(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2 extern Viewport gDefultViewPort = {0, 0}; extern Viewport gDungeonViewport = {0, 64}; // TODO: I guessed the numbers @@ -59,8 +64,8 @@ DisplayMan::~DisplayMan() { delete[] _packedItemPos; delete[] _vgaBuffer; delete[] _bitmaps; - delete[] _wallSetBitMaps[13]; // copy of another bitmap, just flipped - delete[] _wallSetBitMaps[14]; // copy of another bitmap, just flipped + delete[] _wallSetBitMaps[13]; // copy of another bitmap, but flipped + delete[] _wallSetBitMaps[14]; // copy of another bitmap, but flipped } void DisplayMan::setUpScreens(uint16 width, uint16 height) { @@ -244,7 +249,7 @@ uint16 DisplayMan::height(uint16 index) { } void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth) { - blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX + 1, f.destFromY, f.destToY + 1, kColorFlesh, gDungeonViewport); + blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport); } -- cgit v1.2.3 From 05fbf0b3584c5bef1827ce43951b325a20ac40ac Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Thu, 12 May 2016 22:44:30 +0200 Subject: DM: Add dungeonman.o to module.mk, fix _bitmaps memory leak --- engines/dm/dungeonman.h | 2 +- engines/dm/gfx.cpp | 33 ++++++++++++++++++--------------- engines/dm/gfx.h | 2 +- engines/dm/module.mk | 3 ++- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index c88c08d478..e60fb40d43 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -163,7 +163,7 @@ public: // TODO: this does stuff other than load the file! void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap - SquareType getRelSquareType(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY) { + SquareType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { return getSquareType(getRelSquare(dir, stepsForward, stepsRight, posX, posY)); }// @ F0153_DUNGEON_GetRelativeSquareType }; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 603021e8a1..ad8d230e6b 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -37,14 +37,14 @@ struct Frame { uint16 srcX, srcY; Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY): + uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) : destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1), srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {} }; Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); -Frame gWallFrameD3L2(0, 15, 25, 73, 8, 49, 0, 0); // @ FRAME G0711_s_Graphic558_Frame_Wall_D3L2 +Frame gWallFrameD3L2(0, 15, 25, 73, 8, 49, 0, 0); // @ FRAME G0711_s_Graphic558_Frame_Wall_D3L2 Frame gWallFrameD3R2(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2 extern Viewport gDefultViewPort = {0, 0}; @@ -63,6 +63,7 @@ DisplayMan::~DisplayMan() { delete[] _packedBitmaps; delete[] _packedItemPos; delete[] _vgaBuffer; + delete[] _bitmaps[0]; delete[] _bitmaps; delete[] _wallSetBitMaps[13]; // copy of another bitmap, but flipped delete[] _wallSetBitMaps[14]; // copy of another bitmap, but flipped @@ -248,8 +249,8 @@ uint16 DisplayMan::height(uint16 index) { return READ_BE_UINT16(data + 2); } -void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth) { - blitToScreen(bitmap, srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport); +void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) { + blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport); } @@ -282,21 +283,23 @@ void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) { clearBitmap(tmpBitmap, 305, 111, kColorBlack); if (flippedFloorCeiling) { - blitToBitmap(_bitmaps[gFloorIndice], width(gFloorIndice), height(gFloorIndice), tmpBitmap, width(gFloorIndice)); - flipBitmapHorizontal(tmpBitmap, width(gFloorIndice), height(gFloorIndice)); - drawWallSetBitmap(tmpBitmap, gFloorFrame, width(gFloorIndice)); - drawWallSetBitmap(_bitmaps[gCeilingIndice], gCeilingFrame, width(gCeilingIndice)); + uint16 w = gFloorFrame.srcWidth, h = gFloorFrame.srcHeight; + blitToBitmap(_floorBitmap, w, h, tmpBitmap, w); + flipBitmapHorizontal(tmpBitmap, w, h); + drawWallSetBitmap(tmpBitmap, gFloorFrame); + drawWallSetBitmap(_ceilingBitmap, gCeilingFrame); } else { - blitToBitmap(_bitmaps[gCeilingIndice], width(gCeilingIndice), height(gCeilingIndice), tmpBitmap, width(gCeilingIndice)); - flipBitmapHorizontal(tmpBitmap, width(gCeilingIndice), height(gCeilingIndice)); - drawWallSetBitmap(tmpBitmap, gCeilingFrame, width(gCeilingIndice)); - drawWallSetBitmap(_bitmaps[gFloorIndice], gFloorFrame, width(gFloorIndice)); + uint16 w = gCeilingFrame.srcWidth, h = gCeilingFrame.srcHeight; + blitToBitmap(_ceilingBitmap, w, h, tmpBitmap, w); + flipBitmapHorizontal(tmpBitmap, w, h); + drawWallSetBitmap(tmpBitmap, gCeilingFrame); + drawWallSetBitmap(_floorBitmap, gFloorFrame); } - // TODO: CRUDE TEST CODE AT BEST if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallSquareType) - drawWallSetBitmap(_bitmaps[77 + 12], gWallFrameD3L2, width(77 + 12)); - // TODO CRUDE TEST CODE AT BEST + drawWallSetBitmap(_wallSetBitMaps[kWall_D3L2], gWallFrameD3L2); + if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallSquareType) + drawWallSetBitmap(_wallSetBitMaps[kWall_D3R2], gWallFrameD3R2); diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 45b1bb78b3..b2c29bf8c6 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -86,7 +86,7 @@ class DisplayMan { // the original functions has two position parameters, but they are always set to zero void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap void unpackGraphics(); - void drawWallSetBitmap(byte *bitmap, Frame &f, uint16 srcWidth); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap + void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap public: DisplayMan(DMEngine *dmEngine); ~DisplayMan(); diff --git a/engines/dm/module.mk b/engines/dm/module.mk index 3fad4ee9f4..ca425c5ffb 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -3,7 +3,8 @@ MODULE := engines/dm MODULE_OBJS := \ detection.o \ dm.o \ - gfx.o + gfx.o \ + dungeonman.o MODULE_DIRS += \ engines/dm -- cgit v1.2.3 From f39b22f32133cd40c20996e75dfcb167c91e2ae2 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Thu, 12 May 2016 23:19:36 +0200 Subject: DM: Refactor Thing POD --- engines/dm/dungeonman.cpp | 9 ++------- engines/dm/dungeonman.h | 50 ++++++++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 87188aebf8..b5c2a3e1fb 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -11,7 +11,6 @@ int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 / void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } - } using namespace DM; @@ -225,12 +224,8 @@ void DungeonMan::loadDungeonFile() { if (_dunData.squareFirstThings) delete[] _dunData.squareFirstThings; _dunData.squareFirstThings = new Thing[_fileHeader.squareFirstThingCount]; - for (uint16 i = 0; i < _fileHeader.squareFirstThingCount; ++i) { - uint16 tmp = dunDataStream.readUint16BE(); - _dunData.squareFirstThings[i].cell = tmp >> 14; - _dunData.squareFirstThings[i].type = (tmp >> 10) & 0xF; - _dunData.squareFirstThings[i].index = tmp & 0x1FF; - } + for (uint16 i = 0; i < _fileHeader.squareFirstThingCount; ++i) + _dunData.squareFirstThings[i].set(dunDataStream.readUint16BE()); if (_messages.newGame) for (uint16 i = 0; i < 300; ++i) _dunData.squareFirstThings[i] = Thing::specThingNone; diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index e60fb40d43..2afc2aab88 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -52,13 +52,40 @@ class DungeonFileHeader { uint16 thingCounts[16]; // @ ThingCount[16] }; // @ DUNGEON_HEADER +class Map { + friend class DungeonMan; + + uint32 rawDunDataOffset; + uint8 offsetMapX, offsetMapY; + + uint8 level; // only used in DMII + uint8 width, height; // !!! THESRE ARE INCLUSIVE BOUNDARIES + // orn short for Ornament + uint8 wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */ + uint8 randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */ + uint8 floorOrnCount; /* May be used in a Sensor on a Pit, open Fake Wall, Corridor or Teleporter square */ + uint8 randFloorOrnCount; /* Used only on some Corridor squares and some open Fake Wall squares */ + + uint8 doorOrnCount; + uint8 creatureTypeCount; + uint8 difficulty; + + uint8 floorSet, wallSet, doorSet0, doorSet1; +}; // @ MAP + class Thing { friend class DungeonMan; static const Thing specThingNone; - Thing(uint8 cell, uint8 type, uint8 index) : cell(cell), type(type), index(index) {} Thing() {} + Thing(uint8 cell, uint8 type, uint8 index) : cell(cell), type(type), index(index) {} + + void set(uint16 dat) { + cell = dat >> 14; + type = (dat >> 10) & 0xF; + index = dat & 0x1FF; + } uint8 cell; uint8 type; @@ -109,27 +136,6 @@ private: bool restartGameRequest = false; // @ G0523_B_RestartGameRequested }; // @ AGGREGATE -class Map { - friend class DungeonMan; - - uint32 rawDunDataOffset; - uint8 offsetMapX, offsetMapY; - - uint8 level; // only used in DMII - uint8 width, height; // !!! THESRE ARE INCLUSIVE BOUNDARIES - // orn short for Ornament - uint8 wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */ - uint8 randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */ - uint8 floorOrnCount; /* May be used in a Sensor on a Pit, open Fake Wall, Corridor or Teleporter square */ - uint8 randFloorOrnCount; /* Used only on some Corridor squares and some open Fake Wall squares */ - - uint8 doorOrnCount; - uint8 creatureTypeCount; - uint8 difficulty; - - uint8 floorSet, wallSet, doorSet0, doorSet1; - -}; // @ MAP -- cgit v1.2.3 From 253730787de69da9b914f41138f7a54214f41eff Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Fri, 13 May 2016 00:54:01 +0200 Subject: DM: Finish implementing ornament masks in DungeonMan::getSquare --- engines/dm/dungeonman.cpp | 29 ++++++++++++++++++++++++----- engines/dm/dungeonman.h | 41 +++++++++++++++++++++++++++-------------- engines/dm/gfx.cpp | 13 ++++++++++--- engines/dm/gfx.h | 3 ++- 4 files changed, 63 insertions(+), 23 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index b5c2a3e1fb..80239e14fe 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -16,7 +16,7 @@ void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } using namespace DM; -void DungeonMan::mapCoordsAfterRelMovement(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 &posX, uint16 &posY) { +void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) { posX += dirIntoStepCountEast[dir] * stepsForward; posY += dirIntoStepCountNorth[dir] * stepsForward; turnDirRight(dir); @@ -282,17 +282,36 @@ void DungeonMan::setCurrentMap(uint16 mapIndex) { = &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]]; } -byte DungeonMan::getSquare(uint16 mapX, uint16 mapY) { +byte DungeonMan::getSquare(int16 mapX, int16 mapY) { bool isInXBounds = (mapX >= 0) && (mapX < _currMap.width); bool isInYBounds = (mapY >= 0) && (mapY < _currMap.height); if (isInXBounds && isInYBounds) return _currMap.data[mapX][mapY]; - else - return kWallSquareType; + + int16 tmpSquare; + if (isInYBounds) { + tmpSquare = getSquareType(_currMap.data[0][mapY]); + if (mapX == -1 && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType)) + return (kWallElemType << 5) | kWallEastRandOrnAllowed; + + tmpSquare = getSquareType(_currMap.data[_currMap.width - 1][mapY]); + if (mapX == _currMap.width && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType)) + return (kWallElemType << 5) | kWallWestRandOrnAllowed; + } else if (isInXBounds) { + tmpSquare = getSquareType(_currMap.data[mapX][0]); + if (mapY == -1 && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType)) + return (kWallElemType << 5) | kWallSouthRandOrnAllowed; + + tmpSquare = getSquareType(_currMap.data[mapX][_currMap.height - 1]); + if (mapY == _currMap.height && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType)) + return (kWallElemType << 5) | kWallNorthRandOrnAllowed; + } + + return kWallElemType << 5; } -byte DungeonMan::getRelSquare(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY) { +byte DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY); return getSquare(posX, posY); } \ No newline at end of file diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 2afc2aab88..dbe13d3018 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -26,15 +26,28 @@ enum ThingType { kThingTypeTotal = 16 // +1 than the last }; // @ C[00..15]_THING_TYPE_... -enum SquareType { - kWallSquareType = 0, - kCorridorSquareType = 1, - kPitSquareType = 2, - kStairsSquareType = 3, - kDoorSquareType = 4, - kTeleporterSquareType = 5, - kFakeWallSquareType = 6 -}; // @ C[00..06]_ELEMENT_... +enum ElementType { + kChampionElemType = -2, + kCreatureElemType = -1, + kWallElemType = 0, + kCorridorElemType = 1, + kPitElemType = 2, + kStairsElemType = 3, + kDoorElemType = 4, + kTeleporterElemType = 5, + kFakeWallElemType = 6, + kDoorSideElemType = 16, + kDoorFrontElemType = 17, + kStairsSideElemType = 18, + kStairsFrontElemType = 19 +}; // @ C[-2..19]_ELEMENT_... + +enum WallOrnMask { + kWallWestRandOrnAllowed = 0x1, + kWallSouthRandOrnAllowed = 0x2, + kWallEastRandOrnAllowed = 0x4, + kWallNorthRandOrnAllowed = 0x8 +}; class DungeonFileHeader { @@ -156,11 +169,10 @@ class DungeonMan { DungeonMan(const DungeonMan &other); // no implementation on purpose void operator=(const DungeonMan &rhs); // no implementation on purpose - void mapCoordsAfterRelMovement(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 &posX, uint16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement - byte getSquare(uint16 mapX, uint16 mapY); // @ F0151_DUNGEON_GetSquare - byte getRelSquare(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY); // @ F0152_DUNGEON_GetRelativeSquare + byte getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare + byte getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare - SquareType getSquareType(uint16 square) { return (SquareType)(square << 5); } // @ M34_SQUARE_TYPE + ElementType getSquareType(int16 square) { return (ElementType)(square << 5); } // @ M34_SQUARE_TYPE void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon public: @@ -169,7 +181,8 @@ public: // TODO: this does stuff other than load the file! void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap - SquareType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { + void mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement + ElementType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { return getSquareType(getRelSquare(dir, stepsForward, stepsRight, posX, posY)); }// @ F0153_DUNGEON_GetRelativeSquareType }; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index ad8d230e6b..385b23fdac 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -253,6 +253,10 @@ void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) { blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport); } +void drawSquareD3L(direction dir, int16 posX, int16 posY) { + +} + enum WallSetIndices { kDoorFrameFront = 0, // @ G0709_puc_Bitmap_WallSet_DoorFrameFront @@ -273,7 +277,7 @@ enum WallSetIndices { kDoorFrameRight_D1C = 14// @ G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C }; -void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) { +void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { loadPalette(kPalDungeonView0); // TODO: this is a global variable, set from here bool flippedFloorCeiling = (posX + posY + dir) & 1; @@ -296,11 +300,14 @@ void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) { drawWallSetBitmap(_floorBitmap, gFloorFrame); } - if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallSquareType) + if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallElemType) drawWallSetBitmap(_wallSetBitMaps[kWall_D3L2], gWallFrameD3L2); - if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallSquareType) + if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallElemType) drawWallSetBitmap(_wallSetBitMaps[kWall_D3R2], gWallFrameD3R2); + // D3L + int16 tmpPosX = posX, tmpPosY = posY; + _vm->_dungeonMan->getRelSquareType(dir, 3, -1, tmpPosX, tmpPosY); diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index b2c29bf8c6..5670a5657c 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -87,6 +87,7 @@ class DisplayMan { void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap void unpackGraphics(); void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap + void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L public: DisplayMan(DMEngine *dmEngine); ~DisplayMan(); @@ -117,7 +118,7 @@ public: void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color); void clearScreen(Color color); - void drawDungeon(direction dir, uint16 posX, uint16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF + void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); }; -- cgit v1.2.3 From 6d5f8e2757d04d47208f096795cb3755fd8a16f2 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Fri, 13 May 2016 16:13:19 +0200 Subject: DM: Add wrapper class around raw map bytes --- engines/dm/dungeonman.cpp | 37 +++++++++++++++++++-------------- engines/dm/dungeonman.h | 52 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 61 insertions(+), 28 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 80239e14fe..b94382e9b7 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -282,36 +282,43 @@ void DungeonMan::setCurrentMap(uint16 mapIndex) { = &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]]; } -byte DungeonMan::getSquare(int16 mapX, int16 mapY) { + +Square DungeonMan::getSquare(int16 mapX, int16 mapY) { bool isInXBounds = (mapX >= 0) && (mapX < _currMap.width); bool isInYBounds = (mapY >= 0) && (mapY < _currMap.height); if (isInXBounds && isInYBounds) return _currMap.data[mapX][mapY]; - int16 tmpSquare; + + Square tmpSquare; if (isInYBounds) { - tmpSquare = getSquareType(_currMap.data[0][mapY]); - if (mapX == -1 && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType)) - return (kWallElemType << 5) | kWallEastRandOrnAllowed; + Square tmpSquare(_currMap.data[0][mapY]); + if (mapX == -1 && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) + return Square(kWallElemType).set(kWallEastRandOrnAllowed); - tmpSquare = getSquareType(_currMap.data[_currMap.width - 1][mapY]); - if (mapX == _currMap.width && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType)) - return (kWallElemType << 5) | kWallWestRandOrnAllowed; + tmpSquare.set(_currMap.data[_currMap.width - 1][mapY]); + if (mapX == _currMap.width && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) + return Square(kWallElemType).set(kWallWestRandOrnAllowed); } else if (isInXBounds) { - tmpSquare = getSquareType(_currMap.data[mapX][0]); - if (mapY == -1 && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType)) - return (kWallElemType << 5) | kWallSouthRandOrnAllowed; + tmpSquare.set(_currMap.data[mapX][0]); + if (mapY == -1 && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) + return Square(kWallElemType).set(kWallSouthRandOrnAllowed); - tmpSquare = getSquareType(_currMap.data[mapX][_currMap.height - 1]); - if (mapY == _currMap.height && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType)) + tmpSquare.set(_currMap.data[mapX][_currMap.height - 1]); + if (mapY == _currMap.height && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) return (kWallElemType << 5) | kWallNorthRandOrnAllowed; } - return kWallElemType << 5; + return Square(kWallElemType); } -byte DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { +Square DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY); return getSquare(posX, posY); +} + +Thing DungeonMan::getSqureFirstThingIndex(int16 mapX, int16 mapY) { + //if (mapX < 0 || mapX >= _currMap.width || mapY < 0 || mapY >= _currMap.height || !(_currMap.data[mapX] & kThingListPresent)) + return Thing(); } \ No newline at end of file diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index dbe13d3018..8c7ed84bb3 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -26,7 +26,27 @@ enum ThingType { kThingTypeTotal = 16 // +1 than the last }; // @ C[00..15]_THING_TYPE_... -enum ElementType { + +enum SquareMask { + kWallWestRandOrnAllowed = 0x1, + kWallSouthRandOrnAllowed = 0x2, + kWallEastRandOrnAllowed = 0x4, + kWallNorthRandOrnAllowed = 0x8, + kPitImaginary = 0x1, + kPitInvisible = 0x4, + kPitOpen = 0x8, + kStairsUp = 0x4, + kStairsNorthSouthOrient = 0x8, + kDoorNorthSouthOrient = 0x8, + kTeleporterVisible = 0x4, + kTeleporterOpen = 0x8, + kFakeWallImaginary = 0x1, + kFakeWallOpen = 0x4, + kFakeWallRandOrnOrFootPAllowed = 0x8, + kThingListPresent = 0x10 +}; + +enum SquareType { kChampionElemType = -2, kCreatureElemType = -1, kWallElemType = 0, @@ -42,11 +62,17 @@ enum ElementType { kStairsFrontElemType = 19 }; // @ C[-2..19]_ELEMENT_... -enum WallOrnMask { - kWallWestRandOrnAllowed = 0x1, - kWallSouthRandOrnAllowed = 0x2, - kWallEastRandOrnAllowed = 0x4, - kWallNorthRandOrnAllowed = 0x8 +class Square { + byte dat; +public: + Square(byte dat = 0) : dat(dat) {} + Square(SquareType type) { setType(type); } + Square &set(byte dat) { this->dat = dat; return *this; } + Square &set(SquareMask mask) { dat |= mask; return *this; } + bool get(SquareMask mask) { return dat & mask; } + SquareType getType() { return (SquareType)(dat >> 5); } // @ M34_SQUARE_TYPE + Square &setType(SquareType type) { dat = (dat & 0x1F) | type << 5; return *this; } + byte toByte() { return dat; } // I don't like 'em casts }; @@ -169,12 +195,12 @@ class DungeonMan { DungeonMan(const DungeonMan &other); // no implementation on purpose void operator=(const DungeonMan &rhs); // no implementation on purpose - byte getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare - byte getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare - - ElementType getSquareType(int16 square) { return (ElementType)(square << 5); } // @ M34_SQUARE_TYPE + Square getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare + Square getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon + + Thing getSqureFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex public: DungeonMan(DMEngine *dmEngine); ~DungeonMan(); @@ -182,9 +208,9 @@ public: void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap void mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement - ElementType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { - return getSquareType(getRelSquare(dir, stepsForward, stepsRight, posX, posY)); - }// @ F0153_DUNGEON_GetRelativeSquareType + SquareType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { + return Square(getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType(); + } // @ F0153_DUNGEON_GetRelativeSquareType }; } -- cgit v1.2.3 From a8c82c1e947e845e201aa114a246a5b3e3dd863b Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Sun, 15 May 2016 15:53:00 +0200 Subject: DM: Add some draw dungeon dependencies I forgot to do commits and it was already too late to revert back the changes I've because they were too numerous. --- engines/dm/dm.cpp | 14 +- engines/dm/dm.h | 2 +- engines/dm/dungeonman.cpp | 302 ++++++++++++++++++++--- engines/dm/dungeonman.h | 372 +++++++++++++++++++++++----- engines/dm/gfx.cpp | 604 ++++++++++++++++++++++++++++++++++++++++++---- engines/dm/gfx.h | 87 +++++-- 6 files changed, 1222 insertions(+), 159 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 60b2b2a3cb..ee818495e4 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -53,15 +53,18 @@ Common::Error DMEngine::run() { _console = new Console(this); _displayMan = new DisplayMan(this); _dungeonMan = new DungeonMan(this); + + _dungeonMan->loadDungeonFile(); + _displayMan->setUpScreens(320, 200); _displayMan->loadGraphics(); - _dungeonMan->loadDungeonFile(); - _displayMan->loadFloorSet(kFloorSetStone); - _displayMan->loadWallSet(kWallSetStone); - _displayMan->loadPalette(kPalCredits); - _dungeonMan->setCurrentMap(0); + _displayMan->loadCurrentMapGraphics(); + + _displayMan->loadPalette(gPalCredits); + + _dungeonMan->setCurrentMapAndPartyMap(0); uint16 i = 0; //TODO: testing, please delete me while (true) { @@ -69,6 +72,7 @@ Common::Error DMEngine::run() { _displayMan->drawDungeon(kDirNorth, i++, 0); _displayMan->updateScreen(); _system->delayMillis(1000); //TODO: testing, please set me to 10 + if (i == 3) break; } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index d5d748754f..7c8afd132a 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -33,8 +33,8 @@ public: private: Console *_console; - Common::RandomSource *_rnd; public: + Common::RandomSource *_rnd; DisplayMan *_displayMan; DungeonMan *_dungeonMan; }; diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index b94382e9b7..46d4f62704 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1,4 +1,5 @@ #include "dungeonman.h" +#include "gfx.h" #include "common/file.h" #include "common/memstream.h" @@ -11,10 +12,46 @@ int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 / void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } + } using namespace DM; +CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo + /* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo, + MovementTicks, AttackTicks, Defense, BaseHealth, Attack, PoisonAttack, + Dexterity, Ranges, Properties, Resistances, AnimationTicks, WoundProbabilities, AttackType } */ + {0, 4, 0x0482, 0x623D, 8, 20, 55, 150, 150, 240, 55, 0x1153, 0x299B, 0x0876, 0x0254, 0xFD40, 4}, + {1, 0, 0x0480, 0xA625, 15, 32, 20, 110, 80, 15, 20, 0x3132, 0x33A9, 0x0E42, 0x0384, 0xFC41, 3}, + {2, 6, 0x0510, 0x6198, 3, 5, 50, 10, 10, 0, 110, 0x1376, 0x710A, 0x0235, 0x0222, 0xFD20, 0}, + {3, 0, 0x04B4, 0xB225, 10, 21, 30, 40, 58, 0, 80, 0x320A, 0x96AA, 0x0B3C, 0x0113, 0xF910, 5}, + {4, 1, 0x0701, 0xA3B8, 9, 8, 45, 101, 90, 0, 65, 0x1554, 0x58FF, 0x0A34, 0x0143, 0xFE93, 4}, + {5, 0, 0x0581, 0x539D, 20, 18, 100, 60, 30, 0, 30, 0x1232, 0x4338, 0x0583, 0x0265, 0xFFD6, 3}, + {6, 3, 0x070C, 0x0020, 120, 10, 5, 165, 5, 0, 5, 0x1111, 0x10F1, 0x0764, 0x02F2, 0xFC84, 6}, + {7, 7, 0x0300, 0x0220, 185, 15, 170, 50, 40, 5, 10, 0x1463, 0x25C4, 0x06E3, 0x01F4, 0xFD93, 4}, /* Atari ST: AttackSoundOrdinal = 0 */ + {8, 2, 0x1864, 0x5225, 11, 16, 15, 30, 55, 0, 80, 0x1423, 0x4664, 0x0FC8, 0x0116, 0xFB30, 6}, + {9, 10, 0x0282, 0x71B8, 21, 14, 240, 120, 219, 0, 35, 0x1023, 0x3BFF, 0x0FF7, 0x04F3, 0xF920, 3}, /* Atari ST: AttackSoundOrdinal = 7 */ + {10, 2, 0x1480, 0x11B8, 17, 12, 25, 33, 20, 0, 40, 0x1224, 0x5497, 0x0F15, 0x0483, 0xFB20, 3}, + {11, 0, 0x18C6, 0x0225, 255, 8, 45, 80, 105, 0, 60, 0x1314, 0x55A5, 0x0FF9, 0x0114, 0xFD95, 1}, + {12, 11, 0x1280, 0x6038, 7, 7, 22, 20, 22, 0, 80, 0x1013, 0x6596, 0x0F63, 0x0132, 0xFA30, 4}, /* Atari ST: AttackSoundOrdinal = 8 */ + {13, 9, 0x14A2, 0xB23D, 5, 10, 42, 39, 90, 100, 88, 0x1343, 0x5734, 0x0638, 0x0112, 0xFA30, 4}, /* Atari ST: AttackSoundOrdinal = 0 */ + {14, 0, 0x05B8, 0x1638, 10, 20, 47, 44, 75, 0, 90, 0x4335, 0xD952, 0x035B, 0x0664, 0xFD60, 5}, + {15, 5, 0x0381, 0x523D, 18, 19, 72, 70, 45, 35, 35, 0x1AA1, 0x15AB, 0x0B93, 0x0253, 0xFFC5, 4}, + {16, 10, 0x0680, 0xA038, 13, 8, 28, 20, 25, 0, 41, 0x1343, 0x2148, 0x0321, 0x0332, 0xFC30, 3}, /* Atari ST: AttackSoundOrdinal = 7 */ + {17, 0, 0x04A0, 0xF23D, 1, 16, 180, 8, 28, 20, 150, 0x1432, 0x19FD, 0x0004, 0x0112, 0xF710, 4}, + {18, 11, 0x0280, 0xA3BD, 14, 6, 140, 60, 105, 0, 70, 0x1005, 0x7AFF, 0x0FFA, 0x0143, 0xFA30, 4}, /* Atari ST: AttackSoundOrdinal = 8 */ + {19, 0, 0x0060, 0xE23D, 5, 18, 15, 33, 61, 0, 65, 0x3258, 0xAC77, 0x0F56, 0x0117, 0xFC40, 5}, + {20, 8, 0x10DE, 0x0225, 25, 25, 75, 144, 66, 0, 50, 0x1381, 0x7679, 0x0EA7, 0x0345, 0xFD93, 3}, /* Atari ST: AttackSoundOrdinal = 0 */ + {21, 3, 0x0082, 0xA3BD, 7, 15, 33, 77, 130, 0, 60, 0x1592, 0x696A, 0x0859, 0x0224, 0xFC30, 4}, + {22, 0, 0x1480, 0x53BD, 10, 14, 68, 100, 100, 0, 75, 0x4344, 0xBDF9, 0x0A5D, 0x0124, 0xF920, 3}, + {23, 0, 0x38AA, 0x0038, 12, 22, 255, 180, 210, 0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}, + {24, 1, 0x068A, 0x97BD, 13, 28, 110, 255, 255, 0, 70, 0x3645, 0xBF7C, 0x06CD, 0x0445, 0xFC30, 4}, /* Atari ST Version 1.0 1987-12-08 1987-12-11: Ranges = 0x2645 */ + {25, 0, 0x38AA, 0x0000, 12, 22, 255, 180, 210, 0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}, + {26, 0, 0x38AA, 0x0000, 12, 22, 255, 180, 210, 0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}}; + +int16 DM::ordinalToIndex(int16 val) { return val - 1; } +int16 DM::indexToOrdinal(int16 val) { return val + 1; } + void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) { posX += dirIntoStepCountEast[dir] * stepsForward; @@ -34,6 +71,11 @@ DungeonMan::~DungeonMan() { delete[] _dunData.squareFirstThings; delete[] _dunData.textData; delete[] _dunData.mapData; + for (uint16 i = 0; i < 16; ++i) { + if (_dunData.thingsData[i]) + delete[] _dunData.thingsData[i][0]; + delete[] _dunData.thingsData[i]; + } } void DungeonMan::decompressDungeonFile() { @@ -113,27 +155,28 @@ uint8 gAdditionalThingCounts[16] = { 50 /* Explosion */ }; // @ G0236_auc_Graphic559_AdditionalThingCounts -// TODO: refactor THINGS into classes -unsigned char gThingDataByteCount[16] = { - 4, /* Door */ - 6, /* Teleporter */ - 4, /* Text String */ - 8, /* Sensor */ - 16, /* Group */ - 4, /* Weapon */ - 4, /* Armour */ - 4, /* Scroll */ - 4, /* Potion */ - 8, /* Container */ - 4, /* Junk */ +// this is the number of uint16s the data has to be stored, not the lenght of the data in dungeon.dat! +unsigned char gThingDataWordCount[16] = { + 2, /* Door */ + 3, /* Teleporter */ + 2, /* Text String */ + 4, /* Sensor */ + 9, /* Group */ + 2, /* Weapon */ + 2, /* Armour */ + 2, /* Scroll */ + 2, /* Potion */ + 4, /* Container */ + 2, /* Junk */ 0, /* Unused */ 0, /* Unused */ 0, /* Unused */ - 8, /* Projectile */ - 4 /* Explosion */ + 5, /* Projectile */ + 2 /* Explosion */ }; // @ G0235_auc_Graphic559_ThingDataByteCount -const Thing Thing::specThingNone(0, 0, 0); +const Thing Thing::thingNone(0); +const Thing Thing::thingEndOfList(0xFFFE); void DungeonMan::loadDungeonFile() { @@ -193,8 +236,8 @@ void DungeonMan::loadDungeonFile() { tmp = dunDataStream.readUint16BE(); _maps[i].doorSet1 = (tmp >> 12) & 0xF; _maps[i].doorSet0 = (tmp >> 8) & 0xF; - _maps[i].wallSet = (tmp >> 4) & 0xF; - _maps[i].floorSet = tmp & 0xF; + _maps[i].wallSet = (WallSet)((tmp >> 4) & 0xF); + _maps[i].floorSet = (FloorSet)(tmp & 0xF); } // TODO: ??? is this - begin @@ -228,7 +271,7 @@ void DungeonMan::loadDungeonFile() { _dunData.squareFirstThings[i].set(dunDataStream.readUint16BE()); if (_messages.newGame) for (uint16 i = 0; i < 300; ++i) - _dunData.squareFirstThings[i] = Thing::specThingNone; + _dunData.squareFirstThings[i] = Thing::thingNone; // TODO: ??? is this - end @@ -243,12 +286,51 @@ void DungeonMan::loadDungeonFile() { if (_messages.newGame) _dunData.eventMaximumCount = 100; - // load 'Things' - // TODO: implement load things - // this is a temporary workaround to seek to raw map data - for (uint16 i = 0; i < kThingTypeTotal; ++i) - dunDataStream.skip(_fileHeader.thingCounts[i] * gThingDataByteCount[i]); + // load things + for (uint16 thingType = kDoorThingType; thingType < kThingTypeTotal; ++thingType) { + uint16 thingCount = _fileHeader.thingCounts[thingType]; + if (_messages.newGame) { + // _fileHeader.thingCounts[thingType] = 1024; // TODO: what this?? check back later + } + uint16 thingStoreWordCount = gThingDataWordCount[thingType]; + if (!thingStoreWordCount || !thingCount) + continue; + + if (_dunData.thingsData[thingType]) { + delete[] _dunData.thingsData[thingType][0]; + delete[] _dunData.thingsData[thingType]; + } + _dunData.thingsData[thingType] = new uint16*[thingCount]; + _dunData.thingsData[thingType][0] = new uint16[thingCount * thingStoreWordCount]; + for (uint16 i = 0; i < thingCount; ++i) + _dunData.thingsData[thingType][i] = _dunData.thingsData[thingType][0] + i * thingStoreWordCount; + + if (thingType == kGroupThingType) { + for (uint16 i = 0; i < thingCount; ++i) + for (uint16 j = 0; j < thingStoreWordCount; ++j) { + if (j == 2 || j == 3) + _dunData.thingsData[thingType][i][j] = dunDataStream.readByte(); + else + _dunData.thingsData[thingType][i][j] = dunDataStream.readUint16BE(); + } + } else if (thingType == kProjectileThingType) { + for (uint16 i = 0; i < thingCount; ++i) { + _dunData.thingsData[thingType][i][0] = dunDataStream.readUint16BE(); + _dunData.thingsData[thingType][i][1] = dunDataStream.readUint16BE(); + _dunData.thingsData[thingType][i][2] = dunDataStream.readByte(); + _dunData.thingsData[thingType][i][3] = dunDataStream.readByte(); + _dunData.thingsData[thingType][i][4] = dunDataStream.readUint16BE(); + } + } else { + for (uint16 i = 0; i < thingCount; ++i) + for (uint16 j = 0; j < thingStoreWordCount; ++j) + _dunData.thingsData[thingType][i][j] = dunDataStream.readUint16BE(); + } + } + + + // load map data _rawMapData = _rawDunFileData + dunDataStream.pos(); if (_dunData.mapData) delete[] _dunData.mapData; @@ -282,6 +364,26 @@ void DungeonMan::setCurrentMap(uint16 mapIndex) { = &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]]; } +void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) { + setCurrentMap(mapIndex); + + byte *metaMapData = _currMap.data[_currMap.width - 1] + _currMap.height; + _vm->_displayMan->_currMapAllowedCreatureTypes = metaMapData; + + metaMapData += _currMap.map->creatureTypeCount; + memcpy(_vm->_displayMan->_currMapWallOrnIndices, metaMapData, _currMap.map->wallOrnCount); + + metaMapData += _currMap.map->wallOrnCount; + memcpy(_vm->_displayMan->_currMapFloorOrnIndices, metaMapData, _currMap.map->floorOrnCount); + + metaMapData += _currMap.map->wallOrnCount; + memcpy(_vm->_displayMan->_currMapDoorOrnIndices, metaMapData, _currMap.map->doorOrnCount); + + _currMapInscriptionWallOrnIndex = _currMap.map->wallOrnCount; + _vm->_displayMan->_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = kWallOrnInscription; + +} + Square DungeonMan::getSquare(int16 mapX, int16 mapY) { bool isInXBounds = (mapX >= 0) && (mapX < _currMap.width); @@ -293,7 +395,7 @@ Square DungeonMan::getSquare(int16 mapX, int16 mapY) { Square tmpSquare; if (isInYBounds) { - Square tmpSquare(_currMap.data[0][mapY]); + tmpSquare.set(_currMap.data[0][mapY]); if (mapX == -1 && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) return Square(kWallElemType).set(kWallEastRandOrnAllowed); @@ -318,7 +420,149 @@ Square DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRi return getSquare(posX, posY); } -Thing DungeonMan::getSqureFirstThingIndex(int16 mapX, int16 mapY) { - //if (mapX < 0 || mapX >= _currMap.width || mapY < 0 || mapY >= _currMap.height || !(_currMap.data[mapX] & kThingListPresent)) - return Thing(); -} \ No newline at end of file +int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) { + if (mapX < 0 || mapX >= _currMap.width || mapY < 0 || mapY >= _currMap.height || !Square(_currMap.data[mapX][mapY]).get(kThingListPresent)) + return -1; + + int16 y; + uint16 index = _currMap.colCumulativeSquareFirstThingCount[mapX]; + byte* square = _currMap.data[mapX]; + while (y++ != mapY) + if (Square(*square++).get(kThingListPresent)) + index++; + + return index; +} + +Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) { + int16 index = getSquareFirstThingIndex(mapX, mapY); + if (index == -1) + return Thing::thingEndOfList; + return _dunData.squareFirstThings[index]; +} + +enum SquareAspectIndice { + kElemAspect = 0, + kFirstGroupOrObjectAspect = 1, + kRightWallOrnOrdAspect = 2, + kFrontWallOrnOrdAspect = 3, + kLeftWallOrnOrdAspect = 4, + kPitInvisibleAspect = 2, + kTeleporterVisibleAspect = 2, + kStairsUpAspect = 2, + kDoorStateAspect = 2, + kDoorThingIndexAspect = 3, + kFloorOrnOrdAspect = 4 +}; + + +void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) { + bool leftOrnAllowed, rightOrnAllowed, frontOrnAllowed; + bool squareIsFakeWall; + + Thing thing = getSquareFirstThing(mapX, mapY); + Square square = getSquare(mapX, mapY); + + memset(aspectArray, 0, 5 * sizeof(int16)); + aspectArray[kElemAspect] = square.getType(); + + _vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75 + switch (square.getType()) { + case kWallElemType: + switch (dir) { + case kDirNorth: + leftOrnAllowed = square.get(kWallEastRandOrnAllowed); + frontOrnAllowed = square.get(kWallSouthRandOrnAllowed); + rightOrnAllowed = square.get(kWallWestRandOrnAllowed); + break; + case kDirEast: + leftOrnAllowed = square.get(kWallSouthRandOrnAllowed); + frontOrnAllowed = square.get(kWallWestRandOrnAllowed); + rightOrnAllowed = square.get(kWallNorthRandOrnAllowed); + break; + case kDirSouth: + leftOrnAllowed = square.get(kWallWestRandOrnAllowed); + frontOrnAllowed = square.get(kWallNorthRandOrnAllowed); + rightOrnAllowed = square.get(kWallEastRandOrnAllowed); + break; + case kDirWest: + leftOrnAllowed = square.get(kWallNorthRandOrnAllowed); + frontOrnAllowed = square.get(kWallEastRandOrnAllowed); + rightOrnAllowed = square.get(kWallSouthRandOrnAllowed); + break; + } + + squareIsFakeWall = false; + setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall); + + while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) { + int16 sideIndex = (thing.getCell() - dir) & 3; + if (sideIndex) { + if (thing.getType() == kTextstringType) { + if (TextString(getThingData(thing)).isVisible()) { + aspectArray[sideIndex + 1] = _currMapInscriptionWallOrnIndex + 1; + + } else { + Sensor sensor(getThingData(thing)); + aspectArray[sideIndex + 1] = sensor.getOrnOrdinal(); + if (sensor.getType() == kSensorWallChampionPortrait) { + _vm->_displayMan->_championPortraitOrdinal = indexToOrdinal(sensor.getData()); + } + } + } + } + thing = getNextThing(thing); + } + if (squareIsFakeWall && (_currMap.partyPosX != mapX) && (_currMap.partyPosY != mapY)) { + aspectArray[kFirstGroupOrObjectAspect] = Thing::thingEndOfList.toUint16(); + } + break; + } + aspectArray[kFirstGroupOrObjectAspect] = thing.toUint16(); +} + +void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, + int16 mapX, int16 mapY, bool isFakeWall) { + int16 ornCount = _currMap.map->randWallOrnCount; + + turnDirRight(dir); + aspectArray[kRightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); + turnDirRight(dir); + aspectArray[kFrontWallOrnOrdAspect] = getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); + turnDirRight(dir); + aspectArray[kLeftWallOrnOrdAspect] = getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); + + if (isFakeWall || mapX < 0 || mapX >= _currMap.width || mapY < 0 || mapY >= _currMap.height) { + for (uint16 i = kRightWallOrnOrdAspect; i <= kLeftWallOrnOrdAspect; ++i) { + if (isWallOrnAnAlcove(ordinalToIndex(aspectArray[i]))) + aspectArray[i] = 0; + } + } +} + +int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) { + int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1) + + (3000 + (_currMap.index << 6) + _currMap.width + _currMap.height) * 11 + + _fileHeader.ornamentRandomSeed) >> 2) % modulo; + if (allowed && index < count) + return indexToOrdinal(index); + return 0; +} + + +bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) { + if (wallOrnIndex >= 0) + for (uint16 i = 0; i < kAlcoveOrnCount; ++i) + if (_vm->_displayMan->_currMapAlcoveOrnIndices[i] == wallOrnIndex) + return true; + return false; +} + +uint16 *DungeonMan::getThingData(Thing thing) { + return _dunData.thingsData[thing.getType()][thing.getIndex()]; +} + +Thing DungeonMan::getNextThing(Thing thing) { + return getThingData(thing)[0]; // :) +} + diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 8c7ed84bb3..df8395312c 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -2,12 +2,16 @@ #define DUNGEONMAN_H #include "dm.h" +#include "gfx.h" namespace DM { class DungeonMan; -class Map; +struct Map; + +int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX +int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL enum ThingType { kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value kDoorThingType = 0, @@ -23,9 +27,270 @@ enum ThingType { kJunkThingType = 10, kProjectileThingType = 14, kExplosionThingType = 15, - kThingTypeTotal = 16 // +1 than the last + kThingTypeTotal = 16 // +1 than the last (explosionThingType) }; // @ C[00..15]_THING_TYPE_... +class Thing { + uint16 data; +public: + static const Thing thingNone; + static const Thing thingEndOfList; + + Thing() {} + Thing(uint16 d) { set(d); } + + void set(uint16 d) { + data = d; + } + + byte getCell() const { return data >> 14; } + ThingType getType() const { return (ThingType)((data >> 10) & 0xF); } + uint16 getIndex() const { return data & 0x1FF; } + uint16 toUint16() const { return data; } // I don't like 'em cast operators + bool operator==(const Thing &rhs) const { return data == rhs.data; } + bool operator!=(const Thing &rhs) const { return data != rhs.data; } +}; // @ THING + +struct CreatureInfo { + byte creatureAspectIndex; + byte attackSoundOrdinal; + uint16 attributes; /* Bits 15-14 Unreferenced */ + uint16 graphicInfo; /* Bits 11 and 6 Unreferenced */ + byte movementTicks; /* Value 255 means the creature cannot move */ + byte attackTicks; /* Minimum ticks between attacks */ + byte defense; + byte baseHealth; + byte attack; + byte poisonAttack; + byte dexterity; + uint16 Ranges; /* Bits 7-4 Unreferenced */ + uint16 Properties; + uint16 Resistances; /* Bits 15-12 and 3-0 Unreferenced */ + uint16 AnimationTicks; /* Bits 15-12 Unreferenced */ + uint16 WoundProbabilities; /* Contains 4 probabilities to wound a champion's Head (Bits 15-12), Legs (Bits 11-8), Torso (Bits 7-4) and Feet (Bits 3-0) */ + byte AttackType; +}; // @ CREATURE_INFO + + +extern CreatureInfo gCreatureInfo[kCreatureTypeCount]; + +class Door { + Thing nextThing; + uint16 attributes; +public: + Door(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} + Thing getNextThing() { return nextThing; } + bool isMeleeDestructible() { return (attributes >> 8) & 1; } + bool isMagicDestructible() { return (attributes >> 7) & 1; } + bool hasButton() { return (attributes >> 6) & 1; } + bool opensVertically() { return (attributes >> 5) & 1; } + byte getOrnOrdinal() { return (attributes >> 1) & 0xF; } + byte getType() { return attributes & 1; } +}; // @ DOOR + +enum TeleporterScope { + kTelepScopeCreatures = 1, // @ MASK0x0001_SCOPE_CREATURES + kTelepScopeObjOrParty = 2 // @ MASK0x0002_SCOPE_OBJECTS_OR_PARTY +}; + + +class Teleporter { + Thing nextThing; + uint16 attributes; + uint16 destMapIndex; +public: + Teleporter(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]), destMapIndex(rawDat[2]) {} + Thing getNextThing() { return nextThing; } + bool makesSound() { return (attributes >> 15) & 1; } + TeleporterScope getScope() { return (TeleporterScope)((attributes >> 13) & 1); } + bool absRotation() { return (attributes >> 12) & 1; } + direction getRotationDir() { return (direction)((attributes >> 10) & 1); } + byte getDestY() { return (attributes >> 5) & 0xF; } + byte getDestX() { return attributes & 0xF; } + uint16 getDestMapIndex() { return destMapIndex >> 8; } +}; // @ TELEPORTER + + + +class TextString { + Thing nextThing; + uint16 textDataRef; +public: + TextString(uint16 *rawDat) : nextThing(rawDat[0]), textDataRef(rawDat[1]) {} + + Thing getNextThing() { return nextThing; } + uint16 getWordOffset() { return textDataRef >> 3; } + bool isVisible() { return textDataRef & 1; } +}; // @ TEXTSTRING + +enum SensorActionType { + kSensorEffNone = -1, // @ CM1_EFFECT_NONE + kSensorEffSet = 0, // @ C00_EFFECT_SET + kSensorEffClear = 1, // @ C01_EFFECT_CLEAR + kSensorEffToggle = 2, // @ C02_EFFECT_TOGGLE + kSensorEffHold = 3, // @ C03_EFFECT_HOLD + kSensorEffAddExp = 10 // @ C10_EFFECT_ADD_EXPERIENCE +}; + +enum SensorType { + kSensorDisabled = 0, // @ C000_SENSOR_DISABLED /* Never triggered, may be used for a floor or wall ornament */ + kSensorFloorTheronPartyCreatureObj = 1, // @ C001_SENSOR_FLOOR_THERON_PARTY_CREATURE_OBJECT /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorFloorTheronPartyCreature = 2, // @ C002_SENSOR_FLOOR_THERON_PARTY_CREATURE /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorFloorParty = 3, // @ C003_SENSOR_FLOOR_PARTY /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorFloorObj = 4, // @ C004_SENSOR_FLOOR_OBJECT /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorFloorPartyOnStairs = 5, // @ C005_SENSOR_FLOOR_PARTY_ON_STAIRS /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorFloorGroupGenerator = 6, // @ C006_SENSOR_FLOOR_GROUP_GENERATOR /* Triggered by event F0245_TIMELINE_ProcessEvent5_Square_Corridor */ + kSensorFloorCreature = 7, // @ C007_SENSOR_FLOOR_CREATURE /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorFloorPartyPossession = 8, // @ C008_SENSOR_FLOOR_PARTY_POSSESSION /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorFloorVersionChecker = 9, // @ C009_SENSOR_FLOOR_VERSION_CHECKER /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorWallOrnClick = 1, // @ C001_SENSOR_WALL_ORNAMENT_CLICK /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallOrnClickWithAnyObj = 2, // @ C002_SENSOR_WALL_ORNAMENT_CLICK_WITH_ANY_OBJECT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallOrnClickWithSpecObj = 3, // @ C003_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallOrnClickWithSpecObjRemoved = 4, // @ C004_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallAndOrGate = 5, // @ C005_SENSOR_WALL_AND_OR_GATE /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallCountdown = 6, // @ C006_SENSOR_WALL_COUNTDOWN /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallSingleProjLauncherNewObj = 7, // @ C007_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_NEW_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallSingleProjLauncherExplosion = 8, // @ C008_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_EXPLOSION /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallDoubleProjLauncherNewObj = 9, // @ C009_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_NEW_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallDoubleProjLauncherExplosion = 10, // @ C010_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_EXPLOSION /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallOrnClickWithSpecObjRemovedRotateSensors = 11, // @ C011_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_ROTATE_SENSORS /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallObjGeneratorRotateSensors = 12, // @ C012_SENSOR_WALL_OBJECT_GENERATOR_ROTATE_SENSORS /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallSingleObjStorageRotateSensors = 13, // @ C013_SENSOR_WALL_SINGLE_OBJECT_STORAGE_ROTATE_SENSORS /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallSingleProjLauncherSquareObj = 14, // @ C014_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallDoubleProjLauncherSquareObj = 15, // @ C015_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallObjExchanger = 16, // @ C016_SENSOR_WALL_OBJECT_EXCHANGER /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallOrnClickWithSpecObjRemovedSensor = 17, // @ C017_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_REMOVE_SENSOR /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallEndGame = 18, // @ C018_SENSOR_WALL_END_GAME /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallChampionPortrait = 127 // @ C127_SENSOR_WALL_CHAMPION_PORTRAIT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ +}; + +class Sensor { + Thing nextThing; + uint16 datAndType; + uint16 attributes; + uint16 action; +public: + Sensor(uint16 *rawDat) : nextThing(rawDat[0]), datAndType(rawDat[1]), attributes(rawDat[2]), action(rawDat[3]) {} + + Thing getNextThing() { return nextThing; } + SensorType getType() { return (SensorType)(datAndType & 0x7F); } // @ M39_TYPE + uint16 getData() { return datAndType >> 7; } // @ M40_DATA + uint16 getDataMask1() { return (datAndType >> 7) & 0xF; } // @ M42_MASK1 + uint16 getDataMask2() { return (datAndType >> 11) & 0xF; } // @ M43_MASK2 + void setData(int16 dat) { datAndType = (datAndType & 0x7F) | (dat << 7); } // @ M41_SET_DATA + void setTypeDisabled() { datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED + uint16 getOrnOrdinal() { return attributes >> 12; } + bool isLocalAction() { return (attributes >> 11) & 1; } + uint16 getDelay() { return (attributes >> 7) & 0xF; } + bool hasSound() { return (attributes >> 6) & 1; } + bool shouldRevert() { return (attributes >> 5) & 1; } + SensorActionType getActionType() { return (SensorActionType)((attributes >> 3) & 3); } + bool isSingleUse() { return (attributes >> 2) & 1; } + uint16 getRemoteMapY() { return (action >> 11); } + uint16 getRemoteMapX() { return (action >> 6) & 0x1F; } + direction getRemoteDir() { return (direction)((action >> 4) & 3); } + uint16 getLocalAction() { return (action >> 4); } + // some macros missing, i got bored +}; // @ SENSOR + +class Group { + Thing nextThing; + Thing possessionID; + byte type; + byte position; + uint16 health[4]; + uint16 attributes; +public: + Group(uint16 *rawDat) : nextThing(rawDat[0]), possessionID(rawDat[1]), type(rawDat[2]), + position(rawDat[3]), attributes(rawDat[8]) { + health[0] = rawDat[4]; + health[1] = rawDat[5]; + health[2] = rawDat[6]; + health[3] = rawDat[7]; + } + Thing getNextThing() { return nextThing; } +}; // @ GROUP + +class Weapon { + Thing nextThing; + uint16 desc; +public: + Weapon(uint16 *rawDat) : nextThing(rawDat[0]), desc(rawDat[1]) {} + + Thing getNextThing() { return nextThing; } +}; // @ WEAPON + +class Armour { + Thing nextThing; + uint16 attributes; +public: + Armour(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} + + Thing getNextThing() { return nextThing; } +}; // @ ARMOUR + +class Scroll { + Thing nextThing; + uint16 attributes; +public: + Scroll(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} + void set(Thing next, uint16 attribs) { + nextThing = next; + attributes = attribs; + } + Thing getNextThing() { return nextThing; } +}; // @ SCROLL + +class Potion { + Thing nextThing; + uint16 attributes; +public: + Potion(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} + + Thing getNextThing() { return nextThing; } +}; // @ POTION + +class Container { + Thing nextThing; + Thing nextContainedThing; + uint16 type; +public: + Container(uint16 *rawDat) : nextThing(rawDat[0]), nextContainedThing(rawDat[1]), type(rawDat[2]) {} + + Thing getNextThing() { return nextThing; } +}; // @ CONTAINER + +class Junk { + Thing nextThing; + uint16 attributes; +public: + Junk(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} + + Thing getNextThing() { return nextThing; } +}; // @ JUNK + +class Projectile { + Thing nextThing; + Thing object; + byte kineticEnergy; + byte damageEnergy; + uint16 timerIndex; +public: + Projectile(uint16 *rawDat) : nextThing(rawDat[0]), object(rawDat[1]), kineticEnergy(rawDat[2]), + damageEnergy(rawDat[3]), timerIndex(rawDat[4]) {} + + Thing getNextThing() { return nextThing; } +}; // @ PROJECTILE + +class Explosion { + Thing nextThing; + uint16 attributes; +public: + Explosion(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} + + Thing getNextThing() { return nextThing; } +}; // @ EXPLOSION + enum SquareMask { kWallWestRandOrnAllowed = 0x1, @@ -63,22 +328,20 @@ enum SquareType { }; // @ C[-2..19]_ELEMENT_... class Square { - byte dat; + byte data; public: - Square(byte dat = 0) : dat(dat) {} + Square(byte dat = 0) : data(dat) {} Square(SquareType type) { setType(type); } - Square &set(byte dat) { this->dat = dat; return *this; } - Square &set(SquareMask mask) { dat |= mask; return *this; } - bool get(SquareMask mask) { return dat & mask; } - SquareType getType() { return (SquareType)(dat >> 5); } // @ M34_SQUARE_TYPE - Square &setType(SquareType type) { dat = (dat & 0x1F) | type << 5; return *this; } - byte toByte() { return dat; } // I don't like 'em casts + Square &set(byte dat) { this->data = dat; return *this; } + Square &set(SquareMask mask) { data |= mask; return *this; } + bool get(SquareMask mask) { return data & mask; } + SquareType getType() { return (SquareType)(data >> 5); } // @ M34_SQUARE_TYPE + Square &setType(SquareType type) { data = (data & 0x1F) | type << 5; return *this; } + byte toByte() { return data; } // I don't like 'em casts }; -class DungeonFileHeader { - friend class DungeonMan; - +struct DungeonFileHeader { uint16 dungeonId; // @ G0526_ui_DungeonID // equal to dungeonId uint16 ornamentRandomSeed; @@ -91,9 +354,7 @@ class DungeonFileHeader { uint16 thingCounts[16]; // @ ThingCount[16] }; // @ DUNGEON_HEADER -class Map { - friend class DungeonMan; - +struct Map { uint32 rawDunDataOffset; uint8 offsetMapX, offsetMapY; @@ -109,31 +370,14 @@ class Map { uint8 creatureTypeCount; uint8 difficulty; - uint8 floorSet, wallSet, doorSet0, doorSet1; + FloorSet floorSet; + WallSet wallSet; + uint8 doorSet0, doorSet1; }; // @ MAP -class Thing { - friend class DungeonMan; - - static const Thing specThingNone; - - Thing() {} - Thing(uint8 cell, uint8 type, uint8 index) : cell(cell), type(type), index(index) {} - - void set(uint16 dat) { - cell = dat >> 14; - type = (dat >> 10) & 0xF; - index = dat & 0x1FF; - } - - uint8 cell; - uint8 type; - uint8 index; -}; // @ THING -class DungeonData { - friend class DungeonMan; +struct DungeonData { // I have no idea the heck is this uint16 *mapsFirstColumnIndex = NULL; // @ G0281_pui_DungeonMapsFirstColumnIndex uint16 columCount; // @ G0282_ui_DungeonColumnCount @@ -143,7 +387,7 @@ class DungeonData { Thing *squareFirstThings = NULL; // @ G0283_pT_SquareFirstThings uint16 *textData = NULL; // @ G0260_pui_DungeonTextData - byte *rawThingData[16] = {NULL}; // @ G0284_apuc_ThingData + uint16 **thingsData[16] = {NULL}; // @ G0284_apuc_ThingData byte ***mapData = NULL; // @ G0279_pppuc_DungeonMapData @@ -151,9 +395,7 @@ class DungeonData { uint16 eventMaximumCount; // @ G0369_ui_EventMaximumCount }; // @ AGGREGATE -class CurrMapData { - friend class DungeonMan; - +struct CurrMapData { direction partyDir; // @ G0308_i_PartyDirection uint16 partyPosX; // @ G0306_i_PartyMapX uint16 partyPosY; // @ G0307_i_PartyMapY @@ -168,9 +410,6 @@ class CurrMapData { }; // @ AGGREGATE struct Messages { - friend class DungeonMan; - -private: bool newGame = true; // @ G0298_B_NewGame bool restartGameRequest = false; // @ G0523_B_RestartGameRequested }; // @ AGGREGATE @@ -181,17 +420,6 @@ private: class DungeonMan { DMEngine *_vm; - uint32 _rawDunFileDataSize; // @ probably NONE - byte *_rawDunFileData; // @ ??? - DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader - - DungeonData _dunData; // @ NONE - CurrMapData _currMap; // @ NONE - Map *_maps; // @ G0277_ps_DungeonMaps - // does not have to be freed - byte *_rawMapData; // @ G0276_puc_DungeonRawMapData - Messages _messages; // @ NONE - DungeonMan(const DungeonMan &other); // no implementation on purpose void operator=(const DungeonMan &rhs); // no implementation on purpose @@ -200,19 +428,49 @@ class DungeonMan { void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon - Thing getSqureFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex + int16 getSquareFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex + Thing getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing + + int16 getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal + void setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, + int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals + + bool isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove + + void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap + + Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing) + uint16 *getThingData(Thing thing); // @ unsigned char* F0156_DUNGEON_GetThingData(register THING P0276_T_Thing) public: DungeonMan(DMEngine *dmEngine); ~DungeonMan(); // TODO: this does stuff other than load the file! void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC - void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap + void setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap + void mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement SquareType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { return Square(getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType(); } // @ F0153_DUNGEON_GetRelativeSquareType + void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect + + uint32 _rawDunFileDataSize; // @ probably NONE + byte *_rawDunFileData; // @ ??? + DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader + + DungeonData _dunData; // @ NONE + CurrMapData _currMap; // @ NONE + Map *_maps; // @ G0277_ps_DungeonMaps + // does not have to be freed + byte *_rawMapData; // @ G0276_puc_DungeonRawMapData + Messages _messages; // @ NONE; + + int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex + + }; } + #endif diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 385b23fdac..ae5bcd9f88 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1,33 +1,456 @@ -#include "gfx.h" #include "engines/util.h" #include "common/system.h" #include "common/file.h" #include "graphics/palette.h" #include "common/endian.h" -#include "dm/dungeonman.h" + +#include "gfx.h" +#include "dungeonman.h" namespace DM { -// TODO: this is ONLY for the Amiga version, name will have to be refactored -uint16 dmPalettes[10][16] = { - {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}, - {0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF}, - {0x006, 0x0AA, 0xFF6, 0x840, 0xFF8, 0x000, 0x080, 0xA00, 0xC84, 0xFFA, 0xF84, 0xFC0, 0xFA0, 0x000, 0x620, 0xFFC}, - {0x000, 0x666, 0x888, 0x840, 0xCA8, 0x0C0, 0x080, 0x0A0, 0x864, 0xF00, 0xA86, 0x642, 0x444, 0xAAA, 0x620, 0xFFF}, - {0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x444, 0xAAA, 0x00F, 0xFFF}, - {0x000, 0x444, 0x666, 0x620, 0x0CC, 0x820, 0x060, 0x0A0, 0xC00, 0x000, 0x000, 0xFC0, 0x222, 0x888, 0x00C, 0xCCC}, - {0x000, 0x222, 0x444, 0x420, 0x0CC, 0x620, 0x040, 0x080, 0xA00, 0x000, 0x000, 0xFA0, 0x000, 0x666, 0x00A, 0xAAA}, - {0x000, 0x000, 0x222, 0x200, 0x0CC, 0x420, 0x020, 0x060, 0x800, 0x000, 0x000, 0xC80, 0x000, 0x444, 0x008, 0x888}, - {0x000, 0x000, 0x000, 0x000, 0x0CC, 0x200, 0x000, 0x040, 0x600, 0x000, 0x000, 0xA60, 0x000, 0x222, 0x006, 0x666}, - {0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444} + +#define kFirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT +#define kFirstFloorSet 75 // @ C075_GRAPHIC_FIRST_FLOOR_SET +#define kFirstWallSet 77 // @ C077_GRAPHIC_FIRST_WALL_SET +#define kFirstStairs 90 // @ C090_GRAPHIC_FIRST_STAIRS +#define kFirstDoorSet 108 // @ C108_GRAPHIC_FIRST_DOOR_SET +#define kInscriptionFont 120 // @ C120_GRAPHIC_INSCRIPTION_FONT +#define kFirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT +#define kFirstFloorOrn 247 // @ C247_GRAPHIC_FIRST_FLOOR_ORNAMENT +#define kFirstDoorOrn 303 // @ C303_GRAPHIC_FIRST_DOOR_ORNAMENT + + +byte gDoorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordinateSetIndices + 0, /* Door Ornament #00 Square Grid */ + 1, /* Door Ornament #01 Iron Bars */ + 1, /* Door Ornament #02 Jewels */ + 1, /* Door Ornament #03 Wooden Bars */ + 0, /* Door Ornament #04 Arched Grid */ + 2, /* Door Ornament #05 Block Lock */ + 3, /* Door Ornament #06 Corner Lock */ + 1, /* Door Ornament #07 Black door */ + 2, /* Door Ornament #08 Red Triangle Lock */ + 2, /* Door Ornament #09 Triangle Lock */ + 1, /* Door Ornament #10 Ra Door */ + 1}; /* Door Ornament #11 Iron Door Damages */ + +byte gFloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnamentCoordinateSetIndices + 0, /* Floor Ornament 00 Square Grate */ + 0, /* Floor Ornament 01 Square Pressure Pad */ + 0, /* Floor Ornament 02 Moss */ + 0, /* Floor Ornament 03 Round Grate */ + 2, /* Floor Ornament 04 Round Pressure Plate */ + 0, /* Floor Ornament 05 Black Flame Pit */ + 0, /* Floor Ornament 06 Crack */ + 2, /* Floor Ornament 07 Tiny Pressure Pad */ + 0}; /* Floor Ornament 08 Puddle */ + +byte gWallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets + /* { X1, X2, Y1, Y2, PixelWidth, Height } */ + {{80, 83, 41, 45, 8 * 2, 5}, /* D3L */ + {140, 143, 41, 45, 8 * 2, 5}, /* D3R */ + {16, 29, 39, 50, 8 * 2, 12}, /* D3L */ + {107, 120, 39, 50, 8 * 2, 12}, /* D3C */ + {187, 200, 39, 50, 8 * 2, 12}, /* D3R */ + {67, 77, 40, 49, 8 * 2, 10}, /* D2L */ + {146, 156, 40, 49, 8 * 2, 10}, /* D2R */ + {0, 17, 38, 55, 16 * 2, 18}, /* D2L */ + {102, 123, 38, 55, 16 * 2, 18}, /* D2C */ + {206, 223, 38, 55, 16 * 2, 18}, /* D2R */ + {48, 63, 38, 56, 8 * 2, 19}, /* D1L */ + {160, 175, 38, 56, 8 * 2, 19}, /* D1R */ + {96, 127, 36, 63, 16 * 2, 28}}, /* D1C */ + {{74, 82, 41, 60, 8 * 2, 20}, /* D3L */ + {141, 149, 41, 60, 8 * 2, 20}, /* D3R */ + {1, 47, 37, 63, 24 * 2, 27}, /* D3L */ + {88, 134, 37, 63, 24 * 2, 27}, /* D3C */ + {171, 217, 37, 63, 24 * 2, 27}, /* D3R */ + {61, 76, 38, 67, 8 * 2, 30}, /* D2L */ + {147, 162, 38, 67, 8 * 2, 30}, /* D2R */ + {0, 43, 37, 73, 32 * 2, 37}, /* D2L */ + {80, 143, 37, 73, 32 * 2, 37}, /* D2C */ + {180, 223, 37, 73, 32 * 2, 37}, /* D2R */ + {32, 63, 36, 83, 16 * 2, 48}, /* D1L */ + {160, 191, 36, 83, 16 * 2, 48}, /* D1R */ + {64, 159, 36, 91, 48 * 2, 56}}, /* D1C */ + {{80, 83, 66, 70, 8 * 2, 5}, /* D3L */ + {140, 143, 66, 70, 8 * 2, 5}, /* D3R */ + {16, 29, 64, 75, 8 * 2, 12}, /* D3L */ + {106, 119, 64, 75, 8 * 2, 12}, /* D3C */ + {187, 200, 64, 75, 8 * 2, 12}, /* D3R */ + {67, 77, 74, 83, 8 * 2, 10}, /* D2L */ + {146, 156, 74, 83, 8 * 2, 10}, /* D2R */ + {0, 17, 73, 90, 16 * 2, 18}, /* D2L */ + {100, 121, 73, 90, 16 * 2, 18}, /* D2C */ + {206, 223, 73, 90, 16 * 2, 18}, /* D2R */ + {48, 63, 84, 102, 8 * 2, 19}, /* D1L */ + {160, 175, 84, 102, 8 * 2, 19}, /* D1R */ + {96, 127, 92, 119, 16 * 2, 28}}, /* D1C */ + {{80, 83, 49, 53, 8 * 2, 5}, /* D3L */ + {140, 143, 49, 53, 8 * 2, 5}, /* D3R */ + {16, 29, 50, 61, 8 * 2, 12}, /* D3L */ + {106, 119, 50, 61, 8 * 2, 12}, /* D3C */ + {187, 200, 50, 61, 8 * 2, 12}, /* D3R */ + {67, 77, 53, 62, 8 * 2, 10}, /* D2L */ + {146, 156, 53, 62, 8 * 2, 10}, /* D2R */ + {0, 17, 55, 72, 16 * 2, 18}, /* D2L */ + {100, 121, 55, 72, 16 * 2, 18}, /* D2C */ + {206, 223, 55, 72, 16 * 2, 18}, /* D2R */ + {48, 63, 57, 75, 8 * 2, 19}, /* D1L */ + {160, 175, 57, 75, 8 * 2, 19}, /* D1R */ + {96, 127, 64, 91, 16 * 2, 28}}, /* D1C */ + {{75, 90, 40, 44, 8 * 2, 5}, /* D3L */ + {133, 148, 40, 44, 8 * 2, 5}, /* D3R */ + {1, 48, 44, 49, 24 * 2, 6}, /* D3L */ + {88, 135, 44, 49, 24 * 2, 6}, /* D3C */ + {171, 218, 44, 49, 24 * 2, 6}, /* D3R */ + {60, 77, 40, 46, 16 * 2, 7}, /* D2L */ + {146, 163, 40, 46, 16 * 2, 7}, /* D2R */ + {0, 35, 43, 50, 32 * 2, 8}, /* D2L */ + {80, 143, 43, 50, 32 * 2, 8}, /* D2C */ + {184, 223, 43, 50, 32 * 2, 8}, /* D2R */ + {32, 63, 41, 52, 16 * 2, 12}, /* D1L */ + {160, 191, 41, 52, 16 * 2, 12}, /* D1R */ + {64, 159, 41, 52, 48 * 2, 12}}, /* D1C */ + {{78, 85, 36, 51, 8 * 2, 16}, /* D3L */ + {138, 145, 36, 51, 8 * 2, 16}, /* D3R */ + {10, 41, 34, 53, 16 * 2, 20}, /* D3L */ + {98, 129, 34, 53, 16 * 2, 20}, /* D3C */ + {179, 210, 34, 53, 16 * 2, 20}, /* D3R */ + {66, 75, 34, 56, 8 * 2, 23}, /* D2L */ + {148, 157, 34, 56, 8 * 2, 23}, /* D2R */ + {0, 26, 33, 61, 24 * 2, 29}, /* D2L */ + {91, 133, 33, 61, 24 * 2, 29}, /* D2C */ + {194, 223, 33, 61, 24 * 2, 29}, /* D2R */ + {41, 56, 31, 65, 8 * 2, 35}, /* D1L */ + {167, 182, 31, 65, 8 * 2, 35}, /* D1R */ + {80, 143, 29, 71, 32 * 2, 43}}, /* D1C */ + {{75, 82, 25, 75, 8 * 2, 51}, /* D3L */ + {142, 149, 25, 75, 8 * 2, 51}, /* D3R */ + {12, 60, 25, 75, 32 * 2, 51}, /* D3L */ + {88, 136, 25, 75, 32 * 2, 51}, /* D3C */ + {163, 211, 25, 75, 32 * 2, 51}, /* D3R */ + {64, 73, 20, 90, 8 * 2, 71}, /* D2L */ + {150, 159, 20, 90, 8 * 2, 71}, /* D2R */ + {0, 38, 20, 90, 32 * 2, 71}, /* D2L */ + {82, 142, 20, 90, 32 * 2, 71}, /* D2C */ + {184, 223, 20, 90, 32 * 2, 71}, /* D2R */ + {41, 56, 9, 119, 8 * 2, 111}, /* D1L */ + {169, 184, 9, 119, 8 * 2, 111}, /* D1R */ + {64, 159, 9, 119, 48 * 2, 111}}, /* D1C */ + {{74, 85, 25, 75, 8 * 2, 51}, /* D3L */ + {137, 149, 25, 75, 8 * 2, 51}, /* D3R */ + {0, 75, 25, 75, 40 * 2, 51}, /* D3L Atari ST: { 0, 83, 25, 75, 48*2, 51 } */ + {74, 149, 25, 75, 40 * 2, 51}, /* D3C Atari ST: { 74, 149, 25, 75, 48*2, 51 } */ + {148, 223, 25, 75, 40 * 2, 51}, /* D3R Atari ST: { 139, 223, 25, 75, 48*2, 51 } */ + {60, 77, 20, 90, 16 * 2, 71}, /* D2L */ + {146, 163, 20, 90, 16 * 2, 71}, /* D2R */ + {0, 74, 20, 90, 56 * 2, 71}, /* D2L */ + {60, 163, 20, 90, 56 * 2, 71}, /* D2C */ + {149, 223, 20, 90, 56 * 2, 71}, /* D2R */ + {32, 63, 9, 119, 16 * 2, 111}, /* D1L */ + {160, 191, 9, 119, 16 * 2, 111}, /* D1R */ + {32, 191, 9, 119, 80 * 2, 111}}}; /* D1C */ + +byte gWallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoordinateSetIndices + 1, /* Wall Ornament 00 Unreadable Inscription */ + 1, /* Wall Ornament 01 Square Alcove */ + 1, /* Wall Ornament 02 Vi Altar */ + 1, /* Wall Ornament 03 Arched Alcove */ + 0, /* Wall Ornament 04 Hook */ + 0, /* Wall Ornament 05 Iron Lock */ + 0, /* Wall Ornament 06 Wood Ring */ + 0, /* Wall Ornament 07 Small Switch */ + 0, /* Wall Ornament 08 Dent 1 */ + 0, /* Wall Ornament 09 Dent 2 */ + 0, /* Wall Ornament 10 Iron Ring */ + 2, /* Wall Ornament 11 Crack */ + 3, /* Wall Ornament 12 Slime Outlet */ + 0, /* Wall Ornament 13 Dent 3 */ + 0, /* Wall Ornament 14 Tiny Switch */ + 0, /* Wall Ornament 15 Green Switch Out */ + 0, /* Wall Ornament 16 Blue Switch Out */ + 0, /* Wall Ornament 17 Coin Slot */ + 0, /* Wall Ornament 18 Double Iron Lock */ + 0, /* Wall Ornament 19 Square Lock */ + 0, /* Wall Ornament 20 Winged Lock */ + 0, /* Wall Ornament 21 Onyx Lock */ + 0, /* Wall Ornament 22 Stone Lock */ + 0, /* Wall Ornament 23 Cross Lock */ + 0, /* Wall Ornament 24 Topaz Lock */ + 0, /* Wall Ornament 25 Skeleton Lock */ + 0, /* Wall Ornament 26 Gold Lock */ + 0, /* Wall Ornament 27 Tourquoise Lock */ + 0, /* Wall Ornament 28 Emerald Lock */ + 0, /* Wall Ornament 29 Ruby Lock */ + 0, /* Wall Ornament 30 Ra Lock */ + 0, /* Wall Ornament 31 Master Lock */ + 0, /* Wall Ornament 32 Gem Hole */ + 2, /* Wall Ornament 33 Slime */ + 2, /* Wall Ornament 34 Grate */ + 1, /* Wall Ornament 35 Fountain */ + 1, /* Wall Ornament 36 Manacles */ + 1, /* Wall Ornament 37 Ghoul's Head */ + 1, /* Wall Ornament 38 Empty Torch Holder */ + 1, /* Wall Ornament 39 Scratches */ + 4, /* Wall Ornament 40 Poison Holes */ + 4, /* Wall Ornament 41 Fireball Holes */ + 4, /* Wall Ornament 42 Dagger Holes */ + 5, /* Wall Ornament 43 Champion Mirror */ + 0, /* Wall Ornament 44 Lever Up */ + 0, /* Wall Ornament 45 Lever Down */ + 1, /* Wall Ornament 46 Full Torch Holder */ + 0, /* Wall Ornament 47 Red Switch Out */ + 0, /* Wall Ornament 48 Eye Switch */ + 0, /* Wall Ornament 49 Big Switch Out */ + 2, /* Wall Ornament 50 Crack Switch Out */ + 0, /* Wall Ornament 51 Green Switch In */ + 0, /* Wall Ornament 52 Blue Switch In */ + 0, /* Wall Ornament 53 Red Switch In */ + 0, /* Wall Ornament 54 Big Switch In */ + 2, /* Wall Ornament 55 Crack Switch In. Atari ST Version 1.0 1987-12-08: 0 */ + 6, /* Wall Ornament 56 Amalgam (Encased Gem) */ + 6, /* Wall Ornament 57 Amalgam (Free Gem) */ + 6, /* Wall Ornament 58 Amalgam (Without Gem) */ + 7}; /* Wall Ornament 59 Lord Order (Outside) */ + +struct CreatureAspect { + uint16 firstNativeBitmapRelativeIndex; + uint16 firstDerivedBitmapIndex; + byte byteWidthFront; + byte heightFront; + byte byteWidthSide; + byte heightSide; + byte byteWidthAttack; + byte heightAttack; + byte coordinateSet_TransparentColor; + byte replacementColorSetIndices; + + byte getCoordSet() { return (coordinateSet_TransparentColor >> 4) & 0xF; } // @ M71_COORDINATE_SET + byte getTranspColour() { return coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR + byte getReplColour10() { return (replacementColorSetIndices >> 4) & 0xF; } // @ M74_COLOR_10_REPLACEMENT_COLOR_SET + byte getReplColour9() { return replacementColorSetIndices & 0xF; } // @ M73_COLOR_09_REPLACEMENT_COLOR_SET +}; // @ CREATURE_ASPECT + + +CreatureAspect gCreatureAspects[kCreatureTypeCount] = { // @ G0219_as_Graphic558_CreatureAspects +/* { FirstNativeBitmapRelativeIndex, FirstDerivedBitmapIndex, pixelWidthFront, HeightFront, +pixelWidthSide, HeightSide, pixelWidthAttack, HeightAttack, CoordinateSet / TransparentColor, +Replacement Color Set Index for color 10 / Replacement Color Set Index for color 9 } */ + {0, 0, 56 * 2, 84, 56 * 2, 84, 56 * 2, 84, 0x1D, 0x01}, /* Creature #00 Giant Scorpion / Scorpion */ + {4, 0, 32 * 2, 66, 0 * 2, 0, 32 * 2, 69, 0x0B, 0x20}, /* Creature #01 Swamp Slime / Slime Devil */ + {6, 0, 24 * 2, 48, 24 * 2, 48, 0 * 2, 0, 0x0B, 0x00}, /* Creature #02 Giggler */ + {10, 0, 32 * 2, 61, 0 * 2, 0, 32 * 2, 61, 0x24, 0x31}, /* Creature #03 Wizard Eye / Flying Eye */ + {12, 0, 32 * 2, 64, 56 * 2, 64, 32 * 2, 64, 0x14, 0x34}, /* Creature #04 Pain Rat / Hellhound */ + {16, 0, 24 * 2, 49, 40 * 2, 49, 0 * 2, 0, 0x18, 0x34}, /* Creature #05 Ruster */ + {19, 0, 32 * 2, 60, 0 * 2, 0, 32 * 2, 60, 0x0D, 0x00}, /* Creature #06 Screamer */ + {21, 0, 32 * 2, 43, 0 * 2, 0, 32 * 2, 64, 0x04, 0x00}, /* Creature #07 Rockpile / Rock pile */ + {23, 0, 32 * 2, 83, 0 * 2, 0, 32 * 2, 93, 0x04, 0x00}, /* Creature #08 Ghost / Rive */ + {25, 0, 32 * 2, 101, 32 * 2, 101, 32 * 2, 101, 0x14, 0x00}, /* Creature #09 Stone Golem */ + {29, 0, 32 * 2, 82, 32 * 2, 82, 32 * 2, 83, 0x04, 0x00}, /* Creature #10 Mummy */ + {33, 0, 32 * 2, 80, 0 * 2, 0, 32 * 2, 99, 0x14, 0x00}, /* Creature #11 Black Flame */ + {35, 0, 32 * 2, 80, 32 * 2, 80, 32 * 2, 76, 0x04, 0x00}, /* Creature #12 Skeleton */ + {39, 0, 32 * 2, 96, 56 * 2, 93, 32 * 2, 90, 0x1D, 0x20}, /* Creature #13 Couatl */ + {43, 0, 32 * 2, 49, 16 * 2, 49, 32 * 2, 56, 0x04, 0x30}, /* Creature #14 Vexirk */ + {47, 0, 32 * 2, 59, 56 * 2, 43, 32 * 2, 67, 0x14, 0x78}, /* Creature #15 Magenta Worm / Worm */ + {51, 0, 32 * 2, 83, 32 * 2, 74, 32 * 2, 74, 0x04, 0x65}, /* Creature #16 Trolin / Ant Man */ + {55, 0, 24 * 2, 49, 24 * 2, 53, 24 * 2, 53, 0x24, 0x00}, /* Creature #17 Giant Wasp / Muncher */ + {59, 0, 32 * 2, 89, 32 * 2, 89, 32 * 2, 89, 0x04, 0x00}, /* Creature #18 Animated Armour / Deth Knight */ + {63, 0, 32 * 2, 84, 32 * 2, 84, 32 * 2, 84, 0x0D, 0xA9}, /* Creature #19 Materializer / Zytaz */ + {67, 0, 56 * 2, 27, 0 * 2, 0, 56 * 2, 80, 0x04, 0x65}, /* Creature #20 Water Elemental */ + {69, 0, 56 * 2, 77, 56 * 2, 81, 56 * 2, 77, 0x04, 0xA9}, /* Creature #21 Oitu */ + {73, 0, 32 * 2, 87, 32 * 2, 89, 32 * 2, 89, 0x04, 0xCB}, /* Creature #22 Demon */ + {77, 0, 32 * 2, 96, 32 * 2, 94, 32 * 2, 96, 0x04, 0x00}, /* Creature #23 Lord Chaos */ + {81, 0, 64 * 2, 94, 72 * 2, 94, 64 * 2, 94, 0x04, 0xCB}, /* Creature #24 Red Dragon / Dragon */ + {85, 0, 32 * 2, 93, 0 * 2, 0, 0 * 2, 0, 0x04, 0xCB}, /* Creature #25 Lord Order */ + {86, 0, 32 * 2, 93, 0 * 2, 0, 0 * 2, 0, 0x04, 0xCB}}; /* Creature #26 Grey Lord */ + +struct ObjectAspect { + byte firstNativeBitmapRelativeIndex; + byte firstDerivedBitmapRelativeIndex; + byte width; + byte height; + byte graphicInfo; /* Bits 7-5 and 3-1 Unreferenced */ + byte coordinateSet; + ObjectAspect(byte firstN, byte firstD, byte byteWidth, byte h, byte grap, byte coord) : + firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD), + width(byteWidth * 2), height(h), graphicInfo(grap), coordinateSet(coord) {} +}; // @ OBJECT_ASPECT + +ObjectAspect gObjectAspects[kObjAspectCount] = { // @ G0209_as_Graphic558_ObjectAspects + /* FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo, CoordinateSet */ + ObjectAspect(0, 0, 24, 27, 0x11, 0), + ObjectAspect(2, 6, 24, 8, 0x00, 1), + ObjectAspect(3, 8, 8, 18, 0x00, 1), + ObjectAspect(4, 10, 8, 8, 0x00, 1), + ObjectAspect(5, 12, 8, 4, 0x00, 1), + ObjectAspect(6, 14, 16, 11, 0x00, 1), + ObjectAspect(7, 16, 24, 13, 0x00, 0), + ObjectAspect(8, 18, 32, 16, 0x00, 0), + ObjectAspect(9, 20, 40, 24, 0x00, 0), + ObjectAspect(10, 22, 16, 20, 0x00, 1), + ObjectAspect(11, 24, 40, 20, 0x00, 0), + ObjectAspect(12, 26, 32, 4, 0x00, 1), + ObjectAspect(13, 28, 40, 8, 0x00, 1), + ObjectAspect(14, 30, 32, 17, 0x00, 0), + ObjectAspect(15, 32, 40, 17, 0x00, 2), + ObjectAspect(16, 34, 16, 9, 0x00, 1), + ObjectAspect(17, 36, 24, 5, 0x00, 1), + ObjectAspect(18, 38, 16, 9, 0x00, 0), + ObjectAspect(19, 40, 8, 4, 0x00, 1), + ObjectAspect(20, 42, 32, 21, 0x00, 2), + ObjectAspect(21, 44, 32, 25, 0x00, 2), + ObjectAspect(22, 46, 32, 14, 0x00, 1), + ObjectAspect(23, 48, 32, 26, 0x00, 2), + ObjectAspect(24, 50, 32, 16, 0x00, 0), + ObjectAspect(25, 52, 32, 16, 0x00, 0), + ObjectAspect(26, 54, 16, 16, 0x00, 1), + ObjectAspect(27, 56, 16, 15, 0x00, 1), + ObjectAspect(28, 58, 16, 13, 0x00, 1), + ObjectAspect(29, 60, 16, 10, 0x00, 1), + ObjectAspect(30, 62, 40, 24, 0x00, 0), + ObjectAspect(31, 64, 40, 9, 0x00, 1), + ObjectAspect(32, 66, 16, 3, 0x00, 1), + ObjectAspect(33, 68, 32, 5, 0x00, 1), + ObjectAspect(34, 70, 40, 16, 0x00, 0), + ObjectAspect(35, 72, 8, 7, 0x00, 1), + ObjectAspect(36, 74, 32, 7, 0x00, 1), + ObjectAspect(37, 76, 24, 14, 0x00, 0), + ObjectAspect(38, 78, 16, 8, 0x00, 0), + ObjectAspect(39, 80, 8, 3, 0x00, 1), + ObjectAspect(40, 82, 40, 9, 0x00, 1), + ObjectAspect(41, 84, 24, 14, 0x00, 0), + ObjectAspect(42, 86, 40, 20, 0x00, 0), + ObjectAspect(43, 88, 40, 15, 0x00, 1), + ObjectAspect(44, 90, 32, 10, 0x00, 1), + ObjectAspect(45, 92, 32, 19, 0x00, 0), + ObjectAspect(46, 94, 40, 25, 0x00, 2), + ObjectAspect(47, 96, 24, 7, 0x00, 1), + ObjectAspect(48, 98, 8, 7, 0x00, 1), + ObjectAspect(49, 100, 16, 5, 0x00, 1), + ObjectAspect(50, 102, 8, 9, 0x00, 1), + ObjectAspect(51, 104, 32, 11, 0x00, 1), + ObjectAspect(52, 106, 32, 14, 0x00, 0), + ObjectAspect(53, 108, 24, 20, 0x00, 0), + ObjectAspect(54, 110, 16, 14, 0x00, 1), + ObjectAspect(55, 112, 32, 23, 0x00, 0), + ObjectAspect(56, 114, 24, 16, 0x00, 0), + ObjectAspect(57, 116, 32, 25, 0x00, 0), + ObjectAspect(58, 118, 24, 25, 0x00, 0), + ObjectAspect(59, 120, 8, 8, 0x00, 1), + ObjectAspect(60, 122, 8, 7, 0x00, 1), + ObjectAspect(61, 124, 8, 8, 0x00, 1), + ObjectAspect(62, 126, 8, 8, 0x00, 1), + ObjectAspect(63, 128, 8, 5, 0x00, 1), + ObjectAspect(64, 130, 8, 13, 0x01, 1), + ObjectAspect(65, 134, 16, 13, 0x00, 1), + ObjectAspect(66, 136, 16, 14, 0x00, 0), + ObjectAspect(67, 138, 16, 10, 0x00, 1), + ObjectAspect(68, 140, 8, 18, 0x00, 1), + ObjectAspect(69, 142, 8, 17, 0x00, 1), + ObjectAspect(70, 144, 32, 18, 0x00, 0), + ObjectAspect(71, 146, 16, 23, 0x00, 0), + ObjectAspect(72, 148, 16, 24, 0x00, 0), + ObjectAspect(73, 150, 16, 15, 0x00, 0), + ObjectAspect(74, 152, 8, 7, 0x00, 1), + ObjectAspect(75, 154, 8, 15, 0x00, 1), + ObjectAspect(76, 156, 8, 9, 0x00, 1), + ObjectAspect(77, 158, 16, 14, 0x00, 0), + ObjectAspect(78, 160, 8, 8, 0x00, 1), + ObjectAspect(79, 162, 16, 9, 0x00, 1), + ObjectAspect(80, 164, 8, 13, 0x01, 1), + ObjectAspect(81, 168, 8, 18, 0x00, 1), + ObjectAspect(82, 170, 24, 28, 0x00, 0), + ObjectAspect(83, 172, 40, 13, 0x00, 1), + ObjectAspect(84, 174, 8, 4, 0x00, 1), + ObjectAspect(85, 176, 32, 17, 0x00, 0)}; + +struct ProjectileAspect { + byte firstNativeBitmapRelativeIndex; + byte firstDerivedBitmapRelativeIndex; + byte width; + byte height; + uint16 graphicInfo; /* Bits 15-9, 7-5 and 3-2 Unreferenced */ + + ProjectileAspect(byte firstN, byte firstD, byte byteWidth, byte h, uint16 grap) : + firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD), + width(byteWidth * 2), height(h), graphicInfo(grap) {} +}; // @ PROJECTIL_ASPECT + + +ProjectileAspect gProjectileAspect[kProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects + /* ProjectileAspect( FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo ) */ + ProjectileAspect(0, 0, 32, 11, 0x0011), /* Arrow */ + ProjectileAspect(3, 18, 16, 11, 0x0011), /* Dagger */ + ProjectileAspect(6, 36, 24, 47, 0x0010), /* Axe - Executioner */ + ProjectileAspect(9, 54, 32, 15, 0x0112), /* Explosion Lightning Bolt */ + ProjectileAspect(11, 54, 32, 12, 0x0011), /* Slayer */ + ProjectileAspect(14, 72, 24, 47, 0x0010), /* Stone Club */ + ProjectileAspect(17, 90, 24, 47, 0x0010), /* Club */ + ProjectileAspect(20, 108, 16, 11, 0x0011), /* Poison Dart */ + ProjectileAspect(23, 126, 48, 18, 0x0011), /* Storm - Side Splitter - Diamond Edge - Falchion - Ra Blade - Rapier - Biter - Samurai Sword - Sword - Dragon Fang */ + ProjectileAspect(26, 144, 8, 15, 0x0012), /* Throwing Star */ + ProjectileAspect(28, 156, 16, 28, 0x0103), /* Explosion Fireball */ + ProjectileAspect(29, 156, 16, 11, 0x0103), /* Explosion Default */ + ProjectileAspect(30, 156, 16, 28, 0x0103), /* Explosion Slime */ + ProjectileAspect(31, 156, 16, 24, 0x0103) /* Explosion Poison Bolt Poison Cloud */ }; +// TODO: this is ONLY for the Amiga version, name will have to be refactored + +/* Identical to the palette at the end of the swoosh palette animation */ +uint16 gPalSwoosh[16] = {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}; // @ K0057_aui_Palette_Swoosh +uint16 gPalMousePointer[16] = {0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF}; // @ K0150_aui_Palette_MousePointer +/* Atari ST: { 0x003, 0x055, 0x773, 0x420, 0x774, 0x000, 0x040, 0x500, 0x642, 0x775, 0x742, 0x760, 0x750, 0x000, 0x310, 0x776 }, RGB colors are different */ +uint16 gPalCredits[16] = {0x006, 0x0AA, 0xFF6, 0x840, 0xFF8, 0x000, 0x080, 0xA00, 0xC84, 0xFFA, 0xF84, 0xFC0, 0xFA0, 0x000, 0x620, 0xFFC}; // @ G0019_aui_Graphic562_Palette_Credits +/* Atari ST: { 0x000, 0x333, 0x444, 0x420, 0x654, 0x210, 0x040, 0x050, 0x432, 0x700, 0x543, 0x321, 0x222, 0x555, 0x310, 0x777 }, RGB colors are different */ +uint16 gPalEntrance[16] = {0x000, 0x666, 0x888, 0x840, 0xCA8, 0x0C0, 0x080, 0x0A0, 0x864, 0xF00, 0xA86, 0x642, 0x444, 0xAAA, 0x620, 0xFFF}; // @ G0020_aui_Graphic562_Palette_Entrance +uint16 gPalDungeonView[6][16] = { // @ G0021_aaui_Graphic562_Palette_DungeonView + /* Atari ST: { 0x000, 0x333, 0x444, 0x310, 0x066, 0x420, 0x040, 0x060, 0x700, 0x750, 0x643, 0x770, 0x222, 0x555, 0x007, 0x777 }, RGB colors are different */ + 0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x444, 0xAAA, 0x00F, 0xFFF, + /* Atari ST: { 0x000, 0x222, 0x333, 0x310, 0x066, 0x410, 0x030, 0x050, 0x600, 0x640, 0x532, 0x760, 0x111, 0x444, 0x006, 0x666 }, RGB colors are different */ + 0x000, 0x444, 0x666, 0x620, 0x0CC, 0x820, 0x060, 0x0A0, 0xC00, 0x000, 0x000, 0xFC0, 0x222, 0x888, 0x00C, 0xCCC, + /* Atari ST: { 0x000, 0x111, 0x222, 0x210, 0x066, 0x310, 0x020, 0x040, 0x500, 0x530, 0x421, 0x750, 0x000, 0x333, 0x005, 0x555 }, RGB colors are different */ + 0x000, 0x222, 0x444, 0x420, 0x0CC, 0x620, 0x040, 0x080, 0xA00, 0x000, 0x000, 0xFA0, 0x000, 0x666, 0x00A, 0xAAA, + /* Atari ST: { 0x000, 0x000, 0x111, 0x100, 0x066, 0x210, 0x010, 0x030, 0x400, 0x420, 0x310, 0x640, 0x000, 0x222, 0x004, 0x444 }, RGB colors are different */ + 0x000, 0x000, 0x222, 0x200, 0x0CC, 0x420, 0x020, 0x060, 0x800, 0x000, 0x000, 0xC80, 0x000, 0x444, 0x008, 0x888, + /* Atari ST: { 0x000, 0x000, 0x000, 0x000, 0x066, 0x100, 0x000, 0x020, 0x300, 0x310, 0x200, 0x530, 0x000, 0x111, 0x003, 0x333 }, RGB colors are different */ + 0x000, 0x000, 0x000, 0x000, 0x0CC, 0x200, 0x000, 0x040, 0x600, 0x000, 0x000, 0xA60, 0x000, 0x222, 0x006, 0x666, + /* Atari ST: { 0x000, 0x000, 0x000, 0x000, 0x066, 0x000, 0x000, 0x010, 0x200, 0x200, 0x100, 0x320, 0x000, 0x000, 0x002, 0x222 }, RGB colors are different */ + 0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444}; + + +struct CreatureReplColorSet { + uint16 RGBColor[6]; + byte D2ReplacementColor; + byte D3ReplacementColor; +}; // @ CREATURE_REPLACEMENT_COLOR_SET + +CreatureReplColorSet gCreatureReplColorSets[13] = { // @ G0220_as_Graphic558_CreatureReplacementColorSets + /* { Color, Color, Color, Color, Color, Color, D2 replacement color index (x10), D3 replacement color index (x10) } */ + {0x0CA0, 0x0A80, 0x0860, 0x0640, 0x0420, 0x0200, 90, 90}, /* Atari ST: { 0x0650, 0x0540, 0x0430, 0x0320, 0x0210, 0x0100, 90, 90 }, RGB colors are different */ + {0x0060, 0x0040, 0x0020, 0x0000, 0x0000, 0x0000, 0, 0}, /* Atari ST: { 0x0030, 0x0020, 0x0010, 0x0000, 0x0000, 0x0000, 0, 0 }, */ + {0x0860, 0x0640, 0x0420, 0x0200, 0x0000, 0x0000, 100, 100}, /* Atari ST: { 0x0430, 0x0320, 0x0210, 0x0100, 0x0000, 0x0000, 100, 100 }, */ + {0x0640, 0x0420, 0x0200, 0x0000, 0x0000, 0x0000, 90, 0}, /* Atari ST: { 0x0320, 0x0210, 0x0100, 0x0000, 0x0000, 0x0000, 90, 0 }, */ + {0x000A, 0x0008, 0x0006, 0x0004, 0x0002, 0x0000, 90, 100}, /* Atari ST: { 0x0005, 0x0004, 0x0003, 0x0002, 0x0001, 0x0000, 90, 100 }, */ + {0x0008, 0x0006, 0x0004, 0x0002, 0x0000, 0x0000, 100, 0}, /* Atari ST: { 0x0004, 0x0003, 0x0002, 0x0001, 0x0000, 0x0000, 100, 0 }, */ + {0x0808, 0x0606, 0x0404, 0x0202, 0x0000, 0x0000, 90, 0}, /* Atari ST: { 0x0404, 0x0303, 0x0202, 0x0101, 0x0000, 0x0000, 90, 0 }, */ + {0x0A0A, 0x0808, 0x0606, 0x0404, 0x0202, 0x0000, 100, 90}, /* Atari ST: { 0x0505, 0x0404, 0x0303, 0x0202, 0x0101, 0x0000, 100, 90 }, */ + {0x0FA0, 0x0C80, 0x0A60, 0x0840, 0x0620, 0x0400, 100, 50}, /* Atari ST: { 0x0750, 0x0640, 0x0530, 0x0420, 0x0310, 0x0200, 100, 50 }, */ + {0x0F80, 0x0C60, 0x0A40, 0x0820, 0x0600, 0x0200, 50, 70}, /* Atari ST: { 0x0740, 0x0630, 0x0520, 0x0410, 0x0300, 0x0100, 50, 30 }, D3 replacement color index is different */ + {0x0800, 0x0600, 0x0400, 0x0200, 0x0000, 0x0000, 100, 120}, /* Atari ST: { 0x0400, 0x0300, 0x0200, 0x0100, 0x0000, 0x0000, 100, 100 }, D3 replacement color index is different */ + {0x0600, 0x0400, 0x0200, 0x0000, 0x0000, 0x0000, 120, 0}, /* Atari ST: { 0x0300, 0x0200, 0x0100, 0x0000, 0x0000, 0x0000, 120, 0 }, */ + {0x0C86, 0x0A64, 0x0842, 0x0620, 0x0400, 0x0200, 100, 50}}; /* Atari ST: { 0x0643, 0x0532, 0x0421, 0x0310, 0x0200, 0x0100, 100, 50 } }; */ + +byte gPalChangesCreature_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3 +byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, 120, 130, 140, 150}; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2 + enum GraphicIndice { - gFloorIndice = 75, - gCeilingIndice = 76 + kDoorMaskDestroyedIndice = 301 // @ C301_GRAPHIC_DOOR_MASK_DESTROYED }; // The frames in the orignal sources contain inclusive boundaries and byte widths, not pixel widths @@ -50,18 +473,28 @@ Frame gWallFrameD3R2(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Fra extern Viewport gDefultViewPort = {0, 0}; extern Viewport gDungeonViewport = {0, 64}; // TODO: I guessed the numbers +byte gPalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges + +byte gPalChangesFloorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 140, 130}; // @ G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3 +byte gPalChangesFloorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2 + +int gFountainOrnIndices[kFountainOrnCount] = {35}; // @ G0193_ai_Graphic558_FountainOrnamentIndices +byte gAlcoveOrnIndices[kAlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrnamentIndices + 1, /* Square Alcove */ + 2, /* Vi Altar */ + 3}; /* Arched Alcove */ + } using namespace DM; DisplayMan::DisplayMan(DMEngine *dmEngine) : - _vm(dmEngine), _currPalette(kPalSwoosh), _screenWidth(0), _screenHeight(0), - _vgaBuffer(NULL), _packedItemCount(0), _packedItemPos(NULL), _packedBitmaps(NULL), - _bitmaps(NULL) {} + _vm(dmEngine), _screenWidth(0), _screenHeight(0), + _vgaBuffer(NULL), _bitmaps(NULL) {} DisplayMan::~DisplayMan() { - delete[] _packedBitmaps; delete[] _packedItemPos; + delete[] _packedBitmaps; delete[] _vgaBuffer; delete[] _bitmaps[0]; delete[] _bitmaps; @@ -72,7 +505,6 @@ DisplayMan::~DisplayMan() { void DisplayMan::setUpScreens(uint16 width, uint16 height) { _screenWidth = width; _screenHeight = height; - loadPalette(kPalSwoosh); _vgaBuffer = new byte[_screenWidth * _screenHeight]; clearScreen(kColorBlack); } @@ -81,21 +513,37 @@ void DisplayMan::loadGraphics() { Common::File f; f.open("graphics.dat"); - _packedItemCount = f.readUint16BE(); - _packedItemPos = new uint32[_packedItemCount + 1]; + grapItemCount = f.readUint16BE(); + _packedItemPos = new uint32[grapItemCount + 1]; _packedItemPos[0] = 0; - for (uint16 i = 1; i < _packedItemCount + 1; ++i) + for (uint16 i = 1; i < grapItemCount + 1; ++i) _packedItemPos[i] = f.readUint16BE() + _packedItemPos[i - 1]; - _packedBitmaps = new uint8[_packedItemPos[_packedItemCount]]; + _packedBitmaps = new uint8[_packedItemPos[grapItemCount]]; - f.seek(2 + _packedItemCount * 4); - for (uint32 i = 0; i < _packedItemPos[_packedItemCount]; ++i) + f.seek(2 + grapItemCount * 4); + for (uint32 i = 0; i < _packedItemPos[grapItemCount]; ++i) _packedBitmaps[i] = f.readByte(); f.close(); unpackGraphics(); + + for (uint16 i = kDoorOrnDestroyedMask; i <= kDoorOrnThivesEyeMask; ++i) { + _currMapDoorOrnInfo[i][kNativeBitmapIndex] = i + (kDoorMaskDestroyedIndice - kDoorOrnDestroyedMask); + _currMapDoorOrnInfo[i][kNativeCoordinateSet] = 1; + } + + _currMapFloorOrnInfo[kFloorOrnFootprints][kNativeBitmapIndex] = 1; + _currMapFloorOrnInfo[kFloorOrnFootprints][kNativeCoordinateSet] = 1; + + _palChangesProjectile[0] = gPalChangesFloorOrn_D3; + _palChangesProjectile[1] = gPalChangesFloorOrn_D2; + _palChangesProjectile[2] = _palChangesProjectile[3] = gPalChangesNoChanges; + + loadFloorSet(kFloorSetStone); + loadWallSet(kWallSetStone); + } void DisplayMan::unpackGraphics() { @@ -119,18 +567,14 @@ void DisplayMan::unpackGraphics() { } } -void DisplayMan::loadPalette(dmPaletteEnum palette) { - if (_currPalette == palette) - return; - +void DisplayMan::loadPalette(uint16 *palette) { byte colorPalette[16 * 3]; for (int i = 0; i < 16; ++i) { - colorPalette[i * 3] = (dmPalettes[palette][i] >> 8) * (256 / 16); - colorPalette[i * 3 + 1] = (dmPalettes[palette][i] >> 4) * (256 / 16); - colorPalette[i * 3 + 2] = dmPalettes[palette][i] * (256 / 16); + colorPalette[i * 3] = (palette[i] >> 8) * (256 / 16); + colorPalette[i * 3 + 1] = (palette[i] >> 4) * (256 / 16); + colorPalette[i * 3 + 2] = palette[i] * (256 / 16); } _vm->_system->getPaletteManager()->setPalette(colorPalette, 0, 16); - _currPalette = palette; } @@ -253,7 +697,7 @@ void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) { blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport); } -void drawSquareD3L(direction dir, int16 posX, int16 posY) { +void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { } @@ -278,7 +722,7 @@ enum WallSetIndices { }; void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { - loadPalette(kPalDungeonView0); + loadPalette(gPalDungeonView[0]); // TODO: this is a global variable, set from here bool flippedFloorCeiling = (posX + posY + dir) & 1; @@ -323,17 +767,16 @@ void DisplayMan::clearBitmap(byte *bitmap, uint16 width, uint16 height, Color co } -void DisplayMan::loadWallSet(WallSet set) { +void DisplayMan::loadFloorSet(FloorSet set) { // there are 2 bitmaps per set, first one is at 75 - GraphicIndice indice = (GraphicIndice)(75 + (2 * set)); + GraphicIndice indice = (GraphicIndice)(kFirstFloorSet + (kFloorSetGraphicCount * set)); _floorBitmap = _bitmaps[indice]; _ceilingBitmap = _bitmaps[indice + 1]; } -void DisplayMan::loadFloorSet(FloorSet set) { - // there are 13 bitmaps perset, first one is at 77 - uint16 firstIndice = (set * 13) + 77; - for (uint16 i = 0; i < 13; ++i) { +void DisplayMan::loadWallSet(WallSet set) { + uint16 firstIndice = (set * kWallSetGraphicCount) + kFirstWallSet; + for (uint16 i = 0; i < kWallSetGraphicCount; ++i) { _wallSetBitMaps[i] = _bitmaps[i + firstIndice]; } @@ -353,4 +796,77 @@ void DisplayMan::loadFloorSet(FloorSet set) { _wallSetBitMaps[kWall_D3R2] = new byte[w * h]; blitToBitmap(_wallSetBitMaps[kWall_D3L2], w, h, _wallSetBitMaps[kWall_D3R2], w); flipBitmapHorizontal(_wallSetBitMaps[kWall_D3R2], w, h); -} \ No newline at end of file +} + + +void DisplayMan::loadCurrentMapGraphics() { + loadFloorSet(_vm->_dungeonMan->_currMap.map->floorSet); + loadWallSet(_vm->_dungeonMan->_currMap.map->wallSet); + + for (int16 i = 0; i < kAlcoveOrnCount; ++i) + _currMapAlcoveOrnIndices[i] = -1; + for (int16 i = 0; i < kFountainOrnCount; ++i) + _currMapFountainOrnIndices[i] = -1; + + + + + uint16 alcoveCount = 0; + uint16 fountainCount = 0; + Map &currMap = *_vm->_dungeonMan->_currMap.map; + + for (uint16 i = 0; i < currMap.wallOrnCount; ++i) { + uint16 ornIndice = _currMapWallOrnIndices[i]; + uint16 nativeIndice = kFirstWallOrn + ornIndice * 2; + + _currMapWallOrnInfo[i][kNativeBitmapIndex] = nativeIndice; + for (uint16 ornCounter = 0; ornCounter < kAlcoveOrnCount; ++ornCounter) { + if (ornIndice == gAlcoveOrnIndices[ornCounter]) { + _currMapAlcoveOrnIndices[alcoveCount++] = i; + if (ornIndice == 2) + _currMapViAltarIndex = i; + } + } + + for (uint16 ornCounter = 0; ornCounter < kFountainOrnCount; ++ornCounter) + if (ornIndice == gFountainOrnIndices[ornCounter]) + _currMapFountainOrnIndices[fountainCount++] = i; + + _currMapWallOrnInfo[i][kNativeCoordinateSet] = gWallOrnCoordSetIndices[ornIndice]; + } + + for (uint16 i = 0; i < currMap.floorOrnCount; ++i) { + uint16 ornIndice = _currMapFloorOrnIndices[i]; + uint16 nativeIndice = kFirstFloorOrn + ornIndice * 6; + _currMapFloorOrnInfo[i][kNativeBitmapIndex] = nativeIndice; + _currMapFloorOrnInfo[i][kNativeCoordinateSet] = gFloorOrnCoordSetIndices[ornIndice]; + } + + for (uint16 i = 0; i < currMap.doorOrnCount; ++i) { + uint16 ornIndice = _currMapDoorOrnIndices[i]; + uint16 nativeIndice = kFirstDoorOrn + ornIndice; + _currMapDoorOrnInfo[i][kNativeBitmapIndex] = nativeIndice; + _currMapDoorOrnInfo[i][kNativeCoordinateSet] = gDoorOrnCoordIndices[ornIndice]; + } + + applyCreatureReplColors(9, 8); + applyCreatureReplColors(10, 12); + + for (uint16 creatureType = 0; creatureType < currMap.creatureTypeCount; ++creatureType) { + CreatureAspect &aspect = gCreatureAspects[_currMapAllowedCreatureTypes[creatureType]]; + uint16 replColorOrdinal = aspect.getReplColour9(); + if (replColorOrdinal) + applyCreatureReplColors(9, ordinalToIndex(replColorOrdinal)); + replColorOrdinal = aspect.getReplColour10(); + if (replColorOrdinal) + applyCreatureReplColors(10, ordinalToIndex(replColorOrdinal)); + } +} + +void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor) { + for (int16 i = 0; i < 6; ++i) + gPalDungeonView[i][replacedColor] = gCreatureReplColorSets[replacementColor].RGBColor[i]; + + gPalChangesCreature_D2[replacedColor] = gCreatureReplColorSets[replacementColor].D2ReplacementColor; + gPalChangesCreature_D3[replacedColor] = gCreatureReplColorSets[replacementColor].D3ReplacementColor; +} diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 5670a5657c..4c6b461446 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -6,6 +6,12 @@ namespace DM { +extern uint16 gPalSwoosh[16]; +extern uint16 gPalMousePointer[16]; +extern uint16 gPalCredits[16]; +extern uint16 gPalEntrance[16]; +extern uint16 gPalDungeonView[6][16]; + struct Frame; enum WallSet { kWallSetStone = 0 // @ C0_WALL_SET_STONE @@ -35,18 +41,6 @@ enum Color { kColorWhite = 15 }; -enum dmPaletteEnum { - kPalSwoosh = 0, - kPalMousePointer = 1, - kPalCredits = 2, - kPalEntrance = 3, - kPalDungeonView0 = 4, - kPalDungeonView1 = 5, - kPalDungeonView2 = 6, - kPalDungeonView3 = 7, - kPalDungeonView4 = 8, - kPalDungeonView5 = 9, -}; struct Viewport { // TODO: should probably add width and height, seems redundant right meow @@ -57,18 +51,42 @@ extern Viewport gDefultViewPort; extern Viewport gDungeonViewport; +#define kAlcoveOrnCount 3 +#define kFountainOrnCount 1 + +#define kFloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT +#define kWallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT +#define kStairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT +#define kDoorSetGraphicsCount 3 // @ C003_DOOR_SET_GRAPHIC_COUNT +#define kDoorButtonCount 1 // @ C001_DOOR_BUTTON_COUNT +#define kNativeBitmapIndex 0 // @ C0_NATIVE_BITMAP_INDEX +#define kNativeCoordinateSet 1 // @ C1_COORDINATE_SET +#define kCreatureTypeCount 27 // @ C027_CREATURE_TYPE_COUNT +#define kExplosionAspectCount 4 // @ C004_EXPLOSION_ASPECT_COUNT +#define kObjAspectCount 85 // @ C085_OBJECT_ASPECT_COUNT +#define kProjectileAspectCount 14 // @ C014_PROJECTILE_ASPECT_COUNT + + +#define kDoorButton 0 // @ C0_DOOR_BUTTON +#define kWallOrnInscription 0 // @ C0_WALL_ORNAMENT_INSCRIPTION +#define kFloorOrnFootprints 15 // @ C15_FLOOR_ORNAMENT_FOOTPRINTS +#define kDoorOrnDestroyedMask 15 // @ C15_DOOR_ORNAMENT_DESTROYED_MASK +#define kDoorOrnThivesEyeMask 16 // @ C16_DOOR_ORNAMENT_THIEVES_EYE_MASK + + + class DisplayMan { DMEngine *_vm; - dmPaletteEnum _currPalette; uint16 _screenWidth; uint16 _screenHeight; byte *_vgaBuffer; - uint16 _packedItemCount; - uint32 *_packedItemPos; - byte *_packedBitmaps; // TODO: this doesn't not contaion graphics exclusively, will have to be moved + /// Related to graphics.dat file + uint16 grapItemCount; // @ G0632_ui_GraphicCount + uint32 *_packedItemPos; + byte *_packedBitmaps; byte **_bitmaps; @@ -79,25 +97,36 @@ class DisplayMan { byte *_floorBitmap; byte *_ceilingBitmap; + + byte *_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile + + DisplayMan(const DisplayMan &other); // no implementation on purpose void operator=(const DisplayMan &rhs); // no implementation on purpose byte *getCurrentVgaBuffer(); - // the original functions has two position parameters, but they are always set to zero + // the original function has two position parameters, but they are always set to zero void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap void unpackGraphics(); + void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L + + void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet + void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet + + void applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors + public: DisplayMan(DMEngine *dmEngine); ~DisplayMan(); void setUpScreens(uint16 width, uint16 height); - void loadGraphics(); - void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet - void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet + void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader, F0460_START_InitializeGraphicData - void loadPalette(dmPaletteEnum palette); + void loadCurrentMapGraphics(); + + void loadPalette(uint16 *palette); /// Gives the width of an IMG0 type item uint16 width(uint16 index); @@ -120,10 +149,22 @@ public: void clearScreen(Color color); void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); -}; -} + int16 _championPortraitOrdinal = 0; // @ G0289_i_DungeonView_ChampionPortraitOrdinal + int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices + int16 _currMapFountainOrnIndices[kFountainOrnCount]; // @ G0268_ai_CurrentMapFountainOrnamentIndices + int16 _currMapWallOrnInfo[16][2]; // @ G0101_aai_CurrentMapWallOrnamentsInf + int16 _currMapFloorOrnInfo[16][2]; // @ G0102_aai_CurrentMapFloorOrnamentsInfo + int16 _currMapDoorOrnInfo[17][2]; // @ G0103_aai_CurrentMapDoorOrnamentsInfo + byte *_currMapAllowedCreatureTypes; // @ G0264_puc_CurrentMapAllowedCreatureTypes + byte _currMapWallOrnIndices[16]; // @ G0261_auc_CurrentMapWallOrnamentIndices + byte _currMapFloorOrnIndices[16]; // @ G0262_auc_CurrentMapFloorOrnamentIndices + byte _currMapDoorOrnIndices[18]; // @ G0263_auc_CurrentMapDoorOrnamentIndices + int16 _currMapViAltarIndex; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex +}; + +} #endif -- cgit v1.2.3 From 73a7cba58921e59cdd3049f57b0a3990e7422ea2 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 15 May 2016 17:52:39 +0200 Subject: DM: Fix bug with uninitialized _currMap.index and file loading order --- engines/dm/dm.cpp | 7 +++++-- engines/dm/dungeonman.cpp | 3 --- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index ee818495e4..34efcf3407 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -54,9 +54,12 @@ Common::Error DMEngine::run() { _displayMan = new DisplayMan(this); _dungeonMan = new DungeonMan(this); + _displayMan->setUpScreens(320, 200); + _dungeonMan->loadDungeonFile(); + _dungeonMan->setCurrentMapAndPartyMap(0); + - _displayMan->setUpScreens(320, 200); _displayMan->loadGraphics(); @@ -64,7 +67,7 @@ Common::Error DMEngine::run() { _displayMan->loadPalette(gPalCredits); - _dungeonMan->setCurrentMapAndPartyMap(0); + uint16 i = 0; //TODO: testing, please delete me while (true) { diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 46d4f62704..824a730602 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -352,9 +352,6 @@ void DungeonMan::loadDungeonFile() { } void DungeonMan::setCurrentMap(uint16 mapIndex) { - if (_currMap.index == mapIndex) - return; - _currMap.index = mapIndex; _currMap.data = _dunData.mapData[mapIndex]; _currMap.map = _maps + mapIndex; -- cgit v1.2.3 From f21a9197a629fcb225c1c47bb2a9f4cd3018c395 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Sun, 15 May 2016 18:59:55 +0200 Subject: DM: Fix file loading dependancy --- engines/dm/dm.cpp | 3 ++- engines/dm/dungeonman.cpp | 2 +- engines/dm/dungeonman.h | 14 +++++++------- engines/dm/gfx.h | 42 +++++++++++++++++++++--------------------- 4 files changed, 31 insertions(+), 30 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 34efcf3407..64793a9bd9 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -56,11 +56,12 @@ Common::Error DMEngine::run() { _displayMan->setUpScreens(320, 200); + _displayMan->loadGraphics(); + _dungeonMan->loadDungeonFile(); _dungeonMan->setCurrentMapAndPartyMap(0); - _displayMan->loadGraphics(); _displayMan->loadCurrentMapGraphics(); diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 824a730602..9b9791aff4 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -421,7 +421,7 @@ int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) { if (mapX < 0 || mapX >= _currMap.width || mapY < 0 || mapY >= _currMap.height || !Square(_currMap.data[mapX][mapY]).get(kThingListPresent)) return -1; - int16 y; + int16 y = 0; uint16 index = _currMap.colCumulativeSquareFirstThingCount[mapX]; byte* square = _currMap.data[mapX]; while (y++ != mapY) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index df8395312c..5f1dcd3d40 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -402,11 +402,11 @@ struct CurrMapData { uint8 currPartyMapIndex; // @ G0309_i_PartyMapIndex uint8 index; // @ G0272_i_CurrentMapIndex - byte **data; // @ G0271_ppuc_CurrentMapData - Map *map; // @ G0269_ps_CurrentMap + byte **data = NULL; // @ G0271_ppuc_CurrentMapData + Map *map = NULL; // @ G0269_ps_CurrentMap uint16 width; // @ G0273_i_CurrentMapWidth uint16 height; // @ G0274_i_CurrentMapHeight - uint16 *colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount + uint16 *colCumulativeSquareFirstThingCount = NULL; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount }; // @ AGGREGATE struct Messages { @@ -454,15 +454,15 @@ public: } // @ F0153_DUNGEON_GetRelativeSquareType void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect - uint32 _rawDunFileDataSize; // @ probably NONE - byte *_rawDunFileData; // @ ??? + uint32 _rawDunFileDataSize = 0; // @ probably NONE + byte *_rawDunFileData = NULL; // @ ??? DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader DungeonData _dunData; // @ NONE CurrMapData _currMap; // @ NONE - Map *_maps; // @ G0277_ps_DungeonMaps + Map *_maps = NULL; // @ G0277_ps_DungeonMaps // does not have to be freed - byte *_rawMapData; // @ G0276_puc_DungeonRawMapData + byte *_rawMapData = NULL; // @ G0276_puc_DungeonRawMapData Messages _messages; // @ NONE; int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 4c6b461446..576d9e3452 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -77,28 +77,28 @@ extern Viewport gDungeonViewport; class DisplayMan { - DMEngine *_vm; + DMEngine *_vm = NULL; uint16 _screenWidth; - uint16 _screenHeight; - byte *_vgaBuffer; + uint16 _screenHeight = 0; + byte *_vgaBuffer = NULL; /// Related to graphics.dat file - uint16 grapItemCount; // @ G0632_ui_GraphicCount - uint32 *_packedItemPos; - byte *_packedBitmaps; - byte **_bitmaps; + uint16 grapItemCount = 0; // @ G0632_ui_GraphicCount + uint32 *_packedItemPos = NULL; + byte *_packedBitmaps = NULL; + byte **_bitmaps = NULL; // the last two pointers are owned by this array byte *_wallSetBitMaps[15] = {NULL}; // @G[0696..0710]_puc_Bitmap_WallSet_... // pointers are not owned by these fields - byte *_floorBitmap; - byte *_ceilingBitmap; + byte *_floorBitmap = NULL; + byte *_ceilingBitmap = NULL; - byte *_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile + byte *_palChangesProjectile[4] = {NULL}; // @G0075_apuc_PaletteChanges_Projectile DisplayMan(const DisplayMan &other); // no implementation on purpose @@ -152,17 +152,17 @@ public: int16 _championPortraitOrdinal = 0; // @ G0289_i_DungeonView_ChampionPortraitOrdinal - int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices - int16 _currMapFountainOrnIndices[kFountainOrnCount]; // @ G0268_ai_CurrentMapFountainOrnamentIndices - int16 _currMapWallOrnInfo[16][2]; // @ G0101_aai_CurrentMapWallOrnamentsInf - int16 _currMapFloorOrnInfo[16][2]; // @ G0102_aai_CurrentMapFloorOrnamentsInfo - int16 _currMapDoorOrnInfo[17][2]; // @ G0103_aai_CurrentMapDoorOrnamentsInfo - byte *_currMapAllowedCreatureTypes; // @ G0264_puc_CurrentMapAllowedCreatureTypes - byte _currMapWallOrnIndices[16]; // @ G0261_auc_CurrentMapWallOrnamentIndices - byte _currMapFloorOrnIndices[16]; // @ G0262_auc_CurrentMapFloorOrnamentIndices - byte _currMapDoorOrnIndices[18]; // @ G0263_auc_CurrentMapDoorOrnamentIndices - - int16 _currMapViAltarIndex; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex + int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount] = {0}; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices + int16 _currMapFountainOrnIndices[kFountainOrnCount] = {0}; // @ G0268_ai_CurrentMapFountainOrnamentIndices + int16 _currMapWallOrnInfo[16][2] = {0}; // @ G0101_aai_CurrentMapWallOrnamentsInf + int16 _currMapFloorOrnInfo[16][2] = {0}; // @ G0102_aai_CurrentMapFloorOrnamentsInfo + int16 _currMapDoorOrnInfo[17][2] = {0}; // @ G0103_aai_CurrentMapDoorOrnamentsInfo + byte *_currMapAllowedCreatureTypes = NULL; // @ G0264_puc_CurrentMapAllowedCreatureTypes + byte _currMapWallOrnIndices[16] = {0}; // @ G0261_auc_CurrentMapWallOrnamentIndices + byte _currMapFloorOrnIndices[16] = {0}; // @ G0262_auc_CurrentMapFloorOrnamentIndices + byte _currMapDoorOrnIndices[18] = {0}; // @ G0263_auc_CurrentMapDoorOrnamentIndices + + int16 _currMapViAltarIndex = 0; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex }; } -- cgit v1.2.3 From 2e9483cf2e5937f03bc89f9366d3b84d1199237b Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Mon, 16 May 2016 13:37:52 +0200 Subject: DM: Fix dungeon.dat file loading --- engines/dm/dungeonman.cpp | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 9b9791aff4..c933744c19 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -5,6 +5,7 @@ + namespace DM { // TODO: refactor direction into a class int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; @@ -252,6 +253,8 @@ void DungeonMan::loadDungeonFile() { _dunData.columCount = columCount; // TODO: ??? is this - end + + uint32 actualSquareFirstThingCount = _fileHeader.squareFirstThingCount; if (_messages.newGame) // TODO: what purpose does this serve? _fileHeader.squareFirstThingCount += 300; @@ -267,11 +270,11 @@ void DungeonMan::loadDungeonFile() { if (_dunData.squareFirstThings) delete[] _dunData.squareFirstThings; _dunData.squareFirstThings = new Thing[_fileHeader.squareFirstThingCount]; - for (uint16 i = 0; i < _fileHeader.squareFirstThingCount; ++i) + for (uint16 i = 0; i < actualSquareFirstThingCount; ++i) _dunData.squareFirstThings[i].set(dunDataStream.readUint16BE()); if (_messages.newGame) for (uint16 i = 0; i < 300; ++i) - _dunData.squareFirstThings[i] = Thing::thingNone; + _dunData.squareFirstThings[actualSquareFirstThingCount + i] = Thing::thingNone; // TODO: ??? is this - end @@ -291,19 +294,18 @@ void DungeonMan::loadDungeonFile() { for (uint16 thingType = kDoorThingType; thingType < kThingTypeTotal; ++thingType) { uint16 thingCount = _fileHeader.thingCounts[thingType]; if (_messages.newGame) { - // _fileHeader.thingCounts[thingType] = 1024; // TODO: what this?? check back later + _fileHeader.thingCounts[thingType] = MIN((thingType == kExplosionThingType) ? 768 : 1024, thingCount + gAdditionalThingCounts[thingType]); } uint16 thingStoreWordCount = gThingDataWordCount[thingType]; - if (!thingStoreWordCount || !thingCount) - continue; + if (_dunData.thingsData[thingType]) { delete[] _dunData.thingsData[thingType][0]; delete[] _dunData.thingsData[thingType]; } - _dunData.thingsData[thingType] = new uint16*[thingCount]; - _dunData.thingsData[thingType][0] = new uint16[thingCount * thingStoreWordCount]; - for (uint16 i = 0; i < thingCount; ++i) + _dunData.thingsData[thingType] = new uint16*[_fileHeader.thingCounts[thingType]]; + _dunData.thingsData[thingType][0] = new uint16[_fileHeader.thingCounts[thingType] * thingStoreWordCount]; + for (uint16 i = 0; i < _fileHeader.thingCounts[thingType]; ++i) _dunData.thingsData[thingType][i] = _dunData.thingsData[thingType][0] + i * thingStoreWordCount; if (thingType == kGroupThingType) { @@ -327,23 +329,34 @@ void DungeonMan::loadDungeonFile() { for (uint16 j = 0; j < thingStoreWordCount; ++j) _dunData.thingsData[thingType][i][j] = dunDataStream.readUint16BE(); } + + if (_messages.newGame) { + if ((thingType == kGroupThingType) || thingType >= kProjectileThingType) + _dunData.eventMaximumCount += _fileHeader.thingCounts[thingType]; + for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) { + _dunData.thingsData[thingType][thingCount + i][0] = Thing::thingNone.toUint16(); + } + } + } // load map data - _rawMapData = _rawDunFileData + dunDataStream.pos(); + if (!_messages.restartGameRequest) + _rawMapData = _rawDunFileData + dunDataStream.pos(); - if (_dunData.mapData) delete[] _dunData.mapData; if (!_messages.restartGameRequest) { uint8 mapCount = _fileHeader.mapCount; + if (_dunData.mapData) + delete[] _dunData.mapData; _dunData.mapData = new byte**[_dunData.columCount + mapCount]; byte **colFirstSquares = (byte**)_dunData.mapData + mapCount; for (uint8 i = 0; i < mapCount; ++i) { _dunData.mapData[i] = colFirstSquares; byte *square = _rawMapData + _maps[i].rawDunDataOffset; *colFirstSquares++ = square; - for (uint16 w = 0; w <= _maps[i].width; ++w) { + for (uint16 w = 1; w <= _maps[i].width; ++w) { square += _maps[w].height + 1; *colFirstSquares++ = square; } -- cgit v1.2.3 From 909ec36edf6206efac5d2b4bea32a019520087b7 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Tue, 17 May 2016 22:14:34 +0200 Subject: DM: Fix loading map data in loadDungeonFile(..) --- engines/dm/dungeonman.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index c933744c19..e6d94ec07d 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -357,7 +357,7 @@ void DungeonMan::loadDungeonFile() { byte *square = _rawMapData + _maps[i].rawDunDataOffset; *colFirstSquares++ = square; for (uint16 w = 1; w <= _maps[i].width; ++w) { - square += _maps[w].height + 1; + square += _maps[i].height + 1; *colFirstSquares++ = square; } } -- cgit v1.2.3 From 7ddd96bc60e9a5cbe33a5a246f5a8709d4948181 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Tue, 17 May 2016 22:56:14 +0200 Subject: DM: Fix destructor and allocation issues in DungeonMan and DisplayMan --- engines/dm/dungeonman.cpp | 20 ++++++---------- engines/dm/gfx.cpp | 61 ++++++++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index e6d94ec07d..2d700f3d89 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -84,7 +84,7 @@ void DungeonMan::decompressDungeonFile() { f.open("Dungeon.dat"); if (f.readUint16BE() == 0x8104) { _rawDunFileDataSize = f.readUint32BE(); - if (_rawDunFileData) delete[] _rawDunFileData; + delete[] _rawDunFileData; _rawDunFileData = new byte[_rawDunFileDataSize]; f.readUint16BE(); byte common[4]; @@ -209,8 +209,7 @@ void DungeonMan::loadDungeonFile() { } // load map data - if (_maps) delete[] _maps; - + delete[] _maps; _maps = new Map[_fileHeader.mapCount]; for (uint16 i = 0; i < _fileHeader.mapCount; ++i) { _maps[i].rawDunDataOffset = dunDataStream.readUint16BE(); @@ -242,8 +241,7 @@ void DungeonMan::loadDungeonFile() { } // TODO: ??? is this - begin - if (_dunData.mapsFirstColumnIndex) delete[] _dunData.mapsFirstColumnIndex; - + delete[] _dunData.mapsFirstColumnIndex; _dunData.mapsFirstColumnIndex = new uint16[_fileHeader.mapCount]; uint16 columCount = 0; for (uint16 i = 0; i < _fileHeader.mapCount; ++i) { @@ -259,16 +257,14 @@ void DungeonMan::loadDungeonFile() { _fileHeader.squareFirstThingCount += 300; // TODO: ??? is this - begin - if (_dunData.columnsCumulativeSquareThingCount) - delete[] _dunData.columnsCumulativeSquareThingCount; + delete[] _dunData.columnsCumulativeSquareThingCount; _dunData.columnsCumulativeSquareThingCount = new uint16[columCount]; for (uint16 i = 0; i < columCount; ++i) _dunData.columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE(); // TODO: ??? is this - end // TODO: ??? is this - begin - if (_dunData.squareFirstThings) - delete[] _dunData.squareFirstThings; + delete[] _dunData.squareFirstThings; _dunData.squareFirstThings = new Thing[_fileHeader.squareFirstThingCount]; for (uint16 i = 0; i < actualSquareFirstThingCount; ++i) _dunData.squareFirstThings[i].set(dunDataStream.readUint16BE()); @@ -279,8 +275,7 @@ void DungeonMan::loadDungeonFile() { // TODO: ??? is this - end // load text data - if (_dunData.textData) - delete[] _dunData.textData; + delete[] _dunData.textData; _dunData.textData = new uint16[_fileHeader.textDataWordCount]; for (uint16 i = 0; i < _fileHeader.textDataWordCount; ++i) _dunData.textData[i] = dunDataStream.readUint16BE(); @@ -348,8 +343,7 @@ void DungeonMan::loadDungeonFile() { if (!_messages.restartGameRequest) { uint8 mapCount = _fileHeader.mapCount; - if (_dunData.mapData) - delete[] _dunData.mapData; + delete[] _dunData.mapData; _dunData.mapData = new byte**[_dunData.columCount + mapCount]; byte **colFirstSquares = (byte**)_dunData.mapData + mapCount; for (uint8 i = 0; i < mapCount; ++i) { diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index ae5bcd9f88..3a9d1f03ba 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -21,6 +21,25 @@ namespace DM { #define kFirstFloorOrn 247 // @ C247_GRAPHIC_FIRST_FLOOR_ORNAMENT #define kFirstDoorOrn 303 // @ C303_GRAPHIC_FIRST_DOOR_ORNAMENT +enum WallSetIndices { + kDoorFrameFront = 0, // @ G0709_puc_Bitmap_WallSet_DoorFrameFront + kDoorFrameLeft_D1C = 1, // @ G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C + kFameLeft_D2C = 2, // @ G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C + kDoorFrameLeft_D3C = 3, // @ G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C + kDoorFrameLeft_D3L = 4, // @ G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L + kDoorFrameTop_D1LCR = 5, // @ G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR + kDoorFrameTop_D2LCR = 6, // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR + kWall_D0R = 7, // @ G0702_puc_Bitmap_WallSet_Wall_D0R + kWall_D0L = 8, // @ G0701_puc_Bitmap_WallSet_Wall_D0L + kWall_D1LCR = 9, // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR + kWall_D2LCR = 10, // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR + kWall_D3LCR = 11, // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR + kWall_D3L2 = 12, // @ G0697_puc_Bitmap_WallSet_Wall_D3L2 + + kWall_D3R2 = 13, // @ G0696_puc_Bitmap_WallSet_Wall_D3R2 + kDoorFrameRight_D1C = 14// @ G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C +}; + byte gDoorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordinateSetIndices 0, /* Door Ornament #00 Square Grid */ @@ -496,15 +515,18 @@ DisplayMan::~DisplayMan() { delete[] _packedItemPos; delete[] _packedBitmaps; delete[] _vgaBuffer; - delete[] _bitmaps[0]; - delete[] _bitmaps; - delete[] _wallSetBitMaps[13]; // copy of another bitmap, but flipped - delete[] _wallSetBitMaps[14]; // copy of another bitmap, but flipped + if (_bitmaps) { + delete[] _bitmaps[0]; + delete[] _bitmaps; + } + delete[] _wallSetBitMaps[kWall_D3R2]; // copy of another bitmap, but flipped + delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; // copy of another bitmap, but flipped } void DisplayMan::setUpScreens(uint16 width, uint16 height) { _screenWidth = width; _screenHeight = height; + delete[] _vgaBuffer; _vgaBuffer = new byte[_screenWidth * _screenHeight]; clearScreen(kColorBlack); } @@ -514,11 +536,13 @@ void DisplayMan::loadGraphics() { f.open("graphics.dat"); grapItemCount = f.readUint16BE(); + delete[] _packedItemPos; _packedItemPos = new uint32[grapItemCount + 1]; _packedItemPos[0] = 0; for (uint16 i = 1; i < grapItemCount + 1; ++i) _packedItemPos[i] = f.readUint16BE() + _packedItemPos[i - 1]; + delete[] _packedBitmaps; _packedBitmaps = new uint8[_packedItemPos[grapItemCount]]; f.seek(2 + grapItemCount * 4); @@ -553,6 +577,10 @@ void DisplayMan::unpackGraphics() { for (uint16 i = 22; i <= 532; ++i) unpackedBitmapsSize += width(i) * height(i); // graphics items go from 0-20 and 22-532 inclusive, _unpackedItemPos 21 and 22 are there for indexing convenience + if (_bitmaps) { + delete[] _bitmaps[0]; + delete[] _bitmaps; + } _bitmaps = new byte*[533]; _bitmaps[0] = new byte[unpackedBitmapsSize]; loadIntoBitmap(0, _bitmaps[0]); @@ -702,25 +730,6 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { } -enum WallSetIndices { - kDoorFrameFront = 0, // @ G0709_puc_Bitmap_WallSet_DoorFrameFront - kDoorFrameLeft_D1C = 1, // @ G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C - kFameLeft_D2C = 2, // @ G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C - kDoorFrameLeft_D3C = 3, // @ G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C - kDoorFrameLeft_D3L = 4, // @ G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L - kDoorFrameTop_D1LCR = 5, // @ G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR - kDoorFrameTop_D2LCR = 6, // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR - kWall_D0R = 7, // @ G0702_puc_Bitmap_WallSet_Wall_D0R - kWall_D0L = 8, // @ G0701_puc_Bitmap_WallSet_Wall_D0L - kWall_D1LCR = 9, // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR - kWall_D2LCR = 10, // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR - kWall_D3LCR = 11, // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR - kWall_D3L2 = 12, // @ G0697_puc_Bitmap_WallSet_Wall_D3L2 - - kWall_D3R2 = 13, // @ G0696_puc_Bitmap_WallSet_Wall_D3R2 - kDoorFrameRight_D1C = 14// @ G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C -}; - void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { loadPalette(gPalDungeonView[0]); // TODO: this is a global variable, set from here @@ -783,16 +792,14 @@ void DisplayMan::loadWallSet(WallSet set) { uint16 leftDoorIndice = firstIndice + kDoorFrameLeft_D1C; uint16 w = width(leftDoorIndice), h = height(leftDoorIndice); - if (_wallSetBitMaps[kDoorFrameRight_D1C]) - delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; + delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; _wallSetBitMaps[kDoorFrameRight_D1C] = new byte[w * h]; blitToBitmap(_wallSetBitMaps[kDoorFrameLeft_D1C], w, h, _wallSetBitMaps[kDoorFrameRight_D1C], w); flipBitmapHorizontal(_wallSetBitMaps[kDoorFrameRight_D1C], w, h); uint16 leftWallIndice = firstIndice + kWall_D3L2; w = width(leftWallIndice), h = height(leftWallIndice); - if (_wallSetBitMaps[kWall_D3R2]) - delete[] _wallSetBitMaps[kWall_D3R2]; + delete[] _wallSetBitMaps[kWall_D3R2]; _wallSetBitMaps[kWall_D3R2] = new byte[w * h]; blitToBitmap(_wallSetBitMaps[kWall_D3L2], w, h, _wallSetBitMaps[kWall_D3R2], w); flipBitmapHorizontal(_wallSetBitMaps[kWall_D3R2], w, h); -- cgit v1.2.3 From d49c081785bc4eab83246a9c9697604692f47b1d Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Tue, 17 May 2016 23:09:56 +0200 Subject: DM: Fix loadDungeonFile(..) zero sized array allocation --- engines/dm/dungeonman.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 2d700f3d89..d467f5904c 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -293,6 +293,8 @@ void DungeonMan::loadDungeonFile() { } uint16 thingStoreWordCount = gThingDataWordCount[thingType]; + if (thingStoreWordCount == 0) + continue; if (_dunData.thingsData[thingType]) { delete[] _dunData.thingsData[thingType][0]; -- cgit v1.2.3 From e3136f4247280272e6004e0d4b012e1864489f77 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Wed, 18 May 2016 00:39:08 +0200 Subject: DM: Add viewsquare enum --- engines/dm/gfx.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 3a9d1f03ba..6205bc90f5 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -21,6 +21,30 @@ namespace DM { #define kFirstFloorOrn 247 // @ C247_GRAPHIC_FIRST_FLOOR_ORNAMENT #define kFirstDoorOrn 303 // @ C303_GRAPHIC_FIRST_DOOR_ORNAMENT + +enum ViewSquare { + kViewSquare_D4C = -3, // @ CM3_VIEW_SQUARE_D4C + kViewSquare_D4L = -2, // @ CM2_VIEW_SQUARE_D4L + kViewSquare_D4R = -1, // @ CM1_VIEW_SQUARE_D4R + kViewSquare_D3C = 0, // @ C00_VIEW_SQUARE_D3C + kViewSquare_D3L = 1, // @ C01_VIEW_SQUARE_D3L + kViewSquare_D3R = 2, // @ C02_VIEW_SQUARE_D3R + kViewSquare_D2C = 3, // @ C03_VIEW_SQUARE_D2C + kViewSquare_D2L = 4, // @ C04_VIEW_SQUARE_D2L + kViewSquare_D2R = 5, // @ C05_VIEW_SQUARE_D2R + kViewSquare_D1C = 6, // @ C06_VIEW_SQUARE_D1C + kViewSquare_D1L = 7, // @ C07_VIEW_SQUARE_D1L + kViewSquare_D1R = 8, // @ C08_VIEW_SQUARE_D1R + kViewSquare_D0C = 9, // @ C09_VIEW_SQUARE_D0C + kViewSquare_D0L = 10, // @ C10_VIEW_SQUARE_D0L + kViewSquare_D0R = 11, // @ C11_VIEW_SQUARE_D0R + kViewSquare_D3C_Explosion = 3, // @ C03_VIEW_SQUARE_D3C_EXPLOSION + kViewSquare_D3L_Explosion = 4, // @ C04_VIEW_SQUARE_D3L_EXPLOSION + kViewSquare_D1C_Explosion = 9, // @ C09_VIEW_SQUARE_D1C_EXPLOSION + kViewSquare_D0C_Explosion = 12 // @ C12_VIEW_SQUARE_D0C_EXPLOSION +}; + + enum WallSetIndices { kDoorFrameFront = 0, // @ G0709_puc_Bitmap_WallSet_DoorFrameFront kDoorFrameLeft_D1C = 1, // @ G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C @@ -484,9 +508,9 @@ struct Frame { srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {} }; -Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); -Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); -Frame gWallFrameD3L2(0, 15, 25, 73, 8, 49, 0, 0); // @ FRAME G0711_s_Graphic558_Frame_Wall_D3L2 +Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling +Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor +Frame gWallFrameD3L2(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2 Frame gWallFrameD3R2(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2 extern Viewport gDefultViewPort = {0, 0}; @@ -761,6 +785,7 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { // D3L int16 tmpPosX = posX, tmpPosY = posY; _vm->_dungeonMan->getRelSquareType(dir, 3, -1, tmpPosX, tmpPosY); + drawSquareD3L(dir, posX, posY); -- cgit v1.2.3 From 134b482e60944597d4c8c2290ca1b17e549718d9 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Thu, 19 May 2016 16:26:56 +0200 Subject: DM: Add flipped wall bitmaps --- engines/dm/dm.cpp | 2 +- engines/dm/dungeonman.h | 2 -- engines/dm/gfx.cpp | 79 ++++++++++++++++++++++++++++++++++++------------- engines/dm/gfx.h | 4 +++ 4 files changed, 64 insertions(+), 23 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 64793a9bd9..45863d162c 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -76,7 +76,7 @@ Common::Error DMEngine::run() { _displayMan->drawDungeon(kDirNorth, i++, 0); _displayMan->updateScreen(); _system->delayMillis(1000); //TODO: testing, please set me to 10 - if (i == 3) break; + if (i == 10) break; } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 5f1dcd3d40..931d635da0 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -466,8 +466,6 @@ public: Messages _messages; // @ NONE; int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex - - }; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 6205bc90f5..3e170d12ac 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -10,6 +10,18 @@ namespace DM { +// The frames in the orignal sources contain inclusive boundaries and byte widths, not pixel widths +struct Frame { + uint16 destFromX, destToX, destFromY, destToY; + uint16 srcWidth, srcHeight; + uint16 srcX, srcY; + + Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, + uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) : + destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1), + srcWidth(srcWidth), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {} +}; + #define kFirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT #define kFirstFloorSet 75 // @ C075_GRAPHIC_FIRST_FLOOR_SET @@ -44,6 +56,26 @@ enum ViewSquare { kViewSquare_D0C_Explosion = 12 // @ C12_VIEW_SQUARE_D0C_EXPLOSION }; +Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling +Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor + +Frame gFrameWall_D3L2 = {0, 15, 25, 73, 8 * 2, 49, 0, 0}; // @ G0711_s_Graphic558_Frame_Wall_D3L2 +Frame gFrameWall_D3R2 = {208, 223, 25, 73, 8 * 2, 49, 0, 0}; // @ G0712_s_Graphic558_Frame_Wall_D3R2 +Frame gFrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls + /* { X1, X2, Y1, Y2, pixelWidth, Height, X, Y } */ + {74, 149, 25, 75, 64 * 2, 51, 18, 0}, /* D3C */ + {0, 83, 25, 75, 64 * 2, 51, 32, 0}, /* D3L */ + {139, 223, 25, 75, 64 * 2, 51, 0, 0}, /* D3R */ + {60, 163, 20, 90, 72 * 2, 71, 16, 0}, /* D2C */ + {0, 74, 20, 90, 72 * 2, 71, 61, 0}, /* D2L */ + {149, 223, 20, 90, 72 * 2, 71, 0, 0}, /* D2R */ + {32, 191, 9, 119, 128 * 2, 111, 48, 0}, /* D1C */ + {0, 63, 9, 119, 128 * 2, 111, 192, 0}, /* D1L */ + {160, 223, 9, 119, 128 * 2, 111, 0, 0}, /* D1R */ + {0, 223, 0, 135, 0 * 2, 0, 0, 0}, /* D0C */ + {0, 31, 0, 135, 16 * 2, 136, 0, 0}, /* D0L */ + {192, 223, 0, 135, 16 * 2, 136, 0, 0}}; /* D0R */ + enum WallSetIndices { kDoorFrameFront = 0, // @ G0709_puc_Bitmap_WallSet_DoorFrameFront @@ -496,22 +528,7 @@ enum GraphicIndice { kDoorMaskDestroyedIndice = 301 // @ C301_GRAPHIC_DOOR_MASK_DESTROYED }; -// The frames in the orignal sources contain inclusive boundaries and byte widths, not pixel widths -struct Frame { - uint16 destFromX, destToX, destFromY, destToY; - uint16 srcWidth, srcHeight; - uint16 srcX, srcY; - - Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) : - destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1), - srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {} -}; -Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling -Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor -Frame gWallFrameD3L2(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2 -Frame gWallFrameD3R2(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2 extern Viewport gDefultViewPort = {0, 0}; extern Viewport gDungeonViewport = {0, 64}; // TODO: I guessed the numbers @@ -545,6 +562,8 @@ DisplayMan::~DisplayMan() { } delete[] _wallSetBitMaps[kWall_D3R2]; // copy of another bitmap, but flipped delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; // copy of another bitmap, but flipped + for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i) + delete[] _wallSetBitMapsFlipped[i]; } void DisplayMan::setUpScreens(uint16 width, uint16 height) { @@ -750,7 +769,13 @@ void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) { } void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { - + uint16 squareAspect[5]; + _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + switch (squareAspect[0]) { + case kWallElemType: + drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3L]); + break; + } } @@ -769,6 +794,9 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { flipBitmapHorizontal(tmpBitmap, w, h); drawWallSetBitmap(tmpBitmap, gFloorFrame); drawWallSetBitmap(_ceilingBitmap, gCeilingFrame); + + for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i) + _wallSetBitMaps[i] = _wallSetBitMapsFlipped[i]; } else { uint16 w = gCeilingFrame.srcWidth, h = gCeilingFrame.srcHeight; blitToBitmap(_ceilingBitmap, w, h, tmpBitmap, w); @@ -778,16 +806,18 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { } if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallElemType) - drawWallSetBitmap(_wallSetBitMaps[kWall_D3L2], gWallFrameD3L2); + drawWallSetBitmap(_wallSetBitMaps[kWall_D3L2], gFrameWall_D3L2); if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallElemType) - drawWallSetBitmap(_wallSetBitMaps[kWall_D3R2], gWallFrameD3R2); + drawWallSetBitmap(_wallSetBitMaps[kWall_D3R2], gFrameWall_D3R2); // D3L int16 tmpPosX = posX, tmpPosY = posY; _vm->_dungeonMan->getRelSquareType(dir, 3, -1, tmpPosX, tmpPosY); - drawSquareD3L(dir, posX, posY); + //drawSquareD3L(dir, posX, posY); + for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i) + _wallSetBitMaps[i] = _wallSetBitMapsNative[i]; delete[] tmpBitmap; } @@ -814,7 +844,6 @@ void DisplayMan::loadWallSet(WallSet set) { _wallSetBitMaps[i] = _bitmaps[i + firstIndice]; } - uint16 leftDoorIndice = firstIndice + kDoorFrameLeft_D1C; uint16 w = width(leftDoorIndice), h = height(leftDoorIndice); delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; @@ -828,6 +857,16 @@ void DisplayMan::loadWallSet(WallSet set) { _wallSetBitMaps[kWall_D3R2] = new byte[w * h]; blitToBitmap(_wallSetBitMaps[kWall_D3L2], w, h, _wallSetBitMaps[kWall_D3R2], w); flipBitmapHorizontal(_wallSetBitMaps[kWall_D3R2], w, h); + for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i) + _wallSetBitMapsNative[i] = _wallSetBitMaps[i]; + + for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i) { + uint16 w = width(firstIndice + i), h = height(firstIndice + i); + delete[] _wallSetBitMapsFlipped[i]; + _wallSetBitMapsFlipped[i] = new byte[w * h]; + blitToBitmap(_wallSetBitMaps[i], w, h, _wallSetBitMapsFlipped[i], w); + flipBitmapHorizontal(_wallSetBitMapsFlipped[i], w, h); + } } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 576d9e3452..ee2b3730f0 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -93,6 +93,10 @@ class DisplayMan { // the last two pointers are owned by this array byte *_wallSetBitMaps[15] = {NULL}; // @G[0696..0710]_puc_Bitmap_WallSet_... + // only [7-11] is used, indexing convenience + byte *_wallSetBitMapsNative[12] = {NULL}; // @G[0095..0099]_puc_Bitmap_Wall... + byte *_wallSetBitMapsFlipped[12] = {NULL}; // @G[0090..0094]_puc_Bitmap_Wall... + // pointers are not owned by these fields byte *_floorBitmap = NULL; byte *_ceilingBitmap = NULL; -- cgit v1.2.3 From d9bb44eeb97370f5ff6d25f9b917073072db6552 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Fri, 20 May 2016 13:37:47 +0200 Subject: DM: Add the partial drawing of dungeonwalls --- engines/dm/dm.cpp | 8 +- engines/dm/dungeonman.cpp | 2 +- engines/dm/gfx.cpp | 184 ++++++++++++++++++++++++++++++++++++++++------ engines/dm/gfx.h | 12 +++ 4 files changed, 177 insertions(+), 29 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 45863d162c..9295ea6b57 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -68,15 +68,13 @@ Common::Error DMEngine::run() { _displayMan->loadPalette(gPalCredits); - - uint16 i = 0; //TODO: testing, please delete me while (true) { _displayMan->clearScreen(kColorBlack); - _displayMan->drawDungeon(kDirNorth, i++, 0); + _displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY + i); _displayMan->updateScreen(); - _system->delayMillis(1000); //TODO: testing, please set me to 10 - if (i == 10) break; + _system->delayMillis(2000); //TODO: testing, please set me to 10 + if (++i == 100) break; } diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index d467f5904c..e2ad66a418 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -472,7 +472,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, memset(aspectArray, 0, 5 * sizeof(int16)); aspectArray[kElemAspect] = square.getType(); - _vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75 + _vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75, possible fix switch (square.getType()) { case kWallElemType: switch (dir) { diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 3e170d12ac..8bf61783e7 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -19,7 +19,7 @@ struct Frame { Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) : destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1), - srcWidth(srcWidth), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {} + srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {} }; @@ -59,28 +59,28 @@ enum ViewSquare { Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor -Frame gFrameWall_D3L2 = {0, 15, 25, 73, 8 * 2, 49, 0, 0}; // @ G0711_s_Graphic558_Frame_Wall_D3L2 -Frame gFrameWall_D3R2 = {208, 223, 25, 73, 8 * 2, 49, 0, 0}; // @ G0712_s_Graphic558_Frame_Wall_D3R2 +Frame gFrameWall_D3L2 = {0, 15, 25, 73, 8, 49, 0, 0}; // @ G0711_s_Graphic558_Frame_Wall_D3L2 +Frame gFrameWall_D3R2 = {208, 223, 25, 73, 8, 49, 0, 0}; // @ G0712_s_Graphic558_Frame_Wall_D3R2 Frame gFrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls /* { X1, X2, Y1, Y2, pixelWidth, Height, X, Y } */ - {74, 149, 25, 75, 64 * 2, 51, 18, 0}, /* D3C */ - {0, 83, 25, 75, 64 * 2, 51, 32, 0}, /* D3L */ - {139, 223, 25, 75, 64 * 2, 51, 0, 0}, /* D3R */ - {60, 163, 20, 90, 72 * 2, 71, 16, 0}, /* D2C */ - {0, 74, 20, 90, 72 * 2, 71, 61, 0}, /* D2L */ - {149, 223, 20, 90, 72 * 2, 71, 0, 0}, /* D2R */ - {32, 191, 9, 119, 128 * 2, 111, 48, 0}, /* D1C */ - {0, 63, 9, 119, 128 * 2, 111, 192, 0}, /* D1L */ - {160, 223, 9, 119, 128 * 2, 111, 0, 0}, /* D1R */ - {0, 223, 0, 135, 0 * 2, 0, 0, 0}, /* D0C */ - {0, 31, 0, 135, 16 * 2, 136, 0, 0}, /* D0L */ - {192, 223, 0, 135, 16 * 2, 136, 0, 0}}; /* D0R */ + {74, 149, 25, 75, 64, 51, 18, 0}, /* D3C */ + {0, 83, 25, 75, 64, 51, 32, 0}, /* D3L */ + {139, 223, 25, 75, 64, 51, 0, 0}, /* D3R */ + {60, 163, 20, 90, 72, 71, 16, 0}, /* D2C */ + {0, 74, 20, 90, 72, 71, 61, 0}, /* D2L */ + {149, 223, 20, 90, 72, 71, 0, 0}, /* D2R */ + {32, 191, 9, 119, 128, 111, 48, 0}, /* D1C */ + {0, 63, 9, 119, 128, 111, 192, 0}, /* D1L */ + {160, 223, 9, 119, 128, 111, 0, 0}, /* D1R */ + {0, 223, 0, 135, 0, 0, 0, 0}, /* D0C */ + {0, 31, 0, 135, 16, 136, 0, 0}, /* D0L */ + {192, 223, 0, 135, 16, 136, 0, 0}}; /* D0R */ enum WallSetIndices { kDoorFrameFront = 0, // @ G0709_puc_Bitmap_WallSet_DoorFrameFront kDoorFrameLeft_D1C = 1, // @ G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C - kFameLeft_D2C = 2, // @ G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C + kDoorFameLeft_D2C = 2, // @ G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C kDoorFrameLeft_D3C = 3, // @ G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C kDoorFrameLeft_D3L = 4, // @ G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L kDoorFrameTop_D1LCR = 5, // @ G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR @@ -690,8 +690,8 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { for (int j = 0; j < byte1 / 2; ++j) { uint8 byte2 = data[nextByteIndex++]; - destBitmap[k++] = byte2 & 0x0F; destBitmap[k++] = (byte2 & 0xF0) >> 4; + destBitmap[k++] = byte2 & 0x0F; } } } @@ -764,8 +764,15 @@ uint16 DisplayMan::height(uint16 index) { return READ_BE_UINT16(data + 2); } + +void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { + if (f.srcWidth) + blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorNoTransparency, gDungeonViewport); +} + void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) { - blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport); + if (f.srcWidth) + blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport); } void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { @@ -778,9 +785,110 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { } } +void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { + uint16 squareAspect[5]; + _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + switch (squareAspect[0]) { + case kWallElemType: + drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3R]); + break; + } +} +void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) { + uint16 squareAspect[5]; + _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + switch (squareAspect[0]) { + case kWallElemType: + drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3C]); + break; + } +} +void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) { + uint16 squareAspect[5]; + _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + switch (squareAspect[0]) { + case kWallElemType: + drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2L]); + break; + } +} +void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) { + uint16 squareAspect[5]; + _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + switch (squareAspect[0]) { + case kWallElemType: + drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2R]); + break; + } +} +void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) { + uint16 squareAspect[5]; + _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + switch (squareAspect[0]) { + case kWallElemType: + drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2C]); + break; + } +} +void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) { + uint16 squareAspect[5]; + _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + switch (squareAspect[0]) { + case kWallElemType: + drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1L]); + break; + } +} +void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) { + uint16 squareAspect[5]; + _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + switch (squareAspect[0]) { + case kWallElemType: + drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1R]); + break; + } +} +void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) { + uint16 squareAspect[5]; + _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + switch (squareAspect[0]) { + case kWallElemType: + drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1C]); + break; + } +} +void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) { + uint16 squareAspect[5]; + _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + switch (squareAspect[0]) { + case kWallElemType: + drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]); + break; + } +} + +void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) { + uint16 squareAspect[5]; + _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + switch (squareAspect[0]) { + case kWallElemType: + drawWallSetBitmap(_wallSetBitMaps[kWall_D0R], gFrameWalls[kViewSquare_D0R]); + break; + } +} + +void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) { + uint16 squareAspect[5]; + _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + switch (squareAspect[0]) { + case kWallElemType: + drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]); + break; + } +} void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { - loadPalette(gPalDungeonView[0]); + loadPalette(gPalEntrance); // TODO: this is a global variable, set from here bool flippedFloorCeiling = (posX + posY + dir) & 1; @@ -795,7 +903,7 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { drawWallSetBitmap(tmpBitmap, gFloorFrame); drawWallSetBitmap(_ceilingBitmap, gCeilingFrame); - for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i) + for (uint16 i = kWall_D0R; i <= kWall_D3LCR && false; ++i) // TODO: I dunno what this flipped wall thing is, but it messes everything up, disable with && false _wallSetBitMaps[i] = _wallSetBitMapsFlipped[i]; } else { uint16 w = gCeilingFrame.srcWidth, h = gCeilingFrame.srcHeight; @@ -810,10 +918,40 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallElemType) drawWallSetBitmap(_wallSetBitMaps[kWall_D3R2], gFrameWall_D3R2); - // D3L int16 tmpPosX = posX, tmpPosY = posY; - _vm->_dungeonMan->getRelSquareType(dir, 3, -1, tmpPosX, tmpPosY); - //drawSquareD3L(dir, posX, posY); + _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY); + drawSquareD3L(dir, posX, posY); + tmpPosX = posX, tmpPosY = posY; + _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, 1, tmpPosX, tmpPosY); + drawSquareD3R(dir, tmpPosX, tmpPosY); + tmpPosX = posX, tmpPosY = posY; + _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, 0, tmpPosX, tmpPosY); + drawSquareD3C(dir, tmpPosX, tmpPosY); + tmpPosX = posX, tmpPosY = posY; + _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, -1, tmpPosX, tmpPosY); + drawSquareD2L(dir, tmpPosX, tmpPosY); + tmpPosX = posX, tmpPosY = posY; + _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, 1, tmpPosX, tmpPosY); + drawSquareD2R(dir, tmpPosX, tmpPosY); + tmpPosX = posX, tmpPosY = posY; + _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, 0, tmpPosX, tmpPosY); + drawSquareD2C(dir, tmpPosX, tmpPosY); + tmpPosX = posX, tmpPosY = posY; + _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, -1, tmpPosX, tmpPosY); + drawSquareD1L(dir, tmpPosX, tmpPosY); + tmpPosX = posX, tmpPosY = posY; + _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, 1, tmpPosX, tmpPosY); + drawSquareD1R(dir, tmpPosX, tmpPosY); + tmpPosX = posX, tmpPosY = posY; + _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, 0, tmpPosX, tmpPosY); + drawSquareD1C(dir, tmpPosX, tmpPosY); + tmpPosX = posX, tmpPosY = posY; + _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 0, -1, tmpPosX, tmpPosY); + drawSquareD0L(dir, tmpPosX, tmpPosY); + tmpPosX = posX, tmpPosY = posY; + _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 0, 1, tmpPosX, tmpPosY); + drawSquareD0R(dir, tmpPosX, tmpPosY); + drawSquareD0C(dir, posX, posY); for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i) diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index ee2b3730f0..963a8412e3 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -114,7 +114,19 @@ class DisplayMan { void unpackGraphics(); void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap + void drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L + void drawSquareD3R(direction dir, int16 posX, int16 posY); // @ F0117_DUNGEONVIEW_DrawSquareD3R + void drawSquareD3C(direction dir, int16 posX, int16 posY); // @ F0118_DUNGEONVIEW_DrawSquareD3C_CPSF + void drawSquareD2L(direction dir, int16 posX, int16 posY); // @ F0119_DUNGEONVIEW_DrawSquareD2L + void drawSquareD2R(direction dir, int16 posX, int16 posY); // @ F0120_DUNGEONVIEW_DrawSquareD2R_CPSF + void drawSquareD2C(direction dir, int16 posX, int16 posY); // @ F0121_DUNGEONVIEW_DrawSquareD2C + void drawSquareD1L(direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1L + void drawSquareD1R(direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1R + void drawSquareD1C(direction dir, int16 posX, int16 posY); // @ F0124_DUNGEONVIEW_DrawSquareD1C + void drawSquareD0L(direction dir, int16 posX, int16 posY); // @ F0125_DUNGEONVIEW_DrawSquareD0L + void drawSquareD0R(direction dir, int16 posX, int16 posY); // @ F0126_DUNGEONVIEW_DrawSquareD0R + void drawSquareD0C(direction dir, int16 posX, int16 posY); // @ F0127_DUNGEONVIEW_DrawSquareD0C void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet -- cgit v1.2.3 From 9655066a069bc86a956b7da19f6a06ceda2fd4bf Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Sat, 21 May 2016 12:55:37 +0200 Subject: DM: getSquareAspect(..) is complete --- engines/dm/dm.cpp | 2 +- engines/dm/dm.h | 49 ++++++++++++++++++++++++++-- engines/dm/dungeonman.cpp | 81 ++++++++++++++++++++++++++++++++++++++++------- engines/dm/dungeonman.h | 45 +++----------------------- engines/dm/gfx.h | 3 +- 5 files changed, 122 insertions(+), 58 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 9295ea6b57..72a068d31b 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -71,7 +71,7 @@ Common::Error DMEngine::run() { uint16 i = 0; //TODO: testing, please delete me while (true) { _displayMan->clearScreen(kColorBlack); - _displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY + i); + _displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY); _displayMan->updateScreen(); _system->delayMillis(2000); //TODO: testing, please set me to 10 if (++i == 100) break; diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 7c8afd132a..a0bbadd156 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -8,6 +8,11 @@ namespace DM { +class Console; +class DisplayMan; +class DungeonMan; + + enum direction { kDirNorth = 0, kDirEast = 1, @@ -15,9 +20,47 @@ enum direction { kDirWest = 3 }; -class Console; -class DisplayMan; -class DungeonMan; +int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX +int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL +enum ThingType { + kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value + kDoorThingType = 0, + kTeleporterThingType = 1, + kTextstringType = 2, + kSensorThingType = 3, + kGroupThingType = 4, + kWeaponThingType = 5, + kArmourThingType = 6, + kScrollThingType = 7, + kPotionThingType = 8, + kContainerThingType = 9, + kJunkThingType = 10, + kProjectileThingType = 14, + kExplosionThingType = 15, + kThingTypeTotal = 16 // +1 than the last (explosionThingType) +}; // @ C[00..15]_THING_TYPE_... + +class Thing { + uint16 data; +public: + static const Thing thingNone; + static const Thing thingEndOfList; + + Thing() {} + Thing(uint16 d) { set(d); } + + void set(uint16 d) { + data = d; + } + + byte getCell() const { return data >> 14; } + ThingType getType() const { return (ThingType)((data >> 10) & 0xF); } + uint16 getIndex() const { return data & 0x1FF; } + uint16 toUint16() const { return data; } // I don't like 'em cast operators + bool operator==(const Thing &rhs) const { return data == rhs.data; } + bool operator!=(const Thing &rhs) const { return data != rhs.data; } +}; // @ THING + enum { // engine debug channels diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index e2ad66a418..cd713e4127 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -12,6 +12,7 @@ int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } +bool isOrientedWestEast(direction dir) { return dir & 1; } } @@ -458,21 +459,24 @@ enum SquareAspectIndice { kStairsUpAspect = 2, kDoorStateAspect = 2, kDoorThingIndexAspect = 3, - kFloorOrnOrdAspect = 4 + kFloorOrnOrdAspect = 4, + kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS }; -void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) { +// TODO: get rid of the GOTOs +void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) { // complete, except where marked bool leftOrnAllowed, rightOrnAllowed, frontOrnAllowed; bool squareIsFakeWall; + bool footPrintsAllowed; + _vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75, possible fix + + memset(aspectArray, 0, 5 * sizeof(uint16)); Thing thing = getSquareFirstThing(mapX, mapY); Square square = getSquare(mapX, mapY); - memset(aspectArray, 0, 5 * sizeof(int16)); aspectArray[kElemAspect] = square.getType(); - - _vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75, possible fix switch (square.getType()) { case kWallElemType: switch (dir) { @@ -499,6 +503,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, } squareIsFakeWall = false; +T0172010_ClosedFakeWall: setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall); while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) { @@ -507,13 +512,13 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, if (thing.getType() == kTextstringType) { if (TextString(getThingData(thing)).isVisible()) { aspectArray[sideIndex + 1] = _currMapInscriptionWallOrnIndex + 1; - - } else { - Sensor sensor(getThingData(thing)); - aspectArray[sideIndex + 1] = sensor.getOrnOrdinal(); - if (sensor.getType() == kSensorWallChampionPortrait) { - _vm->_displayMan->_championPortraitOrdinal = indexToOrdinal(sensor.getData()); - } + _vm->_displayMan->_inscriptionThing = thing; // BUG0_76 + } + } else { + Sensor sensor(getThingData(thing)); + aspectArray[sideIndex + 1] = sensor.getOrnOrdinal(); + if (sensor.getType() == kSensorWallChampionPortrait) { + _vm->_displayMan->_championPortraitOrdinal = indexToOrdinal(sensor.getData()); } } } @@ -521,8 +526,60 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, } if (squareIsFakeWall && (_currMap.partyPosX != mapX) && (_currMap.partyPosY != mapY)) { aspectArray[kFirstGroupOrObjectAspect] = Thing::thingEndOfList.toUint16(); + return; } break; + case kPitElemType: + if (square.get(kPitOpen)) + aspectArray[kPitInvisibleAspect] = square.get(kPitInvisible); + else + aspectArray[kElemAspect] = kCorridorElemType; + footPrintsAllowed = true; + goto T0172030_Pit; + case kFakeWallElemType: + if (!square.get(kFakeWallOpen)) { + aspectArray[kElemAspect] = kWallElemType; + leftOrnAllowed = rightOrnAllowed = frontOrnAllowed = square.get(kFakeWallRandOrnOrFootPAllowed); + squareIsFakeWall = true; + goto T0172010_ClosedFakeWall; + } + aspectArray[kWallElemType] = kCorridorElemType; + footPrintsAllowed = square.get(kFakeWallRandOrnOrFootPAllowed); + // intentional fallthrough + case kCorridorElemType: + aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap.map->randFloorOrnCount, mapX, mapY, 30); +T0172029_Teleporter: + footPrintsAllowed = true; +T0172030_Pit: + while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) { + if (thing.getType() == kSensorThingType) + aspectArray[kFloorOrnOrdAspect] = Sensor(getThingData(thing)).getOrnOrdinal(); + thing = getNextThing(thing); + } + goto T0172049_Footprints; + case kTeleporterElemType: + aspectArray[kTeleporterVisibleAspect] = square.get(kTeleporterOpen) && square.get(kTeleporterVisible); + goto T0172029_Teleporter; + case kStairsElemType: + aspectArray[kElemAspect] = ((square.get(kStairsNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) ? kStairsSideElemType : kStairsFrontElemType; + aspectArray[kStairsUpAspect] = square.get(kStairsUp); + footPrintsAllowed = false; + goto T0172046_Stairs; + case kDoorElemType: + if ((square.get(kDoorNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) { + aspectArray[kElemAspect] = kDoorSideElemType; + } else { + aspectArray[kElemAspect] = kDoorFrontElemType; + aspectArray[kDoorStateAspect] = square.getDoorState(); + aspectArray[kDoorThingIndexAspect] = getSquareFirstThing(mapX, mapY).getIndex(); + } + footPrintsAllowed = true; +T0172046_Stairs: + while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) + thing = getNextThing(thing); +T0172049_Footprints: + if (footPrintsAllowed) // TODO: I skipped some party query code, must come back later and complete + aspectArray[kFloorOrnOrdAspect] &= kFootprintsAspect; } aspectArray[kFirstGroupOrObjectAspect] = thing.toUint16(); } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 931d635da0..3c0215849c 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -10,46 +10,6 @@ class DungeonMan; struct Map; -int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX -int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL -enum ThingType { - kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value - kDoorThingType = 0, - kTeleporterThingType = 1, - kTextstringType = 2, - kSensorThingType = 3, - kGroupThingType = 4, - kWeaponThingType = 5, - kArmourThingType = 6, - kScrollThingType = 7, - kPotionThingType = 8, - kContainerThingType = 9, - kJunkThingType = 10, - kProjectileThingType = 14, - kExplosionThingType = 15, - kThingTypeTotal = 16 // +1 than the last (explosionThingType) -}; // @ C[00..15]_THING_TYPE_... - -class Thing { - uint16 data; -public: - static const Thing thingNone; - static const Thing thingEndOfList; - - Thing() {} - Thing(uint16 d) { set(d); } - - void set(uint16 d) { - data = d; - } - - byte getCell() const { return data >> 14; } - ThingType getType() const { return (ThingType)((data >> 10) & 0xF); } - uint16 getIndex() const { return data & 0x1FF; } - uint16 toUint16() const { return data; } // I don't like 'em cast operators - bool operator==(const Thing &rhs) const { return data == rhs.data; } - bool operator!=(const Thing &rhs) const { return data != rhs.data; } -}; // @ THING struct CreatureInfo { byte creatureAspectIndex; @@ -297,6 +257,7 @@ enum SquareMask { kWallSouthRandOrnAllowed = 0x2, kWallEastRandOrnAllowed = 0x4, kWallNorthRandOrnAllowed = 0x8, + kCorridorRandOrnAllowed = 0x8, kPitImaginary = 0x1, kPitInvisible = 0x4, kPitOpen = 0x8, @@ -334,7 +295,9 @@ public: Square(SquareType type) { setType(type); } Square &set(byte dat) { this->data = dat; return *this; } Square &set(SquareMask mask) { data |= mask; return *this; } - bool get(SquareMask mask) { return data & mask; } + byte get(SquareMask mask) { return data & mask; } + byte getDoorState() { return data & 0x7; } // @ M36_DOOR_STATE + Square &setDoorState(byte state) { data = ((data & ~0x7) | state); } // @ M37_SET_DOOR_STATE SquareType getType() { return (SquareType)(data >> 5); } // @ M34_SQUARE_TYPE Square &setType(SquareType type) { data = (data & 0x1F) | type << 5; return *this; } byte toByte() { return data; } // I don't like 'em casts diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 963a8412e3..4c54ff6ca6 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -166,7 +166,6 @@ public: void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); - int16 _championPortraitOrdinal = 0; // @ G0289_i_DungeonView_ChampionPortraitOrdinal int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount] = {0}; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices int16 _currMapFountainOrnIndices[kFountainOrnCount] = {0}; // @ G0268_ai_CurrentMapFountainOrnamentIndices @@ -179,6 +178,8 @@ public: byte _currMapDoorOrnIndices[18] = {0}; // @ G0263_auc_CurrentMapDoorOrnamentIndices int16 _currMapViAltarIndex = 0; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex + + Thing _inscriptionThing = Thing::thingNone; // @ G0290_T_DungeonView_InscriptionThing }; } -- cgit v1.2.3 From 807fda8a9a3d7b975a749c6d82232526bc43281d Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Sat, 21 May 2016 19:36:24 +0200 Subject: DM: Add wall flipping display --- engines/dm/dm.cpp | 11 +++++-- engines/dm/gfx.cpp | 91 ++++++++++++++++++++++++++++++++++++------------------ engines/dm/gfx.h | 13 +++++--- 3 files changed, 77 insertions(+), 38 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 72a068d31b..9cdcd1a9f4 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -68,13 +68,18 @@ Common::Error DMEngine::run() { _displayMan->loadPalette(gPalCredits); + byte pos[] = {kDirSouth, 1, 3, kDirSouth, 1, 4, kDirSouth, 1, 5, kDirSouth, 1, 6, kDirSouth, 1, 7, kDirEast, 1, 7}; + uint16 i = 0; //TODO: testing, please delete me while (true) { _displayMan->clearScreen(kColorBlack); - _displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY); + _displayMan->drawDungeon((direction)pos[i*3 + 0], pos[i*3 + 1], pos[i*3 + 2]); + //_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY + i); _displayMan->updateScreen(); - _system->delayMillis(2000); //TODO: testing, please set me to 10 - if (++i == 100) break; + _system->delayMillis(1000); //TODO: testing, please set me to 10 + if(i == 0) + _system->delayMillis(0000); //TODO: testing, please set me to 10 + if (++i == 6) i = 0; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 8bf61783e7..4dbc31515a 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -93,7 +93,19 @@ enum WallSetIndices { kWall_D3L2 = 12, // @ G0697_puc_Bitmap_WallSet_Wall_D3L2 kWall_D3R2 = 13, // @ G0696_puc_Bitmap_WallSet_Wall_D3R2 - kDoorFrameRight_D1C = 14// @ G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C + kDoorFrameRight_D1C = 14, // @ G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C + + kWall_D0R_Flipped = 15, + kWall_D0L_Flipped = 16, + kWall_D1LCR_Flipped = 17, + kWall_D2LCR_Flipped = 18, + kWall_D3LCR_Flipped = 19, + + kWall_D0R_Native = 20, + kWall_D0L_Native = 21, + kWall_D1LCR_Native = 22, + kWall_D2LCR_Native = 23, + kWall_D3LCR_Native = 24, }; @@ -562,8 +574,8 @@ DisplayMan::~DisplayMan() { } delete[] _wallSetBitMaps[kWall_D3R2]; // copy of another bitmap, but flipped delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; // copy of another bitmap, but flipped - for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i) - delete[] _wallSetBitMapsFlipped[i]; + for (uint16 i = kWall_D0L_Flipped; i <= kWall_D3LCR_Flipped; ++i) + delete[] _wallSetBitMaps[i]; } void DisplayMan::setUpScreens(uint16 width, uint16 height) { @@ -903,8 +915,8 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { drawWallSetBitmap(tmpBitmap, gFloorFrame); drawWallSetBitmap(_ceilingBitmap, gCeilingFrame); - for (uint16 i = kWall_D0R; i <= kWall_D3LCR && false; ++i) // TODO: I dunno what this flipped wall thing is, but it messes everything up, disable with && false - _wallSetBitMaps[i] = _wallSetBitMapsFlipped[i]; + for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i) + _wallSetBitMaps[i + kWall_D0R] = _wallSetBitMaps[i + kWall_D0R_Flipped]; } else { uint16 w = gCeilingFrame.srcWidth, h = gCeilingFrame.srcHeight; blitToBitmap(_ceilingBitmap, w, h, tmpBitmap, w); @@ -920,7 +932,7 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { int16 tmpPosX = posX, tmpPosY = posY; _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY); - drawSquareD3L(dir, posX, posY); + drawSquareD3L(dir, tmpPosX, tmpPosY); tmpPosX = posX, tmpPosY = posY; _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, 1, tmpPosX, tmpPosY); drawSquareD3R(dir, tmpPosX, tmpPosY); @@ -954,8 +966,8 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { drawSquareD0C(dir, posX, posY); - for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i) - _wallSetBitMaps[i] = _wallSetBitMapsNative[i]; + for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i) + _wallSetBitMaps[i + kWall_D0R] = _wallSetBitMaps[i + kWall_D0R_Native]; delete[] tmpBitmap; } @@ -976,35 +988,54 @@ void DisplayMan::loadFloorSet(FloorSet set) { _ceilingBitmap = _bitmaps[indice + 1]; } + +Box gBoxWallBitmap_D3LCR = {0, 115, 0, 50}; // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR +Box gBoxWallBitmap_D2LCR = {0, 135, 0, 70}; // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR + void DisplayMan::loadWallSet(WallSet set) { uint16 firstIndice = (set * kWallSetGraphicCount) + kFirstWallSet; for (uint16 i = 0; i < kWallSetGraphicCount; ++i) { _wallSetBitMaps[i] = _bitmaps[i + firstIndice]; } - uint16 leftDoorIndice = firstIndice + kDoorFrameLeft_D1C; - uint16 w = width(leftDoorIndice), h = height(leftDoorIndice); - delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; - _wallSetBitMaps[kDoorFrameRight_D1C] = new byte[w * h]; - blitToBitmap(_wallSetBitMaps[kDoorFrameLeft_D1C], w, h, _wallSetBitMaps[kDoorFrameRight_D1C], w); - flipBitmapHorizontal(_wallSetBitMaps[kDoorFrameRight_D1C], w, h); - - uint16 leftWallIndice = firstIndice + kWall_D3L2; - w = width(leftWallIndice), h = height(leftWallIndice); - delete[] _wallSetBitMaps[kWall_D3R2]; - _wallSetBitMaps[kWall_D3R2] = new byte[w * h]; - blitToBitmap(_wallSetBitMaps[kWall_D3L2], w, h, _wallSetBitMaps[kWall_D3R2], w); - flipBitmapHorizontal(_wallSetBitMaps[kWall_D3R2], w, h); - for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i) - _wallSetBitMapsNative[i] = _wallSetBitMaps[i]; - - for (uint16 i = kWall_D0R; i <= kWall_D3LCR; ++i) { - uint16 w = width(firstIndice + i), h = height(firstIndice + i); - delete[] _wallSetBitMapsFlipped[i]; - _wallSetBitMapsFlipped[i] = new byte[w * h]; - blitToBitmap(_wallSetBitMaps[i], w, h, _wallSetBitMapsFlipped[i], w); - flipBitmapHorizontal(_wallSetBitMapsFlipped[i], w, h); + for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i) + _wallSetBitMaps[i + kWall_D0R_Native] = _wallSetBitMaps[i + kWall_D0R]; + + uint16 srcIndex[7] = {kDoorFrameLeft_D1C, kWall_D3L2, kWall_D1LCR, kWall_D0L, kWall_D0R, + kWall_D2LCR, kWall_D3LCR}; + + uint16 destIndex[7] = {kDoorFrameRight_D1C, kWall_D3R2, kWall_D1LCR_Flipped, kWall_D0R_Flipped, kWall_D0L_Flipped, + kWall_D2LCR_Flipped, kWall_D3LCR_Flipped}; + + for (uint16 i = 0; i < 7; ++i) { + uint16 srcGraphicIndice = firstIndice + srcIndex[i]; + uint16 w = width(srcGraphicIndice), h = height(srcGraphicIndice); + delete[] _wallSetBitMaps[destIndex[i]]; + _wallSetBitMaps[destIndex[i]] = new byte[w * h]; + blitToBitmap(_wallSetBitMaps[srcIndex[i]], w, h, _wallSetBitMaps[destIndex[i]], w); + if (srcIndex[i] != kWall_D2LCR && srcIndex[i] != kWall_D3LCR) // TODO: implement flipping of these two bitmaps, disabled with if + flipBitmapHorizontal(_wallSetBitMaps[destIndex[i]], w, h); } + + + /* + uint16 graphicIndice = firstIndice + kWall_D2LCR; + uint16 w = width(graphicIndice), h = height(graphicIndice); + byte *tmp = new byte[w * h]; + clearBitmap(tmp, w, h, kColorFlesh); + Box *box = &gBoxWallBitmap_D2LCR; + blitToBitmap(_wallSetBitMaps[kWall_D2LCR_Flipped], w, 8, 0, tmp, w, box->X1, box->X2, box->Y1, box->Y2, kColorNoTransparency); + delete[] _wallSetBitMaps[kWall_D2LCR_Flipped]; + _wallSetBitMaps[kWall_D2LCR_Flipped] = tmp; + + graphicIndice = firstIndice + kWall_D3LCR; + w = width(graphicIndice), h = height(graphicIndice); + tmp = new byte[w * h]; + clearBitmap(tmp, w, h, kColorFlesh); + box = &gBoxWallBitmap_D3LCR; + blitToBitmap(_wallSetBitMaps[kWall_D3LCR_Flipped], w, 8, 0, tmp, w, box->X1, box->X2, box->Y1, box->Y2, kColorNoTransparency); + delete[] _wallSetBitMaps[kWall_D3LCR_Flipped]; + _wallSetBitMaps[kWall_D3LCR_Flipped] = tmp;*/ } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 4c54ff6ca6..8b59d5194a 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -12,6 +12,13 @@ extern uint16 gPalCredits[16]; extern uint16 gPalEntrance[16]; extern uint16 gPalDungeonView[6][16]; +typedef struct { + uint16 X1; + uint16 X2; + uint16 Y1; + uint16 Y2; +} Box; // @ BOX_BYTE, BOX_WORD + struct Frame; enum WallSet { kWallSetStone = 0 // @ C0_WALL_SET_STONE @@ -91,11 +98,7 @@ class DisplayMan { // the last two pointers are owned by this array - byte *_wallSetBitMaps[15] = {NULL}; // @G[0696..0710]_puc_Bitmap_WallSet_... - - // only [7-11] is used, indexing convenience - byte *_wallSetBitMapsNative[12] = {NULL}; // @G[0095..0099]_puc_Bitmap_Wall... - byte *_wallSetBitMapsFlipped[12] = {NULL}; // @G[0090..0094]_puc_Bitmap_Wall... + byte *_wallSetBitMaps[25] = {NULL}; // @G[0696..0710]_puc_Bitmap_WallSet_... // pointers are not owned by these fields byte *_floorBitmap = NULL; -- cgit v1.2.3 From f591cbbcf350b0f61cb2441bd4a89a7b45e3c689 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Sat, 21 May 2016 21:09:09 +0200 Subject: DM: Add dummy movement code for testing --- engines/dm/dm.cpp | 55 ++++++++++++++++++++++++++++++++++++++--------- engines/dm/dm.h | 11 ++++++++-- engines/dm/dungeonman.cpp | 12 ----------- engines/dm/dungeonman.h | 7 +++--- engines/dm/gfx.h | 1 + 5 files changed, 59 insertions(+), 27 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 9cdcd1a9f4..0aa4cb32b0 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -9,6 +9,7 @@ #include "engines/engine.h" #include "graphics/palette.h" #include "common/file.h" +#include "common/events.h" #include "dm/dm.h" #include "dm/gfx.h" @@ -16,6 +17,13 @@ namespace DM { +int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; +int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; + +void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } +void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); } +bool isOrientedWestEast(direction dir) { return dir & 1; } + DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { // Do not load data files @@ -59,7 +67,8 @@ Common::Error DMEngine::run() { _displayMan->loadGraphics(); _dungeonMan->loadDungeonFile(); - _dungeonMan->setCurrentMapAndPartyMap(0); + int16 dummyMapIndex = 0; + _dungeonMan->setCurrentMapAndPartyMap(dummyMapIndex); @@ -68,18 +77,44 @@ Common::Error DMEngine::run() { _displayMan->loadPalette(gPalCredits); - byte pos[] = {kDirSouth, 1, 3, kDirSouth, 1, 4, kDirSouth, 1, 5, kDirSouth, 1, 6, kDirSouth, 1, 7, kDirEast, 1, 7}; - - uint16 i = 0; //TODO: testing, please delete me + CurrMapData &currMap = _dungeonMan->_currMap; while (true) { + Common::Event event; + while (_system->getEventManager()->pollEvent(event)) { + if (event.type == Common::EVENT_KEYDOWN && !event.synthetic) + switch (event.kbd.keycode) { + case Common::KEYCODE_w: + _dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY); + break; + case Common::KEYCODE_a: + _dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY); + break; + case Common::KEYCODE_s: + _dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY); + break; + case Common::KEYCODE_d: + _dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY); + break; + case Common::KEYCODE_q: + turnDirLeft(currMap.partyDir); + break; + case Common::KEYCODE_e: + turnDirRight(currMap.partyDir); + break; + case Common::KEYCODE_UP: + if (dummyMapIndex < 13) + _dungeonMan->setCurrentMapAndPartyMap(++dummyMapIndex); + break; + case Common::KEYCODE_DOWN: + if (dummyMapIndex > 0) + _dungeonMan->setCurrentMapAndPartyMap(--dummyMapIndex); + break; + } + } _displayMan->clearScreen(kColorBlack); - _displayMan->drawDungeon((direction)pos[i*3 + 0], pos[i*3 + 1], pos[i*3 + 2]); - //_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY + i); + _displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY); _displayMan->updateScreen(); - _system->delayMillis(1000); //TODO: testing, please set me to 10 - if(i == 0) - _system->delayMillis(0000); //TODO: testing, please set me to 10 - if (++i == 6) i = 0; + _system->delayMillis(10); } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index a0bbadd156..817c3ece28 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -20,8 +20,15 @@ enum direction { kDirWest = 3 }; -int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX -int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL +// TODO: refactor direction into a class +extern int8 dirIntoStepCountEast[4]; +extern int8 dirIntoStepCountNorth[4]; + +void turnDirRight(direction &dir); +void turnDirLeft(direction &dir); +bool isOrientedWestEast(direction dir); + + enum ThingType { kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value kDoorThingType = 0, diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index cd713e4127..ccefaceb45 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -5,18 +5,6 @@ - -namespace DM { -// TODO: refactor direction into a class -int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; -int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; - -void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } -bool isOrientedWestEast(direction dir) { return dir & 1; } - - -} - using namespace DM; CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 3c0215849c..35a337d088 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -9,7 +9,8 @@ namespace DM { class DungeonMan; struct Map; - +int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX +int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL struct CreatureInfo { byte creatureAspectIndex; @@ -360,8 +361,8 @@ struct DungeonData { struct CurrMapData { direction partyDir; // @ G0308_i_PartyDirection - uint16 partyPosX; // @ G0306_i_PartyMapX - uint16 partyPosY; // @ G0307_i_PartyMapY + int16 partyPosX; // @ G0306_i_PartyMapX + int16 partyPosY; // @ G0307_i_PartyMapY uint8 currPartyMapIndex; // @ G0309_i_PartyMapIndex uint8 index; // @ G0272_i_CurrentMapIndex diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 8b59d5194a..d558e812a7 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -116,6 +116,7 @@ class DisplayMan { void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap void unpackGraphics(); + // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap void drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L -- cgit v1.2.3 From 3ada56f6b1e8f2b65b6a77dbd3ff4d91bba705a0 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Sun, 22 May 2016 00:32:53 +0200 Subject: DM: Add stairs display --- engines/dm/dungeonman.cpp | 17 +--- engines/dm/dungeonman.h | 17 ++++ engines/dm/gfx.cpp | 192 +++++++++++++++++++++++++++++++++++++++++++--- engines/dm/gfx.h | 34 +++++++- 4 files changed, 233 insertions(+), 27 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index ccefaceb45..af10338030 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -7,6 +7,8 @@ using namespace DM; + + CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo /* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo, MovementTicks, AttackTicks, Defense, BaseHealth, Attack, PoisonAttack, @@ -436,21 +438,6 @@ Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) { return _dunData.squareFirstThings[index]; } -enum SquareAspectIndice { - kElemAspect = 0, - kFirstGroupOrObjectAspect = 1, - kRightWallOrnOrdAspect = 2, - kFrontWallOrnOrdAspect = 3, - kLeftWallOrnOrdAspect = 4, - kPitInvisibleAspect = 2, - kTeleporterVisibleAspect = 2, - kStairsUpAspect = 2, - kDoorStateAspect = 2, - kDoorThingIndexAspect = 3, - kFloorOrnOrdAspect = 4, - kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS -}; - // TODO: get rid of the GOTOs void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) { // complete, except where marked diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 35a337d088..60a0bb6881 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -12,6 +12,23 @@ struct Map; int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL + +enum SquareAspectIndice { + kElemAspect = 0, + kFirstGroupOrObjectAspect = 1, + kRightWallOrnOrdAspect = 2, + kFrontWallOrnOrdAspect = 3, + kLeftWallOrnOrdAspect = 4, + kPitInvisibleAspect = 2, + kTeleporterVisibleAspect = 2, + kStairsUpAspect = 2, + kDoorStateAspect = 2, + kDoorThingIndexAspect = 3, + kFloorOrnOrdAspect = 4, + kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS +}; + + struct CreatureInfo { byte creatureAspectIndex; byte attackSoundOrdinal; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 4dbc31515a..c88ca0068a 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -23,6 +23,71 @@ struct Frame { }; +enum StairFrameIndex { + kFrameStairsUpFront_D3L = 0, // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L + kFrameStairsUpFront_D3C = 1, // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C + kFrameStairsUpFront_D3R = 2, // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R + kFrameStairsUpFront_D2L = 3, // @ G0113_s_Graphic558_Frame_StairsUpFront_D2L + kFrameStairsUpFront_D2C = 4, // @ G0114_s_Graphic558_Frame_StairsUpFront_D2C + kFrameStairsUpFront_D2R = 5, // @ G0115_s_Graphic558_Frame_StairsUpFront_D2R + kFrameStairsUpFront_D1L = 6, // @ G0116_s_Graphic558_Frame_StairsUpFront_D1L + kFrameStairsUpFront_D1C = 7, // @ G0117_s_Graphic558_Frame_StairsUpFront_D1C + kFrameStairsUpFront_D1R = 8, // @ G0118_s_Graphic558_Frame_StairsUpFront_D1R + kFrameStairsUpFront_D0L = 9, // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L + kFrameStairsUpFront_D0R = 10, // @ G0120_s_Graphic558_Frame_StairsUpFront_D0R + kFrameStairsDownFront_D3L = 11, // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L + kFrameStairsDownFront_D3C = 12, // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C + kFrameStairsDownFront_D3R = 13, // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R + kFrameStairsDownFront_D2L = 14, // @ G0124_s_Graphic558_Frame_StairsDownFront_D2L + kFrameStairsDownFront_D2C = 15, // @ G0125_s_Graphic558_Frame_StairsDownFront_D2C + kFrameStairsDownFront_D2R = 16, // @ G0126_s_Graphic558_Frame_StairsDownFront_D2R + kFrameStairsDownFront_D1L = 17, // @ G0127_s_Graphic558_Frame_StairsDownFront_D1L + kFrameStairsDownFront_D1C = 18, // @ G0128_s_Graphic558_Frame_StairsDownFront_D1C + kFrameStairsDownFront_D1R = 19, // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R + kFrameStairsDownFront_D0L = 20, // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L + kFrameStairsDownFront_D0R = 21, // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R + kFrameStairsSide_D2L = 22, // @ G0132_s_Graphic558_Frame_StairsSide_D2L + kFrameStairsSide_D2R = 23, // @ G0133_s_Graphic558_Frame_StairsSide_D2R + kFrameStairsUpSide_D1L = 24, // @ G0134_s_Graphic558_Frame_StairsUpSide_D1L + kFrameStairsUpSide_D1R = 25, // @ G0135_s_Graphic558_Frame_StairsUpSide_D1R + kFrameStairsDownSide_D1L = 26, // @ G0136_s_Graphic558_Frame_StairsDownSide_D1L + kFrameStairsDownSide_D1R = 27, // @ G0137_s_Graphic558_Frame_StairsDownSide_D1R + kFrameStairsSide_D0L = 28, // @ G0138_s_Graphic558_Frame_StairsSide_D0L + kFrameStairsSide_D0R = 29 // @ G0139_s_Graphic558_Frame_StairsSide_D0R +}; + +Frame gStairFrames[] = {{0, 79, 25, 70, 40, 46, 0, 0}, +{64, 159, 25, 70, 48, 46, 0, 0}, +{149, 223, 25, 70, 40, 46, 5, 0}, +{0, 63, 22, 83, 32, 62, 0, 0}, +{64, 159, 22, 83, 48, 62, 0, 0}, +{160, 223, 22, 83, 32, 62, 0, 0}, +{0, 31, 9, 108, 16, 100, 0, 0}, +{32, 191, 9, 108, 80, 100, 0, 0}, +{192, 223, 9, 108, 16, 100, 0, 0}, +{0, 31, 58, 101, 16, 44, 0, 0}, +{192, 223, 58, 101, 16, 44, 0, 0}, +{0, 79, 28, 68, 40, 41, 0, 0}, +{64, 159, 28, 70, 48, 43, 0, 0}, +{149, 223, 28, 68, 40, 41, 5, 0}, +{0, 63, 24, 85, 32, 62, 0, 0}, +{64, 159, 24, 85, 48, 62, 0, 0}, +{160, 223, 24, 85, 32, 62, 0, 0}, +{0, 31, 18, 108, 16, 91, 0, 0}, +{32, 191, 18, 108, 80, 91, 0, 0}, +{192, 223, 18, 108, 16, 91, 0, 0}, +{0, 31, 76, 135, 16, 60, 0, 0}, +{192, 223, 76, 135, 16, 60, 0, 0}, +{60, 75, 57, 61, 8, 5, 0, 0}, +{148, 163, 57, 61, 8, 5, 0, 0}, +{32, 63, 57, 99, 16, 43, 0, 0}, +{160, 191, 57, 99, 16, 43, 0, 0}, +{32, 63, 60, 98, 16, 39, 0, 0}, +{160, 191, 60, 98, 16, 39, 0, 0}, +{0, 15, 73, 85, 8, 13, 0, 0}, +{208, 223, 73, 85, 8, 13, 0, 0}}; + + #define kFirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT #define kFirstFloorSet 75 // @ C075_GRAPHIC_FIRST_FLOOR_SET #define kFirstWallSet 77 // @ C077_GRAPHIC_FIRST_WALL_SET @@ -581,6 +646,8 @@ DisplayMan::~DisplayMan() { void DisplayMan::setUpScreens(uint16 width, uint16 height) { _screenWidth = width; _screenHeight = height; + delete[] _tmpBitmap; + _tmpBitmap = new byte[_screenWidth * _screenHeight]; delete[] _vgaBuffer; _vgaBuffer = new byte[_screenWidth * _screenHeight]; clearScreen(kColorBlack); @@ -590,18 +657,18 @@ void DisplayMan::loadGraphics() { Common::File f; f.open("graphics.dat"); - grapItemCount = f.readUint16BE(); + _grapItemCount = f.readUint16BE(); delete[] _packedItemPos; - _packedItemPos = new uint32[grapItemCount + 1]; + _packedItemPos = new uint32[_grapItemCount + 1]; _packedItemPos[0] = 0; - for (uint16 i = 1; i < grapItemCount + 1; ++i) + for (uint16 i = 1; i < _grapItemCount + 1; ++i) _packedItemPos[i] = f.readUint16BE() + _packedItemPos[i - 1]; delete[] _packedBitmaps; - _packedBitmaps = new uint8[_packedItemPos[grapItemCount]]; + _packedBitmaps = new uint8[_packedItemPos[_grapItemCount]]; - f.seek(2 + grapItemCount * 4); - for (uint32 i = 0; i < _packedItemPos[grapItemCount]; ++i) + f.seek(2 + _grapItemCount * 4); + for (uint32 i = 0; i < _packedItemPos[_grapItemCount]; ++i) _packedBitmaps[i] = f.readByte(); f.close(); @@ -790,7 +857,13 @@ void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) { void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { + switch (squareAspect[kElemAspect]) { + case kStairsFrontElemType: + if (squareAspect[kStairsUpAspect]) + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3L]); + else + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3L]); + break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3L]); break; @@ -801,6 +874,12 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { + case kStairsFrontElemType: + if (squareAspect[kStairsUpAspect]) + drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3R]); + else + drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3R]); + break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3R]); break; @@ -810,6 +889,12 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { + case kStairsFrontElemType: + if (squareAspect[kStairsUpAspect]) + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D3C, gStairFrames[kFrameStairsUpFront_D3C]); + else + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D3C, gStairFrames[kFrameStairsDownFront_D3C]); + break; case kWallElemType: drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3C]); break; @@ -819,24 +904,48 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { + case kStairsFrontElemType: + if (squareAspect[kStairsUpAspect]) + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2L]); + else + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2L]); + break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2L]); break; + case kStairsSideElemType: + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D2L, gFrameWalls[kFrameStairsSide_D2L]); + break; } } void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { + case kStairsFrontElemType: + if (squareAspect[kStairsUpAspect]) + drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2R]); + else + drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2R]); + break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2R]); break; + case kStairsSideElemType: + drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]); + break; } } void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { + case kStairsFrontElemType: + if (squareAspect[kStairsUpAspect]) + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D2C, gStairFrames[kFrameStairsUpFront_D2C]); + else + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D2C, gStairFrames[kFrameStairsDownFront_D2C]); + break; case kWallElemType: drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2C]); break; @@ -846,24 +955,54 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { + case kStairsFrontElemType: + if (squareAspect[kStairsUpAspect]) + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1L]); + else + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1L]); + break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1L]); break; + case kStairsSideElemType: + if (squareAspect[kStairsUpAspect]) + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1L]); + else + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1L]); + break; } } void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { + case kStairsFrontElemType: + if (squareAspect[kStairsUpAspect]) + drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1R]); + else + drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1R]); + break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1R]); break; + case kStairsSideElemType: + if (squareAspect[kStairsUpAspect]) + drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1R]); + else + drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1R]); + break; } } void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { + case kStairsFrontElemType: + if (squareAspect[kStairsUpAspect]) + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D1C, gStairFrames[kFrameStairsUpFront_D1C]); + else + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D1C, gStairFrames[kFrameStairsDownFront_D1C]); + break; case kWallElemType: drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1C]); break; @@ -873,6 +1012,10 @@ void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { + case kStairsSideElemType: + if (squareAspect[kStairsUpAspect]) + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0L]); + break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]); break; @@ -883,6 +1026,10 @@ void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { + case kStairsSideElemType: + if (squareAspect[kStairsUpAspect]) + drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0R]); + return; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D0R], gFrameWalls[kViewSquare_D0R]); break; @@ -893,8 +1040,14 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { - case kWallElemType: - drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]); + case kStairsFrontElemType: + if (squareAspect[kStairsUpAspect]) { + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0L]); + drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0R]); + } else { + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0L]); + drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0R]); + } break; } } @@ -1007,6 +1160,8 @@ void DisplayMan::loadWallSet(WallSet set) { uint16 destIndex[7] = {kDoorFrameRight_D1C, kWall_D3R2, kWall_D1LCR_Flipped, kWall_D0R_Flipped, kWall_D0L_Flipped, kWall_D2LCR_Flipped, kWall_D3LCR_Flipped}; + // the original loads these flipped walls in loadCurrentMapGraphics + for (uint16 i = 0; i < 7; ++i) { uint16 srcGraphicIndice = firstIndice + srcIndex[i]; uint16 w = width(srcGraphicIndice), h = height(srcGraphicIndice); @@ -1043,6 +1198,11 @@ void DisplayMan::loadCurrentMapGraphics() { loadFloorSet(_vm->_dungeonMan->_currMap.map->floorSet); loadWallSet(_vm->_dungeonMan->_currMap.map->wallSet); + // the original loads some flipped walls here, I moved it to loadWallSet + + for (uint16 i = 0, firstGraphicIndex = _vm->_dungeonMan->_currMap.map->wallSet * kStairsGraphicCount + kFirstStairs; i < kStairsGraphicCount; ++i) + _stairIndices[i] = firstGraphicIndex + i; + for (int16 i = 0; i < kAlcoveOrnCount; ++i) _currMapAlcoveOrnIndices[i] = -1; for (int16 i = 0; i < kFountainOrnCount; ++i) @@ -1110,3 +1270,17 @@ void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor gPalChangesCreature_D2[replacedColor] = gCreatureReplColorSets[replacementColor].D2ReplacementColor; gPalChangesCreature_D3[replacedColor] = gCreatureReplColorSets[replacementColor].D3ReplacementColor; } + +void DisplayMan::drawFloorPitOrStairsBitmap(StairIndex relIndex, Frame &f) { + if (f.srcWidth) { + blitToScreen(_bitmaps[_stairIndices[relIndex]], f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport); + } +} + +void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relIndex, Frame &f) { + if (f.srcWidth) { + blitToBitmap(_bitmaps[_stairIndices[relIndex]], f.srcWidth, f.srcHeight, _tmpBitmap, f.srcWidth); + flipBitmapHorizontal(_tmpBitmap, f.srcWidth, f.srcHeight); + blitToScreen(_tmpBitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport); + } +} diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index d558e812a7..bc7296e9c2 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -28,6 +28,28 @@ enum FloorSet { kFloorSetStone = 0 // @ C0_FLOOR_SET_STONE }; +enum StairIndex { + kStairsNativeIndex_Up_Front_D3L = 0, // @ G0675_i_StairsNativeBitmapIndex_Up_Front_D3L + kStairsNativeIndex_Up_Front_D3C = 1, // @ G0676_i_StairsNativeBitmapIndex_Up_Front_D3C + kStairsNativeIndex_Up_Front_D2L = 2, // @ G0677_i_StairsNativeBitmapIndex_Up_Front_D2L + kStairsNativeIndex_Up_Front_D2C = 3, // @ G0678_i_StairsNativeBitmapIndex_Up_Front_D2C + kStairsNativeIndex_Up_Front_D1L = 4, // @ G0679_i_StairsNativeBitmapIndex_Up_Front_D1L + kStairsNativeIndex_Up_Front_D1C = 5, // @ G0680_i_StairsNativeBitmapIndex_Up_Front_D1C + kStairsNativeIndex_Up_Front_D0C_Left = 6, // @ G0681_i_StairsNativeBitmapIndex_Up_Front_D0C_Left + kStairsNativeIndex_Down_Front_D3L = 7, // @ G0682_i_StairsNativeBitmapIndex_Down_Front_D3L + kStairsNativeIndex_Down_Front_D3C = 8, // @ G0683_i_StairsNativeBitmapIndex_Down_Front_D3C + kStairsNativeIndex_Down_Front_D2L = 9, // @ G0684_i_StairsNativeBitmapIndex_Down_Front_D2L + kStairsNativeIndex_Down_Front_D2C = 10, // @ G0685_i_StairsNativeBitmapIndex_Down_Front_D2C + kStairsNativeIndex_Down_Front_D1L = 11, // @ G0686_i_StairsNativeBitmapIndex_Down_Front_D1L + kStairsNativeIndex_Down_Front_D1C = 12, // @ G0687_i_StairsNativeBitmapIndex_Down_Front_D1C + kStairsNativeIndex_Down_Front_D0C_Left = 13, // @ G0688_i_StairsNativeBitmapIndex_Down_Front_D0C_Left + kStairsNativeIndex_Side_D2L = 14, // @ G0689_i_StairsNativeBitmapIndex_Side_D2L + kStairsNativeIndex_Up_Side_D1L = 15, // @ G0690_i_StairsNativeBitmapIndex_Up_Side_D1L + kStairsNativeIndex_Down_Side_D1L = 16, // @ G0691_i_StairsNativeBitmapIndex_Down_Side_D1L + kStairsNativeIndex_Side_D0L = 17 // @ G0692_i_StairsNativeBitmapIndex_Side_D0L +}; + + enum Color { kColorNoTransparency = 255, kColorBlack = 0, @@ -91,15 +113,18 @@ class DisplayMan { /// Related to graphics.dat file - uint16 grapItemCount = 0; // @ G0632_ui_GraphicCount + uint16 _grapItemCount = 0; // @ G0632_ui_GraphicCount uint32 *_packedItemPos = NULL; byte *_packedBitmaps = NULL; byte **_bitmaps = NULL; - // the last two pointers are owned by this array + // pointers 13,14 and [15-19] are owned by this array byte *_wallSetBitMaps[25] = {NULL}; // @G[0696..0710]_puc_Bitmap_WallSet_... + uint16 _stairIndices[kStairsGraphicCount] = {0}; + + // pointers are not owned by these fields byte *_floorBitmap = NULL; byte *_ceilingBitmap = NULL; @@ -116,7 +141,8 @@ class DisplayMan { void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap void unpackGraphics(); - // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap + void drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally + void drawFloorPitOrStairsBitmap(StairIndex relIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap void drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L @@ -137,6 +163,8 @@ class DisplayMan { void applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors + // some methods use this for a stratchpad, don't make assumptions about content between function calls + byte *_tmpBitmap = NULL; public: DisplayMan(DMEngine *dmEngine); ~DisplayMan(); -- cgit v1.2.3 From 082e3fb37ccd97f9d8a782f4fb47adf9a0661ecb Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Sun, 22 May 2016 16:35:29 +0200 Subject: DM: Add global variable dependencies for isDrawnWallOrnAnAlcove --- engines/dm/dungeonman.h | 4 ++++ engines/dm/gfx.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++++-- engines/dm/gfx.h | 21 ++++++++++++++++++- 3 files changed, 76 insertions(+), 3 deletions(-) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 60a0bb6881..dbcb6fbcd8 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -447,6 +447,10 @@ public: Messages _messages; // @ NONE; int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex + byte _dungeonViewClickableBoxes[6][4]; // G0291_aauc_DungeonViewClickableBoxes + bool _isFacingAlcove; // @ G0286_B_FacingAlcove + bool _isFacingViAltar; // @ G0287_B_FacingViAltar + bool _isFacingFountain; // @ G0288_B_FacingFountain }; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index c88ca0068a..0840da6b02 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -121,6 +121,7 @@ enum ViewSquare { kViewSquare_D0C_Explosion = 12 // @ C12_VIEW_SQUARE_D0C_EXPLOSION }; + Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor @@ -607,8 +608,9 @@ enum GraphicIndice { -extern Viewport gDefultViewPort = {0, 0}; -extern Viewport gDungeonViewport = {0, 64}; // TODO: I guessed the numbers +Viewport gDefultViewPort = {0, 0}; +// TODO: I guessed the numbers +Viewport gDungeonViewport = {0, 64}; // @ G0296_puc_Bitmap_Viewport byte gPalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges @@ -1004,6 +1006,9 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) { drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D1C, gStairFrames[kFrameStairsDownFront_D1C]); break; case kWallElemType: + _vm->_dungeonMan->_isFacingAlcove = false; + _vm->_dungeonMan->_isFacingViAltar = false; + _vm->_dungeonMan->_isFacingFountain = false; drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1C]); break; } @@ -1061,6 +1066,11 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { byte *tmpBitmap = new byte[305 * 111]; clearBitmap(tmpBitmap, 305, 111, kColorBlack); + memset(_vm->_dungeonMan->_dungeonViewClickableBoxes, 0, sizeof(_vm->_dungeonMan->_dungeonViewClickableBoxes)); + for (uint16 i = 0; i < 6; ++i) { + _vm->_dungeonMan->_dungeonViewClickableBoxes[i][0] = 255; + } + if (flippedFloorCeiling) { uint16 w = gFloorFrame.srcWidth, h = gFloorFrame.srcHeight; blitToBitmap(_floorBitmap, w, h, tmpBitmap, w); @@ -1215,6 +1225,8 @@ void DisplayMan::loadCurrentMapGraphics() { uint16 fountainCount = 0; Map &currMap = *_vm->_dungeonMan->_currMap.map; + _currMapViAltarIndex = -1; + for (uint16 i = 0; i < currMap.wallOrnCount; ++i) { uint16 ornIndice = _currMapWallOrnIndices[i]; uint16 nativeIndice = kFirstWallOrn + ornIndice * 2; @@ -1284,3 +1296,41 @@ void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relInd blitToScreen(_tmpBitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport); } } + + +Box gBoxWallPatchBehindInscription = {110, 113, 37, 63}; // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription +byte gInscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY + 48, /* 1 Line */ + 59, /* 2 lines */ + 75, /* 3 lines */ + 86}; /* 4 lines */ +byte gWallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_WallOrnamentDerivedBitmapIndexIncrement + 0, /* D3L Right */ + 0, /* D3R Left */ + 1, /* D3L Front */ + 1, /* D3C Front */ + 1, /* D3R Front */ + 2, /* D2L Right */ + 2, /* D2R Left */ + 3, /* D2L Front */ + 3, /* D2C Front */ + 3, /* D2R Front */ + 4, /* D1L Right */ + 4}; /* D1R Left */ + +byte gPalChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3 +byte gPalChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2 + +byte gUnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2 + /* { Y for 1 line, Y for 2 lines, Y for 3 lines } */ + 45, 48, 53, /* D3L Right, D3R Left */ + 43, 49, 56, /* D3L Front, D3C Front, D3R Front */ + 42, 49, 56, /* D2L Right, D2R Left */ + 46, 53, 63, /* D2L Front, D2C Front, D2R Front */ + 46, 57, 68}; /* D1L Right, D1R Left */ + +Box gBoxChampionPortraitOnWall = {96, 127, 35, 63}; // G0109_s_Graphic558_Box_ChampionPortraitOnWall + +bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) { + return false; // dummy +} diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index bc7296e9c2..bbd9eb48f9 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -49,6 +49,23 @@ enum StairIndex { kStairsNativeIndex_Side_D0L = 17 // @ G0692_i_StairsNativeBitmapIndex_Side_D0L }; +enum ViewWall { + kViewWall_D3L_RIGHT = 0, // @ C00_VIEW_WALL_D3L_RIGHT + kViewWall_D3R_LEFT = 1, // @ C01_VIEW_WALL_D3R_LEFT + kViewWall_D3L_FRONT = 2, // @ C02_VIEW_WALL_D3L_FRONT + kViewWall_D3C_FRONT = 3, // @ C03_VIEW_WALL_D3C_FRONT + kViewWall_D3R_FRONT = 4, // @ C04_VIEW_WALL_D3R_FRONT + kViewWall_D2L_RIGHT = 5, // @ C05_VIEW_WALL_D2L_RIGHT + kViewWall_D2R_LEFT = 6, // @ C06_VIEW_WALL_D2R_LEFT + kViewWall_D2L_FRONT = 7, // @ C07_VIEW_WALL_D2L_FRONT + kViewWall_D2C_FRONT = 8, // @ C08_VIEW_WALL_D2C_FRONT + kViewWall_D2R_FRONT = 9, // @ C09_VIEW_WALL_D2R_FRONT + kViewWall_D1L_RIGHT = 10, // @ C10_VIEW_WALL_D1L_RIGHT + kViewWall_D1R_LEFT = 11, // @ C11_VIEW_WALL_D1R_LEFT + kViewWall_D1C_FRONT = 12 // @ C12_VIEW_WALL_D1C_FRONT +}; + + enum Color { kColorNoTransparency = 255, @@ -163,6 +180,8 @@ class DisplayMan { void applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors + bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF + // some methods use this for a stratchpad, don't make assumptions about content between function calls byte *_tmpBitmap = NULL; public: @@ -201,7 +220,7 @@ public: int16 _championPortraitOrdinal = 0; // @ G0289_i_DungeonView_ChampionPortraitOrdinal int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount] = {0}; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices int16 _currMapFountainOrnIndices[kFountainOrnCount] = {0}; // @ G0268_ai_CurrentMapFountainOrnamentIndices - int16 _currMapWallOrnInfo[16][2] = {0}; // @ G0101_aai_CurrentMapWallOrnamentsInf + int16 _currMapWallOrnInfo[16][2] = {0}; // @ G0101_aai_CurrentMapWallOrnamentsInfo int16 _currMapFloorOrnInfo[16][2] = {0}; // @ G0102_aai_CurrentMapFloorOrnamentsInfo int16 _currMapDoorOrnInfo[17][2] = {0}; // @ G0103_aai_CurrentMapDoorOrnamentsInfo byte *_currMapAllowedCreatureTypes = NULL; // @ G0264_puc_CurrentMapAllowedCreatureTypes -- cgit v1.2.3 From 3a85c565815c58e6e6c9b007776b83ad942d7767 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Sun, 22 May 2016 17:18:56 +0200 Subject: DM: Add decodeText dependencies --- engines/dm/dungeonman.cpp | 104 ++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/dungeonman.h | 15 ++++++- 2 files changed, 117 insertions(+), 2 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index af10338030..1da24e6b1d 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -604,3 +604,107 @@ Thing DungeonMan::getNextThing(Thing thing) { return getThingData(thing)[0]; // :) } +char gMessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings + {'x', 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '?', 0, 0, 0, 0, 0, 0, 0 }, */ + {'y', 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '!', 0, 0, 0, 0, 0, 0, 0 }, */ + {'T','H','E',' ', 0, 0, 0, 0}, + {'Y','O','U',' ', 0, 0, 0, 0}, + {'z', 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ + {'{', 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ + {'|', 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ + {'}', 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ + {'~', 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ + {'', 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}}; +char gEscReplacementCharacters[32][2] = { // @ G0256_aac_Graphic559_EscapeReplacementCharacters + {'a', 0}, + {'b', 0}, + {'c', 0}, + {'d', 0}, + {'e', 0}, + {'f', 0}, + {'g', 0}, + {'h', 0}, + {'i', 0}, + {'j', 0}, + {'k', 0}, + {'l', 0}, + {'m', 0}, + {'n', 0}, + {'o', 0}, + {'p', 0}, + {'q', 0}, + {'r', 0}, + {'s', 0}, + {'t', 0}, + {'u', 0}, + {'v', 0}, + {'w', 0}, + {'x', 0}, + {'0', 0}, + {'1', 0}, + {'2', 0}, + {'3', 0}, + {'4', 0}, + {'5', 0}, + {'6', 0}, + {'7', 0}}; +char gInscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_InscriptionEscapeReplacementStrings + {28, 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ + {29, 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ + {19, 7, 4, 26, 0, 0, 0, 0}, + {24, 14, 20, 26, 0, 0, 0, 0}, + {30, 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ + {31, 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ + {32, 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ + {33, 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ + {34, 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ + {35, 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}}; + + +void decodeText(char *destString, Thing thing, TextType type) { + +} diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index dbcb6fbcd8..4a5ff1786a 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -13,6 +13,15 @@ int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL +enum TextType { + /* Used for text on walls */ + kTextTypeInscription = 0, // @ C0_TEXT_TYPE_INSCRIPTION + /* Used for messages displayed when the party walks on a square */ + kTextTypeMessage = 1, // @ C1_TEXT_TYPE_MESSAGE + /* Used for text on scrolls and champion information */ + kTextTypeScroll = 2 // @ C2_TEXT_TYPE_SCROLL +}; + enum SquareAspectIndice { kElemAspect = 0, kFirstGroupOrObjectAspect = 1, @@ -287,7 +296,8 @@ enum SquareMask { kFakeWallImaginary = 0x1, kFakeWallOpen = 0x4, kFakeWallRandOrnOrFootPAllowed = 0x8, - kThingListPresent = 0x10 + kThingListPresent = 0x10, + kDecodeEvenIfInvisible = 0x8000 }; enum SquareType { @@ -434,8 +444,9 @@ public: return Square(getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType(); } // @ F0153_DUNGEON_GetRelativeSquareType void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect + void decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText - uint32 _rawDunFileDataSize = 0; // @ probably NONE + uint32 _rawDunFileDataSize = 0; // @ probably NONE byte *_rawDunFileData = NULL; // @ ??? DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader -- cgit v1.2.3 From 02c0487b5769b9a2d53f1cf692c2bb616b03be96 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Sun, 22 May 2016 18:43:35 +0200 Subject: DM: Add decodeText function --- engines/dm/dungeonman.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 1da24e6b1d..4d75d12582 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -705,6 +705,69 @@ char gInscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_Insc {0, 0, 0, 0, 0, 0, 0, 0}}; -void decodeText(char *destString, Thing thing, TextType type) { - +void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { + char sepChar; + TextString textString(_dunData.thingsData[kTextstringType][thing.getIndex()]); + if ((textString.isVisible()) || (type & kDecodeEvenIfInvisible)) { + type = (TextType)(type & ~kDecodeEvenIfInvisible); + if (type == kTextTypeMessage) { + *destString++ = '\n'; + sepChar = ' '; + } else if (type == kTextTypeInscription) { + sepChar = 0x80; + } else { + sepChar = '\n'; + } + uint16 codeCounter = 0; + int16 escChar = 0; + uint16 *codeWord = _dunData.textData + textString.getWordOffset(); + uint16 code, codes; + char *escReplString = NULL; + for (;;) { /*infinite loop*/ + if (!codeCounter) { + codes = *codeWord++; + code = (codes >> 10) & 0x1F; + } else if (codeCounter == 1) { + code = (codes >> 5) & 0x1F; + } else { + code = codes & 0x1F; + } + ++codeCounter; + codeCounter %= 3; + + if (escChar) { + *destString = '\0'; + if (escChar == 30) { + if (type != kTextTypeInscription) { + escReplString = gMessageAndScrollEscReplacementStrings[code]; + } else { + escReplString = gInscriptionEscReplacementStrings[code]; + } + } else { + escReplString = gEscReplacementCharacters[code]; + } + strcat(destString, escReplString); + destString += strlen(escReplString); + escChar = 0; + } else if (code < 28) { + if (type != kTextTypeInscription) { + if (code == 26) { + code = ' '; + } else if (code == 27) { + code = '.'; + } else { + code += 'A'; + } + } + *destString++ = code; + } else if (code == 28) { + *destString++ = sepChar; + } else if (code <= 30) { + escChar = code; + } else { + break; + } + } + } + *destString = ((type == kTextTypeInscription) ? 0x81 : '\0'); } -- cgit v1.2.3 From ab1e17257ca737c89c3e1a5f51741b2665ab4cac Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Mon, 23 May 2016 23:31:09 +0200 Subject: DM: Add isDrawnWallOrnAnAlcove function --- engines/dm/dungeonman.cpp | 1 - engines/dm/dungeonman.h | 58 ++++++++-------- engines/dm/gfx.cpp | 174 +++++++++++++++++++++++++++++++++++++++++++++- engines/dm/gfx.h | 2 + 4 files changed, 202 insertions(+), 33 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 4d75d12582..0702ab2fbb 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -378,7 +378,6 @@ void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) { _currMapInscriptionWallOrnIndex = _currMap.map->wallOrnCount; _vm->_displayMan->_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = kWallOrnInscription; - } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 4a5ff1786a..cb53ba0440 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -120,35 +120,35 @@ enum SensorActionType { }; enum SensorType { - kSensorDisabled = 0, // @ C000_SENSOR_DISABLED /* Never triggered, may be used for a floor or wall ornament */ - kSensorFloorTheronPartyCreatureObj = 1, // @ C001_SENSOR_FLOOR_THERON_PARTY_CREATURE_OBJECT /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorFloorTheronPartyCreature = 2, // @ C002_SENSOR_FLOOR_THERON_PARTY_CREATURE /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorFloorParty = 3, // @ C003_SENSOR_FLOOR_PARTY /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorFloorObj = 4, // @ C004_SENSOR_FLOOR_OBJECT /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorFloorPartyOnStairs = 5, // @ C005_SENSOR_FLOOR_PARTY_ON_STAIRS /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorFloorGroupGenerator = 6, // @ C006_SENSOR_FLOOR_GROUP_GENERATOR /* Triggered by event F0245_TIMELINE_ProcessEvent5_Square_Corridor */ - kSensorFloorCreature = 7, // @ C007_SENSOR_FLOOR_CREATURE /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorFloorPartyPossession = 8, // @ C008_SENSOR_FLOOR_PARTY_POSSESSION /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorFloorVersionChecker = 9, // @ C009_SENSOR_FLOOR_VERSION_CHECKER /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorWallOrnClick = 1, // @ C001_SENSOR_WALL_ORNAMENT_CLICK /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallOrnClickWithAnyObj = 2, // @ C002_SENSOR_WALL_ORNAMENT_CLICK_WITH_ANY_OBJECT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallOrnClickWithSpecObj = 3, // @ C003_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallOrnClickWithSpecObjRemoved = 4, // @ C004_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallAndOrGate = 5, // @ C005_SENSOR_WALL_AND_OR_GATE /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallCountdown = 6, // @ C006_SENSOR_WALL_COUNTDOWN /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallSingleProjLauncherNewObj = 7, // @ C007_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_NEW_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallSingleProjLauncherExplosion = 8, // @ C008_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_EXPLOSION /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallDoubleProjLauncherNewObj = 9, // @ C009_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_NEW_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallDoubleProjLauncherExplosion = 10, // @ C010_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_EXPLOSION /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorDisabled = 0, // @ C000_SENSOR_DISABLED /* Never triggered, may be used for a floor or wall ornament */ + kSensorFloorTheronPartyCreatureObj = 1, // @ C001_SENSOR_FLOOR_THERON_PARTY_CREATURE_OBJECT /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorFloorTheronPartyCreature = 2, // @ C002_SENSOR_FLOOR_THERON_PARTY_CREATURE /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorFloorParty = 3, // @ C003_SENSOR_FLOOR_PARTY /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorFloorObj = 4, // @ C004_SENSOR_FLOOR_OBJECT /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorFloorPartyOnStairs = 5, // @ C005_SENSOR_FLOOR_PARTY_ON_STAIRS /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorFloorGroupGenerator = 6, // @ C006_SENSOR_FLOOR_GROUP_GENERATOR /* Triggered by event F0245_TIMELINE_ProcessEvent5_Square_Corridor */ + kSensorFloorCreature = 7, // @ C007_SENSOR_FLOOR_CREATURE /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorFloorPartyPossession = 8, // @ C008_SENSOR_FLOOR_PARTY_POSSESSION /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorFloorVersionChecker = 9, // @ C009_SENSOR_FLOOR_VERSION_CHECKER /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + kSensorWallOrnClick = 1, // @ C001_SENSOR_WALL_ORNAMENT_CLICK /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallOrnClickWithAnyObj = 2, // @ C002_SENSOR_WALL_ORNAMENT_CLICK_WITH_ANY_OBJECT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallOrnClickWithSpecObj = 3, // @ C003_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallOrnClickWithSpecObjRemoved = 4, // @ C004_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallAndOrGate = 5, // @ C005_SENSOR_WALL_AND_OR_GATE /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallCountdown = 6, // @ C006_SENSOR_WALL_COUNTDOWN /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallSingleProjLauncherNewObj = 7, // @ C007_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_NEW_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallSingleProjLauncherExplosion = 8, // @ C008_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_EXPLOSION /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallDoubleProjLauncherNewObj = 9, // @ C009_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_NEW_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallDoubleProjLauncherExplosion = 10, // @ C010_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_EXPLOSION /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ kSensorWallOrnClickWithSpecObjRemovedRotateSensors = 11, // @ C011_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_ROTATE_SENSORS /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallObjGeneratorRotateSensors = 12, // @ C012_SENSOR_WALL_OBJECT_GENERATOR_ROTATE_SENSORS /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallSingleObjStorageRotateSensors = 13, // @ C013_SENSOR_WALL_SINGLE_OBJECT_STORAGE_ROTATE_SENSORS /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallSingleProjLauncherSquareObj = 14, // @ C014_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallDoubleProjLauncherSquareObj = 15, // @ C015_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallObjExchanger = 16, // @ C016_SENSOR_WALL_OBJECT_EXCHANGER /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallObjGeneratorRotateSensors = 12, // @ C012_SENSOR_WALL_OBJECT_GENERATOR_ROTATE_SENSORS /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallSingleObjStorageRotateSensors = 13, // @ C013_SENSOR_WALL_SINGLE_OBJECT_STORAGE_ROTATE_SENSORS /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallSingleProjLauncherSquareObj = 14, // @ C014_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallDoubleProjLauncherSquareObj = 15, // @ C015_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallObjExchanger = 16, // @ C016_SENSOR_WALL_OBJECT_EXCHANGER /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ kSensorWallOrnClickWithSpecObjRemovedSensor = 17, // @ C017_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_REMOVE_SENSOR /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallEndGame = 18, // @ C018_SENSOR_WALL_END_GAME /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallChampionPortrait = 127 // @ C127_SENSOR_WALL_CHAMPION_PORTRAIT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + kSensorWallEndGame = 18, // @ C018_SENSOR_WALL_END_GAME /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + kSensorWallChampionPortrait = 127 // @ C127_SENSOR_WALL_CHAMPION_PORTRAIT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ }; class Sensor { @@ -426,7 +426,6 @@ class DungeonMan { void setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals - bool isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap @@ -439,6 +438,7 @@ public: void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC void setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap + bool isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove void mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement SquareType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { return Square(getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType(); @@ -458,7 +458,7 @@ public: Messages _messages; // @ NONE; int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex - byte _dungeonViewClickableBoxes[6][4]; // G0291_aauc_DungeonViewClickableBoxes + uint16 _dungeonViewClickableBoxes[6][4]; // G0291_aauc_DungeonViewClickableBoxes bool _isFacingAlcove; // @ G0286_B_FacingAlcove bool _isFacingViAltar; // @ G0287_B_FacingViAltar bool _isFacingFountain; // @ G0288_B_FacingFountain diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 0840da6b02..cc9d971177 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -16,6 +16,7 @@ struct Frame { uint16 srcWidth, srcHeight; uint16 srcX, srcY; + Frame() {} Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) : destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1), @@ -23,6 +24,15 @@ struct Frame { }; +enum ViewCell { + kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT + kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT + kViewCellBackRight = 2, // @ C02_VIEW_CELL_BACK_RIGHT + kViewCellBackLeft = 3, // @ C03_VIEW_CELL_BACK_LEFT + kViewCellAlcove = 4, // @ C04_VIEW_CELL_ALCOVE + kViewCellDoorButtonOrWallOrn = 5 // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT +}; + enum StairFrameIndex { kFrameStairsUpFront_D3L = 0, // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L kFrameStairsUpFront_D3C = 1, // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C @@ -200,7 +210,7 @@ byte gFloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnamentCoor 2, /* Floor Ornament 07 Tiny Pressure Pad */ 0}; /* Floor Ornament 08 Puddle */ -byte gWallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets +uint16 gWallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets /* { X1, X2, Y1, Y2, PixelWidth, Height } */ {{80, 83, 41, 45, 8 * 2, 5}, /* D3L */ {140, 143, 41, 45, 8 * 2, 5}, /* D3R */ @@ -603,7 +613,9 @@ byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, enum GraphicIndice { - kDoorMaskDestroyedIndice = 301 // @ C301_GRAPHIC_DOOR_MASK_DESTROYED + kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT + kDoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED + kChampionPortraitsIndice = 26 // @ C026_GRAPHIC_CHAMPION_PORTRAITS }; @@ -868,6 +880,10 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3L]); + isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], kViewWall_D3L_RIGHT); + if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3L_FRONT)) { + // ... missing code + } break; } } @@ -884,6 +900,10 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3R]); + isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], kViewWall_D3R_LEFT); + if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3R_FRONT)) { + // ... missing code + } break; } } @@ -899,6 +919,9 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) { break; case kWallElemType: drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3C]); + if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3C_FRONT)) { + //... missing code + } break; } } @@ -914,6 +937,10 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) { break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2L]); + isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], kViewWall_D2L_RIGHT); + if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D2L_FRONT)) { + // ... missing code + } break; case kStairsSideElemType: drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D2L, gFrameWalls[kFrameStairsSide_D2L]); @@ -932,6 +959,10 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) { break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2R]); + isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], kViewWall_D2R_LEFT); + if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D2R_FRONT)) { + // ... missing code + } break; case kStairsSideElemType: drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]); @@ -950,6 +981,9 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) { break; case kWallElemType: drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2C]); + if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D2C_FRONT)) { + // ... missing code + } break; } } @@ -965,6 +999,7 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) { break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1L]); + isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], kViewWall_D1L_RIGHT); break; case kStairsSideElemType: if (squareAspect[kStairsUpAspect]) @@ -986,6 +1021,7 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) { break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1R]); + isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], kViewWall_D1R_LEFT); break; case kStairsSideElemType: if (squareAspect[kStairsUpAspect]) @@ -1010,6 +1046,9 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) { _vm->_dungeonMan->_isFacingViAltar = false; _vm->_dungeonMan->_isFacingFountain = false; drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1C]); + if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D1C_FRONT)) { + // .... code not yet implemneted + } break; } } @@ -1332,5 +1371,134 @@ byte gUnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableIns Box gBoxChampionPortraitOnWall = {96, 127, 35, 63}; // G0109_s_Graphic558_Box_ChampionPortraitOnWall bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) { - return false; // dummy + byte *bitmapGreen; + byte *bitmapRed; + int16 coordinateSetOffset; + bool flipHorizontal; + bool isInscription; + bool isAlcove; + Frame frame; + unsigned char inscriptionString[70]; + + + if (wallOrnOrd) { + int16 var_X; + int16 wallOrnIndex = wallOrnOrd - 1; + int16 nativeBitmapIndex = _currMapWallOrnInfo[wallOrnIndex][kNativeBitmapIndex]; + + uint16 *coordinateSetA = gWallOrnCoordSets[_currMapWallOrnInfo[wallOrnIndex][kNativeCoordinateSet]][viewWallIndex]; + isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnIndex); + if (isInscription = (wallOrnIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex)) { + _vm->_dungeonMan->decodeText((char*)inscriptionString, _inscriptionThing, kTextTypeInscription); + } + + if (viewWallIndex >= kViewWall_D1L_RIGHT) { + if (viewWallIndex == kViewWall_D1C_FRONT) { + if (isInscription) { + Frame &D1CFrame = gFrameWalls[kViewSquare_D1C]; + blitToScreen(_wallSetBitMaps[kWall_D1LCR], D1CFrame.srcWidth, 94, 28, gBoxWallPatchBehindInscription.X1, gBoxWallPatchBehindInscription.X2, + gBoxWallPatchBehindInscription.Y1, gBoxWallPatchBehindInscription.Y2, kColorNoTransparency, gDungeonViewport); + + unsigned char *string = inscriptionString; + bitmapRed = _bitmaps[kInscriptionFontIndice]; + int16 textLineIndex = 0; + do { + int16 characterCount = 0; + unsigned char *character = string; + while (*character++ < 0x80) { + characterCount++; + } + frame.destToX = (frame.destFromX = 112 - (characterCount * 4)) + 7; + frame.destFromY = (frame.destToY = gInscriptionLineY[textLineIndex++]) - 7; + while (characterCount--) { + blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame.destFromX, frame.destToX, frame.destFromY, frame.destToY, kColorFlesh, gDungeonViewport); + frame.destFromX += 8; + frame.destToX += 8; + } + } while (*string++ != 0x81); + return isAlcove; + } + nativeBitmapIndex++; + for (uint16 i = 0; i < 4; ++i) + _vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn][i] = coordinateSetA[i]; + _vm->_dungeonMan->_isFacingAlcove = isAlcove; + _vm->_dungeonMan->_isFacingViAltar = (wallOrnIndex == _currMapViAltarIndex); + _vm->_dungeonMan->_isFacingFountain = false; + for (int16 fountainOrnIndex = 0; fountainOrnIndex < kFountainOrnCount; ++fountainOrnIndex) { + if (_currMapFountainOrnIndices[fountainOrnIndex] == wallOrnIndex) { + _vm->_dungeonMan->_isFacingFountain = true; + break; + } + } + } + bitmapGreen = _bitmaps[nativeBitmapIndex]; + if (viewWallIndex == kViewWall_D1R_LEFT) { + blitToBitmap(bitmapGreen, coordinateSetA[4], coordinateSetA[5], _tmpBitmap, coordinateSetA[4]); + bitmapGreen = _tmpBitmap; + } + var_X = 0; + } else { + coordinateSetOffset = 0; + uint16 *coordSetB; + int16 wallOrnCoordSetIndex = _currMapWallOrnInfo[wallOrnIndex][kNativeCoordinateSet]; + if (flipHorizontal = (viewWallIndex == kViewWall_D2R_LEFT) || (viewWallIndex == kViewWall_D3R_LEFT)) { + coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1R_LEFT]; + } else if ((viewWallIndex == kViewWall_D2L_RIGHT) || (viewWallIndex == kViewWall_D3L_RIGHT)) { + coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1L_RIGHT]; + } else { + nativeBitmapIndex++; + coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1C_FRONT]; + if (viewWallIndex == kViewWall_D2L_FRONT) { + coordinateSetOffset = 6; + } else if (viewWallIndex == kViewWall_D2R_FRONT) { + coordinateSetOffset = -6; + } + } + int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0]; + // TODO: I skipped some bitmap shrinking code here + bitmapGreen = _bitmaps[nativeBitmapIndex]; + var_X = pixelWidth; + if (flipHorizontal) { + blitToBitmap(bitmapGreen, coordSetB[4], coordSetB[5], _tmpBitmap, coordSetB[4]); + bitmapGreen = _tmpBitmap; + var_X = 15 - (var_X & 0xF); + } else if (viewWallIndex == kViewWall_D2L_FRONT) { + var_X -= coordinateSetA[1] - coordinateSetA[0]; + } else { + var_X = 0; + } + } + if (isInscription) { + unsigned char *string = inscriptionString; + int16 unreadableTextLineCount = 0; + do { + while (*string < 0x80) { + string++; + } + unreadableTextLineCount++; + } while (*string++ != 0x81); + + if (unreadableTextLineCount < 4) { + frame.destFromX = coordinateSetA[0]; + frame.destToX = coordinateSetA[1]; + frame.destFromY = coordinateSetA[2]; + frame.destToY = coordinateSetA[3]; + frame.srcWidth = coordinateSetA[4]; + frame.srcHeight = coordinateSetA[5]; + + coordinateSetA = &frame.destFromX; + + coordinateSetA[3] = gUnreadableInscriptionBoxY2[gWallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1]; + } + } + blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, coordinateSetA[0], coordinateSetA[1], coordinateSetA[2], coordinateSetA[3], kColorFlesh, gDungeonViewport); + + if ((viewWallIndex == kViewWall_D1C_FRONT) && _championPortraitOrdinal--) { + Box &box = gBoxChampionPortraitOnWall; + blitToScreen(_bitmaps[kChampionPortraitsIndice], 256, (_championPortraitOrdinal & 0x7) << 5, _championPortraitOrdinal, box.X1, box.X2, box.Y1, box.Y2, + kColorDarkGary, gDungeonViewport); + } + return isAlcove; + } + return false; } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index bbd9eb48f9..14cb6ebc94 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -12,6 +12,8 @@ extern uint16 gPalCredits[16]; extern uint16 gPalEntrance[16]; extern uint16 gPalDungeonView[6][16]; + + typedef struct { uint16 X1; uint16 X2; -- cgit v1.2.3 From b9935dfddc17ed71a6135896554d27d80c30b516 Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Wed, 25 May 2016 01:13:36 +0200 Subject: DM: Add blitToBitmapShrinkWithPalChange --- engines/dm/gfx.cpp | 27 ++++++++++++++++++++++++--- engines/dm/gfx.h | 3 +++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index cc9d971177..5a81151f64 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1052,6 +1052,7 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) { break; } } + void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); @@ -1434,6 +1435,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex bitmapGreen = _bitmaps[nativeBitmapIndex]; if (viewWallIndex == kViewWall_D1R_LEFT) { blitToBitmap(bitmapGreen, coordinateSetA[4], coordinateSetA[5], _tmpBitmap, coordinateSetA[4]); + flipBitmapHorizontal(_tmpBitmap, coordinateSetA[4], coordinateSetA[5]); bitmapGreen = _tmpBitmap; } var_X = 0; @@ -1455,11 +1457,14 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex } } int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0]; - // TODO: I skipped some bitmap shrinking code here + blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], coordSetB[4] << 1, coordSetB[5], _tmpBitmap, pixelWidth + 1, coordinateSetA[5], + (viewWallIndex <= kViewWall_D3R_FRONT) ? gPalChangesDoorButtonAndWallOrn_D3 : gPalChangesDoorButtonAndWallOrn_D2); bitmapGreen = _bitmaps[nativeBitmapIndex]; var_X = pixelWidth; if (flipHorizontal) { - blitToBitmap(bitmapGreen, coordSetB[4], coordSetB[5], _tmpBitmap, coordSetB[4]); + if(bitmapGreen != _tmpBitmap) + blitToBitmap(bitmapGreen, coordSetB[4], coordSetB[5], _tmpBitmap, coordSetB[4]); + flipBitmapHorizontal(_tmpBitmap, coordSetB[4], coordSetB[5]); bitmapGreen = _tmpBitmap; var_X = 15 - (var_X & 0xF); } else if (viewWallIndex == kViewWall_D2L_FRONT) { @@ -1495,10 +1500,26 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex if ((viewWallIndex == kViewWall_D1C_FRONT) && _championPortraitOrdinal--) { Box &box = gBoxChampionPortraitOnWall; - blitToScreen(_bitmaps[kChampionPortraitsIndice], 256, (_championPortraitOrdinal & 0x7) << 5, _championPortraitOrdinal, box.X1, box.X2, box.Y1, box.Y2, + blitToScreen(_bitmaps[kChampionPortraitsIndice], 256, (_championPortraitOrdinal & 0x7) << 5, (_championPortraitOrdinal >> 3) * 29, box.X1, box.X2, box.Y1, box.Y2, kColorDarkGary, gDungeonViewport); } return isAlcove; } return false; } + + +void DisplayMan::blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHeight, byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange) { + double rateW = srcWidth / destWidth; + double rateH = srcHeight / destHeight; + + for (uint16 y = 0; y < destHeight; ++y) { + for (uint16 x = 0; x < destWidth; ++x) { + if (palChange) + destBitmap[y * destWidth + x] = palChange[srcBitmap[(int)(y * rateH * srcWidth) + (int)(x * rateW)]]; + else + destBitmap[y * destWidth + x] = srcBitmap[(int)(y * rateH * srcWidth) + (int)(x * rateW)]; + } + } + +} diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 14cb6ebc94..d8f4e29247 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -206,6 +206,9 @@ public: byte *destBitmap, uint16 destWidth, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort); + void blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight, + byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges + void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0); void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, -- cgit v1.2.3 From 24c7c1e905991a846f6853020962bc3a942cfdfe Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 3 Jun 2016 23:47:04 +0200 Subject: DM: Fix some compilation errors under MSVC9 --- engines/dm/dungeonman.cpp | 57 ++++++++++++++++++++++++++++++++++++++++- engines/dm/dungeonman.h | 36 +++++++++++--------------- engines/dm/gfx.cpp | 57 +++++++++++++++++++++++++++++++++++++---- engines/dm/gfx.h | 64 +++++++++++++++++++---------------------------- 4 files changed, 149 insertions(+), 65 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 0702ab2fbb..bb803abf92 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -53,7 +53,62 @@ void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, in posY += dirIntoStepCountNorth[dir] * stepsRight; } -DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) {} +DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) { + _dunData.columCount = 0; + _dunData.eventMaximumCount = 0; + + _dunData.mapsFirstColumnIndex = nullptr; + _dunData.columnsCumulativeSquareThingCount = nullptr; + _dunData.squareFirstThings = nullptr; + _dunData.textData = nullptr; + _dunData.mapData = nullptr; + + for (int i = 0; i < 16; i++) + _dunData.thingsData[i] = nullptr; + + _currMap.partyDir = kDirNorth; + _currMap.partyPosX = 0; + _currMap.partyPosY = 0; + _currMap.currPartyMapIndex = 0; + _currMap.index = 0; + _currMap.width = 0; + _currMap.height = 0; + + _currMap.data = nullptr; + _currMap.map = nullptr; + _currMap.colCumulativeSquareFirstThingCount = nullptr; + + _messages.newGame = true; + _messages.restartGameRequest = false; + + _rawDunFileDataSize = 0; + _rawDunFileData = nullptr; + + _fileHeader.dungeonId = 0; + _fileHeader.ornamentRandomSeed = 0; + _fileHeader.rawMapDataSize = 0; + _fileHeader.mapCount = 0; + _fileHeader.textDataWordCount = 0; + _fileHeader.partyStartDir = kDirNorth; + _fileHeader.partyStartPosX = 0; + _fileHeader.partyStartPosY = 0; + _fileHeader.squareFirstThingCount = 0; + + for (int i = 0; i < 16; i++) + _fileHeader.thingCounts[i] = 0; + + _maps = nullptr; + _rawMapData = nullptr; + + _currMapInscriptionWallOrnIndex = 0; + _isFacingAlcove = false; + _isFacingViAltar = false; + _isFacingFountain = false; + + for (int i = 0; i < 4; i++) + for (int j = 0; j < 6; j++) + _dungeonViewClickableBoxes[j][i] = 0; +} DungeonMan::~DungeonMan() { delete[] _rawDunFileData; diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index cb53ba0440..7652596eb4 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -331,7 +331,6 @@ public: byte toByte() { return data; } // I don't like 'em casts }; - struct DungeonFileHeader { uint16 dungeonId; // @ G0526_ui_DungeonID // equal to dungeonId @@ -366,21 +365,19 @@ struct Map { uint8 doorSet0, doorSet1; }; // @ MAP - - struct DungeonData { // I have no idea the heck is this - uint16 *mapsFirstColumnIndex = NULL; // @ G0281_pui_DungeonMapsFirstColumnIndex + uint16 *mapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex uint16 columCount; // @ G0282_ui_DungeonColumnCount // I have no idea the heck is this - uint16 *columnsCumulativeSquareThingCount = NULL; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount - Thing *squareFirstThings = NULL; // @ G0283_pT_SquareFirstThings - uint16 *textData = NULL; // @ G0260_pui_DungeonTextData + uint16 *columnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount + Thing *squareFirstThings; // @ G0283_pT_SquareFirstThings + uint16 *textData; // @ G0260_pui_DungeonTextData - uint16 **thingsData[16] = {NULL}; // @ G0284_apuc_ThingData + uint16 **thingsData[16]; // @ G0284_apuc_ThingData - byte ***mapData = NULL; // @ G0279_pppuc_DungeonMapData + byte ***mapData; // @ G0279_pppuc_DungeonMapData // TODO: ??? is this doing here uint16 eventMaximumCount; // @ G0369_ui_EventMaximumCount @@ -393,21 +390,18 @@ struct CurrMapData { uint8 currPartyMapIndex; // @ G0309_i_PartyMapIndex uint8 index; // @ G0272_i_CurrentMapIndex - byte **data = NULL; // @ G0271_ppuc_CurrentMapData - Map *map = NULL; // @ G0269_ps_CurrentMap + byte **data; // @ G0271_ppuc_CurrentMapData + Map *map; // @ G0269_ps_CurrentMap uint16 width; // @ G0273_i_CurrentMapWidth uint16 height; // @ G0274_i_CurrentMapHeight - uint16 *colCumulativeSquareFirstThingCount = NULL; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount + uint16 *colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount }; // @ AGGREGATE struct Messages { - bool newGame = true; // @ G0298_B_NewGame - bool restartGameRequest = false; // @ G0523_B_RestartGameRequested + bool newGame; // @ G0298_B_NewGame + bool restartGameRequest; // @ G0523_B_RestartGameRequested }; // @ AGGREGATE - - - class DungeonMan { DMEngine *_vm; @@ -446,15 +440,15 @@ public: void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect void decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText - uint32 _rawDunFileDataSize = 0; // @ probably NONE - byte *_rawDunFileData = NULL; // @ ??? + uint32 _rawDunFileDataSize; // @ probably NONE + byte *_rawDunFileData; // @ ??? DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader DungeonData _dunData; // @ NONE CurrMapData _currMap; // @ NONE - Map *_maps = NULL; // @ G0277_ps_DungeonMaps + Map *_maps; // @ G0277_ps_DungeonMaps // does not have to be freed - byte *_rawMapData = NULL; // @ G0276_puc_DungeonRawMapData + byte *_rawMapData; // @ G0276_puc_DungeonRawMapData Messages _messages; // @ NONE; int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 5a81151f64..581e4fa343 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -633,15 +633,62 @@ int gFountainOrnIndices[kFountainOrnCount] = {35}; // @ G0193_ai_Graphic558_Foun byte gAlcoveOrnIndices[kAlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrnamentIndices 1, /* Square Alcove */ 2, /* Vi Altar */ - 3}; /* Arched Alcove */ - + 3}; /* Arched Alcove */ } using namespace DM; -DisplayMan::DisplayMan(DMEngine *dmEngine) : - _vm(dmEngine), _screenWidth(0), _screenHeight(0), - _vgaBuffer(NULL), _bitmaps(NULL) {} +DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { + _vgaBuffer = nullptr; + _bitmaps = nullptr; + _grapItemCount = 0; + _packedItemPos = nullptr; + _packedBitmaps = nullptr; + _bitmaps = nullptr; + _tmpBitmap = nullptr; + _floorBitmap = nullptr; + _ceilingBitmap = nullptr; + _currMapAllowedCreatureTypes = nullptr; + + _screenWidth = _screenHeight = 0; + _championPortraitOrdinal = 0; + _currMapViAltarIndex = 0; + + for (int i = 0; i < 25; i++) + _wallSetBitMaps[i] = nullptr; + + for (int i = 0; i < kStairsGraphicCount; i++) + _stairIndices[i] = 0; + + for (int i = 0; i < 4; i++) + _palChangesProjectile[i] = nullptr; + + for (int i = 0; i < kAlcoveOrnCount; i++) + _currMapAlcoveOrnIndices[i] = 0; + + for (int i = 0; i < kFountainOrnCount; i++) + _currMapFountainOrnIndices[i] = 0; + + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 16; j++) { + _currMapWallOrnInfo[j][i] = 0; + _currMapFloorOrnInfo[j][i] = 0; + } + for (int j = 0; j < 17; j++) { + _currMapDoorOrnInfo[j][i] = 0; + } + } + + for (int i = 0; i < 16; i++) { + _currMapWallOrnIndices[i] = 0; + _currMapFloorOrnIndices[i] = 0; + } + + for (int i = 0; i < 18; i++) + _currMapDoorOrnIndices[i] = 0; + + Thing _inscriptionThing = Thing::thingNone; +} DisplayMan::~DisplayMan() { delete[] _packedItemPos; diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index d8f4e29247..8ed7c565be 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -121,36 +121,26 @@ extern Viewport gDungeonViewport; #define kDoorOrnDestroyedMask 15 // @ C15_DOOR_ORNAMENT_DESTROYED_MASK #define kDoorOrnThivesEyeMask 16 // @ C16_DOOR_ORNAMENT_THIEVES_EYE_MASK - - - class DisplayMan { - DMEngine *_vm = NULL; + DMEngine *_vm; uint16 _screenWidth; - uint16 _screenHeight = 0; - byte *_vgaBuffer = NULL; - + uint16 _screenHeight; + byte *_vgaBuffer; /// Related to graphics.dat file - uint16 _grapItemCount = 0; // @ G0632_ui_GraphicCount - uint32 *_packedItemPos = NULL; - byte *_packedBitmaps = NULL; - byte **_bitmaps = NULL; - + uint16 _grapItemCount; // @ G0632_ui_GraphicCount + uint32 *_packedItemPos; + byte *_packedBitmaps; + byte **_bitmaps; // pointers 13,14 and [15-19] are owned by this array - byte *_wallSetBitMaps[25] = {NULL}; // @G[0696..0710]_puc_Bitmap_WallSet_... - - uint16 _stairIndices[kStairsGraphicCount] = {0}; - + byte *_wallSetBitMaps[25]; // @G[0696..0710]_puc_Bitmap_WallSet_... + uint16 _stairIndices[kStairsGraphicCount]; // pointers are not owned by these fields - byte *_floorBitmap = NULL; - byte *_ceilingBitmap = NULL; - - - byte *_palChangesProjectile[4] = {NULL}; // @G0075_apuc_PaletteChanges_Projectile - + byte *_floorBitmap; + byte *_ceilingBitmap; + byte *_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile DisplayMan(const DisplayMan &other); // no implementation on purpose void operator=(const DisplayMan &rhs); // no implementation on purpose @@ -185,16 +175,14 @@ class DisplayMan { bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF // some methods use this for a stratchpad, don't make assumptions about content between function calls - byte *_tmpBitmap = NULL; + byte *_tmpBitmap; public: DisplayMan(DMEngine *dmEngine); ~DisplayMan(); - void setUpScreens(uint16 width, uint16 height); + void setUpScreens(uint16 width, uint16 height); void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader, F0460_START_InitializeGraphicData - void loadCurrentMapGraphics(); - void loadPalette(uint16 *palette); /// Gives the width of an IMG0 type item @@ -222,20 +210,20 @@ public: void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); - int16 _championPortraitOrdinal = 0; // @ G0289_i_DungeonView_ChampionPortraitOrdinal - int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount] = {0}; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices - int16 _currMapFountainOrnIndices[kFountainOrnCount] = {0}; // @ G0268_ai_CurrentMapFountainOrnamentIndices - int16 _currMapWallOrnInfo[16][2] = {0}; // @ G0101_aai_CurrentMapWallOrnamentsInfo - int16 _currMapFloorOrnInfo[16][2] = {0}; // @ G0102_aai_CurrentMapFloorOrnamentsInfo - int16 _currMapDoorOrnInfo[17][2] = {0}; // @ G0103_aai_CurrentMapDoorOrnamentsInfo - byte *_currMapAllowedCreatureTypes = NULL; // @ G0264_puc_CurrentMapAllowedCreatureTypes - byte _currMapWallOrnIndices[16] = {0}; // @ G0261_auc_CurrentMapWallOrnamentIndices - byte _currMapFloorOrnIndices[16] = {0}; // @ G0262_auc_CurrentMapFloorOrnamentIndices - byte _currMapDoorOrnIndices[18] = {0}; // @ G0263_auc_CurrentMapDoorOrnamentIndices + int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal + int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices + int16 _currMapFountainOrnIndices[kFountainOrnCount]; // @ G0268_ai_CurrentMapFountainOrnamentIndices + int16 _currMapWallOrnInfo[16][2]; // @ G0101_aai_CurrentMapWallOrnamentsInfo + int16 _currMapFloorOrnInfo[16][2]; // @ G0102_aai_CurrentMapFloorOrnamentsInfo + int16 _currMapDoorOrnInfo[17][2]; // @ G0103_aai_CurrentMapDoorOrnamentsInfo + byte *_currMapAllowedCreatureTypes; // @ G0264_puc_CurrentMapAllowedCreatureTypes + byte _currMapWallOrnIndices[16]; // @ G0261_auc_CurrentMapWallOrnamentIndices + byte _currMapFloorOrnIndices[16]; // @ G0262_auc_CurrentMapFloorOrnamentIndices + byte _currMapDoorOrnIndices[18]; // @ G0263_auc_CurrentMapDoorOrnamentIndices - int16 _currMapViAltarIndex = 0; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex + int16 _currMapViAltarIndex; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex - Thing _inscriptionThing = Thing::thingNone; // @ G0290_T_DungeonView_InscriptionThing + Thing _inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing }; } -- cgit v1.2.3 From 35677f1c82d0e47463ddb537ed894d582bf823aa Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 4 Jun 2016 10:03:26 +0200 Subject: DM: Fix Frame initializations --- engines/dm/gfx.cpp | 93 +++++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 581e4fa343..d559fb90b6 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -66,37 +66,38 @@ enum StairFrameIndex { kFrameStairsSide_D0R = 29 // @ G0139_s_Graphic558_Frame_StairsSide_D0R }; -Frame gStairFrames[] = {{0, 79, 25, 70, 40, 46, 0, 0}, -{64, 159, 25, 70, 48, 46, 0, 0}, -{149, 223, 25, 70, 40, 46, 5, 0}, -{0, 63, 22, 83, 32, 62, 0, 0}, -{64, 159, 22, 83, 48, 62, 0, 0}, -{160, 223, 22, 83, 32, 62, 0, 0}, -{0, 31, 9, 108, 16, 100, 0, 0}, -{32, 191, 9, 108, 80, 100, 0, 0}, -{192, 223, 9, 108, 16, 100, 0, 0}, -{0, 31, 58, 101, 16, 44, 0, 0}, -{192, 223, 58, 101, 16, 44, 0, 0}, -{0, 79, 28, 68, 40, 41, 0, 0}, -{64, 159, 28, 70, 48, 43, 0, 0}, -{149, 223, 28, 68, 40, 41, 5, 0}, -{0, 63, 24, 85, 32, 62, 0, 0}, -{64, 159, 24, 85, 48, 62, 0, 0}, -{160, 223, 24, 85, 32, 62, 0, 0}, -{0, 31, 18, 108, 16, 91, 0, 0}, -{32, 191, 18, 108, 80, 91, 0, 0}, -{192, 223, 18, 108, 16, 91, 0, 0}, -{0, 31, 76, 135, 16, 60, 0, 0}, -{192, 223, 76, 135, 16, 60, 0, 0}, -{60, 75, 57, 61, 8, 5, 0, 0}, -{148, 163, 57, 61, 8, 5, 0, 0}, -{32, 63, 57, 99, 16, 43, 0, 0}, -{160, 191, 57, 99, 16, 43, 0, 0}, -{32, 63, 60, 98, 16, 39, 0, 0}, -{160, 191, 60, 98, 16, 39, 0, 0}, -{0, 15, 73, 85, 8, 13, 0, 0}, -{208, 223, 73, 85, 8, 13, 0, 0}}; - +Frame gStairFrames[] = { + Frame(0, 79, 25, 70, 40, 46, 0, 0), + Frame(64, 159, 25, 70, 48, 46, 0, 0), + Frame(149, 223, 25, 70, 40, 46, 5, 0), + Frame(0, 63, 22, 83, 32, 62, 0, 0), + Frame(64, 159, 22, 83, 48, 62, 0, 0), + Frame(160, 223, 22, 83, 32, 62, 0, 0), + Frame(0, 31, 9, 108, 16, 100, 0, 0), + Frame(32, 191, 9, 108, 80, 100, 0, 0), + Frame(192, 223, 9, 108, 16, 100, 0, 0), + Frame(0, 31, 58, 101, 16, 44, 0, 0), + Frame(192, 223, 58, 101, 16, 44, 0, 0), + Frame(0, 79, 28, 68, 40, 41, 0, 0), + Frame(64, 159, 28, 70, 48, 43, 0, 0), + Frame(149, 223, 28, 68, 40, 41, 5, 0), + Frame(0, 63, 24, 85, 32, 62, 0, 0), + Frame(64, 159, 24, 85, 48, 62, 0, 0), + Frame(160, 223, 24, 85, 32, 62, 0, 0), + Frame(0, 31, 18, 108, 16, 91, 0, 0), + Frame(32, 191, 18, 108, 80, 91, 0, 0), + Frame(192, 223, 18, 108, 16, 91, 0, 0), + Frame(0, 31, 76, 135, 16, 60, 0, 0), + Frame(192, 223, 76, 135, 16, 60, 0, 0), + Frame(60, 75, 57, 61, 8, 5, 0, 0), + Frame(148, 163, 57, 61, 8, 5, 0, 0), + Frame(32, 63, 57, 99, 16, 43, 0, 0), + Frame(160, 191, 57, 99, 16, 43, 0, 0), + Frame(32, 63, 60, 98, 16, 39, 0, 0), + Frame(160, 191, 60, 98, 16, 39, 0, 0), + Frame(0, 15, 73, 85, 8, 13, 0, 0), + Frame(208, 223, 73, 85, 8, 13, 0, 0) +}; #define kFirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT #define kFirstFloorSet 75 // @ C075_GRAPHIC_FIRST_FLOOR_SET @@ -135,23 +136,23 @@ enum ViewSquare { Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor -Frame gFrameWall_D3L2 = {0, 15, 25, 73, 8, 49, 0, 0}; // @ G0711_s_Graphic558_Frame_Wall_D3L2 -Frame gFrameWall_D3R2 = {208, 223, 25, 73, 8, 49, 0, 0}; // @ G0712_s_Graphic558_Frame_Wall_D3R2 +Frame gFrameWall_D3L2 = Frame(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2 +Frame gFrameWall_D3R2 = Frame(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2 Frame gFrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls /* { X1, X2, Y1, Y2, pixelWidth, Height, X, Y } */ - {74, 149, 25, 75, 64, 51, 18, 0}, /* D3C */ - {0, 83, 25, 75, 64, 51, 32, 0}, /* D3L */ - {139, 223, 25, 75, 64, 51, 0, 0}, /* D3R */ - {60, 163, 20, 90, 72, 71, 16, 0}, /* D2C */ - {0, 74, 20, 90, 72, 71, 61, 0}, /* D2L */ - {149, 223, 20, 90, 72, 71, 0, 0}, /* D2R */ - {32, 191, 9, 119, 128, 111, 48, 0}, /* D1C */ - {0, 63, 9, 119, 128, 111, 192, 0}, /* D1L */ - {160, 223, 9, 119, 128, 111, 0, 0}, /* D1R */ - {0, 223, 0, 135, 0, 0, 0, 0}, /* D0C */ - {0, 31, 0, 135, 16, 136, 0, 0}, /* D0L */ - {192, 223, 0, 135, 16, 136, 0, 0}}; /* D0R */ - + Frame(74, 149, 25, 75, 64, 51, 18, 0), /* D3C */ + Frame(0, 83, 25, 75, 64, 51, 32, 0), /* D3L */ + Frame(139, 223, 25, 75, 64, 51, 0, 0), /* D3R */ + Frame(60, 163, 20, 90, 72, 71, 16, 0), /* D2C */ + Frame(0, 74, 20, 90, 72, 71, 61, 0), /* D2L */ + Frame(149, 223, 20, 90, 72, 71, 0, 0), /* D2R */ + Frame(32, 191, 9, 119, 128, 111, 48, 0), /* D1C */ + Frame(0, 63, 9, 119, 128, 111, 192, 0), /* D1L */ + Frame(160, 223, 9, 119, 128, 111, 0, 0), /* D1R */ + Frame(0, 223, 0, 135, 0, 0, 0, 0), /* D0C */ + Frame(0, 31, 0, 135, 16, 136, 0, 0), /* D0L */ + Frame(192, 223, 0, 135, 16, 136, 0, 0) +}; /* D0R */ enum WallSetIndices { kDoorFrameFront = 0, // @ G0709_puc_Bitmap_WallSet_DoorFrameFront -- cgit v1.2.3 From 442d41714023d2d128d92f15a284c5c0aa341ee4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 4 Jun 2016 10:11:25 +0200 Subject: DM: Fix some warnings --- engines/dm/dungeonman.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index bb803abf92..c37467eb88 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -495,10 +495,6 @@ Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) { // TODO: get rid of the GOTOs void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) { // complete, except where marked - bool leftOrnAllowed, rightOrnAllowed, frontOrnAllowed; - bool squareIsFakeWall; - bool footPrintsAllowed; - _vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75, possible fix memset(aspectArray, 0, 5 * sizeof(uint16)); @@ -506,6 +502,12 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, Square square = getSquare(mapX, mapY); aspectArray[kElemAspect] = square.getType(); + + bool leftOrnAllowed = false; + bool rightOrnAllowed = false; + bool frontOrnAllowed = false; + bool squareIsFakeWall = false; + bool footPrintsAllowed = false; switch (square.getType()) { case kWallElemType: switch (dir) { @@ -531,7 +533,6 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, break; } - squareIsFakeWall = false; T0172010_ClosedFakeWall: setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall); @@ -775,8 +776,8 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { uint16 codeCounter = 0; int16 escChar = 0; uint16 *codeWord = _dunData.textData + textString.getWordOffset(); - uint16 code, codes; - char *escReplString = NULL; + uint16 code = 0, codes = 0; + char *escReplString = nullptr; for (;;) { /*infinite loop*/ if (!codeCounter) { codes = *codeWord++; -- cgit v1.2.3 From bdc57056cde5ae86d481147b3591c2ba5cd87090 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 4 Jun 2016 10:44:37 +0200 Subject: DM: Move some structs to header in gfx --- engines/dm/gfx.cpp | 74 +++--------------------------------------------------- engines/dm/gfx.h | 69 ++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 65 insertions(+), 78 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index d559fb90b6..1c820a9467 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -10,20 +10,6 @@ namespace DM { -// The frames in the orignal sources contain inclusive boundaries and byte widths, not pixel widths -struct Frame { - uint16 destFromX, destToX, destFromY, destToY; - uint16 srcWidth, srcHeight; - uint16 srcX, srcY; - - Frame() {} - Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) : - destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1), - srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {} -}; - - enum ViewCell { kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT @@ -380,25 +366,6 @@ byte gWallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoord 6, /* Wall Ornament 58 Amalgam (Without Gem) */ 7}; /* Wall Ornament 59 Lord Order (Outside) */ -struct CreatureAspect { - uint16 firstNativeBitmapRelativeIndex; - uint16 firstDerivedBitmapIndex; - byte byteWidthFront; - byte heightFront; - byte byteWidthSide; - byte heightSide; - byte byteWidthAttack; - byte heightAttack; - byte coordinateSet_TransparentColor; - byte replacementColorSetIndices; - - byte getCoordSet() { return (coordinateSet_TransparentColor >> 4) & 0xF; } // @ M71_COORDINATE_SET - byte getTranspColour() { return coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR - byte getReplColour10() { return (replacementColorSetIndices >> 4) & 0xF; } // @ M74_COLOR_10_REPLACEMENT_COLOR_SET - byte getReplColour9() { return replacementColorSetIndices & 0xF; } // @ M73_COLOR_09_REPLACEMENT_COLOR_SET -}; // @ CREATURE_ASPECT - - CreatureAspect gCreatureAspects[kCreatureTypeCount] = { // @ G0219_as_Graphic558_CreatureAspects /* { FirstNativeBitmapRelativeIndex, FirstDerivedBitmapIndex, pixelWidthFront, HeightFront, pixelWidthSide, HeightSide, pixelWidthAttack, HeightAttack, CoordinateSet / TransparentColor, @@ -431,18 +398,6 @@ Replacement Color Set Index for color 10 / Replacement Color Set Index for color {85, 0, 32 * 2, 93, 0 * 2, 0, 0 * 2, 0, 0x04, 0xCB}, /* Creature #25 Lord Order */ {86, 0, 32 * 2, 93, 0 * 2, 0, 0 * 2, 0, 0x04, 0xCB}}; /* Creature #26 Grey Lord */ -struct ObjectAspect { - byte firstNativeBitmapRelativeIndex; - byte firstDerivedBitmapRelativeIndex; - byte width; - byte height; - byte graphicInfo; /* Bits 7-5 and 3-1 Unreferenced */ - byte coordinateSet; - ObjectAspect(byte firstN, byte firstD, byte byteWidth, byte h, byte grap, byte coord) : - firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD), - width(byteWidth * 2), height(h), graphicInfo(grap), coordinateSet(coord) {} -}; // @ OBJECT_ASPECT - ObjectAspect gObjectAspects[kObjAspectCount] = { // @ G0209_as_Graphic558_ObjectAspects /* FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo, CoordinateSet */ ObjectAspect(0, 0, 24, 27, 0x11, 0), @@ -529,20 +484,8 @@ ObjectAspect gObjectAspects[kObjAspectCount] = { // @ G0209_as_Graphic558_Object ObjectAspect(82, 170, 24, 28, 0x00, 0), ObjectAspect(83, 172, 40, 13, 0x00, 1), ObjectAspect(84, 174, 8, 4, 0x00, 1), - ObjectAspect(85, 176, 32, 17, 0x00, 0)}; - -struct ProjectileAspect { - byte firstNativeBitmapRelativeIndex; - byte firstDerivedBitmapRelativeIndex; - byte width; - byte height; - uint16 graphicInfo; /* Bits 15-9, 7-5 and 3-2 Unreferenced */ - - ProjectileAspect(byte firstN, byte firstD, byte byteWidth, byte h, uint16 grap) : - firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD), - width(byteWidth * 2), height(h), graphicInfo(grap) {} -}; // @ PROJECTIL_ASPECT - + ObjectAspect(85, 176, 32, 17, 0x00, 0) +}; ProjectileAspect gProjectileAspect[kProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects /* ProjectileAspect( FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo ) */ @@ -562,7 +505,6 @@ ProjectileAspect gProjectileAspect[kProjectileAspectCount] = { // @ G0210_as_Gra ProjectileAspect(31, 156, 16, 24, 0x0103) /* Explosion Poison Bolt Poison Cloud */ }; - // TODO: this is ONLY for the Amiga version, name will have to be refactored /* Identical to the palette at the end of the swoosh palette animation */ @@ -584,14 +526,8 @@ uint16 gPalDungeonView[6][16] = { // @ G0021_aaui_Graphic562_Palette_DungeonView /* Atari ST: { 0x000, 0x000, 0x000, 0x000, 0x066, 0x100, 0x000, 0x020, 0x300, 0x310, 0x200, 0x530, 0x000, 0x111, 0x003, 0x333 }, RGB colors are different */ 0x000, 0x000, 0x000, 0x000, 0x0CC, 0x200, 0x000, 0x040, 0x600, 0x000, 0x000, 0xA60, 0x000, 0x222, 0x006, 0x666, /* Atari ST: { 0x000, 0x000, 0x000, 0x000, 0x066, 0x000, 0x000, 0x010, 0x200, 0x200, 0x100, 0x320, 0x000, 0x000, 0x002, 0x222 }, RGB colors are different */ - 0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444}; - - -struct CreatureReplColorSet { - uint16 RGBColor[6]; - byte D2ReplacementColor; - byte D3ReplacementColor; -}; // @ CREATURE_REPLACEMENT_COLOR_SET + 0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444 +}; CreatureReplColorSet gCreatureReplColorSets[13] = { // @ G0220_as_Graphic558_CreatureReplacementColorSets /* { Color, Color, Color, Color, Color, Color, D2 replacement color index (x10), D3 replacement color index (x10) } */ @@ -612,7 +548,6 @@ CreatureReplColorSet gCreatureReplColorSets[13] = { // @ G0220_as_Graphic558_Cre byte gPalChangesCreature_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3 byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, 120, 130, 140, 150}; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2 - enum GraphicIndice { kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT kDoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED @@ -620,7 +555,6 @@ enum GraphicIndice { }; - Viewport gDefultViewPort = {0, 0}; // TODO: I guessed the numbers Viewport gDungeonViewport = {0, 64}; // @ G0296_puc_Bitmap_Viewport diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 8ed7c565be..bbd2b190a6 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -12,8 +12,6 @@ extern uint16 gPalCredits[16]; extern uint16 gPalEntrance[16]; extern uint16 gPalDungeonView[6][16]; - - typedef struct { uint16 X1; uint16 X2; @@ -21,7 +19,19 @@ typedef struct { uint16 Y2; } Box; // @ BOX_BYTE, BOX_WORD -struct Frame; +// The frames in the original sources contain inclusive boundaries and byte widths, not pixel widths +struct Frame { + uint16 destFromX, destToX, destFromY, destToY; + uint16 srcWidth, srcHeight; + uint16 srcX, srcY; + + Frame() {} + Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, + uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) : + destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1), + srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {} +}; + enum WallSet { kWallSetStone = 0 // @ C0_WALL_SET_STONE }; @@ -67,8 +77,6 @@ enum ViewWall { kViewWall_D1C_FRONT = 12 // @ C12_VIEW_WALL_D1C_FRONT }; - - enum Color { kColorNoTransparency = 255, kColorBlack = 0, @@ -89,16 +97,62 @@ enum Color { kColorWhite = 15 }; - struct Viewport { // TODO: should probably add width and height, seems redundant right meow uint16 posX, posY; }; +struct CreatureAspect { + uint16 firstNativeBitmapRelativeIndex; + uint16 firstDerivedBitmapIndex; + byte byteWidthFront; + byte heightFront; + byte byteWidthSide; + byte heightSide; + byte byteWidthAttack; + byte heightAttack; + byte coordinateSet_TransparentColor; + byte replacementColorSetIndices; + + byte getCoordSet() { return (coordinateSet_TransparentColor >> 4) & 0xF; } // @ M71_COORDINATE_SET + byte getTranspColour() { return coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR + byte getReplColour10() { return (replacementColorSetIndices >> 4) & 0xF; } // @ M74_COLOR_10_REPLACEMENT_COLOR_SET + byte getReplColour9() { return replacementColorSetIndices & 0xF; } // @ M73_COLOR_09_REPLACEMENT_COLOR_SET +}; // @ CREATURE_ASPECT + +struct ObjectAspect { + byte firstNativeBitmapRelativeIndex; + byte firstDerivedBitmapRelativeIndex; + byte width; + byte height; + byte graphicInfo; /* Bits 7-5 and 3-1 Unreferenced */ + byte coordinateSet; + ObjectAspect(byte firstN, byte firstD, byte byteWidth, byte h, byte grap, byte coord) : + firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD), + width(byteWidth * 2), height(h), graphicInfo(grap), coordinateSet(coord) {} +}; // @ OBJECT_ASPECT + +struct ProjectileAspect { + byte firstNativeBitmapRelativeIndex; + byte firstDerivedBitmapRelativeIndex; + byte width; + byte height; + uint16 graphicInfo; /* Bits 15-9, 7-5 and 3-2 Unreferenced */ + + ProjectileAspect(byte firstN, byte firstD, byte byteWidth, byte h, uint16 grap) : + firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD), + width(byteWidth * 2), height(h), graphicInfo(grap) {} +}; // @ PROJECTIL_ASPECT + +struct CreatureReplColorSet { + uint16 RGBColor[6]; + byte D2ReplacementColor; + byte D3ReplacementColor; +}; // @ CREATURE_REPLACEMENT_COLOR_SET + extern Viewport gDefultViewPort; extern Viewport gDungeonViewport; - #define kAlcoveOrnCount 3 #define kFountainOrnCount 1 @@ -114,7 +168,6 @@ extern Viewport gDungeonViewport; #define kObjAspectCount 85 // @ C085_OBJECT_ASPECT_COUNT #define kProjectileAspectCount 14 // @ C014_PROJECTILE_ASPECT_COUNT - #define kDoorButton 0 // @ C0_DOOR_BUTTON #define kWallOrnInscription 0 // @ C0_WALL_ORNAMENT_INSCRIPTION #define kFloorOrnFootprints 15 // @ C15_FLOOR_ORNAMENT_FOOTPRINTS -- cgit v1.2.3 From 6ffca3a7dbf06227cadb791ca73ca99158f87ce0 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 14 Jun 2016 16:40:45 +0200 Subject: DM: Forgot to commit these lines earlier --- engines/dm/dungeonman.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index c37467eb88..056364905e 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -497,7 +497,9 @@ Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) { void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) { // complete, except where marked _vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75, possible fix - memset(aspectArray, 0, 5 * sizeof(uint16)); + for (uint16 i = 0; i < 5; ++i) + aspectArray[i] = 0; + Thing thing = getSquareFirstThing(mapX, mapY); Square square = getSquare(mapX, mapY); @@ -560,11 +562,13 @@ T0172010_ClosedFakeWall: } break; case kPitElemType: - if (square.get(kPitOpen)) + if (square.get(kPitOpen)) { aspectArray[kPitInvisibleAspect] = square.get(kPitInvisible); - else + footPrintsAllowed = square.toByte() & 1; + } else { aspectArray[kElemAspect] = kCorridorElemType; - footPrintsAllowed = true; + footPrintsAllowed = true; + } goto T0172030_Pit; case kFakeWallElemType: if (!square.get(kFakeWallOpen)) { @@ -575,6 +579,7 @@ T0172010_ClosedFakeWall: } aspectArray[kWallElemType] = kCorridorElemType; footPrintsAllowed = square.get(kFakeWallRandOrnOrFootPAllowed); + square = footPrintsAllowed ? 8 : 0; // intentional fallthrough case kCorridorElemType: aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap.map->randFloorOrnCount, mapX, mapY, 30); @@ -608,6 +613,7 @@ T0172046_Stairs: while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) thing = getNextThing(thing); T0172049_Footprints: + unsigned char scentOrdinal; // see next line comment if (footPrintsAllowed) // TODO: I skipped some party query code, must come back later and complete aspectArray[kFloorOrnOrdAspect] &= kFootprintsAspect; } -- cgit v1.2.3 From 3ca7622a6ca4563f7c906013d59f9213a55f4c1b Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 14 Jun 2016 16:49:04 +0200 Subject: DM: Fix wrong MemoryReadStream size when loading dungeon.dat --- engines/dm/dungeonman.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 056364905e..dd73e24a81 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -230,7 +230,7 @@ void DungeonMan::loadDungeonFile() { if (_messages.newGame) decompressDungeonFile(); - Common::MemoryReadStream dunDataStream(_rawDunFileData, _fileHeader.rawMapDataSize, DisposeAfterUse::NO); + Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO); // initialize _fileHeader _fileHeader.dungeonId = _fileHeader.ornamentRandomSeed = dunDataStream.readUint16BE(); -- cgit v1.2.3 From ad8fbaa118e26cb57d3d77ddb7a597c2b37a9f76 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 15 Jun 2016 10:41:33 +0200 Subject: DM: Add event manager --- engines/dm/dm.cpp | 38 ++++----------------------- engines/dm/dm.h | 2 ++ engines/dm/eventman.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/eventman.h | 28 ++++++++++++++++++++ engines/dm/module.mk | 3 ++- 5 files changed, 105 insertions(+), 34 deletions(-) create mode 100644 engines/dm/eventman.cpp create mode 100644 engines/dm/eventman.h diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 0aa4cb32b0..df6629c3f9 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -50,6 +50,7 @@ DMEngine::~DMEngine() { delete _console; delete _displayMan; delete _dungeonMan; + delete _eventMan; // clear debug channels DebugMan.clearAllDebugChannels(); @@ -61,6 +62,7 @@ Common::Error DMEngine::run() { _console = new Console(this); _displayMan = new DisplayMan(this); _dungeonMan = new DungeonMan(this); + _eventMan = new EventManager(this); _displayMan->setUpScreens(320, 200); @@ -77,40 +79,10 @@ Common::Error DMEngine::run() { _displayMan->loadPalette(gPalCredits); - CurrMapData &currMap = _dungeonMan->_currMap; + _eventMan->initMouse(); + while (true) { - Common::Event event; - while (_system->getEventManager()->pollEvent(event)) { - if (event.type == Common::EVENT_KEYDOWN && !event.synthetic) - switch (event.kbd.keycode) { - case Common::KEYCODE_w: - _dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY); - break; - case Common::KEYCODE_a: - _dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY); - break; - case Common::KEYCODE_s: - _dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY); - break; - case Common::KEYCODE_d: - _dungeonMan->mapCoordsAfterRelMovement(currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY); - break; - case Common::KEYCODE_q: - turnDirLeft(currMap.partyDir); - break; - case Common::KEYCODE_e: - turnDirRight(currMap.partyDir); - break; - case Common::KEYCODE_UP: - if (dummyMapIndex < 13) - _dungeonMan->setCurrentMapAndPartyMap(++dummyMapIndex); - break; - case Common::KEYCODE_DOWN: - if (dummyMapIndex > 0) - _dungeonMan->setCurrentMapAndPartyMap(--dummyMapIndex); - break; - } - } + _eventMan->processInput(); _displayMan->clearScreen(kColorBlack); _displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY); _displayMan->updateScreen(); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 817c3ece28..b77f2cce44 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -4,6 +4,7 @@ #include "common/random.h" #include "engines/engine.h" #include "gui/debugger.h" +#include "eventman.h" namespace DM { @@ -87,6 +88,7 @@ public: Common::RandomSource *_rnd; DisplayMan *_displayMan; DungeonMan *_dungeonMan; + EventManager *_eventMan; }; class Console : public GUI::Debugger { diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp new file mode 100644 index 0000000000..44ea32795f --- /dev/null +++ b/engines/dm/eventman.cpp @@ -0,0 +1,68 @@ +#include "eventman.h" +#include "dm.h" +#include "common/system.h" +#include "dungeonman.h" + + + +using namespace DM; + + +EventManager::EventManager(DMEngine *vm) : _vm(vm) {} + + +void EventManager::initMouse() { + _mousePos = Common::Point(0, 0); + _dummyMapIndex = 0; + // TODO: add cursor creatin, set to hidden +} + +void showMouse(bool visibility) { + // TODO: add code +} + +void EventManager::setMousePos(Common::Point pos) { + _vm->_system->warpMouse(pos.x, pos.y); +} + + +void EventManager::processInput() { + DungeonMan &dungeonMan = *_vm->_dungeonMan; + CurrMapData &currMap = dungeonMan._currMap; + + Common::Event event; + while (_vm->_system->getEventManager()->pollEvent(event)) { + if (event.type == Common::EVENT_KEYDOWN && !event.synthetic) { + switch (event.kbd.keycode) { + case Common::KEYCODE_w: + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY); + break; + case Common::KEYCODE_a: + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY); + break; + case Common::KEYCODE_s: + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY); + break; + case Common::KEYCODE_d: + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY); + break; + case Common::KEYCODE_q: + turnDirLeft(currMap.partyDir); + break; + case Common::KEYCODE_e: + turnDirRight(currMap.partyDir); + break; + case Common::KEYCODE_UP: + if (_dummyMapIndex < 13) + dungeonMan.setCurrentMapAndPartyMap(++_dummyMapIndex); + break; + case Common::KEYCODE_DOWN: + if (_dummyMapIndex > 0) + dungeonMan.setCurrentMapAndPartyMap(--_dummyMapIndex); + break; + } + } else if (event.type == Common::EVENT_MOUSEMOVE) { + _mousePos = event.mouse; + } + } +} diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h new file mode 100644 index 0000000000..eabff49a2b --- /dev/null +++ b/engines/dm/eventman.h @@ -0,0 +1,28 @@ + + +#ifndef DM_EVENTMAN_H +#define DM_EVENTMAN_H + +#include "common/events.h" + +namespace DM { + +class DMEngine; + +class EventManager { + DMEngine *_vm; + + Common::Point _mousePos; + uint16 _dummyMapIndex; +public: + EventManager(DMEngine *vm); + void initMouse(); + + void setMousePos(Common::Point pos); + void processInput(); +}; + +}; + + +#endif DM_EVENTMAN_H diff --git a/engines/dm/module.mk b/engines/dm/module.mk index ca425c5ffb..3078fa54ab 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -4,7 +4,8 @@ MODULE_OBJS := \ detection.o \ dm.o \ gfx.o \ - dungeonman.o + dungeonman.o \ + eventman.o MODULE_DIRS += \ engines/dm -- cgit v1.2.3 From de3bb231d703a5f19c21e643f19506a27ab53255 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 15 Jun 2016 18:22:32 +0200 Subject: DM: Add dummy cursor display --- engines/dm/dm.cpp | 1 + engines/dm/eventman.cpp | 37 +++++++++++++++++++++++++++++++++---- engines/dm/eventman.h | 3 ++- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index df6629c3f9..a86e7850b9 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -80,6 +80,7 @@ Common::Error DMEngine::run() { _displayMan->loadPalette(gPalCredits); _eventMan->initMouse(); + _eventMan->showMouse(true); while (true) { _eventMan->processInput(); diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 44ea32795f..96a6bf570a 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -2,23 +2,52 @@ #include "dm.h" #include "common/system.h" #include "dungeonman.h" +#include "graphics/cursorman.h" +#include "gfx.h" using namespace DM; -EventManager::EventManager(DMEngine *vm) : _vm(vm) {} +EventManager::EventManager(DMEngine *vm) : _vm(vm) { + _dummyMapIndex = 0; +} + + +// dummy data +static const byte mouseData[] = { + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 7, 1, 0, 0, 0, 0, 0, 0, 0, + 1, 7, 7, 1, 0, 0, 0, 0, 0, 0, + 1, 7, 7, 7, 1, 0, 0, 0, 0, 0, + 1, 7, 7, 7, 7, 1, 0, 0, 0, 0, + 1, 7, 7, 7, 7, 7, 1, 0, 0, 0, + 1, 7, 7, 7, 7, 7, 7, 1, 0, 0, + 1, 7, 7, 7, 7, 7, 7, 7, 1, 0, + 1, 7, 7, 7, 7, 7, 1, 1, 1, 1, + 1, 7, 7, 1, 7, 7, 1, 0, 0, 0, + 1, 7, 1, 0, 1, 7, 7, 1, 0, 0, + 1, 1, 0, 0, 1, 7, 7, 1, 0, 0, + 0, 0, 0, 0, 0, 1, 7, 7, 1, 0, + 0, 0, 0, 0, 0, 1, 7, 7, 1, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 +}; +#define MOUSE_WIDTH 10 +#define MOUSE_HEIGHT 15 void EventManager::initMouse() { _mousePos = Common::Point(0, 0); - _dummyMapIndex = 0; + CursorMan.pushCursor(mouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0); + CursorMan.showMouse(false); + + setMousePos(Common::Point(320/2, 200/2)); // TODO: add cursor creatin, set to hidden } -void showMouse(bool visibility) { - // TODO: add code +void EventManager::showMouse(bool visibility) { + CursorMan.showMouse(visibility); } void EventManager::setMousePos(Common::Point pos) { diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index eabff49a2b..ccce4c46b7 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -17,12 +17,13 @@ class EventManager { public: EventManager(DMEngine *vm); void initMouse(); + void showMouse(bool visibility); void setMousePos(Common::Point pos); void processInput(); }; -}; +} #endif DM_EVENTMAN_H -- cgit v1.2.3 From 251768b883737a729b25b003fd531f40ccf6fe91 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 15 Jun 2016 22:42:08 +0200 Subject: DM: Add commands --- engines/dm/dm.cpp | 5 +- engines/dm/dm.h | 2 +- engines/dm/dungeonman.cpp | 4 +- engines/dm/dungeonman.h | 6 +- engines/dm/eventman.cpp | 7 +-- engines/dm/eventman.h | 142 +++++++++++++++++++++++++++++++++++++++++++++- engines/dm/gfx.h | 9 ++- 7 files changed, 156 insertions(+), 19 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index a86e7850b9..002068a650 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -12,8 +12,9 @@ #include "common/events.h" #include "dm/dm.h" -#include "dm/gfx.h" -#include "dm/dungeonman.h" +#include "gfx.h" +#include "dungeonman.h" +#include "eventman.h" namespace DM { diff --git a/engines/dm/dm.h b/engines/dm/dm.h index b77f2cce44..c381587abf 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -4,7 +4,6 @@ #include "common/random.h" #include "engines/engine.h" #include "gui/debugger.h" -#include "eventman.h" namespace DM { @@ -12,6 +11,7 @@ namespace DM { class Console; class DisplayMan; class DungeonMan; +class EventManager; enum direction { diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index dd73e24a81..efff5ff16c 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1,8 +1,6 @@ -#include "dungeonman.h" -#include "gfx.h" #include "common/file.h" #include "common/memstream.h" - +#include "dungeonman.h" using namespace DM; diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 7652596eb4..93261560f6 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -2,12 +2,12 @@ #define DUNGEONMAN_H #include "dm.h" +#include "dungeonman.h" #include "gfx.h" + namespace DM { -class DungeonMan; -struct Map; int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL @@ -458,7 +458,7 @@ public: bool _isFacingFountain; // @ G0288_B_FacingFountain }; -} +}; #endif diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 96a6bf570a..860ea06453 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -1,9 +1,8 @@ -#include "eventman.h" -#include "dm.h" #include "common/system.h" -#include "dungeonman.h" #include "graphics/cursorman.h" -#include "gfx.h" + +#include "eventman.h" +#include "dungeonman.h" diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index ccce4c46b7..cf34636598 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -1,12 +1,148 @@ - - #ifndef DM_EVENTMAN_H #define DM_EVENTMAN_H #include "common/events.h" +#include "gfx.h" + namespace DM { +enum MouseButton { + kLeftMouseButton, + kRightMouseButton +}; + +enum CommandType { + kCommandNone = 0, // @ C000_COMMAND_NONE + kCommandTurnLeft = 1, // @ C001_COMMAND_TURN_LEFT + kCommandTurnRight = 2, // @ C002_COMMAND_TURN_RIGHT + kCommandMoveForward = 3, // @ C003_COMMAND_MOVE_FORWARD + kCommandMoveRight = 4, // @ C004_COMMAND_MOVE_RIGHT + kCommandMoveBackward = 5, // @ C005_COMMAND_MOVE_BACKWARD + kCommandMoveLeft = 6, // @ C006_COMMAND_MOVE_LEFT + kCommandToggleInventoryChampion_0 = 7, // @ C007_COMMAND_TOGGLE_INVENTORY_CHAMPION_0 + kCommandToggleInventoryChampion_1 = 8, // @ C008_COMMAND_TOGGLE_INVENTORY_CHAMPION_1 + kCommandToggleInventoryChampion_2 = 9, // @ C009_COMMAND_TOGGLE_INVENTORY_CHAMPION_2 + kCommandToggleInventoryChampion_3 = 10, // @ C010_COMMAND_TOGGLE_INVENTORY_CHAMPION_3 + kCommandCloseInventory = 11, // @ C011_COMMAND_CLOSE_INVENTORY + kCommandClickInChampion_0_StatusBox = 12, // @ C012_COMMAND_CLICK_IN_CHAMPION_0_STATUS_BOX + kCommandClickInChampion_1_StatusBox = 13, // @ C013_COMMAND_CLICK_IN_CHAMPION_1_STATUS_BOX + kCommandClickInChampion_2_StatusBox = 14, // @ C014_COMMAND_CLICK_IN_CHAMPION_2_STATUS_BOX + kCommandClickInChampion_3_StatusBox = 15, // @ C015_COMMAND_CLICK_IN_CHAMPION_3_STATUS_BOX + kCommandSetLeaderChampion_0 = 16, // @ C016_COMMAND_SET_LEADER_CHAMPION_0 + kCommandSetLeaderChampion_1 = 17, // @ C017_COMMAND_SET_LEADER_CHAMPION_1 + kCommandSetLeaderChampion_2 = 18, // @ C018_COMMAND_SET_LEADER_CHAMPION_2 + kCommandSetLeaderChampion_3 = 19, // @ C019_COMMAND_SET_LEADER_CHAMPION_3 + kCommandClickOnSlotBoxChampion_0_StatusBoxReadyHand = 20, // @ C020_COMMAND_CLICK_ON_SLOT_BOX_00_CHAMPION_0_STATUS_BOX_READY_HAND + kCommandClickOnSlotBoxChampion_0_StatusBoxActionHand = 21, // @ C021_COMMAND_CLICK_ON_SLOT_BOX_01_CHAMPION_0_STATUS_BOX_ACTION_HAND + kCommandClickOnSlotBoxChampion_1_StatusBoxReadyHand = 22, // @ C022_COMMAND_CLICK_ON_SLOT_BOX_02_CHAMPION_1_STATUS_BOX_READY_HAND + kCommandClickOnSlotBoxChampion_1_StatusBoxAactionHand = 23, // @ C023_COMMAND_CLICK_ON_SLOT_BOX_03_CHAMPION_1_STATUS_BOX_ACTION_HAND + kCommandClickOnSlotBoxChampion_2_StatusBoxReadyHand = 24, // @ C024_COMMAND_CLICK_ON_SLOT_BOX_04_CHAMPION_2_STATUS_BOX_READY_HAND + kCommandClickOnSlotBoxChampion_2_StatusBoxActionHand = 25, // @ C025_COMMAND_CLICK_ON_SLOT_BOX_05_CHAMPION_2_STATUS_BOX_ACTION_HAND + kCommandClickOnSlotBoxChampion_3_StatusBoxReadyHand = 26, // @ C026_COMMAND_CLICK_ON_SLOT_BOX_06_CHAMPION_3_STATUS_BOX_READY_HAND + kCommandClickOnSlotBoxChampion_3_StatusBoxActionHand = 27, // @ C027_COMMAND_CLICK_ON_SLOT_BOX_07_CHAMPION_3_STATUS_BOX_ACTION_HAND + kCommandClickOnSlotBoxInventoryReadyHand = 28, // @ C028_COMMAND_CLICK_ON_SLOT_BOX_08_INVENTORY_READY_HAND + kCommandClickOnSlotBoxInventoryActionHand = 29, // @ C029_COMMAND_CLICK_ON_SLOT_BOX_09_INVENTORY_ACTION_HAND + kCommandClickOnSlotBoxInventoryHead = 30, // @ C030_COMMAND_CLICK_ON_SLOT_BOX_10_INVENTORY_HEAD + kCommandClickOnSlotBoxInventoryTorso = 31, // @ C031_COMMAND_CLICK_ON_SLOT_BOX_11_INVENTORY_TORSO + kCommandClickOnSlotBoxInventoryLegs = 32, // @ C032_COMMAND_CLICK_ON_SLOT_BOX_12_INVENTORY_LEGS + kCommandClickOnSlotBoxInventoryFeet = 33, // @ C033_COMMAND_CLICK_ON_SLOT_BOX_13_INVENTORY_FEET + kCommandClickOnSlotBoxInventoryPouch_2 = 34, // @ C034_COMMAND_CLICK_ON_SLOT_BOX_14_INVENTORY_POUCH_2 + kCommandClickOnSlotBoxInventoryQuiverLine_2_1 = 35, // @ C035_COMMAND_CLICK_ON_SLOT_BOX_15_INVENTORY_QUIVER_LINE2_1 + kCommandClickOnSlotBoxInventoryQuiverLine_1_2 = 36, // @ C036_COMMAND_CLICK_ON_SLOT_BOX_16_INVENTORY_QUIVER_LINE1_2 + kCommandClickOnSlotBoxInventoryQuiverLine_2_2 = 37, // @ C037_COMMAND_CLICK_ON_SLOT_BOX_17_INVENTORY_QUIVER_LINE2_2 + kCommandClickOnSlotBoxInventoryNeck = 38, // @ C038_COMMAND_CLICK_ON_SLOT_BOX_18_INVENTORY_NECK + kCommandClickOnSlotBoxInventoryPouch_1 = 39, // @ C039_COMMAND_CLICK_ON_SLOT_BOX_19_INVENTORY_POUCH_1 + kCommandClickOnSlotBoxInventoryQuiverLine_1_1 = 40, // @ C040_COMMAND_CLICK_ON_SLOT_BOX_20_INVENTORY_QUIVER_LINE1_1 + kCommandClickOnSlotBoxInventoryBackpackLine_1_1 = 41, // @ C041_COMMAND_CLICK_ON_SLOT_BOX_21_INVENTORY_BACKPACK_LINE1_1 + kCommandClickOnSlotBoxInventoryBackpackLine_2_2 = 42, // @ C042_COMMAND_CLICK_ON_SLOT_BOX_22_INVENTORY_BACKPACK_LINE2_2 + kCommandClickOnSlotBoxInventoryBackpackLine_2_3 = 43, // @ C043_COMMAND_CLICK_ON_SLOT_BOX_23_INVENTORY_BACKPACK_LINE2_3 + kCommandClickOnSlotBoxInventoryBackpackLine_2_4 = 44, // @ C044_COMMAND_CLICK_ON_SLOT_BOX_24_INVENTORY_BACKPACK_LINE2_4 + kCommandClickOnSlotBoxInventoryBackpackLine_2_5 = 45, // @ C045_COMMAND_CLICK_ON_SLOT_BOX_25_INVENTORY_BACKPACK_LINE2_5 + kCommandClickOnSlotBoxInventoryBackpackLine_2_6 = 46, // @ C046_COMMAND_CLICK_ON_SLOT_BOX_26_INVENTORY_BACKPACK_LINE2_6 + kCommandClickOnSlotBoxInventoryBackpackLine_2_7 = 47, // @ C047_COMMAND_CLICK_ON_SLOT_BOX_27_INVENTORY_BACKPACK_LINE2_7 + kCommandClickOnSlotBoxInventoryBackpackLine_2_8 = 48, // @ C048_COMMAND_CLICK_ON_SLOT_BOX_28_INVENTORY_BACKPACK_LINE2_8 + kCommandClickOnSlotBoxInventoryBackpackLine_2_9 = 49, // @ C049_COMMAND_CLICK_ON_SLOT_BOX_29_INVENTORY_BACKPACK_LINE2_9 + kCommandClickOnSlotBoxInventoryBackpackLine_1_2 = 50, // @ C050_COMMAND_CLICK_ON_SLOT_BOX_30_INVENTORY_BACKPACK_LINE1_2 + kCommandClickOnSlotBoxInventoryBackpackLine_1_3 = 51, // @ C051_COMMAND_CLICK_ON_SLOT_BOX_31_INVENTORY_BACKPACK_LINE1_3 + kCommandClickOnSlotBoxInventoryBackpackLine_1_4 = 52, // @ C052_COMMAND_CLICK_ON_SLOT_BOX_32_INVENTORY_BACKPACK_LINE1_4 + kCommandClickOnSlotBoxInventoryBackpackLine_1_5 = 53, // @ C053_COMMAND_CLICK_ON_SLOT_BOX_33_INVENTORY_BACKPACK_LINE1_5 + kCommandClickOnSlotBoxInventoryBackpackLine_1_6 = 54, // @ C054_COMMAND_CLICK_ON_SLOT_BOX_34_INVENTORY_BACKPACK_LINE1_6 + kCommandClickOnSlotBoxInventoryBackpackLine_1_7 = 55, // @ C055_COMMAND_CLICK_ON_SLOT_BOX_35_INVENTORY_BACKPACK_LINE1_7 + kCommandClickOnSlotBoxInventoryBackpackLine_1_8 = 56, // @ C056_COMMAND_CLICK_ON_SLOT_BOX_36_INVENTORY_BACKPACK_LINE1_8 + kCommandClickOnSlotBoxInventoryBackpackLine_1_9 = 57, // @ C057_COMMAND_CLICK_ON_SLOT_BOX_37_INVENTORY_BACKPACK_LINE1_9 + kCommandClickOnSlotBoxChest_1 = 58, // @ C058_COMMAND_CLICK_ON_SLOT_BOX_38_CHEST_1 + kCommandClickOnSlotBoxChest_2 = 59, // @ C059_COMMAND_CLICK_ON_SLOT_BOX_39_CHEST_2 + kCommandClickOnSlotBoxChest_3 = 60, // @ C060_COMMAND_CLICK_ON_SLOT_BOX_40_CHEST_3 + kCommandClickOnSlotBoxChest_4 = 61, // @ C061_COMMAND_CLICK_ON_SLOT_BOX_41_CHEST_4 + kCommandClickOnSlotBoxChest_5 = 62, // @ C062_COMMAND_CLICK_ON_SLOT_BOX_42_CHEST_5 + kCommandClickOnSlotBoxChest_6 = 63, // @ C063_COMMAND_CLICK_ON_SLOT_BOX_43_CHEST_6 + kCommandClickOnSlotBoxChest_7 = 64, // @ C064_COMMAND_CLICK_ON_SLOT_BOX_44_CHEST_7 + kCommandClickOnSlotBoxChest_8 = 65, // @ C065_COMMAND_CLICK_ON_SLOT_BOX_45_CHEST_8 + kCommandClickOnMouth = 70, // @ C070_COMMAND_CLICK_ON_MOUTH + kCommandClickOnEye = 71, // @ C071_COMMAND_CLICK_ON_EYE + kCommandClickInDungeonView = 80, // @ C080_COMMAND_CLICK_IN_DUNGEON_VIEW + kCommandClickInPanel = 81, // @ C081_COMMAND_CLICK_IN_PANEL + kCommandToggleInventoryLeader = 83, // @ C083_COMMAND_TOGGLE_INVENTORY_LEADER + kCommandClickInSpellArea = 100, // @ C100_COMMAND_CLICK_IN_SPELL_AREA + kCommandClickInSpellAreaSymbol_1 = 101, // @ C101_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_1 + kCommandClickInSpellAreaSymbol_2 = 102, // @ C102_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_2 + kCommandClickInSpellAreaSymbol_3 = 103, // @ C103_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_3 + kCommandClickInSpellAreaSymbol_4 = 104, // @ C104_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_4 + kCommandClickInSpellAreaSymbol_5 = 105, // @ C105_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_5 + kCommandClickInSpellAreaSymbol_6 = 106, // @ C106_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_6 + kCommandClickInSpellAreaRecantSymbol = 107, // @ C107_COMMAND_CLICK_IN_SPELL_AREA_RECANT_SYMBOL + kCommandClickInSpeallAreaCastSpell = 108, // @ C108_COMMAND_CLICK_IN_SPELL_AREA_CAST_SPELL + kCommandClickInActionArea = 111, // @ C111_COMMAND_CLICK_IN_ACTION_AREA + kCommandClickInActionAreaPass = 112, // @ C112_COMMAND_CLICK_IN_ACTION_AREA_PASS + kCommandClickInActionAreaAction_0 = 113, // @ C113_COMMAND_CLICK_IN_ACTION_AREA_ACTION_0 + kCommandClickInActionAreaAction_1 = 114, // @ C114_COMMAND_CLICK_IN_ACTION_AREA_ACTION_1 + kCommandClickInActionAreaAction_2 = 115, // @ C115_COMMAND_CLICK_IN_ACTION_AREA_ACTION_2 + kCommandClickInActionAreaChampion_0_Action = 116, // @ C116_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_0_ACTION + kCommandClickInActionAreaChampion_1_Action = 117, // @ C117_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_1_ACTION + kCommandClickInActionAreaChampion_2_Action = 118, // @ C118_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_2_ACTION + kCommandClickInActionAreaChampion_3_Action = 119, // @ C119_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_3_ACTION + kCommandClickOnChamptionIcon_Top_Left = 125, // @ C125_COMMAND_CLICK_ON_CHAMPION_ICON_TOP_LEFT + kCommandClickOnChamptionIcon_Top_Right = 126, // @ C126_COMMAND_CLICK_ON_CHAMPION_ICON_TOP_RIGHT + kCommandClickOnChamptionIcon_Lower_Right = 127, // @ C127_COMMAND_CLICK_ON_CHAMPION_ICON_LOWER_RIGHT + kCommandClickOnChamptionIcon_Lower_Left = 128, // @ C128_COMMAND_CLICK_ON_CHAMPION_ICON_LOWER_LEFT + kCommandSaveGame = 140, // @ C140_COMMAND_SAVE_GAME + kCommandSleep = 145, // @ C145_COMMAND_SLEEP + kCommandWakeUp = 146, // @ C146_COMMAND_WAKE_UP + kCommandFreezeGame = 147, // @ C147_COMMAND_FREEZE_GAME + kCommandUnfreezeGame = 148, // @ C148_COMMAND_UNFREEZE_GAME + kCommandClickInPanelResurrect = 160, // @ C160_COMMAND_CLICK_IN_PANEL_RESURRECT + kCommandClickInPanelReincarnate = 161, // @ C161_COMMAND_CLICK_IN_PANEL_REINCARNATE + kCommandClickInPanelCancel = 162, // @ C162_COMMAND_CLICK_IN_PANEL_CANCEL + kCommandEntranceEnterDungeon = 200, // @ C200_COMMAND_ENTRANCE_ENTER_DUNGEON + kCommandEntranceResume = 201, // @ C201_COMMAND_ENTRANCE_RESUME /* Versions 1.x and 2.x command */ + kCommandEntranceDrawCredits = 202, // @ C202_COMMAND_ENTRANCE_DRAW_CREDITS /* Versions 1.x and 2.x command */ + kCommandClickOnDialogChoice_1 = 210, // @ C210_COMMAND_CLICK_ON_DIALOG_CHOICE_1 + kCommandClickOnDialogChoice_2 = 211, // @ C211_COMMAND_CLICK_ON_DIALOG_CHOICE_2 + kCommandClickOnDialogChoice_3 = 212, // @ C212_COMMAND_CLICK_ON_DIALOG_CHOICE_3 + kCommandClickOnDialogChoice_4 = 213, // @ C213_COMMAND_CLICK_ON_DIALOG_CHOICE_4 + kCommandRestartGame = 215 // @ C215_COMMAND_RESTART_GAME +}; // @ NONE + +class Command { +public: + int16 posX, posY; + CommandType type; + + Command(int16 x, int16 y, CommandType commandType): posX(x), posY(y), type(type) {} +}; // @ COMMAND + + +class MouseInput { +public: + CommandType commandTypeToIssue; + Box hitbox; + MouseButton button; + + MouseInput(CommandType type, uint16 x1, uint16 x2, uint16 y1, uint16 y2, MouseButton mouseButton) + : commandTypeToIssue(type), hitbox(x1, x2, y1, y2), button(mouseButton) {} +}; // @ MOUSE_INPUT + class DMEngine; class EventManager { @@ -26,4 +162,4 @@ public: } -#endif DM_EVENTMAN_H +#endif diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index bbd2b190a6..9790517507 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -2,7 +2,7 @@ #define GFX_H #include "common/scummsys.h" -#include "dm/dm.h" +#include "dm.h" namespace DM { @@ -12,12 +12,15 @@ extern uint16 gPalCredits[16]; extern uint16 gPalEntrance[16]; extern uint16 gPalDungeonView[6][16]; -typedef struct { +class Box { +public: uint16 X1; uint16 X2; uint16 Y1; uint16 Y2; -} Box; // @ BOX_BYTE, BOX_WORD + + Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): X1(x1), X2(x2), Y1(y1), Y2(y2) {} +}; // @ BOX_BYTE, BOX_WORD // The frames in the original sources contain inclusive boundaries and byte widths, not pixel widths struct Frame { -- cgit v1.2.3 From 28874dee1f555abbc31e4ea85bd92c3dd71d1c03 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 16 Jun 2016 15:16:45 +0200 Subject: DM: Add global static MouseInput arrays --- engines/dm/eventman.cpp | 201 ++++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/eventman.h | 31 +++++++- 2 files changed, 229 insertions(+), 3 deletions(-) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 860ea06453..8bf5a5bdc9 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -9,6 +9,207 @@ using namespace DM; +MouseInput DM::gPrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4] + /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ + MouseInput(kCommandEntranceEnterDungeon, 244, 298, 45, 58, kLeftMouseButton), + // Strangerke - C201_COMMAND_ENTRANCE_RESUME isn't present in the demo + MouseInput(kCommandEntranceResume, 244, 298, 76, 93, kLeftMouseButton), + MouseInput(kCommandEntranceDrawCredits, 248, 293, 187, 199, kLeftMouseButton), + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gPrimaryMouseInput_RestartGame[2] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2] + /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ + MouseInput(kCommandRestartGame, 103, 217, 145, 159, kLeftMouseButton), + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gPrimaryMouseInput_Interface[20] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20] + /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ + MouseInput(kCommandClickInChampion_0_StatusBox, 0, 42, 0, 28, kLeftMouseButton), + MouseInput(kCommandClickInChampion_1_StatusBox, 69, 111, 0, 28, kLeftMouseButton), + MouseInput(kCommandClickInChampion_2_StatusBox, 138, 180, 0, 28, kLeftMouseButton), + MouseInput(kCommandClickInChampion_3_StatusBox, 207, 249, 0, 28, kLeftMouseButton), + MouseInput(kCommandClickOnChamptionIcon_Top_Left, 274, 299, 0, 13, kLeftMouseButton), + MouseInput(kCommandClickOnChamptionIcon_Top_Right, 301, 319, 0, 13, kLeftMouseButton), + MouseInput(kCommandClickOnChamptionIcon_Lower_Right, 301, 319, 15, 28, kLeftMouseButton), + MouseInput(kCommandClickOnChamptionIcon_Lower_Left, 274, 299, 15, 28, kLeftMouseButton), + MouseInput(kCommandToggleInventoryChampion_0, 43, 66, 0, 28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 44. swapped with 4 next entries */ + MouseInput(kCommandToggleInventoryChampion_1, 112, 135, 0, 28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 113. swapped with 4 next entries */ + MouseInput(kCommandToggleInventoryChampion_2, 181, 204, 0, 28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 182. swapped with 4 next entries */ + MouseInput(kCommandToggleInventoryChampion_3, 250, 273, 0, 28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 251. swapped with 4 next entries */ + MouseInput(kCommandToggleInventoryChampion_0, 0, 66, 0, 28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */ + MouseInput(kCommandToggleInventoryChampion_1, 69, 135, 0, 28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */ + MouseInput(kCommandToggleInventoryChampion_2, 138, 204, 0, 28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */ + MouseInput(kCommandToggleInventoryChampion_3, 207, 273, 0, 28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */ + MouseInput(kCommandClickInSpellArea, 233, 319, 42, 73, kLeftMouseButton), + MouseInput(kCommandClickInActionArea, 233, 319, 77, 121, kLeftMouseButton), + MouseInput(kCommandFreezeGame, 0, 1, 198, 199, kLeftMouseButton), + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gSecondaryMouseInput_Movement[9] = { // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9] + /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ + MouseInput(kCommandTurnLeft, 234, 261, 125, 145, kLeftMouseButton), + MouseInput(kCommandMoveForward, 263, 289, 125, 145, kLeftMouseButton), + MouseInput(kCommandTurnRight, 291, 318, 125, 145, kLeftMouseButton), + MouseInput(kCommandMoveLeft, 234, 261, 147, 167, kLeftMouseButton), + MouseInput(kCommandMoveBackward, 263, 289, 147, 167, kLeftMouseButton), + MouseInput(kCommandMoveRight, 291, 318, 147, 167, kLeftMouseButton), + MouseInput(kCommandClickInDungeonView, 0, 223, 33, 168, kLeftMouseButton), + MouseInput(kCommandToggleInventoryLeader, 0, 319, 33, 199, kRightMouseButton), + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gSecondaryMouseInput_ChampionInventory[38] = { // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38] + /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ + MouseInput(kCommandCloseInventory, 0, 319, 0, 199, kRightMouseButton), + MouseInput(kCommandSaveGame, 174, 182, 36, 44, kLeftMouseButton), + MouseInput(kCommandSleep, 188, 204, 36, 44, kLeftMouseButton), + MouseInput(kCommandCloseInventory, 210, 218, 36, 44, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryReadyHand , 6, 21, 86, 101, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryActionHand, 62, 77, 86, 101, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryHead, 34, 49, 59, 74, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryTorso, 34, 49, 79, 94, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryLegs, 34, 49, 99, 114, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryFeet, 34, 49, 119, 134, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryPouch_2, 6, 21, 123, 138, kLeftMouseButton), + MouseInput(kCommandClickOnMouth, 56, 71, 46, 61, kLeftMouseButton), + MouseInput(kCommandClickOnEye, 12, 27, 46, 61, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_2_1, 79, 94, 106, 121, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_1_2, 62, 77, 123, 138, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_2_2, 79, 94, 123, 138, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryNeck, 6, 21, 66, 81, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryPouch_1, 6, 21, 106, 121, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_1_1, 62, 77, 106, 121, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_1, 66, 81, 66, 81, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_2, 83, 98, 49, 64, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_3, 100, 115, 49, 64, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_4, 117, 132, 49, 64, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_5, 134, 149, 49, 64, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_6, 151, 166, 49, 64, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_7, 168, 183, 49, 64, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_8, 185, 200, 49, 64, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_9, 202, 217, 49, 64, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_2, 83, 98, 66, 81, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_3, 100, 115, 66, 81, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_4, 117, 132, 66, 81, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_5, 134, 149, 66, 81, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_6, 151, 166, 66, 81, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_7, 168, 183, 66, 81, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_8, 185, 200, 66, 81, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_9, 202, 217, 66, 81, kLeftMouseButton), + MouseInput(kCommandClickInPanel, 96, 223, 83, 167, kLeftMouseButton), + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gPrimaryMouseInput_PartySleeping[3] = { // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3] + /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ + MouseInput(kCommandWakeUp, 0, 223, 33, 168, kLeftMouseButton), + MouseInput(kCommandWakeUp, 0, 223, 33, 168, kRightMouseButton), + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gPrimaryMouseInput_FrozenGame[3] = { // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3] + /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ + MouseInput(kCommandUnfreezeGame, 0, 319, 0, 199, kLeftMouseButton), + MouseInput(kCommandUnfreezeGame, 0, 319, 0, 199, kRightMouseButton), + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gMouseInput_ActionAreaNames[5] = { // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5] + /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ + MouseInput(kCommandClickInActionAreaPass, 285, 318, 77, 83, kLeftMouseButton), + MouseInput(kCommandClickInActionAreaAction_0, 234, 318, 86, 96, kLeftMouseButton), + MouseInput(kCommandClickInActionAreaAction_1, 234, 318, 98, 108, kLeftMouseButton), + MouseInput(kCommandClickInActionAreaAction_2, 234, 318, 110, 120, kLeftMouseButton), + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gMouseInput_ActionAreaIcons[5] = { // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5] + /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ + MouseInput(kCommandClickInActionAreaChampion_0_Action, 233, 252, 86, 120, kLeftMouseButton), + MouseInput(kCommandClickInActionAreaChampion_1_Action, 255, 274, 86, 120, kLeftMouseButton), + MouseInput(kCommandClickInActionAreaChampion_2_Action, 277, 296, 86, 120, kLeftMouseButton), + MouseInput(kCommandClickInActionAreaChampion_3_Action, 299, 318, 86, 120, kLeftMouseButton), + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gMouseInput_SpellArea[9] = { // @ G0454_as_Graphic561_MouseInput_SpellArea[9] + /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ + MouseInput(kCommandClickInSpellAreaSymbol_1, 235, 247, 51, 61, kLeftMouseButton), + MouseInput(kCommandClickInSpellAreaSymbol_2, 249, 261, 51, 61, kLeftMouseButton), + MouseInput(kCommandClickInSpellAreaSymbol_3, 263, 275, 51, 61, kLeftMouseButton), + MouseInput(kCommandClickInSpellAreaSymbol_4, 277, 289, 51, 61, kLeftMouseButton), + MouseInput(kCommandClickInSpellAreaSymbol_5, 291, 303, 51, 61, kLeftMouseButton), + MouseInput(kCommandClickInSpellAreaSymbol_6, 305, 317, 51, 61, kLeftMouseButton), + MouseInput(kCommandClickInSpeallAreaCastSpell, 234, 303, 63, 73, kLeftMouseButton), + MouseInput(kCommandClickInSpellAreaRecantSymbol, 305, 318, 63, 73, kLeftMouseButton), + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gMouseInput_ChampionNamesHands[13] = { // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13] + /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ + MouseInput(kCommandSetLeaderChampion_0, 0, 42, 0, 6, kLeftMouseButton), + MouseInput(kCommandSetLeaderChampion_1, 69, 111, 0, 6, kLeftMouseButton), + MouseInput(kCommandSetLeaderChampion_2, 138, 180, 0, 6, kLeftMouseButton), + MouseInput(kCommandSetLeaderChampion_3, 207, 249, 0, 6, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChampion_0_StatusBoxReadyHand, 4, 19, 10, 25, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChampion_0_StatusBoxActionHand, 24, 39, 10, 25, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChampion_1_StatusBoxReadyHand, 73, 88, 10, 25, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChampion_1_StatusBoxActionHand, 93, 108, 10, 25, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChampion_2_StatusBoxReadyHand, 142, 157, 10, 25, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChampion_2_StatusBoxActionHand, 162, 177, 10, 25, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChampion_3_StatusBoxReadyHand, 211, 226, 10, 25, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChampion_3_StatusBoxActionHand, 231, 246, 10, 25, kLeftMouseButton), + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gMouseInput_PanelChest[9] = { // @ G0456_as_Graphic561_MouseInput_PanelChest[9] + /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ + MouseInput(kCommandClickOnSlotBoxChest_1, 117, 132, 92, 107, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChest_2, 106, 121, 109, 124, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChest_3, 111, 126, 126, 141, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChest_4, 128, 143, 131, 146, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChest_5, 145, 160, 134, 149, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChest_6, 162, 177, 136, 151, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChest_7, 179, 194, 137, 152, kLeftMouseButton), + MouseInput(kCommandClickOnSlotBoxChest_8, 196, 211, 138, 153, kLeftMouseButton), + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gMouseInput_PanelResurrectReincarnateCancel[4] = { // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4] + /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ + MouseInput(kCommandClickInPanelResurrect, 108, 158, 90, 138, kLeftMouseButton), /* Atari ST: Box = 104, 158, 86, 142 */ + MouseInput(kCommandClickInPanelReincarnate, 161, 211, 90, 138, kLeftMouseButton), /* Atari ST: Box = 163, 217, 86, 142 */ + MouseInput(kCommandClickInPanelCancel, 108, 211, 141, 153, kLeftMouseButton), /* Atari ST: Box = 104, 217, 146, 156 */ + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; + + +MouseInput DM::gPrimaryMouseInput_ViewportDialog1Choice[2] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2] + MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 138, 152, kLeftMouseButton), /* Bottom button */ + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gPrimaryMouseInput_ViewportDialog2Choices[3] = { // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3] + MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 101, 115, kLeftMouseButton), /* Top button */ + MouseInput(kCommandClickOnDialogChoice_2, 16, 207, 138, 152, kLeftMouseButton), /* Bottom button */ + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gPrimaryMouseInput_ViewportDialog3Choices[4] = { // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4] + MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 101, 115, kLeftMouseButton), /* Top button */ + MouseInput(kCommandClickOnDialogChoice_2, 16, 101, 138, 152, kLeftMouseButton), /* Lower left button */ + MouseInput(kCommandClickOnDialogChoice_3, 123, 207, 138, 152, kLeftMouseButton), /* Lower right button */ + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gPrimaryMouseInput_ViewportDialog4Choices[5] = { // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5] + MouseInput(kCommandClickOnDialogChoice_1, 16, 101, 101, 115, kLeftMouseButton), /* Top left button */ + MouseInput(kCommandClickOnDialogChoice_2, 123, 207, 101, 115, kLeftMouseButton), /* Top right button */ + MouseInput(kCommandClickOnDialogChoice_3, 16, 101, 138, 152, kLeftMouseButton), /* Lower left button */ + MouseInput(kCommandClickOnDialogChoice_4, 123, 207, 138, 152, kLeftMouseButton), /* Lower right button */ + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gPrimaryMouseInput_ScreenDialog1Choice[2] = { // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2] + MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 138, 152, kLeftMouseButton), /* Bottom button */ + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gPrimaryMouseInput_ScreenDialog2Choices[3] = { // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3] + MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 101, 115, kLeftMouseButton), /* Top button */ + MouseInput(kCommandClickOnDialogChoice_2, 63, 254, 138, 152, kLeftMouseButton), /* Bottom button */ + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gPrimaryMouseInput_ScreenDialog3Choices[4] = { // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4] + MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 101, 115, kLeftMouseButton), /* Top button */ + MouseInput(kCommandClickOnDialogChoice_2, 63, 148, 138, 152, kLeftMouseButton), /* Lower left button */ + MouseInput(kCommandClickOnDialogChoice_3, 170, 254, 138, 152, kLeftMouseButton), /* Lower right button */ + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; +MouseInput DM::gPrimaryMouseInput_ScreenDialog4Choices[5] = { // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5] + MouseInput(kCommandClickOnDialogChoice_1, 63, 148, 101, 115, kLeftMouseButton), /* Top left button */ + MouseInput(kCommandClickOnDialogChoice_2, 170, 254, 101, 115, kLeftMouseButton), /* Top right button */ + MouseInput(kCommandClickOnDialogChoice_3, 63, 148, 138, 152, kLeftMouseButton), /* Lower left button */ + MouseInput(kCommandClickOnDialogChoice_4, 170, 254, 138, 152, kLeftMouseButton), /* Lower right button */ + MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; + +MouseInput* DM::gPrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets + {gPrimaryMouseInput_ViewportDialog1Choice, + gPrimaryMouseInput_ViewportDialog2Choices, + gPrimaryMouseInput_ViewportDialog3Choices, + gPrimaryMouseInput_ViewportDialog4Choices}, + {gPrimaryMouseInput_ScreenDialog1Choice, + gPrimaryMouseInput_ScreenDialog2Choices, + gPrimaryMouseInput_ScreenDialog3Choices, + gPrimaryMouseInput_ScreenDialog4Choices},}; + + EventManager::EventManager(DMEngine *vm) : _vm(vm) { _dummyMapIndex = 0; } diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index cf34636598..996443df07 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -8,8 +8,9 @@ namespace DM { enum MouseButton { - kLeftMouseButton, - kRightMouseButton + kNoneMouseButton = 0, // present only because of typesafety + kLeftMouseButton = 1, + kRightMouseButton = 2 }; enum CommandType { @@ -36,7 +37,7 @@ enum CommandType { kCommandClickOnSlotBoxChampion_0_StatusBoxReadyHand = 20, // @ C020_COMMAND_CLICK_ON_SLOT_BOX_00_CHAMPION_0_STATUS_BOX_READY_HAND kCommandClickOnSlotBoxChampion_0_StatusBoxActionHand = 21, // @ C021_COMMAND_CLICK_ON_SLOT_BOX_01_CHAMPION_0_STATUS_BOX_ACTION_HAND kCommandClickOnSlotBoxChampion_1_StatusBoxReadyHand = 22, // @ C022_COMMAND_CLICK_ON_SLOT_BOX_02_CHAMPION_1_STATUS_BOX_READY_HAND - kCommandClickOnSlotBoxChampion_1_StatusBoxAactionHand = 23, // @ C023_COMMAND_CLICK_ON_SLOT_BOX_03_CHAMPION_1_STATUS_BOX_ACTION_HAND + kCommandClickOnSlotBoxChampion_1_StatusBoxActionHand = 23, // @ C023_COMMAND_CLICK_ON_SLOT_BOX_03_CHAMPION_1_STATUS_BOX_ACTION_HAND kCommandClickOnSlotBoxChampion_2_StatusBoxReadyHand = 24, // @ C024_COMMAND_CLICK_ON_SLOT_BOX_04_CHAMPION_2_STATUS_BOX_READY_HAND kCommandClickOnSlotBoxChampion_2_StatusBoxActionHand = 25, // @ C025_COMMAND_CLICK_ON_SLOT_BOX_05_CHAMPION_2_STATUS_BOX_ACTION_HAND kCommandClickOnSlotBoxChampion_3_StatusBoxReadyHand = 26, // @ C026_COMMAND_CLICK_ON_SLOT_BOX_06_CHAMPION_3_STATUS_BOX_READY_HAND @@ -143,6 +144,30 @@ public: : commandTypeToIssue(type), hitbox(x1, x2, y1, y2), button(mouseButton) {} }; // @ MOUSE_INPUT +extern MouseInput gPrimaryMouseInput_Entrance[4]; // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4] +extern MouseInput gPrimaryMouseInput_RestartGame[2]; // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2] +extern MouseInput gPrimaryMouseInput_Interface[20]; // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20] +extern MouseInput gSecondaryMouseInput_Movement[9]; // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9] +extern MouseInput gSecondaryMouseInput_ChampionInventory[38]; // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38] +extern MouseInput gPrimaryMouseInput_PartySleeping[3]; // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3] +extern MouseInput gPrimaryMouseInput_FrozenGame[3]; // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3] +extern MouseInput gMouseInput_ActionAreaNames[5]; // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5] +extern MouseInput gMouseInput_ActionAreaIcons[5]; // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5] +extern MouseInput gMouseInput_SpellArea[9]; // @ G0454_as_Graphic561_MouseInput_SpellArea[9] +extern MouseInput gMouseInput_ChampionNamesHands[13]; // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13] +extern MouseInput gMouseInput_PanelChest[9]; // @ G0456_as_Graphic561_MouseInput_PanelChest[9] +extern MouseInput gMouseInput_PanelResurrectReincarnateCancel[4]; // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4] +extern MouseInput gPrimaryMouseInput_ViewportDialog1Choice[2]; // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2] +extern MouseInput gPrimaryMouseInput_ViewportDialog2Choices[3]; // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3] +extern MouseInput gPrimaryMouseInput_ViewportDialog3Choices[4]; // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4] +extern MouseInput gPrimaryMouseInput_ViewportDialog4Choices[5]; // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5] +extern MouseInput gPrimaryMouseInput_ScreenDialog1Choice[2]; // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2] +extern MouseInput gPrimaryMouseInput_ScreenDialog2Choices[3]; // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3] +extern MouseInput gPrimaryMouseInput_ScreenDialog3Choices[4]; // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4] +extern MouseInput gPrimaryMouseInput_ScreenDialog4Choices[5]; // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5] +extern MouseInput* gPrimaryMouseInput_DialogSets[2][4]; // @ G0480_aaps_PrimaryMouseInput_DialogSets + + class DMEngine; class EventManager { -- cgit v1.2.3 From 6b31b1bbc32ecb021de8b92a02e31621c7d8e45f Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 16 Jun 2016 17:18:01 +0200 Subject: DM: Add KeyboardInput struct --- engines/dm/eventman.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index 996443df07..ae3eb90b35 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -167,6 +167,14 @@ extern MouseInput gPrimaryMouseInput_ScreenDialog3Choices[4]; // @ G0477_as_Grap extern MouseInput gPrimaryMouseInput_ScreenDialog4Choices[5]; // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5] extern MouseInput* gPrimaryMouseInput_DialogSets[2][4]; // @ G0480_aaps_PrimaryMouseInput_DialogSets +class KeyboardInput { +public: + Command commandToIssue; + Common::KeyCode key; + byte modifiers; + + KeyboardInput(Command command, Common::KeyCode keycode, byte modifierFlags) : commandToIssue(command), key(keycode), modifiers(modifierFlags) {} +}; // @ KEYBOARD_INPUT class DMEngine; -- cgit v1.2.3 From bcfe176df557b78adf9181a9dfea229ff3fadfe1 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 16 Jun 2016 23:48:18 +0200 Subject: DM: Add mouseclick processing --- engines/dm/dm.cpp | 12 ++++-- engines/dm/dm.h | 1 + engines/dm/eventman.cpp | 107 ++++++++++++++++++++++++++++++++++++------------ engines/dm/eventman.h | 20 +++++++-- engines/dm/gfx.cpp | 2 +- engines/dm/gfx.h | 4 ++ 6 files changed, 112 insertions(+), 34 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 002068a650..44c90d245e 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -74,15 +74,15 @@ Common::Error DMEngine::run() { _dungeonMan->setCurrentMapAndPartyMap(dummyMapIndex); - - _displayMan->loadCurrentMapGraphics(); - _displayMan->loadPalette(gPalCredits); _eventMan->initMouse(); _eventMan->showMouse(true); + startGame(); + + while (true) { _eventMan->processInput(); _displayMan->clearScreen(kColorBlack); @@ -95,4 +95,10 @@ Common::Error DMEngine::run() { return Common::kNoError; } + +void DMEngine::startGame() { + _eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface; + _eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement; +} + } // End of namespace DM diff --git a/engines/dm/dm.h b/engines/dm/dm.h index c381587abf..83f80e4327 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -76,6 +76,7 @@ enum { }; class DMEngine : public Engine { + void startGame(); // @ F0462_START_StartGame_CPSF public: DMEngine(OSystem *syst); ~DMEngine(); diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 8bf5a5bdc9..f2ca15e0c5 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -6,21 +6,21 @@ -using namespace DM; +namespace DM { -MouseInput DM::gPrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4] +MouseInput gPrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(kCommandEntranceEnterDungeon, 244, 298, 45, 58, kLeftMouseButton), // Strangerke - C201_COMMAND_ENTRANCE_RESUME isn't present in the demo MouseInput(kCommandEntranceResume, 244, 298, 76, 93, kLeftMouseButton), MouseInput(kCommandEntranceDrawCredits, 248, 293, 187, 199, kLeftMouseButton), MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gPrimaryMouseInput_RestartGame[2] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2] +MouseInput gPrimaryMouseInput_RestartGame[2] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(kCommandRestartGame, 103, 217, 145, 159, kLeftMouseButton), MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gPrimaryMouseInput_Interface[20] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20] +MouseInput gPrimaryMouseInput_Interface[20] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(kCommandClickInChampion_0_StatusBox, 0, 42, 0, 28, kLeftMouseButton), MouseInput(kCommandClickInChampion_1_StatusBox, 69, 111, 0, 28, kLeftMouseButton), @@ -42,7 +42,7 @@ MouseInput DM::gPrimaryMouseInput_Interface[20] = { // @ G0447_as_Graphic561_Pri MouseInput(kCommandClickInActionArea, 233, 319, 77, 121, kLeftMouseButton), MouseInput(kCommandFreezeGame, 0, 1, 198, 199, kLeftMouseButton), MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gSecondaryMouseInput_Movement[9] = { // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9] +MouseInput gSecondaryMouseInput_Movement[9] = { // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(kCommandTurnLeft, 234, 261, 125, 145, kLeftMouseButton), MouseInput(kCommandMoveForward, 263, 289, 125, 145, kLeftMouseButton), @@ -53,7 +53,7 @@ MouseInput DM::gSecondaryMouseInput_Movement[9] = { // @ G0448_as_Graphic561_Sec MouseInput(kCommandClickInDungeonView, 0, 223, 33, 168, kLeftMouseButton), MouseInput(kCommandToggleInventoryLeader, 0, 319, 33, 199, kRightMouseButton), MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gSecondaryMouseInput_ChampionInventory[38] = { // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38] +MouseInput gSecondaryMouseInput_ChampionInventory[38] = { // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(kCommandCloseInventory, 0, 319, 0, 199, kRightMouseButton), MouseInput(kCommandSaveGame, 174, 182, 36, 44, kLeftMouseButton), @@ -93,31 +93,31 @@ MouseInput DM::gSecondaryMouseInput_ChampionInventory[38] = { // @ G0449_as_Grap MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_9, 202, 217, 66, 81, kLeftMouseButton), MouseInput(kCommandClickInPanel, 96, 223, 83, 167, kLeftMouseButton), MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gPrimaryMouseInput_PartySleeping[3] = { // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3] +MouseInput gPrimaryMouseInput_PartySleeping[3] = { // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(kCommandWakeUp, 0, 223, 33, 168, kLeftMouseButton), MouseInput(kCommandWakeUp, 0, 223, 33, 168, kRightMouseButton), MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gPrimaryMouseInput_FrozenGame[3] = { // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3] +MouseInput gPrimaryMouseInput_FrozenGame[3] = { // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(kCommandUnfreezeGame, 0, 319, 0, 199, kLeftMouseButton), MouseInput(kCommandUnfreezeGame, 0, 319, 0, 199, kRightMouseButton), MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gMouseInput_ActionAreaNames[5] = { // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5] +MouseInput gMouseInput_ActionAreaNames[5] = { // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(kCommandClickInActionAreaPass, 285, 318, 77, 83, kLeftMouseButton), MouseInput(kCommandClickInActionAreaAction_0, 234, 318, 86, 96, kLeftMouseButton), MouseInput(kCommandClickInActionAreaAction_1, 234, 318, 98, 108, kLeftMouseButton), MouseInput(kCommandClickInActionAreaAction_2, 234, 318, 110, 120, kLeftMouseButton), MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gMouseInput_ActionAreaIcons[5] = { // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5] +MouseInput gMouseInput_ActionAreaIcons[5] = { // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(kCommandClickInActionAreaChampion_0_Action, 233, 252, 86, 120, kLeftMouseButton), MouseInput(kCommandClickInActionAreaChampion_1_Action, 255, 274, 86, 120, kLeftMouseButton), MouseInput(kCommandClickInActionAreaChampion_2_Action, 277, 296, 86, 120, kLeftMouseButton), MouseInput(kCommandClickInActionAreaChampion_3_Action, 299, 318, 86, 120, kLeftMouseButton), MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gMouseInput_SpellArea[9] = { // @ G0454_as_Graphic561_MouseInput_SpellArea[9] +MouseInput gMouseInput_SpellArea[9] = { // @ G0454_as_Graphic561_MouseInput_SpellArea[9] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(kCommandClickInSpellAreaSymbol_1, 235, 247, 51, 61, kLeftMouseButton), MouseInput(kCommandClickInSpellAreaSymbol_2, 249, 261, 51, 61, kLeftMouseButton), @@ -128,7 +128,7 @@ MouseInput DM::gMouseInput_SpellArea[9] = { // @ G0454_as_Graphic561_MouseInput_ MouseInput(kCommandClickInSpeallAreaCastSpell, 234, 303, 63, 73, kLeftMouseButton), MouseInput(kCommandClickInSpellAreaRecantSymbol, 305, 318, 63, 73, kLeftMouseButton), MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gMouseInput_ChampionNamesHands[13] = { // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13] +MouseInput gMouseInput_ChampionNamesHands[13] = { // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(kCommandSetLeaderChampion_0, 0, 42, 0, 6, kLeftMouseButton), MouseInput(kCommandSetLeaderChampion_1, 69, 111, 0, 6, kLeftMouseButton), @@ -143,7 +143,7 @@ MouseInput DM::gMouseInput_ChampionNamesHands[13] = { // @ G0455_as_Graphic561_M MouseInput(kCommandClickOnSlotBoxChampion_3_StatusBoxReadyHand, 211, 226, 10, 25, kLeftMouseButton), MouseInput(kCommandClickOnSlotBoxChampion_3_StatusBoxActionHand, 231, 246, 10, 25, kLeftMouseButton), MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gMouseInput_PanelChest[9] = { // @ G0456_as_Graphic561_MouseInput_PanelChest[9] +MouseInput gMouseInput_PanelChest[9] = { // @ G0456_as_Graphic561_MouseInput_PanelChest[9] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(kCommandClickOnSlotBoxChest_1, 117, 132, 92, 107, kLeftMouseButton), MouseInput(kCommandClickOnSlotBoxChest_2, 106, 121, 109, 124, kLeftMouseButton), @@ -154,7 +154,7 @@ MouseInput DM::gMouseInput_PanelChest[9] = { // @ G0456_as_Graphic561_MouseInput MouseInput(kCommandClickOnSlotBoxChest_7, 179, 194, 137, 152, kLeftMouseButton), MouseInput(kCommandClickOnSlotBoxChest_8, 196, 211, 138, 153, kLeftMouseButton), MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gMouseInput_PanelResurrectReincarnateCancel[4] = { // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4] +MouseInput gMouseInput_PanelResurrectReincarnateCancel[4] = { // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(kCommandClickInPanelResurrect, 108, 158, 90, 138, kLeftMouseButton), /* Atari ST: Box = 104, 158, 86, 142 */ MouseInput(kCommandClickInPanelReincarnate, 161, 211, 90, 138, kLeftMouseButton), /* Atari ST: Box = 163, 217, 86, 142 */ @@ -162,44 +162,44 @@ MouseInput DM::gMouseInput_PanelResurrectReincarnateCancel[4] = { // @ G0457_as_ MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gPrimaryMouseInput_ViewportDialog1Choice[2] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2] +MouseInput gPrimaryMouseInput_ViewportDialog1Choice[2] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2] MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 138, 152, kLeftMouseButton), /* Bottom button */ MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gPrimaryMouseInput_ViewportDialog2Choices[3] = { // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3] +MouseInput gPrimaryMouseInput_ViewportDialog2Choices[3] = { // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3] MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 101, 115, kLeftMouseButton), /* Top button */ MouseInput(kCommandClickOnDialogChoice_2, 16, 207, 138, 152, kLeftMouseButton), /* Bottom button */ MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gPrimaryMouseInput_ViewportDialog3Choices[4] = { // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4] +MouseInput gPrimaryMouseInput_ViewportDialog3Choices[4] = { // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4] MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 101, 115, kLeftMouseButton), /* Top button */ MouseInput(kCommandClickOnDialogChoice_2, 16, 101, 138, 152, kLeftMouseButton), /* Lower left button */ MouseInput(kCommandClickOnDialogChoice_3, 123, 207, 138, 152, kLeftMouseButton), /* Lower right button */ MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gPrimaryMouseInput_ViewportDialog4Choices[5] = { // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5] +MouseInput gPrimaryMouseInput_ViewportDialog4Choices[5] = { // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5] MouseInput(kCommandClickOnDialogChoice_1, 16, 101, 101, 115, kLeftMouseButton), /* Top left button */ MouseInput(kCommandClickOnDialogChoice_2, 123, 207, 101, 115, kLeftMouseButton), /* Top right button */ MouseInput(kCommandClickOnDialogChoice_3, 16, 101, 138, 152, kLeftMouseButton), /* Lower left button */ MouseInput(kCommandClickOnDialogChoice_4, 123, 207, 138, 152, kLeftMouseButton), /* Lower right button */ MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gPrimaryMouseInput_ScreenDialog1Choice[2] = { // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2] +MouseInput gPrimaryMouseInput_ScreenDialog1Choice[2] = { // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2] MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 138, 152, kLeftMouseButton), /* Bottom button */ MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gPrimaryMouseInput_ScreenDialog2Choices[3] = { // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3] +MouseInput gPrimaryMouseInput_ScreenDialog2Choices[3] = { // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3] MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 101, 115, kLeftMouseButton), /* Top button */ MouseInput(kCommandClickOnDialogChoice_2, 63, 254, 138, 152, kLeftMouseButton), /* Bottom button */ MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gPrimaryMouseInput_ScreenDialog3Choices[4] = { // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4] +MouseInput gPrimaryMouseInput_ScreenDialog3Choices[4] = { // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4] MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 101, 115, kLeftMouseButton), /* Top button */ MouseInput(kCommandClickOnDialogChoice_2, 63, 148, 138, 152, kLeftMouseButton), /* Lower left button */ MouseInput(kCommandClickOnDialogChoice_3, 170, 254, 138, 152, kLeftMouseButton), /* Lower right button */ MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput DM::gPrimaryMouseInput_ScreenDialog4Choices[5] = { // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5] +MouseInput gPrimaryMouseInput_ScreenDialog4Choices[5] = { // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5] MouseInput(kCommandClickOnDialogChoice_1, 63, 148, 101, 115, kLeftMouseButton), /* Top left button */ MouseInput(kCommandClickOnDialogChoice_2, 170, 254, 101, 115, kLeftMouseButton), /* Top right button */ MouseInput(kCommandClickOnDialogChoice_3, 63, 148, 138, 152, kLeftMouseButton), /* Lower left button */ MouseInput(kCommandClickOnDialogChoice_4, 170, 254, 138, 152, kLeftMouseButton), /* Lower right button */ MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput* DM::gPrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets +MouseInput* gPrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets {gPrimaryMouseInput_ViewportDialog1Choice, gPrimaryMouseInput_ViewportDialog2Choices, gPrimaryMouseInput_ViewportDialog3Choices, @@ -211,7 +211,13 @@ MouseInput* DM::gPrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryM EventManager::EventManager(DMEngine *vm) : _vm(vm) { - _dummyMapIndex = 0; + _primaryMouseInput = nullptr; + _secondaryMouseInput = nullptr; + + _pendingClickPresent = false; + _isCommandQueueLocked = true; + + _dummyMapIndex = 0; } @@ -242,7 +248,7 @@ void EventManager::initMouse() { CursorMan.pushCursor(mouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0); CursorMan.showMouse(false); - setMousePos(Common::Point(320/2, 200/2)); + setMousePos(Common::Point(320 / 2, 200 / 2)); // TODO: add cursor creatin, set to hidden } @@ -261,7 +267,11 @@ void EventManager::processInput() { Common::Event event; while (_vm->_system->getEventManager()->pollEvent(event)) { - if (event.type == Common::EVENT_KEYDOWN && !event.synthetic) { + switch (event.type) { + case Common::EVENT_KEYDOWN: + if (event.synthetic) + break; + switch (event.kbd.keycode) { case Common::KEYCODE_w: dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY); @@ -290,8 +300,51 @@ void EventManager::processInput() { dungeonMan.setCurrentMapAndPartyMap(--_dummyMapIndex); break; } - } else if (event.type == Common::EVENT_MOUSEMOVE) { + case Common::EVENT_MOUSEMOVE: _mousePos = event.mouse; + break; + case Common::EVENT_LBUTTONUP: + case Common::EVENT_RBUTTONUP: + _pendingClickPresent = true; + _pendingClickPos = _mousePos; + _pendingClickButton = (event.type == Common::EVENT_LBUTTONUP) ? kLeftMouseButton : kRightMouseButton; + break; } } } + +void EventManager::processPendingClick() { + if (_pendingClickPresent) { + _pendingClickPresent = false; + processClick(_pendingClickPos, _pendingClickButton); + } +} + +void EventManager::processClick(Common::Point mousePos, MouseButton button) { + CommandType commandType; + + commandType = getCommandTypeFromMouseInput(_primaryMouseInput, mousePos, button); + if (commandType == kCommandNone) + commandType = getCommandTypeFromMouseInput(_secondaryMouseInput, mousePos, button); + + if (commandType != kCommandNone) + _commandQueue.push(Command(mousePos, commandType)); + + _isCommandQueueLocked = false; +} + +CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button) { + if (!input) + return kCommandNone; + CommandType commandType = kCommandNone; + + while ((commandType = input->commandTypeToIssue) != kCommandNone) { + if (input->hitbox.isPointInside(mousePos) && input->button == button) + break; + input++; + } + return commandType; +} + + +}; // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index ae3eb90b35..c52cf6d95c 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -2,6 +2,7 @@ #define DM_EVENTMAN_H #include "common/events.h" +#include "common/queue.h" #include "gfx.h" @@ -127,10 +128,10 @@ enum CommandType { class Command { public: - int16 posX, posY; + Common::Point pos; CommandType type; - Command(int16 x, int16 y, CommandType commandType): posX(x), posY(y), type(type) {} + Command(Common::Point position, CommandType commandType): pos(position), type(type) {} }; // @ COMMAND @@ -141,7 +142,7 @@ public: MouseButton button; MouseInput(CommandType type, uint16 x1, uint16 x2, uint16 y1, uint16 y2, MouseButton mouseButton) - : commandTypeToIssue(type), hitbox(x1, x2, y1, y2), button(mouseButton) {} + : commandTypeToIssue(type), hitbox(x1, x2 + 1, y1, y2 + 1), button(mouseButton) {} }; // @ MOUSE_INPUT extern MouseInput gPrimaryMouseInput_Entrance[4]; // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4] @@ -183,13 +184,26 @@ class EventManager { Common::Point _mousePos; uint16 _dummyMapIndex; + + bool _pendingClickPresent; // G0436_B_PendingClickPresent + Common::Point _pendingClickPos; // @ G0437_i_PendingClickX, G0438_i_PendingClickY + MouseButton _pendingClickButton; // @ G0439_i_PendingClickButtonsStatus + + bool _isCommandQueueLocked; + Common::Queue _commandQueue; public: + MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput + MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput + EventManager(DMEngine *vm); void initMouse(); void showMouse(bool visibility); void setMousePos(Common::Point pos); void processInput(); + void processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick + void processClick(Common::Point mousePos, MouseButton button); // @ F0359_COMMAND_ProcessClick_CPSC + CommandType getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC }; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 1c820a9467..3042d8f03e 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -622,7 +622,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { for (int i = 0; i < 18; i++) _currMapDoorOrnIndices[i] = 0; - Thing _inscriptionThing = Thing::thingNone; + _inscriptionThing = Thing::thingNone; } DisplayMan::~DisplayMan() { diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 9790517507..50171feaa3 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -2,6 +2,7 @@ #define GFX_H #include "common/scummsys.h" +#include "common/rect.h" #include "dm.h" namespace DM { @@ -20,6 +21,9 @@ public: uint16 Y2; Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): X1(x1), X2(x2), Y1(y1), Y2(y2) {} + bool isPointInside(Common::Point point) { + return (X1 <= point.x) && (point.x < X2) && (Y1 <= point.y) && (point.y < Y2); + } }; // @ BOX_BYTE, BOX_WORD // The frames in the original sources contain inclusive boundaries and byte widths, not pixel widths -- cgit v1.2.3 From 98c79f89bf2c5860f39a6ec7ca88a01a2f987323 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 17 Jun 2016 14:29:05 +0200 Subject: DM: Add mouse input processing and display for movement arrows --- engines/dm/dm.cpp | 15 +++++++++- engines/dm/dm.h | 4 +++ engines/dm/eventman.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++-- engines/dm/eventman.h | 10 +++++-- engines/dm/gfx.cpp | 12 ++++---- engines/dm/gfx.h | 13 +++++++- engines/dm/menus.cpp | 18 +++++++++++ engines/dm/menus.h | 18 +++++++++++ engines/dm/module.mk | 3 +- 9 files changed, 158 insertions(+), 14 deletions(-) create mode 100644 engines/dm/menus.cpp create mode 100644 engines/dm/menus.h diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 44c90d245e..40e25d30fd 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -15,6 +15,7 @@ #include "gfx.h" #include "dungeonman.h" #include "eventman.h" +#include "menus.h" namespace DM { @@ -52,6 +53,7 @@ DMEngine::~DMEngine() { delete _displayMan; delete _dungeonMan; delete _eventMan; + delete _menuMan; // clear debug channels DebugMan.clearAllDebugChannels(); @@ -64,6 +66,7 @@ Common::Error DMEngine::run() { _displayMan = new DisplayMan(this); _dungeonMan = new DungeonMan(this); _eventMan = new EventManager(this); + _menuMan = new MenuMan(this); _displayMan->setUpScreens(320, 200); @@ -84,9 +87,16 @@ Common::Error DMEngine::run() { while (true) { - _eventMan->processInput(); + _stopWaitingForPlayerInput = false; + //do { + _eventMan->processInput(); + _eventMan->processCommandQueue(); + //} while (!_stopWaitingForPlayerInput || !_gameTimeTicking); + _displayMan->clearScreen(kColorBlack); _displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY); + // DUMMY CODE: + _menuMan->drawMovementArrows(); _displayMan->updateScreen(); _system->delayMillis(10); } @@ -99,6 +109,9 @@ Common::Error DMEngine::run() { void DMEngine::startGame() { _eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface; _eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement; + + _menuMan->drawMovementArrows(); + _gameTimeTicking = true; } } // End of namespace DM diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 83f80e4327..384ac1dd5d 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -12,6 +12,7 @@ class Console; class DisplayMan; class DungeonMan; class EventManager; +class MenuMan; enum direction { @@ -90,6 +91,9 @@ public: DisplayMan *_displayMan; DungeonMan *_dungeonMan; EventManager *_eventMan; + MenuMan *_menuMan; + bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput + bool _gameTimeTicking; // @ G0301_B_GameTimeTicking }; class Console : public GUI::Debugger { diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index f2ca15e0c5..488deeb017 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -268,6 +268,7 @@ void EventManager::processInput() { Common::Event event; while (_vm->_system->getEventManager()->pollEvent(event)) { switch (event.type) { + // DUMMY CODE: EVENT_KEYDOWN, only for testing case Common::EVENT_KEYDOWN: if (event.synthetic) break; @@ -303,11 +304,11 @@ void EventManager::processInput() { case Common::EVENT_MOUSEMOVE: _mousePos = event.mouse; break; - case Common::EVENT_LBUTTONUP: - case Common::EVENT_RBUTTONUP: + case Common::EVENT_LBUTTONDOWN: + case Common::EVENT_RBUTTONDOWN: _pendingClickPresent = true; _pendingClickPos = _mousePos; - _pendingClickButton = (event.type == Common::EVENT_LBUTTONUP) ? kLeftMouseButton : kRightMouseButton; + _pendingClickButton = (event.type == Common::EVENT_LBUTTONDOWN) ? kLeftMouseButton : kRightMouseButton; break; } } @@ -347,4 +348,76 @@ CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common } +void EventManager::processCommandQueue() { + _isCommandQueueLocked = true; + if (_commandQueue.empty()) { + _isCommandQueueLocked = false; + processPendingClick(); + return; + } + + Command cmd = _commandQueue.pop(); + + // MISSING CODE: for when movement is disabled + + _isCommandQueueLocked = false; + processPendingClick(); + + if ((cmd.type == kCommandTurnRight) || (cmd.type == kCommandTurnLeft)) { + commandTurnParty(cmd.type); + return; + } + + if ((cmd.type >= kCommandMoveForward) && (cmd.type <= kCommandMoveLeft)) { + commandMoveParty(cmd.type); + return; + } + + // MISSING CODE: the rest of the function +} + +void EventManager::commandTurnParty(CommandType cmdType) { + _vm->_stopWaitingForPlayerInput = true; + + // MISSING CODE: highlight turn left/right buttons + + // MISSING CODE: processing stairs + + // MISSING CODE: process sensors + + // DUMMY CODE: should call F0284_CHAMPION_SetPartyDirection instead + direction &partyDir = _vm->_dungeonMan->_currMap.partyDir; + (cmdType == kCommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir); + + // MISSING CODE: process sensors +} + +void EventManager::commandMoveParty(CommandType cmdType) { + _vm->_stopWaitingForPlayerInput = true; + + // MISSING CODE: Lots of code + + // DUMMY CODE: + DungeonMan &dungeonMan = *_vm->_dungeonMan; + CurrMapData &currMap = dungeonMan._currMap; + + switch (cmdType) { + case kCommandMoveForward: + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY); + break; + case kCommandMoveLeft: + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY); + break; + case kCommandMoveBackward: + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY); + break; + case kCommandMoveRight: + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY); + break; + } + + // MISSING CODE: Lots of code +} + + }; // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index c52cf6d95c..ed6bba20b1 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -131,7 +131,7 @@ public: Common::Point pos; CommandType type; - Command(Common::Point position, CommandType commandType): pos(position), type(type) {} + Command(Common::Point position, CommandType commandType): pos(position), type(commandType) {} }; // @ COMMAND @@ -189,8 +189,11 @@ class EventManager { Common::Point _pendingClickPos; // @ G0437_i_PendingClickX, G0438_i_PendingClickY MouseButton _pendingClickButton; // @ G0439_i_PendingClickButtonsStatus - bool _isCommandQueueLocked; + bool _isCommandQueueLocked; // this doesn't seem to be used anywhere at all Common::Queue _commandQueue; + + void commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty + void commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty public: MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput @@ -200,10 +203,11 @@ public: void showMouse(bool visibility); void setMousePos(Common::Point pos); - void processInput(); + void processInput(); // acknowledges mouse and keyboard input void processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick void processClick(Common::Point mousePos, MouseButton button); // @ F0359_COMMAND_ProcessClick_CPSC CommandType getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC + void processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC }; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 3042d8f03e..8f88bab5f6 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -10,6 +10,8 @@ namespace DM { +Box gBoxMovementArrows = {224, 319, 124, 168}; + enum ViewCell { kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT @@ -548,11 +550,7 @@ CreatureReplColorSet gCreatureReplColorSets[13] = { // @ G0220_as_Graphic558_Cre byte gPalChangesCreature_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3 byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, 120, 130, 140, 150}; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2 -enum GraphicIndice { - kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT - kDoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED - kChampionPortraitsIndice = 26 // @ C026_GRAPHIC_CHAMPION_PORTRAITS -}; + Viewport gDefultViewPort = {0, 0}; @@ -1505,3 +1503,7 @@ void DisplayMan::blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth } } + +byte* DisplayMan::getBitmap(uint16 index) { + return _bitmaps[index]; +} diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 50171feaa3..fd9a4a3bd9 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -7,6 +7,14 @@ namespace DM { + +enum GraphicIndice { + kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT + kDoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED + kChampionPortraitsIndice = 26, // @ C026_GRAPHIC_CHAMPION_PORTRAITS + kMovementArrowsIndice = 13 // @ C013_GRAPHIC_MOVEMENT_ARROWS +}; + extern uint16 gPalSwoosh[16]; extern uint16 gPalMousePointer[16]; extern uint16 gPalCredits[16]; @@ -20,12 +28,14 @@ public: uint16 Y1; uint16 Y2; - Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): X1(x1), X2(x2), Y1(y1), Y2(y2) {} + Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): X1(x1), X2(x2 + 1), Y1(y1), Y2(y2 + 1) {} bool isPointInside(Common::Point point) { return (X1 <= point.x) && (point.x < X2) && (Y1 <= point.y) && (point.y < Y2); } }; // @ BOX_BYTE, BOX_WORD +extern Box gBoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows + // The frames in the original sources contain inclusive boundaries and byte widths, not pixel widths struct Frame { uint16 destFromX, destToX, destFromY, destToY; @@ -269,6 +279,7 @@ public: void clearScreen(Color color); void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); + byte* getBitmap(uint16 index); int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp new file mode 100644 index 0000000000..1b4c68dafe --- /dev/null +++ b/engines/dm/menus.cpp @@ -0,0 +1,18 @@ +#include "menus.h" +#include "gfx.h" + + +namespace DM { + +MenuMan::MenuMan(DMEngine *vm): _vm(vm) {} + +void MenuMan::drawMovementArrows() { + DisplayMan &disp = *_vm->_displayMan; + byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice); + Box &dest = gBoxMovementArrows; + uint16 w = disp.width(kMovementArrowsIndice); + + disp.blitToScreen(arrowsBitmap, w, 0, 0, dest.X1, dest.X2, dest.Y1, dest.Y2, kColorNoTransparency); +} + +} \ No newline at end of file diff --git a/engines/dm/menus.h b/engines/dm/menus.h new file mode 100644 index 0000000000..d4ea2d68ba --- /dev/null +++ b/engines/dm/menus.h @@ -0,0 +1,18 @@ +#ifndef DM_MENUS_H +#define DM_MENUS_H + +#include "dm.h" + +namespace DM { + +class MenuMan { + DMEngine *_vm; +public: + MenuMan(DMEngine *vm); + + void drawMovementArrows(); +}; + +} + +#endif // !DM_MENUS_H diff --git a/engines/dm/module.mk b/engines/dm/module.mk index 3078fa54ab..ed2e2ea442 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -5,7 +5,8 @@ MODULE_OBJS := \ dm.o \ gfx.o \ dungeonman.o \ - eventman.o + eventman.o \ + menus.o MODULE_DIRS += \ engines/dm -- cgit v1.2.3 From 9b57cdb8ddc6e8c199bd47d1ca04ce49c3280e6d Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 17 Jun 2016 22:32:42 +0200 Subject: DM: Add champion POD and it's enums --- engines/dm/champion.cpp | 8 ++ engines/dm/champion.h | 250 ++++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/eventman.cpp | 2 +- engines/dm/gfx.cpp | 9 +- engines/dm/gfx.h | 8 ++ engines/dm/module.mk | 3 +- 6 files changed, 270 insertions(+), 10 deletions(-) create mode 100644 engines/dm/champion.cpp create mode 100644 engines/dm/champion.h diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp new file mode 100644 index 0000000000..b3a4ad5c73 --- /dev/null +++ b/engines/dm/champion.cpp @@ -0,0 +1,8 @@ +#include "champion.h" + + +namespace DM { + +ChampionMan::ChampionMan(DMEngine *vm): _vm(vm) {} + +} \ No newline at end of file diff --git a/engines/dm/champion.h b/engines/dm/champion.h new file mode 100644 index 0000000000..ab6d4916ec --- /dev/null +++ b/engines/dm/champion.h @@ -0,0 +1,250 @@ +#ifndef DM_CHAMPION_H +#define DM_CHAMPION_H + +#include "dm.h" +#include "gfx.h" + +namespace DM { + +enum ChampionIndice { + kChampionNone = -1, // @ CM1_CHAMPION_NONE + kChampionFirst = 0, // @ C00_CHAMPION_FIRST + kChmpionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY + kChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY +}; + +enum ChampionAttribute { + kChampionAttributNone = 0x0000, // @ MASK0x0000_NONE + kChampionAttributeDisableAction = 0x0008, // @ MASK0x0008_DISABLE_ACTION + kChampionAttributeMale = 0x0010, // @ MASK0x0010_MALE + kChampionAttributeNameTitle = 0x0080, // @ MASK0x0080_NAME_TITLE + kChampionAttributeStatistics = 0x0100, // @ MASK0x0100_STATISTICS + kChampionAttributeLoad = 0x0200, // @ MASK0x0200_LOAD + kChampionAttributeIcon = 0x0400, // @ MASK0x0400_ICON + kChampionAttributePanel = 0x0800, // @ MASK0x0800_PANEL + kChampionAttributeStatusBox = 0x1000, // @ MASK0x1000_STATUS_BOX + kChampionAttributeWounds = 0x2000, // @ MASK0x2000_WOUNDS + kChampionAttributeViewport = 0x4000, // @ MASK0x4000_VIEWPORT + kChampionAttributeActionHand = 0x8000 // @ MASK0x8000_ACTION_HAND +}; + + +enum ChampionWound { + kChampionWoundNone = 0x0000, // @ MASK0x0000_NO_WOUND + kChampionWoundReadHand = 0x0001, // @ MASK0x0001_READY_HAND + kChampionWoundActionHand = 0x0002, // @ MASK0x0002_ACTION_HAND + kChampionWoundHead = 0x0004, // @ MASK0x0004_HEAD + kChampionWoundTorso = 0x0008, // @ MASK0x0008_TORSO + kChampionWoundLegs = 0x0010, // @ MASK0x0010_LEGS + kChampionWoundFeet = 0x0020 // @ MASK0x0020_FEET +}; + + +enum ChampionStatisticType { + kChampionStatLuck = 0, // @ C0_STATISTIC_LUCK + kChampionStatStrength = 1, // @ C1_STATISTIC_STRENGTH + kChampionStatDexterity = 2, // @ C2_STATISTIC_DEXTERITY + kChampionStatWisdom = 3, // @ C3_STATISTIC_WISDOM + kChampionStatVitality = 4, // @ C4_STATISTIC_VITALITY + kChampionStatAntimagic = 5, // @ C5_STATISTIC_ANTIMAGIC + kChampionStatAntifire = 6, // @ C6_STATISTIC_ANTIFIRE + kChampionStatMana = 8 // @ C8_STATISTIC_MANA /* Used as a fake statistic index for objects granting a Mana bonus */ +}; + +enum ChampionStatisticValue { + kChampionStatMaximum = 0, // @ C0_MAXIMUM + kChampionStatCurrent = 1, // @ C1_CURRENT + kChampionStatMinimum = 2 // @ C2_MINIMUM +}; + +enum ChampionSkill { + kChampionSkillFighter = 0, // @ C00_SKILL_FIGHTER + kChampionSkillNinja = 1, // @ C01_SKILL_NINJA + kChampionSkillPriest = 2, // @ C02_SKILL_PRIEST + kChampionSkillWizard = 3, // @ C03_SKILL_WIZARD + kChampionSkillSwing = 4, // @ C04_SKILL_SWING + kChampionSkillThrust = 5, // @ C05_SKILL_THRUST + kChampionSkillClub = 6, // @ C06_SKILL_CLUB + kChampionSkillParry = 7, // @ C07_SKILL_PARRY + kChampionSkillSteal = 8, // @ C08_SKILL_STEAL + kChampionSkillFight = 9, // @ C09_SKILL_FIGHT + kChampionSkillThrow = 10, // @ C10_SKILL_THROW + kChampionSkillShoot = 11, // @ C11_SKILL_SHOOT + kChampionSkillIdentify = 12, // @ C12_SKILL_IDENTIFY + kChampionSkillHeal = 13, // @ C13_SKILL_HEAL + kChampionSkillInfluence = 14, // @ C14_SKILL_INFLUENCE + kChampionSkillDefend = 15, // @ C15_SKILL_DEFEND + kChampionSkillFire = 16, // @ C16_SKILL_FIRE + kChampionSkillAir = 17, // @ C17_SKILL_AIR + kChampionSkillEarth = 18, // @ C18_SKILL_EARTH + kChampionSkillWater = 19 // @ C19_SKILL_WATER +}; + +enum ChampionSlot { + kChampionSlotLeaderHand = -1, // @ CM1_SLOT_LEADER_HAND + kChampionSlotReadyHand = 0, // @ C00_SLOT_READY_HAND + kChampionSlotActionHand = 1, // @ C01_SLOT_ACTION_HAND + kChampionSlotHead = 2, // @ C02_SLOT_HEAD + kChampionSlotTorso = 3, // @ C03_SLOT_TORSO + kChampionSlotLegs = 4, // @ C04_SLOT_LEGS + kChampionSlotFeet = 5, // @ C05_SLOT_FEET + kChampionSlotPouch_2 = 6, // @ C06_SLOT_POUCH_2 + kChampionSlotQuiverLine_2_1 = 7, // @ C07_SLOT_QUIVER_LINE2_1 + kChampionSlotQuiverLine_1_2 = 8, // @ C08_SLOT_QUIVER_LINE1_2 + kChampionSlotQuiverLine_2_2 = 9, // @ C09_SLOT_QUIVER_LINE2_2 + kChampionSlotNeck = 10, // @ C10_SLOT_NECK + kChampionSlotPouch_1 = 11, // @ C11_SLOT_POUCH_1 + kChampionSlotQuiverLine_1_1 = 12, // @ C12_SLOT_QUIVER_LINE1_1 + kChampionSlotBackpackLine_1_1 = 13, // @ C13_SLOT_BACKPACK_LINE1_1 + kChampionSlotBackpackLine_2_2 = 14, // @ C14_SLOT_BACKPACK_LINE2_2 + kChampionSlotBackpackLine_2_3 = 15, // @ C15_SLOT_BACKPACK_LINE2_3 + kChampionSlotBackpackLine_2_4 = 16, // @ C16_SLOT_BACKPACK_LINE2_4 + kChampionSlotBackpackLine_2_5 = 17, // @ C17_SLOT_BACKPACK_LINE2_5 + kChampionSlotBackpackLine_2_6 = 18, // @ C18_SLOT_BACKPACK_LINE2_6 + kChampionSlotBackpackLine_2_7 = 19, // @ C19_SLOT_BACKPACK_LINE2_7 + kChampionSlotBackpackLine_2_8 = 20, // @ C20_SLOT_BACKPACK_LINE2_8 + kChampionSlotBackpackLine_2_9 = 21, // @ C21_SLOT_BACKPACK_LINE2_9 + kChampionSlotBackpackLine_1_2 = 22, // @ C22_SLOT_BACKPACK_LINE1_2 + kChampionSlotBackpackLine_1_3 = 23, // @ C23_SLOT_BACKPACK_LINE1_3 + kChampionSlotBackpackLine_1_4 = 24, // @ C24_SLOT_BACKPACK_LINE1_4 + kChampionSlotBackpackLine_1_5 = 25, // @ C25_SLOT_BACKPACK_LINE1_5 + kChampionSlotBackpackLine_1_6 = 26, // @ C26_SLOT_BACKPACK_LINE1_6 + kChampionSlotBackpackLine_1_7 = 27, // @ C27_SLOT_BACKPACK_LINE1_7 + kChampionSlotBackpackLine_1_8 = 28, // @ C28_SLOT_BACKPACK_LINE1_8 + kChampionSlotBackpackLine_1_9 = 29, // @ C29_SLOT_BACKPACK_LINE1_9 + kChampionSlotChest_1 = 30, // @ C30_SLOT_CHEST_1 + kChampionSlotChest_2 = 31, // @ C31_SLOT_CHEST_2 + kChampionSlotChest_3 = 32, // @ C32_SLOT_CHEST_3 + kChampionSlotChest_4 = 33, // @ C33_SLOT_CHEST_4 + kChampionSlotChest_5 = 34, // @ C34_SLOT_CHEST_5 + kChampionSlotChest_6 = 35, // @ C35_SLOT_CHEST_6 + kChampionSlotChest_7 = 36, // @ C36_SLOT_CHEST_7 + kChampionSlotChest_8 = 37 // @ C37_SLOT_CHEST_8 +}; + +enum ChampionAction { + kChampionActionN = 0, // @ C000_ACTION_N + kChampionActionBlock = 1, // @ C001_ACTION_BLOCK + kChampionActionChop = 2, // @ C002_ACTION_CHOP + kChampionActionX_C003 = 3, // @ C003_ACTION_X + kChampionActionBlowHorn = 4, // @ C004_ACTION_BLOW_HORN + kChampionActionFlip = 5, // @ C005_ACTION_FLIP + kChampionActionPunch = 6, // @ C006_ACTION_PUNCH + kChampionActionKick = 7, // @ C007_ACTION_KICK + kChampionActionWarCry = 8, // @ C008_ACTION_WAR_CRY + kChampionActionStab_C009 = 9, // @ C009_ACTION_STAB + kChampionActionClimbDown = 10, // @ C010_ACTION_CLIMB_DOWN + kChampionActionFreezeLife = 11, // @ C011_ACTION_FREEZE_LIFE + kChampionActionHit = 12, // @ C012_ACTION_HIT + kChampionActionSwing = 13, // @ C013_ACTION_SWING + kChampionActionStab_C014 = 14, // @ C014_ACTION_STAB + kChampionActionThrust = 15, // @ C015_ACTION_THRUST + kChampionActionJab = 16, // @ C016_ACTION_JAB + kChampionActionParry = 17, // @ C017_ACTION_PARRY + kChampionActionHack = 18, // @ C018_ACTION_HACK + kChampionActionBerzerk = 19, // @ C019_ACTION_BERZERK + kChampionActionFireball = 20, // @ C020_ACTION_FIREBALL + kChampionActionDispel = 21, // @ C021_ACTION_DISPELL + kChampionActionConfuse = 22, // @ C022_ACTION_CONFUSE + kChampionActionLightning = 23, // @ C023_ACTION_LIGHTNING + kChampionActionDisrupt = 24, // @ C024_ACTION_DISRUPT + kChampionActionMelee = 25, // @ C025_ACTION_MELEE + kChampionActionX_C026 = 26, // @ C026_ACTION_X + kChampionActionInvoke = 27, // @ C027_ACTION_INVOKE + kChampionActionSlash = 28, // @ C028_ACTION_SLASH + kChampionActionCleave = 29, // @ C029_ACTION_CLEAVE + kChampionActionBash = 30, // @ C030_ACTION_BASH + kChampionActionStun = 31, // @ C031_ACTION_STUN + kChampionActionShoot = 32, // @ C032_ACTION_SHOOT + kChampionActionSpellshield = 33, // @ C033_ACTION_SPELLSHIELD + kChampionActionFireshield = 34, // @ C034_ACTION_FIRESHIELD + kChampionActionFluxcage = 35, // @ C035_ACTION_FLUXCAGE + kChampionActionHeal = 36, // @ C036_ACTION_HEAL + kChampionActionCalm = 37, // @ C037_ACTION_CALM + kChampionActionLight = 38, // @ C038_ACTION_LIGHT + kChampionActionWindow = 39, // @ C039_ACTION_WINDOW + kChampionActionSpit = 40, // @ C040_ACTION_SPIT + kChampionActionBrandish = 41, // @ C041_ACTION_BRANDISH + kChampionActionThrow = 42, // @ C042_ACTION_THROW + kChampionActionFuse = 43, // @ C043_ACTION_FUSE + kChampionActionNone = 255 // @ C255_ACTION_NONE +}; + + +class Skill { + int TemporaryExperience; + long Experience; +}; // @ SKILL + +class Champion { + Thing _slots[30]; + Skill _skills[20]; +public: + char _name[8]; + char _title[20]; + direction _dir; + ViewCell _cell; + ChampionAction _actionIndex; + uint16 _symbolStep; + char _symbols[5]; + uint16 _directionMaximumDamageReceived; + uint16 _maximumDamageReceived; + uint16 _poisonEventCount; + int16 _enableActionEventIndex; + int16 _hideDamageReceivedIndex; + uint16 _attributes; + uint16 _wounds; + int16 _currHealth; + int16 _maxHealth; + int16 _currStamina; + int16 _maxStamina; + int16 _currMana; + int16 _maxMana; + int16 _actionDefense; + int16 _food; + int16 _water; + byte _statistics[7][3]; + uint16 _load; + int16 _shieldDefense; + byte Portrait[464]; // 32 x 29 pixel portrait + + Thing getSlot(ChampionSlot slot) { return _slots[slot]; } + void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; } + + Skill getSkill(ChampionSkill skill) { return _skills[skill]; } + void setSkill(ChampionSkill skill, Skill val) { _skills[skill] = val; } + + byte getStatistic(ChampionStatisticType type, ChampionStatisticValue valType) { return _statistics[type][valType]; } + void setStatistic(ChampionStatisticType type, ChampionStatisticValue valType, byte newVal) { _statistics[type][valType] = newVal; } + + uint16 getAttributes() { return _attributes; } + void setAttributeFlag(ChampionAttribute flag, bool value) { + if (value) { + _attributes |= flag; + } else { + _attributes &= ~flag; + } + } + void clearAttributes(){ _attributes = kChampionAttributNone; } + + uint16 getWounds() { return _wounds; } + void setWoundsFlag(ChampionWound flag, bool value) { + if (value) { + _wounds |= flag; + } else { + _wounds &= ~flag; + } + } + void clearWounds(){ _wounds = kChampionWoundNone; } +}; // @ CHAMPION_INCLUDING_PORTRAIT + +class ChampionMan { + DMEngine *_vm; + Champion champions[4]; +public: + ChampionMan(DMEngine *vm); +}; + +} + +#endif diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 488deeb017..6a13b84947 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -268,7 +268,7 @@ void EventManager::processInput() { Common::Event event; while (_vm->_system->getEventManager()->pollEvent(event)) { switch (event.type) { - // DUMMY CODE: EVENT_KEYDOWN, only for testing + // DUMMY CODE: case EVENT_KEYDOWN, only for testing case Common::EVENT_KEYDOWN: if (event.synthetic) break; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 8f88bab5f6..61592fd654 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -12,14 +12,7 @@ namespace DM { Box gBoxMovementArrows = {224, 319, 124, 168}; -enum ViewCell { - kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT - kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT - kViewCellBackRight = 2, // @ C02_VIEW_CELL_BACK_RIGHT - kViewCellBackLeft = 3, // @ C03_VIEW_CELL_BACK_LEFT - kViewCellAlcove = 4, // @ C04_VIEW_CELL_ALCOVE - kViewCellDoorButtonOrWallOrn = 5 // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT -}; + enum StairFrameIndex { kFrameStairsUpFront_D3L = 0, // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index fd9a4a3bd9..cf06f1c7eb 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -7,6 +7,14 @@ namespace DM { +enum ViewCell { + kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT + kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT + kViewCellBackRight = 2, // @ C02_VIEW_CELL_BACK_RIGHT + kViewCellBackLeft = 3, // @ C03_VIEW_CELL_BACK_LEFT + kViewCellAlcove = 4, // @ C04_VIEW_CELL_ALCOVE + kViewCellDoorButtonOrWallOrn = 5 // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT +}; enum GraphicIndice { kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT diff --git a/engines/dm/module.mk b/engines/dm/module.mk index ed2e2ea442..1acf291453 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -6,7 +6,8 @@ MODULE_OBJS := \ gfx.o \ dungeonman.o \ eventman.o \ - menus.o + menus.o \ + champion.o MODULE_DIRS += \ engines/dm -- cgit v1.2.3 From 42567b744d4a8a2dcc3055d4d43058a1d34fe1c0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 17 Jun 2016 22:34:03 +0200 Subject: DM: Fix compilation on MSVC9 --- engines/dm/gfx.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 61592fd654..b0b2c73f1a 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -10,7 +10,7 @@ namespace DM { -Box gBoxMovementArrows = {224, 319, 124, 168}; +Box gBoxMovementArrows = Box(224, 319, 124, 168); @@ -1165,8 +1165,8 @@ void DisplayMan::loadFloorSet(FloorSet set) { } -Box gBoxWallBitmap_D3LCR = {0, 115, 0, 50}; // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR -Box gBoxWallBitmap_D2LCR = {0, 135, 0, 70}; // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR +Box gBoxWallBitmap_D3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR +Box gBoxWallBitmap_D2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR void DisplayMan::loadWallSet(WallSet set) { uint16 firstIndice = (set * kWallSetGraphicCount) + kFirstWallSet; @@ -1311,7 +1311,7 @@ void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relInd } -Box gBoxWallPatchBehindInscription = {110, 113, 37, 63}; // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription +Box gBoxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription byte gInscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY 48, /* 1 Line */ 59, /* 2 lines */ @@ -1342,7 +1342,7 @@ byte gUnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableIns 46, 53, 63, /* D2L Front, D2C Front, D2R Front */ 46, 57, 68}; /* D1L Right, D1R Left */ -Box gBoxChampionPortraitOnWall = {96, 127, 35, 63}; // G0109_s_Graphic558_Box_ChampionPortraitOnWall +Box gBoxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) { byte *bitmapGreen; -- cgit v1.2.3 From 75db418e64e7e8753c5c8ab48f322e425c31f9b4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 17 Jun 2016 22:42:39 +0200 Subject: DM: Fix a couple of warnings --- engines/dm/dungeonman.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index efff5ff16c..35b299d2be 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -594,12 +594,12 @@ T0172030_Pit: aspectArray[kTeleporterVisibleAspect] = square.get(kTeleporterOpen) && square.get(kTeleporterVisible); goto T0172029_Teleporter; case kStairsElemType: - aspectArray[kElemAspect] = ((square.get(kStairsNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) ? kStairsSideElemType : kStairsFrontElemType; + aspectArray[kElemAspect] = ((square.get(kStairsNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) ? kStairsSideElemType : kStairsFrontElemType; aspectArray[kStairsUpAspect] = square.get(kStairsUp); footPrintsAllowed = false; goto T0172046_Stairs; case kDoorElemType: - if ((square.get(kDoorNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) { + if ((square.get(kDoorNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) { aspectArray[kElemAspect] = kDoorSideElemType; } else { aspectArray[kElemAspect] = kDoorFrontElemType; -- cgit v1.2.3 From 59af06fd821911c44b44b5338db568b1ae2eff4d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 17 Jun 2016 23:08:04 +0200 Subject: DM: Fix some CppCheck warnings --- engines/dm/dm.cpp | 7 +++++++ engines/dm/dm.h | 2 +- engines/dm/dungeonman.cpp | 2 +- engines/dm/eventman.cpp | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 40e25d30fd..7875c5c45d 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -41,6 +41,13 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { // register random source _rnd = new Common::RandomSource("quux"); + _displayMan = nullptr; + _dungeonMan = nullptr; + _eventMan = nullptr; + _menuMan = nullptr; + _stopWaitingForPlayerInput = false; + _gameTimeTicking = false; + debug("DMEngine::DMEngine"); } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 384ac1dd5d..de37d3fceb 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -55,7 +55,7 @@ public: static const Thing thingNone; static const Thing thingEndOfList; - Thing() {} + Thing() : data(0) {} Thing(uint16 d) { set(d); } void set(uint16 d) { diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 35b299d2be..4e09ce4896 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -773,7 +773,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { *destString++ = '\n'; sepChar = ' '; } else if (type == kTextTypeInscription) { - sepChar = 0x80; + sepChar = (char)0x80; } else { sepChar = '\n'; } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 6a13b84947..626887ebab 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -218,6 +218,7 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) { _isCommandQueueLocked = true; _dummyMapIndex = 0; + _pendingClickButton = kNoneMouseButton; } -- cgit v1.2.3 From 3ff3512c64fd3e5245b45506203a8d5083598a88 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 11:36:31 +0200 Subject: DM: Add initialization related to F0435_STARTEND_LoadGame_CPSF --- engines/dm/champion.cpp | 4 ++++ engines/dm/champion.h | 10 +++++++++- engines/dm/dm.cpp | 20 ++++++++++++++++---- engines/dm/dm.h | 6 ++++++ engines/dm/loadsave.cpp | 37 +++++++++++++++++++++++++++++++++++++ engines/dm/loadsave.h | 25 +++++++++++++++++++++++++ engines/dm/module.mk | 3 ++- 7 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 engines/dm/loadsave.cpp create mode 100644 engines/dm/loadsave.h diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b3a4ad5c73..0e0d5e8eea 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -5,4 +5,8 @@ namespace DM { ChampionMan::ChampionMan(DMEngine *vm): _vm(vm) {} +ChampionIndex ChampionMan::getIndexInCell(int16 mapX, int16 mapY, ViewCell cell) { + return kChampionNone; +} + } \ No newline at end of file diff --git a/engines/dm/champion.h b/engines/dm/champion.h index ab6d4916ec..36f1689b7a 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -6,9 +6,12 @@ namespace DM { -enum ChampionIndice { +enum ChampionIndex { kChampionNone = -1, // @ CM1_CHAMPION_NONE kChampionFirst = 0, // @ C00_CHAMPION_FIRST + kChampionSecond = 1, + kChampionThird = 2, + kChampionFourth = 3, kChmpionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY kChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY }; @@ -242,7 +245,12 @@ class ChampionMan { DMEngine *_vm; Champion champions[4]; public: + uint16 _partChampionCount; + bool _partyDead; // @ G0303_B_PartyDead + Thing _leaderHand; + ChampionMan(DMEngine *vm); + ChampionIndex getIndexInCell(int16 mapX, int16 mapY, ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell }; } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 7875c5c45d..77d7ed012a 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -16,6 +16,8 @@ #include "dungeonman.h" #include "eventman.h" #include "menus.h" +#include "champion.h" +#include "loadsave.h" namespace DM { @@ -41,10 +43,12 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { // register random source _rnd = new Common::RandomSource("quux"); - _displayMan = nullptr; _dungeonMan = nullptr; + _displayMan = nullptr; _eventMan = nullptr; _menuMan = nullptr; + _championMan = nullptr; + _loadsaveMan = nullptr; _stopWaitingForPlayerInput = false; _gameTimeTicking = false; @@ -61,6 +65,8 @@ DMEngine::~DMEngine() { delete _dungeonMan; delete _eventMan; delete _menuMan; + delete _championMan; + delete _loadsaveMan; // clear debug channels DebugMan.clearAllDebugChannels(); @@ -74,14 +80,15 @@ Common::Error DMEngine::run() { _dungeonMan = new DungeonMan(this); _eventMan = new EventManager(this); _menuMan = new MenuMan(this); + _championMan = new ChampionMan(this); + _loadsaveMan = new LoadsaveMan(this); _displayMan->setUpScreens(320, 200); _displayMan->loadGraphics(); _dungeonMan->loadDungeonFile(); - int16 dummyMapIndex = 0; - _dungeonMan->setCurrentMapAndPartyMap(dummyMapIndex); + _dungeonMan->setCurrentMapAndPartyMap(0); _displayMan->loadCurrentMapGraphics(); @@ -90,13 +97,15 @@ Common::Error DMEngine::run() { _eventMan->initMouse(); _eventMan->showMouse(true); + _loadsaveMan->loadgame(); + startGame(); while (true) { _stopWaitingForPlayerInput = false; //do { - _eventMan->processInput(); + _eventMan->processInput(); _eventMan->processCommandQueue(); //} while (!_stopWaitingForPlayerInput || !_gameTimeTicking); @@ -117,8 +126,11 @@ void DMEngine::startGame() { _eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface; _eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement; + _menuMan->drawMovementArrows(); _gameTimeTicking = true; + + // MISSING CODE: Lot of stuff } } // End of namespace DM diff --git a/engines/dm/dm.h b/engines/dm/dm.h index de37d3fceb..67d968a7f9 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -13,6 +13,8 @@ class DisplayMan; class DungeonMan; class EventManager; class MenuMan; +class ChampionMan; +class LoadsaveMan; enum direction { @@ -92,8 +94,12 @@ public: DungeonMan *_dungeonMan; EventManager *_eventMan; MenuMan *_menuMan; + ChampionMan *_championMan; + LoadsaveMan *_loadsaveMan; bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput bool _gameTimeTicking; // @ G0301_B_GameTimeTicking + bool _restartGameAllowed; // @ G0524_B_RestartGameAllowed + uint32 _gameId; // @ G0525_l_GameID, probably useless here }; class Console : public GUI::Debugger { diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp new file mode 100644 index 0000000000..cd522fa508 --- /dev/null +++ b/engines/dm/loadsave.cpp @@ -0,0 +1,37 @@ +#include "loadsave.h" +#include "dungeonman.h" +#include "champion.h" + + + +namespace DM { + +LoadsaveMan::LoadsaveMan(DMEngine *vm) : _vm(vm) {} + + +LoadgameResponse LoadsaveMan::loadgame() { + bool newGame = _vm->_dungeonMan->_messages.newGame; + ChampionMan &cm = *_vm->_championMan; + + if (newGame) { + _vm->_restartGameAllowed = false; + cm._partChampionCount = 0; + cm._leaderHand = Thing::thingNone; + _vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536); + } else { + assert(false); + // MISSING CODE: load game + } + + + if (newGame) { + warning("MISSING CODE: Timline init, Group init"); + } else { + assert(false); + // MISSING CODE: load game + } + cm._partyDead = false; + return kLoadgameSuccess; +} + +} \ No newline at end of file diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h new file mode 100644 index 0000000000..857191200f --- /dev/null +++ b/engines/dm/loadsave.h @@ -0,0 +1,25 @@ +#ifndef DM_LOADSAVE_H +#define DM_LOADSAVE_H + +#include "dm.h" + +namespace DM { + +enum LoadgameResponse { + kLoadgameFailure = -1, // @ CM1_LOAD_GAME_FAILURE + kLoadgameSuccess = 1// @ C01_LOAD_GAME_SUCCESS +}; + +class LoadsaveMan { + DMEngine *_vm; +public: + LoadsaveMan(DMEngine *vm); + + LoadgameResponse loadgame(); // @ F0435_STARTEND_LoadGame_CPSF + +}; + +} + +#endif + diff --git a/engines/dm/module.mk b/engines/dm/module.mk index 1acf291453..45a6ed528d 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -7,7 +7,8 @@ MODULE_OBJS := \ dungeonman.o \ eventman.o \ menus.o \ - champion.o + champion.o \ + loadsave.o MODULE_DIRS += \ engines/dm -- cgit v1.2.3 From 332a515d2cb718fdaa46f8c01875f430dbd03036 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 11:47:17 +0200 Subject: DM: Add getIndexInCell function in ChampionMan --- engines/dm/champion.cpp | 7 ++++++- engines/dm/champion.h | 6 +++--- engines/dm/loadsave.cpp | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 0e0d5e8eea..0ae05396f7 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -5,7 +5,12 @@ namespace DM { ChampionMan::ChampionMan(DMEngine *vm): _vm(vm) {} -ChampionIndex ChampionMan::getIndexInCell(int16 mapX, int16 mapY, ViewCell cell) { +ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { + for (uint16 i = 0; i < _partyChampionCount; ++i) { + if ((_champions[i]._cell == cell) && _champions[i]._currHealth) + return (ChampionIndex)i; + } + return kChampionNone; } diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 36f1689b7a..536d3676b2 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -243,14 +243,14 @@ public: class ChampionMan { DMEngine *_vm; - Champion champions[4]; + Champion _champions[4]; public: - uint16 _partChampionCount; + uint16 _partyChampionCount; bool _partyDead; // @ G0303_B_PartyDead Thing _leaderHand; ChampionMan(DMEngine *vm); - ChampionIndex getIndexInCell(int16 mapX, int16 mapY, ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell + ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell }; } diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index cd522fa508..e58b746060 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -15,7 +15,7 @@ LoadgameResponse LoadsaveMan::loadgame() { if (newGame) { _vm->_restartGameAllowed = false; - cm._partChampionCount = 0; + cm._partyChampionCount = 0; cm._leaderHand = Thing::thingNone; _vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536); } else { -- cgit v1.2.3 From e744d8a42710ae9219e0b48ffb7094b08c0f5f5f Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 12:08:05 +0200 Subject: DM: Add F0279_CHAMPION_GetDecodedValue, M27_PORTRAIT_X, M28_PORTRAIT_Y --- engines/dm/champion.cpp | 18 +++++++++++++++++- engines/dm/champion.h | 11 ++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 0ae05396f7..3aabfb0fa5 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -3,7 +3,23 @@ namespace DM { -ChampionMan::ChampionMan(DMEngine *vm): _vm(vm) {} +ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {} + +uint16 ChampionMan::getChampionPortraitX(uint16 index) { + return ((index) & 0x7) << 5; +} + +uint16 ChampionMan::getChampionPortraitY(uint16 index) { + return ((index) >> 3) * 29; +} + +int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) { + int val = 0; + for (uint16 i = 0; i < characterCount; ++i) { + val = (val << 4) + (string[i] - 'A'); + } + return val; +} ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { for (uint16 i = 0; i < _partyChampionCount; ++i) { diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 536d3676b2..dc0e11c6ab 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -228,7 +228,7 @@ public: _attributes &= ~flag; } } - void clearAttributes(){ _attributes = kChampionAttributNone; } + void clearAttributes() { _attributes = kChampionAttributNone; } uint16 getWounds() { return _wounds; } void setWoundsFlag(ChampionWound flag, bool value) { @@ -238,19 +238,24 @@ public: _wounds &= ~flag; } } - void clearWounds(){ _wounds = kChampionWoundNone; } + void clearWounds() { _wounds = kChampionWoundNone; } }; // @ CHAMPION_INCLUDING_PORTRAIT class ChampionMan { DMEngine *_vm; Champion _champions[4]; + + uint16 getChampionPortraitX(uint16 index); // @ M27_PORTRAIT_X + uint16 getChampionPortraitY(uint16 index); // @ M28_PORTRAIT_Y + + ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell + int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue public: uint16 _partyChampionCount; bool _partyDead; // @ G0303_B_PartyDead Thing _leaderHand; ChampionMan(DMEngine *vm); - ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell }; } -- cgit v1.2.3 From 793ebd32a394bac738c27ac448431ef2c9faed38 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 12:37:30 +0200 Subject: DM: Add WEAPON_INFO and related enums --- engines/dm/dungeonman.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 93261560f6..6d4653e5b3 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -9,6 +9,39 @@ namespace DM { +enum WeaponClass { +/* Class 0: SWING weapons */ + kWeaponClassSwingWeapon = 0, // @ C000_CLASS_SWING_WEAPON + /* Class 1 to 15: THROW weapons */ + kWeaponClassDaggerAndAxes = 2, // @ C002_CLASS_DAGGER_AND_AXES + kWeaponClassBowAmmunition = 10, // @ C010_CLASS_BOW_AMMUNITION + kWeaponClassSlingAmmunition = 11, // @ C011_CLASS_SLING_AMMUNITION + kWeaponClassPoisinDart = 12, // @ C012_CLASS_POISON_DART + /* Class 16 to 111: SHOOT weapons */ + kWeaponClassFirstBow = 16, // @ C016_CLASS_FIRST_BOW + kWeaponClassLastBow = 31, // @ C031_CLASS_LAST_BOW + kWeaponClassFirstSling = 32, // @ C032_CLASS_FIRST_SLING + kWeaponClassLastSling = 47, // @ C047_CLASS_LAST_SLING + /* Class 112 to 255: Magic and special weapons */ + kWeaponClassFirstMagicWeapon = 112 // @ C112_CLASS_FIRST_MAGIC_WEAPON +}; + +class WeaponInfo { + uint16 _attributes; /* Bits 15-13 Unreferenced */ +public: + byte _weight; + WeaponClass _class; + byte _strength; + byte _kineticEnergy; + + WeaponInfo(byte weight, WeaponClass wClass, byte strength, byte kineticEnergy, uint16 attributes) + : _attributes(attributes), _weight(weight), _class(wClass), _strength(strength), _kineticEnergy(kineticEnergy) {} + + uint16 getShootAttack() {return _attributes & 0xFF;} // @ M65_SHOOT_ATTACK + uint16 getProjectileAspectOrdinal() {return (_attributes >> 8) & 0x1F;} // @ M66_PROJECTILE_ASPECT_ORDINAL +}; // @ WEAPON_INFO + + int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL -- cgit v1.2.3 From ef95c50fbb7acfa97b10a009c1f65e060ba26815 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 12:44:41 +0200 Subject: DM: Add gWeaponInfo --- engines/dm/dungeonman.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/dungeonman.h | 16 +++++++++------- 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 4e09ce4896..3fd2e06a37 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -6,6 +6,54 @@ using namespace DM; +WeaponInfo gWeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo + /* { Weight, Class, Strength, KineticEnergy, Attributes } */ + WeaponInfo(1, (WeaponClass)130, 2, 0, 0x2000), /* EYE OF TIME */ + WeaponInfo(1, (WeaponClass)131, 2, 0, 0x2000), /* STORMRING */ + WeaponInfo(11, (WeaponClass)0, 8, 2, 0x2000), /* TORCH */ + WeaponInfo(12, (WeaponClass)112, 10, 80, 0x2028), /* FLAMITT */ + WeaponInfo(9, (WeaponClass)129, 16, 7, 0x2000), /* STAFF OF CLAWS */ + WeaponInfo(30, (WeaponClass)113, 49, 110, 0x0942), /* BOLT BLADE */ + WeaponInfo(47, (WeaponClass)0, 55, 20, 0x0900), /* FURY */ + WeaponInfo(24, (WeaponClass)255, 25, 10, 0x20FF), /* THE FIRESTAFF */ + WeaponInfo(5, (WeaponClass)2, 10, 19, 0x0200), /* DAGGER */ + WeaponInfo(33, (WeaponClass)0, 30, 8, 0x0900), /* FALCHION */ + WeaponInfo(32, (WeaponClass)0, 34, 10, 0x0900), /* SWORD */ + WeaponInfo(26, (WeaponClass)0, 38, 10, 0x0900), /* RAPIER */ + WeaponInfo(35, (WeaponClass)0, 42, 11, 0x0900), /* SABRE */ + WeaponInfo(36, (WeaponClass)0, 46, 12, 0x0900), /* SAMURAI SWORD */ + WeaponInfo(33, (WeaponClass)0, 50, 14, 0x0900), /* DELTA */ + WeaponInfo(37, (WeaponClass)0, 62, 14, 0x0900), /* DIAMOND EDGE */ + WeaponInfo(30, (WeaponClass)0, 48, 13, 0x0000), /* VORPAL BLADE */ + WeaponInfo(39, (WeaponClass)0, 58, 15, 0x0900), /* THE INQUISITOR */ + WeaponInfo(43, (WeaponClass)2, 49, 33, 0x0300), /* AXE */ + WeaponInfo(65, (WeaponClass)2, 70, 44, 0x0300), /* HARDCLEAVE */ + WeaponInfo(31, (WeaponClass)0, 32, 10, 0x2000), /* MACE */ + WeaponInfo(41, (WeaponClass)0, 42, 13, 0x2000), /* MACE OF ORDER */ + WeaponInfo(50, (WeaponClass)0, 60, 15, 0x2000), /* MORNINGSTAR */ + WeaponInfo(36, (WeaponClass)0, 19, 10, 0x2700), /* CLUB */ + WeaponInfo(110, (WeaponClass)0, 44, 22, 0x2600), /* STONE CLUB */ + WeaponInfo(10, (WeaponClass)20, 1, 50, 0x2032), /* BOW */ + WeaponInfo(28, (WeaponClass)30, 1, 180, 0x2078), /* CROSSBOW */ + WeaponInfo(2, (WeaponClass)10, 2, 10, 0x0100), /* ARROW */ + WeaponInfo(2, (WeaponClass)10, 2, 28, 0x0500), /* SLAYER */ + WeaponInfo(19, (WeaponClass)39, 5, 20, 0x2032), /* SLING */ + WeaponInfo(10, (WeaponClass)11, 6, 18, 0x2000), /* ROCK */ + WeaponInfo(3, (WeaponClass)12, 7, 23, 0x0800), /* POISON DART */ + WeaponInfo(1, (WeaponClass)1, 3, 19, 0x0A00), /* THROWING STAR */ + WeaponInfo(8, (WeaponClass)0, 4, 4, 0x2000), /* STICK */ + WeaponInfo(26, (WeaponClass)129, 12, 4, 0x2000), /* STAFF */ + WeaponInfo(1, (WeaponClass)130, 0, 0, 0x2000), /* WAND */ + WeaponInfo(2, (WeaponClass)140, 1, 20, 0x2000), /* TEOWAND */ + WeaponInfo(35, (WeaponClass)128, 18, 6, 0x2000), /* YEW STAFF */ + WeaponInfo(29, (WeaponClass)159, 0, 4, 0x2000), /* STAFF OF MANAR */ + WeaponInfo(21, (WeaponClass)131, 0, 3, 0x2000), /* SNAKE STAFF */ + WeaponInfo(33, (WeaponClass)136, 0, 7, 0x2000), /* THE CONDUIT */ + WeaponInfo(8, (WeaponClass)132, 3, 1, 0x2000), /* DRAGON SPIT */ + WeaponInfo(18, (WeaponClass)131, 9, 4, 0x2000), /* SCEPTRE OF LYF */ + WeaponInfo(8, (WeaponClass)192, 1, 1, 0x2000), /* HORN OF FEAR */ + WeaponInfo(30, (WeaponClass)26, 1, 220, 0x207D), /* SPEEDBOW */ + WeaponInfo(36, (WeaponClass)255, 100, 50, 0x20FF)}; /* THE FIRESTAFF */ CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo /* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo, diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 6d4653e5b3..93705721f6 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -27,15 +27,17 @@ enum WeaponClass { }; class WeaponInfo { - uint16 _attributes; /* Bits 15-13 Unreferenced */ + public: - byte _weight; + uint16 _weight; WeaponClass _class; - byte _strength; - byte _kineticEnergy; - - WeaponInfo(byte weight, WeaponClass wClass, byte strength, byte kineticEnergy, uint16 attributes) - : _attributes(attributes), _weight(weight), _class(wClass), _strength(strength), _kineticEnergy(kineticEnergy) {} + uint16 _strength; + uint16 _kineticEnergy; +private: + uint16 _attributes; /* Bits 15-13 Unreferenced */ +public: + WeaponInfo(uint16 weight, WeaponClass wClass, uint16 strength, uint16 kineticEnergy, uint16 attributes) + : _weight(weight), _class(wClass), _strength(strength), _kineticEnergy(kineticEnergy), _attributes(attributes) {} uint16 getShootAttack() {return _attributes & 0xFF;} // @ M65_SHOOT_ATTACK uint16 getProjectileAspectOrdinal() {return (_attributes >> 8) & 0x1F;} // @ M66_PROJECTILE_ASPECT_ORDINAL -- cgit v1.2.3 From 21be32bb17530ef833a6d60b9a685007a209fac0 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 12:53:52 +0200 Subject: DM: Add ArmourInfo and realted enums --- engines/dm/dungeonman.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 93705721f6..f5943cd6be 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -8,6 +8,25 @@ namespace DM { + +enum ArmourAttribute { + kArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD + kArmourAttributeSharpDefense = 0x0007, // @ MASK0x0007_SHARP_DEFENSE +}; + +class ArmourInfo { +public: + uint16 _weight; + uint16 _defense; +private: + uint16 _attributes; +public: + ArmourInfo(uint16 weight, uint16 defense) + :_weight(weight), _defense(defense) {} + + uint16 getAttribute(ArmourAttribute attribute) { return _attributes & attribute; } + void setAttribute(ArmourAttribute attribute) { _attributes |= attribute; } +}; // @ ARMOUR_INFO enum WeaponClass { /* Class 0: SWING weapons */ -- cgit v1.2.3 From 5874a7fb56d3e3a0ee1d0cb3e9d243f3080530c3 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 12:58:34 +0200 Subject: DM: Add G0239_as_Graphic559_ArmourInfo --- engines/dm/dungeonman.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/dungeonman.h | 8 +++++-- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 3fd2e06a37..723b6a11fc 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -6,6 +6,67 @@ using namespace DM; +ArmourInfo gArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo +/* { Weight, Defense, Attributes, Unreferenced } */ + ArmourInfo(3, 5, 0x01), /* CAPE */ + ArmourInfo(4, 10, 0x01), /* CLOAK OF NIGHT */ + ArmourInfo(3, 4, 0x01), /* BARBARIAN HIDE */ + ArmourInfo(6, 5, 0x02), /* SANDALS */ + ArmourInfo(16, 25, 0x04), /* LEATHER BOOTS */ + ArmourInfo(4, 5, 0x00), /* ROBE */ + ArmourInfo(4, 5, 0x00), /* ROBE */ + ArmourInfo(3, 7, 0x01), /* FINE ROBE */ + ArmourInfo(3, 7, 0x01), /* FINE ROBE */ + ArmourInfo(4, 6, 0x01), /* KIRTLE */ + ArmourInfo(2, 4, 0x00), /* SILK SHIRT */ + ArmourInfo(4, 5, 0x01), /* TABARD */ + ArmourInfo(5, 7, 0x01), /* GUNNA */ + ArmourInfo(3, 11, 0x02), /* ELVEN DOUBLET */ + ArmourInfo(3, 13, 0x02), /* ELVEN HUKE */ + ArmourInfo(4, 13, 0x02), /* ELVEN BOOTS */ + ArmourInfo(6, 17, 0x03), /* LEATHER JERKIN */ + ArmourInfo(8, 20, 0x03), /* LEATHER PANTS */ + ArmourInfo(14, 20, 0x03), /* SUEDE BOOTS */ + ArmourInfo(6, 12, 0x02), /* BLUE PANTS */ + ArmourInfo(5, 9, 0x01), /* TUNIC */ + ArmourInfo(5, 8, 0x01), /* GHI */ + ArmourInfo(5, 9, 0x01), /* GHI TROUSERS */ + ArmourInfo(4, 1, 0x04), /* CALISTA */ + ArmourInfo(6, 5, 0x04), /* CROWN OF NERRA */ + ArmourInfo(11, 12, 0x05), /* BEZERKER HELM */ + ArmourInfo(14, 17, 0x05), /* HELMET */ + ArmourInfo(15, 20, 0x05), /* BASINET */ + ArmourInfo(11, 22, 0x85), /* BUCKLER */ + ArmourInfo(10, 16, 0x82), /* HIDE SHIELD */ + ArmourInfo(14, 20, 0x83), /* WOODEN SHIELD */ + ArmourInfo(21, 35, 0x84), /* SMALL SHIELD */ + ArmourInfo(65, 35, 0x05), /* MAIL AKETON */ + ArmourInfo(53, 35, 0x05), /* LEG MAIL */ + ArmourInfo(52, 70, 0x07), /* MITHRAL AKETON */ + ArmourInfo(41, 55, 0x07), /* MITHRAL MAIL */ + ArmourInfo(16, 25, 0x06), /* CASQUE 'N COIF */ + ArmourInfo(16, 30, 0x06), /* HOSEN */ + ArmourInfo(19, 40, 0x07), /* ARMET */ + ArmourInfo(120, 65, 0x04), /* TORSO PLATE */ + ArmourInfo(80, 56, 0x04), /* LEG PLATE */ + ArmourInfo(28, 37, 0x05), /* FOOT PLATE */ + ArmourInfo(34, 56, 0x84), /* LARGE SHIELD */ + ArmourInfo(17, 62, 0x05), /* HELM OF LYTE */ + ArmourInfo(108, 125, 0x04), /* PLATE OF LYTE */ + ArmourInfo(72, 90, 0x04), /* POLEYN OF LYTE */ + ArmourInfo(24, 50, 0x05), /* GREAVE OF LYTE */ + ArmourInfo(30, 85, 0x84), /* SHIELD OF LYTE */ + ArmourInfo(35, 76, 0x04), /* HELM OF DARC */ + ArmourInfo(141, 160, 0x04), /* PLATE OF DARC */ + ArmourInfo(90, 101, 0x04), /* POLEYN OF DARC */ + ArmourInfo(31, 60, 0x05), /* GREAVE OF DARC */ + ArmourInfo(40, 100, 0x84), /* SHIELD OF DARC */ + ArmourInfo(14, 54, 0x06), /* DEXHELM */ + ArmourInfo(57, 60, 0x07), /* FLAMEBAIN */ + ArmourInfo(81, 88, 0x04), /* POWERTOWERS */ + ArmourInfo(3, 16, 0x02), /* BOOTS OF SPEED */ + ArmourInfo(2, 3, 0x03)}; /* HALTER */ + WeaponInfo gWeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo /* { Weight, Class, Strength, KineticEnergy, Attributes } */ WeaponInfo(1, (WeaponClass)130, 2, 0, 0x2000), /* EYE OF TIME */ diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index f5943cd6be..645dd2f24a 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -21,13 +21,15 @@ public: private: uint16 _attributes; public: - ArmourInfo(uint16 weight, uint16 defense) - :_weight(weight), _defense(defense) {} + ArmourInfo(uint16 weight, uint16 defense, uint16 attributes) + :_weight(weight), _defense(defense), _attributes(attributes) {} uint16 getAttribute(ArmourAttribute attribute) { return _attributes & attribute; } void setAttribute(ArmourAttribute attribute) { _attributes |= attribute; } }; // @ ARMOUR_INFO +extern ArmourInfo gArmourInfo[58]; + enum WeaponClass { /* Class 0: SWING weapons */ kWeaponClassSwingWeapon = 0, // @ C000_CLASS_SWING_WEAPON @@ -62,6 +64,8 @@ public: uint16 getProjectileAspectOrdinal() {return (_attributes >> 8) & 0x1F;} // @ M66_PROJECTILE_ASPECT_ORDINAL }; // @ WEAPON_INFO +extern WeaponInfo gWeaponInfo[46]; + int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL -- cgit v1.2.3 From c96f24d8fe265306619282685ee9e8f6ac8aac6a Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 13:32:43 +0200 Subject: DM: Add G0241_auc_Graphic559_JunkInfo --- engines/dm/dungeonman.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/dungeonman.h | 1 + 2 files changed, 55 insertions(+) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 723b6a11fc..9ec9830b15 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -5,6 +5,60 @@ using namespace DM; +uint16 gJunkInfo[53] = { // @ G0241_auc_Graphic559_JunkInfo + 1, /* COMPASS */ + 3, /* WATERSKIN */ + 2, /* JEWEL SYMAL */ + 2, /* ILLUMULET */ + 4, /* ASHES */ + 15, /* BONES */ + 1, /* COPPER COIN */ + 1, /* SILVER COIN */ + 1, /* GOLD COIN */ + 2, /* IRON KEY */ + 1, /* KEY OF B */ + 1, /* SOLID KEY */ + 1, /* SQUARE KEY */ + 1, /* TOURQUOISE KEY */ + 1, /* CROSS KEY */ + 1, /* ONYX KEY */ + 1, /* SKELETON KEY */ + 1, /* GOLD KEY */ + 1, /* WINGED KEY */ + 1, /* TOPAZ KEY */ + 1, /* SAPPHIRE KEY */ + 1, /* EMERALD KEY */ + 1, /* RUBY KEY */ + 1, /* RA KEY */ + 1, /* MASTER KEY */ + 81, /* BOULDER */ + 2, /* BLUE GEM */ + 3, /* ORANGE GEM */ + 2, /* GREEN GEM */ + 4, /* APPLE */ + 4, /* CORN */ + 3, /* BREAD */ + 8, /* CHEESE */ + 5, /* SCREAMER SLICE */ + 11, /* WORM ROUND */ + 4, /* DRUMSTICK */ + 6, /* DRAGON STEAK */ + 2, /* GEM OF AGES */ + 3, /* EKKHARD CROSS */ + 2, /* MOONSTONE */ + 2, /* THE HELLION */ + 2, /* PENDANT FERAL */ + 6, /* MAGICAL BOX */ + 9, /* MAGICAL BOX */ + 3, /* MIRROR OF DAWN */ + 10, /* ROPE */ + 1, /* RABBIT'S FOOT */ + 0, /* CORBAMITE */ + 1, /* CHOKER */ + 1, /* LOCK PICKS */ + 2, /* MAGNIFIER */ + 0, /* ZOKATHRA SPELL */ + 8}; /* BONES */ ArmourInfo gArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo /* { Weight, Defense, Attributes, Unreferenced } */ diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 645dd2f24a..2502a385e3 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -8,6 +8,7 @@ namespace DM { +extern uint16 gJunkInfo[53]; enum ArmourAttribute { kArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD -- cgit v1.2.3 From d6e90e8a9090ad29406d25ee317332a5500a31de Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 15:01:25 +0200 Subject: DM: Add F0140_DUNGEON_GetObjectWeight and types for Potions, Armour, Weapons and Junk --- engines/dm/dungeonman.cpp | 48 +++++++++++++++++++++++++++++++++++++-- engines/dm/dungeonman.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 2 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 9ec9830b15..fa1ec5cab5 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -3,7 +3,8 @@ #include "dungeonman.h" -using namespace DM; + +namespace DM { uint16 gJunkInfo[53] = { // @ G0241_auc_Graphic559_JunkInfo 1, /* COMPASS */ @@ -529,9 +530,10 @@ void DungeonMan::loadDungeonFile() { _dunData.thingsData[thingType][i][4] = dunDataStream.readUint16BE(); } } else { - for (uint16 i = 0; i < thingCount; ++i) + for (uint16 i = 0; i < thingCount; ++i) { for (uint16 j = 0; j < thingStoreWordCount; ++j) _dunData.thingsData[thingType][i][j] = dunDataStream.readUint16BE(); + } } if (_messages.newGame) { @@ -993,3 +995,45 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { } *destString = ((type == kTextTypeInscription) ? 0x81 : '\0'); } + + +uint16 DungeonMan::getObjectWeight(Thing thing) { + if (thing == Thing::thingNone) + return 0; + switch (thing.getType()) { + case kWeaponThingType: + return gWeaponInfo[Weapon(getThingData(thing)).getType()]._weight; + case kArmourThingType: + return gArmourInfo[Armour(getThingData(thing)).getType()]._weight; + case kJunkThingType: { + Junk junk = getThingData(thing); + uint16 weight = gJunkInfo[junk.getType()]; + if (junk.getType() == kJunkTypeWaterskin) + weight += junk.getChargeCount() * 2; + return weight; + } + case kContainerThingType: { + uint16 weight = 50; + Container container = getThingData(thing); + Thing slotThing = container.getNextContainedThing(); + while (slotThing != Thing::thingEndOfList) { + weight += getObjectWeight(slotThing); + slotThing = getNextThing(slotThing); + } + return weight; + } + case kPotionThingType: + if (Junk(getThingData(thing)).getType() == kPotionTypeEmptyFlask) { + return 1; + } else { + return 3; + } + case kScrollThingType: + return 1; + } + + assert(false); // this should never be taken + return 0; // dummy +} + +} \ No newline at end of file diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 2502a385e3..c13d460e8d 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -257,21 +257,43 @@ public: Thing getNextThing() { return nextThing; } }; // @ GROUP +enum WeaponType { + kWeaponTypeTorch = 2, // @ C02_WEAPON_TORCH + kWeaponTypeDagger = 8, // @ C08_WEAPON_DAGGER + kWeaponTypeFalchion = 9, // @ C09_WEAPON_FALCHION + kWeaponTypeSword = 10, // @ C10_WEAPON_SWORD + kWeaponTypeClub = 23, // @ C23_WEAPON_CLUB + kWeaponTypeStoneClub = 24, // @ C24_WEAPON_STONE_CLUB + kWeaponTypeArrow = 27, // @ C27_WEAPON_ARROW + kWeaponTypeSlayer = 28, // @ C28_WEAPON_SLAYER + kWeaponTypeRock = 30, // @ C30_WEAPON_ROCK + kWeaponTypePoisonDart = 31, // @ C31_WEAPON_POISON_DART + kWeaponTypeThrowingStar = 32 // @ C32_WEAPON_THROWING_STAR +}; class Weapon { Thing nextThing; uint16 desc; public: Weapon(uint16 *rawDat) : nextThing(rawDat[0]), desc(rawDat[1]) {} + WeaponType getType() { return (WeaponType)(desc & 0x7F); } Thing getNextThing() { return nextThing; } }; // @ WEAPON +enum ArmourType { + kArmourTypeWoodenShield = 30, // @ C30_ARMOUR_WOODEN_SHIELD + kArmourTypeArmet = 38, // @ C38_ARMOUR_ARMET + kArmourTypeTorsoPlate = 39, // @ C39_ARMOUR_TORSO_PLATE + kArmourTypeLegPlate = 40, // @ C40_ARMOUR_LEG_PLATE + kArmourTypeFootPlate = 41 // @ C41_ARMOUR_FOOT_PLATE +}; class Armour { Thing nextThing; uint16 attributes; public: Armour(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} + ArmourType getType() { return (ArmourType)(attributes & 0x7F); } Thing getNextThing() { return nextThing; } }; // @ ARMOUR @@ -287,12 +309,28 @@ public: Thing getNextThing() { return nextThing; } }; // @ SCROLL +enum PotionType { + kPotionTypeVen = 3, // @ C03_POTION_VEN_POTION, + kPotionTypeRos = 6, // @ C06_POTION_ROS_POTION, + kPotionTypeKu = 7, // @ C07_POTION_KU_POTION, + kPotionTypeDane = 8, // @ C08_POTION_DANE_POTION, + kPotionTypeNeta = 9, // @ C09_POTION_NETA_POTION, + kPotionTypeAntivenin = 10, // @ C10_POTION_ANTIVENIN, + kPotionTypeMon = 11, // @ C11_POTION_MON_POTION, + kPotionTypeYa = 12, // @ C12_POTION_YA_POTION, + kPotionTypeEe = 13, // @ C13_POTION_EE_POTION, + kPotionTypeVi = 14, // @ C14_POTION_VI_POTION, + kPotionTypeWaterFlask = 15, // @ C15_POTION_WATER_FLASK, + kPotionTypeFulBomb = 19, // @ C19_POTION_FUL_BOMB, + kPotionTypeEmptyFlask = 20 // @ C20_POTION_EMPTY_FLASK, +}; class Potion { Thing nextThing; uint16 attributes; public: Potion(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} + PotionType getType() { return (PotionType)((attributes >> 8) & 0x7F); } Thing getNextThing() { return nextThing; } }; // @ POTION @@ -303,15 +341,32 @@ class Container { public: Container(uint16 *rawDat) : nextThing(rawDat[0]), nextContainedThing(rawDat[1]), type(rawDat[2]) {} + Thing getNextContainedThing() { return nextContainedThing; } Thing getNextThing() { return nextThing; } }; // @ CONTAINER +enum JunkType { + kJunkTypeWaterskin = 1, // @ C01_JUNK_WATERSKIN, + kJunkTypeBones = 5, // @ C05_JUNK_BONES, + kJunkTypeBoulder = 25, // @ C25_JUNK_BOULDER, + kJunkTypeScreamerSlice = 33, // @ C33_JUNK_SCREAMER_SLICE, + kJunkTypeWormRound = 34, // @ C34_JUNK_WORM_ROUND, + kJunkTypeDrumstickShank = 35, // @ C35_JUNK_DRUMSTICK_SHANK, + kJunkTypeDragonSteak = 36, // @ C36_JUNK_DRAGON_STEAK, + kJunkTypeMagicalBoxBlue = 42, // @ C42_JUNK_MAGICAL_BOX_BLUE, + kJunkTypeMagicalBoxGreen = 43, // @ C43_JUNK_MAGICAL_BOX_GREEN, + kJunkTypeZokathra = 51 // @ C51_JUNK_ZOKATHRA, +}; + class Junk { Thing nextThing; uint16 attributes; public: Junk(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} + JunkType getType() { return (JunkType)(attributes & 0x7F); } + uint16 getChargeCount() { return (attributes >> 14) & 0x3; } + Thing getNextThing() { return nextThing; } }; // @ JUNK @@ -499,6 +554,8 @@ public: void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect void decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText + uint16 getObjectWeight(Thing thing);// @ F0140_DUNGEON_GetObjectWeight + uint32 _rawDunFileDataSize; // @ probably NONE byte *_rawDunFileData; // @ ??? DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader -- cgit v1.2.3 From 40e4cceb3feb9da805f2c2dde47802b404a7e5cc Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 16:23:44 +0200 Subject: DM: Add F0368_COMMAND_SetLeader, G0411_i_LeaderIndex, G0299_ui_CandidateChampionOrdinal --- engines/dm/champion.cpp | 4 +++- engines/dm/champion.h | 14 ++++++++------ engines/dm/eventman.cpp | 29 +++++++++++++++++++++++++++++ engines/dm/eventman.h | 4 ++++ 4 files changed, 44 insertions(+), 7 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 3aabfb0fa5..5ba529d263 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -3,7 +3,9 @@ namespace DM { -ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {} +ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { + _leaderIndex = kChampionNone; +} uint16 ChampionMan::getChampionPortraitX(uint16 index) { return ((index) & 0x7) << 5; diff --git a/engines/dm/champion.h b/engines/dm/champion.h index dc0e11c6ab..353fcf0194 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -182,6 +182,9 @@ class Skill { class Champion { Thing _slots[30]; Skill _skills[20]; + uint16 _attributes; + byte _statistics[7][3]; + uint16 _wounds; public: char _name[8]; char _title[20]; @@ -195,8 +198,6 @@ public: uint16 _poisonEventCount; int16 _enableActionEventIndex; int16 _hideDamageReceivedIndex; - uint16 _attributes; - uint16 _wounds; int16 _currHealth; int16 _maxHealth; int16 _currStamina; @@ -206,7 +207,6 @@ public: int16 _actionDefense; int16 _food; int16 _water; - byte _statistics[7][3]; uint16 _load; int16 _shieldDefense; byte Portrait[464]; // 32 x 29 pixel portrait @@ -243,7 +243,6 @@ public: class ChampionMan { DMEngine *_vm; - Champion _champions[4]; uint16 getChampionPortraitX(uint16 index); // @ M27_PORTRAIT_X uint16 getChampionPortraitY(uint16 index); // @ M28_PORTRAIT_Y @@ -251,9 +250,12 @@ class ChampionMan { ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue public: - uint16 _partyChampionCount; + Champion _champions[4]; + uint16 _partyChampionCount; // @ G0305_ui_PartyChampionCount bool _partyDead; // @ G0303_B_PartyDead - Thing _leaderHand; + Thing _leaderHand; // @ G0414_T_LeaderHandObject + ChampionIndex _leaderIndex; // @ G0411_i_LeaderIndex + uint16 _candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal ChampionMan(DMEngine *vm); }; diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 626887ebab..8728dd76f6 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -420,5 +420,34 @@ void EventManager::commandMoveParty(CommandType cmdType) { // MISSING CODE: Lots of code } +void EventManager::commandSetLeader(ChampionIndex index) { + ChampionMan &cm = *_vm->_championMan; + ChampionIndex leaderIndex; + + if ((cm._leaderIndex == index) || ((index != kChampionNone) && !cm._champions[index]._currHealth)) + return; + + if (cm._leaderIndex != kChampionNone) { + leaderIndex = cm._leaderIndex; + cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeLoad, true); + cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeNameTitle, true); + cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHand); + cm._leaderIndex = kChampionNone; + warning("MISSING CODE: F0292_CHAMPION_DrawState"); + } + if (index == kChampionNone) { + cm._leaderIndex = kChampionNone; + return; + } + cm._leaderIndex = index; + Champion *champion = &cm._champions[cm._leaderIndex]; + champion->_dir = _vm->_dungeonMan->_currMap.partyDir; + cm._champions[index]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHand); + if (indexToOrdinal(index) != cm._candidateChampionOrdinal) { + champion->setAttributeFlag(kChampionAttributeIcon, true); + champion->setAttributeFlag(kChampionAttributeNameTitle, true); + warning("MISSING CODE: F0292_CHAMPION_DrawState"); + } +} }; // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index ed6bba20b1..8984b02f27 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -3,7 +3,9 @@ #include "common/events.h" #include "common/queue.h" + #include "gfx.h" +#include "champion.h" namespace DM { @@ -208,6 +210,8 @@ public: void processClick(Common::Point mousePos, MouseButton button); // @ F0359_COMMAND_ProcessClick_CPSC CommandType getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC void processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC + + void commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader }; } -- cgit v1.2.3 From a2328b9eb2867c4b6ce78c4e4bab0c7f3a6cb620 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 16:32:31 +0200 Subject: DM: Add G0508_B_RefreshActionArea --- engines/dm/menus.h | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/dm/menus.h b/engines/dm/menus.h index d4ea2d68ba..c1ceddd8ab 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -8,6 +8,7 @@ namespace DM { class MenuMan { DMEngine *_vm; public: + bool _shouldRefreshActionArea; // @ G0508_B_RefreshActionArea MenuMan(DMEngine *vm); void drawMovementArrows(); -- cgit v1.2.3 From 7a255919994af82f4a09915f5586f9756ca0348a Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 17:18:01 +0200 Subject: DM: Rearrange main parts to better align with the original --- engines/dm/dm.cpp | 80 ++++++++++++++++++++++++++++--------------------- engines/dm/dm.h | 4 ++- engines/dm/gfx.h | 5 ++-- engines/dm/loadsave.cpp | 1 + 4 files changed, 53 insertions(+), 37 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 77d7ed012a..94f9f30420 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -72,8 +72,43 @@ DMEngine::~DMEngine() { DebugMan.clearAllDebugChannels(); } +void DMEngine::initializeGame() { + _displayMan->loadGraphics(); + // DUMMY CODE: next line + _displayMan->loadPalette(gPalCredits); + + _eventMan->initMouse(); + + while (_loadsaveMan->loadgame() != kLoadgameSuccess) { + // MISSING CODE: F0441_STARTEND_ProcessEntrance + } + + _displayMan->loadFloorSet(kFloorSetStone); + _displayMan->loadWallSet(kWallSetStone); + + startGame(); + warning("MISSING CODE: F0267_MOVE_GetMoveResult_CPSCE (if newGame)"); + _eventMan->showMouse(true); + warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); +} + + +void DMEngine::startGame() { + _eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface; + _eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement; + // TODO:(next 2 lines) move to F0003_MAIN_ProcessNewPartyMap_CPSE + _dungeonMan->setCurrentMapAndPartyMap(0); + _displayMan->loadCurrentMapGraphics(); + + + _menuMan->drawMovementArrows(); + _gameTimeTicking = true; + + // MISSING CODE: Lot of stuff +} Common::Error DMEngine::run() { + // scummvm/engine specific initGraphics(320, 200, false); _console = new Console(this); _displayMan = new DisplayMan(this); @@ -82,55 +117,32 @@ Common::Error DMEngine::run() { _menuMan = new MenuMan(this); _championMan = new ChampionMan(this); _loadsaveMan = new LoadsaveMan(this); - _displayMan->setUpScreens(320, 200); - _displayMan->loadGraphics(); - - _dungeonMan->loadDungeonFile(); - _dungeonMan->setCurrentMapAndPartyMap(0); - - - _displayMan->loadCurrentMapGraphics(); - _displayMan->loadPalette(gPalCredits); - - _eventMan->initMouse(); - _eventMan->showMouse(true); - - _loadsaveMan->loadgame(); - - startGame(); + initializeGame(); // @ F0463_START_InitializeGame_CPSADEF + while (true) { + gameloop(); + // MISSING CODE: F0444_STARTEND_Endgame(G0303_B_PartyDead); + } + return Common::kNoError; +} +void DMEngine::gameloop() { while (true) { _stopWaitingForPlayerInput = false; //do { - _eventMan->processInput(); - _eventMan->processCommandQueue(); + _eventMan->processInput(); + _eventMan->processCommandQueue(); //} while (!_stopWaitingForPlayerInput || !_gameTimeTicking); _displayMan->clearScreen(kColorBlack); _displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY); - // DUMMY CODE: + // DUMMY CODE: next line _menuMan->drawMovementArrows(); _displayMan->updateScreen(); _system->delayMillis(10); } - - - return Common::kNoError; -} - - -void DMEngine::startGame() { - _eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface; - _eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement; - - - _menuMan->drawMovementArrows(); - _gameTimeTicking = true; - - // MISSING CODE: Lot of stuff } } // End of namespace DM diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 67d968a7f9..852b210ff0 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -84,7 +84,9 @@ public: DMEngine(OSystem *syst); ~DMEngine(); - virtual Common::Error run(); + virtual Common::Error run(); // @ main + void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF + void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF private: Console *_console; diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index cf06f1c7eb..241d45bfda 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -245,8 +245,6 @@ class DisplayMan { void drawSquareD0R(direction dir, int16 posX, int16 posY); // @ F0126_DUNGEONVIEW_DrawSquareD0R void drawSquareD0C(direction dir, int16 posX, int16 posY); // @ F0127_DUNGEONVIEW_DrawSquareD0C - void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet - void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet void applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors @@ -258,6 +256,9 @@ public: DisplayMan(DMEngine *dmEngine); ~DisplayMan(); + void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet + void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet + void setUpScreens(uint16 width, uint16 height); void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader, F0460_START_InitializeGraphicData void loadCurrentMapGraphics(); diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index e58b746060..5518e7927d 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -22,6 +22,7 @@ LoadgameResponse LoadsaveMan::loadgame() { assert(false); // MISSING CODE: load game } + _vm->_dungeonMan->loadDungeonFile(); if (newGame) { -- cgit v1.2.3 From ea33eb8c87cef8ceeb53ce370c527a79553aa1e2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 18 Jun 2016 17:48:48 +0200 Subject: DM: Some renaming --- engines/dm/champion.h | 6 +- engines/dm/dm.h | 22 ++-- engines/dm/dungeonman.cpp | 262 +++++++++++++++++++------------------- engines/dm/dungeonman.h | 316 +++++++++++++++++++++++----------------------- engines/dm/gfx.cpp | 16 +-- engines/dm/loadsave.cpp | 2 +- 6 files changed, 312 insertions(+), 312 deletions(-) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 353fcf0194..5844760c05 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -175,8 +175,8 @@ enum ChampionAction { class Skill { - int TemporaryExperience; - long Experience; + int _temporaryExperience; + long _experience; }; // @ SKILL class Champion { @@ -209,7 +209,7 @@ public: int16 _water; uint16 _load; int16 _shieldDefense; - byte Portrait[464]; // 32 x 29 pixel portrait + byte _portrait[464]; // 32 x 29 pixel portrait Thing getSlot(ChampionSlot slot) { return _slots[slot]; } void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 852b210ff0..888e6313be 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -52,24 +52,24 @@ enum ThingType { }; // @ C[00..15]_THING_TYPE_... class Thing { - uint16 data; + uint16 _data; public: - static const Thing thingNone; - static const Thing thingEndOfList; + static const Thing _thingNone; + static const Thing _thingEndOfList; - Thing() : data(0) {} + Thing() : _data(0) {} Thing(uint16 d) { set(d); } void set(uint16 d) { - data = d; + _data = d; } - byte getCell() const { return data >> 14; } - ThingType getType() const { return (ThingType)((data >> 10) & 0xF); } - uint16 getIndex() const { return data & 0x1FF; } - uint16 toUint16() const { return data; } // I don't like 'em cast operators - bool operator==(const Thing &rhs) const { return data == rhs.data; } - bool operator!=(const Thing &rhs) const { return data != rhs.data; } + byte getCell() const { return _data >> 14; } + ThingType getType() const { return (ThingType)((_data >> 10) & 0xF); } + uint16 getIndex() const { return _data & 0x1FF; } + uint16 toUint16() const { return _data; } // I don't like 'em cast operators + bool operator==(const Thing &rhs) const { return _data == rhs._data; } + bool operator!=(const Thing &rhs) const { return _data != rhs._data; } }; // @ THING diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index fa1ec5cab5..80fb73331d 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -216,17 +216,17 @@ void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, in } DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) { - _dunData.columCount = 0; - _dunData.eventMaximumCount = 0; + _dunData._columCount = 0; + _dunData._eventMaximumCount = 0; - _dunData.mapsFirstColumnIndex = nullptr; - _dunData.columnsCumulativeSquareThingCount = nullptr; - _dunData.squareFirstThings = nullptr; - _dunData.textData = nullptr; - _dunData.mapData = nullptr; + _dunData._mapsFirstColumnIndex = nullptr; + _dunData._columnsCumulativeSquareThingCount = nullptr; + _dunData._squareFirstThings = nullptr; + _dunData._textData = nullptr; + _dunData._mapData = nullptr; for (int i = 0; i < 16; i++) - _dunData.thingsData[i] = nullptr; + _dunData._thingsData[i] = nullptr; _currMap.partyDir = kDirNorth; _currMap.partyPosX = 0; @@ -246,18 +246,18 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL _rawDunFileDataSize = 0; _rawDunFileData = nullptr; - _fileHeader.dungeonId = 0; - _fileHeader.ornamentRandomSeed = 0; - _fileHeader.rawMapDataSize = 0; - _fileHeader.mapCount = 0; - _fileHeader.textDataWordCount = 0; - _fileHeader.partyStartDir = kDirNorth; - _fileHeader.partyStartPosX = 0; - _fileHeader.partyStartPosY = 0; - _fileHeader.squareFirstThingCount = 0; + _fileHeader._dungeonId = 0; + _fileHeader._ornamentRandomSeed = 0; + _fileHeader._rawMapDataSize = 0; + _fileHeader._mapCount = 0; + _fileHeader._textDataWordCount = 0; + _fileHeader._partyStartDir = kDirNorth; + _fileHeader._partyStartPosX = 0; + _fileHeader._partyStartPosY = 0; + _fileHeader._squareFirstThingCount = 0; for (int i = 0; i < 16; i++) - _fileHeader.thingCounts[i] = 0; + _fileHeader._thingCounts[i] = 0; _maps = nullptr; _rawMapData = nullptr; @@ -275,15 +275,15 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL DungeonMan::~DungeonMan() { delete[] _rawDunFileData; delete[] _maps; - delete[] _dunData.mapsFirstColumnIndex; - delete[] _dunData.columnsCumulativeSquareThingCount; - delete[] _dunData.squareFirstThings; - delete[] _dunData.textData; - delete[] _dunData.mapData; + delete[] _dunData._mapsFirstColumnIndex; + delete[] _dunData._columnsCumulativeSquareThingCount; + delete[] _dunData._squareFirstThings; + delete[] _dunData._textData; + delete[] _dunData._mapData; for (uint16 i = 0; i < 16; ++i) { - if (_dunData.thingsData[i]) - delete[] _dunData.thingsData[i][0]; - delete[] _dunData.thingsData[i]; + if (_dunData._thingsData[i]) + delete[] _dunData._thingsData[i][0]; + delete[] _dunData._thingsData[i]; } } @@ -384,8 +384,8 @@ unsigned char gThingDataWordCount[16] = { 2 /* Explosion */ }; // @ G0235_auc_Graphic559_ThingDataByteCount -const Thing Thing::thingNone(0); -const Thing Thing::thingEndOfList(0xFFFE); +const Thing Thing::_thingNone(0); +const Thing Thing::_thingEndOfList(0xFFFE); void DungeonMan::loadDungeonFile() { @@ -395,152 +395,152 @@ void DungeonMan::loadDungeonFile() { Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO); // initialize _fileHeader - _fileHeader.dungeonId = _fileHeader.ornamentRandomSeed = dunDataStream.readUint16BE(); - _fileHeader.rawMapDataSize = dunDataStream.readUint16BE(); - _fileHeader.mapCount = dunDataStream.readByte(); + _fileHeader._dungeonId = _fileHeader._ornamentRandomSeed = dunDataStream.readUint16BE(); + _fileHeader._rawMapDataSize = dunDataStream.readUint16BE(); + _fileHeader._mapCount = dunDataStream.readByte(); dunDataStream.readByte(); // discard 1 byte - _fileHeader.textDataWordCount = dunDataStream.readUint16BE(); + _fileHeader._textDataWordCount = dunDataStream.readUint16BE(); uint16 partyPosition = dunDataStream.readUint16BE(); - _fileHeader.partyStartDir = (direction)((partyPosition >> 10) & 3); - _fileHeader.partyStartPosY = (partyPosition >> 5) & 0x1F; - _fileHeader.partyStartPosX = (partyPosition >> 0) & 0x1F; - _fileHeader.squareFirstThingCount = dunDataStream.readUint16BE(); + _fileHeader._partyStartDir = (direction)((partyPosition >> 10) & 3); + _fileHeader._partyStartPosY = (partyPosition >> 5) & 0x1F; + _fileHeader._partyStartPosX = (partyPosition >> 0) & 0x1F; + _fileHeader._squareFirstThingCount = dunDataStream.readUint16BE(); for (uint16 i = 0; i < kThingTypeTotal; ++i) - _fileHeader.thingCounts[i] = dunDataStream.readUint16BE(); + _fileHeader._thingCounts[i] = dunDataStream.readUint16BE(); // init party position and mapindex if (_messages.newGame) { - _currMap.partyDir = _fileHeader.partyStartDir; - _currMap.partyPosX = _fileHeader.partyStartPosX; - _currMap.partyPosY = _fileHeader.partyStartPosY; + _currMap.partyDir = _fileHeader._partyStartDir; + _currMap.partyPosX = _fileHeader._partyStartPosX; + _currMap.partyPosY = _fileHeader._partyStartPosY; _currMap.currPartyMapIndex = 0; } // load map data delete[] _maps; - _maps = new Map[_fileHeader.mapCount]; - for (uint16 i = 0; i < _fileHeader.mapCount; ++i) { - _maps[i].rawDunDataOffset = dunDataStream.readUint16BE(); + _maps = new Map[_fileHeader._mapCount]; + for (uint16 i = 0; i < _fileHeader._mapCount; ++i) { + _maps[i]._rawDunDataOffset = dunDataStream.readUint16BE(); dunDataStream.readUint32BE(); // discard 4 bytes - _maps[i].offsetMapX = dunDataStream.readByte(); - _maps[i].offsetMapY = dunDataStream.readByte(); + _maps[i]._offsetMapX = dunDataStream.readByte(); + _maps[i]._offsetMapY = dunDataStream.readByte(); uint16 tmp = dunDataStream.readUint16BE(); - _maps[i].height = tmp >> 11; - _maps[i].width = (tmp >> 6) & 0x1F; - _maps[i].level = tmp & 0x1F; // Only used in DMII + _maps[i]._height = tmp >> 11; + _maps[i]._width = (tmp >> 6) & 0x1F; + _maps[i]._level = tmp & 0x1F; // Only used in DMII tmp = dunDataStream.readUint16BE(); - _maps[i].randFloorOrnCount = tmp >> 12; - _maps[i].floorOrnCount = (tmp >> 8) & 0xF; - _maps[i].randWallOrnCount = (tmp >> 4) & 0xF; - _maps[i].wallOrnCount = tmp & 0xF; + _maps[i]._randFloorOrnCount = tmp >> 12; + _maps[i]._floorOrnCount = (tmp >> 8) & 0xF; + _maps[i]._randWallOrnCount = (tmp >> 4) & 0xF; + _maps[i]._wallOrnCount = tmp & 0xF; tmp = dunDataStream.readUint16BE(); - _maps[i].difficulty = tmp >> 12; - _maps[i].creatureTypeCount = (tmp >> 4) & 0xF; - _maps[i].doorOrnCount = tmp & 0xF; + _maps[i]._difficulty = tmp >> 12; + _maps[i]._creatureTypeCount = (tmp >> 4) & 0xF; + _maps[i]._doorOrnCount = tmp & 0xF; tmp = dunDataStream.readUint16BE(); - _maps[i].doorSet1 = (tmp >> 12) & 0xF; - _maps[i].doorSet0 = (tmp >> 8) & 0xF; - _maps[i].wallSet = (WallSet)((tmp >> 4) & 0xF); - _maps[i].floorSet = (FloorSet)(tmp & 0xF); + _maps[i]._doorSet1 = (tmp >> 12) & 0xF; + _maps[i]._doorSet0 = (tmp >> 8) & 0xF; + _maps[i]._wallSet = (WallSet)((tmp >> 4) & 0xF); + _maps[i]._floorSet = (FloorSet)(tmp & 0xF); } // TODO: ??? is this - begin - delete[] _dunData.mapsFirstColumnIndex; - _dunData.mapsFirstColumnIndex = new uint16[_fileHeader.mapCount]; + delete[] _dunData._mapsFirstColumnIndex; + _dunData._mapsFirstColumnIndex = new uint16[_fileHeader._mapCount]; uint16 columCount = 0; - for (uint16 i = 0; i < _fileHeader.mapCount; ++i) { - _dunData.mapsFirstColumnIndex[i] = columCount; - columCount += _maps[i].width + 1; + for (uint16 i = 0; i < _fileHeader._mapCount; ++i) { + _dunData._mapsFirstColumnIndex[i] = columCount; + columCount += _maps[i]._width + 1; } - _dunData.columCount = columCount; + _dunData._columCount = columCount; // TODO: ??? is this - end - uint32 actualSquareFirstThingCount = _fileHeader.squareFirstThingCount; + uint32 actualSquareFirstThingCount = _fileHeader._squareFirstThingCount; if (_messages.newGame) // TODO: what purpose does this serve? - _fileHeader.squareFirstThingCount += 300; + _fileHeader._squareFirstThingCount += 300; // TODO: ??? is this - begin - delete[] _dunData.columnsCumulativeSquareThingCount; - _dunData.columnsCumulativeSquareThingCount = new uint16[columCount]; + delete[] _dunData._columnsCumulativeSquareThingCount; + _dunData._columnsCumulativeSquareThingCount = new uint16[columCount]; for (uint16 i = 0; i < columCount; ++i) - _dunData.columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE(); + _dunData._columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE(); // TODO: ??? is this - end // TODO: ??? is this - begin - delete[] _dunData.squareFirstThings; - _dunData.squareFirstThings = new Thing[_fileHeader.squareFirstThingCount]; + delete[] _dunData._squareFirstThings; + _dunData._squareFirstThings = new Thing[_fileHeader._squareFirstThingCount]; for (uint16 i = 0; i < actualSquareFirstThingCount; ++i) - _dunData.squareFirstThings[i].set(dunDataStream.readUint16BE()); + _dunData._squareFirstThings[i].set(dunDataStream.readUint16BE()); if (_messages.newGame) for (uint16 i = 0; i < 300; ++i) - _dunData.squareFirstThings[actualSquareFirstThingCount + i] = Thing::thingNone; + _dunData._squareFirstThings[actualSquareFirstThingCount + i] = Thing::_thingNone; // TODO: ??? is this - end // load text data - delete[] _dunData.textData; - _dunData.textData = new uint16[_fileHeader.textDataWordCount]; - for (uint16 i = 0; i < _fileHeader.textDataWordCount; ++i) - _dunData.textData[i] = dunDataStream.readUint16BE(); + delete[] _dunData._textData; + _dunData._textData = new uint16[_fileHeader._textDataWordCount]; + for (uint16 i = 0; i < _fileHeader._textDataWordCount; ++i) + _dunData._textData[i] = dunDataStream.readUint16BE(); // TODO: ??? what this if (_messages.newGame) - _dunData.eventMaximumCount = 100; + _dunData._eventMaximumCount = 100; // load things for (uint16 thingType = kDoorThingType; thingType < kThingTypeTotal; ++thingType) { - uint16 thingCount = _fileHeader.thingCounts[thingType]; + uint16 thingCount = _fileHeader._thingCounts[thingType]; if (_messages.newGame) { - _fileHeader.thingCounts[thingType] = MIN((thingType == kExplosionThingType) ? 768 : 1024, thingCount + gAdditionalThingCounts[thingType]); + _fileHeader._thingCounts[thingType] = MIN((thingType == kExplosionThingType) ? 768 : 1024, thingCount + gAdditionalThingCounts[thingType]); } uint16 thingStoreWordCount = gThingDataWordCount[thingType]; if (thingStoreWordCount == 0) continue; - if (_dunData.thingsData[thingType]) { - delete[] _dunData.thingsData[thingType][0]; - delete[] _dunData.thingsData[thingType]; + if (_dunData._thingsData[thingType]) { + delete[] _dunData._thingsData[thingType][0]; + delete[] _dunData._thingsData[thingType]; } - _dunData.thingsData[thingType] = new uint16*[_fileHeader.thingCounts[thingType]]; - _dunData.thingsData[thingType][0] = new uint16[_fileHeader.thingCounts[thingType] * thingStoreWordCount]; - for (uint16 i = 0; i < _fileHeader.thingCounts[thingType]; ++i) - _dunData.thingsData[thingType][i] = _dunData.thingsData[thingType][0] + i * thingStoreWordCount; + _dunData._thingsData[thingType] = new uint16*[_fileHeader._thingCounts[thingType]]; + _dunData._thingsData[thingType][0] = new uint16[_fileHeader._thingCounts[thingType] * thingStoreWordCount]; + for (uint16 i = 0; i < _fileHeader._thingCounts[thingType]; ++i) + _dunData._thingsData[thingType][i] = _dunData._thingsData[thingType][0] + i * thingStoreWordCount; if (thingType == kGroupThingType) { for (uint16 i = 0; i < thingCount; ++i) for (uint16 j = 0; j < thingStoreWordCount; ++j) { if (j == 2 || j == 3) - _dunData.thingsData[thingType][i][j] = dunDataStream.readByte(); + _dunData._thingsData[thingType][i][j] = dunDataStream.readByte(); else - _dunData.thingsData[thingType][i][j] = dunDataStream.readUint16BE(); + _dunData._thingsData[thingType][i][j] = dunDataStream.readUint16BE(); } } else if (thingType == kProjectileThingType) { for (uint16 i = 0; i < thingCount; ++i) { - _dunData.thingsData[thingType][i][0] = dunDataStream.readUint16BE(); - _dunData.thingsData[thingType][i][1] = dunDataStream.readUint16BE(); - _dunData.thingsData[thingType][i][2] = dunDataStream.readByte(); - _dunData.thingsData[thingType][i][3] = dunDataStream.readByte(); - _dunData.thingsData[thingType][i][4] = dunDataStream.readUint16BE(); + _dunData._thingsData[thingType][i][0] = dunDataStream.readUint16BE(); + _dunData._thingsData[thingType][i][1] = dunDataStream.readUint16BE(); + _dunData._thingsData[thingType][i][2] = dunDataStream.readByte(); + _dunData._thingsData[thingType][i][3] = dunDataStream.readByte(); + _dunData._thingsData[thingType][i][4] = dunDataStream.readUint16BE(); } } else { for (uint16 i = 0; i < thingCount; ++i) { for (uint16 j = 0; j < thingStoreWordCount; ++j) - _dunData.thingsData[thingType][i][j] = dunDataStream.readUint16BE(); + _dunData._thingsData[thingType][i][j] = dunDataStream.readUint16BE(); } } if (_messages.newGame) { if ((thingType == kGroupThingType) || thingType >= kProjectileThingType) - _dunData.eventMaximumCount += _fileHeader.thingCounts[thingType]; + _dunData._eventMaximumCount += _fileHeader._thingCounts[thingType]; for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) { - _dunData.thingsData[thingType][thingCount + i][0] = Thing::thingNone.toUint16(); + _dunData._thingsData[thingType][thingCount + i][0] = Thing::_thingNone.toUint16(); } } @@ -553,16 +553,16 @@ void DungeonMan::loadDungeonFile() { if (!_messages.restartGameRequest) { - uint8 mapCount = _fileHeader.mapCount; - delete[] _dunData.mapData; - _dunData.mapData = new byte**[_dunData.columCount + mapCount]; - byte **colFirstSquares = (byte**)_dunData.mapData + mapCount; + uint8 mapCount = _fileHeader._mapCount; + delete[] _dunData._mapData; + _dunData._mapData = new byte**[_dunData._columCount + mapCount]; + byte **colFirstSquares = (byte**)_dunData._mapData + mapCount; for (uint8 i = 0; i < mapCount; ++i) { - _dunData.mapData[i] = colFirstSquares; - byte *square = _rawMapData + _maps[i].rawDunDataOffset; + _dunData._mapData[i] = colFirstSquares; + byte *square = _rawMapData + _maps[i]._rawDunDataOffset; *colFirstSquares++ = square; - for (uint16 w = 1; w <= _maps[i].width; ++w) { - square += _maps[i].height + 1; + for (uint16 w = 1; w <= _maps[i]._width; ++w) { + square += _maps[i]._height + 1; *colFirstSquares++ = square; } } @@ -571,12 +571,12 @@ void DungeonMan::loadDungeonFile() { void DungeonMan::setCurrentMap(uint16 mapIndex) { _currMap.index = mapIndex; - _currMap.data = _dunData.mapData[mapIndex]; + _currMap.data = _dunData._mapData[mapIndex]; _currMap.map = _maps + mapIndex; - _currMap.width = _maps[mapIndex].width + 1; - _currMap.height = _maps[mapIndex].height + 1; + _currMap.width = _maps[mapIndex]._width + 1; + _currMap.height = _maps[mapIndex]._height + 1; _currMap.colCumulativeSquareFirstThingCount - = &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]]; + = &_dunData._columnsCumulativeSquareThingCount[_dunData._mapsFirstColumnIndex[mapIndex]]; } void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) { @@ -585,16 +585,16 @@ void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) { byte *metaMapData = _currMap.data[_currMap.width - 1] + _currMap.height; _vm->_displayMan->_currMapAllowedCreatureTypes = metaMapData; - metaMapData += _currMap.map->creatureTypeCount; - memcpy(_vm->_displayMan->_currMapWallOrnIndices, metaMapData, _currMap.map->wallOrnCount); + metaMapData += _currMap.map->_creatureTypeCount; + memcpy(_vm->_displayMan->_currMapWallOrnIndices, metaMapData, _currMap.map->_wallOrnCount); - metaMapData += _currMap.map->wallOrnCount; - memcpy(_vm->_displayMan->_currMapFloorOrnIndices, metaMapData, _currMap.map->floorOrnCount); + metaMapData += _currMap.map->_wallOrnCount; + memcpy(_vm->_displayMan->_currMapFloorOrnIndices, metaMapData, _currMap.map->_floorOrnCount); - metaMapData += _currMap.map->wallOrnCount; - memcpy(_vm->_displayMan->_currMapDoorOrnIndices, metaMapData, _currMap.map->doorOrnCount); + metaMapData += _currMap.map->_wallOrnCount; + memcpy(_vm->_displayMan->_currMapDoorOrnIndices, metaMapData, _currMap.map->_doorOrnCount); - _currMapInscriptionWallOrnIndex = _currMap.map->wallOrnCount; + _currMapInscriptionWallOrnIndex = _currMap.map->_wallOrnCount; _vm->_displayMan->_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = kWallOrnInscription; } @@ -651,8 +651,8 @@ int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) { Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) { int16 index = getSquareFirstThingIndex(mapX, mapY); if (index == -1) - return Thing::thingEndOfList; - return _dunData.squareFirstThings[index]; + return Thing::_thingEndOfList; + return _dunData._squareFirstThings[index]; } @@ -701,7 +701,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, T0172010_ClosedFakeWall: setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall); - while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) { + while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType)) { int16 sideIndex = (thing.getCell() - dir) & 3; if (sideIndex) { if (thing.getType() == kTextstringType) { @@ -720,7 +720,7 @@ T0172010_ClosedFakeWall: thing = getNextThing(thing); } if (squareIsFakeWall && (_currMap.partyPosX != mapX) && (_currMap.partyPosY != mapY)) { - aspectArray[kFirstGroupOrObjectAspect] = Thing::thingEndOfList.toUint16(); + aspectArray[kFirstGroupOrObjectAspect] = Thing::_thingEndOfList.toUint16(); return; } break; @@ -745,11 +745,11 @@ T0172010_ClosedFakeWall: square = footPrintsAllowed ? 8 : 0; // intentional fallthrough case kCorridorElemType: - aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap.map->randFloorOrnCount, mapX, mapY, 30); + aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap.map->_randFloorOrnCount, mapX, mapY, 30); T0172029_Teleporter: footPrintsAllowed = true; T0172030_Pit: - while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) { + while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType)) { if (thing.getType() == kSensorThingType) aspectArray[kFloorOrnOrdAspect] = Sensor(getThingData(thing)).getOrnOrdinal(); thing = getNextThing(thing); @@ -773,7 +773,7 @@ T0172030_Pit: } footPrintsAllowed = true; T0172046_Stairs: - while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) + while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType)) thing = getNextThing(thing); T0172049_Footprints: unsigned char scentOrdinal; // see next line comment @@ -785,7 +785,7 @@ T0172049_Footprints: void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, int16 mapX, int16 mapY, bool isFakeWall) { - int16 ornCount = _currMap.map->randWallOrnCount; + int16 ornCount = _currMap.map->_randWallOrnCount; turnDirRight(dir); aspectArray[kRightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); @@ -805,7 +805,7 @@ void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowe int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) { int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1) + (3000 + (_currMap.index << 6) + _currMap.width + _currMap.height) * 11 - + _fileHeader.ornamentRandomSeed) >> 2) % modulo; + + _fileHeader._ornamentRandomSeed) >> 2) % modulo; if (allowed && index < count) return indexToOrdinal(index); return 0; @@ -821,7 +821,7 @@ bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) { } uint16 *DungeonMan::getThingData(Thing thing) { - return _dunData.thingsData[thing.getType()][thing.getIndex()]; + return _dunData._thingsData[thing.getType()][thing.getIndex()]; } Thing DungeonMan::getNextThing(Thing thing) { @@ -931,7 +931,7 @@ char gInscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_Insc void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { char sepChar; - TextString textString(_dunData.thingsData[kTextstringType][thing.getIndex()]); + TextString textString(_dunData._thingsData[kTextstringType][thing.getIndex()]); if ((textString.isVisible()) || (type & kDecodeEvenIfInvisible)) { type = (TextType)(type & ~kDecodeEvenIfInvisible); if (type == kTextTypeMessage) { @@ -944,7 +944,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { } uint16 codeCounter = 0; int16 escChar = 0; - uint16 *codeWord = _dunData.textData + textString.getWordOffset(); + uint16 *codeWord = _dunData._textData + textString.getWordOffset(); uint16 code = 0, codes = 0; char *escReplString = nullptr; for (;;) { /*infinite loop*/ @@ -998,7 +998,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { uint16 DungeonMan::getObjectWeight(Thing thing) { - if (thing == Thing::thingNone) + if (thing == Thing::_thingNone) return 0; switch (thing.getType()) { case kWeaponThingType: @@ -1016,7 +1016,7 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { uint16 weight = 50; Container container = getThingData(thing); Thing slotThing = container.getNextContainedThing(); - while (slotThing != Thing::thingEndOfList) { + while (slotThing != Thing::_thingEndOfList) { weight += getObjectWeight(slotThing); slotThing = getNextThing(slotThing); } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index c13d460e8d..7ae10f1f26 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -98,40 +98,40 @@ enum SquareAspectIndice { struct CreatureInfo { - byte creatureAspectIndex; - byte attackSoundOrdinal; - uint16 attributes; /* Bits 15-14 Unreferenced */ - uint16 graphicInfo; /* Bits 11 and 6 Unreferenced */ - byte movementTicks; /* Value 255 means the creature cannot move */ - byte attackTicks; /* Minimum ticks between attacks */ - byte defense; - byte baseHealth; - byte attack; - byte poisonAttack; - byte dexterity; - uint16 Ranges; /* Bits 7-4 Unreferenced */ - uint16 Properties; - uint16 Resistances; /* Bits 15-12 and 3-0 Unreferenced */ - uint16 AnimationTicks; /* Bits 15-12 Unreferenced */ - uint16 WoundProbabilities; /* Contains 4 probabilities to wound a champion's Head (Bits 15-12), Legs (Bits 11-8), Torso (Bits 7-4) and Feet (Bits 3-0) */ - byte AttackType; + byte _creatureAspectIndex; + byte _attackSoundOrdinal; + uint16 _attributes; /* Bits 15-14 Unreferenced */ + uint16 _graphicInfo; /* Bits 11 and 6 Unreferenced */ + byte _movementTicks; /* Value 255 means the creature cannot move */ + byte _attackTicks; /* Minimum ticks between attacks */ + byte _defense; + byte _baseHealth; + byte _attack; + byte _poisonAttack; + byte _dexterity; + uint16 _ranges; /* Bits 7-4 Unreferenced */ + uint16 _properties; + uint16 _resistances; /* Bits 15-12 and 3-0 Unreferenced */ + uint16 _animationTicks; /* Bits 15-12 Unreferenced */ + uint16 _woundProbabilities; /* Contains 4 probabilities to wound a champion's Head (Bits 15-12), Legs (Bits 11-8), Torso (Bits 7-4) and Feet (Bits 3-0) */ + byte _attackType; }; // @ CREATURE_INFO extern CreatureInfo gCreatureInfo[kCreatureTypeCount]; class Door { - Thing nextThing; - uint16 attributes; + Thing _nextThing; + uint16 _attributes; public: - Door(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} - Thing getNextThing() { return nextThing; } - bool isMeleeDestructible() { return (attributes >> 8) & 1; } - bool isMagicDestructible() { return (attributes >> 7) & 1; } - bool hasButton() { return (attributes >> 6) & 1; } - bool opensVertically() { return (attributes >> 5) & 1; } - byte getOrnOrdinal() { return (attributes >> 1) & 0xF; } - byte getType() { return attributes & 1; } + Door(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} + Thing getNextThing() { return _nextThing; } + bool isMeleeDestructible() { return (_attributes >> 8) & 1; } + bool isMagicDestructible() { return (_attributes >> 7) & 1; } + bool hasButton() { return (_attributes >> 6) & 1; } + bool opensVertically() { return (_attributes >> 5) & 1; } + byte getOrnOrdinal() { return (_attributes >> 1) & 0xF; } + byte getType() { return _attributes & 1; } }; // @ DOOR enum TeleporterScope { @@ -159,14 +159,14 @@ public: class TextString { - Thing nextThing; - uint16 textDataRef; + Thing _nextThing; + uint16 _textDataRef; public: - TextString(uint16 *rawDat) : nextThing(rawDat[0]), textDataRef(rawDat[1]) {} + TextString(uint16 *rawDat) : _nextThing(rawDat[0]), _textDataRef(rawDat[1]) {} - Thing getNextThing() { return nextThing; } - uint16 getWordOffset() { return textDataRef >> 3; } - bool isVisible() { return textDataRef & 1; } + Thing getNextThing() { return _nextThing; } + uint16 getWordOffset() { return _textDataRef >> 3; } + bool isVisible() { return _textDataRef & 1; } }; // @ TEXTSTRING enum SensorActionType { @@ -211,50 +211,50 @@ enum SensorType { }; class Sensor { - Thing nextThing; - uint16 datAndType; - uint16 attributes; - uint16 action; + Thing _nextThing; + uint16 _datAndType; + uint16 _attributes; + uint16 _action; public: - Sensor(uint16 *rawDat) : nextThing(rawDat[0]), datAndType(rawDat[1]), attributes(rawDat[2]), action(rawDat[3]) {} - - Thing getNextThing() { return nextThing; } - SensorType getType() { return (SensorType)(datAndType & 0x7F); } // @ M39_TYPE - uint16 getData() { return datAndType >> 7; } // @ M40_DATA - uint16 getDataMask1() { return (datAndType >> 7) & 0xF; } // @ M42_MASK1 - uint16 getDataMask2() { return (datAndType >> 11) & 0xF; } // @ M43_MASK2 - void setData(int16 dat) { datAndType = (datAndType & 0x7F) | (dat << 7); } // @ M41_SET_DATA - void setTypeDisabled() { datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED - uint16 getOrnOrdinal() { return attributes >> 12; } - bool isLocalAction() { return (attributes >> 11) & 1; } - uint16 getDelay() { return (attributes >> 7) & 0xF; } - bool hasSound() { return (attributes >> 6) & 1; } - bool shouldRevert() { return (attributes >> 5) & 1; } - SensorActionType getActionType() { return (SensorActionType)((attributes >> 3) & 3); } - bool isSingleUse() { return (attributes >> 2) & 1; } - uint16 getRemoteMapY() { return (action >> 11); } - uint16 getRemoteMapX() { return (action >> 6) & 0x1F; } - direction getRemoteDir() { return (direction)((action >> 4) & 3); } - uint16 getLocalAction() { return (action >> 4); } + Sensor(uint16 *rawDat) : _nextThing(rawDat[0]), _datAndType(rawDat[1]), _attributes(rawDat[2]), _action(rawDat[3]) {} + + Thing getNextThing() { return _nextThing; } + SensorType getType() { return (SensorType)(_datAndType & 0x7F); } // @ M39_TYPE + uint16 getData() { return _datAndType >> 7; } // @ M40_DATA + uint16 getDataMask1() { return (_datAndType >> 7) & 0xF; } // @ M42_MASK1 + uint16 getDataMask2() { return (_datAndType >> 11) & 0xF; } // @ M43_MASK2 + void setData(int16 dat) { _datAndType = (_datAndType & 0x7F) | (dat << 7); } // @ M41_SET_DATA + void setTypeDisabled() { _datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED + uint16 getOrnOrdinal() { return _attributes >> 12; } + bool isLocalAction() { return (_attributes >> 11) & 1; } + uint16 getDelay() { return (_attributes >> 7) & 0xF; } + bool hasSound() { return (_attributes >> 6) & 1; } + bool shouldRevert() { return (_attributes >> 5) & 1; } + SensorActionType getActionType() { return (SensorActionType)((_attributes >> 3) & 3); } + bool isSingleUse() { return (_attributes >> 2) & 1; } + uint16 getRemoteMapY() { return (_action >> 11); } + uint16 getRemoteMapX() { return (_action >> 6) & 0x1F; } + direction getRemoteDir() { return (direction)((_action >> 4) & 3); } + uint16 getLocalAction() { return (_action >> 4); } // some macros missing, i got bored }; // @ SENSOR class Group { - Thing nextThing; - Thing possessionID; - byte type; - byte position; - uint16 health[4]; - uint16 attributes; + Thing _nextThing; + Thing _possessionID; + byte _type; + byte _position; + uint16 _health[4]; + uint16 _attributes; public: - Group(uint16 *rawDat) : nextThing(rawDat[0]), possessionID(rawDat[1]), type(rawDat[2]), - position(rawDat[3]), attributes(rawDat[8]) { - health[0] = rawDat[4]; - health[1] = rawDat[5]; - health[2] = rawDat[6]; - health[3] = rawDat[7]; + Group(uint16 *rawDat) : _nextThing(rawDat[0]), _possessionID(rawDat[1]), _type(rawDat[2]), + _position(rawDat[3]), _attributes(rawDat[8]) { + _health[0] = rawDat[4]; + _health[1] = rawDat[5]; + _health[2] = rawDat[6]; + _health[3] = rawDat[7]; } - Thing getNextThing() { return nextThing; } + Thing getNextThing() { return _nextThing; } }; // @ GROUP enum WeaponType { @@ -271,13 +271,13 @@ enum WeaponType { kWeaponTypeThrowingStar = 32 // @ C32_WEAPON_THROWING_STAR }; class Weapon { - Thing nextThing; - uint16 desc; + Thing _nextThing; + uint16 _desc; public: - Weapon(uint16 *rawDat) : nextThing(rawDat[0]), desc(rawDat[1]) {} + Weapon(uint16 *rawDat) : _nextThing(rawDat[0]), _desc(rawDat[1]) {} - WeaponType getType() { return (WeaponType)(desc & 0x7F); } - Thing getNextThing() { return nextThing; } + WeaponType getType() { return (WeaponType)(_desc & 0x7F); } + Thing getNextThing() { return _nextThing; } }; // @ WEAPON enum ArmourType { @@ -288,25 +288,25 @@ enum ArmourType { kArmourTypeFootPlate = 41 // @ C41_ARMOUR_FOOT_PLATE }; class Armour { - Thing nextThing; - uint16 attributes; + Thing _nextThing; + uint16 _attributes; public: - Armour(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} + Armour(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} - ArmourType getType() { return (ArmourType)(attributes & 0x7F); } - Thing getNextThing() { return nextThing; } + ArmourType getType() { return (ArmourType)(_attributes & 0x7F); } + Thing getNextThing() { return _nextThing; } }; // @ ARMOUR class Scroll { - Thing nextThing; - uint16 attributes; + Thing _nextThing; + uint16 _attributes; public: - Scroll(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} + Scroll(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} void set(Thing next, uint16 attribs) { - nextThing = next; - attributes = attribs; + _nextThing = next; + _attributes = attribs; } - Thing getNextThing() { return nextThing; } + Thing getNextThing() { return _nextThing; } }; // @ SCROLL enum PotionType { @@ -325,24 +325,24 @@ enum PotionType { kPotionTypeEmptyFlask = 20 // @ C20_POTION_EMPTY_FLASK, }; class Potion { - Thing nextThing; - uint16 attributes; + Thing _nextThing; + uint16 _attributes; public: - Potion(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} + Potion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} - PotionType getType() { return (PotionType)((attributes >> 8) & 0x7F); } - Thing getNextThing() { return nextThing; } + PotionType getType() { return (PotionType)((_attributes >> 8) & 0x7F); } + Thing getNextThing() { return _nextThing; } }; // @ POTION class Container { - Thing nextThing; - Thing nextContainedThing; - uint16 type; + Thing _nextThing; + Thing _nextContainedThing; + uint16 _type; public: - Container(uint16 *rawDat) : nextThing(rawDat[0]), nextContainedThing(rawDat[1]), type(rawDat[2]) {} + Container(uint16 *rawDat) : _nextThing(rawDat[0]), _nextContainedThing(rawDat[1]), _type(rawDat[2]) {} - Thing getNextContainedThing() { return nextContainedThing; } - Thing getNextThing() { return nextThing; } + Thing getNextContainedThing() { return _nextContainedThing; } + Thing getNextThing() { return _nextThing; } }; // @ CONTAINER enum JunkType { @@ -359,37 +359,37 @@ enum JunkType { }; class Junk { - Thing nextThing; - uint16 attributes; + Thing _nextThing; + uint16 _attributes; public: - Junk(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} + Junk(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} - JunkType getType() { return (JunkType)(attributes & 0x7F); } - uint16 getChargeCount() { return (attributes >> 14) & 0x3; } + JunkType getType() { return (JunkType)(_attributes & 0x7F); } + uint16 getChargeCount() { return (_attributes >> 14) & 0x3; } - Thing getNextThing() { return nextThing; } + Thing getNextThing() { return _nextThing; } }; // @ JUNK class Projectile { - Thing nextThing; - Thing object; - byte kineticEnergy; - byte damageEnergy; - uint16 timerIndex; + Thing _nextThing; + Thing _object; + byte _kineticEnergy; + byte _damageEnergy; + uint16 _timerIndex; public: - Projectile(uint16 *rawDat) : nextThing(rawDat[0]), object(rawDat[1]), kineticEnergy(rawDat[2]), - damageEnergy(rawDat[3]), timerIndex(rawDat[4]) {} + Projectile(uint16 *rawDat) : _nextThing(rawDat[0]), _object(rawDat[1]), _kineticEnergy(rawDat[2]), + _damageEnergy(rawDat[3]), _timerIndex(rawDat[4]) {} - Thing getNextThing() { return nextThing; } + Thing getNextThing() { return _nextThing; } }; // @ PROJECTILE class Explosion { - Thing nextThing; - uint16 attributes; + Thing _nextThing; + uint16 _attributes; public: - Explosion(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]) {} + Explosion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} - Thing getNextThing() { return nextThing; } + Thing getNextThing() { return _nextThing; } }; // @ EXPLOSION @@ -431,70 +431,70 @@ enum SquareType { }; // @ C[-2..19]_ELEMENT_... class Square { - byte data; + byte _data; public: - Square(byte dat = 0) : data(dat) {} + Square(byte dat = 0) : _data(dat) {} Square(SquareType type) { setType(type); } - Square &set(byte dat) { this->data = dat; return *this; } - Square &set(SquareMask mask) { data |= mask; return *this; } - byte get(SquareMask mask) { return data & mask; } - byte getDoorState() { return data & 0x7; } // @ M36_DOOR_STATE - Square &setDoorState(byte state) { data = ((data & ~0x7) | state); } // @ M37_SET_DOOR_STATE - SquareType getType() { return (SquareType)(data >> 5); } // @ M34_SQUARE_TYPE - Square &setType(SquareType type) { data = (data & 0x1F) | type << 5; return *this; } - byte toByte() { return data; } // I don't like 'em casts + Square &set(byte dat) { this->_data = dat; return *this; } + Square &set(SquareMask mask) { _data |= mask; return *this; } + byte get(SquareMask mask) { return _data & mask; } + byte getDoorState() { return _data & 0x7; } // @ M36_DOOR_STATE + Square &setDoorState(byte state) { _data = ((_data & ~0x7) | state); } // @ M37_SET_DOOR_STATE + SquareType getType() { return (SquareType)(_data >> 5); } // @ M34_SQUARE_TYPE + Square &setType(SquareType type) { _data = (_data & 0x1F) | type << 5; return *this; } + byte toByte() { return _data; } // I don't like 'em casts }; struct DungeonFileHeader { - uint16 dungeonId; // @ G0526_ui_DungeonID + uint16 _dungeonId; // @ G0526_ui_DungeonID // equal to dungeonId - uint16 ornamentRandomSeed; - uint32 rawMapDataSize; - uint8 mapCount; - uint16 textDataWordCount; - direction partyStartDir; // @ InitialPartyLocation - uint16 partyStartPosX, partyStartPosY; - uint16 squareFirstThingCount; // @ SquareFirstThingCount - uint16 thingCounts[16]; // @ ThingCount[16] + uint16 _ornamentRandomSeed; + uint32 _rawMapDataSize; + uint8 _mapCount; + uint16 _textDataWordCount; + direction _partyStartDir; // @ InitialPartyLocation + uint16 _partyStartPosX, _partyStartPosY; + uint16 _squareFirstThingCount; // @ SquareFirstThingCount + uint16 _thingCounts[16]; // @ ThingCount[16] }; // @ DUNGEON_HEADER struct Map { - uint32 rawDunDataOffset; - uint8 offsetMapX, offsetMapY; + uint32 _rawDunDataOffset; + uint8 _offsetMapX, _offsetMapY; - uint8 level; // only used in DMII - uint8 width, height; // !!! THESRE ARE INCLUSIVE BOUNDARIES + uint8 _level; // only used in DMII + uint8 _width, _height; // !!! THESRE ARE INCLUSIVE BOUNDARIES // orn short for Ornament - uint8 wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */ - uint8 randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */ - uint8 floorOrnCount; /* May be used in a Sensor on a Pit, open Fake Wall, Corridor or Teleporter square */ - uint8 randFloorOrnCount; /* Used only on some Corridor squares and some open Fake Wall squares */ - - uint8 doorOrnCount; - uint8 creatureTypeCount; - uint8 difficulty; - - FloorSet floorSet; - WallSet wallSet; - uint8 doorSet0, doorSet1; + uint8 _wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */ + uint8 _randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */ + uint8 _floorOrnCount; /* May be used in a Sensor on a Pit, open Fake Wall, Corridor or Teleporter square */ + uint8 _randFloorOrnCount; /* Used only on some Corridor squares and some open Fake Wall squares */ + + uint8 _doorOrnCount; + uint8 _creatureTypeCount; + uint8 _difficulty; + + FloorSet _floorSet; + WallSet _wallSet; + uint8 _doorSet0, _doorSet1; }; // @ MAP struct DungeonData { // I have no idea the heck is this - uint16 *mapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex - uint16 columCount; // @ G0282_ui_DungeonColumnCount + uint16 *_mapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex + uint16 _columCount; // @ G0282_ui_DungeonColumnCount // I have no idea the heck is this - uint16 *columnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount - Thing *squareFirstThings; // @ G0283_pT_SquareFirstThings - uint16 *textData; // @ G0260_pui_DungeonTextData + uint16 *_columnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount + Thing *_squareFirstThings; // @ G0283_pT_SquareFirstThings + uint16 *_textData; // @ G0260_pui_DungeonTextData - uint16 **thingsData[16]; // @ G0284_apuc_ThingData + uint16 **_thingsData[16]; // @ G0284_apuc_ThingData - byte ***mapData; // @ G0279_pppuc_DungeonMapData + byte ***_mapData; // @ G0279_pppuc_DungeonMapData // TODO: ??? is this doing here - uint16 eventMaximumCount; // @ G0369_ui_EventMaximumCount + uint16 _eventMaximumCount; // @ G0369_ui_EventMaximumCount }; // @ AGGREGATE struct CurrMapData { diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index b0b2c73f1a..13ec773aaf 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -613,7 +613,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { for (int i = 0; i < 18; i++) _currMapDoorOrnIndices[i] = 0; - _inscriptionThing = Thing::thingNone; + _inscriptionThing = Thing::_thingNone; } DisplayMan::~DisplayMan() { @@ -1218,12 +1218,12 @@ void DisplayMan::loadWallSet(WallSet set) { void DisplayMan::loadCurrentMapGraphics() { - loadFloorSet(_vm->_dungeonMan->_currMap.map->floorSet); - loadWallSet(_vm->_dungeonMan->_currMap.map->wallSet); + loadFloorSet(_vm->_dungeonMan->_currMap.map->_floorSet); + loadWallSet(_vm->_dungeonMan->_currMap.map->_wallSet); // the original loads some flipped walls here, I moved it to loadWallSet - for (uint16 i = 0, firstGraphicIndex = _vm->_dungeonMan->_currMap.map->wallSet * kStairsGraphicCount + kFirstStairs; i < kStairsGraphicCount; ++i) + for (uint16 i = 0, firstGraphicIndex = _vm->_dungeonMan->_currMap.map->_wallSet * kStairsGraphicCount + kFirstStairs; i < kStairsGraphicCount; ++i) _stairIndices[i] = firstGraphicIndex + i; for (int16 i = 0; i < kAlcoveOrnCount; ++i) @@ -1240,7 +1240,7 @@ void DisplayMan::loadCurrentMapGraphics() { _currMapViAltarIndex = -1; - for (uint16 i = 0; i < currMap.wallOrnCount; ++i) { + for (uint16 i = 0; i < currMap._wallOrnCount; ++i) { uint16 ornIndice = _currMapWallOrnIndices[i]; uint16 nativeIndice = kFirstWallOrn + ornIndice * 2; @@ -1260,14 +1260,14 @@ void DisplayMan::loadCurrentMapGraphics() { _currMapWallOrnInfo[i][kNativeCoordinateSet] = gWallOrnCoordSetIndices[ornIndice]; } - for (uint16 i = 0; i < currMap.floorOrnCount; ++i) { + for (uint16 i = 0; i < currMap._floorOrnCount; ++i) { uint16 ornIndice = _currMapFloorOrnIndices[i]; uint16 nativeIndice = kFirstFloorOrn + ornIndice * 6; _currMapFloorOrnInfo[i][kNativeBitmapIndex] = nativeIndice; _currMapFloorOrnInfo[i][kNativeCoordinateSet] = gFloorOrnCoordSetIndices[ornIndice]; } - for (uint16 i = 0; i < currMap.doorOrnCount; ++i) { + for (uint16 i = 0; i < currMap._doorOrnCount; ++i) { uint16 ornIndice = _currMapDoorOrnIndices[i]; uint16 nativeIndice = kFirstDoorOrn + ornIndice; _currMapDoorOrnInfo[i][kNativeBitmapIndex] = nativeIndice; @@ -1277,7 +1277,7 @@ void DisplayMan::loadCurrentMapGraphics() { applyCreatureReplColors(9, 8); applyCreatureReplColors(10, 12); - for (uint16 creatureType = 0; creatureType < currMap.creatureTypeCount; ++creatureType) { + for (uint16 creatureType = 0; creatureType < currMap._creatureTypeCount; ++creatureType) { CreatureAspect &aspect = gCreatureAspects[_currMapAllowedCreatureTypes[creatureType]]; uint16 replColorOrdinal = aspect.getReplColour9(); if (replColorOrdinal) diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 5518e7927d..a153d8eb6c 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -16,7 +16,7 @@ LoadgameResponse LoadsaveMan::loadgame() { if (newGame) { _vm->_restartGameAllowed = false; cm._partyChampionCount = 0; - cm._leaderHand = Thing::thingNone; + cm._leaderHand = Thing::_thingNone; _vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536); } else { assert(false); -- cgit v1.2.3 From 9ad057a4864ac33a16ec0fb9ab8124a2526b1f1a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 18 Jun 2016 17:51:22 +0200 Subject: DM: Some more renaming, remove extra semi-column --- engines/dm/dm.cpp | 2 +- engines/dm/dungeonman.cpp | 112 +++++++++++++++++++++++----------------------- engines/dm/dungeonman.h | 29 ++++++------ engines/dm/eventman.cpp | 24 +++++----- engines/dm/gfx.cpp | 8 ++-- engines/dm/loadsave.cpp | 2 +- 6 files changed, 88 insertions(+), 89 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 94f9f30420..2ff815cadb 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -137,7 +137,7 @@ void DMEngine::gameloop() { //} while (!_stopWaitingForPlayerInput || !_gameTimeTicking); _displayMan->clearScreen(kColorBlack); - _displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY); + _displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY); // DUMMY CODE: next line _menuMan->drawMovementArrows(); _displayMan->updateScreen(); diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 80fb73331d..6b577ca3af 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -228,20 +228,20 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL for (int i = 0; i < 16; i++) _dunData._thingsData[i] = nullptr; - _currMap.partyDir = kDirNorth; - _currMap.partyPosX = 0; - _currMap.partyPosY = 0; - _currMap.currPartyMapIndex = 0; - _currMap.index = 0; - _currMap.width = 0; - _currMap.height = 0; + _currMap._partyDir = kDirNorth; + _currMap._partyPosX = 0; + _currMap._partyPosY = 0; + _currMap._currPartyMapIndex = 0; + _currMap._index = 0; + _currMap._width = 0; + _currMap._height = 0; - _currMap.data = nullptr; - _currMap.map = nullptr; - _currMap.colCumulativeSquareFirstThingCount = nullptr; + _currMap._data = nullptr; + _currMap._map = nullptr; + _currMap._colCumulativeSquareFirstThingCount = nullptr; - _messages.newGame = true; - _messages.restartGameRequest = false; + _messages._newGame = true; + _messages._restartGameRequest = false; _rawDunFileDataSize = 0; _rawDunFileData = nullptr; @@ -389,7 +389,7 @@ const Thing Thing::_thingEndOfList(0xFFFE); void DungeonMan::loadDungeonFile() { - if (_messages.newGame) + if (_messages._newGame) decompressDungeonFile(); Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO); @@ -409,11 +409,11 @@ void DungeonMan::loadDungeonFile() { _fileHeader._thingCounts[i] = dunDataStream.readUint16BE(); // init party position and mapindex - if (_messages.newGame) { - _currMap.partyDir = _fileHeader._partyStartDir; - _currMap.partyPosX = _fileHeader._partyStartPosX; - _currMap.partyPosY = _fileHeader._partyStartPosY; - _currMap.currPartyMapIndex = 0; + if (_messages._newGame) { + _currMap._partyDir = _fileHeader._partyStartDir; + _currMap._partyPosX = _fileHeader._partyStartPosX; + _currMap._partyPosY = _fileHeader._partyStartPosY; + _currMap._currPartyMapIndex = 0; } // load map data @@ -461,7 +461,7 @@ void DungeonMan::loadDungeonFile() { uint32 actualSquareFirstThingCount = _fileHeader._squareFirstThingCount; - if (_messages.newGame) // TODO: what purpose does this serve? + if (_messages._newGame) // TODO: what purpose does this serve? _fileHeader._squareFirstThingCount += 300; // TODO: ??? is this - begin @@ -476,7 +476,7 @@ void DungeonMan::loadDungeonFile() { _dunData._squareFirstThings = new Thing[_fileHeader._squareFirstThingCount]; for (uint16 i = 0; i < actualSquareFirstThingCount; ++i) _dunData._squareFirstThings[i].set(dunDataStream.readUint16BE()); - if (_messages.newGame) + if (_messages._newGame) for (uint16 i = 0; i < 300; ++i) _dunData._squareFirstThings[actualSquareFirstThingCount + i] = Thing::_thingNone; @@ -489,14 +489,14 @@ void DungeonMan::loadDungeonFile() { _dunData._textData[i] = dunDataStream.readUint16BE(); // TODO: ??? what this - if (_messages.newGame) + if (_messages._newGame) _dunData._eventMaximumCount = 100; // load things for (uint16 thingType = kDoorThingType; thingType < kThingTypeTotal; ++thingType) { uint16 thingCount = _fileHeader._thingCounts[thingType]; - if (_messages.newGame) { + if (_messages._newGame) { _fileHeader._thingCounts[thingType] = MIN((thingType == kExplosionThingType) ? 768 : 1024, thingCount + gAdditionalThingCounts[thingType]); } uint16 thingStoreWordCount = gThingDataWordCount[thingType]; @@ -536,7 +536,7 @@ void DungeonMan::loadDungeonFile() { } } - if (_messages.newGame) { + if (_messages._newGame) { if ((thingType == kGroupThingType) || thingType >= kProjectileThingType) _dunData._eventMaximumCount += _fileHeader._thingCounts[thingType]; for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) { @@ -548,11 +548,11 @@ void DungeonMan::loadDungeonFile() { // load map data - if (!_messages.restartGameRequest) + if (!_messages._restartGameRequest) _rawMapData = _rawDunFileData + dunDataStream.pos(); - if (!_messages.restartGameRequest) { + if (!_messages._restartGameRequest) { uint8 mapCount = _fileHeader._mapCount; delete[] _dunData._mapData; _dunData._mapData = new byte**[_dunData._columCount + mapCount]; @@ -570,59 +570,59 @@ void DungeonMan::loadDungeonFile() { } void DungeonMan::setCurrentMap(uint16 mapIndex) { - _currMap.index = mapIndex; - _currMap.data = _dunData._mapData[mapIndex]; - _currMap.map = _maps + mapIndex; - _currMap.width = _maps[mapIndex]._width + 1; - _currMap.height = _maps[mapIndex]._height + 1; - _currMap.colCumulativeSquareFirstThingCount + _currMap._index = mapIndex; + _currMap._data = _dunData._mapData[mapIndex]; + _currMap._map = _maps + mapIndex; + _currMap._width = _maps[mapIndex]._width + 1; + _currMap._height = _maps[mapIndex]._height + 1; + _currMap._colCumulativeSquareFirstThingCount = &_dunData._columnsCumulativeSquareThingCount[_dunData._mapsFirstColumnIndex[mapIndex]]; } void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) { setCurrentMap(mapIndex); - byte *metaMapData = _currMap.data[_currMap.width - 1] + _currMap.height; + byte *metaMapData = _currMap._data[_currMap._width - 1] + _currMap._height; _vm->_displayMan->_currMapAllowedCreatureTypes = metaMapData; - metaMapData += _currMap.map->_creatureTypeCount; - memcpy(_vm->_displayMan->_currMapWallOrnIndices, metaMapData, _currMap.map->_wallOrnCount); + metaMapData += _currMap._map->_creatureTypeCount; + memcpy(_vm->_displayMan->_currMapWallOrnIndices, metaMapData, _currMap._map->_wallOrnCount); - metaMapData += _currMap.map->_wallOrnCount; - memcpy(_vm->_displayMan->_currMapFloorOrnIndices, metaMapData, _currMap.map->_floorOrnCount); + metaMapData += _currMap._map->_wallOrnCount; + memcpy(_vm->_displayMan->_currMapFloorOrnIndices, metaMapData, _currMap._map->_floorOrnCount); - metaMapData += _currMap.map->_wallOrnCount; - memcpy(_vm->_displayMan->_currMapDoorOrnIndices, metaMapData, _currMap.map->_doorOrnCount); + metaMapData += _currMap._map->_wallOrnCount; + memcpy(_vm->_displayMan->_currMapDoorOrnIndices, metaMapData, _currMap._map->_doorOrnCount); - _currMapInscriptionWallOrnIndex = _currMap.map->_wallOrnCount; + _currMapInscriptionWallOrnIndex = _currMap._map->_wallOrnCount; _vm->_displayMan->_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = kWallOrnInscription; } Square DungeonMan::getSquare(int16 mapX, int16 mapY) { - bool isInXBounds = (mapX >= 0) && (mapX < _currMap.width); - bool isInYBounds = (mapY >= 0) && (mapY < _currMap.height); + bool isInXBounds = (mapX >= 0) && (mapX < _currMap._width); + bool isInYBounds = (mapY >= 0) && (mapY < _currMap._height); if (isInXBounds && isInYBounds) - return _currMap.data[mapX][mapY]; + return _currMap._data[mapX][mapY]; Square tmpSquare; if (isInYBounds) { - tmpSquare.set(_currMap.data[0][mapY]); + tmpSquare.set(_currMap._data[0][mapY]); if (mapX == -1 && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) return Square(kWallElemType).set(kWallEastRandOrnAllowed); - tmpSquare.set(_currMap.data[_currMap.width - 1][mapY]); - if (mapX == _currMap.width && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) + tmpSquare.set(_currMap._data[_currMap._width - 1][mapY]); + if (mapX == _currMap._width && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) return Square(kWallElemType).set(kWallWestRandOrnAllowed); } else if (isInXBounds) { - tmpSquare.set(_currMap.data[mapX][0]); + tmpSquare.set(_currMap._data[mapX][0]); if (mapY == -1 && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) return Square(kWallElemType).set(kWallSouthRandOrnAllowed); - tmpSquare.set(_currMap.data[mapX][_currMap.height - 1]); - if (mapY == _currMap.height && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) + tmpSquare.set(_currMap._data[mapX][_currMap._height - 1]); + if (mapY == _currMap._height && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) return (kWallElemType << 5) | kWallNorthRandOrnAllowed; } @@ -635,12 +635,12 @@ Square DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRi } int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) { - if (mapX < 0 || mapX >= _currMap.width || mapY < 0 || mapY >= _currMap.height || !Square(_currMap.data[mapX][mapY]).get(kThingListPresent)) + if (mapX < 0 || mapX >= _currMap._width || mapY < 0 || mapY >= _currMap._height || !Square(_currMap._data[mapX][mapY]).get(kThingListPresent)) return -1; int16 y = 0; - uint16 index = _currMap.colCumulativeSquareFirstThingCount[mapX]; - byte* square = _currMap.data[mapX]; + uint16 index = _currMap._colCumulativeSquareFirstThingCount[mapX]; + byte* square = _currMap._data[mapX]; while (y++ != mapY) if (Square(*square++).get(kThingListPresent)) index++; @@ -719,7 +719,7 @@ T0172010_ClosedFakeWall: } thing = getNextThing(thing); } - if (squareIsFakeWall && (_currMap.partyPosX != mapX) && (_currMap.partyPosY != mapY)) { + if (squareIsFakeWall && (_currMap._partyPosX != mapX) && (_currMap._partyPosY != mapY)) { aspectArray[kFirstGroupOrObjectAspect] = Thing::_thingEndOfList.toUint16(); return; } @@ -745,7 +745,7 @@ T0172010_ClosedFakeWall: square = footPrintsAllowed ? 8 : 0; // intentional fallthrough case kCorridorElemType: - aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap.map->_randFloorOrnCount, mapX, mapY, 30); + aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap._map->_randFloorOrnCount, mapX, mapY, 30); T0172029_Teleporter: footPrintsAllowed = true; T0172030_Pit: @@ -785,7 +785,7 @@ T0172049_Footprints: void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, int16 mapX, int16 mapY, bool isFakeWall) { - int16 ornCount = _currMap.map->_randWallOrnCount; + int16 ornCount = _currMap._map->_randWallOrnCount; turnDirRight(dir); aspectArray[kRightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); @@ -794,7 +794,7 @@ void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowe turnDirRight(dir); aspectArray[kLeftWallOrnOrdAspect] = getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - if (isFakeWall || mapX < 0 || mapX >= _currMap.width || mapY < 0 || mapY >= _currMap.height) { + if (isFakeWall || mapX < 0 || mapX >= _currMap._width || mapY < 0 || mapY >= _currMap._height) { for (uint16 i = kRightWallOrnOrdAspect; i <= kLeftWallOrnOrdAspect; ++i) { if (isWallOrnAnAlcove(ordinalToIndex(aspectArray[i]))) aspectArray[i] = 0; @@ -804,7 +804,7 @@ void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowe int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) { int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1) - + (3000 + (_currMap.index << 6) + _currMap.width + _currMap.height) * 11 + + (3000 + (_currMap._index << 6) + _currMap._width + _currMap._height) * 11 + _fileHeader._ornamentRandomSeed) >> 2) % modulo; if (allowed && index < count) return indexToOrdinal(index); diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 7ae10f1f26..aba2872a65 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -498,22 +498,22 @@ struct DungeonData { }; // @ AGGREGATE struct CurrMapData { - direction partyDir; // @ G0308_i_PartyDirection - int16 partyPosX; // @ G0306_i_PartyMapX - int16 partyPosY; // @ G0307_i_PartyMapY - uint8 currPartyMapIndex; // @ G0309_i_PartyMapIndex - - uint8 index; // @ G0272_i_CurrentMapIndex - byte **data; // @ G0271_ppuc_CurrentMapData - Map *map; // @ G0269_ps_CurrentMap - uint16 width; // @ G0273_i_CurrentMapWidth - uint16 height; // @ G0274_i_CurrentMapHeight - uint16 *colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount + direction _partyDir; // @ G0308_i_PartyDirection + int16 _partyPosX; // @ G0306_i_PartyMapX + int16 _partyPosY; // @ G0307_i_PartyMapY + uint8 _currPartyMapIndex; // @ G0309_i_PartyMapIndex + + uint8 _index; // @ G0272_i_CurrentMapIndex + byte **_data; // @ G0271_ppuc_CurrentMapData + Map *_map; // @ G0269_ps_CurrentMap + uint16 _width; // @ G0273_i_CurrentMapWidth + uint16 _height; // @ G0274_i_CurrentMapHeight + uint16 *_colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount }; // @ AGGREGATE struct Messages { - bool newGame; // @ G0298_B_NewGame - bool restartGameRequest; // @ G0523_B_RestartGameRequested + bool _newGame; // @ G0298_B_NewGame + bool _restartGameRequest; // @ G0523_B_RestartGameRequested }; // @ AGGREGATE class DungeonMan { @@ -574,7 +574,6 @@ public: bool _isFacingFountain; // @ G0288_B_FacingFountain }; -}; - +} #endif diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 8728dd76f6..e182b78d96 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -276,22 +276,22 @@ void EventManager::processInput() { switch (event.kbd.keycode) { case Common::KEYCODE_w: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 1, 0, currMap._partyPosX, currMap._partyPosY); break; case Common::KEYCODE_a: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, -1, currMap._partyPosX, currMap._partyPosY); break; case Common::KEYCODE_s: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, -1, 0, currMap._partyPosX, currMap._partyPosY); break; case Common::KEYCODE_d: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, 1, currMap._partyPosX, currMap._partyPosY); break; case Common::KEYCODE_q: - turnDirLeft(currMap.partyDir); + turnDirLeft(currMap._partyDir); break; case Common::KEYCODE_e: - turnDirRight(currMap.partyDir); + turnDirRight(currMap._partyDir); break; case Common::KEYCODE_UP: if (_dummyMapIndex < 13) @@ -387,7 +387,7 @@ void EventManager::commandTurnParty(CommandType cmdType) { // MISSING CODE: process sensors // DUMMY CODE: should call F0284_CHAMPION_SetPartyDirection instead - direction &partyDir = _vm->_dungeonMan->_currMap.partyDir; + direction &partyDir = _vm->_dungeonMan->_currMap._partyDir; (cmdType == kCommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir); // MISSING CODE: process sensors @@ -404,16 +404,16 @@ void EventManager::commandMoveParty(CommandType cmdType) { switch (cmdType) { case kCommandMoveForward: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 1, 0, currMap._partyPosX, currMap._partyPosY); break; case kCommandMoveLeft: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, -1, currMap._partyPosX, currMap._partyPosY); break; case kCommandMoveBackward: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, -1, 0, currMap._partyPosX, currMap._partyPosY); break; case kCommandMoveRight: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, 1, currMap._partyPosX, currMap._partyPosY); break; } @@ -441,7 +441,7 @@ void EventManager::commandSetLeader(ChampionIndex index) { } cm._leaderIndex = index; Champion *champion = &cm._champions[cm._leaderIndex]; - champion->_dir = _vm->_dungeonMan->_currMap.partyDir; + champion->_dir = _vm->_dungeonMan->_currMap._partyDir; cm._champions[index]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHand); if (indexToOrdinal(index) != cm._candidateChampionOrdinal) { champion->setAttributeFlag(kChampionAttributeIcon, true); diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 13ec773aaf..ae9ef62414 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1218,12 +1218,12 @@ void DisplayMan::loadWallSet(WallSet set) { void DisplayMan::loadCurrentMapGraphics() { - loadFloorSet(_vm->_dungeonMan->_currMap.map->_floorSet); - loadWallSet(_vm->_dungeonMan->_currMap.map->_wallSet); + loadFloorSet(_vm->_dungeonMan->_currMap._map->_floorSet); + loadWallSet(_vm->_dungeonMan->_currMap._map->_wallSet); // the original loads some flipped walls here, I moved it to loadWallSet - for (uint16 i = 0, firstGraphicIndex = _vm->_dungeonMan->_currMap.map->_wallSet * kStairsGraphicCount + kFirstStairs; i < kStairsGraphicCount; ++i) + for (uint16 i = 0, firstGraphicIndex = _vm->_dungeonMan->_currMap._map->_wallSet * kStairsGraphicCount + kFirstStairs; i < kStairsGraphicCount; ++i) _stairIndices[i] = firstGraphicIndex + i; for (int16 i = 0; i < kAlcoveOrnCount; ++i) @@ -1236,7 +1236,7 @@ void DisplayMan::loadCurrentMapGraphics() { uint16 alcoveCount = 0; uint16 fountainCount = 0; - Map &currMap = *_vm->_dungeonMan->_currMap.map; + Map &currMap = *_vm->_dungeonMan->_currMap._map; _currMapViAltarIndex = -1; diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index a153d8eb6c..1a07ae2e35 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -10,7 +10,7 @@ LoadsaveMan::LoadsaveMan(DMEngine *vm) : _vm(vm) {} LoadgameResponse LoadsaveMan::loadgame() { - bool newGame = _vm->_dungeonMan->_messages.newGame; + bool newGame = _vm->_dungeonMan->_messages._newGame; ChampionMan &cm = *_vm->_championMan; if (newGame) { -- cgit v1.2.3 From bcbb3e447f5037d4026ad5bed6d7a34eaa378e46 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 18 Jun 2016 18:02:48 +0200 Subject: DM: Some more renaming --- engines/dm/eventman.cpp | 12 +++---- engines/dm/eventman.h | 23 ++++++------ engines/dm/gfx.cpp | 78 ++++++++++++++++++++-------------------- engines/dm/gfx.h | 94 ++++++++++++++++++++++++------------------------- engines/dm/menus.cpp | 4 +-- 5 files changed, 105 insertions(+), 106 deletions(-) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index e182b78d96..6d76ddb960 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -340,8 +340,8 @@ CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common return kCommandNone; CommandType commandType = kCommandNone; - while ((commandType = input->commandTypeToIssue) != kCommandNone) { - if (input->hitbox.isPointInside(mousePos) && input->button == button) + while ((commandType = input->_commandTypeToIssue) != kCommandNone) { + if (input->_hitbox.isPointInside(mousePos) && input->_button == button) break; input++; } @@ -364,13 +364,13 @@ void EventManager::processCommandQueue() { _isCommandQueueLocked = false; processPendingClick(); - if ((cmd.type == kCommandTurnRight) || (cmd.type == kCommandTurnLeft)) { - commandTurnParty(cmd.type); + if ((cmd._type == kCommandTurnRight) || (cmd._type == kCommandTurnLeft)) { + commandTurnParty(cmd._type); return; } - if ((cmd.type >= kCommandMoveForward) && (cmd.type <= kCommandMoveLeft)) { - commandMoveParty(cmd.type); + if ((cmd._type >= kCommandMoveForward) && (cmd._type <= kCommandMoveLeft)) { + commandMoveParty(cmd._type); return; } diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index 8984b02f27..cdf0f06291 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -130,21 +130,21 @@ enum CommandType { class Command { public: - Common::Point pos; - CommandType type; + Common::Point _pos; + CommandType _type; - Command(Common::Point position, CommandType commandType): pos(position), type(commandType) {} + Command(Common::Point position, CommandType commandType): _pos(position), _type(commandType) {} }; // @ COMMAND class MouseInput { public: - CommandType commandTypeToIssue; - Box hitbox; - MouseButton button; + CommandType _commandTypeToIssue; + Box _hitbox; + MouseButton _button; MouseInput(CommandType type, uint16 x1, uint16 x2, uint16 y1, uint16 y2, MouseButton mouseButton) - : commandTypeToIssue(type), hitbox(x1, x2 + 1, y1, y2 + 1), button(mouseButton) {} + : _commandTypeToIssue(type), _hitbox(x1, x2 + 1, y1, y2 + 1), _button(mouseButton) {} }; // @ MOUSE_INPUT extern MouseInput gPrimaryMouseInput_Entrance[4]; // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4] @@ -172,11 +172,11 @@ extern MouseInput* gPrimaryMouseInput_DialogSets[2][4]; // @ G0480_aaps_PrimaryM class KeyboardInput { public: - Command commandToIssue; - Common::KeyCode key; - byte modifiers; + Command _commandToIssue; + Common::KeyCode _key; + byte _modifiers; - KeyboardInput(Command command, Common::KeyCode keycode, byte modifierFlags) : commandToIssue(command), key(keycode), modifiers(modifierFlags) {} + KeyboardInput(Command command, Common::KeyCode keycode, byte modifierFlags) : _commandToIssue(command), _key(keycode), _modifiers(modifierFlags) {} }; // @ KEYBOARD_INPUT class DMEngine; @@ -216,5 +216,4 @@ public: } - #endif diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index ae9ef62414..790c055784 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -682,9 +682,9 @@ void DisplayMan::loadGraphics() { void DisplayMan::unpackGraphics() { uint32 unpackedBitmapsSize = 0; for (uint16 i = 0; i <= 20; ++i) - unpackedBitmapsSize += width(i) * height(i); + unpackedBitmapsSize += getWidth(i) * getHeight(i); for (uint16 i = 22; i <= 532; ++i) - unpackedBitmapsSize += width(i) * height(i); + unpackedBitmapsSize += getWidth(i) * getHeight(i); // graphics items go from 0-20 and 22-532 inclusive, _unpackedItemPos 21 and 22 are there for indexing convenience if (_bitmaps) { delete[] _bitmaps[0]; @@ -694,12 +694,12 @@ void DisplayMan::unpackGraphics() { _bitmaps[0] = new byte[unpackedBitmapsSize]; loadIntoBitmap(0, _bitmaps[0]); for (uint16 i = 1; i <= 20; ++i) { - _bitmaps[i] = _bitmaps[i - 1] + width(i - 1) * height(i - 1); + _bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1); loadIntoBitmap(i, _bitmaps[i]); } - _bitmaps[22] = _bitmaps[20] + width(20) * height(20); + _bitmaps[22] = _bitmaps[20] + getWidth(20) * getHeight(20); for (uint16 i = 23; i < 533; ++i) { - _bitmaps[i] = _bitmaps[i - 1] + width(i - 1) * height(i - 1); + _bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1); loadIntoBitmap(i, _bitmaps[i]); } } @@ -771,7 +771,7 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uin for (uint16 x = 0; x < destToX - destFromX; ++x) { byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x]; if (srcPixel != transparent) - destBitmap[destWidth * (y + destFromY + destViewport.posY) + destFromX + x + destViewport.posX] = srcPixel; + destBitmap[destWidth * (y + destFromY + destViewport._posY) + destFromX + x + destViewport._posX] = srcPixel; } } @@ -820,25 +820,25 @@ byte *DisplayMan::getCurrentVgaBuffer() { return _vgaBuffer; } -uint16 DisplayMan::width(uint16 index) { +uint16 DisplayMan::getWidth(uint16 index) { byte *data = _packedBitmaps + _packedItemPos[index]; return READ_BE_UINT16(data); } -uint16 DisplayMan::height(uint16 index) { +uint16 DisplayMan::getHeight(uint16 index) { uint8 *data = _packedBitmaps + _packedItemPos[index]; return READ_BE_UINT16(data + 2); } void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { - if (f.srcWidth) - blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorNoTransparency, gDungeonViewport); + if (f._srcWidth) + blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorNoTransparency, gDungeonViewport); } void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) { - if (f.srcWidth) - blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport); + if (f._srcWidth) + blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorFlesh, gDungeonViewport); } void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { @@ -1085,7 +1085,7 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { } if (flippedFloorCeiling) { - uint16 w = gFloorFrame.srcWidth, h = gFloorFrame.srcHeight; + uint16 w = gFloorFrame._srcWidth, h = gFloorFrame._srcHeight; blitToBitmap(_floorBitmap, w, h, tmpBitmap, w); flipBitmapHorizontal(tmpBitmap, w, h); drawWallSetBitmap(tmpBitmap, gFloorFrame); @@ -1094,7 +1094,7 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i) _wallSetBitMaps[i + kWall_D0R] = _wallSetBitMaps[i + kWall_D0R_Flipped]; } else { - uint16 w = gCeilingFrame.srcWidth, h = gCeilingFrame.srcHeight; + uint16 w = gCeilingFrame._srcWidth, h = gCeilingFrame._srcHeight; blitToBitmap(_ceilingBitmap, w, h, tmpBitmap, w); flipBitmapHorizontal(tmpBitmap, w, h); drawWallSetBitmap(tmpBitmap, gCeilingFrame); @@ -1187,7 +1187,7 @@ void DisplayMan::loadWallSet(WallSet set) { for (uint16 i = 0; i < 7; ++i) { uint16 srcGraphicIndice = firstIndice + srcIndex[i]; - uint16 w = width(srcGraphicIndice), h = height(srcGraphicIndice); + uint16 w = getWidth(srcGraphicIndice), h = getHeight(srcGraphicIndice); delete[] _wallSetBitMaps[destIndex[i]]; _wallSetBitMaps[destIndex[i]] = new byte[w * h]; blitToBitmap(_wallSetBitMaps[srcIndex[i]], w, h, _wallSetBitMaps[destIndex[i]], w); @@ -1290,23 +1290,23 @@ void DisplayMan::loadCurrentMapGraphics() { void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor) { for (int16 i = 0; i < 6; ++i) - gPalDungeonView[i][replacedColor] = gCreatureReplColorSets[replacementColor].RGBColor[i]; + gPalDungeonView[i][replacedColor] = gCreatureReplColorSets[replacementColor]._RGBColor[i]; - gPalChangesCreature_D2[replacedColor] = gCreatureReplColorSets[replacementColor].D2ReplacementColor; - gPalChangesCreature_D3[replacedColor] = gCreatureReplColorSets[replacementColor].D3ReplacementColor; + gPalChangesCreature_D2[replacedColor] = gCreatureReplColorSets[replacementColor]._D2ReplacementColor; + gPalChangesCreature_D3[replacedColor] = gCreatureReplColorSets[replacementColor]._D3ReplacementColor; } void DisplayMan::drawFloorPitOrStairsBitmap(StairIndex relIndex, Frame &f) { - if (f.srcWidth) { - blitToScreen(_bitmaps[_stairIndices[relIndex]], f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport); + if (f._srcWidth) { + blitToScreen(_bitmaps[_stairIndices[relIndex]], f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorFlesh, gDungeonViewport); } } void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relIndex, Frame &f) { - if (f.srcWidth) { - blitToBitmap(_bitmaps[_stairIndices[relIndex]], f.srcWidth, f.srcHeight, _tmpBitmap, f.srcWidth); - flipBitmapHorizontal(_tmpBitmap, f.srcWidth, f.srcHeight); - blitToScreen(_tmpBitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport); + if (f._srcWidth) { + blitToBitmap(_bitmaps[_stairIndices[relIndex]], f._srcWidth, f._srcHeight, _tmpBitmap, f._srcWidth); + flipBitmapHorizontal(_tmpBitmap, f._srcWidth, f._srcHeight); + blitToScreen(_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorFlesh, gDungeonViewport); } } @@ -1370,8 +1370,8 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex if (viewWallIndex == kViewWall_D1C_FRONT) { if (isInscription) { Frame &D1CFrame = gFrameWalls[kViewSquare_D1C]; - blitToScreen(_wallSetBitMaps[kWall_D1LCR], D1CFrame.srcWidth, 94, 28, gBoxWallPatchBehindInscription.X1, gBoxWallPatchBehindInscription.X2, - gBoxWallPatchBehindInscription.Y1, gBoxWallPatchBehindInscription.Y2, kColorNoTransparency, gDungeonViewport); + blitToScreen(_wallSetBitMaps[kWall_D1LCR], D1CFrame._srcWidth, 94, 28, gBoxWallPatchBehindInscription._x1, gBoxWallPatchBehindInscription._x2, + gBoxWallPatchBehindInscription._y1, gBoxWallPatchBehindInscription._y2, kColorNoTransparency, gDungeonViewport); unsigned char *string = inscriptionString; bitmapRed = _bitmaps[kInscriptionFontIndice]; @@ -1382,12 +1382,12 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex while (*character++ < 0x80) { characterCount++; } - frame.destToX = (frame.destFromX = 112 - (characterCount * 4)) + 7; - frame.destFromY = (frame.destToY = gInscriptionLineY[textLineIndex++]) - 7; + frame._destToX = (frame._destFromX = 112 - (characterCount * 4)) + 7; + frame._destFromY = (frame._destToY = gInscriptionLineY[textLineIndex++]) - 7; while (characterCount--) { - blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame.destFromX, frame.destToX, frame.destFromY, frame.destToY, kColorFlesh, gDungeonViewport); - frame.destFromX += 8; - frame.destToX += 8; + blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._destFromX, frame._destToX, frame._destFromY, frame._destToY, kColorFlesh, gDungeonViewport); + frame._destFromX += 8; + frame._destToX += 8; } } while (*string++ != 0x81); return isAlcove; @@ -1457,14 +1457,14 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex } while (*string++ != 0x81); if (unreadableTextLineCount < 4) { - frame.destFromX = coordinateSetA[0]; - frame.destToX = coordinateSetA[1]; - frame.destFromY = coordinateSetA[2]; - frame.destToY = coordinateSetA[3]; - frame.srcWidth = coordinateSetA[4]; - frame.srcHeight = coordinateSetA[5]; + frame._destFromX = coordinateSetA[0]; + frame._destToX = coordinateSetA[1]; + frame._destFromY = coordinateSetA[2]; + frame._destToY = coordinateSetA[3]; + frame._srcWidth = coordinateSetA[4]; + frame._srcHeight = coordinateSetA[5]; - coordinateSetA = &frame.destFromX; + coordinateSetA = &frame._destFromX; coordinateSetA[3] = gUnreadableInscriptionBoxY2[gWallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1]; } @@ -1473,7 +1473,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex if ((viewWallIndex == kViewWall_D1C_FRONT) && _championPortraitOrdinal--) { Box &box = gBoxChampionPortraitOnWall; - blitToScreen(_bitmaps[kChampionPortraitsIndice], 256, (_championPortraitOrdinal & 0x7) << 5, (_championPortraitOrdinal >> 3) * 29, box.X1, box.X2, box.Y1, box.Y2, + blitToScreen(_bitmaps[kChampionPortraitsIndice], 256, (_championPortraitOrdinal & 0x7) << 5, (_championPortraitOrdinal >> 3) * 29, box._x1, box._x2, box._y1, box._y2, kColorDarkGary, gDungeonViewport); } return isAlcove; diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 241d45bfda..3283175086 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -31,14 +31,14 @@ extern uint16 gPalDungeonView[6][16]; class Box { public: - uint16 X1; - uint16 X2; - uint16 Y1; - uint16 Y2; + uint16 _x1; + uint16 _x2; + uint16 _y1; + uint16 _y2; - Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): X1(x1), X2(x2 + 1), Y1(y1), Y2(y2 + 1) {} + Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): _x1(x1), _x2(x2 + 1), _y1(y1), _y2(y2 + 1) {} bool isPointInside(Common::Point point) { - return (X1 <= point.x) && (point.x < X2) && (Y1 <= point.y) && (point.y < Y2); + return (_x1 <= point.x) && (point.x < _x2) && (_y1 <= point.y) && (point.y < _y2); } }; // @ BOX_BYTE, BOX_WORD @@ -46,15 +46,15 @@ extern Box gBoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows // The frames in the original sources contain inclusive boundaries and byte widths, not pixel widths struct Frame { - uint16 destFromX, destToX, destFromY, destToY; - uint16 srcWidth, srcHeight; - uint16 srcX, srcY; + uint16 _destFromX, _destToX, _destFromY, _destToY; + uint16 _srcWidth, _srcHeight; + uint16 _srcX, _srcY; Frame() {} Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) : - destFromX(destFromX), destToX(destToX + 1), destFromY(destFromY), destToY(destToY + 1), - srcWidth(srcWidth * 2), srcHeight(srcHeight), srcX(srcX), srcY(srcY) {} + _destFromX(destFromX), _destToX(destToX + 1), _destFromY(destFromY), _destToY(destToY + 1), + _srcWidth(srcWidth * 2), _srcHeight(srcHeight), _srcX(srcX), _srcY(srcY) {} }; enum WallSet { @@ -124,55 +124,55 @@ enum Color { struct Viewport { // TODO: should probably add width and height, seems redundant right meow - uint16 posX, posY; + uint16 _posX, _posY; }; struct CreatureAspect { - uint16 firstNativeBitmapRelativeIndex; - uint16 firstDerivedBitmapIndex; - byte byteWidthFront; - byte heightFront; - byte byteWidthSide; - byte heightSide; - byte byteWidthAttack; - byte heightAttack; - byte coordinateSet_TransparentColor; - byte replacementColorSetIndices; - - byte getCoordSet() { return (coordinateSet_TransparentColor >> 4) & 0xF; } // @ M71_COORDINATE_SET - byte getTranspColour() { return coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR - byte getReplColour10() { return (replacementColorSetIndices >> 4) & 0xF; } // @ M74_COLOR_10_REPLACEMENT_COLOR_SET - byte getReplColour9() { return replacementColorSetIndices & 0xF; } // @ M73_COLOR_09_REPLACEMENT_COLOR_SET + uint16 _firstNativeBitmapRelativeIndex; + uint16 _firstDerivedBitmapIndex; + byte _byteWidthFront; + byte _heightFront; + byte _byteWidthSide; + byte _heightSide; + byte _byteWidthAttack; + byte _heightAttack; + byte _coordinateSet_TransparentColor; + byte _replacementColorSetIndices; + + byte getCoordSet() { return (_coordinateSet_TransparentColor >> 4) & 0xF; } // @ M71_COORDINATE_SET + byte getTranspColour() { return _coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR + byte getReplColour10() { return (_replacementColorSetIndices >> 4) & 0xF; } // @ M74_COLOR_10_REPLACEMENT_COLOR_SET + byte getReplColour9() { return _replacementColorSetIndices & 0xF; } // @ M73_COLOR_09_REPLACEMENT_COLOR_SET }; // @ CREATURE_ASPECT struct ObjectAspect { - byte firstNativeBitmapRelativeIndex; - byte firstDerivedBitmapRelativeIndex; - byte width; - byte height; - byte graphicInfo; /* Bits 7-5 and 3-1 Unreferenced */ - byte coordinateSet; + byte _firstNativeBitmapRelativeIndex; + byte _firstDerivedBitmapRelativeIndex; + byte _width; + byte _height; + byte _graphicInfo; /* Bits 7-5 and 3-1 Unreferenced */ + byte _coordinateSet; ObjectAspect(byte firstN, byte firstD, byte byteWidth, byte h, byte grap, byte coord) : - firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD), - width(byteWidth * 2), height(h), graphicInfo(grap), coordinateSet(coord) {} + _firstNativeBitmapRelativeIndex(firstN), _firstDerivedBitmapRelativeIndex(firstD), + _width(byteWidth * 2), _height(h), _graphicInfo(grap), _coordinateSet(coord) {} }; // @ OBJECT_ASPECT struct ProjectileAspect { - byte firstNativeBitmapRelativeIndex; - byte firstDerivedBitmapRelativeIndex; - byte width; - byte height; - uint16 graphicInfo; /* Bits 15-9, 7-5 and 3-2 Unreferenced */ + byte _firstNativeBitmapRelativeIndex; + byte _firstDerivedBitmapRelativeIndex; + byte _width; + byte _height; + uint16 _graphicInfo; /* Bits 15-9, 7-5 and 3-2 Unreferenced */ ProjectileAspect(byte firstN, byte firstD, byte byteWidth, byte h, uint16 grap) : - firstNativeBitmapRelativeIndex(firstN), firstDerivedBitmapRelativeIndex(firstD), - width(byteWidth * 2), height(h), graphicInfo(grap) {} + _firstNativeBitmapRelativeIndex(firstN), _firstDerivedBitmapRelativeIndex(firstD), + _width(byteWidth * 2), _height(h), _graphicInfo(grap) {} }; // @ PROJECTIL_ASPECT struct CreatureReplColorSet { - uint16 RGBColor[6]; - byte D2ReplacementColor; - byte D3ReplacementColor; + uint16 _RGBColor[6]; + byte _D2ReplacementColor; + byte _D3ReplacementColor; }; // @ CREATURE_REPLACEMENT_COLOR_SET extern Viewport gDefultViewPort; @@ -265,9 +265,9 @@ public: void loadPalette(uint16 *palette); /// Gives the width of an IMG0 type item - uint16 width(uint16 index); + uint16 getWidth(uint16 index); /// Gives the height of an IMG1 type item - uint16 height(uint16 index); + uint16 getHeight(uint16 index); void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte *destBitmap, uint16 destWidth, diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 1b4c68dafe..4e079e4263 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -10,9 +10,9 @@ void MenuMan::drawMovementArrows() { DisplayMan &disp = *_vm->_displayMan; byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice); Box &dest = gBoxMovementArrows; - uint16 w = disp.width(kMovementArrowsIndice); + uint16 w = disp.getWidth(kMovementArrowsIndice); - disp.blitToScreen(arrowsBitmap, w, 0, 0, dest.X1, dest.X2, dest.Y1, dest.Y2, kColorNoTransparency); + disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency); } } \ No newline at end of file -- cgit v1.2.3 From 78d8a8d3c842cfa94b011cf318680d4ad3e71bd0 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 19:42:05 +0200 Subject: DM: Add several global variables, add code to F0462_START_StartGame_CPSF --- engines/dm/champion.h | 2 ++ engines/dm/dm.cpp | 24 ++++++++++++++++++++++-- engines/dm/dm.h | 5 +++++ engines/dm/eventman.h | 3 ++- engines/dm/gfx.h | 2 ++ engines/dm/menus.h | 1 + 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 5844760c05..2dda3de06a 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -256,6 +256,8 @@ public: Thing _leaderHand; // @ G0414_T_LeaderHandObject ChampionIndex _leaderIndex; // @ G0411_i_LeaderIndex uint16 _candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal + bool _partyIsSleeping; // @ G0300_B_PartyIsSleeping + uint16 _actingChampionOrdinal; // @ G0506_ui_ActingChampionOrdinal ChampionMan(DMEngine *vm); }; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 2ff815cadb..a669154ea3 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -94,17 +94,37 @@ void DMEngine::initializeGame() { void DMEngine::startGame() { + _pressingEye = false; + _stopPressingEye = false; + _pressingMouth = false; + _stopPressingMouth = false; + _highlightBoxInversionRequested = false; + _eventMan->_highlightBoxEnabled = false; + _championMan->_partyIsSleeping = false; + _championMan->_actingChampionOrdinal = indexToOrdinal(kChampionNone); + _menuMan->_actionAreaContainsIcons = true; + _eventMan->_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kChampionNone); + _eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface; _eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement; + warning("MISSING CODE: set primary/secondary keyboard input"); + + // MISSING CODE: F0003_MAIN_ProcessNewPartyMap_CPSE // TODO:(next 2 lines) move to F0003_MAIN_ProcessNewPartyMap_CPSE _dungeonMan->setCurrentMapAndPartyMap(0); _displayMan->loadCurrentMapGraphics(); + if (!_dungeonMan->_messages._newGame) { + // MISSING CODE: loading game + } { + _displayMan->_useByteBoxCoordinates = false; + // MISSING CODE: clear screen + } + // MISSING CODE: build copper _menuMan->drawMovementArrows(); + warning("MISSING CODE: F0278_CHAMPION_ResetDataToStartGame"); _gameTimeTicking = true; - - // MISSING CODE: Lot of stuff } Common::Error DMEngine::run() { diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 888e6313be..468390dd2b 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -102,6 +102,11 @@ public: bool _gameTimeTicking; // @ G0301_B_GameTimeTicking bool _restartGameAllowed; // @ G0524_B_RestartGameAllowed uint32 _gameId; // @ G0525_l_GameID, probably useless here + bool _pressingEye; // @ G0331_B_PressingEye + bool _stopPressingEye; // @ G0332_B_StopPressingEye + bool _pressingMouth; // @ G0333_B_PressingMouth + bool _stopPressingMouth; // @ G0334_B_StopPressingMouth + bool _highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested }; class Console : public GUI::Debugger { diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index cdf0f06291..b2834e813e 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -199,7 +199,8 @@ class EventManager { public: MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput - + bool _highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled + uint16 _useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap EventManager(DMEngine *vm); void initMouse(); void showMouse(bool visibility); diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 3283175086..86a152af9c 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -304,6 +304,8 @@ public: int16 _currMapViAltarIndex; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex Thing _inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing + + bool _useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates }; } diff --git a/engines/dm/menus.h b/engines/dm/menus.h index c1ceddd8ab..6006d7a210 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -9,6 +9,7 @@ class MenuMan { DMEngine *_vm; public: bool _shouldRefreshActionArea; // @ G0508_B_RefreshActionArea + bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons MenuMan(DMEngine *vm); void drawMovementArrows(); -- cgit v1.2.3 From 43cedc4c78a0565df6eb37b9e16ac07ba2e498e7 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 19:58:19 +0200 Subject: DM: Add F0003_MAIN_ProcessNewPartyMap_CPSE --- engines/dm/dm.cpp | 13 +++++++++---- engines/dm/dm.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index a669154ea3..d8eb3b817e 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -109,10 +109,7 @@ void DMEngine::startGame() { _eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement; warning("MISSING CODE: set primary/secondary keyboard input"); - // MISSING CODE: F0003_MAIN_ProcessNewPartyMap_CPSE - // TODO:(next 2 lines) move to F0003_MAIN_ProcessNewPartyMap_CPSE - _dungeonMan->setCurrentMapAndPartyMap(0); - _displayMan->loadCurrentMapGraphics(); + processNewPartyMap(_dungeonMan->_currMap._currPartyMapIndex); if (!_dungeonMan->_messages._newGame) { // MISSING CODE: loading game @@ -127,6 +124,14 @@ void DMEngine::startGame() { _gameTimeTicking = true; } +void DMEngine::processNewPartyMap(uint16 mapIndex) { + warning("MISSING CODE: F0194_GROUP_RemoveAllActiveGroups"); + _dungeonMan->setCurrentMapAndPartyMap(mapIndex); + _displayMan->loadCurrentMapGraphics(); + warning("MISSING CODE: F0195_GROUP_AddAllActiveGroups"); + warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette"); +} + Common::Error DMEngine::run() { // scummvm/engine specific initGraphics(320, 200, false); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 468390dd2b..a900b863bf 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -80,6 +80,7 @@ enum { class DMEngine : public Engine { void startGame(); // @ F0462_START_StartGame_CPSF + void processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE public: DMEngine(OSystem *syst); ~DMEngine(); -- cgit v1.2.3 From bcf8e07f2859ae8f04d414bc84975e67dd7dc5f0 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 20:27:31 +0200 Subject: DM: Add IconIndex enum, F0278_CHAMPION_ResetDataToStartGame, related global variables --- engines/dm/champion.cpp | 12 ++++++++ engines/dm/champion.h | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/dm.cpp | 2 +- 3 files changed, 92 insertions(+), 1 deletion(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 5ba529d263..83d520443e 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1,4 +1,5 @@ #include "champion.h" +#include "dungeonman.h" namespace DM { @@ -32,4 +33,15 @@ ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { return kChampionNone; } +void ChampionMan::resetDataToStartGame() { + if (!_vm->_dungeonMan->_messages._newGame) { + warning("MISSING CODE: stuff for reeseting for loaded games"); + assert(false); + } + + _leaderHand = Thing::_thingNone; + _leaderHandObjectIconIndex = kIconIndiceNone; + _leaderEmptyHanded = true; +} + } \ No newline at end of file diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 2dda3de06a..89a1d059b9 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -6,6 +6,82 @@ namespace DM { +enum IconIndice { + kIconIndiceNone = -1, // @ CM1_ICON_NONE + kIconIndiceJunkCompassNorth = 0, // @ C000_ICON_JUNK_COMPASS_NORTH + kIconIndiceJunkCompassWest = 3, // @ C003_ICON_JUNK_COMPASS_WEST + kIconIndiceWeaponTorchUnlit = 4, // @ C004_ICON_WEAPON_TORCH_UNLIT + kIconIndiceWeaponTorchLit = 7, // @ C007_ICON_WEAPON_TORCH_LIT + kIconIndiceJunkWater = 8, // @ C008_ICON_JUNK_WATER + kIconIndiceJunkWaterSkin = 9, // @ C009_ICON_JUNK_WATERSKIN + kIconIndiceJunkJewelSymalUnequipped = 10, // @ C010_ICON_JUNK_JEWEL_SYMAL_UNEQUIPPED + kIconIndiceJunkJewelSymalEquipped = 11, // @ C011_ICON_JUNK_JEWEL_SYMAL_EQUIPPED + kIconIndiceJunkIllumuletUnequipped = 12, // @ C012_ICON_JUNK_ILLUMULET_UNEQUIPPED + kIconIndiceJunkIllumuletEquipped = 13, // @ C013_ICON_JUNK_ILLUMULET_EQUIPPED + kIconIndiceWeaponFlamittEmpty = 14, // @ C014_ICON_WEAPON_FLAMITT_EMPTY + kIconIndiceWeaponEyeOfTimeEmpty = 16, // @ C016_ICON_WEAPON_EYE_OF_TIME_EMPTY + kIconIndiceWeaponStormringEmpty = 18, // @ C018_ICON_WEAPON_STORMRING_EMPTY + kIconIndiceWeaponStaffOfClawsEmpty = 20, // @ C020_ICON_WEAPON_STAFF_OF_CLAWS_EMPTY + kIconIndiceWeaponStaffOfClawsFull = 22, // @ C022_ICON_WEAPON_STAFF_OF_CLAWS_FULL + kIconIndiceWeaponBoltBladeStormEmpty = 23, // @ C023_ICON_WEAPON_BOLT_BLADE_STORM_EMPTY + kIconIndiceWeaponFuryRaBladeEmpty = 25, // @ C025_ICON_WEAPON_FURY_RA_BLADE_EMPTY + kIconIndiceWeaponTheFirestaff = 27, // @ C027_ICON_WEAPON_THE_FIRESTAFF + kIconIndiceWeaponTheFirestaffComplete = 28, // @ C028_ICON_WEAPON_THE_FIRESTAFF_COMPLETE + kIconIndiceScrollOpen = 30, // @ C030_ICON_SCROLL_SCROLL_OPEN + kIconIndiceScrollClosed = 31, // @ C031_ICON_SCROLL_SCROLL_CLOSED + kIconIndiceWeaponDagger = 32, // @ C032_ICON_WEAPON_DAGGER + kIconIndiceWeaponDeltaSideSplitter = 38, // @ C038_ICON_WEAPON_DELTA_SIDE_SPLITTER + kIconIndiceWeaponDiamondEdge = 39, // @ C039_ICON_WEAPON_DIAMOND_EDGE + kIconIndiceWeaponVorpalBlade = 40, // @ C040_ICON_WEAPON_VORPAL_BLADE + kIconIndiceWeaponTheInquisitorDragonFang = 41, // @ C041_ICON_WEAPON_THE_INQUISITOR_DRAGON_FANG + kIconIndiceWeaponHardcleaveExecutioner = 43, // @ C043_ICON_WEAPON_HARDCLEAVE_EXECUTIONER + kIconIndiceWeaponMaceOfOrder = 45, // @ C045_ICON_WEAPON_MACE_OF_ORDER + kIconIndiceWeaponArrow = 51, // @ C051_ICON_WEAPON_ARROW + kIconIndiceWeaponSlayer = 52, // @ C052_ICON_WEAPON_SLAYER + kIconIndiceWeaponRock = 54, // @ C054_ICON_WEAPON_ROCK + kIconIndiceWeaponPoisonDart = 55, // @ C055_ICON_WEAPON_POISON_DART + kIconIndiceWeaponThrowingStar = 56, // @ C056_ICON_WEAPON_THROWING_STAR + kIconIndiceWeaponStaff = 58, // @ C058_ICON_WEAPON_STAFF + kIconIndiceWeaponWand = 59, // @ C059_ICON_WEAPON_WAND + kIconIndiceWeaponTeowand = 60, // @ C060_ICON_WEAPON_TEOWAND + kIconIndiceWeaponYewStaff = 61, // @ C061_ICON_WEAPON_YEW_STAFF + kIconIndiceWeaponStaffOfManarStaffOfIrra = 62, // @ C062_ICON_WEAPON_STAFF_OF_MANAR_STAFF_OF_IRRA + kIconIndiceWeaponSnakeStaffCrossOfNeta = 63, // @ C063_ICON_WEAPON_SNAKE_STAFF_CROSS_OF_NETA + kIconIndiceWeaponTheConduitSerpentStaff = 64, // @ C064_ICON_WEAPON_THE_CONDUIT_SERPENT_STAFF + kIconIndiceWeaponDragonSpit = 65, // @ C065_ICON_WEAPON_DRAGON_SPIT + kIconIndiceWeaponSceptreOfLyf = 66, // @ C066_ICON_WEAPON_SCEPTRE_OF_LYF + kIconIndiceArmourCloakOfNight = 81, // @ C081_ICON_ARMOUR_CLOAK_OF_NIGHT + kIconIndiceArmourCrownOfNerra = 104, // @ C104_ICON_ARMOUR_CROWN_OF_NERRA + kIconIndiceArmourElvenBoots = 119, // @ C119_ICON_ARMOUR_ELVEN_BOOTS + kIconIndiceJunkGemOfAges = 120, // @ C120_ICON_JUNK_GEM_OF_AGES + kIconIndiceJunkEkkhardCross = 121, // @ C121_ICON_JUNK_EKKHARD_CROSS + kIconIndiceJunkMoonstone = 122, // @ C122_ICON_JUNK_MOONSTONE + kIconIndiceJunkPendantFeral = 124, // @ C124_ICON_JUNK_PENDANT_FERAL + kIconIndiceJunkBoulder = 128, // @ C128_ICON_JUNK_BOULDER + kIconIndiceJunkRabbitsFoot = 137, // @ C137_ICON_JUNK_RABBITS_FOOT + kIconIndiceArmourDexhelm = 140, // @ C140_ICON_ARMOUR_DEXHELM + kIconIndiceArmourFlamebain = 141, // @ C141_ICON_ARMOUR_FLAMEBAIN + kIconIndiceArmourPowertowers = 142, // @ C142_ICON_ARMOUR_POWERTOWERS + kIconIndiceContainerChestClosed = 144, // @ C144_ICON_CONTAINER_CHEST_CLOSED + kIconIndiceContainerChestOpen = 145, // @ C145_ICON_CONTAINER_CHEST_OPEN + kIconIndiceJunkChampionBones = 147, // @ C147_ICON_JUNK_CHAMPION_BONES + kIconIndicePotionMaPotionMonPotion = 148, // @ C148_ICON_POTION_MA_POTION_MON_POTION + kIconIndicePotionWaterFlask = 163, // @ C163_ICON_POTION_WATER_FLASK + kIconIndiceJunkApple = 168, // @ C168_ICON_JUNK_APPLE + kIconIndiceJunkIronKey = 176, // @ C176_ICON_JUNK_IRON_KEY + kIconIndiceJunkMasterKey = 191, // @ C191_ICON_JUNK_MASTER_KEY + kIconIndiceArmourBootOfSpeed = 194, // @ C194_ICON_ARMOUR_BOOT_OF_SPEED + kIconIndicePotionEmptyFlask = 195, // @ C195_ICON_POTION_EMPTY_FLASK + kIconIndiceJunkZokathra = 197, // @ C197_ICON_JUNK_ZOKATHRA + kIconIndiceActionEmptyHand = 201, // @ C201_ICON_ACTION_ICON_EMPTY_HAND + kIconIndiceEyeNotLooking = 202, // @ C202_ICON_EYE_NOT_LOOKING /* One pixel is different in this bitmap from the eye in C017_GRAPHIC_INVENTORY. This is visible by selecting another champion after clicking the eye */ + kIconIndiceEyeLooking = 203, // @ C203_ICON_EYE_LOOKING + kIconIndiceEmptyBox = 204, // @ C204_ICON_EMPTY_BOX + kIconIndiceMouthOpen = 205, // @ C205_ICON_MOUTH_OPEN + kIconIndiceNeck = 208, // @ C208_ICON_NECK + kIconIndiceReadyHand = 212 // @ C212_ICON_READY_HAND +}; + enum ChampionIndex { kChampionNone = -1, // @ CM1_CHAMPION_NONE kChampionFirst = 0, // @ C00_CHAMPION_FIRST @@ -258,8 +334,11 @@ public: uint16 _candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal bool _partyIsSleeping; // @ G0300_B_PartyIsSleeping uint16 _actingChampionOrdinal; // @ G0506_ui_ActingChampionOrdinal + IconIndice _leaderHandObjectIconIndex; // @ G0413_i_LeaderHandObjectIconIndex + bool _leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded ChampionMan(DMEngine *vm); + void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame }; } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index d8eb3b817e..1466c807e8 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -120,7 +120,7 @@ void DMEngine::startGame() { // MISSING CODE: build copper _menuMan->drawMovementArrows(); - warning("MISSING CODE: F0278_CHAMPION_ResetDataToStartGame"); + _championMan->resetDataToStartGame(); _gameTimeTicking = true; } -- cgit v1.2.3 From cc6ff27dd34b3c72ecff18aeca08fa6d1f574999 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 20:36:00 +0200 Subject: DM: Move F0463_START_InitializeGame_CPSADEF, F0002_MAIN_GameLoop_CPSDF in DMEngine to private --- engines/dm/dm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/dm/dm.h b/engines/dm/dm.h index a900b863bf..468cd5c528 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -81,13 +81,13 @@ enum { class DMEngine : public Engine { void startGame(); // @ F0462_START_StartGame_CPSF void processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE + void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF + void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF public: DMEngine(OSystem *syst); ~DMEngine(); virtual Common::Error run(); // @ main - void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF - void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF private: Console *_console; -- cgit v1.2.3 From 6b833550b0371919c9108ceb36c916a7030f9b7c Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 20:45:25 +0200 Subject: DM: Add F0388_MENUS_ClearActingChampion --- engines/dm/menus.cpp | 12 ++++++++++++ engines/dm/menus.h | 1 + 2 files changed, 13 insertions(+) diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 4e079e4263..d7948c25e4 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -1,5 +1,7 @@ #include "menus.h" #include "gfx.h" +#include "champion.h" +#include "dungeonman.h" namespace DM { @@ -14,5 +16,15 @@ void MenuMan::drawMovementArrows() { disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency); } +void MenuMan::clearActingChampion() { + ChampionMan &cm = *_vm->_championMan; + if (cm._actingChampionOrdinal) { + cm._actingChampionOrdinal--; + cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true); + warning("MISSING CODE: F0292_CHAMPION_DrawState"); + cm._actingChampionOrdinal = indexToOrdinal(kChampionNone); + _shouldRefreshActionArea = true; + } +} } \ No newline at end of file diff --git a/engines/dm/menus.h b/engines/dm/menus.h index 6006d7a210..ce6c1667fe 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -11,6 +11,7 @@ public: bool _shouldRefreshActionArea; // @ G0508_B_RefreshActionArea bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons MenuMan(DMEngine *vm); + void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion void drawMovementArrows(); }; -- cgit v1.2.3 From 7dd90c3daf2d9955ba232c0ed70d1f4b90ba81e9 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 18 Jun 2016 23:05:45 +0200 Subject: DM: Add F0141_DUNGEON_GetObjectInfoIndex, getType for Container --- engines/dm/dungeonman.cpp | 28 ++++++++++++++++++++++++++++ engines/dm/dungeonman.h | 4 +++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 6b577ca3af..93bde021e0 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1036,4 +1036,32 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { return 0; // dummy } +/* Object info */ +#define kObjectInfoIndexFirstScroll 0 // @ C000_OBJECT_INFO_INDEX_FIRST_SCROLL +#define kObjectInfoIndexFirstContainer 1 // @ C001_OBJECT_INFO_INDEX_FIRST_CONTAINER +#define kObjectInfoIndexFirstPotion 2 // @ C002_OBJECT_INFO_INDEX_FIRST_POTION +#define kObjectInfoIndexFirstWeapon 23 // @ C023_OBJECT_INFO_INDEX_FIRST_WEAPON +#define kObjectInfoIndexFirstArmour 69 // @ C069_OBJECT_INFO_INDEX_FIRST_ARMOUR +#define kObjectInfoIndexFirstJunk 127 // @ C127_OBJECT_INFO_INDEX_FIRST_JUNK + +int16 DungeonMan::getObjectInfoIndex(Thing thing) { + uint16 *rawType = getThingData(thing); + switch (thing.getType()) { + case kScrollThingType: + return kObjectInfoIndexFirstScroll; + case kContainerThingType: + return kObjectInfoIndexFirstContainer + Container(rawType).getType(); + case kJunkThingType: + return kObjectInfoIndexFirstJunk + Junk(rawType).getType(); + case kWeaponThingType: + return kObjectInfoIndexFirstWeapon + Weapon(rawType).getType(); + case kArmourThingType: + return kObjectInfoIndexFirstArmour + Armour(rawType).getType(); + case kPotionThingType: + return kObjectInfoIndexFirstPotion + Potion(rawType).getType(); + default: + return -1; + } +} + } \ No newline at end of file diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index aba2872a65..0a68600c1a 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -341,6 +341,7 @@ class Container { public: Container(uint16 *rawDat) : _nextThing(rawDat[0]), _nextContainedThing(rawDat[1]), _type(rawDat[2]) {} + uint16 getType() { return (_type >> 1) & 0x3; } Thing getNextContainedThing() { return _nextContainedThing; } Thing getNextThing() { return _nextThing; } }; // @ CONTAINER @@ -554,7 +555,8 @@ public: void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect void decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText - uint16 getObjectWeight(Thing thing);// @ F0140_DUNGEON_GetObjectWeight + uint16 getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight + int16 getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex uint32 _rawDunFileDataSize; // @ probably NONE byte *_rawDunFileData; // @ ??? -- cgit v1.2.3 From c97a4560b21ba73537e59cbcc9c18d8943992231 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 19 Jun 2016 00:24:19 +0200 Subject: DM: Change some comments to warnings --- engines/dm/dm.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 1466c807e8..2a20b86410 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -80,7 +80,7 @@ void DMEngine::initializeGame() { _eventMan->initMouse(); while (_loadsaveMan->loadgame() != kLoadgameSuccess) { - // MISSING CODE: F0441_STARTEND_ProcessEntrance + warning("TODO: F0441_STARTEND_ProcessEntrance"); } _displayMan->loadFloorSet(kFloorSetStone); @@ -112,13 +112,13 @@ void DMEngine::startGame() { processNewPartyMap(_dungeonMan->_currMap._currPartyMapIndex); if (!_dungeonMan->_messages._newGame) { - // MISSING CODE: loading game + warning("TODO: loading game"); } { _displayMan->_useByteBoxCoordinates = false; - // MISSING CODE: clear screen + warning("TODO: clear screen"); } - // MISSING CODE: build copper + warning("TODO: build copper"); _menuMan->drawMovementArrows(); _championMan->resetDataToStartGame(); _gameTimeTicking = true; @@ -147,7 +147,7 @@ Common::Error DMEngine::run() { initializeGame(); // @ F0463_START_InitializeGame_CPSADEF while (true) { gameloop(); - // MISSING CODE: F0444_STARTEND_Endgame(G0303_B_PartyDead); + warning("TODO: F0444_STARTEND_Endgame(G0303_B_PartyDead);"); } return Common::kNoError; -- cgit v1.2.3 From 16d65d476d2acdefd559e79e34b1854cc4d141d3 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 00:26:01 +0200 Subject: DM: Add ObjectInfo --- engines/dm/dungeonman.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 0a68600c1a..00dbcc2c9c 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -8,6 +8,40 @@ namespace DM { +enum ObjectAllowedSlot { + kObjectAllowedSlotMouth = 0x0001, // @ MASK0x0001_MOUTH + kObjectAllowedSlotHead = 0x0002, // @ MASK0x0002_HEAD + kObjectAllowedSlotNeck = 0x0004, // @ MASK0x0004_NECK + kObjectAllowedSlotTorso = 0x0008, // @ MASK0x0008_TORSO + kObjectAllowedSlotLegs = 0x0010, // @ MASK0x0010_LEGS + kObjectAllowedSlotFeet = 0x0020, // @ MASK0x0020_FEET + kObjectAllowedSlotQuiverLine_1 = 0x0040, // @ MASK0x0040_QUIVER_LINE1 + kObjectAllowedSlotQuiverLine_2 = 0x0080, // @ MASK0x0080_QUIVER_LINE2 + kObjectAllowedSlotPouchPassAndThroughDoors = 0x0100, // @ MASK0x0100_POUCH_PASS_AND_THROUGH_DOORS + kObjectAllowedSlotHands = 0x0200, // @ MASK0x0200_HANDS + kObjectAllowedSlotContainer = 0x0400 // @ MASK0x0400_CONTAINER +}; + +class ObjectInfo { +public: + int16 _type; + uint16 _objectAspectIndex; + uint16 _actionSetIndex; +private: + uint16 _allowedSlots; +public: + ObjectInfo(int16 type, uint16 objectAspectIndex, uint16 actionSetIndex, uint16 allowedSlots) + : _type(type), _objectAspectIndex(objectAspectIndex), _actionSetIndex(actionSetIndex), _allowedSlots(allowedSlots) {} + bool getAllowedSlot(ObjectAllowedSlot slot) { return _allowedSlots & slot; } + void setAllowedSlot(ObjectAllowedSlot slot, bool val) { + if (val) { + _allowedSlots |= slot; + } else { + _allowedSlots &= ~slot; + } + } +}; // @ OBJECT_INFO + extern uint16 gJunkInfo[53]; enum ArmourAttribute { -- cgit v1.2.3 From b7c225b4d4fe1bbdf0cd13ac0b72c1f614e37be0 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 00:29:56 +0200 Subject: DM: Add G0237_as_Graphic559_ObjectInfo --- engines/dm/dungeonman.cpp | 183 ++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/dungeonman.h | 2 + 2 files changed, 185 insertions(+) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 93bde021e0..01791bf94a 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -6,6 +6,189 @@ namespace DM { +ObjectInfo gObjectInfo[180] = { // @ G0237_as_Graphic559_ObjectInfo +/* { Type, ObjectAspectIndex, ActionSetIndex, AllowedSlots } */ + ObjectInfo(30, 1, 0, 0x0500), /* COMPASS Pouch/Chest */ + ObjectInfo(144, 0, 0, 0x0200), /* COMPASS Hands */ + ObjectInfo(148, 67, 0, 0x0500), /* COMPASS Pouch/Chest */ + ObjectInfo(149, 67, 0, 0x0500), /* COMPASS Pouch/Chest */ + ObjectInfo(150, 67, 0, 0x0500), /* TORCH Pouch/Chest */ + ObjectInfo(151, 67, 42, 0x0500), /* TORCH Pouch/Chest */ + ObjectInfo(152, 67, 0, 0x0500), /* TORCH Pouch/Chest */ + ObjectInfo(153, 67, 0, 0x0500), /* TORCH Pouch/Chest */ + ObjectInfo(154, 2, 0, 0x0501), /* WATERSKIN Mouth/Pouch/Chest */ + ObjectInfo(155, 2, 0, 0x0501), /* WATER Mouth/Pouch/Chest */ + ObjectInfo(156, 2, 0, 0x0501), /* JEWEL SYMAL Mouth/Pouch/Chest */ + ObjectInfo(157, 2, 0, 0x0501), /* JEWEL SYMAL Mouth/Pouch/Chest */ + ObjectInfo(158, 2, 0, 0x0501), /* ILLUMULET Mouth/Pouch/Chest */ + ObjectInfo(159, 2, 0, 0x0501), /* ILLUMULET Mouth/Pouch/Chest */ + ObjectInfo(160, 2, 0, 0x0501), /* FLAMITT Mouth/Pouch/Chest */ + ObjectInfo(161, 2, 0, 0x0501), /* FLAMITT Mouth/Pouch/Chest */ + ObjectInfo(162, 2, 0, 0x0501), /* EYE OF TIME Mouth/Pouch/Chest */ + ObjectInfo(163, 2, 0, 0x0501), /* EYE OF TIME Mouth/Pouch/Chest */ + ObjectInfo(164, 68, 0, 0x0500), /* STORMRING Pouch/Chest */ + ObjectInfo(165, 68, 0, 0x0500), /* STORMRING Pouch/Chest */ + ObjectInfo(166, 68, 0, 0x0500), /* STAFF OF CLAWS Pouch/Chest */ + ObjectInfo(167, 68, 42, 0x0500), /* STAFF OF CLAWS Pouch/Chest */ + ObjectInfo(195, 80, 0, 0x0500), /* STAFF OF CLAWS Pouch/Chest */ + ObjectInfo(16, 38, 43, 0x0500), /* BOLT BLADE Pouch/Chest */ + ObjectInfo(18, 38, 7, 0x0500), /* BOLT BLADE Pouch/Chest */ + ObjectInfo(4, 35, 5, 0x0400), /* FURY Chest */ + ObjectInfo(14, 37, 6, 0x0400), /* FURY Chest */ + ObjectInfo(20, 11, 8, 0x0040), /* THE FIRESTAFF Quiver 1 */ + ObjectInfo(23, 12, 9, 0x0040), /* THE FIRESTAFF Quiver 1 */ + ObjectInfo(25, 12, 10, 0x0040), /* THE FIRESTAFF Quiver 1 */ + ObjectInfo(27, 39, 11, 0x0040), /* OPEN SCROLL Quiver 1 */ + ObjectInfo(32, 17, 12, 0x05C0), /* SCROLL Quiver 1/Quiver 2/Pouch/Chest */ + ObjectInfo(33, 12, 13, 0x0040), /* DAGGER Quiver 1 */ + ObjectInfo(34, 12, 13, 0x0040), /* FALCHION Quiver 1 */ + ObjectInfo(35, 12, 14, 0x0040), /* SWORD Quiver 1 */ + ObjectInfo(36, 12, 15, 0x0040), /* RAPIER Quiver 1 */ + ObjectInfo(37, 12, 15, 0x0040), /* SABRE Quiver 1 */ + ObjectInfo(38, 12, 16, 0x0040), /* SAMURAI SWORD Quiver 1 */ + ObjectInfo(39, 12, 17, 0x0040), /* DELTA Quiver 1 */ + ObjectInfo(40, 42, 18, 0x0040), /* DIAMOND EDGE Quiver 1 */ + ObjectInfo(41, 12, 19, 0x0040), /* VORPAL BLADE Quiver 1 */ + ObjectInfo(42, 13, 20, 0x0040), /* THE INQUISITOR Quiver 1 */ + ObjectInfo(43, 13, 21, 0x0040), /* AXE Quiver 1 */ + ObjectInfo(44, 21, 22, 0x0040), /* HARDCLEAVE Quiver 1 */ + ObjectInfo(45, 21, 22, 0x0040), /* MACE Quiver 1 */ + ObjectInfo(46, 33, 23, 0x0440), /* MACE OF ORDER Quiver 1/Chest */ + ObjectInfo(47, 43, 24, 0x0040), /* MORNINGSTAR Quiver 1 */ + ObjectInfo(48, 44, 24, 0x0040), /* CLUB Quiver 1 */ + ObjectInfo(49, 14, 27, 0x0040), /* STONE CLUB Quiver 1 */ + ObjectInfo(50, 45, 27, 0x0040), /* BOW Quiver 1 */ + ObjectInfo(51, 16, 26, 0x05C0), /* CROSSBOW Quiver 1/Quiver 2/Pouch/Chest */ + ObjectInfo(52, 46, 26, 0x05C0), /* ARROW Quiver 1/Quiver 2/Pouch/Chest */ + ObjectInfo(53, 11, 27, 0x0440), /* SLAYER Quiver 1/Chest */ + ObjectInfo(54, 47, 42, 0x05C0), /* SLING Quiver 1/Quiver 2/Pouch/Chest */ + ObjectInfo(55, 48, 40, 0x05C0), /* ROCK Quiver 1/Quiver 2/Pouch/Chest */ + ObjectInfo(56, 49, 42, 0x05C0), /* POISON DART Quiver 1/Quiver 2/Pouch/Chest */ + ObjectInfo(57, 50, 5, 0x0040), /* THROWING STAR Quiver 1 */ + ObjectInfo(58, 11, 5, 0x0040), /* STICK Quiver 1 */ + ObjectInfo(59, 31, 28, 0x0540), /* STAFF Quiver 1/Pouch/Chest */ + ObjectInfo(60, 31, 29, 0x0540), /* WAND Quiver 1/Pouch/Chest */ + ObjectInfo(61, 11, 30, 0x0040), /* TEOWAND Quiver 1 */ + ObjectInfo(62, 11, 31, 0x0040), /* YEW STAFF Quiver 1 */ + ObjectInfo(63, 11, 32, 0x0040), /* STAFF OF MANAR Quiver 1 Atari ST Version 1.0 1987-12-08: ObjectAspectIndex = 35 */ + ObjectInfo(64, 51, 33, 0x0040), /* SNAKE STAFF Quiver 1 */ + ObjectInfo(65, 32, 5, 0x0440), /* THE CONDUIT Quiver 1/Chest */ + ObjectInfo(66, 30, 35, 0x0040), /* DRAGON SPIT Quiver 1 */ + ObjectInfo(135, 65, 36, 0x0440), /* SCEPTRE OF LYF Quiver 1/Chest */ + ObjectInfo(143, 45, 27, 0x0040), /* ROBE Quiver 1 */ + ObjectInfo(28, 82, 1, 0x0040), /* FINE ROBE Quiver 1 */ + ObjectInfo(80, 23, 0, 0x040C), /* KIRTLE Neck/Torso/Chest */ + ObjectInfo(81, 23, 0, 0x040C), /* SILK SHIRT Neck/Torso/Chest */ + ObjectInfo(82, 23, 0, 0x0410), /* ELVEN DOUBLET Legs/Chest */ + ObjectInfo(112, 55, 0, 0x0420), /* LEATHER JERKIN Feet/Chest */ + ObjectInfo(114, 8, 0, 0x0420), /* TUNIC Feet/Chest */ + ObjectInfo(67, 24, 0, 0x0408), /* GHI Torso/Chest */ + ObjectInfo(83, 24, 0, 0x0410), /* MAIL AKETON Legs/Chest */ + ObjectInfo(68, 24, 0, 0x0408), /* MITHRAL AKETON Torso/Chest */ + ObjectInfo(84, 24, 0, 0x0410), /* TORSO PLATE Legs/Chest */ + ObjectInfo(69, 69, 0, 0x0408), /* PLATE OF LYTE Torso/Chest */ + ObjectInfo(70, 24, 0, 0x0408), /* PLATE OF DARC Torso/Chest */ + ObjectInfo(85, 24, 0, 0x0410), /* CAPE Legs/Chest */ + ObjectInfo(86, 69, 0, 0x0410), /* CLOAK OF NIGHT Legs/Chest */ + ObjectInfo(71, 7, 0, 0x0408), /* BARBARIAN HIDE Torso/Chest */ + ObjectInfo(87, 7, 0, 0x0410), /* ROBE Legs/Chest */ + ObjectInfo(119, 57, 0, 0x0420), /* FINE ROBE Feet/Chest */ + ObjectInfo(72, 23, 0, 0x0408), /* TABARD Torso/Chest */ + ObjectInfo(88, 23, 0, 0x0410), /* GUNNA Legs/Chest */ + ObjectInfo(113, 29, 0, 0x0420), /* ELVEN HUKE Feet/Chest */ + ObjectInfo(89, 69, 0, 0x0410), /* LEATHER PANTS Legs/Chest */ + ObjectInfo(73, 69, 0, 0x0408), /* BLUE PANTS Torso/Chest */ + ObjectInfo(74, 24, 0, 0x0408), /* GHI TROUSERS Torso/Chest */ + ObjectInfo(90, 24, 0, 0x0410), /* LEG MAIL Legs/Chest */ + ObjectInfo(103, 53, 0, 0x0402), /* MITHRAL MAIL Head/Chest */ + ObjectInfo(104, 53, 0, 0x0402), /* LEG PLATE Head/Chest */ + ObjectInfo(96, 9, 0, 0x0402), /* POLEYN OF LYTE Head/Chest */ + ObjectInfo(97, 9, 0, 0x0402), /* POLEYN OF DARC Head/Chest */ + ObjectInfo(98, 9, 0, 0x0402), /* BEZERKER HELM Head/Chest */ + ObjectInfo(105, 54, 41, 0x0400), /* HELMET Chest */ + ObjectInfo(106, 54, 41, 0x0200), /* BASINET Hands */ + ObjectInfo(108, 10, 41, 0x0200), /* CASQUE 'N COIF Hands */ + ObjectInfo(107, 54, 41, 0x0200), /* ARMET Hands */ + ObjectInfo(75, 19, 0, 0x0408), /* HELM OF LYTE Torso/Chest */ + ObjectInfo(91, 19, 0, 0x0410), /* HELM OF DARC Legs/Chest */ + ObjectInfo(76, 19, 0, 0x0408), /* CALISTA Torso/Chest */ + ObjectInfo(92, 19, 0, 0x0410), /* CROWN OF NERRA Legs/Chest */ + ObjectInfo(99, 9, 0, 0x0402), /* BUCKLER Head/Chest */ + ObjectInfo(115, 19, 0, 0x0420), /* HIDE SHIELD Feet/Chest */ + ObjectInfo(100, 52, 0, 0x0402), /* SMALL SHIELD Head/Chest */ + ObjectInfo(77, 20, 0, 0x0008), /* WOODEN SHIELD Torso */ + ObjectInfo(93, 22, 0, 0x0010), /* LARGE SHIELD Legs */ + ObjectInfo(116, 56, 0, 0x0420), /* SHIELD OF LYTE Feet/Chest */ + ObjectInfo(109, 10, 41, 0x0200), /* SHIELD OF DARC Hands */ + ObjectInfo(101, 52, 0, 0x0402), /* SANDALS Head/Chest */ + ObjectInfo(78, 20, 0, 0x0008), /* SUEDE BOOTS Torso */ + ObjectInfo(94, 22, 0, 0x0010), /* LEATHER BOOTS Legs */ + ObjectInfo(117, 56, 0, 0x0420), /* HOSEN Feet/Chest */ + ObjectInfo(110, 10, 41, 0x0200), /* FOOT PLATE Hands */ + ObjectInfo(102, 52, 0, 0x0402), /* GREAVE OF LYTE Head/Chest */ + ObjectInfo(79, 20, 0, 0x0008), /* GREAVE OF DARC Torso */ + ObjectInfo(95, 22, 0, 0x0010), /* ELVEN BOOTS Legs */ + ObjectInfo(118, 56, 0, 0x0420), /* GEM OF AGES Feet/Chest */ + ObjectInfo(111, 10, 41, 0x0200), /* EKKHARD CROSS Hands */ + ObjectInfo(140, 52, 0, 0x0402), /* MOONSTONE Head/Chest */ + ObjectInfo(141, 19, 0, 0x0408), /* THE HELLION Torso/Chest */ + ObjectInfo(142, 22, 0, 0x0010), /* PENDANT FERAL Legs */ + ObjectInfo(194, 81, 0, 0x0420), /* COPPER COIN Feet/Chest */ + ObjectInfo(196, 84, 0, 0x0408), /* SILVER COIN Torso/Chest */ + ObjectInfo(0, 34, 0, 0x0500), /* GOLD COIN Pouch/Chest */ + ObjectInfo(8, 6, 0, 0x0501), /* BOULDER Mouth/Pouch/Chest */ + ObjectInfo(10, 15, 0, 0x0504), /* BLUE GEM Neck/Pouch/Chest */ + ObjectInfo(12, 15, 0, 0x0504), /* ORANGE GEM Neck/Pouch/Chest */ + ObjectInfo(146, 40, 0, 0x0500), /* GREEN GEM Pouch/Chest */ + ObjectInfo(147, 41, 0, 0x0400), /* MAGICAL BOX Chest */ + ObjectInfo(125, 4, 37, 0x0500), /* MAGICAL BOX Pouch/Chest */ + ObjectInfo(126, 83, 37, 0x0500), /* MIRROR OF DAWN Pouch/Chest */ + ObjectInfo(127, 4, 37, 0x0500), /* HORN OF FEAR Pouch/Chest */ + ObjectInfo(176, 18, 0, 0x0500), /* ROPE Pouch/Chest */ + ObjectInfo(177, 18, 0, 0x0500), /* RABBIT'S FOOT Pouch/Chest */ + ObjectInfo(178, 18, 0, 0x0500), /* CORBAMITE Pouch/Chest */ + ObjectInfo(179, 18, 0, 0x0500), /* CHOKER Pouch/Chest */ + ObjectInfo(180, 18, 0, 0x0500), /* DEXHELM Pouch/Chest */ + ObjectInfo(181, 18, 0, 0x0500), /* FLAMEBAIN Pouch/Chest */ + ObjectInfo(182, 18, 0, 0x0500), /* POWERTOWERS Pouch/Chest */ + ObjectInfo(183, 18, 0, 0x0500), /* SPEEDBOW Pouch/Chest */ + ObjectInfo(184, 62, 0, 0x0500), /* CHEST Pouch/Chest */ + ObjectInfo(185, 62, 0, 0x0500), /* OPEN CHEST Pouch/Chest */ + ObjectInfo(186, 62, 0, 0x0500), /* ASHES Pouch/Chest */ + ObjectInfo(187, 62, 0, 0x0500), /* BONES Pouch/Chest */ + ObjectInfo(188, 62, 0, 0x0500), /* MON POTION Pouch/Chest */ + ObjectInfo(189, 62, 0, 0x0500), /* UM POTION Pouch/Chest */ + ObjectInfo(190, 62, 0, 0x0500), /* DES POTION Pouch/Chest */ + ObjectInfo(191, 62, 0, 0x0500), /* VEN POTION Pouch/Chest */ + ObjectInfo(128, 76, 0, 0x0200), /* SAR POTION Hands */ + ObjectInfo(129, 3, 0, 0x0500), /* ZO POTION Pouch/Chest */ + ObjectInfo(130, 60, 0, 0x0500), /* ROS POTION Pouch/Chest */ + ObjectInfo(131, 61, 0, 0x0500), /* KU POTION Pouch/Chest */ + ObjectInfo(168, 27, 0, 0x0501), /* DANE POTION Mouth/Pouch/Chest */ + ObjectInfo(169, 28, 0, 0x0501), /* NETA POTION Mouth/Pouch/Chest */ + ObjectInfo(170, 25, 0, 0x0501), /* BRO POTION Mouth/Pouch/Chest */ + ObjectInfo(171, 26, 0, 0x0501), /* MA POTION Mouth/Pouch/Chest */ + ObjectInfo(172, 71, 0, 0x0401), /* YA POTION Mouth/Chest */ + ObjectInfo(173, 70, 0, 0x0401), /* EE POTION Mouth/Chest */ + ObjectInfo(174, 5, 0, 0x0501), /* VI POTION Mouth/Pouch/Chest */ + ObjectInfo(175, 66, 0, 0x0501), /* WATER FLASK Mouth/Pouch/Chest */ + ObjectInfo(120, 15, 0, 0x0504), /* KATH BOMB Neck/Pouch/Chest */ + ObjectInfo(121, 15, 0, 0x0504), /* PEW BOMB Neck/Pouch/Chest */ + ObjectInfo(122, 58, 0, 0x0504), /* RA BOMB Neck/Pouch/Chest */ + ObjectInfo(123, 59, 0, 0x0504), /* FUL BOMB Neck/Pouch/Chest */ + ObjectInfo(124, 59, 0, 0x0504), /* APPLE Neck/Pouch/Chest */ + ObjectInfo(132, 79, 38, 0x0500), /* CORN Pouch/Chest */ + ObjectInfo(133, 63, 38, 0x0500), /* BREAD Pouch/Chest */ + ObjectInfo(134, 64, 0, 0x0500), /* CHEESE Pouch/Chest */ + ObjectInfo(136, 72, 39, 0x0400), /* SCREAMER SLICE Chest */ + ObjectInfo(137, 73, 0, 0x0500), /* WORM ROUND Pouch/Chest */ + ObjectInfo(138, 74, 0, 0x0500), /* DRUMSTICK Pouch/Chest */ + ObjectInfo(139, 75, 0, 0x0504), /* DRAGON STEAK Neck/Pouch/Chest */ + ObjectInfo(192, 77, 0, 0x0500), /* IRON KEY Pouch/Chest */ + ObjectInfo(193, 78, 0, 0x0500), /* KEY OF B Pouch/Chest */ + ObjectInfo(197, 74, 0, 0x0000), /* SOLID KEY */ + ObjectInfo(198, 41, 0, 0x0400)}; /* SQUARE KEY Chest */ + uint16 gJunkInfo[53] = { // @ G0241_auc_Graphic559_JunkInfo 1, /* COMPASS */ 3, /* WATERSKIN */ diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 00dbcc2c9c..5a7bf24d4b 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -42,6 +42,8 @@ public: } }; // @ OBJECT_INFO +extern ObjectInfo gObjectInfo[180]; + extern uint16 gJunkInfo[53]; enum ArmourAttribute { -- cgit v1.2.3 From 9d7f35cc8282f1ee6a41ea98d56388030435b4c4 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 00:34:15 +0200 Subject: DM: Add ObjectMan --- engines/dm/module.mk | 3 ++- engines/dm/objectman.cpp | 8 ++++++++ engines/dm/objectman.h | 13 +++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 engines/dm/objectman.cpp create mode 100644 engines/dm/objectman.h diff --git a/engines/dm/module.mk b/engines/dm/module.mk index 45a6ed528d..088caf82d3 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -8,7 +8,8 @@ MODULE_OBJS := \ eventman.o \ menus.o \ champion.o \ - loadsave.o + loadsave.o \ + objectman.o MODULE_DIRS += \ engines/dm diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp new file mode 100644 index 0000000000..4ab760d53a --- /dev/null +++ b/engines/dm/objectman.cpp @@ -0,0 +1,8 @@ +#include "objectman.h" + + +namespace DM { + +ObjectMan::ObjectMan(DMEngine *vm): _vm(vm) {} + +} \ No newline at end of file diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h new file mode 100644 index 0000000000..347703c86f --- /dev/null +++ b/engines/dm/objectman.h @@ -0,0 +1,13 @@ +#include "dm.h" + + +namespace DM { + +class ObjectMan { + DMEngine *_vm; +public: + ObjectMan(DMEngine *vm); + +}; + +} -- cgit v1.2.3 From 749ffcc3f0e7866a8edc8d9591fe70d152fc157a Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 00:48:28 +0200 Subject: DM: Add F0032_OBJECT_GetType --- engines/dm/objectman.cpp | 13 +++++++++++++ engines/dm/objectman.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 4ab760d53a..e65b061225 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -1,8 +1,21 @@ #include "objectman.h" +#include "dungeonman.h" namespace DM { ObjectMan::ObjectMan(DMEngine *vm): _vm(vm) {} +IconIndice ObjectMan::getObjectType(Thing thing) { + if (thing == Thing::_thingNone) + return kIconIndiceNone; + + int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing); + if (objectInfoIndex != -1) { + objectInfoIndex = gObjectInfo[objectInfoIndex]._type; + } + return (IconIndice)objectInfoIndex; +} + + } \ No newline at end of file diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index 347703c86f..6421d7c04f 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -1,4 +1,5 @@ #include "dm.h" +#include "champion.h" namespace DM { @@ -7,6 +8,7 @@ class ObjectMan { DMEngine *_vm; public: ObjectMan(DMEngine *vm); + IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType }; -- cgit v1.2.3 From ceed621a51366be53bd5f189e275bf631328dd24 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 00:49:23 +0200 Subject: DM: Fix missing else in DMEngine::startGame() --- engines/dm/dm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 2a20b86410..4408eb4993 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -113,7 +113,7 @@ void DMEngine::startGame() { if (!_dungeonMan->_messages._newGame) { warning("TODO: loading game"); - } { + } else { _displayMan->_useByteBoxCoordinates = false; warning("TODO: clear screen"); } -- cgit v1.2.3 From 359ef01a338e9571101baac2ddb82032ca6a1cc7 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 00:51:12 +0200 Subject: DM: Add G0029_auc_Graphic562_ChargeCountToTorchType --- engines/dm/objectman.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index e65b061225..04888ee63f 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -18,4 +18,7 @@ IconIndice ObjectMan::getObjectType(Thing thing) { } +byte gChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType + + } \ No newline at end of file -- cgit v1.2.3 From 23c1acff1939b8feb4bcbbf04bc44ca00321547d Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 00:54:28 +0200 Subject: DM: Add ObjectMan to DMEngine --- engines/dm/dm.cpp | 4 ++++ engines/dm/dm.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 4408eb4993..af0868d061 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -18,6 +18,7 @@ #include "menus.h" #include "champion.h" #include "loadsave.h" +#include "objectman.h" namespace DM { @@ -49,6 +50,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _menuMan = nullptr; _championMan = nullptr; _loadsaveMan = nullptr; + _objectMan = nullptr; _stopWaitingForPlayerInput = false; _gameTimeTicking = false; @@ -67,6 +69,7 @@ DMEngine::~DMEngine() { delete _menuMan; delete _championMan; delete _loadsaveMan; + delete _objectMan; // clear debug channels DebugMan.clearAllDebugChannels(); @@ -142,6 +145,7 @@ Common::Error DMEngine::run() { _menuMan = new MenuMan(this); _championMan = new ChampionMan(this); _loadsaveMan = new LoadsaveMan(this); + _objectMan = new ObjectMan(this); _displayMan->setUpScreens(320, 200); initializeGame(); // @ F0463_START_InitializeGame_CPSADEF diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 468cd5c528..14a8772dba 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -15,6 +15,7 @@ class EventManager; class MenuMan; class ChampionMan; class LoadsaveMan; +class ObjectMan; enum direction { @@ -99,6 +100,7 @@ public: MenuMan *_menuMan; ChampionMan *_championMan; LoadsaveMan *_loadsaveMan; + ObjectMan *_objectMan; bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput bool _gameTimeTicking; // @ G0301_B_GameTimeTicking bool _restartGameAllowed; // @ G0524_B_RestartGameAllowed -- cgit v1.2.3 From 29d832b353c94f2e1096117b34142ded9675f822 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 01:28:28 +0200 Subject: DM: Add F0033_OBJECT_GetIconIndex and several getters for object types --- engines/dm/dungeonman.h | 9 +++++++-- engines/dm/objectman.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++-- engines/dm/objectman.h | 1 + 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 5a7bf24d4b..45130e88e4 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -313,6 +313,8 @@ public: Weapon(uint16 *rawDat) : _nextThing(rawDat[0]), _desc(rawDat[1]) {} WeaponType getType() { return (WeaponType)(_desc & 0x7F); } + bool isLit() { return (_desc >> 15) & 1; } + uint16 getChargeCount() { return (_desc >> 10) & 0xF; } Thing getNextThing() { return _nextThing; } }; // @ WEAPON @@ -343,6 +345,7 @@ public: _attributes = attribs; } Thing getNextThing() { return _nextThing; } + uint16 getClosed() { return (_attributes >> 10) & 0x3F; } // ??? dunno why, the original bitfield is 6 bits long }; // @ SCROLL enum PotionType { @@ -574,11 +577,13 @@ class DungeonMan { void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap - Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing) - uint16 *getThingData(Thing thing); // @ unsigned char* F0156_DUNGEON_GetThingData(register THING P0276_T_Thing) public: DungeonMan(DMEngine *dmEngine); ~DungeonMan(); + + Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing) + uint16 *getThingData(Thing thing); // @ unsigned char* F0156_DUNGEON_GetThingData(register THING P0276_T_Thing) + // TODO: this does stuff other than load the file! void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC void setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 04888ee63f..a373e94f1f 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -4,7 +4,7 @@ namespace DM { -ObjectMan::ObjectMan(DMEngine *vm): _vm(vm) {} +ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {} IconIndice ObjectMan::getObjectType(Thing thing) { if (thing == Thing::_thingNone) @@ -17,8 +17,54 @@ IconIndice ObjectMan::getObjectType(Thing thing) { return (IconIndice)objectInfoIndex; } - byte gChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType +int16 ObjectMan::getIconIndex(Thing thing) { + IconIndice iconIndex = getObjectType(thing); + + if ((iconIndex != kIconIndiceNone) && + ((iconIndex < kIconIndiceWeaponDagger) &&(iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error + ((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) || + (iconIndex == kIconIndicePotionEmptyFlask) + ) { + uint16 *rawType = _vm->_dungeonMan->getThingData(thing); + switch (iconIndex) { + case kIconIndiceJunkCompassNorth: + iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_currMap._partyDir); + break; + case kIconIndiceWeaponTorchUnlit: { + Weapon weapon(rawType); + if (weapon.isLit()) { + iconIndex = (IconIndice)(iconIndex + gChargeCountToTorchType[weapon.getChargeCount()]); + } + break; + } + case kIconIndiceScrollOpen: + if (Scroll(rawType).getClosed()) { + iconIndex = (IconIndice)(iconIndex + 1); + } + break; + case kIconIndiceJunkWater: + case kIconIndiceJunkIllumuletUnequipped: + case kIconIndiceJunkJewelSymalUnequipped: + if (Junk(rawType).getChargeCount()) { + iconIndex = (IconIndice)(iconIndex + 1); + } + break; + case kIconIndiceWeaponBoltBladeStormEmpty: + case kIconIndiceWeaponFlamittEmpty: + case kIconIndiceWeaponStormringEmpty: + case kIconIndiceWeaponFuryRaBladeEmpty: + case kIconIndiceWeaponEyeOfTimeEmpty: + case kIconIndiceWeaponStaffOfClawsEmpty: + if (Weapon(rawType).getChargeCount()) { + iconIndex = (IconIndice)(iconIndex + 1); + } + break; + } + } + + return iconIndex; +} } \ No newline at end of file diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index 6421d7c04f..bad5f7c28a 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -9,6 +9,7 @@ class ObjectMan { public: ObjectMan(DMEngine *vm); IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType + int16 getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex }; -- cgit v1.2.3 From 472778a06e141188dd157fd088873279970608db Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 01:35:11 +0200 Subject: DM: Replace WeaponClass enum with #defines --- engines/dm/dungeonman.cpp | 92 +++++++++++++++++++++++------------------------ engines/dm/dungeonman.h | 32 ++++++++--------- 2 files changed, 61 insertions(+), 63 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 01791bf94a..f93ad0f6cd 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -307,52 +307,52 @@ ArmourInfo gArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo WeaponInfo gWeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo /* { Weight, Class, Strength, KineticEnergy, Attributes } */ - WeaponInfo(1, (WeaponClass)130, 2, 0, 0x2000), /* EYE OF TIME */ - WeaponInfo(1, (WeaponClass)131, 2, 0, 0x2000), /* STORMRING */ - WeaponInfo(11, (WeaponClass)0, 8, 2, 0x2000), /* TORCH */ - WeaponInfo(12, (WeaponClass)112, 10, 80, 0x2028), /* FLAMITT */ - WeaponInfo(9, (WeaponClass)129, 16, 7, 0x2000), /* STAFF OF CLAWS */ - WeaponInfo(30, (WeaponClass)113, 49, 110, 0x0942), /* BOLT BLADE */ - WeaponInfo(47, (WeaponClass)0, 55, 20, 0x0900), /* FURY */ - WeaponInfo(24, (WeaponClass)255, 25, 10, 0x20FF), /* THE FIRESTAFF */ - WeaponInfo(5, (WeaponClass)2, 10, 19, 0x0200), /* DAGGER */ - WeaponInfo(33, (WeaponClass)0, 30, 8, 0x0900), /* FALCHION */ - WeaponInfo(32, (WeaponClass)0, 34, 10, 0x0900), /* SWORD */ - WeaponInfo(26, (WeaponClass)0, 38, 10, 0x0900), /* RAPIER */ - WeaponInfo(35, (WeaponClass)0, 42, 11, 0x0900), /* SABRE */ - WeaponInfo(36, (WeaponClass)0, 46, 12, 0x0900), /* SAMURAI SWORD */ - WeaponInfo(33, (WeaponClass)0, 50, 14, 0x0900), /* DELTA */ - WeaponInfo(37, (WeaponClass)0, 62, 14, 0x0900), /* DIAMOND EDGE */ - WeaponInfo(30, (WeaponClass)0, 48, 13, 0x0000), /* VORPAL BLADE */ - WeaponInfo(39, (WeaponClass)0, 58, 15, 0x0900), /* THE INQUISITOR */ - WeaponInfo(43, (WeaponClass)2, 49, 33, 0x0300), /* AXE */ - WeaponInfo(65, (WeaponClass)2, 70, 44, 0x0300), /* HARDCLEAVE */ - WeaponInfo(31, (WeaponClass)0, 32, 10, 0x2000), /* MACE */ - WeaponInfo(41, (WeaponClass)0, 42, 13, 0x2000), /* MACE OF ORDER */ - WeaponInfo(50, (WeaponClass)0, 60, 15, 0x2000), /* MORNINGSTAR */ - WeaponInfo(36, (WeaponClass)0, 19, 10, 0x2700), /* CLUB */ - WeaponInfo(110, (WeaponClass)0, 44, 22, 0x2600), /* STONE CLUB */ - WeaponInfo(10, (WeaponClass)20, 1, 50, 0x2032), /* BOW */ - WeaponInfo(28, (WeaponClass)30, 1, 180, 0x2078), /* CROSSBOW */ - WeaponInfo(2, (WeaponClass)10, 2, 10, 0x0100), /* ARROW */ - WeaponInfo(2, (WeaponClass)10, 2, 28, 0x0500), /* SLAYER */ - WeaponInfo(19, (WeaponClass)39, 5, 20, 0x2032), /* SLING */ - WeaponInfo(10, (WeaponClass)11, 6, 18, 0x2000), /* ROCK */ - WeaponInfo(3, (WeaponClass)12, 7, 23, 0x0800), /* POISON DART */ - WeaponInfo(1, (WeaponClass)1, 3, 19, 0x0A00), /* THROWING STAR */ - WeaponInfo(8, (WeaponClass)0, 4, 4, 0x2000), /* STICK */ - WeaponInfo(26, (WeaponClass)129, 12, 4, 0x2000), /* STAFF */ - WeaponInfo(1, (WeaponClass)130, 0, 0, 0x2000), /* WAND */ - WeaponInfo(2, (WeaponClass)140, 1, 20, 0x2000), /* TEOWAND */ - WeaponInfo(35, (WeaponClass)128, 18, 6, 0x2000), /* YEW STAFF */ - WeaponInfo(29, (WeaponClass)159, 0, 4, 0x2000), /* STAFF OF MANAR */ - WeaponInfo(21, (WeaponClass)131, 0, 3, 0x2000), /* SNAKE STAFF */ - WeaponInfo(33, (WeaponClass)136, 0, 7, 0x2000), /* THE CONDUIT */ - WeaponInfo(8, (WeaponClass)132, 3, 1, 0x2000), /* DRAGON SPIT */ - WeaponInfo(18, (WeaponClass)131, 9, 4, 0x2000), /* SCEPTRE OF LYF */ - WeaponInfo(8, (WeaponClass)192, 1, 1, 0x2000), /* HORN OF FEAR */ - WeaponInfo(30, (WeaponClass)26, 1, 220, 0x207D), /* SPEEDBOW */ - WeaponInfo(36, (WeaponClass)255, 100, 50, 0x20FF)}; /* THE FIRESTAFF */ + WeaponInfo(1, 130, 2, 0, 0x2000), /* EYE OF TIME */ + WeaponInfo(1, 131, 2, 0, 0x2000), /* STORMRING */ + WeaponInfo(11, 0, 8, 2, 0x2000), /* TORCH */ + WeaponInfo(12, 112, 10, 80, 0x2028), /* FLAMITT */ + WeaponInfo(9, 129, 16, 7, 0x2000), /* STAFF OF CLAWS */ + WeaponInfo(30, 113, 49, 110, 0x0942), /* BOLT BLADE */ + WeaponInfo(47, 0, 55, 20, 0x0900), /* FURY */ + WeaponInfo(24, 255, 25, 10, 0x20FF), /* THE FIRESTAFF */ + WeaponInfo(5, 2, 10, 19, 0x0200), /* DAGGER */ + WeaponInfo(33, 0, 30, 8, 0x0900), /* FALCHION */ + WeaponInfo(32, 0, 34, 10, 0x0900), /* SWORD */ + WeaponInfo(26, 0, 38, 10, 0x0900), /* RAPIER */ + WeaponInfo(35, 0, 42, 11, 0x0900), /* SABRE */ + WeaponInfo(36, 0, 46, 12, 0x0900), /* SAMURAI SWORD */ + WeaponInfo(33, 0, 50, 14, 0x0900), /* DELTA */ + WeaponInfo(37, 0, 62, 14, 0x0900), /* DIAMOND EDGE */ + WeaponInfo(30, 0, 48, 13, 0x0000), /* VORPAL BLADE */ + WeaponInfo(39, 0, 58, 15, 0x0900), /* THE INQUISITOR */ + WeaponInfo(43, 2, 49, 33, 0x0300), /* AXE */ + WeaponInfo(65, 2, 70, 44, 0x0300), /* HARDCLEAVE */ + WeaponInfo(31, 0, 32, 10, 0x2000), /* MACE */ + WeaponInfo(41, 0, 42, 13, 0x2000), /* MACE OF ORDER */ + WeaponInfo(50, 0, 60, 15, 0x2000), /* MORNINGSTAR */ + WeaponInfo(36, 0, 19, 10, 0x2700), /* CLUB */ + WeaponInfo(110, 0, 44, 22, 0x2600), /* STONE CLUB */ + WeaponInfo(10, 20, 1, 50, 0x2032), /* BOW */ + WeaponInfo(28, 30, 1, 180, 0x2078), /* CROSSBOW */ + WeaponInfo(2, 10, 2, 10, 0x0100), /* ARROW */ + WeaponInfo(2, 10, 2, 28, 0x0500), /* SLAYER */ + WeaponInfo(19, 39, 5, 20, 0x2032), /* SLING */ + WeaponInfo(10, 11, 6, 18, 0x2000), /* ROCK */ + WeaponInfo(3, 12, 7, 23, 0x0800), /* POISON DART */ + WeaponInfo(1, 1, 3, 19, 0x0A00), /* THROWING STAR */ + WeaponInfo(8, 0, 4, 4, 0x2000), /* STICK */ + WeaponInfo(26, 129, 12, 4, 0x2000), /* STAFF */ + WeaponInfo(1, 130, 0, 0, 0x2000), /* WAND */ + WeaponInfo(2, 140, 1, 20, 0x2000), /* TEOWAND */ + WeaponInfo(35, 128, 18, 6, 0x2000), /* YEW STAFF */ + WeaponInfo(29, 159, 0, 4, 0x2000), /* STAFF OF MANAR */ + WeaponInfo(21, 131, 0, 3, 0x2000), /* SNAKE STAFF */ + WeaponInfo(33, 136, 0, 7, 0x2000), /* THE CONDUIT */ + WeaponInfo(8, 132, 3, 1, 0x2000), /* DRAGON SPIT */ + WeaponInfo(18, 131, 9, 4, 0x2000), /* SCEPTRE OF LYF */ + WeaponInfo(8, 192, 1, 1, 0x2000), /* HORN OF FEAR */ + WeaponInfo(30, 26, 1, 220, 0x207D), /* SPEEDBOW */ + WeaponInfo(36, 255, 100, 50, 0x20FF)}; /* THE FIRESTAFF */ CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo /* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo, diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 45130e88e4..41a39739f8 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -67,34 +67,32 @@ public: extern ArmourInfo gArmourInfo[58]; -enum WeaponClass { /* Class 0: SWING weapons */ - kWeaponClassSwingWeapon = 0, // @ C000_CLASS_SWING_WEAPON - /* Class 1 to 15: THROW weapons */ - kWeaponClassDaggerAndAxes = 2, // @ C002_CLASS_DAGGER_AND_AXES - kWeaponClassBowAmmunition = 10, // @ C010_CLASS_BOW_AMMUNITION - kWeaponClassSlingAmmunition = 11, // @ C011_CLASS_SLING_AMMUNITION - kWeaponClassPoisinDart = 12, // @ C012_CLASS_POISON_DART - /* Class 16 to 111: SHOOT weapons */ - kWeaponClassFirstBow = 16, // @ C016_CLASS_FIRST_BOW - kWeaponClassLastBow = 31, // @ C031_CLASS_LAST_BOW - kWeaponClassFirstSling = 32, // @ C032_CLASS_FIRST_SLING - kWeaponClassLastSling = 47, // @ C047_CLASS_LAST_SLING - /* Class 112 to 255: Magic and special weapons */ - kWeaponClassFirstMagicWeapon = 112 // @ C112_CLASS_FIRST_MAGIC_WEAPON -}; +#define kWeaponClassSwingWeapon 0 // @ C000_CLASS_SWING_WEAPON +/* Class 1 to 15: THROW weapons */ +#define kWeaponClassDaggerAndAxes 2 // @ C002_CLASS_DAGGER_AND_AXES +#define kWeaponClassBowAmmunition 10 // @ C010_CLASS_BOW_AMMUNITION +#define kWeaponClassSlingAmmunition 11 // @ C011_CLASS_SLING_AMMUNITION +#define kWeaponClassPoisinDart 12 // @ C012_CLASS_POISON_DART +/* Class 16 to 111: SHOOT weapons */ +#define kWeaponClassFirstBow 16 // @ C016_CLASS_FIRST_BOW +#define kWeaponClassLastBow 31 // @ C031_CLASS_LAST_BOW +#define kWeaponClassFirstSling 32 // @ C032_CLASS_FIRST_SLING +#define kWeaponClassLastSling 47 // @ C047_CLASS_LAST_SLING +/* Class 112 to 255: Magic and special weapons */ +#define kWeaponClassFirstMagicWeapon 112 // @ C112_CLASS_FIRST_MAGIC_WEAPON class WeaponInfo { public: uint16 _weight; - WeaponClass _class; + uint16 _class; uint16 _strength; uint16 _kineticEnergy; private: uint16 _attributes; /* Bits 15-13 Unreferenced */ public: - WeaponInfo(uint16 weight, WeaponClass wClass, uint16 strength, uint16 kineticEnergy, uint16 attributes) + WeaponInfo(uint16 weight, uint16 wClass, uint16 strength, uint16 kineticEnergy, uint16 attributes) : _weight(weight), _class(wClass), _strength(strength), _kineticEnergy(kineticEnergy), _attributes(attributes) {} uint16 getShootAttack() {return _attributes & 0xFF;} // @ M65_SHOOT_ATTACK -- cgit v1.2.3 From 0597fdc6584f806f9dcae69c2456464014227908 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 11:47:22 +0200 Subject: DM: Add D24_FillScreenBox --- engines/dm/gfx.cpp | 6 ++++++ engines/dm/gfx.h | 1 + 2 files changed, 7 insertions(+) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 790c055784..ea05f44b76 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1500,3 +1500,9 @@ void DisplayMan::blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth byte* DisplayMan::getBitmap(uint16 index) { return _bitmaps[index]; } + +void DisplayMan::clearScreenBox(Color color, Box &box) { + uint16 width = box._x2 - box._x1; + for (int y = box._y1; y < box._y2; ++y) + memset(_vgaBuffer + y * _screenWidth + box._x1, color, sizeof(byte) * width); +} diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 86a152af9c..749d4874fb 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -286,6 +286,7 @@ public: void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color); void clearScreen(Color color); + void clearScreenBox(Color color, Box &box); // @ D24_FillScreenBox void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); byte* getBitmap(uint16 index); -- cgit v1.2.3 From 592cd055758427c8832773cdde2e5fa09d89ed52 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 11:51:45 +0200 Subject: DM: Add G0026_ai_Graphic562_IconGraphicFirstIconIndex --- engines/dm/objectman.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index a373e94f1f..0e6394f510 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -4,6 +4,15 @@ namespace DM { +int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex + 0, /* First icon index in graphic #42 */ + 32, /* First icon index in graphic #43 */ + 64, /* First icon index in graphic #44 */ + 96, /* First icon index in graphic #45 */ + 128, /* First icon index in graphic #46 */ + 160, /* First icon index in graphic #47 */ + 192}; /* First icon index in graphic #48 */ + ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {} IconIndice ObjectMan::getObjectType(Thing thing) { -- cgit v1.2.3 From 6e041819b480785b452a9023cdecb5421b8066ce Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 14:09:51 +0200 Subject: DM: Add F0036_OBJECT_ExtractIconFromBitmap, K0077_ai_IconGraphicHeight, ObjectIcon indices --- engines/dm/gfx.h | 9 ++++++++- engines/dm/objectman.cpp | 15 +++++++++++++++ engines/dm/objectman.h | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 749d4874fb..46ce6e3d93 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -20,7 +20,14 @@ enum GraphicIndice { kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT kDoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED kChampionPortraitsIndice = 26, // @ C026_GRAPHIC_CHAMPION_PORTRAITS - kMovementArrowsIndice = 13 // @ C013_GRAPHIC_MOVEMENT_ARROWS + kMovementArrowsIndice = 13, // @ C013_GRAPHIC_MOVEMENT_ARROWS + kObjectIcons_000_TO_031 = 42, // @ C042_GRAPHIC_OBJECT_ICONS_000_TO_031 + kObjectIcons_032_TO_063 = 43, // @ C043_GRAPHIC_OBJECT_ICONS_032_TO_063 + kObjectIcons_064_TO_095 = 44, // @ C044_GRAPHIC_OBJECT_ICONS_064_TO_095 + kObjectIcons_096_TO_127 = 45, // @ C045_GRAPHIC_OBJECT_ICONS_096_TO_127 + kObjectIcons_128_TO_159 = 46, // @ C046_GRAPHIC_OBJECT_ICONS_128_TO_159 + kObjectIcons_160_TO_191 = 47, // @ C047_GRAPHIC_OBJECT_ICONS_160_TO_191 + kObjectIcons_192_TO_223 = 48 // @ C048_GRAPHIC_OBJECT_ICONS_192_TO_223 }; extern uint16 gPalSwoosh[16]; diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 0e6394f510..bc0b923422 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -4,6 +4,8 @@ namespace DM { +int16 gIconGraphicHeight[7] = {32, 32, 32, 32, 32, 32, 32}; // @ K0077_ai_IconGraphicHeight + int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex 0, /* First icon index in graphic #42 */ 32, /* First icon index in graphic #43 */ @@ -76,4 +78,17 @@ int16 ObjectMan::getIconIndex(Thing thing) { return iconIndex; } +void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { + int16 i; + for (i = 0; i < 7; ++i) + if (gIconGraphicFirstIndex[i] > iconIndex) + break; + --i; + byte *srcBitmap = _vm->_displayMan->getBitmap(kObjectIcons_000_TO_031 + i); + iconIndex -= gIconGraphicFirstIndex[i]; + _vm->_displayMan->_useByteBoxCoordinates = true; + _vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, 0, 16, 0, 16, kColorNoTransparency); + +} + } \ No newline at end of file diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index bad5f7c28a..177d3bb0e3 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -10,7 +10,7 @@ public: ObjectMan(DMEngine *vm); IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType int16 getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex - + void extractIconFromBitmap(uint16 iconIndex, byte *srcBitmap); // F0036_OBJECT_ExtractIconFromBitmap }; } -- cgit v1.2.3 From d9ed599de6a4c362f9d3eaf6e37b9fb1f86edfb3 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 14:12:39 +0200 Subject: DM: Add G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon --- engines/dm/menus.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index d7948c25e4..075543bffb 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -6,6 +6,8 @@ namespace DM { +byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon + MenuMan::MenuMan(DMEngine *vm): _vm(vm) {} void MenuMan::drawMovementArrows() { -- cgit v1.2.3 From 7782754d68e87d5bfd9980aa1c78a01c29a87574 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 15:23:37 +0200 Subject: DM: Add F0386_MENUS_DrawActionIcon --- engines/dm/champion.h | 1 + engines/dm/gfx.h | 4 +- engines/dm/menus.cpp | 102 ++++++++++++++++++++++++++++++++--------------- engines/dm/menus.h | 2 + engines/dm/objectman.cpp | 2 +- engines/dm/objectman.h | 2 +- 6 files changed, 78 insertions(+), 35 deletions(-) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 89a1d059b9..0c8a46fae0 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -297,6 +297,7 @@ public: void setStatistic(ChampionStatisticType type, ChampionStatisticValue valType, byte newVal) { _statistics[type][valType] = newVal; } uint16 getAttributes() { return _attributes; } + uint16 getAttributes(ChampionAttribute flag) { return _attributes & flag; } void setAttributeFlag(ChampionAttribute flag, bool value) { if (value) { _attributes |= flag; diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 46ce6e3d93..99d3f8f417 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -44,6 +44,7 @@ public: uint16 _y2; Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): _x1(x1), _x2(x2 + 1), _y1(y1), _y2(y2 + 1) {} + Box() {} bool isPointInside(Common::Point point) { return (_x1 <= point.x) && (point.x < _x2) && (_y1 <= point.y) && (point.y < _y2); } @@ -257,9 +258,10 @@ class DisplayMan { bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF +public: // some methods use this for a stratchpad, don't make assumptions about content between function calls byte *_tmpBitmap; -public: + DisplayMan(DMEngine *dmEngine); ~DisplayMan(); diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 075543bffb..530ac24e4a 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -1,32 +1,70 @@ -#include "menus.h" -#include "gfx.h" -#include "champion.h" -#include "dungeonman.h" - - -namespace DM { - -byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon - -MenuMan::MenuMan(DMEngine *vm): _vm(vm) {} - -void MenuMan::drawMovementArrows() { - DisplayMan &disp = *_vm->_displayMan; - byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice); - Box &dest = gBoxMovementArrows; - uint16 w = disp.getWidth(kMovementArrowsIndice); - - disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency); -} -void MenuMan::clearActingChampion() { - ChampionMan &cm = *_vm->_championMan; - if (cm._actingChampionOrdinal) { - cm._actingChampionOrdinal--; - cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true); - warning("MISSING CODE: F0292_CHAMPION_DrawState"); - cm._actingChampionOrdinal = indexToOrdinal(kChampionNone); - _shouldRefreshActionArea = true; - } -} - -} \ No newline at end of file +#include "menus.h" +#include "gfx.h" +#include "champion.h" +#include "dungeonman.h" +#include "objectman.h" + + +namespace DM { + +byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon + +MenuMan::MenuMan(DMEngine *vm): _vm(vm) {} + +void MenuMan::drawMovementArrows() { + DisplayMan &disp = *_vm->_displayMan; + byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice); + Box &dest = gBoxMovementArrows; + uint16 w = disp.getWidth(kMovementArrowsIndice); + + disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency); +} +void MenuMan::clearActingChampion() { + ChampionMan &cm = *_vm->_championMan; + if (cm._actingChampionOrdinal) { + cm._actingChampionOrdinal--; + cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true); + warning("MISSING CODE: F0292_CHAMPION_DrawState"); + cm._actingChampionOrdinal = indexToOrdinal(kChampionNone); + _shouldRefreshActionArea = true; + } +} + +void MenuMan::drawActionIcon(ChampionIndex championIndex) { + if (!_actionAreaContainsIcons) + return; + DisplayMan &dm = *_vm->_displayMan; + Champion &champion = _vm->_championMan->_champions[championIndex]; + + Box box; + box._x1 = championIndex * 22 + 233; + box._x2 = box._x1 + 19 + 1; + box._y1 = 86; + box._y2 = 120 + 1; + dm._useByteBoxCoordinates = false; + if (!champion._currHealth) { + dm.clearScreenBox(kColorBlack, box); + return; + } + byte *bitmapIcon = dm._tmpBitmap; + Thing thing = champion.getSlot(kChampionSlotActionHand); + IconIndice iconIndex; + if (thing == Thing::_thingNone) { + iconIndex = kIconIndiceActionEmptyHand; + } else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) { + iconIndex = _vm->_objectMan->getIconIndex(thing); + } else { + dm.clearBitmap(bitmapIcon, 16, 16, kColorCyan); + goto T0386006; + } + _vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon); + dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon); +T0386006: + dm.clearScreenBox(kColorCyan, box); + Box box2; + box2._x1 = box._x1 + 2; + box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that + box2._y1 = 95; + box2._y2 = 110 + 1; + dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2); + if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } } } \ No newline at end of file diff --git a/engines/dm/menus.h b/engines/dm/menus.h index ce6c1667fe..a35659da23 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -2,6 +2,7 @@ #define DM_MENUS_H #include "dm.h" +#include "champion.h" namespace DM { @@ -12,6 +13,7 @@ public: bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons MenuMan(DMEngine *vm); void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion + void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon void drawMovementArrows(); }; diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index bc0b923422..c237b914a2 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -30,7 +30,7 @@ IconIndice ObjectMan::getObjectType(Thing thing) { byte gChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType -int16 ObjectMan::getIconIndex(Thing thing) { +IconIndice ObjectMan::getIconIndex(Thing thing) { IconIndice iconIndex = getObjectType(thing); if ((iconIndex != kIconIndiceNone) && diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index 177d3bb0e3..908520c5f0 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -9,7 +9,7 @@ class ObjectMan { public: ObjectMan(DMEngine *vm); IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType - int16 getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex + IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex void extractIconFromBitmap(uint16 iconIndex, byte *srcBitmap); // F0036_OBJECT_ExtractIconFromBitmap }; -- cgit v1.2.3 From f4f4c867a41a8bd306c3ec288e5b948ad1bf7e25 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 16:17:28 +0200 Subject: DM: Add InventoryMan, G0041_s_Graphic562_Box_ViewportFloppyZzzCross --- engines/dm/dm.cpp | 4 ++++ engines/dm/dm.h | 2 ++ engines/dm/inventory.cpp | 11 +++++++++++ engines/dm/inventory.h | 14 ++++++++++++++ engines/dm/module.mk | 3 ++- 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 engines/dm/inventory.cpp create mode 100644 engines/dm/inventory.h diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index af0868d061..24182e387b 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -19,6 +19,7 @@ #include "champion.h" #include "loadsave.h" #include "objectman.h" +#include "inventory.h" namespace DM { @@ -51,6 +52,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _championMan = nullptr; _loadsaveMan = nullptr; _objectMan = nullptr; + _inventoryMan = nullptr; _stopWaitingForPlayerInput = false; _gameTimeTicking = false; @@ -70,6 +72,7 @@ DMEngine::~DMEngine() { delete _championMan; delete _loadsaveMan; delete _objectMan; + delete _inventoryMan; // clear debug channels DebugMan.clearAllDebugChannels(); @@ -146,6 +149,7 @@ Common::Error DMEngine::run() { _championMan = new ChampionMan(this); _loadsaveMan = new LoadsaveMan(this); _objectMan = new ObjectMan(this); + _inventoryMan = new InventoryMan(this); _displayMan->setUpScreens(320, 200); initializeGame(); // @ F0463_START_InitializeGame_CPSADEF diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 14a8772dba..66be764bbc 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -16,6 +16,7 @@ class MenuMan; class ChampionMan; class LoadsaveMan; class ObjectMan; +class InventoryMan; enum direction { @@ -101,6 +102,7 @@ public: ChampionMan *_championMan; LoadsaveMan *_loadsaveMan; ObjectMan *_objectMan; + InventoryMan *_inventoryMan; bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput bool _gameTimeTicking; // @ G0301_B_GameTimeTicking bool _restartGameAllowed; // @ G0524_B_RestartGameAllowed diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp new file mode 100644 index 0000000000..378d79839b --- /dev/null +++ b/engines/dm/inventory.cpp @@ -0,0 +1,11 @@ +#include "inventory.h" + + + +namespace DM { + +Viewport gViewportFloppyZzzCross = {174, 2}; // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross + +InventoryMan::InventoryMan(DMEngine *vm): _vm(vm) {} + +} \ No newline at end of file diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h new file mode 100644 index 0000000000..06488fe4d4 --- /dev/null +++ b/engines/dm/inventory.h @@ -0,0 +1,14 @@ +#include "dm.h" +#include "gfx.h" + + + +namespace DM { + +class InventoryMan { + DMEngine *_vm; +public: + InventoryMan(DMEngine *vm); +}; + +} \ No newline at end of file diff --git a/engines/dm/module.mk b/engines/dm/module.mk index 088caf82d3..3a7fa1038c 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -9,7 +9,8 @@ MODULE_OBJS := \ menus.o \ champion.o \ loadsave.o \ - objectman.o + objectman.o \ + inventory.o MODULE_DIRS += \ engines/dm -- cgit v1.2.3 From e64e352815cb80d4aa0b709b86ad30abb6b6ef8c Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 16:22:13 +0200 Subject: DM: Add G0326_B_RefreshMousePointerInMainLoop, G0598_B_MousePointerBitmapUpdated --- engines/dm/eventman.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index b2834e813e..f72a985c58 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -199,6 +199,8 @@ class EventManager { public: MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput + bool _mousePointerBitmapUpdated; // @ G0598_B_MousePointerBitmapUpdated + bool _refreshMousePointerInMainLoop; // @ G0326_B_RefreshMousePointerInMainLoop bool _highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled uint16 _useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap EventManager(DMEngine *vm); -- cgit v1.2.3 From e9a4e818f21af256eea54bf08993425c6933e998 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 18:05:19 +0200 Subject: DM: Add F0355_INVENTORY_Toggle_CPSE --- engines/dm/gfx.cpp | 2 +- engines/dm/gfx.h | 5 +-- engines/dm/inventory.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++- engines/dm/inventory.h | 3 ++ 4 files changed, 85 insertions(+), 4 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index ea05f44b76..223257c220 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1501,7 +1501,7 @@ byte* DisplayMan::getBitmap(uint16 index) { return _bitmaps[index]; } -void DisplayMan::clearScreenBox(Color color, Box &box) { +void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) { uint16 width = box._x2 - box._x1; for (int y = box._y1; y < box._y2; ++y) memset(_vgaBuffer + y * _screenWidth + box._x1, color, sizeof(byte) * width); diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 99d3f8f417..65322918cd 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -27,7 +27,8 @@ enum GraphicIndice { kObjectIcons_096_TO_127 = 45, // @ C045_GRAPHIC_OBJECT_ICONS_096_TO_127 kObjectIcons_128_TO_159 = 46, // @ C046_GRAPHIC_OBJECT_ICONS_128_TO_159 kObjectIcons_160_TO_191 = 47, // @ C047_GRAPHIC_OBJECT_ICONS_160_TO_191 - kObjectIcons_192_TO_223 = 48 // @ C048_GRAPHIC_OBJECT_ICONS_192_TO_223 + kObjectIcons_192_TO_223 = 48, // @ C048_GRAPHIC_OBJECT_ICONS_192_TO_223 + kInventoryGraphicIndice = 17 // @ C017_GRAPHIC_INVENTORY }; extern uint16 gPalSwoosh[16]; @@ -295,7 +296,7 @@ public: void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color); void clearScreen(Color color); - void clearScreenBox(Color color, Box &box); // @ D24_FillScreenBox + void clearScreenBox(Color color, Box &box, Viewport &viewport = gDefultViewPort); // @ D24_FillScreenBox void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); byte* getBitmap(uint16 index); diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 378d79839b..70359334b0 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -1,11 +1,88 @@ #include "inventory.h" +#include "dungeonman.h" +#include "eventman.h" +#include "menus.h" namespace DM { -Viewport gViewportFloppyZzzCross = {174, 2}; // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross +Box gBoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross InventoryMan::InventoryMan(DMEngine *vm): _vm(vm) {} +void InventoryMan::toggleInventory(ChampionIndex championIndex) { + ChampionMan &cm = *_vm->_championMan; + EventManager &em = *_vm->_eventMan; + DisplayMan &dm = *_vm->_displayMan; + + if ((championIndex == kChmpionCloseInventory) && !cm._champions[championIndex]._currHealth) + return; + if (_vm->_pressingEye || _vm->_pressingMouth) + return; + _vm->_stopWaitingForPlayerInput = true; + int16 invChampOrdinal = _inventoryChampionOrdinal; // copy, as the original will be edited + if (indexToOrdinal(championIndex) == invChampOrdinal) { + championIndex = kChmpionCloseInventory; + } + + Champion *champion; + if (invChampOrdinal) { + _inventoryChampionOrdinal = indexToOrdinal(kChampionNone); + warning("MISSING CODE: F0334_INVENTORY_CloseChest"); + champion = &cm._champions[ordinalToIndex(kChampionNone)]; + if (champion->_currHealth && !cm._candidateChampionOrdinal) { + champion->setAttributeFlag(kChampionAttributeStatusBox, true); + warning("MISSING CODE: F0292_CHAMPION_DrawState"); + } + if (cm._partyIsSleeping) { + return; + } + if (championIndex == kChmpionCloseInventory) { + em._refreshMousePointerInMainLoop = true; + _vm->_menuMan->drawMovementArrows(); + em._secondaryMouseInput = gSecondaryMouseInput_Movement; + warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput"); + warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); + return; + } + } + + dm._useByteBoxCoordinates = false; + _inventoryChampionOrdinal = indexToOrdinal(championIndex); + if (!invChampOrdinal) { + warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); + } + + champion = &cm._champions[championIndex]; + int16 w = dm.getWidth(kInventoryGraphicIndice); + int16 h = dm.getHeight(kInventoryGraphicIndice); + dm.blitToScreen(dm.getBitmap(kInventoryGraphicIndice), w, 0, 0, 0, w, 0, h, kColorNoTransparency, gDungeonViewport); + if (cm._candidateChampionOrdinal) { + dm.clearScreenBox(kColorDarkestGray, gBoxFloppyZzzCross, gDungeonViewport); + } else { + static Box gBoxFloppy = Box(174, 182, 2, 12); // @ K0300_s_Box_ViewportFloppy + dm.clearScreenBox(kColorDarkestGray, gBoxFloppy, gDungeonViewport); + } + warning("MISSING CODE: F0052_TEXT_PrintToViewport -> HEALTH"); + warning("MISSING CODE: F0052_TEXT_PrintToViewport -> STAMINA"); + warning("MISSING CODE: F0052_TEXT_PrintToViewport -> MANA"); + + warning("MISSING CODE: F0291_CHAMPION_DrawSlot in LOOOOOOOOOOOOP"); + + champion->setAttributeFlag(kChampionAttributeViewport, true); + champion->setAttributeFlag(kChampionAttributeStatusBox, true); + champion->setAttributeFlag(kChampionAttributePanel, true); + champion->setAttributeFlag(kChampionAttributeLoad, true); + champion->setAttributeFlag(kChampionAttributeStatistics, true); + champion->setAttributeFlag(kChampionAttributeNameTitle, true); + + warning("MISSING CODE: F0292_CHAMPION_DrawState"); + em._mousePointerBitmapUpdated = true; + em._secondaryMouseInput = gSecondaryMouseInput_ChampionInventory; + warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput"); + warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); +} + + } \ No newline at end of file diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 06488fe4d4..6579708293 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -1,5 +1,6 @@ #include "dm.h" #include "gfx.h" +#include "champion.h" @@ -8,7 +9,9 @@ namespace DM { class InventoryMan { DMEngine *_vm; public: + int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal InventoryMan(DMEngine *vm); + void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE }; } \ No newline at end of file -- cgit v1.2.3 From 11e779e0a4cdcf00db4ef69940554da0faab91d5 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 18:18:55 +0200 Subject: DM: Add F0456_START_DrawDisabledMenus --- engines/dm/menus.cpp | 5 +++-- engines/dm/menus.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 530ac24e4a..1d8b00cbc7 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -3,13 +3,14 @@ #include "champion.h" #include "dungeonman.h" #include "objectman.h" +#include "inventory.h" namespace DM { byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon -MenuMan::MenuMan(DMEngine *vm): _vm(vm) {} +MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {} void MenuMan::drawMovementArrows() { DisplayMan &disp = *_vm->_displayMan; @@ -67,4 +68,4 @@ T0386006: box2._y1 = 95; box2._y2 = 110 + 1; dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2); - if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } } } \ No newline at end of file + if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } } void MenuMan::drawDisabledMenu() { if (!_vm->_championMan->_partyIsSleeping) { warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); _vm->_displayMan->_useByteBoxCoordinates = false; if (_vm->_inventoryMan->_inventoryChampionOrdinal) { warning("MISSING CODE: F0334_INVENTORY_CloseChest"); } else { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal"); } } } \ No newline at end of file diff --git a/engines/dm/menus.h b/engines/dm/menus.h index a35659da23..52b99ab771 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -16,6 +16,7 @@ public: void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon void drawMovementArrows(); + void drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus }; } -- cgit v1.2.3 From 334275756946b6079718bcbed16be3cd72afe0c2 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 19 Jun 2016 18:25:21 +0200 Subject: DM: Add G0234_ai_Graphic559_DirectionToStepNorthCount, G0233_ai_Graphic559_DirectionToStepEastCount, G0047_s_Graphic562_Box_ChampionPortrait --- engines/dm/champion.cpp | 2 ++ engines/dm/dm.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 83d520443e..a6b1ff69ba 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -4,6 +4,8 @@ namespace DM { +Box gBoxChampionPortrait = {0, 31, 0, 28}; // @ G0047_s_Graphic562_Box_ChampionPortrait + ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { _leaderIndex = kChampionNone; } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 24182e387b..63ddf12be2 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -23,8 +23,8 @@ namespace DM { -int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; -int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; +int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount +int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); } -- cgit v1.2.3 From c87e3ba0488b10c4dafa7c8d36e99938b22e216a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 19 Jun 2016 19:27:48 +0200 Subject: DM: Fix compilation, fix typos and some comment alignement --- engines/dm/champion.cpp | 4 ++-- engines/dm/dungeonman.cpp | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index a6b1ff69ba..01f863732f 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -4,7 +4,7 @@ namespace DM { -Box gBoxChampionPortrait = {0, 31, 0, 28}; // @ G0047_s_Graphic562_Box_ChampionPortrait +Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { _leaderIndex = kChampionNone; @@ -37,7 +37,7 @@ ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { void ChampionMan::resetDataToStartGame() { if (!_vm->_dungeonMan->_messages._newGame) { - warning("MISSING CODE: stuff for reeseting for loaded games"); + warning("MISSING CODE: stuff for resetting for loaded games"); assert(false); } diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index f93ad0f6cd..1ac9e850be 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -522,12 +522,11 @@ void DungeonMan::decompressDungeonFile() { } } } else { - // TODO: if the dungeon is uncompressed, read it here + warning("TODO: if the dungeon is uncompressed, read it here"); } f.close(); } - uint8 gAdditionalThingCounts[16] = { 0, /* Door */ 0, /* Teleporter */ @@ -547,13 +546,13 @@ uint8 gAdditionalThingCounts[16] = { 50 /* Explosion */ }; // @ G0236_auc_Graphic559_AdditionalThingCounts -// this is the number of uint16s the data has to be stored, not the lenght of the data in dungeon.dat! +// this is the number of uint16s the data has to be stored, not the length of the data in dungeon.dat! unsigned char gThingDataWordCount[16] = { 2, /* Door */ 3, /* Teleporter */ 2, /* Text String */ 4, /* Sensor */ - 9, /* Group */ + 9, /* Group */ 2, /* Weapon */ 2, /* Armour */ 2, /* Scroll */ @@ -570,7 +569,6 @@ unsigned char gThingDataWordCount[16] = { const Thing Thing::_thingNone(0); const Thing Thing::_thingEndOfList(0xFFFE); - void DungeonMan::loadDungeonFile() { if (_messages._newGame) decompressDungeonFile(); @@ -675,7 +673,6 @@ void DungeonMan::loadDungeonFile() { if (_messages._newGame) _dunData._eventMaximumCount = 100; - // load things for (uint16 thingType = kDoorThingType; thingType < kThingTypeTotal; ++thingType) { uint16 thingCount = _fileHeader._thingCounts[thingType]; @@ -726,10 +723,8 @@ void DungeonMan::loadDungeonFile() { _dunData._thingsData[thingType][thingCount + i][0] = Thing::_thingNone.toUint16(); } } - } - // load map data if (!_messages._restartGameRequest) _rawMapData = _rawDunFileData + dunDataStream.pos(); -- cgit v1.2.3 From 61500b3dc8253df3c62fada6ee6e5f297d67b33e Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:07:38 +0200 Subject: DM: Add F0280_CHAMPION_AddCandidateChampionToParty --- engines/dm/champion.cpp | 221 +++++++++++++++++++++++++++++++++++++++++++++++- engines/dm/champion.h | 12 ++- engines/dm/dm.cpp | 1 + engines/dm/dm.h | 1 + engines/dm/dungeonman.h | 3 +- engines/dm/menus.cpp | 162 +++++++++++++++++++---------------- 6 files changed, 322 insertions(+), 78 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 01f863732f..f93a9aa405 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1,10 +1,54 @@ #include "champion.h" #include "dungeonman.h" +#include "eventman.h" +#include "menus.h" +#include "inventory.h" namespace DM { -Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait +uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks + /* 30 for champion inventory, 8 for chest */ + 0xFFFF, /* Ready Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Action Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0x0002, /* Head Head */ + 0x0008, /* Torso Torso */ + 0x0010, /* Legs Legs */ + 0x0020, /* Feet Feet */ + 0x0100, /* Pouch 2 Pouch */ + 0x0080, /* Quiver Line2 1 Quiver 2 */ + 0x0080, /* Quiver Line1 2 Quiver 2 */ + 0x0080, /* Quiver Line2 2 Quiver 2 */ + 0x0004, /* Neck Neck */ + 0x0100, /* Pouch 1 Pouch */ + 0x0040, /* Quiver Line1 1 Quiver 1 */ + 0xFFFF, /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0x0400, /* Chest 1 Chest */ + 0x0400, /* Chest 2 Chest */ + 0x0400, /* Chest 3 Chest */ + 0x0400, /* Chest 4 Chest */ + 0x0400, /* Chest 5 Chest */ + 0x0400, /* Chest 6 Chest */ + 0x0400, /* Chest 7 Chest */ + 0x0400}; /* Chest 8 Chest */ + +Box gBoxChampionPortrait = {0, 31, 0, 28}; // @ G0047_s_Graphic562_Box_ChampionPortrait ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { _leaderIndex = kChampionNone; @@ -37,7 +81,7 @@ ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { void ChampionMan::resetDataToStartGame() { if (!_vm->_dungeonMan->_messages._newGame) { - warning("MISSING CODE: stuff for resetting for loaded games"); + warning("MISSING CODE: stuff for reeseting for loaded games"); assert(false); } @@ -46,4 +90,177 @@ void ChampionMan::resetDataToStartGame() { _leaderEmptyHanded = true; } + +void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { + DisplayMan &dispMan = *_vm->_displayMan; + DungeonMan &dunMan = *_vm->_dungeonMan; + + if (!_leaderEmptyHanded || _partyChampionCount == 4) + return; + + uint16 prevChampCount = _partyChampionCount; + Champion *champ = &_champions[prevChampCount]; + warning("MISSING CODE: Fill champ memory with zero bytes"); + dispMan._useByteBoxCoordinates = true; + { // block on purpose + Box &destBox = gBoxChampionPortrait; + dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), + champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency); + } + + champ->_actionIndex = kChampionActionNone; + champ->_enableActionEventIndex = -1; + champ->_hideDamageReceivedIndex = -1; + champ->_dir = dunMan._currMap._partyDir; + ViewCell AL_0_viewCell = kViewCellFronLeft; + while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone) + AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); + champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3); + champ->clearAttributes(kChampionAttributeIcon); + champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir; + champ->_food = 1500 + _vm->_rnd->getRandomNumber(256); + champ->_water = 1500 + _vm->_rnd->getRandomNumber(256); + int16 AL_0_slotIndex_Red; + for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) { + champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone); + } + Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY); + while (thing.getType() != kTextstringType) { + thing = dunMan.getNextThing(thing); + } + char decodedChampionText[77]; + char* character_Green = decodedChampionText; + dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible)); + int16 AL_0_characterIndex = 0; + uint16 AL_2_character; + while ((AL_2_character = *character_Green++) != '\n') { + champ->_name[AL_0_characterIndex++] = AL_2_character; + } + champ->_name[AL_0_characterIndex] = '\0'; + AL_0_characterIndex = 0; + bool AL_4_champTitleCopied = false; + for (;;) { // infinite + AL_2_character = *character_Green++; + if (AL_2_character == '\n') { + if (AL_4_champTitleCopied) + break; + AL_4_champTitleCopied = true; + } else { + champ->_title[AL_0_characterIndex++] = AL_2_character; + } + } + champ->_title[AL_0_characterIndex] = '\0'; + if (*character_Green++ == 'M') { + champ->setAttributeFlag(kChampionAttributeMale, true); + } + character_Green++; + champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4); + character_Green += 4; + champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4); + character_Green += 4; + character_Green++; + + int16 AL_0_statisticIndex; + for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) { + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30); + uint16 currMaxVal = getDecodedValue(character_Green, 2); + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal); + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal); + character_Green += 2; + } + + champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10); + character_Green++; + + int16 AL_0_skillIndex; + int16 AL_2_skillValue; + for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) { + if ((AL_2_skillValue = *character_Green++ - 'A') > 0) { + champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue); + } + } + + for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) { + int32 baseSkillExp = 0; + int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2; + for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) { + baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience; + } + champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp); + } + + _candidateChampionOrdinal = prevChampCount + 1; + if (++_partyChampionCount == 1) { + _vm->_eventMan->commandSetLeader(kChampionFirst); + _vm->_menuMan->_shouldRefreshActionArea = true; + } else { + _vm->_menuMan->clearActingChampion(); + _vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1)); + } + + int16 mapX = _vm->_dungeonMan->_currMap._partyPosX; + int16 mapY = _vm->_dungeonMan->_currMap._partyPosY; + + uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir)); + mapX += dirIntoStepCountEast[dunMan._currMap._partyDir]; + mapY += dirIntoStepCountNorth[dunMan._currMap._partyDir]; + thing = dunMan.getSquareFirstThing(mapX, mapY); + AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1; + uint16 slotIndex_Green; + while (thing != Thing::_thingNone) { + ThingType AL_2_thingType = thing.getType(); + if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) { + int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots(); + switch (AL_2_thingType) { + case kArmourThingType: + for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) { + if (objectAllowedSlots & gSlotMasks[slotIndex_Green]) + goto T0280048; + } + if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { + slotIndex_Green = kChampionSlotNeck; + } else { + goto T0280046; + } + break; + case kWeaponThingType: + if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) { + slotIndex_Green = kChampionSlotActionHand; + } else { + goto T0280046; + } + break; + case kScrollThingType: + case kPotionThingType: + if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) { + slotIndex_Green = kChampionSlotPouch_1; + } else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) { + slotIndex_Green = kChampionSlotPouch_2; + } else { + goto T0280046; + } + break; + case kContainerThingType: + case kJunkThingType: +T0280046: + if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { + slotIndex_Green = kChampionSlotNeck; + } else { + slotIndex_Green = AL_0_slotIndex_Red++; + } + break; + } +T0280048: + if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) { + goto T0280046; + } + warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot"); + } + thing = dunMan.getNextThing(thing); + } + + _vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount); + _vm->_menuMan->drawDisabledMenu(); +} + } \ No newline at end of file diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 0c8a46fae0..96a5ef563a 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -251,8 +251,9 @@ enum ChampionAction { class Skill { - int _temporaryExperience; - long _experience; +public: + int16 _temporaryExperience; + int32 _experience; }; // @ SKILL class Champion { @@ -291,7 +292,8 @@ public: void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; } Skill getSkill(ChampionSkill skill) { return _skills[skill]; } - void setSkill(ChampionSkill skill, Skill val) { _skills[skill] = val; } + void setSkillExp(ChampionSkill skill, int32 val) { _skills[skill]._experience = val; } + void setSkillTempExp(ChampionSkill skill, int16 val) { _skills[skill]._temporaryExperience= val; } byte getStatistic(ChampionStatisticType type, ChampionStatisticValue valType) { return _statistics[type][valType]; } void setStatistic(ChampionStatisticType type, ChampionStatisticValue valType, byte newVal) { _statistics[type][valType] = newVal; } @@ -305,7 +307,7 @@ public: _attributes &= ~flag; } } - void clearAttributes() { _attributes = kChampionAttributNone; } + void clearAttributes(ChampionAttribute attribute = kChampionAttributNone) { _attributes = attribute; } uint16 getWounds() { return _wounds; } void setWoundsFlag(ChampionWound flag, bool value) { @@ -340,8 +342,10 @@ public: ChampionMan(DMEngine *vm); void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame + void addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty }; + } #endif diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 63ddf12be2..860fba2af6 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -28,6 +28,7 @@ int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 / void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); } +direction returnOppositeDir(direction dir) { return (direction)((dir + 2) & 3); } bool isOrientedWestEast(direction dir) { return dir & 1; } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 66be764bbc..61cb92c2c0 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -32,6 +32,7 @@ extern int8 dirIntoStepCountNorth[4]; void turnDirRight(direction &dir); void turnDirLeft(direction &dir); +direction returnOppositeDir(direction dir); bool isOrientedWestEast(direction dir); diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 41a39739f8..ad64b85084 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -33,6 +33,7 @@ public: ObjectInfo(int16 type, uint16 objectAspectIndex, uint16 actionSetIndex, uint16 allowedSlots) : _type(type), _objectAspectIndex(objectAspectIndex), _actionSetIndex(actionSetIndex), _allowedSlots(allowedSlots) {} bool getAllowedSlot(ObjectAllowedSlot slot) { return _allowedSlots & slot; } + uint16 getAllowedSlots() { return _allowedSlots; } void setAllowedSlot(ObjectAllowedSlot slot, bool val) { if (val) { _allowedSlots |= slot; @@ -566,7 +567,6 @@ class DungeonMan { void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon int16 getSquareFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex - Thing getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing int16 getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal void setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, @@ -579,6 +579,7 @@ public: DungeonMan(DMEngine *dmEngine); ~DungeonMan(); + Thing getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing) uint16 *getThingData(Thing thing); // @ unsigned char* F0156_DUNGEON_GetThingData(register THING P0276_T_Thing) diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 1d8b00cbc7..d39aa22a1a 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -1,71 +1,91 @@ -#include "menus.h" -#include "gfx.h" -#include "champion.h" -#include "dungeonman.h" -#include "objectman.h" -#include "inventory.h" - - -namespace DM { - -byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon - -MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {} - -void MenuMan::drawMovementArrows() { - DisplayMan &disp = *_vm->_displayMan; - byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice); - Box &dest = gBoxMovementArrows; - uint16 w = disp.getWidth(kMovementArrowsIndice); - - disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency); -} -void MenuMan::clearActingChampion() { - ChampionMan &cm = *_vm->_championMan; - if (cm._actingChampionOrdinal) { - cm._actingChampionOrdinal--; - cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true); - warning("MISSING CODE: F0292_CHAMPION_DrawState"); - cm._actingChampionOrdinal = indexToOrdinal(kChampionNone); - _shouldRefreshActionArea = true; - } -} - -void MenuMan::drawActionIcon(ChampionIndex championIndex) { - if (!_actionAreaContainsIcons) - return; - DisplayMan &dm = *_vm->_displayMan; - Champion &champion = _vm->_championMan->_champions[championIndex]; - - Box box; - box._x1 = championIndex * 22 + 233; - box._x2 = box._x1 + 19 + 1; - box._y1 = 86; - box._y2 = 120 + 1; - dm._useByteBoxCoordinates = false; - if (!champion._currHealth) { - dm.clearScreenBox(kColorBlack, box); - return; - } - byte *bitmapIcon = dm._tmpBitmap; - Thing thing = champion.getSlot(kChampionSlotActionHand); - IconIndice iconIndex; - if (thing == Thing::_thingNone) { - iconIndex = kIconIndiceActionEmptyHand; - } else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) { - iconIndex = _vm->_objectMan->getIconIndex(thing); - } else { - dm.clearBitmap(bitmapIcon, 16, 16, kColorCyan); - goto T0386006; - } - _vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon); - dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon); -T0386006: - dm.clearScreenBox(kColorCyan, box); - Box box2; - box2._x1 = box._x1 + 2; - box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that - box2._y1 = 95; - box2._y2 = 110 + 1; - dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2); - if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } } void MenuMan::drawDisabledMenu() { if (!_vm->_championMan->_partyIsSleeping) { warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); _vm->_displayMan->_useByteBoxCoordinates = false; if (_vm->_inventoryMan->_inventoryChampionOrdinal) { warning("MISSING CODE: F0334_INVENTORY_CloseChest"); } else { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal"); } } } \ No newline at end of file +#include "menus.h" +#include "gfx.h" +#include "champion.h" +#include "dungeonman.h" +#include "objectman.h" +#include "inventory.h" + + +namespace DM { + +byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon + +MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {} + +void MenuMan::drawMovementArrows() { + DisplayMan &disp = *_vm->_displayMan; + byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice); + Box &dest = gBoxMovementArrows; + uint16 w = disp.getWidth(kMovementArrowsIndice); + + disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency); +} +void MenuMan::clearActingChampion() { + ChampionMan &cm = *_vm->_championMan; + if (cm._actingChampionOrdinal) { + cm._actingChampionOrdinal--; + cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true); + warning("MISSING CODE: F0292_CHAMPION_DrawState"); + cm._actingChampionOrdinal = indexToOrdinal(kChampionNone); + _shouldRefreshActionArea = true; + } +} + +void MenuMan::drawActionIcon(ChampionIndex championIndex) { + if (!_actionAreaContainsIcons) + return; + DisplayMan &dm = *_vm->_displayMan; + Champion &champion = _vm->_championMan->_champions[championIndex]; + + Box box; + box._x1 = championIndex * 22 + 233; + box._x2 = box._x1 + 19 + 1; + box._y1 = 86; + box._y2 = 120 + 1; + dm._useByteBoxCoordinates = false; + if (!champion._currHealth) { + dm.clearScreenBox(kColorBlack, box); + return; + } + byte *bitmapIcon = dm._tmpBitmap; + Thing thing = champion.getSlot(kChampionSlotActionHand); + IconIndice iconIndex; + if (thing == Thing::_thingNone) { + iconIndex = kIconIndiceActionEmptyHand; + } else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) { + iconIndex = _vm->_objectMan->getIconIndex(thing); + } else { + dm.clearBitmap(bitmapIcon, 16, 16, kColorCyan); + goto T0386006; + } + _vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon); + dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon); +T0386006: + dm.clearScreenBox(kColorCyan, box); + Box box2; + box2._x1 = box._x1 + 2; + box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that + box2._y1 = 95; + box2._y2 = 110 + 1; + dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2); + if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) { + warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); + } +} + +void MenuMan::drawDisabledMenu() { + if (!_vm->_championMan->_partyIsSleeping) { + warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); + _vm->_displayMan->_useByteBoxCoordinates = false; + if (_vm->_inventoryMan->_inventoryChampionOrdinal) { + warning("MISSING CODE: F0334_INVENTORY_CloseChest"); + } else { + warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); + } + warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); + warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); + warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal"); + } +} + +} \ No newline at end of file -- cgit v1.2.3 From cfebcea041d9fd123e06a01d1ddaf87b6e246bc0 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:09:29 +0200 Subject: DM: Add dummy test code for chmpion selection --- engines/dm/champion.cpp | 8 ++++---- engines/dm/dm.cpp | 9 +++++++-- engines/dm/dm.h | 4 ++-- engines/dm/dungeonman.cpp | 8 ++++---- engines/dm/eventman.cpp | 15 +++++++++++++++ 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index f93a9aa405..6518ee9eeb 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -48,7 +48,7 @@ uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks 0x0400, /* Chest 7 Chest */ 0x0400}; /* Chest 8 Chest */ -Box gBoxChampionPortrait = {0, 31, 0, 28}; // @ G0047_s_Graphic562_Box_ChampionPortrait +Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { _leaderIndex = kChampionNone; @@ -81,7 +81,7 @@ ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { void ChampionMan::resetDataToStartGame() { if (!_vm->_dungeonMan->_messages._newGame) { - warning("MISSING CODE: stuff for reeseting for loaded games"); + warning("MISSING CODE: stuff for resetting for loaded games"); assert(false); } @@ -202,8 +202,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { int16 mapY = _vm->_dungeonMan->_currMap._partyPosY; uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir)); - mapX += dirIntoStepCountEast[dunMan._currMap._partyDir]; - mapY += dirIntoStepCountNorth[dunMan._currMap._partyDir]; + mapX += gDirIntoStepCountEast[dunMan._currMap._partyDir]; + mapY += gDirIntoStepCountNorth[dunMan._currMap._partyDir]; thing = dunMan.getSquareFirstThing(mapX, mapY); AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1; uint16 slotIndex_Green; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 860fba2af6..6d9b503399 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -23,8 +23,8 @@ namespace DM { -int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount -int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount +int8 gDirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount +int8 gDirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); } @@ -163,6 +163,11 @@ Common::Error DMEngine::run() { } void DMEngine::gameloop() { + warning("DUMMY CODE SETTING PARTY POS AND DIRECTION"); + _dungeonMan->_currMap._partyPosX = 10; + _dungeonMan->_currMap._partyPosY = 4; + _dungeonMan->_currMap._partyDir = kDirNorth; + while (true) { _stopWaitingForPlayerInput = false; //do { diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 61cb92c2c0..d9cecaa2ab 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -27,8 +27,8 @@ enum direction { }; // TODO: refactor direction into a class -extern int8 dirIntoStepCountEast[4]; -extern int8 dirIntoStepCountNorth[4]; +extern int8 gDirIntoStepCountEast[4]; +extern int8 gDirIntoStepCountNorth[4]; void turnDirRight(direction &dir); void turnDirLeft(direction &dir); diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 1ac9e850be..f489c53d2f 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -391,11 +391,11 @@ int16 DM::indexToOrdinal(int16 val) { return val + 1; } void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) { - posX += dirIntoStepCountEast[dir] * stepsForward; - posY += dirIntoStepCountNorth[dir] * stepsForward; + posX += gDirIntoStepCountEast[dir] * stepsForward; + posY += gDirIntoStepCountNorth[dir] * stepsForward; turnDirRight(dir); - posX += dirIntoStepCountEast[dir] * stepsRight; - posY += dirIntoStepCountNorth[dir] * stepsRight; + posX += gDirIntoStepCountEast[dir] * stepsRight; + posY += gDirIntoStepCountNorth[dir] * stepsRight; } DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) { diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 6d76ddb960..a7a330366d 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -372,6 +372,21 @@ void EventManager::processCommandQueue() { if ((cmd._type >= kCommandMoveForward) && (cmd._type <= kCommandMoveLeft)) { commandMoveParty(cmd._type); return; + } + + if (cmd._type == kCommandClickInDungeonView) { + warning("DUMMY CODE, all of this"); + DungeonMan &dunMan = *_vm->_dungeonMan; + CurrMapData &currMap = dunMan._currMap; + uint16 mapX = currMap._partyPosX; + uint16 mapY = currMap._partyPosY; + mapX += gDirIntoStepCountEast[currMap._partyDir]; + mapY += gDirIntoStepCountNorth[currMap._partyDir]; + Thing squareFirstThing = dunMan.getSquareFirstThing(mapX, mapY); + Sensor sensor(dunMan.getThingData(squareFirstThing)); + if (sensor.getType() == kSensorWallChampionPortrait) { + _vm->_championMan->addCandidateChampionToParty(sensor.getData()); + } } // MISSING CODE: the rest of the function -- cgit v1.2.3 From 0e0fb9763220f0949925fe8d5c6e0dcbd2a15b14 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:18:01 +0200 Subject: DM: Some renaming --- engines/dm/champion.cpp | 4 ++-- engines/dm/dm.cpp | 4 ++-- engines/dm/dm.h | 5 ++--- engines/dm/dungeonman.cpp | 8 ++++---- engines/dm/dungeonman.h | 24 ++++++++++++------------ 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 6518ee9eeb..1ef0e8a81d 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -202,8 +202,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { int16 mapY = _vm->_dungeonMan->_currMap._partyPosY; uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir)); - mapX += gDirIntoStepCountEast[dunMan._currMap._partyDir]; - mapY += gDirIntoStepCountNorth[dunMan._currMap._partyDir]; + mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir]; + mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir]; thing = dunMan.getSquareFirstThing(mapX, mapY); AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1; uint16 slotIndex_Green; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 6d9b503399..e8543fc307 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -23,8 +23,8 @@ namespace DM { -int8 gDirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount -int8 gDirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount +int8 _dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount +int8 _dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index d9cecaa2ab..0b69aff89e 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -27,15 +27,14 @@ enum direction { }; // TODO: refactor direction into a class -extern int8 gDirIntoStepCountEast[4]; -extern int8 gDirIntoStepCountNorth[4]; +extern int8 _dirIntoStepCountEast[4]; +extern int8 _dirIntoStepCountNorth[4]; void turnDirRight(direction &dir); void turnDirLeft(direction &dir); direction returnOppositeDir(direction dir); bool isOrientedWestEast(direction dir); - enum ThingType { kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value kDoorThingType = 0, diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index f489c53d2f..d9554f29da 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -391,11 +391,11 @@ int16 DM::indexToOrdinal(int16 val) { return val + 1; } void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) { - posX += gDirIntoStepCountEast[dir] * stepsForward; - posY += gDirIntoStepCountNorth[dir] * stepsForward; + posX += _dirIntoStepCountEast[dir] * stepsForward; + posY += _dirIntoStepCountNorth[dir] * stepsForward; turnDirRight(dir); - posX += gDirIntoStepCountEast[dir] * stepsRight; - posY += gDirIntoStepCountNorth[dir] * stepsRight; + posX += _dirIntoStepCountEast[dir] * stepsRight; + posY += _dirIntoStepCountNorth[dir] * stepsRight; } DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) { diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index ad64b85084..3dc3ab4176 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -176,19 +176,19 @@ enum TeleporterScope { class Teleporter { - Thing nextThing; - uint16 attributes; - uint16 destMapIndex; + Thing _nextThing; + uint16 _attributes; + uint16 _destMapIndex; public: - Teleporter(uint16 *rawDat) : nextThing(rawDat[0]), attributes(rawDat[1]), destMapIndex(rawDat[2]) {} - Thing getNextThing() { return nextThing; } - bool makesSound() { return (attributes >> 15) & 1; } - TeleporterScope getScope() { return (TeleporterScope)((attributes >> 13) & 1); } - bool absRotation() { return (attributes >> 12) & 1; } - direction getRotationDir() { return (direction)((attributes >> 10) & 1); } - byte getDestY() { return (attributes >> 5) & 0xF; } - byte getDestX() { return attributes & 0xF; } - uint16 getDestMapIndex() { return destMapIndex >> 8; } + Teleporter(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]), _destMapIndex(rawDat[2]) {} + Thing getNextThing() { return _nextThing; } + bool makesSound() { return (_attributes >> 15) & 1; } + TeleporterScope getScope() { return (TeleporterScope)((_attributes >> 13) & 1); } + bool absRotation() { return (_attributes >> 12) & 1; } + direction getRotationDir() { return (direction)((_attributes >> 10) & 1); } + byte getDestY() { return (_attributes >> 5) & 0xF; } + byte getDestX() { return _attributes & 0xF; } + uint16 getDestMapIndex() { return _destMapIndex >> 8; } }; // @ TELEPORTER -- cgit v1.2.3 From 2a2a9a53b0b6dbd0cb18104b2603b3f7968f9d74 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:20:42 +0200 Subject: DM: Add champion reset, fix ChampionMan::addCandidateChampionToPart while loop condition --- engines/dm/champion.cpp | 6 +++--- engines/dm/champion.h | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 1ef0e8a81d..ec098ee137 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -100,9 +100,9 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { uint16 prevChampCount = _partyChampionCount; Champion *champ = &_champions[prevChampCount]; - warning("MISSING CODE: Fill champ memory with zero bytes"); + champ->resetToZero(); dispMan._useByteBoxCoordinates = true; - { // block on purpose + { // limit destBox scope Box &destBox = gBoxChampionPortrait; dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency); @@ -207,7 +207,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { thing = dunMan.getSquareFirstThing(mapX, mapY); AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1; uint16 slotIndex_Green; - while (thing != Thing::_thingNone) { + while (thing != Thing::_thingEndOfList) { ThingType AL_2_thingType = thing.getType(); if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) { int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots(); diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 96a5ef563a..a3c6f80773 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -254,6 +254,8 @@ class Skill { public: int16 _temporaryExperience; int32 _experience; + + void resetToZero() { _temporaryExperience = _experience = 0; } }; // @ SKILL class Champion { @@ -318,6 +320,25 @@ public: } } void clearWounds() { _wounds = kChampionWoundNone; } + void resetToZero() { // oh boy > . < + for (int16 i = 0; i < 30; ++i) + _slots[i] = Thing::_thingNone; + for (int16 i = 0; i < 20; ++i) + _skills[i].resetToZero(); + _attributes = _wounds = 0; + memset(_statistics, 0, 7 * 3); + memset(_name, '\0', 8); + memset(_title, '\0', 20); + _dir = kDirNorth; + _cell = kViewCellFronLeft; + _actionIndex = kChampionActionN; + _symbolStep = 0; + memset(_symbols, '\0', 5); + _directionMaximumDamageReceived = _maximumDamageReceived = _poisonEventCount = _enableActionEventIndex = 0; + _hideDamageReceivedIndex = _currHealth = _maxHealth = _currStamina = _maxStamina = _currMana = _maxMana = 0; + _actionDefense = _food = _water = _load = _shieldDefense = 0; + memset(_portrait, 0, 464); + } }; // @ CHAMPION_INCLUDING_PORTRAIT class ChampionMan { -- cgit v1.2.3 From 051b1d9adf69ac82a76751a0fe13c69ac7822934 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 20 Jun 2016 14:34:31 +0200 Subject: DM: Remove demo code from ToggleInventory, add dummy code setting _inventoryChampionOrdinal, fix error in InventoryToggle getting champion pointer --- engines/dm/dm.cpp | 8 ++++++-- engines/dm/inventory.cpp | 7 ++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index e8543fc307..c1d7e14c0d 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -168,6 +168,9 @@ void DMEngine::gameloop() { _dungeonMan->_currMap._partyPosY = 4; _dungeonMan->_currMap._partyDir = kDirNorth; + + warning("DUMMY CODE: setting InventoryMan::_inventoryChampionOrdinal to zero"); + _inventoryMan->_inventoryChampionOrdinal = 0; while (true) { _stopWaitingForPlayerInput = false; //do { @@ -175,8 +178,9 @@ void DMEngine::gameloop() { _eventMan->processCommandQueue(); //} while (!_stopWaitingForPlayerInput || !_gameTimeTicking); - _displayMan->clearScreen(kColorBlack); - _displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY); + if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) { + _displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY); + } // DUMMY CODE: next line _menuMan->drawMovementArrows(); _displayMan->updateScreen(); diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 70359334b0..5c448c0175 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -9,7 +9,7 @@ namespace DM { Box gBoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross -InventoryMan::InventoryMan(DMEngine *vm): _vm(vm) {} +InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {} void InventoryMan::toggleInventory(ChampionIndex championIndex) { ChampionMan &cm = *_vm->_championMan; @@ -30,7 +30,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { if (invChampOrdinal) { _inventoryChampionOrdinal = indexToOrdinal(kChampionNone); warning("MISSING CODE: F0334_INVENTORY_CloseChest"); - champion = &cm._champions[ordinalToIndex(kChampionNone)]; + champion = &cm._champions[ordinalToIndex(_inventoryChampionOrdinal)]; if (champion->_currHealth && !cm._candidateChampionOrdinal) { champion->setAttributeFlag(kChampionAttributeStatusBox, true); warning("MISSING CODE: F0292_CHAMPION_DrawState"); @@ -60,9 +60,6 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { dm.blitToScreen(dm.getBitmap(kInventoryGraphicIndice), w, 0, 0, 0, w, 0, h, kColorNoTransparency, gDungeonViewport); if (cm._candidateChampionOrdinal) { dm.clearScreenBox(kColorDarkestGray, gBoxFloppyZzzCross, gDungeonViewport); - } else { - static Box gBoxFloppy = Box(174, 182, 2, 12); // @ K0300_s_Box_ViewportFloppy - dm.clearScreenBox(kColorDarkestGray, gBoxFloppy, gDungeonViewport); } warning("MISSING CODE: F0052_TEXT_PrintToViewport -> HEALTH"); warning("MISSING CODE: F0052_TEXT_PrintToViewport -> STAMINA"); -- cgit v1.2.3 From 3fe7213947a52b75ad7a0777af840909a372ef8f Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 20 Jun 2016 17:34:32 +0200 Subject: DM: Add PARTY and SCENT types --- engines/dm/champion.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index a3c6f80773..8f202612d3 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -6,6 +6,46 @@ namespace DM { +class Scent { + uint16 _scent; +public: + Scent(uint16 scent = 0): _scent(scent) {} + + uint16 getMapX() { return _scent & 0x1F; } + uint16 getMapY() { return (_scent >> 5) & 0x1F; } + uint16 getMapIndex() { return (_scent >> 10) & 0x3F; } + + uint16 setMapX(uint16 val) { _scent = (_scent & ~0x1F) & (val & 0x1F); } + uint16 setMapY(uint16 val) { _scent = (_scent & ~(0x1F << 5)) & (val & 0x1F); } + uint16 setMapIndex(uint16 val) { _scent = (_scent & ~(0x1F << 10)) & (val & 0x3F); } +}; // @ SCENT + +class Party { +public: + Party() { + _magicalLightAmount = _event73Count_ThievesEye = _event79Count_Footprints = _shieldDefense = 0; + _fireShieldDefense = _spellShieldDefense = _scentCount = _freezeLifeTicks = _firstScentIndex = 0; + _lastScentIndex = _event71Count_Invisibility = 0; + for (int16 i = 0; i < 24; ++i) + _scentStrengths[i] = 0; + } + int16 _magicalLightAmount; + byte _event73Count_ThievesEye; + byte _event79Count_Footprints; + int16 _shieldDefense; + + int16 _fireShieldDefense; + int16 _spellShieldDefense; + byte _scentCount; + byte _freezeLifeTicks; + byte _firstScentIndex; + + byte _lastScentIndex; + Scent _scents[24]; // if I remember correctly, user defined default constructors are always called + byte _scentStrengths[24]; + byte _event71Count_Invisibility; +}; // @ PARTY + enum IconIndice { kIconIndiceNone = -1, // @ CM1_ICON_NONE kIconIndiceJunkCompassNorth = 0, // @ C000_ICON_JUNK_COMPASS_NORTH -- cgit v1.2.3 From 35b5f03b26ec126af55a901af68f392e8fa883a1 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:23:22 +0200 Subject: DM: Add G0048_s_Graphic562_Box_Mouth, G0049_s_Graphic562_Box_Eye, G0054_ai_Graphic562_Box_ChampionIcons, G0046_auc_Graphic562_ChampionColor --- engines/dm/champion.cpp | 539 ++++++++++++++++++++++++------------------------ 1 file changed, 274 insertions(+), 265 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index ec098ee137..052c7e89e0 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1,266 +1,275 @@ -#include "champion.h" -#include "dungeonman.h" -#include "eventman.h" -#include "menus.h" -#include "inventory.h" - - -namespace DM { - -uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks - /* 30 for champion inventory, 8 for chest */ - 0xFFFF, /* Ready Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Action Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0x0002, /* Head Head */ - 0x0008, /* Torso Torso */ - 0x0010, /* Legs Legs */ - 0x0020, /* Feet Feet */ - 0x0100, /* Pouch 2 Pouch */ - 0x0080, /* Quiver Line2 1 Quiver 2 */ - 0x0080, /* Quiver Line1 2 Quiver 2 */ - 0x0080, /* Quiver Line2 2 Quiver 2 */ - 0x0004, /* Neck Neck */ - 0x0100, /* Pouch 1 Pouch */ - 0x0040, /* Quiver Line1 1 Quiver 1 */ - 0xFFFF, /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0x0400, /* Chest 1 Chest */ - 0x0400, /* Chest 2 Chest */ - 0x0400, /* Chest 3 Chest */ - 0x0400, /* Chest 4 Chest */ - 0x0400, /* Chest 5 Chest */ - 0x0400, /* Chest 6 Chest */ - 0x0400, /* Chest 7 Chest */ - 0x0400}; /* Chest 8 Chest */ - -Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait - -ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { - _leaderIndex = kChampionNone; -} - -uint16 ChampionMan::getChampionPortraitX(uint16 index) { - return ((index) & 0x7) << 5; -} - -uint16 ChampionMan::getChampionPortraitY(uint16 index) { - return ((index) >> 3) * 29; -} - -int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) { - int val = 0; - for (uint16 i = 0; i < characterCount; ++i) { - val = (val << 4) + (string[i] - 'A'); - } - return val; -} - -ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { - for (uint16 i = 0; i < _partyChampionCount; ++i) { - if ((_champions[i]._cell == cell) && _champions[i]._currHealth) - return (ChampionIndex)i; - } - - return kChampionNone; -} - -void ChampionMan::resetDataToStartGame() { - if (!_vm->_dungeonMan->_messages._newGame) { - warning("MISSING CODE: stuff for resetting for loaded games"); - assert(false); - } - - _leaderHand = Thing::_thingNone; - _leaderHandObjectIconIndex = kIconIndiceNone; - _leaderEmptyHanded = true; -} - - -void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { - DisplayMan &dispMan = *_vm->_displayMan; - DungeonMan &dunMan = *_vm->_dungeonMan; - - if (!_leaderEmptyHanded || _partyChampionCount == 4) - return; - - uint16 prevChampCount = _partyChampionCount; - Champion *champ = &_champions[prevChampCount]; - champ->resetToZero(); - dispMan._useByteBoxCoordinates = true; - { // limit destBox scope - Box &destBox = gBoxChampionPortrait; - dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), - champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency); - } - - champ->_actionIndex = kChampionActionNone; - champ->_enableActionEventIndex = -1; - champ->_hideDamageReceivedIndex = -1; - champ->_dir = dunMan._currMap._partyDir; - ViewCell AL_0_viewCell = kViewCellFronLeft; - while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone) - AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); - champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3); - champ->clearAttributes(kChampionAttributeIcon); - champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir; - champ->_food = 1500 + _vm->_rnd->getRandomNumber(256); - champ->_water = 1500 + _vm->_rnd->getRandomNumber(256); - int16 AL_0_slotIndex_Red; - for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) { - champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone); - } - Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY); - while (thing.getType() != kTextstringType) { - thing = dunMan.getNextThing(thing); - } - char decodedChampionText[77]; - char* character_Green = decodedChampionText; - dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible)); - int16 AL_0_characterIndex = 0; - uint16 AL_2_character; - while ((AL_2_character = *character_Green++) != '\n') { - champ->_name[AL_0_characterIndex++] = AL_2_character; - } - champ->_name[AL_0_characterIndex] = '\0'; - AL_0_characterIndex = 0; - bool AL_4_champTitleCopied = false; - for (;;) { // infinite - AL_2_character = *character_Green++; - if (AL_2_character == '\n') { - if (AL_4_champTitleCopied) - break; - AL_4_champTitleCopied = true; - } else { - champ->_title[AL_0_characterIndex++] = AL_2_character; - } - } - champ->_title[AL_0_characterIndex] = '\0'; - if (*character_Green++ == 'M') { - champ->setAttributeFlag(kChampionAttributeMale, true); - } - character_Green++; - champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4); - character_Green += 4; - champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4); - character_Green += 4; - character_Green++; - - int16 AL_0_statisticIndex; - for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) { - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30); - uint16 currMaxVal = getDecodedValue(character_Green, 2); - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal); - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal); - character_Green += 2; - } - - champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10); - character_Green++; - - int16 AL_0_skillIndex; - int16 AL_2_skillValue; - for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) { - if ((AL_2_skillValue = *character_Green++ - 'A') > 0) { - champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue); - } - } - - for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) { - int32 baseSkillExp = 0; - int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2; - for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) { - baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience; - } - champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp); - } - - _candidateChampionOrdinal = prevChampCount + 1; - if (++_partyChampionCount == 1) { - _vm->_eventMan->commandSetLeader(kChampionFirst); - _vm->_menuMan->_shouldRefreshActionArea = true; - } else { - _vm->_menuMan->clearActingChampion(); - _vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1)); - } - - int16 mapX = _vm->_dungeonMan->_currMap._partyPosX; - int16 mapY = _vm->_dungeonMan->_currMap._partyPosY; - - uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir)); - mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir]; - mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir]; - thing = dunMan.getSquareFirstThing(mapX, mapY); - AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1; - uint16 slotIndex_Green; - while (thing != Thing::_thingEndOfList) { - ThingType AL_2_thingType = thing.getType(); - if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) { - int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots(); - switch (AL_2_thingType) { - case kArmourThingType: - for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) { - if (objectAllowedSlots & gSlotMasks[slotIndex_Green]) - goto T0280048; - } - if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { - slotIndex_Green = kChampionSlotNeck; - } else { - goto T0280046; - } - break; - case kWeaponThingType: - if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) { - slotIndex_Green = kChampionSlotActionHand; - } else { - goto T0280046; - } - break; - case kScrollThingType: - case kPotionThingType: - if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) { - slotIndex_Green = kChampionSlotPouch_1; - } else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) { - slotIndex_Green = kChampionSlotPouch_2; - } else { - goto T0280046; - } - break; - case kContainerThingType: - case kJunkThingType: -T0280046: - if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { - slotIndex_Green = kChampionSlotNeck; - } else { - slotIndex_Green = AL_0_slotIndex_Red++; - } - break; - } -T0280048: - if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) { - goto T0280046; - } - warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot"); - } - thing = dunMan.getNextThing(thing); - } - - _vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount); - _vm->_menuMan->drawDisabledMenu(); -} - +#include "champion.h" +#include "dungeonman.h" +#include "eventman.h" +#include "menus.h" +#include "inventory.h" + + +namespace DM { + +Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth +Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye +Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons + Box(281, 299, 0, 13), + Box(301, 319, 0, 13), + Box(301, 319, 15, 28), + Box(281, 299, 15, 28) }; +byte gChampionColor[4] = {7, 11, 8, 14}; // @ G0046_auc_Graphic562_ChampionColor + +uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks + /* 30 for champion inventory, 8 for chest */ + 0xFFFF, /* Ready Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Action Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0x0002, /* Head Head */ + 0x0008, /* Torso Torso */ + 0x0010, /* Legs Legs */ + 0x0020, /* Feet Feet */ + 0x0100, /* Pouch 2 Pouch */ + 0x0080, /* Quiver Line2 1 Quiver 2 */ + 0x0080, /* Quiver Line1 2 Quiver 2 */ + 0x0080, /* Quiver Line2 2 Quiver 2 */ + 0x0004, /* Neck Neck */ + 0x0100, /* Pouch 1 Pouch */ + 0x0040, /* Quiver Line1 1 Quiver 1 */ + 0xFFFF, /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0x0400, /* Chest 1 Chest */ + 0x0400, /* Chest 2 Chest */ + 0x0400, /* Chest 3 Chest */ + 0x0400, /* Chest 4 Chest */ + 0x0400, /* Chest 5 Chest */ + 0x0400, /* Chest 6 Chest */ + 0x0400, /* Chest 7 Chest */ + 0x0400}; /* Chest 8 Chest */ + +Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait + +ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { + _leaderIndex = kChampionNone; +} + +uint16 ChampionMan::getChampionPortraitX(uint16 index) { + return ((index) & 0x7) << 5; +} + +uint16 ChampionMan::getChampionPortraitY(uint16 index) { + return ((index) >> 3) * 29; +} + +int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) { + int val = 0; + for (uint16 i = 0; i < characterCount; ++i) { + val = (val << 4) + (string[i] - 'A'); + } + return val; +} + +ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { + for (uint16 i = 0; i < _partyChampionCount; ++i) { + if ((_champions[i]._cell == cell) && _champions[i]._currHealth) + return (ChampionIndex)i; + } + + return kChampionNone; +} + +void ChampionMan::resetDataToStartGame() { + if (!_vm->_dungeonMan->_messages._newGame) { + warning("MISSING CODE: stuff for resetting for loaded games"); + assert(false); + } + + _leaderHand = Thing::_thingNone; + _leaderHandObjectIconIndex = kIconIndiceNone; + _leaderEmptyHanded = true; +} + + +void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { + DisplayMan &dispMan = *_vm->_displayMan; + DungeonMan &dunMan = *_vm->_dungeonMan; + + if (!_leaderEmptyHanded || _partyChampionCount == 4) + return; + + uint16 prevChampCount = _partyChampionCount; + Champion *champ = &_champions[prevChampCount]; + champ->resetToZero(); + dispMan._useByteBoxCoordinates = true; + { // limit destBox scope + Box &destBox = gBoxChampionPortrait; + dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), + champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency); + } + + champ->_actionIndex = kChampionActionNone; + champ->_enableActionEventIndex = -1; + champ->_hideDamageReceivedIndex = -1; + champ->_dir = dunMan._currMap._partyDir; + ViewCell AL_0_viewCell = kViewCellFronLeft; + while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone) + AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); + champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3); + champ->clearAttributes(kChampionAttributeIcon); + champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir; + champ->_food = 1500 + _vm->_rnd->getRandomNumber(256); + champ->_water = 1500 + _vm->_rnd->getRandomNumber(256); + int16 AL_0_slotIndex_Red; + for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) { + champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone); + } + Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY); + while (thing.getType() != kTextstringType) { + thing = dunMan.getNextThing(thing); + } + char decodedChampionText[77]; + char* character_Green = decodedChampionText; + dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible)); + int16 AL_0_characterIndex = 0; + uint16 AL_2_character; + while ((AL_2_character = *character_Green++) != '\n') { + champ->_name[AL_0_characterIndex++] = AL_2_character; + } + champ->_name[AL_0_characterIndex] = '\0'; + AL_0_characterIndex = 0; + bool AL_4_champTitleCopied = false; + for (;;) { // infinite + AL_2_character = *character_Green++; + if (AL_2_character == '\n') { + if (AL_4_champTitleCopied) + break; + AL_4_champTitleCopied = true; + } else { + champ->_title[AL_0_characterIndex++] = AL_2_character; + } + } + champ->_title[AL_0_characterIndex] = '\0'; + if (*character_Green++ == 'M') { + champ->setAttributeFlag(kChampionAttributeMale, true); + } + character_Green++; + champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4); + character_Green += 4; + champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4); + character_Green += 4; + character_Green++; + + int16 AL_0_statisticIndex; + for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) { + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30); + uint16 currMaxVal = getDecodedValue(character_Green, 2); + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal); + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal); + character_Green += 2; + } + + champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10); + character_Green++; + + int16 AL_0_skillIndex; + int16 AL_2_skillValue; + for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) { + if ((AL_2_skillValue = *character_Green++ - 'A') > 0) { + champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue); + } + } + + for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) { + int32 baseSkillExp = 0; + int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2; + for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) { + baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience; + } + champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp); + } + + _candidateChampionOrdinal = prevChampCount + 1; + if (++_partyChampionCount == 1) { + _vm->_eventMan->commandSetLeader(kChampionFirst); + _vm->_menuMan->_shouldRefreshActionArea = true; + } else { + _vm->_menuMan->clearActingChampion(); + _vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1)); + } + + int16 mapX = _vm->_dungeonMan->_currMap._partyPosX; + int16 mapY = _vm->_dungeonMan->_currMap._partyPosY; + + uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir)); + mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir]; + mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir]; + thing = dunMan.getSquareFirstThing(mapX, mapY); + AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1; + uint16 slotIndex_Green; + while (thing != Thing::_thingEndOfList) { + ThingType AL_2_thingType = thing.getType(); + if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) { + int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots(); + switch (AL_2_thingType) { + case kArmourThingType: + for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) { + if (objectAllowedSlots & gSlotMasks[slotIndex_Green]) + goto T0280048; + } + if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { + slotIndex_Green = kChampionSlotNeck; + } else { + goto T0280046; + } + break; + case kWeaponThingType: + if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) { + slotIndex_Green = kChampionSlotActionHand; + } else { + goto T0280046; + } + break; + case kScrollThingType: + case kPotionThingType: + if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) { + slotIndex_Green = kChampionSlotPouch_1; + } else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) { + slotIndex_Green = kChampionSlotPouch_2; + } else { + goto T0280046; + } + break; + case kContainerThingType: + case kJunkThingType: +T0280046: + if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { + slotIndex_Green = kChampionSlotNeck; + } else { + slotIndex_Green = AL_0_slotIndex_Red++; + } + break; + } +T0280048: + if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) { + goto T0280046; + } + warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot"); + } + thing = dunMan.getNextThing(thing); + } + + _vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount); + _vm->_menuMan->drawDisabledMenu(); +} + } \ No newline at end of file -- cgit v1.2.3 From aa269b9f5e30cd2592884362b4e25a2a1a4c4ce6 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 20 Jun 2016 18:03:48 +0200 Subject: DM: Add blitToScreen using Box --- engines/dm/gfx.cpp | 18 ++++++++++++------ engines/dm/gfx.h | 3 +++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 223257c220..28fb63cac6 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -117,7 +117,7 @@ enum ViewSquare { Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor -Frame gFrameWall_D3L2 = Frame(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2 +Frame gFrameWall_D3L2 = Frame(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2 Frame gFrameWall_D3R2 = Frame(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2 Frame gFrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls /* { X1, X2, Y1, Y2, pixelWidth, Height, X, Y } */ @@ -564,7 +564,7 @@ byte gAlcoveOrnIndices[kAlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrna using namespace DM; -DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { +DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _vgaBuffer = nullptr; _bitmaps = nullptr; _grapItemCount = 0; @@ -585,9 +585,9 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { for (int i = 0; i < kStairsGraphicCount; i++) _stairIndices[i] = 0; - + for (int i = 0; i < 4; i++) - _palChangesProjectile[i] = nullptr; + _palChangesProjectile[i] = nullptr; for (int i = 0; i < kAlcoveOrnCount; i++) _currMapAlcoveOrnIndices[i] = 0; @@ -604,7 +604,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _currMapDoorOrnInfo[j][i] = 0; } } - + for (int i = 0; i < 16; i++) { _currMapWallOrnIndices[i] = 0; _currMapFloorOrnIndices[i] = 0; @@ -1435,7 +1435,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex bitmapGreen = _bitmaps[nativeBitmapIndex]; var_X = pixelWidth; if (flipHorizontal) { - if(bitmapGreen != _tmpBitmap) + if (bitmapGreen != _tmpBitmap) blitToBitmap(bitmapGreen, coordSetB[4], coordSetB[5], _tmpBitmap, coordSetB[4]); flipBitmapHorizontal(_tmpBitmap, coordSetB[4], coordSetB[5]); bitmapGreen = _tmpBitmap; @@ -1506,3 +1506,9 @@ void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) { for (int y = box._y1; y < box._y2; ++y) memset(_vgaBuffer + y * _screenWidth + box._x1, color, sizeof(byte) * width); } + +void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, + Box &box, + Color transparent, Viewport &viewport) { + blitToScreen(srcBitmap, srcWidth, srcX, srcY, box._x1, box._x2, box._y1, box._y2, transparent, viewport); +} diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 65322918cd..48df3d7695 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -290,6 +290,9 @@ public: void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort); + void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, + Box &box, + Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort); void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); -- cgit v1.2.3 From d5e4448ec619dd724fbdcbda38a5d3db8f74122a Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 20 Jun 2016 18:12:22 +0200 Subject: DM: Add F0354_INVENTORY_DrawStatusBoxPortrait --- engines/dm/inventory.cpp | 14 +++++++++++++- engines/dm/inventory.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 5c448c0175..c62bf15905 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -2,6 +2,7 @@ #include "dungeonman.h" #include "eventman.h" #include "menus.h" +#include "gfx.h" @@ -81,5 +82,16 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); } +#define kChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING +void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) { + DisplayMan &dispMan = *_vm->_displayMan; + dispMan._useByteBoxCoordinates = false; + Box box; + box._y1 = 0; + box._y2 = 28 + 1; + box._x1 = championIndex * kChampionStatusBoxSpacing + 7; + box._x2 = box._x1 + 31 + 1; + dispMan.blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0, box, kColorNoTransparency); +} -} \ No newline at end of file +} diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 6579708293..90565f57ce 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -12,6 +12,7 @@ public: int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal InventoryMan(DMEngine *vm); void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE + void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait }; } \ No newline at end of file -- cgit v1.2.3 From ef2411f7afe060ce60b6b2d6d607dc3d8d339021 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 20 Jun 2016 19:39:36 +0200 Subject: DM: Add F0287_CHAMPION_DrawBarGraph --- engines/dm/champion.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++-- engines/dm/champion.h | 1 + engines/dm/inventory.cpp | 1 - engines/dm/inventory.h | 2 ++ 4 files changed, 69 insertions(+), 3 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 052c7e89e0..b30d3390c5 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -13,8 +13,8 @@ Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons Box(281, 299, 0, 13), Box(301, 319, 0, 13), Box(301, 319, 15, 28), - Box(281, 299, 15, 28) }; -byte gChampionColor[4] = {7, 11, 8, 14}; // @ G0046_auc_Graphic562_ChampionColor + Box(281, 299, 15, 28)}; +Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; // @ G0046_auc_Graphic562_ChampionColor uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks /* 30 for champion inventory, 8 for chest */ @@ -272,4 +272,68 @@ T0280048: _vm->_menuMan->drawDisabledMenu(); } +void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { + + Champion *AL_6_champion = &_champions[champIndex]; + int16 AL_2_barGraphIndex = 0; + int16 barGraphHeightArray[3]; + + if (AL_6_champion->_currHealth > 0) { + uint32 AL_4_barGraphHeight = (((uint32)(AL_6_champion->_currHealth) << 10) * 25) / AL_6_champion->_maxHealth; + if (AL_4_barGraphHeight & 0x3FF) { + barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10) + 1; + } else { + barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10); + } + } else { + barGraphHeightArray[AL_2_barGraphIndex++] = 0; + } + + if (AL_6_champion->_currStamina > 0) { + uint32 AL_4_barGraphHeight = (((uint32)(AL_6_champion->_currStamina) << 10) * 25) / AL_6_champion->_maxStamina; + if (AL_4_barGraphHeight & 0x3FF) { + barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10) + 1; + } else { + barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10); + } + } else { + barGraphHeightArray[AL_2_barGraphIndex++] = 0; + } + + if (AL_6_champion->_currMana > 0) { + uint32 AL_4_barGraphHeight = (((uint32)(AL_6_champion->_currMana) << 10) * 25) / AL_6_champion->_maxMana; + if (AL_4_barGraphHeight & 0x3FF) { + barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10) + 1; + } else { + barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10); + } + } else { + barGraphHeightArray[AL_2_barGraphIndex++] = 0; + } + warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + + Box box; + box._x1 = champIndex * kChampionStatusBoxSpacing + 46; + box._x2 = box._x1 + 3; + box._y1 = 2; + box._y2 = 26; + + for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) { + int16 AL_2_barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex]; + if (AL_2_barGraphHeight < 25) { + box._y1 = 2; + box._y1 = 27 - AL_2_barGraphHeight; + _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); + } + if (AL_2_barGraphHeight) { + box._y1 = 27 - AL_2_barGraphHeight; + box._y2 = 26; + _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); + } + box._x1 += 7; + box._x2 += 7; + } + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); +} + } \ No newline at end of file diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 8f202612d3..b92462d61c 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -404,6 +404,7 @@ public: ChampionMan(DMEngine *vm); void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame void addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty + void drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs }; diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index c62bf15905..15dbd7e82f 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -82,7 +82,6 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); } -#define kChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) { DisplayMan &dispMan = *_vm->_displayMan; dispMan._useByteBoxCoordinates = false; diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 90565f57ce..eb4b458b82 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -6,6 +6,8 @@ namespace DM { +#define kChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING + class InventoryMan { DMEngine *_vm; public: -- cgit v1.2.3 From 493c8ed4bcdfc02b5327ad0e2e083cd4e8158736 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 20 Jun 2016 20:51:06 +0200 Subject: DM: Add F0306_CHAMPION_GetStaminaAdjustedValue --- engines/dm/champion.cpp | 11 +++++++++++ engines/dm/champion.h | 1 + 2 files changed, 12 insertions(+) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b30d3390c5..f38552ac32 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -336,4 +336,15 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } + +int16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) { + int16 currStamina = champ->_currStamina; + int16 halfMaxStamina = champ->_maxStamina / 2; + if (currStamina < halfMaxStamina) { + val /= 2; + return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina; + } + return val; +} + } \ No newline at end of file diff --git a/engines/dm/champion.h b/engines/dm/champion.h index b92462d61c..6271c94fc6 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -405,6 +405,7 @@ public: void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame void addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty void drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs + int16 getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue }; -- cgit v1.2.3 From 3134891f6cf62b1c20f2622030bfd2deb2ecefee Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 20 Jun 2016 21:40:09 +0200 Subject: DM: Add F0309_CHAMPION_GetMaximumLoad --- engines/dm/champion.cpp | 19 ++++++++++++++++++- engines/dm/champion.h | 4 +++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index f38552ac32..898975de65 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -3,6 +3,7 @@ #include "eventman.h" #include "menus.h" #include "inventory.h" +#include "objectman.h" namespace DM { @@ -337,14 +338,30 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { } -int16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) { +uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) { int16 currStamina = champ->_currStamina; int16 halfMaxStamina = champ->_maxStamina / 2; if (currStamina < halfMaxStamina) { + warning("Possible undefined behaviour in the original code"); val /= 2; return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina; } return val; } +uint16 ChampionMan::getMaximumLoad(Champion *champ) { + uint16 maximumLoad = champ->getStatistic(kChampionStatStrength, kChampionStatCurrent) * 8 + 100; + maximumLoad = getStaminaAdjustedValue(champ, maximumLoad); + int16 wounds = champ->getWounds(); + if (wounds) { + maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kChampionWoundLegs) ? 2 : 3); + } + if (_vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotFeet)) == kIconIndiceArmourElvenBoots) { + maximumLoad += maximumLoad * 16; + } + maximumLoad += 9; + maximumLoad -= maximumLoad % 10; + return maximumLoad; +} + } \ No newline at end of file diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 6271c94fc6..db554120f2 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -359,6 +359,7 @@ public: _wounds &= ~flag; } } + uint16 getWoundsFlag(ChampionWound wound) { return _wounds & wound; } void clearWounds() { _wounds = kChampionWoundNone; } void resetToZero() { // oh boy > . < for (int16 i = 0; i < 30; ++i) @@ -405,7 +406,8 @@ public: void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame void addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty void drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs - int16 getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue + uint16 getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue + uint16 getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad }; -- cgit v1.2.3 From b068beb33f38c2f3a4cb8c5ea0b26ad53b3e35b0 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 20 Jun 2016 21:51:34 +0200 Subject: DM: Add G0032_s_Graphic562_Box_Panel, G0035_s_Graphic562_Box_Food, G0036_s_Graphic562_Box_Water, G0037_s_Graphic562_Box_Poisoned --- engines/dm/inventory.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 15dbd7e82f..2e7f2544f4 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -9,6 +9,10 @@ namespace DM { Box gBoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross +Box gBoxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel +Box gBoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food +Box gBoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water +Box gBoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {} -- cgit v1.2.3 From 3385a3dd5cc21a3e8b05ad065dd46fc38e39ba33 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 20 Jun 2016 22:10:55 +0200 Subject: DM: Add F0343_INVENTORY_DrawPanel_HorizontalBar --- engines/dm/inventory.cpp | 10 ++++++++++ engines/dm/inventory.h | 1 + 2 files changed, 11 insertions(+) diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 2e7f2544f4..ea643dac4d 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -97,4 +97,14 @@ void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) { dispMan.blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0, box, kColorNoTransparency); } +void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) { + Box box; + box._x1 = x; + box._x2 = box._x1 + pixelWidth; + box._y1 = y; + box._y2 = box._y1 + 6; + _vm->_displayMan->_useByteBoxCoordinates = false; + _vm->_displayMan->clearScreenBox(color, box); +} + } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index eb4b458b82..192b68964a 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -15,6 +15,7 @@ public: InventoryMan(DMEngine *vm); void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait + void drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar }; } \ No newline at end of file -- cgit v1.2.3 From 8c007d02faf933ae633a5f10694e9d1667d424c3 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 20 Jun 2016 22:20:58 +0200 Subject: DM: Add F0344_INVENTORY_DrawPanel_FoodOrWaterBar --- engines/dm/inventory.cpp | 16 ++++++++++++++++ engines/dm/inventory.h | 1 + 2 files changed, 17 insertions(+) diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index ea643dac4d..98713d01ce 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -107,4 +107,20 @@ void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Co _vm->_displayMan->clearScreenBox(color, box); } +void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) { + if (amount < -512) { + color = kColorRed; + } else if(amount < 0) { + color = kColorYellow; + } + + int16 pixelWidth = amount + 1024; + if (pixelWidth == 3072) { + pixelWidth = 3071; + } + pixelWidth /= 32; + drawPanelHorizontalBar(115, y + 2, pixelWidth, kColorBlack); + drawPanelHorizontalBar(113, y, pixelWidth, color); +} + } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 192b68964a..bd6f18d788 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -16,6 +16,7 @@ public: void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait void drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar + void drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color); // @ F0344_INVENTORY_DrawPanel_FoodOrWaterBar }; } \ No newline at end of file -- cgit v1.2.3 From 6eea379cc5d7311fde62b9f63fa175b42762a565 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 21 Jun 2016 01:15:06 +0200 Subject: DM: Add F0345_INVENTORY_DrawPanel_FoodWaterPoisoned --- engines/dm/gfx.h | 8 ++++++-- engines/dm/inventory.cpp | 16 +++++++++++++++- engines/dm/inventory.h | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 48df3d7695..023535f704 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -13,7 +13,7 @@ enum ViewCell { kViewCellBackRight = 2, // @ C02_VIEW_CELL_BACK_RIGHT kViewCellBackLeft = 3, // @ C03_VIEW_CELL_BACK_LEFT kViewCellAlcove = 4, // @ C04_VIEW_CELL_ALCOVE - kViewCellDoorButtonOrWallOrn = 5 // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT + kViewCellDoorButtonOrWallOrn = 5, // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT }; enum GraphicIndice { @@ -28,7 +28,11 @@ enum GraphicIndice { kObjectIcons_128_TO_159 = 46, // @ C046_GRAPHIC_OBJECT_ICONS_128_TO_159 kObjectIcons_160_TO_191 = 47, // @ C047_GRAPHIC_OBJECT_ICONS_160_TO_191 kObjectIcons_192_TO_223 = 48, // @ C048_GRAPHIC_OBJECT_ICONS_192_TO_223 - kInventoryGraphicIndice = 17 // @ C017_GRAPHIC_INVENTORY + kInventoryGraphicIndice = 17, // @ C017_GRAPHIC_INVENTORY + kPanelEmptyIndice = 20, // @ C020_GRAPHIC_PANEL_EMPTY + kFoodLabelIndice = 30, // @ C030_GRAPHIC_FOOD_LABEL + kWaterLabelIndice = 31, // @ C031_GRAPHIC_WATER_LABEL + kPoisionedLabelIndice = 32 // @ C032_GRAPHIC_POISONED_LABEL }; extern uint16 gPalSwoosh[16]; diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 98713d01ce..68ebd616ed 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -110,7 +110,7 @@ void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Co void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) { if (amount < -512) { color = kColorRed; - } else if(amount < 0) { + } else if (amount < 0) { color = kColorYellow; } @@ -123,4 +123,18 @@ void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) { drawPanelHorizontalBar(113, y, pixelWidth, color); } +void InventoryMan::drawPanelFoodWaterPoisoned() { + Champion &champ = _vm->_championMan->_champions[_inventoryChampionOrdinal]; + warning("MISSING CODE: F0334_INVENTORY_CloseChest"); + DisplayMan &dispMan = *_vm->_displayMan; + dispMan.blitToScreen(dispMan.getBitmap(kPanelEmptyIndice), 144, 0, 0, gBoxPanel, kColorRed); + dispMan.blitToScreen(dispMan.getBitmap(kFoodLabelIndice), 48, 0, 0, gBoxFood, kColorDarkestGray); + dispMan.blitToScreen(dispMan.getBitmap(kWaterLabelIndice), 48, 0, 0, gBoxWater, kColorDarkestGray); + if (champ._poisonEventCount) { + dispMan.blitToScreen(dispMan.getBitmap(kPoisionedLabelIndice), 96, 0, 0, gBoxPoisoned, kColorDarkestGray); + } + drawPanelFoodOrWaterBar(champ._food, 69, kColorLightBrown); + drawPanelFoodOrWaterBar(champ._water, 92, kColorBlue); +} + } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index bd6f18d788..5fb3f7560f 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -17,6 +17,7 @@ public: void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait void drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar void drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color); // @ F0344_INVENTORY_DrawPanel_FoodOrWaterBar + void drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned }; } \ No newline at end of file -- cgit v1.2.3 From b8c35406acefb716117fca0cf1f2564cc1786d5a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 21 Jun 2016 07:21:49 +0200 Subject: DM: Some renaming --- engines/dm/champion.cpp | 52 ++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 898975de65..3dfc2e3b84 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -275,41 +275,41 @@ T0280048: void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { - Champion *AL_6_champion = &_champions[champIndex]; - int16 AL_2_barGraphIndex = 0; + Champion *curChampion = &_champions[champIndex]; + int16 barGraphIndex = 0; int16 barGraphHeightArray[3]; - if (AL_6_champion->_currHealth > 0) { - uint32 AL_4_barGraphHeight = (((uint32)(AL_6_champion->_currHealth) << 10) * 25) / AL_6_champion->_maxHealth; - if (AL_4_barGraphHeight & 0x3FF) { - barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10) + 1; + if (curChampion->_currHealth > 0) { + uint32 barGraphHeight = (((uint32)(curChampion->_currHealth) << 10) * 25) / curChampion->_maxHealth; + if (barGraphHeight & 0x3FF) { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; } else { - barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10); + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); } } else { - barGraphHeightArray[AL_2_barGraphIndex++] = 0; + barGraphHeightArray[barGraphIndex++] = 0; } - if (AL_6_champion->_currStamina > 0) { - uint32 AL_4_barGraphHeight = (((uint32)(AL_6_champion->_currStamina) << 10) * 25) / AL_6_champion->_maxStamina; - if (AL_4_barGraphHeight & 0x3FF) { - barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10) + 1; + if (curChampion->_currStamina > 0) { + uint32 barGraphHeight = (((uint32)(curChampion->_currStamina) << 10) * 25) / curChampion->_maxStamina; + if (barGraphHeight & 0x3FF) { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; } else { - barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10); + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); } } else { - barGraphHeightArray[AL_2_barGraphIndex++] = 0; + barGraphHeightArray[barGraphIndex++] = 0; } - if (AL_6_champion->_currMana > 0) { - uint32 AL_4_barGraphHeight = (((uint32)(AL_6_champion->_currMana) << 10) * 25) / AL_6_champion->_maxMana; - if (AL_4_barGraphHeight & 0x3FF) { - barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10) + 1; + if (curChampion->_currMana > 0) { + uint32 barGraphHeight = (((uint32)(curChampion->_currMana) << 10) * 25) / curChampion->_maxMana; + if (barGraphHeight & 0x3FF) { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; } else { - barGraphHeightArray[AL_2_barGraphIndex++] = (AL_4_barGraphHeight >> 10); + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); } } else { - barGraphHeightArray[AL_2_barGraphIndex++] = 0; + barGraphHeightArray[barGraphIndex++] = 0; } warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); @@ -320,14 +320,14 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { box._y2 = 26; for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) { - int16 AL_2_barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex]; - if (AL_2_barGraphHeight < 25) { + int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex]; + if (barGraphHeight < 25) { box._y1 = 2; - box._y1 = 27 - AL_2_barGraphHeight; + box._y1 = 27 - barGraphHeight; _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); } - if (AL_2_barGraphHeight) { - box._y1 = 27 - AL_2_barGraphHeight; + if (barGraphHeight) { + box._y1 = 27 - barGraphHeight; box._y2 = 26; _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); } @@ -342,7 +342,7 @@ uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) { int16 currStamina = champ->_currStamina; int16 halfMaxStamina = champ->_maxStamina / 2; if (currStamina < halfMaxStamina) { - warning("Possible undefined behaviour in the original code"); + warning("Possible undefined behavior in the original code"); val /= 2; return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina; } -- cgit v1.2.3 From e59be236e11f13fd8c257a0fc72594f00a9dff63 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 21 Jun 2016 07:58:54 +0200 Subject: DM: Move junkInfo to getObjectWeight, make it static and const. --- engines/dm/dungeonman.cpp | 82 +++++++++++++++-------------------------------- engines/dm/dungeonman.h | 3 -- 2 files changed, 26 insertions(+), 59 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index d9554f29da..bbf0c7ddd1 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -189,61 +189,6 @@ ObjectInfo gObjectInfo[180] = { // @ G0237_as_Graphic559_ObjectInfo ObjectInfo(197, 74, 0, 0x0000), /* SOLID KEY */ ObjectInfo(198, 41, 0, 0x0400)}; /* SQUARE KEY Chest */ -uint16 gJunkInfo[53] = { // @ G0241_auc_Graphic559_JunkInfo - 1, /* COMPASS */ - 3, /* WATERSKIN */ - 2, /* JEWEL SYMAL */ - 2, /* ILLUMULET */ - 4, /* ASHES */ - 15, /* BONES */ - 1, /* COPPER COIN */ - 1, /* SILVER COIN */ - 1, /* GOLD COIN */ - 2, /* IRON KEY */ - 1, /* KEY OF B */ - 1, /* SOLID KEY */ - 1, /* SQUARE KEY */ - 1, /* TOURQUOISE KEY */ - 1, /* CROSS KEY */ - 1, /* ONYX KEY */ - 1, /* SKELETON KEY */ - 1, /* GOLD KEY */ - 1, /* WINGED KEY */ - 1, /* TOPAZ KEY */ - 1, /* SAPPHIRE KEY */ - 1, /* EMERALD KEY */ - 1, /* RUBY KEY */ - 1, /* RA KEY */ - 1, /* MASTER KEY */ - 81, /* BOULDER */ - 2, /* BLUE GEM */ - 3, /* ORANGE GEM */ - 2, /* GREEN GEM */ - 4, /* APPLE */ - 4, /* CORN */ - 3, /* BREAD */ - 8, /* CHEESE */ - 5, /* SCREAMER SLICE */ - 11, /* WORM ROUND */ - 4, /* DRUMSTICK */ - 6, /* DRAGON STEAK */ - 2, /* GEM OF AGES */ - 3, /* EKKHARD CROSS */ - 2, /* MOONSTONE */ - 2, /* THE HELLION */ - 2, /* PENDANT FERAL */ - 6, /* MAGICAL BOX */ - 9, /* MAGICAL BOX */ - 3, /* MIRROR OF DAWN */ - 10, /* ROPE */ - 1, /* RABBIT'S FOOT */ - 0, /* CORBAMITE */ - 1, /* CHOKER */ - 1, /* LOCK PICKS */ - 2, /* MAGNIFIER */ - 0, /* ZOKATHRA SPELL */ - 8}; /* BONES */ - ArmourInfo gArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo /* { Weight, Defense, Attributes, Unreferenced } */ ArmourInfo(3, 5, 0x01), /* CAPE */ @@ -1176,6 +1121,31 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { uint16 DungeonMan::getObjectWeight(Thing thing) { + static const uint16 junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo + // COMPASS - WATERSKIN - JEWEL SYMAL - ILLUMULET - ASHES + 1, 3, 2, 2, 4, + // BONES - COPPER COIN - SILVER COIN - GOLD COIN - IRON KEY + 15, 1, 1, 1, 2, + // KEY OF B - SOLID KEY - SQUARE KEY - TOURQUOISE KEY - CROSS KEY + 1, 1, 1, 1, 1, + // ONYX KEY - SKELETON KEY - GOLD KEY - WINGED KEY - TOPAZ KEY + 1, 1, 1, 1, 1, + // SAPPHIRE KEY - EMERALD KEY - RUBY KEY - RA KEY - MASTER KEY + 1, 1, 1, 1, 1, + // BOULDER - BLUE GEM - ORANGE GEM - GREEN GEM - APPLE + 81, 2, 3, 2, 4, + // CORN - BREAD - CHEESE - SCREAMER SLICE - WORM ROUND + 4, 3, 8, 5, 11, + // DRUMSTICK - DRAGON STEAK - GEM OF AGES - EKKHARD CROSS - MOONSTONE + 4, 6, 2, 3, 2, + // THE HELLION - PENDANT FERAL - MAGICAL BOX - MAGICAL BOX - MIRROR OF DAWN + 2, 2, 6, 9, 3, + // ROPE - RABBIT'S FOOT - CORBAMITE - CHOKER - LOCK PICKS + 10, 1, 0, 1, 1, + // MAGNIFIER - ZOKATHRA SPELL - BONES + 2, 0, 8 + }; + if (thing == Thing::_thingNone) return 0; switch (thing.getType()) { @@ -1185,7 +1155,7 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { return gArmourInfo[Armour(getThingData(thing)).getType()]._weight; case kJunkThingType: { Junk junk = getThingData(thing); - uint16 weight = gJunkInfo[junk.getType()]; + uint16 weight = junkInfo[junk.getType()]; if (junk.getType() == kJunkTypeWaterskin) weight += junk.getChargeCount() * 2; return weight; diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 3dc3ab4176..9ab79512c7 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -44,8 +44,6 @@ public: }; // @ OBJECT_INFO extern ObjectInfo gObjectInfo[180]; - -extern uint16 gJunkInfo[53]; enum ArmourAttribute { kArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD @@ -572,7 +570,6 @@ class DungeonMan { void setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals - void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap public: -- cgit v1.2.3 From 038056ed0f29af6146be45462a2f581a2293e946 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 21 Jun 2016 14:55:57 +0200 Subject: DM: Add G0423_i_InventoryChampionOrdinal and related enum, PanelContent --- engines/dm/gfx.h | 3 ++- engines/dm/inventory.cpp | 9 ++++++++- engines/dm/inventory.h | 13 +++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 023535f704..07dabce88a 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -32,7 +32,8 @@ enum GraphicIndice { kPanelEmptyIndice = 20, // @ C020_GRAPHIC_PANEL_EMPTY kFoodLabelIndice = 30, // @ C030_GRAPHIC_FOOD_LABEL kWaterLabelIndice = 31, // @ C031_GRAPHIC_WATER_LABEL - kPoisionedLabelIndice = 32 // @ C032_GRAPHIC_POISONED_LABEL + kPoisionedLabelIndice = 32, // @ C032_GRAPHIC_POISONED_LABEL + kPanelResurectReincaranteIndice // @ C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE }; extern uint16 gPalSwoosh[16]; diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 68ebd616ed..e4887100d4 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -14,7 +14,9 @@ Box gBoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food Box gBoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water Box gBoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned -InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {} +InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) { + _panelContent = kPanelContentFoodWaterPoisoned; +} void InventoryMan::toggleInventory(ChampionIndex championIndex) { ChampionMan &cm = *_vm->_championMan; @@ -137,4 +139,9 @@ void InventoryMan::drawPanelFoodWaterPoisoned() { drawPanelFoodOrWaterBar(champ._water, 92, kColorBlue); } +void InventoryMan::drawPanelResurrectReincarnate() { + _panelContent = kPanelContentResurrectReincarnate; + _vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(kPanelResurectReincaranteIndice), 144, 0, 0, gBoxPanel, kColorDarkGreen, gDungeonViewport); +} + } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 5fb3f7560f..b6b23c4109 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -8,16 +8,29 @@ namespace DM { #define kChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING + +enum PanelContent { + kPanelContentFoodWaterPoisoned = 0, // @ C00_PANEL_FOOD_WATER_POISONED + kPanelContentScroll = 2, // @ C02_PANEL_SCROLL + kPanelContentChest = 4, // @ C04_PANEL_CHEST + kPanelContentResurrectReincarnate = 5 // @ C05_PANEL_RESURRECT_REINCARNATE +}; + + + class InventoryMan { DMEngine *_vm; public: int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal + PanelContent _panelContent; // @ G0424_i_PanelContent InventoryMan(DMEngine *vm); void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait void drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar void drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color); // @ F0344_INVENTORY_DrawPanel_FoodOrWaterBar void drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned + void drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate + }; } \ No newline at end of file -- cgit v1.2.3 From 2c669d4119c2e218010c7d1d2eca0b81be58a99b Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 21 Jun 2016 15:09:24 +0200 Subject: DM: Add F0347_INVENTORY_DrawPanel --- engines/dm/inventory.cpp | 29 +++++++++++++++++++++++++++++ engines/dm/inventory.h | 1 + 2 files changed, 30 insertions(+) diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index e4887100d4..db3472051d 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -144,4 +144,33 @@ void InventoryMan::drawPanelResurrectReincarnate() { _vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(kPanelResurectReincaranteIndice), 144, 0, 0, gBoxPanel, kColorDarkGreen, gDungeonViewport); } +void InventoryMan::drawPanel() { + warning("MISSING CODE: F0334_INVENTORY_CloseChest, altho adding it may reintroduce BUG0_48"); + + ChampionMan &cm = *_vm->_championMan; + if (cm._candidateChampionOrdinal) { + drawPanelResurrectReincarnate(); + return; + } + + Thing thing = cm._champions[ordinalToIndex(_inventoryChampionOrdinal)].getSlot(kChampionSlotActionHand); + + _panelContent = kPanelContentFoodWaterPoisoned; + switch (thing.getType()) { + case kContainerThingType: + _panelContent = kPanelContentChest; + break; + case kScrollThingType: + _panelContent = kPanelContentScroll; + break; + default: + thing = Thing::_thingNone; + break; + } + if (thing == Thing::_thingNone) { + drawPanelFoodWaterPoisoned(); + } else { + warning("MISSING CODE: F0342_INVENTORY_DrawPanel_Object(L1075_T_Thing, C0_FALSE);"); + } +} } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index b6b23c4109..32c3d451ae 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -30,6 +30,7 @@ public: void drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color); // @ F0344_INVENTORY_DrawPanel_FoodOrWaterBar void drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned void drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate + void drawPanel(); // @ F0347_INVENTORY_DrawPanel }; -- cgit v1.2.3 From c986a71beabb7ba8f54a79f3b20735ab6a83e7e0 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 21 Jun 2016 17:45:10 +0200 Subject: DM: Add F0292_CHAMPION_DrawState, G0407_s_Party, M26_CHAMPION_ICON_INDEX, several graphic indices, fix missing kPanelResurectReincaranteIndice value --- engines/dm/champion.cpp | 166 +++++++++++++++++++++++++++++++++++++++++++++++- engines/dm/champion.h | 3 + engines/dm/dm.h | 1 + engines/dm/gfx.h | 15 +++-- 4 files changed, 180 insertions(+), 5 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 3dfc2e3b84..ca5c6acc83 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -364,4 +364,168 @@ uint16 ChampionMan::getMaximumLoad(Champion *champ) { return maximumLoad; } -} \ No newline at end of file +void ChampionMan::drawChampionState(ChampionIndex champIndex) { + InventoryMan &invMan = *_vm->_inventoryMan; + DisplayMan &dispMan = *_vm->_displayMan; + MenuMan &menuMan = *_vm->_menuMan; + EventManager &eventMan = *_vm->_eventMan; + + Box box; + int16 champStatusBoxX = champIndex * kChampionStatusBoxSpacing; + Champion *champ = &_champions[champIndex]; + uint16 champAttributes = champ->getAttributes(); + if (!((champAttributes) & (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon | + kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport | + kChampionAttributeActionHand))) { + return; + } + bool isInventoryChamp = (indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal); + dispMan._useByteBoxCoordinates = false; + if (champAttributes & kChampionAttributeStatusBox) { + box._y1 = 0; + box._y2 = 28; + box._x1 = champStatusBoxX; + box._x2 = box._x1 + 66; + if (champ->_currHealth) { + dispMan.clearScreenBox(kColorDarkestGray, box); + int16 nativeBitmapIndices[3]; + for (int16 i = 0; i < 3; ++i) + nativeBitmapIndices[i] = 0; + int16 AL_0_borderCount = 0; + if (_party._fireShieldDefense > 0) + nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyFireshieldIndice; + if (_party._spellShieldDefense > 0) + nativeBitmapIndices[AL_0_borderCount++] = kBorderPartySpellshieldIndice; + if (_party._shieldDefense > 0) + nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyShieldIndice; + while (AL_0_borderCount--) { + dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, kColorFlesh); + } + if (isInventoryChamp) { + invMan.drawStatusBoxPortrait(champIndex); + champAttributes |= kChampionAttributeStatistics; + } else { + champAttributes |= (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeWounds | kChampionAttributeActionHand); + } + } else { + dispMan.blitToScreen(dispMan.getBitmap(kStatusBoxDeadChampion), 80, 0, 0, box, kColorNoTransparency); + warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen"); + menuMan.drawActionIcon(champIndex); + goto T0292042_green; + } + } + + if (!champ->_currHealth) + goto T0292042_green; + + if(champAttributes & kChampionAttributeNameTitle) { + int16 AL_0_colorIndex = (champIndex == _leaderIndex) ? kColorGold : kColorLightestGray; // unused because of missing functions + if(isInventoryChamp) { + char *champName = champ->_name; + warning("MISSING CODE: F0052_TEXT_PrintToViewport"); + int16 champTitleX = 6 * strlen(champName) + 3; + char champTitleFirstChar = champ->_title[0]; + if ((champTitleFirstChar != ',') && (champTitleFirstChar != ';') && (champTitleFirstChar != '-')) { + champTitleX += 6; + } + warning("MISSING CODE: F0052_TEXT_PrintToViewport"); + champAttributes |= kChampionAttributeViewport; + } else { + box._y1 = 0; + box._y2 = 6; + box._x1 = champStatusBoxX; + box._x2 = box._x1 + 42; + dispMan.clearScreenBox(kColorDarkGary, box); + warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen"); + } + } + + if (champAttributes & kChampionAttributeStatistics) { + drawChampionBarGraphs(champIndex); + if (isInventoryChamp) { + warning("MISSING CODE: F0290_CHAMPION_DrawHealthStaminaManaValues"); + int16 AL_2_nativeBitmapIndex; + if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) { + AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice; + } else { + AL_2_nativeBitmapIndex = kSlotBoxNormalIndice; + } + dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, kColorDarkestGray, gDungeonViewport); + AL_2_nativeBitmapIndex = kSlotBoxNormalIndice; + for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) { + if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent) + < champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum)) { + AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice; + break; + } + } + dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, kColorDarkestGray, gDungeonViewport); + champAttributes |= kChampionAttributeViewport; + } + } + + if (champAttributes & kChampionAttributeWounds) { + for (int16 AL_0_slotIndex = isInventoryChamp ? kChampionSlotFeet : kChampionSlotActionHand; AL_0_slotIndex >= kChampionSlotReadyHand; AL_0_slotIndex--) { + warning("MISSING CODE: F0291_CHAMPION_DrawSlot"); + } + if (isInventoryChamp) { + champAttributes |= kChampionAttributeViewport; + } + } + + if (champAttributes & kChampionAttributeLoad) { + warning("MISSING CODE: whole if branch, many F0052_TEXT_PrintToViewport-s"); + + + + champAttributes |= kChampionAttributeViewport; + } + + { // block so goto won't skip AL_0_championIconIndex initialization + int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir); + + if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != indexToOrdinal(AL_0_championIconIndex))) { + dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]); + dispMan.blitToScreen(dispMan.getBitmap(kChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0, + gBoxChampionIcons[AL_0_championIconIndex], kColorDarkestGray); + } + } + + if ((champAttributes & kChampionAttributePanel) && isInventoryChamp) { + if (_vm->_pressingMouth) { + invMan.drawPanelFoodWaterPoisoned(); + } else if (_vm->_pressingEye) { + if (_leaderEmptyHanded) { + warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics"); + } + } else { + invMan.drawPanel(); + } + champAttributes |= kChampionAttributeViewport; + } + + if (champAttributes & kChampionAttributeActionHand) { + warning("MISSING CODE: F0291_CHAMPION_DrawSlot"); + menuMan.drawActionIcon(champIndex); + if (isInventoryChamp) { + champAttributes |= kChampionAttributeViewport; + } + } + + if (champAttributes & kChampionAttributeViewport) { + warning("MISSGIN CODE: F0097_DUNGEONVIEW_DrawViewport"); + } + + +T0292042_green: + champ->setAttributeFlag((ChampionAttribute)(kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon | + kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport | + kChampionAttributeActionHand), false); + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); +} + + uint16 ChampionMan::championIconIndex(int16 val, direction dir) + { + return ((val + 4 - dir) & 0x3); + } +} diff --git a/engines/dm/champion.h b/engines/dm/champion.h index db554120f2..f8ea79c82f 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -401,6 +401,7 @@ public: uint16 _actingChampionOrdinal; // @ G0506_ui_ActingChampionOrdinal IconIndice _leaderHandObjectIconIndex; // @ G0413_i_LeaderHandObjectIconIndex bool _leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded + Party _party; // @ G0407_s_Party ChampionMan(DMEngine *vm); void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame @@ -408,6 +409,8 @@ public: void drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs uint16 getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue uint16 getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad + void drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState + uint16 championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX }; diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 0b69aff89e..2a718ce868 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -35,6 +35,7 @@ void turnDirLeft(direction &dir); direction returnOppositeDir(direction dir); bool isOrientedWestEast(direction dir); + enum ThingType { kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value kDoorThingType = 0, diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 07dabce88a..0c92214a0f 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -33,7 +33,14 @@ enum GraphicIndice { kFoodLabelIndice = 30, // @ C030_GRAPHIC_FOOD_LABEL kWaterLabelIndice = 31, // @ C031_GRAPHIC_WATER_LABEL kPoisionedLabelIndice = 32, // @ C032_GRAPHIC_POISONED_LABEL - kPanelResurectReincaranteIndice // @ C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE + kPanelResurectReincaranteIndice = 40, // @ C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE + kBorderPartyShieldIndice = 37, // @ C037_GRAPHIC_BORDER_PARTY_SHIELD + kBorderPartyFireshieldIndice = 38, // @ C038_GRAPHIC_BORDER_PARTY_FIRESHIELD + kBorderPartySpellshieldIndice = 39, // @ C039_GRAPHIC_BORDER_PARTY_SPELLSHIELD + kStatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION + kSlotBoxNormalIndice = 33, // @ C033_GRAPHIC_SLOT_BOX_NORMAL + kSlotBoxWoundedIndice = 34, // @ C034_GRAPHIC_SLOT_BOX_WOUNDED + kChampionIcons = 28 // @ C028_GRAPHIC_CHAMPION_ICONS }; extern uint16 gPalSwoosh[16]; @@ -49,7 +56,7 @@ public: uint16 _y1; uint16 _y2; - Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): _x1(x1), _x2(x2 + 1), _y1(y1), _y2(y2 + 1) {} + Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2) : _x1(x1), _x2(x2 + 1), _y1(y1), _y2(y2 + 1) {} Box() {} bool isPointInside(Common::Point point) { return (_x1 <= point.x) && (point.x < _x2) && (_y1 <= point.y) && (point.y < _y2); @@ -66,8 +73,8 @@ struct Frame { Frame() {} Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) : - _destFromX(destFromX), _destToX(destToX + 1), _destFromY(destFromY), _destToY(destToY + 1), + uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) : + _destFromX(destFromX), _destToX(destToX + 1), _destFromY(destFromY), _destToY(destToY + 1), _srcWidth(srcWidth * 2), _srcHeight(srcHeight), _srcX(srcX), _srcY(srcY) {} }; -- cgit v1.2.3 From afd844b6de922f27e22a66e075c273dc7a586ac0 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:24:42 +0200 Subject: DM: Add missing F0292_CHAMPION_DrawState functions, fix error in toggleInventory --- engines/dm/eventman.cpp | 16 ++++++++-------- engines/dm/inventory.cpp | 6 +++--- engines/dm/menus.cpp | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index a7a330366d..b7caa60668 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -435,11 +435,11 @@ void EventManager::commandMoveParty(CommandType cmdType) { // MISSING CODE: Lots of code } -void EventManager::commandSetLeader(ChampionIndex index) { +void EventManager::commandSetLeader(ChampionIndex champIndex) { ChampionMan &cm = *_vm->_championMan; ChampionIndex leaderIndex; - if ((cm._leaderIndex == index) || ((index != kChampionNone) && !cm._champions[index]._currHealth)) + if ((cm._leaderIndex == champIndex) || ((champIndex != kChampionNone) && !cm._champions[champIndex]._currHealth)) return; if (cm._leaderIndex != kChampionNone) { @@ -448,20 +448,20 @@ void EventManager::commandSetLeader(ChampionIndex index) { cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeNameTitle, true); cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHand); cm._leaderIndex = kChampionNone; - warning("MISSING CODE: F0292_CHAMPION_DrawState"); + cm.drawChampionState(leaderIndex); } - if (index == kChampionNone) { + if (champIndex == kChampionNone) { cm._leaderIndex = kChampionNone; return; } - cm._leaderIndex = index; + cm._leaderIndex = champIndex; Champion *champion = &cm._champions[cm._leaderIndex]; champion->_dir = _vm->_dungeonMan->_currMap._partyDir; - cm._champions[index]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHand); - if (indexToOrdinal(index) != cm._candidateChampionOrdinal) { + cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHand); + if (indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) { champion->setAttributeFlag(kChampionAttributeIcon, true); champion->setAttributeFlag(kChampionAttributeNameTitle, true); - warning("MISSING CODE: F0292_CHAMPION_DrawState"); + cm.drawChampionState(champIndex); } } diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index db3472051d..b0cc9f0281 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -37,10 +37,10 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { if (invChampOrdinal) { _inventoryChampionOrdinal = indexToOrdinal(kChampionNone); warning("MISSING CODE: F0334_INVENTORY_CloseChest"); - champion = &cm._champions[ordinalToIndex(_inventoryChampionOrdinal)]; + champion = &cm._champions[ordinalToIndex(invChampOrdinal)]; if (champion->_currHealth && !cm._candidateChampionOrdinal) { champion->setAttributeFlag(kChampionAttributeStatusBox, true); - warning("MISSING CODE: F0292_CHAMPION_DrawState"); + cm.drawChampionState((ChampionIndex)ordinalToIndex(invChampOrdinal)); } if (cm._partyIsSleeping) { return; @@ -81,7 +81,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { champion->setAttributeFlag(kChampionAttributeStatistics, true); champion->setAttributeFlag(kChampionAttributeNameTitle, true); - warning("MISSING CODE: F0292_CHAMPION_DrawState"); + cm.drawChampionState(championIndex); em._mousePointerBitmapUpdated = true; em._secondaryMouseInput = gSecondaryMouseInput_ChampionInventory; warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput"); diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index d39aa22a1a..f641e02ede 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -25,7 +25,7 @@ void MenuMan::clearActingChampion() { if (cm._actingChampionOrdinal) { cm._actingChampionOrdinal--; cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true); - warning("MISSING CODE: F0292_CHAMPION_DrawState"); + cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal); cm._actingChampionOrdinal = indexToOrdinal(kChampionNone); _shouldRefreshActionArea = true; } @@ -88,4 +88,4 @@ void MenuMan::drawDisabledMenu() { } } -} \ No newline at end of file +} -- cgit v1.2.3 From 4b83ebc0da2a2bb46c2435ddfe96c333b7cbd8ed Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 21 Jun 2016 20:27:57 +0200 Subject: DM: Add fix gDungeonViewport, some comments --- engines/dm/dm.cpp | 2 ++ engines/dm/gfx.cpp | 2 +- engines/dm/menus.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index c1d7e14c0d..3a1a951c2b 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -171,6 +171,7 @@ void DMEngine::gameloop() { warning("DUMMY CODE: setting InventoryMan::_inventoryChampionOrdinal to zero"); _inventoryMan->_inventoryChampionOrdinal = 0; + warning("DUMMY CODE: clearing screen to black"); while (true) { _stopWaitingForPlayerInput = false; //do { @@ -179,6 +180,7 @@ void DMEngine::gameloop() { //} while (!_stopWaitingForPlayerInput || !_gameTimeTicking); if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) { + _displayMan->clearScreen(kColorBlack); // dummy code _displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY); } // DUMMY CODE: next line diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 28fb63cac6..6ddff20398 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -548,7 +548,7 @@ byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, Viewport gDefultViewPort = {0, 0}; // TODO: I guessed the numbers -Viewport gDungeonViewport = {0, 64}; // @ G0296_puc_Bitmap_Viewport +Viewport gDungeonViewport = {0, 33}; // @ G0296_puc_Bitmap_Viewport byte gPalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges diff --git a/engines/dm/menus.h b/engines/dm/menus.h index 52b99ab771..de0c43ac74 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -15,7 +15,7 @@ public: void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon - void drawMovementArrows(); + void drawMovementArrows(); // @ F0395_MENUS_DrawMovementArrows void drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus }; -- cgit v1.2.3 From 485d5f94de671aa28017edca2c4725fc09c796c4 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 21 Jun 2016 20:32:08 +0200 Subject: DM: Fix box coordinates in drawChampionState --- engines/dm/champion.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index ca5c6acc83..d41429e817 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -383,9 +383,9 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { dispMan._useByteBoxCoordinates = false; if (champAttributes & kChampionAttributeStatusBox) { box._y1 = 0; - box._y2 = 28; + box._y2 = 28 + 1; box._x1 = champStatusBoxX; - box._x2 = box._x1 + 66; + box._x2 = box._x1 + 66 + 1; if (champ->_currHealth) { dispMan.clearScreenBox(kColorDarkestGray, box); int16 nativeBitmapIndices[3]; @@ -432,9 +432,9 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { champAttributes |= kChampionAttributeViewport; } else { box._y1 = 0; - box._y2 = 6; + box._y2 = 6 + 1; box._x1 = champStatusBoxX; - box._x2 = box._x1 + 42; + box._x2 = box._x1 + 42 + 1; dispMan.clearScreenBox(kColorDarkGary, box); warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen"); } -- cgit v1.2.3 From 1639c2e887ae8bee4d43bddb84440b8639ce4efb Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 21 Jun 2016 20:39:49 +0200 Subject: DM: Fix several inclusive boundary errors with Box types --- engines/dm/champion.cpp | 8 ++++---- engines/dm/inventory.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index d41429e817..693fb50ace 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -315,20 +315,20 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { Box box; box._x1 = champIndex * kChampionStatusBoxSpacing + 46; - box._x2 = box._x1 + 3; + box._x2 = box._x1 + 3 + 1; box._y1 = 2; - box._y2 = 26; + box._y2 = 26 + 1; for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) { int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex]; if (barGraphHeight < 25) { box._y1 = 2; - box._y1 = 27 - barGraphHeight; + box._y1 = 27 - barGraphHeight + 1; _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); } if (barGraphHeight) { box._y1 = 27 - barGraphHeight; - box._y2 = 26; + box._y2 = 26 + 1; _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); } box._x1 += 7; diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index b0cc9f0281..a67d308e68 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -102,9 +102,9 @@ void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) { void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) { Box box; box._x1 = x; - box._x2 = box._x1 + pixelWidth; + box._x2 = box._x1 + pixelWidth + 1; box._y1 = y; - box._y2 = box._y1 + 6; + box._y2 = box._y1 + 6 + 1; _vm->_displayMan->_useByteBoxCoordinates = false; _vm->_displayMan->clearScreenBox(color, box); } -- cgit v1.2.3 From 3a2677eecfd5123fc186f056518f5ec242873a59 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 21 Jun 2016 20:53:24 +0200 Subject: DM: Add missing code setting champion mana in ChampionMan::addCandidateChampionToParty --- engines/dm/champion.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 693fb50ace..71e285ed1c 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -168,6 +168,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { character_Green += 4; champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4); character_Green += 4; + champ->_currMana = champ->_maxMana = getDecodedValue(character_Green, 4); + character_Green += 4; character_Green++; int16 AL_0_statisticIndex; -- cgit v1.2.3 From 0f04a0902b9b5dc3b83dc506a2155f679feeac0c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 22 Jun 2016 00:00:03 +0200 Subject: DM: Fix some GCC warnings --- engines/dm/dungeonman.h | 6 +++--- engines/dm/gfx.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 9ab79512c7..7f6e9666ba 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -47,7 +47,7 @@ extern ObjectInfo gObjectInfo[180]; enum ArmourAttribute { kArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD - kArmourAttributeSharpDefense = 0x0007, // @ MASK0x0007_SHARP_DEFENSE + kArmourAttributeSharpDefense = 0x0007 // @ MASK0x0007_SHARP_DEFENSE }; class ArmourInfo { @@ -476,9 +476,9 @@ public: Square &set(SquareMask mask) { _data |= mask; return *this; } byte get(SquareMask mask) { return _data & mask; } byte getDoorState() { return _data & 0x7; } // @ M36_DOOR_STATE - Square &setDoorState(byte state) { _data = ((_data & ~0x7) | state); } // @ M37_SET_DOOR_STATE + void setDoorState(byte state) { _data = ((_data & ~0x7) | state); } // @ M37_SET_DOOR_STATE SquareType getType() { return (SquareType)(_data >> 5); } // @ M34_SQUARE_TYPE - Square &setType(SquareType type) { _data = (_data & 0x1F) | type << 5; return *this; } + void setType(SquareType type) { _data = (_data & 0x1F) | type << 5; } byte toByte() { return _data; } // I don't like 'em casts }; diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 0c92214a0f..87d6bda69f 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -13,7 +13,7 @@ enum ViewCell { kViewCellBackRight = 2, // @ C02_VIEW_CELL_BACK_RIGHT kViewCellBackLeft = 3, // @ C03_VIEW_CELL_BACK_LEFT kViewCellAlcove = 4, // @ C04_VIEW_CELL_ALCOVE - kViewCellDoorButtonOrWallOrn = 5, // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT + kViewCellDoorButtonOrWallOrn = 5 // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT }; enum GraphicIndice { -- cgit v1.2.3 From b97535ef698f3fda7dac27ee39499d67aed1418c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 22 Jun 2016 00:16:21 +0200 Subject: DM: Fix some more GCC warnings --- engines/dm/champion.h | 6 +++--- engines/dm/inventory.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index f8ea79c82f..2428308c3e 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -15,9 +15,9 @@ public: uint16 getMapY() { return (_scent >> 5) & 0x1F; } uint16 getMapIndex() { return (_scent >> 10) & 0x3F; } - uint16 setMapX(uint16 val) { _scent = (_scent & ~0x1F) & (val & 0x1F); } - uint16 setMapY(uint16 val) { _scent = (_scent & ~(0x1F << 5)) & (val & 0x1F); } - uint16 setMapIndex(uint16 val) { _scent = (_scent & ~(0x1F << 10)) & (val & 0x3F); } + void setMapX(uint16 val) { _scent = (_scent & ~0x1F) & (val & 0x1F); } + void setMapY(uint16 val) { _scent = (_scent & ~(0x1F << 5)) & (val & 0x1F); } + void setMapIndex(uint16 val) { _scent = (_scent & ~(0x1F << 10)) & (val & 0x3F); } }; // @ SCENT class Party { diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 32c3d451ae..aa75dc0d6d 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -34,4 +34,4 @@ public: }; -} \ No newline at end of file +} -- cgit v1.2.3 From f1ef774a285844edd3a01c7d21e41e957a175ba8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 22 Jun 2016 00:24:34 +0200 Subject: DM: Fix another GCC warning and a bug --- engines/dm/gfx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 6ddff20398..8027425fa5 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -163,7 +163,7 @@ enum WallSetIndices { kWall_D0L_Native = 21, kWall_D1LCR_Native = 22, kWall_D2LCR_Native = 23, - kWall_D3LCR_Native = 24, + kWall_D3LCR_Native = 24 }; @@ -916,7 +916,7 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) { } break; case kStairsSideElemType: - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D2L, gFrameWalls[kFrameStairsSide_D2L]); + drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2L]); break; } } -- cgit v1.2.3 From f46a588164f7a49767ed75cd108d16cfc6cf7410 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 22 Jun 2016 00:37:58 +0200 Subject: DM: Silent two more GCC warnings --- engines/dm/gfx.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 8027425fa5..1af0a03c0b 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1362,7 +1362,8 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex uint16 *coordinateSetA = gWallOrnCoordSets[_currMapWallOrnInfo[wallOrnIndex][kNativeCoordinateSet]][viewWallIndex]; isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnIndex); - if (isInscription = (wallOrnIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex)) { + isInscription = (wallOrnIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex); + if (isInscription) { _vm->_dungeonMan->decodeText((char*)inscriptionString, _inscriptionThing, kTextTypeInscription); } @@ -1416,7 +1417,8 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex coordinateSetOffset = 0; uint16 *coordSetB; int16 wallOrnCoordSetIndex = _currMapWallOrnInfo[wallOrnIndex][kNativeCoordinateSet]; - if (flipHorizontal = (viewWallIndex == kViewWall_D2R_LEFT) || (viewWallIndex == kViewWall_D3R_LEFT)) { + flipHorizontal = (viewWallIndex == kViewWall_D2R_LEFT) || (viewWallIndex == kViewWall_D3R_LEFT); + if (flipHorizontal) { coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1R_LEFT]; } else if ((viewWallIndex == kViewWall_D2L_RIGHT) || (viewWallIndex == kViewWall_D3L_RIGHT)) { coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1L_RIGHT]; -- cgit v1.2.3 From 9538db0b6100b407d3ed1450256ffdc63efef4c2 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 22 Jun 2016 20:32:30 +0200 Subject: Add: TextMan, font loading and basic text display --- engines/dm/dm.cpp | 4 ++++ engines/dm/dm.h | 3 +++ engines/dm/gfx.cpp | 24 ++++++++++++++++++++++-- engines/dm/gfx.h | 6 +++++- engines/dm/text.cpp | 37 +++++++++++++++++++++++++++++++++++++ engines/dm/text.h | 20 ++++++++++++++++++++ 6 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 engines/dm/text.cpp create mode 100644 engines/dm/text.h diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 3a1a951c2b..8d38c5bf85 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -20,6 +20,7 @@ #include "loadsave.h" #include "objectman.h" #include "inventory.h" +#include "text.h" namespace DM { @@ -54,6 +55,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _loadsaveMan = nullptr; _objectMan = nullptr; _inventoryMan = nullptr; + _textMan = nullptr; _stopWaitingForPlayerInput = false; _gameTimeTicking = false; @@ -74,6 +76,7 @@ DMEngine::~DMEngine() { delete _loadsaveMan; delete _objectMan; delete _inventoryMan; + delete _textMan; // clear debug channels DebugMan.clearAllDebugChannels(); @@ -151,6 +154,7 @@ Common::Error DMEngine::run() { _loadsaveMan = new LoadsaveMan(this); _objectMan = new ObjectMan(this); _inventoryMan = new InventoryMan(this); + _textMan = new TextMan(this); _displayMan->setUpScreens(320, 200); initializeGame(); // @ F0463_START_InitializeGame_CPSADEF diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 2a718ce868..f2d14c9422 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -17,6 +17,7 @@ class ChampionMan; class LoadsaveMan; class ObjectMan; class InventoryMan; +class TextMan; enum direction { @@ -104,6 +105,8 @@ public: LoadsaveMan *_loadsaveMan; ObjectMan *_objectMan; InventoryMan *_inventoryMan; + TextMan *_textMan; + bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput bool _gameTimeTicking; // @ G0301_B_GameTimeTicking bool _restartGameAllowed; // @ G0524_B_RestartGameAllowed diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 1af0a03c0b..ab0f9f114e 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -685,12 +685,13 @@ void DisplayMan::unpackGraphics() { unpackedBitmapsSize += getWidth(i) * getHeight(i); for (uint16 i = 22; i <= 532; ++i) unpackedBitmapsSize += getWidth(i) * getHeight(i); + unpackedBitmapsSize += (5 + 1) * (6 + 1) * 128; // 5 x 6 characters, 128 of them, +1 for convenience padding // graphics items go from 0-20 and 22-532 inclusive, _unpackedItemPos 21 and 22 are there for indexing convenience if (_bitmaps) { delete[] _bitmaps[0]; delete[] _bitmaps; } - _bitmaps = new byte*[533]; + _bitmaps = new byte*[575]; // largest graphic indice (i think) _bitmaps[0] = new byte[unpackedBitmapsSize]; loadIntoBitmap(0, _bitmaps[0]); for (uint16 i = 1; i <= 20; ++i) { @@ -698,10 +699,29 @@ void DisplayMan::unpackGraphics() { loadIntoBitmap(i, _bitmaps[i]); } _bitmaps[22] = _bitmaps[20] + getWidth(20) * getHeight(20); - for (uint16 i = 23; i < 533; ++i) { + for (uint16 i = 23; i <= 532; ++i) { _bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1); loadIntoBitmap(i, _bitmaps[i]); } + _bitmaps[kFontGraphicIndice] = _bitmaps[532] + getWidth(532) * getHeight(532); + loadFNT1intoBitmap(kFontGraphicIndice, _bitmaps[kFontGraphicIndice]); +} + +void DisplayMan::loadFNT1intoBitmap(uint16 index, byte* destBitmap) +{ + uint8 *data = _packedBitmaps + _packedItemPos[index]; + for (uint16 i = 0; i < 6; i++) { + for (uint16 w = 0; w < 128; ++w) { + *destBitmap++ = kColorBlack; + + uint16 nextByte = *data++; + for (int16 pixel = 4; pixel >= 0; --pixel) { + *destBitmap++ = (nextByte >> pixel) & 0x1; + } + } + } + memset(data, 0, 128); + data += 128; } void DisplayMan::loadPalette(uint16 *palette) { diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 87d6bda69f..38d6630a96 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -40,7 +40,8 @@ enum GraphicIndice { kStatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION kSlotBoxNormalIndice = 33, // @ C033_GRAPHIC_SLOT_BOX_NORMAL kSlotBoxWoundedIndice = 34, // @ C034_GRAPHIC_SLOT_BOX_WOUNDED - kChampionIcons = 28 // @ C028_GRAPHIC_CHAMPION_ICONS + kChampionIcons = 28, // @ C028_GRAPHIC_CHAMPION_ICONS + kFontGraphicIndice = 557 // @ C557_GRAPHIC_FONT }; extern uint16 gPalSwoosh[16]; @@ -221,6 +222,8 @@ extern Viewport gDungeonViewport; #define kDoorOrnThivesEyeMask 16 // @ C16_DOOR_ORNAMENT_THIEVES_EYE_MASK class DisplayMan { + friend class DM::TextMan; + DMEngine *_vm; uint16 _screenWidth; uint16 _screenHeight; @@ -248,6 +251,7 @@ class DisplayMan { // the original function has two position parameters, but they are always set to zero void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap void unpackGraphics(); + void loadFNT1intoBitmap(uint16 index, byte *destBitmap); void drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally void drawFloorPitOrStairsBitmap(StairIndex relIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp new file mode 100644 index 0000000000..116058de35 --- /dev/null +++ b/engines/dm/text.cpp @@ -0,0 +1,37 @@ +#include "text.h" + + +namespace DM { + +TextMan::TextMan(DMEngine* vm) : _vm(vm) {} + +#define kLetterWidth 5 +#define kLetterHeight 6 + +void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, Color textColor, Color bgColor, char* text, uint16 destHeight, Viewport &viewport) { + uint16 textLength = strlen(text); + uint16 nextX = destX; + uint16 nextY = destY; + byte *srcBitmap = _vm->_displayMan->getBitmap(kFontGraphicIndice); + + + for (char *begin = text, *end = text + textLength; begin != end; ++begin) { + // Note: this does no wraps in the middle of words + if (nextX + kLetterWidth + 1 > destPixelWidth || (*begin == '\n')) { + nextX = destX; + nextY += kLetterHeight + 1; + } + if (nextY + kLetterHeight + 1 > destHeight) + break; + uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code + _vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, srcX, 0, destBitmap, destPixelWidth, + nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight + 1, kColorNoTransparency, viewport); + nextX += kLetterWidth + 1; + } +} + +void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, char* text, Viewport &viewport) { + printTextToBitmap(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport); +} + +} diff --git a/engines/dm/text.h b/engines/dm/text.h new file mode 100644 index 0000000000..7f57525012 --- /dev/null +++ b/engines/dm/text.h @@ -0,0 +1,20 @@ +#ifndef DM_TEXT_H +#define DM_TEXT_H + +#include "dm.h" +#include "gfx.h" + +namespace DM { + +class TextMan { + DMEngine *_vm; +public: + TextMan(DMEngine *vm); + void printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, + Color textColor, Color bgColor, char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print + void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, char *text, Viewport &viewport = gDefultViewPort); +}; + +} + +#endif -- cgit v1.2.3 From 45419f971a0d12ebec0e3f5b7c02312edfb6d75f Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 22 Jun 2016 20:49:19 +0200 Subject: DM: Add color setting to TextMan::printTextToBitmap --- engines/dm/text.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index 116058de35..d6d005fed4 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -14,6 +14,12 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 uint16 nextY = destY; byte *srcBitmap = _vm->_displayMan->getBitmap(kFontGraphicIndice); + byte *tmp = _vm->_displayMan->_tmpBitmap; + for (uint16 i = 0; i < (kLetterWidth + 1) * (kLetterHeight + 1) * 128; ++i) { + tmp[i] = srcBitmap[i] ? textColor : bgColor; + } + srcBitmap = tmp; + for (char *begin = text, *end = text + textLength; begin != end; ++begin) { // Note: this does no wraps in the middle of words -- cgit v1.2.3 From 63d06a40118716a0869b9d031567e83c2398e890 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 22 Jun 2016 07:35:14 +0200 Subject: DM: Fix code formatting --- engines/dm/champion.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 71e285ed1c..8a79271ada 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -526,8 +526,8 @@ T0292042_green: warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } - uint16 ChampionMan::championIconIndex(int16 val, direction dir) - { - return ((val + 4 - dir) & 0x3); - } +uint16 ChampionMan::championIconIndex(int16 val, direction dir) { + return ((val + 4 - dir) & 0x3); +} + } -- cgit v1.2.3 From 75f9721e1df0e9675ac330087fac28999382d096 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 22 Jun 2016 07:47:41 +0200 Subject: DM: Silent some CppCheck warnings --- engines/dm/champion.h | 4 ++-- engines/dm/dm.h | 6 +++--- engines/dm/dungeonman.h | 32 ++++++++++++++++---------------- engines/dm/eventman.h | 4 +++- engines/dm/gfx.h | 2 +- engines/dm/inventory.h | 4 +++- engines/dm/loadsave.h | 4 +--- engines/dm/menus.h | 4 +++- engines/dm/objectman.h | 3 ++- 9 files changed, 34 insertions(+), 29 deletions(-) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 2428308c3e..4e9e29d9c7 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -9,7 +9,7 @@ namespace DM { class Scent { uint16 _scent; public: - Scent(uint16 scent = 0): _scent(scent) {} + explicit Scent(uint16 scent = 0): _scent(scent) {} uint16 getMapX() { return _scent & 0x1F; } uint16 getMapY() { return (_scent >> 5) & 0x1F; } @@ -403,7 +403,7 @@ public: bool _leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded Party _party; // @ G0407_s_Party - ChampionMan(DMEngine *vm); + explicit ChampionMan(DMEngine *vm); void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame void addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty void drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs diff --git a/engines/dm/dm.h b/engines/dm/dm.h index f2d14c9422..61583a39c1 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -62,7 +62,7 @@ public: static const Thing _thingEndOfList; Thing() : _data(0) {} - Thing(uint16 d) { set(d); } + explicit Thing(uint16 d) { set(d); } void set(uint16 d) { _data = d; @@ -88,7 +88,7 @@ class DMEngine : public Engine { void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF public: - DMEngine(OSystem *syst); + explicit DMEngine(OSystem *syst); ~DMEngine(); virtual Common::Error run(); // @ main @@ -120,7 +120,7 @@ public: class Console : public GUI::Debugger { public: - Console(DMEngine *vm) {} + explicit Console(DMEngine *vm) {} virtual ~Console(void) {} }; diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 7f6e9666ba..c5c356e888 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -157,7 +157,7 @@ class Door { Thing _nextThing; uint16 _attributes; public: - Door(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} + explicit Door(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} Thing getNextThing() { return _nextThing; } bool isMeleeDestructible() { return (_attributes >> 8) & 1; } bool isMagicDestructible() { return (_attributes >> 7) & 1; } @@ -178,7 +178,7 @@ class Teleporter { uint16 _attributes; uint16 _destMapIndex; public: - Teleporter(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]), _destMapIndex(rawDat[2]) {} + explicit Teleporter(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]), _destMapIndex(rawDat[2]) {} Thing getNextThing() { return _nextThing; } bool makesSound() { return (_attributes >> 15) & 1; } TeleporterScope getScope() { return (TeleporterScope)((_attributes >> 13) & 1); } @@ -195,7 +195,7 @@ class TextString { Thing _nextThing; uint16 _textDataRef; public: - TextString(uint16 *rawDat) : _nextThing(rawDat[0]), _textDataRef(rawDat[1]) {} + explicit TextString(uint16 *rawDat) : _nextThing(rawDat[0]), _textDataRef(rawDat[1]) {} Thing getNextThing() { return _nextThing; } uint16 getWordOffset() { return _textDataRef >> 3; } @@ -249,7 +249,7 @@ class Sensor { uint16 _attributes; uint16 _action; public: - Sensor(uint16 *rawDat) : _nextThing(rawDat[0]), _datAndType(rawDat[1]), _attributes(rawDat[2]), _action(rawDat[3]) {} + explicit Sensor(uint16 *rawDat) : _nextThing(rawDat[0]), _datAndType(rawDat[1]), _attributes(rawDat[2]), _action(rawDat[3]) {} Thing getNextThing() { return _nextThing; } SensorType getType() { return (SensorType)(_datAndType & 0x7F); } // @ M39_TYPE @@ -280,7 +280,7 @@ class Group { uint16 _health[4]; uint16 _attributes; public: - Group(uint16 *rawDat) : _nextThing(rawDat[0]), _possessionID(rawDat[1]), _type(rawDat[2]), + explicit Group(uint16 *rawDat) : _nextThing(rawDat[0]), _possessionID(rawDat[1]), _type(rawDat[2]), _position(rawDat[3]), _attributes(rawDat[8]) { _health[0] = rawDat[4]; _health[1] = rawDat[5]; @@ -307,7 +307,7 @@ class Weapon { Thing _nextThing; uint16 _desc; public: - Weapon(uint16 *rawDat) : _nextThing(rawDat[0]), _desc(rawDat[1]) {} + explicit Weapon(uint16 *rawDat) : _nextThing(rawDat[0]), _desc(rawDat[1]) {} WeaponType getType() { return (WeaponType)(_desc & 0x7F); } bool isLit() { return (_desc >> 15) & 1; } @@ -326,7 +326,7 @@ class Armour { Thing _nextThing; uint16 _attributes; public: - Armour(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} + explicit Armour(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} ArmourType getType() { return (ArmourType)(_attributes & 0x7F); } Thing getNextThing() { return _nextThing; } @@ -336,7 +336,7 @@ class Scroll { Thing _nextThing; uint16 _attributes; public: - Scroll(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} + explicit Scroll(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} void set(Thing next, uint16 attribs) { _nextThing = next; _attributes = attribs; @@ -364,7 +364,7 @@ class Potion { Thing _nextThing; uint16 _attributes; public: - Potion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} + explicit Potion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} PotionType getType() { return (PotionType)((_attributes >> 8) & 0x7F); } Thing getNextThing() { return _nextThing; } @@ -375,7 +375,7 @@ class Container { Thing _nextContainedThing; uint16 _type; public: - Container(uint16 *rawDat) : _nextThing(rawDat[0]), _nextContainedThing(rawDat[1]), _type(rawDat[2]) {} + explicit Container(uint16 *rawDat) : _nextThing(rawDat[0]), _nextContainedThing(rawDat[1]), _type(rawDat[2]) {} uint16 getType() { return (_type >> 1) & 0x3; } Thing getNextContainedThing() { return _nextContainedThing; } @@ -399,7 +399,7 @@ class Junk { Thing _nextThing; uint16 _attributes; public: - Junk(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} + explicit Junk(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} JunkType getType() { return (JunkType)(_attributes & 0x7F); } uint16 getChargeCount() { return (_attributes >> 14) & 0x3; } @@ -414,7 +414,7 @@ class Projectile { byte _damageEnergy; uint16 _timerIndex; public: - Projectile(uint16 *rawDat) : _nextThing(rawDat[0]), _object(rawDat[1]), _kineticEnergy(rawDat[2]), + explicit Projectile(uint16 *rawDat) : _nextThing(rawDat[0]), _object(rawDat[1]), _kineticEnergy(rawDat[2]), _damageEnergy(rawDat[3]), _timerIndex(rawDat[4]) {} Thing getNextThing() { return _nextThing; } @@ -424,7 +424,7 @@ class Explosion { Thing _nextThing; uint16 _attributes; public: - Explosion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} + explicit Explosion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} Thing getNextThing() { return _nextThing; } }; // @ EXPLOSION @@ -470,8 +470,8 @@ enum SquareType { class Square { byte _data; public: - Square(byte dat = 0) : _data(dat) {} - Square(SquareType type) { setType(type); } + explicit Square(byte dat = 0) : _data(dat) {} + explicit Square(SquareType type) { setType(type); } Square &set(byte dat) { this->_data = dat; return *this; } Square &set(SquareMask mask) { _data |= mask; return *this; } byte get(SquareMask mask) { return _data & mask; } @@ -573,7 +573,7 @@ class DungeonMan { void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap public: - DungeonMan(DMEngine *dmEngine); + explicit DungeonMan(DMEngine *dmEngine); ~DungeonMan(); Thing getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index f72a985c58..4b62677474 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -197,13 +197,15 @@ class EventManager { void commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty void commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty public: + explicit EventManager(DMEngine *vm); + MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput bool _mousePointerBitmapUpdated; // @ G0598_B_MousePointerBitmapUpdated bool _refreshMousePointerInMainLoop; // @ G0326_B_RefreshMousePointerInMainLoop bool _highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled uint16 _useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap - EventManager(DMEngine *vm); + void initMouse(); void showMouse(bool visibility); diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 38d6630a96..e2f30f339c 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -279,7 +279,7 @@ public: // some methods use this for a stratchpad, don't make assumptions about content between function calls byte *_tmpBitmap; - DisplayMan(DMEngine *dmEngine); + explicit DisplayMan(DMEngine *dmEngine); ~DisplayMan(); void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index aa75dc0d6d..b8fbe516a5 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -21,9 +21,11 @@ enum PanelContent { class InventoryMan { DMEngine *_vm; public: + explicit InventoryMan(DMEngine *vm); + int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal PanelContent _panelContent; // @ G0424_i_PanelContent - InventoryMan(DMEngine *vm); + void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait void drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h index 857191200f..abedf54908 100644 --- a/engines/dm/loadsave.h +++ b/engines/dm/loadsave.h @@ -13,13 +13,11 @@ enum LoadgameResponse { class LoadsaveMan { DMEngine *_vm; public: - LoadsaveMan(DMEngine *vm); + explicit LoadsaveMan(DMEngine *vm); LoadgameResponse loadgame(); // @ F0435_STARTEND_LoadGame_CPSF - }; } #endif - diff --git a/engines/dm/menus.h b/engines/dm/menus.h index de0c43ac74..edaa970bd5 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -9,9 +9,11 @@ namespace DM { class MenuMan { DMEngine *_vm; public: + explicit MenuMan(DMEngine *vm); + bool _shouldRefreshActionArea; // @ G0508_B_RefreshActionArea bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons - MenuMan(DMEngine *vm); + void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index 908520c5f0..dd0150d747 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -7,7 +7,8 @@ namespace DM { class ObjectMan { DMEngine *_vm; public: - ObjectMan(DMEngine *vm); + explicit ObjectMan(DMEngine *vm); + IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex void extractIconFromBitmap(uint16 iconIndex, byte *srcBitmap); // F0036_OBJECT_ExtractIconFromBitmap -- cgit v1.2.3 From 204853952295bf6504921979db32d6c10909131a Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:33:28 +0200 Subject: DM: Initialize some variables --- engines/dm/champion.cpp | 1071 ++++++++++++++++++++++++----------------------- engines/dm/dm.cpp | 7 + engines/dm/eventman.cpp | 3 + engines/dm/gfx.cpp | 3 +- engines/dm/menus.cpp | 5 +- 5 files changed, 553 insertions(+), 536 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 8a79271ada..ff3e5f700e 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1,533 +1,538 @@ -#include "champion.h" -#include "dungeonman.h" -#include "eventman.h" -#include "menus.h" -#include "inventory.h" -#include "objectman.h" - - -namespace DM { - -Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth -Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye -Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons - Box(281, 299, 0, 13), - Box(301, 319, 0, 13), - Box(301, 319, 15, 28), - Box(281, 299, 15, 28)}; -Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; // @ G0046_auc_Graphic562_ChampionColor - -uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks - /* 30 for champion inventory, 8 for chest */ - 0xFFFF, /* Ready Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Action Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0x0002, /* Head Head */ - 0x0008, /* Torso Torso */ - 0x0010, /* Legs Legs */ - 0x0020, /* Feet Feet */ - 0x0100, /* Pouch 2 Pouch */ - 0x0080, /* Quiver Line2 1 Quiver 2 */ - 0x0080, /* Quiver Line1 2 Quiver 2 */ - 0x0080, /* Quiver Line2 2 Quiver 2 */ - 0x0004, /* Neck Neck */ - 0x0100, /* Pouch 1 Pouch */ - 0x0040, /* Quiver Line1 1 Quiver 1 */ - 0xFFFF, /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0x0400, /* Chest 1 Chest */ - 0x0400, /* Chest 2 Chest */ - 0x0400, /* Chest 3 Chest */ - 0x0400, /* Chest 4 Chest */ - 0x0400, /* Chest 5 Chest */ - 0x0400, /* Chest 6 Chest */ - 0x0400, /* Chest 7 Chest */ - 0x0400}; /* Chest 8 Chest */ - -Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait - -ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { - _leaderIndex = kChampionNone; -} - -uint16 ChampionMan::getChampionPortraitX(uint16 index) { - return ((index) & 0x7) << 5; -} - -uint16 ChampionMan::getChampionPortraitY(uint16 index) { - return ((index) >> 3) * 29; -} - -int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) { - int val = 0; - for (uint16 i = 0; i < characterCount; ++i) { - val = (val << 4) + (string[i] - 'A'); - } - return val; -} - -ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { - for (uint16 i = 0; i < _partyChampionCount; ++i) { - if ((_champions[i]._cell == cell) && _champions[i]._currHealth) - return (ChampionIndex)i; - } - - return kChampionNone; -} - -void ChampionMan::resetDataToStartGame() { - if (!_vm->_dungeonMan->_messages._newGame) { - warning("MISSING CODE: stuff for resetting for loaded games"); - assert(false); - } - - _leaderHand = Thing::_thingNone; - _leaderHandObjectIconIndex = kIconIndiceNone; - _leaderEmptyHanded = true; -} - - -void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { - DisplayMan &dispMan = *_vm->_displayMan; - DungeonMan &dunMan = *_vm->_dungeonMan; - - if (!_leaderEmptyHanded || _partyChampionCount == 4) - return; - - uint16 prevChampCount = _partyChampionCount; - Champion *champ = &_champions[prevChampCount]; - champ->resetToZero(); - dispMan._useByteBoxCoordinates = true; - { // limit destBox scope - Box &destBox = gBoxChampionPortrait; - dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), - champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency); - } - - champ->_actionIndex = kChampionActionNone; - champ->_enableActionEventIndex = -1; - champ->_hideDamageReceivedIndex = -1; - champ->_dir = dunMan._currMap._partyDir; - ViewCell AL_0_viewCell = kViewCellFronLeft; - while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone) - AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); - champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3); - champ->clearAttributes(kChampionAttributeIcon); - champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir; - champ->_food = 1500 + _vm->_rnd->getRandomNumber(256); - champ->_water = 1500 + _vm->_rnd->getRandomNumber(256); - int16 AL_0_slotIndex_Red; - for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) { - champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone); - } - Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY); - while (thing.getType() != kTextstringType) { - thing = dunMan.getNextThing(thing); - } - char decodedChampionText[77]; - char* character_Green = decodedChampionText; - dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible)); - int16 AL_0_characterIndex = 0; - uint16 AL_2_character; - while ((AL_2_character = *character_Green++) != '\n') { - champ->_name[AL_0_characterIndex++] = AL_2_character; - } - champ->_name[AL_0_characterIndex] = '\0'; - AL_0_characterIndex = 0; - bool AL_4_champTitleCopied = false; - for (;;) { // infinite - AL_2_character = *character_Green++; - if (AL_2_character == '\n') { - if (AL_4_champTitleCopied) - break; - AL_4_champTitleCopied = true; - } else { - champ->_title[AL_0_characterIndex++] = AL_2_character; - } - } - champ->_title[AL_0_characterIndex] = '\0'; - if (*character_Green++ == 'M') { - champ->setAttributeFlag(kChampionAttributeMale, true); - } - character_Green++; - champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4); - character_Green += 4; - champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4); - character_Green += 4; - champ->_currMana = champ->_maxMana = getDecodedValue(character_Green, 4); - character_Green += 4; - character_Green++; - - int16 AL_0_statisticIndex; - for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) { - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30); - uint16 currMaxVal = getDecodedValue(character_Green, 2); - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal); - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal); - character_Green += 2; - } - - champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10); - character_Green++; - - int16 AL_0_skillIndex; - int16 AL_2_skillValue; - for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) { - if ((AL_2_skillValue = *character_Green++ - 'A') > 0) { - champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue); - } - } - - for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) { - int32 baseSkillExp = 0; - int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2; - for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) { - baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience; - } - champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp); - } - - _candidateChampionOrdinal = prevChampCount + 1; - if (++_partyChampionCount == 1) { - _vm->_eventMan->commandSetLeader(kChampionFirst); - _vm->_menuMan->_shouldRefreshActionArea = true; - } else { - _vm->_menuMan->clearActingChampion(); - _vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1)); - } - - int16 mapX = _vm->_dungeonMan->_currMap._partyPosX; - int16 mapY = _vm->_dungeonMan->_currMap._partyPosY; - - uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir)); - mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir]; - mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir]; - thing = dunMan.getSquareFirstThing(mapX, mapY); - AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1; - uint16 slotIndex_Green; - while (thing != Thing::_thingEndOfList) { - ThingType AL_2_thingType = thing.getType(); - if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) { - int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots(); - switch (AL_2_thingType) { - case kArmourThingType: - for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) { - if (objectAllowedSlots & gSlotMasks[slotIndex_Green]) - goto T0280048; - } - if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { - slotIndex_Green = kChampionSlotNeck; - } else { - goto T0280046; - } - break; - case kWeaponThingType: - if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) { - slotIndex_Green = kChampionSlotActionHand; - } else { - goto T0280046; - } - break; - case kScrollThingType: - case kPotionThingType: - if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) { - slotIndex_Green = kChampionSlotPouch_1; - } else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) { - slotIndex_Green = kChampionSlotPouch_2; - } else { - goto T0280046; - } - break; - case kContainerThingType: - case kJunkThingType: -T0280046: - if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { - slotIndex_Green = kChampionSlotNeck; - } else { - slotIndex_Green = AL_0_slotIndex_Red++; - } - break; - } -T0280048: - if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) { - goto T0280046; - } - warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot"); - } - thing = dunMan.getNextThing(thing); - } - - _vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount); - _vm->_menuMan->drawDisabledMenu(); -} - -void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { - - Champion *curChampion = &_champions[champIndex]; - int16 barGraphIndex = 0; - int16 barGraphHeightArray[3]; - - if (curChampion->_currHealth > 0) { - uint32 barGraphHeight = (((uint32)(curChampion->_currHealth) << 10) * 25) / curChampion->_maxHealth; - if (barGraphHeight & 0x3FF) { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; - } else { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); - } - } else { - barGraphHeightArray[barGraphIndex++] = 0; - } - - if (curChampion->_currStamina > 0) { - uint32 barGraphHeight = (((uint32)(curChampion->_currStamina) << 10) * 25) / curChampion->_maxStamina; - if (barGraphHeight & 0x3FF) { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; - } else { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); - } - } else { - barGraphHeightArray[barGraphIndex++] = 0; - } - - if (curChampion->_currMana > 0) { - uint32 barGraphHeight = (((uint32)(curChampion->_currMana) << 10) * 25) / curChampion->_maxMana; - if (barGraphHeight & 0x3FF) { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; - } else { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); - } - } else { - barGraphHeightArray[barGraphIndex++] = 0; - } - warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - - Box box; - box._x1 = champIndex * kChampionStatusBoxSpacing + 46; - box._x2 = box._x1 + 3 + 1; - box._y1 = 2; - box._y2 = 26 + 1; - - for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) { - int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex]; - if (barGraphHeight < 25) { - box._y1 = 2; - box._y1 = 27 - barGraphHeight + 1; - _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); - } - if (barGraphHeight) { - box._y1 = 27 - barGraphHeight; - box._y2 = 26 + 1; - _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); - } - box._x1 += 7; - box._x2 += 7; - } - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); -} - - -uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) { - int16 currStamina = champ->_currStamina; - int16 halfMaxStamina = champ->_maxStamina / 2; - if (currStamina < halfMaxStamina) { - warning("Possible undefined behavior in the original code"); - val /= 2; - return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina; - } - return val; -} - -uint16 ChampionMan::getMaximumLoad(Champion *champ) { - uint16 maximumLoad = champ->getStatistic(kChampionStatStrength, kChampionStatCurrent) * 8 + 100; - maximumLoad = getStaminaAdjustedValue(champ, maximumLoad); - int16 wounds = champ->getWounds(); - if (wounds) { - maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kChampionWoundLegs) ? 2 : 3); - } - if (_vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotFeet)) == kIconIndiceArmourElvenBoots) { - maximumLoad += maximumLoad * 16; - } - maximumLoad += 9; - maximumLoad -= maximumLoad % 10; - return maximumLoad; -} - -void ChampionMan::drawChampionState(ChampionIndex champIndex) { - InventoryMan &invMan = *_vm->_inventoryMan; - DisplayMan &dispMan = *_vm->_displayMan; - MenuMan &menuMan = *_vm->_menuMan; - EventManager &eventMan = *_vm->_eventMan; - - Box box; - int16 champStatusBoxX = champIndex * kChampionStatusBoxSpacing; - Champion *champ = &_champions[champIndex]; - uint16 champAttributes = champ->getAttributes(); - if (!((champAttributes) & (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon | - kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport | - kChampionAttributeActionHand))) { - return; - } - bool isInventoryChamp = (indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal); - dispMan._useByteBoxCoordinates = false; - if (champAttributes & kChampionAttributeStatusBox) { - box._y1 = 0; - box._y2 = 28 + 1; - box._x1 = champStatusBoxX; - box._x2 = box._x1 + 66 + 1; - if (champ->_currHealth) { - dispMan.clearScreenBox(kColorDarkestGray, box); - int16 nativeBitmapIndices[3]; - for (int16 i = 0; i < 3; ++i) - nativeBitmapIndices[i] = 0; - int16 AL_0_borderCount = 0; - if (_party._fireShieldDefense > 0) - nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyFireshieldIndice; - if (_party._spellShieldDefense > 0) - nativeBitmapIndices[AL_0_borderCount++] = kBorderPartySpellshieldIndice; - if (_party._shieldDefense > 0) - nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyShieldIndice; - while (AL_0_borderCount--) { - dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, kColorFlesh); - } - if (isInventoryChamp) { - invMan.drawStatusBoxPortrait(champIndex); - champAttributes |= kChampionAttributeStatistics; - } else { - champAttributes |= (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeWounds | kChampionAttributeActionHand); - } - } else { - dispMan.blitToScreen(dispMan.getBitmap(kStatusBoxDeadChampion), 80, 0, 0, box, kColorNoTransparency); - warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen"); - menuMan.drawActionIcon(champIndex); - goto T0292042_green; - } - } - - if (!champ->_currHealth) - goto T0292042_green; - - if(champAttributes & kChampionAttributeNameTitle) { - int16 AL_0_colorIndex = (champIndex == _leaderIndex) ? kColorGold : kColorLightestGray; // unused because of missing functions - if(isInventoryChamp) { - char *champName = champ->_name; - warning("MISSING CODE: F0052_TEXT_PrintToViewport"); - int16 champTitleX = 6 * strlen(champName) + 3; - char champTitleFirstChar = champ->_title[0]; - if ((champTitleFirstChar != ',') && (champTitleFirstChar != ';') && (champTitleFirstChar != '-')) { - champTitleX += 6; - } - warning("MISSING CODE: F0052_TEXT_PrintToViewport"); - champAttributes |= kChampionAttributeViewport; - } else { - box._y1 = 0; - box._y2 = 6 + 1; - box._x1 = champStatusBoxX; - box._x2 = box._x1 + 42 + 1; - dispMan.clearScreenBox(kColorDarkGary, box); - warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen"); - } - } - - if (champAttributes & kChampionAttributeStatistics) { - drawChampionBarGraphs(champIndex); - if (isInventoryChamp) { - warning("MISSING CODE: F0290_CHAMPION_DrawHealthStaminaManaValues"); - int16 AL_2_nativeBitmapIndex; - if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) { - AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice; - } else { - AL_2_nativeBitmapIndex = kSlotBoxNormalIndice; - } - dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, kColorDarkestGray, gDungeonViewport); - AL_2_nativeBitmapIndex = kSlotBoxNormalIndice; - for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) { - if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent) - < champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum)) { - AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice; - break; - } - } - dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, kColorDarkestGray, gDungeonViewport); - champAttributes |= kChampionAttributeViewport; - } - } - - if (champAttributes & kChampionAttributeWounds) { - for (int16 AL_0_slotIndex = isInventoryChamp ? kChampionSlotFeet : kChampionSlotActionHand; AL_0_slotIndex >= kChampionSlotReadyHand; AL_0_slotIndex--) { - warning("MISSING CODE: F0291_CHAMPION_DrawSlot"); - } - if (isInventoryChamp) { - champAttributes |= kChampionAttributeViewport; - } - } - - if (champAttributes & kChampionAttributeLoad) { - warning("MISSING CODE: whole if branch, many F0052_TEXT_PrintToViewport-s"); - - - - champAttributes |= kChampionAttributeViewport; - } - - { // block so goto won't skip AL_0_championIconIndex initialization - int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir); - - if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != indexToOrdinal(AL_0_championIconIndex))) { - dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]); - dispMan.blitToScreen(dispMan.getBitmap(kChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0, - gBoxChampionIcons[AL_0_championIconIndex], kColorDarkestGray); - } - } - - if ((champAttributes & kChampionAttributePanel) && isInventoryChamp) { - if (_vm->_pressingMouth) { - invMan.drawPanelFoodWaterPoisoned(); - } else if (_vm->_pressingEye) { - if (_leaderEmptyHanded) { - warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics"); - } - } else { - invMan.drawPanel(); - } - champAttributes |= kChampionAttributeViewport; - } - - if (champAttributes & kChampionAttributeActionHand) { - warning("MISSING CODE: F0291_CHAMPION_DrawSlot"); - menuMan.drawActionIcon(champIndex); - if (isInventoryChamp) { - champAttributes |= kChampionAttributeViewport; - } - } - - if (champAttributes & kChampionAttributeViewport) { - warning("MISSGIN CODE: F0097_DUNGEONVIEW_DrawViewport"); - } - - -T0292042_green: - champ->setAttributeFlag((ChampionAttribute)(kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon | - kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport | - kChampionAttributeActionHand), false); - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); -} - -uint16 ChampionMan::championIconIndex(int16 val, direction dir) { - return ((val + 4 - dir) & 0x3); -} - -} +#include "champion.h" +#include "dungeonman.h" +#include "eventman.h" +#include "menus.h" +#include "inventory.h" +#include "objectman.h" + + +namespace DM { + +Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth +Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye +Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons + Box(281, 299, 0, 13), + Box(301, 319, 0, 13), + Box(301, 319, 15, 28), + Box(281, 299, 15, 28)}; +Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; // @ G0046_auc_Graphic562_ChampionColor + +uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks + /* 30 for champion inventory, 8 for chest */ + 0xFFFF, /* Ready Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Action Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0x0002, /* Head Head */ + 0x0008, /* Torso Torso */ + 0x0010, /* Legs Legs */ + 0x0020, /* Feet Feet */ + 0x0100, /* Pouch 2 Pouch */ + 0x0080, /* Quiver Line2 1 Quiver 2 */ + 0x0080, /* Quiver Line1 2 Quiver 2 */ + 0x0080, /* Quiver Line2 2 Quiver 2 */ + 0x0004, /* Neck Neck */ + 0x0100, /* Pouch 1 Pouch */ + 0x0040, /* Quiver Line1 1 Quiver 1 */ + 0xFFFF, /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0x0400, /* Chest 1 Chest */ + 0x0400, /* Chest 2 Chest */ + 0x0400, /* Chest 3 Chest */ + 0x0400, /* Chest 4 Chest */ + 0x0400, /* Chest 5 Chest */ + 0x0400, /* Chest 6 Chest */ + 0x0400, /* Chest 7 Chest */ + 0x0400}; /* Chest 8 Chest */ + +Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait + +ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { + _leaderIndex = kChampionNone; + + _partyDead = false; + _partyIsSleeping = false; + _leaderHandObjectIconIndex = kIconIndiceNone; + _leaderEmptyHanded = true; +} + +uint16 ChampionMan::getChampionPortraitX(uint16 index) { + return ((index) & 0x7) << 5; +} + +uint16 ChampionMan::getChampionPortraitY(uint16 index) { + return ((index) >> 3) * 29; +} + +int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) { + int val = 0; + for (uint16 i = 0; i < characterCount; ++i) { + val = (val << 4) + (string[i] - 'A'); + } + return val; +} + +ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { + for (uint16 i = 0; i < _partyChampionCount; ++i) { + if ((_champions[i]._cell == cell) && _champions[i]._currHealth) + return (ChampionIndex)i; + } + + return kChampionNone; +} + +void ChampionMan::resetDataToStartGame() { + if (!_vm->_dungeonMan->_messages._newGame) { + warning("MISSING CODE: stuff for resetting for loaded games"); + assert(false); + } + + _leaderHand = Thing::_thingNone; + _leaderHandObjectIconIndex = kIconIndiceNone; + _leaderEmptyHanded = true; +} + + +void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { + DisplayMan &dispMan = *_vm->_displayMan; + DungeonMan &dunMan = *_vm->_dungeonMan; + + if (!_leaderEmptyHanded || _partyChampionCount == 4) + return; + + uint16 prevChampCount = _partyChampionCount; + Champion *champ = &_champions[prevChampCount]; + champ->resetToZero(); + dispMan._useByteBoxCoordinates = true; + { // limit destBox scope + Box &destBox = gBoxChampionPortrait; + dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), + champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency); + } + + champ->_actionIndex = kChampionActionNone; + champ->_enableActionEventIndex = -1; + champ->_hideDamageReceivedIndex = -1; + champ->_dir = dunMan._currMap._partyDir; + ViewCell AL_0_viewCell = kViewCellFronLeft; + while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone) + AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); + champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3); + champ->clearAttributes(kChampionAttributeIcon); + champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir; + champ->_food = 1500 + _vm->_rnd->getRandomNumber(256); + champ->_water = 1500 + _vm->_rnd->getRandomNumber(256); + int16 AL_0_slotIndex_Red; + for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) { + champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone); + } + Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY); + while (thing.getType() != kTextstringType) { + thing = dunMan.getNextThing(thing); + } + char decodedChampionText[77]; + char* character_Green = decodedChampionText; + dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible)); + int16 AL_0_characterIndex = 0; + uint16 AL_2_character; + while ((AL_2_character = *character_Green++) != '\n') { + champ->_name[AL_0_characterIndex++] = AL_2_character; + } + champ->_name[AL_0_characterIndex] = '\0'; + AL_0_characterIndex = 0; + bool AL_4_champTitleCopied = false; + for (;;) { // infinite + AL_2_character = *character_Green++; + if (AL_2_character == '\n') { + if (AL_4_champTitleCopied) + break; + AL_4_champTitleCopied = true; + } else { + champ->_title[AL_0_characterIndex++] = AL_2_character; + } + } + champ->_title[AL_0_characterIndex] = '\0'; + if (*character_Green++ == 'M') { + champ->setAttributeFlag(kChampionAttributeMale, true); + } + character_Green++; + champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4); + character_Green += 4; + champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4); + character_Green += 4; + champ->_currMana = champ->_maxMana = getDecodedValue(character_Green, 4); + character_Green += 4; + character_Green++; + + int16 AL_0_statisticIndex; + for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) { + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30); + uint16 currMaxVal = getDecodedValue(character_Green, 2); + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal); + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal); + character_Green += 2; + } + + champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10); + character_Green++; + + int16 AL_0_skillIndex; + int16 AL_2_skillValue; + for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) { + if ((AL_2_skillValue = *character_Green++ - 'A') > 0) { + champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue); + } + } + + for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) { + int32 baseSkillExp = 0; + int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2; + for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) { + baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience; + } + champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp); + } + + _candidateChampionOrdinal = prevChampCount + 1; + if (++_partyChampionCount == 1) { + _vm->_eventMan->commandSetLeader(kChampionFirst); + _vm->_menuMan->_shouldRefreshActionArea = true; + } else { + _vm->_menuMan->clearActingChampion(); + _vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1)); + } + + int16 mapX = _vm->_dungeonMan->_currMap._partyPosX; + int16 mapY = _vm->_dungeonMan->_currMap._partyPosY; + + uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir)); + mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir]; + mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir]; + thing = dunMan.getSquareFirstThing(mapX, mapY); + AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1; + uint16 slotIndex_Green; + while (thing != Thing::_thingEndOfList) { + ThingType AL_2_thingType = thing.getType(); + if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) { + int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots(); + switch (AL_2_thingType) { + case kArmourThingType: + for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) { + if (objectAllowedSlots & gSlotMasks[slotIndex_Green]) + goto T0280048; + } + if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { + slotIndex_Green = kChampionSlotNeck; + } else { + goto T0280046; + } + break; + case kWeaponThingType: + if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) { + slotIndex_Green = kChampionSlotActionHand; + } else { + goto T0280046; + } + break; + case kScrollThingType: + case kPotionThingType: + if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) { + slotIndex_Green = kChampionSlotPouch_1; + } else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) { + slotIndex_Green = kChampionSlotPouch_2; + } else { + goto T0280046; + } + break; + case kContainerThingType: + case kJunkThingType: +T0280046: + if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { + slotIndex_Green = kChampionSlotNeck; + } else { + slotIndex_Green = AL_0_slotIndex_Red++; + } + break; + } +T0280048: + if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) { + goto T0280046; + } + warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot"); + } + thing = dunMan.getNextThing(thing); + } + + _vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount); + _vm->_menuMan->drawDisabledMenu(); +} + +void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { + + Champion *curChampion = &_champions[champIndex]; + int16 barGraphIndex = 0; + int16 barGraphHeightArray[3]; + + if (curChampion->_currHealth > 0) { + uint32 barGraphHeight = (((uint32)(curChampion->_currHealth) << 10) * 25) / curChampion->_maxHealth; + if (barGraphHeight & 0x3FF) { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; + } else { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); + } + } else { + barGraphHeightArray[barGraphIndex++] = 0; + } + + if (curChampion->_currStamina > 0) { + uint32 barGraphHeight = (((uint32)(curChampion->_currStamina) << 10) * 25) / curChampion->_maxStamina; + if (barGraphHeight & 0x3FF) { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; + } else { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); + } + } else { + barGraphHeightArray[barGraphIndex++] = 0; + } + + if (curChampion->_currMana > 0) { + uint32 barGraphHeight = (((uint32)(curChampion->_currMana) << 10) * 25) / curChampion->_maxMana; + if (barGraphHeight & 0x3FF) { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; + } else { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); + } + } else { + barGraphHeightArray[barGraphIndex++] = 0; + } + warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + + Box box; + box._x1 = champIndex * kChampionStatusBoxSpacing + 46; + box._x2 = box._x1 + 3 + 1; + box._y1 = 2; + box._y2 = 26 + 1; + + for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) { + int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex]; + if (barGraphHeight < 25) { + box._y1 = 2; + box._y1 = 27 - barGraphHeight + 1; + _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); + } + if (barGraphHeight) { + box._y1 = 27 - barGraphHeight; + box._y2 = 26 + 1; + _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); + } + box._x1 += 7; + box._x2 += 7; + } + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); +} + + +uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) { + int16 currStamina = champ->_currStamina; + int16 halfMaxStamina = champ->_maxStamina / 2; + if (currStamina < halfMaxStamina) { + warning("Possible undefined behavior in the original code"); + val /= 2; + return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina; + } + return val; +} + +uint16 ChampionMan::getMaximumLoad(Champion *champ) { + uint16 maximumLoad = champ->getStatistic(kChampionStatStrength, kChampionStatCurrent) * 8 + 100; + maximumLoad = getStaminaAdjustedValue(champ, maximumLoad); + int16 wounds = champ->getWounds(); + if (wounds) { + maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kChampionWoundLegs) ? 2 : 3); + } + if (_vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotFeet)) == kIconIndiceArmourElvenBoots) { + maximumLoad += maximumLoad * 16; + } + maximumLoad += 9; + maximumLoad -= maximumLoad % 10; + return maximumLoad; +} + +void ChampionMan::drawChampionState(ChampionIndex champIndex) { + InventoryMan &invMan = *_vm->_inventoryMan; + DisplayMan &dispMan = *_vm->_displayMan; + MenuMan &menuMan = *_vm->_menuMan; + EventManager &eventMan = *_vm->_eventMan; + + Box box; + int16 champStatusBoxX = champIndex * kChampionStatusBoxSpacing; + Champion *champ = &_champions[champIndex]; + uint16 champAttributes = champ->getAttributes(); + if (!((champAttributes) & (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon | + kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport | + kChampionAttributeActionHand))) { + return; + } + bool isInventoryChamp = (indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal); + dispMan._useByteBoxCoordinates = false; + if (champAttributes & kChampionAttributeStatusBox) { + box._y1 = 0; + box._y2 = 28 + 1; + box._x1 = champStatusBoxX; + box._x2 = box._x1 + 66 + 1; + if (champ->_currHealth) { + dispMan.clearScreenBox(kColorDarkestGray, box); + int16 nativeBitmapIndices[3]; + for (int16 i = 0; i < 3; ++i) + nativeBitmapIndices[i] = 0; + int16 AL_0_borderCount = 0; + if (_party._fireShieldDefense > 0) + nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyFireshieldIndice; + if (_party._spellShieldDefense > 0) + nativeBitmapIndices[AL_0_borderCount++] = kBorderPartySpellshieldIndice; + if (_party._shieldDefense > 0) + nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyShieldIndice; + while (AL_0_borderCount--) { + dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, kColorFlesh); + } + if (isInventoryChamp) { + invMan.drawStatusBoxPortrait(champIndex); + champAttributes |= kChampionAttributeStatistics; + } else { + champAttributes |= (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeWounds | kChampionAttributeActionHand); + } + } else { + dispMan.blitToScreen(dispMan.getBitmap(kStatusBoxDeadChampion), 80, 0, 0, box, kColorNoTransparency); + warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen"); + menuMan.drawActionIcon(champIndex); + goto T0292042_green; + } + } + + if (!champ->_currHealth) + goto T0292042_green; + + if(champAttributes & kChampionAttributeNameTitle) { + int16 AL_0_colorIndex = (champIndex == _leaderIndex) ? kColorGold : kColorLightestGray; // unused because of missing functions + if(isInventoryChamp) { + char *champName = champ->_name; + warning("MISSING CODE: F0052_TEXT_PrintToViewport"); + int16 champTitleX = 6 * strlen(champName) + 3; + char champTitleFirstChar = champ->_title[0]; + if ((champTitleFirstChar != ',') && (champTitleFirstChar != ';') && (champTitleFirstChar != '-')) { + champTitleX += 6; + } + warning("MISSING CODE: F0052_TEXT_PrintToViewport"); + champAttributes |= kChampionAttributeViewport; + } else { + box._y1 = 0; + box._y2 = 6 + 1; + box._x1 = champStatusBoxX; + box._x2 = box._x1 + 42 + 1; + dispMan.clearScreenBox(kColorDarkGary, box); + warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen"); + } + } + + if (champAttributes & kChampionAttributeStatistics) { + drawChampionBarGraphs(champIndex); + if (isInventoryChamp) { + warning("MISSING CODE: F0290_CHAMPION_DrawHealthStaminaManaValues"); + int16 AL_2_nativeBitmapIndex; + if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) { + AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice; + } else { + AL_2_nativeBitmapIndex = kSlotBoxNormalIndice; + } + dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, kColorDarkestGray, gDungeonViewport); + AL_2_nativeBitmapIndex = kSlotBoxNormalIndice; + for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) { + if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent) + < champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum)) { + AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice; + break; + } + } + dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, kColorDarkestGray, gDungeonViewport); + champAttributes |= kChampionAttributeViewport; + } + } + + if (champAttributes & kChampionAttributeWounds) { + for (int16 AL_0_slotIndex = isInventoryChamp ? kChampionSlotFeet : kChampionSlotActionHand; AL_0_slotIndex >= kChampionSlotReadyHand; AL_0_slotIndex--) { + warning("MISSING CODE: F0291_CHAMPION_DrawSlot"); + } + if (isInventoryChamp) { + champAttributes |= kChampionAttributeViewport; + } + } + + if (champAttributes & kChampionAttributeLoad) { + warning("MISSING CODE: whole if branch, many F0052_TEXT_PrintToViewport-s"); + + + + champAttributes |= kChampionAttributeViewport; + } + + { // block so goto won't skip AL_0_championIconIndex initialization + int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir); + + if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != indexToOrdinal(AL_0_championIconIndex))) { + dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]); + dispMan.blitToScreen(dispMan.getBitmap(kChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0, + gBoxChampionIcons[AL_0_championIconIndex], kColorDarkestGray); + } + } + + if ((champAttributes & kChampionAttributePanel) && isInventoryChamp) { + if (_vm->_pressingMouth) { + invMan.drawPanelFoodWaterPoisoned(); + } else if (_vm->_pressingEye) { + if (_leaderEmptyHanded) { + warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics"); + } + } else { + invMan.drawPanel(); + } + champAttributes |= kChampionAttributeViewport; + } + + if (champAttributes & kChampionAttributeActionHand) { + warning("MISSING CODE: F0291_CHAMPION_DrawSlot"); + menuMan.drawActionIcon(champIndex); + if (isInventoryChamp) { + champAttributes |= kChampionAttributeViewport; + } + } + + if (champAttributes & kChampionAttributeViewport) { + warning("MISSGIN CODE: F0097_DUNGEONVIEW_DrawViewport"); + } + + +T0292042_green: + champ->setAttributeFlag((ChampionAttribute)(kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon | + kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport | + kChampionAttributeActionHand), false); + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); +} + +uint16 ChampionMan::championIconIndex(int16 val, direction dir) { + return ((val + 4 - dir) & 0x3); +} + +} diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 8d38c5bf85..61810e8376 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -56,8 +56,15 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _objectMan = nullptr; _inventoryMan = nullptr; _textMan = nullptr; + _stopWaitingForPlayerInput = false; _gameTimeTicking = false; + _restartGameAllowed = false; + _pressingEye = false; + _pressingMouth = false; + _stopPressingEye = false; + _stopPressingMouth = false; + _highlightBoxInversionRequested = false; debug("DMEngine::DMEngine"); } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index b7caa60668..b5937296c2 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -216,6 +216,9 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) { _pendingClickPresent = false; _isCommandQueueLocked = true; + _mousePointerBitmapUpdated = false; + _refreshMousePointerInMainLoop = false; + _highlightBoxEnabled = false; _dummyMapIndex = 0; _pendingClickButton = kNoneMouseButton; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index ab0f9f114e..e2713a2536 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -12,8 +12,6 @@ namespace DM { Box gBoxMovementArrows = Box(224, 319, 124, 168); - - enum StairFrameIndex { kFrameStairsUpFront_D3L = 0, // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L kFrameStairsUpFront_D3C = 1, // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C @@ -614,6 +612,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _currMapDoorOrnIndices[i] = 0; _inscriptionThing = Thing::_thingNone; + _useByteBoxCoordinates = false; } DisplayMan::~DisplayMan() { diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index f641e02ede..b3464647a5 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -10,7 +10,10 @@ namespace DM { byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon -MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {} +MenuMan::MenuMan(DMEngine *vm) : _vm(vm) { + _shouldRefreshActionArea = false; + _actionAreaContainsIcons = false; +} void MenuMan::drawMovementArrows() { DisplayMan &disp = *_vm->_displayMan; -- cgit v1.2.3 From 9d7cfe5cd8cc5ba12b544c0da2e8d3d1f84133fa Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:35:29 +0200 Subject: DM: Add several functions realted to text display Add F0290_CHAMPION_DrawHealthStaminaManaValues, F0289_CHAMPION_DrawHealthOrStaminaOrManaValue, F0288_CHAMPION_GetStringFromInteger, F0052_TEXT_PrintToViewport, swap warning for real code, expand viewport fields with width, height, remove self-inclusion in dungeonman.h, remove extra black line when loading fonts, fix alignment error in TextMan::printTextToBitmap --- engines/dm/champion.cpp | 1101 +++++++++++++++++++++++---------------------- engines/dm/champion.h | 5 + engines/dm/dungeonman.cpp | 1 + engines/dm/dungeonman.h | 1 - engines/dm/gfx.cpp | 8 +- engines/dm/gfx.h | 4 +- engines/dm/inventory.cpp | 7 +- engines/dm/text.cpp | 26 +- engines/dm/text.h | 5 +- 9 files changed, 598 insertions(+), 560 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index ff3e5f700e..79f4267c7d 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1,538 +1,563 @@ -#include "champion.h" -#include "dungeonman.h" -#include "eventman.h" -#include "menus.h" -#include "inventory.h" -#include "objectman.h" - - -namespace DM { - -Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth -Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye -Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons - Box(281, 299, 0, 13), - Box(301, 319, 0, 13), - Box(301, 319, 15, 28), - Box(281, 299, 15, 28)}; -Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; // @ G0046_auc_Graphic562_ChampionColor - -uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks - /* 30 for champion inventory, 8 for chest */ - 0xFFFF, /* Ready Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Action Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0x0002, /* Head Head */ - 0x0008, /* Torso Torso */ - 0x0010, /* Legs Legs */ - 0x0020, /* Feet Feet */ - 0x0100, /* Pouch 2 Pouch */ - 0x0080, /* Quiver Line2 1 Quiver 2 */ - 0x0080, /* Quiver Line1 2 Quiver 2 */ - 0x0080, /* Quiver Line2 2 Quiver 2 */ - 0x0004, /* Neck Neck */ - 0x0100, /* Pouch 1 Pouch */ - 0x0040, /* Quiver Line1 1 Quiver 1 */ - 0xFFFF, /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0x0400, /* Chest 1 Chest */ - 0x0400, /* Chest 2 Chest */ - 0x0400, /* Chest 3 Chest */ - 0x0400, /* Chest 4 Chest */ - 0x0400, /* Chest 5 Chest */ - 0x0400, /* Chest 6 Chest */ - 0x0400, /* Chest 7 Chest */ - 0x0400}; /* Chest 8 Chest */ - -Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait - -ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { - _leaderIndex = kChampionNone; - - _partyDead = false; - _partyIsSleeping = false; - _leaderHandObjectIconIndex = kIconIndiceNone; - _leaderEmptyHanded = true; -} - -uint16 ChampionMan::getChampionPortraitX(uint16 index) { - return ((index) & 0x7) << 5; -} - -uint16 ChampionMan::getChampionPortraitY(uint16 index) { - return ((index) >> 3) * 29; -} - -int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) { - int val = 0; - for (uint16 i = 0; i < characterCount; ++i) { - val = (val << 4) + (string[i] - 'A'); - } - return val; -} - -ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { - for (uint16 i = 0; i < _partyChampionCount; ++i) { - if ((_champions[i]._cell == cell) && _champions[i]._currHealth) - return (ChampionIndex)i; - } - - return kChampionNone; -} - -void ChampionMan::resetDataToStartGame() { - if (!_vm->_dungeonMan->_messages._newGame) { - warning("MISSING CODE: stuff for resetting for loaded games"); - assert(false); - } - - _leaderHand = Thing::_thingNone; - _leaderHandObjectIconIndex = kIconIndiceNone; - _leaderEmptyHanded = true; -} - - -void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { - DisplayMan &dispMan = *_vm->_displayMan; - DungeonMan &dunMan = *_vm->_dungeonMan; - - if (!_leaderEmptyHanded || _partyChampionCount == 4) - return; - - uint16 prevChampCount = _partyChampionCount; - Champion *champ = &_champions[prevChampCount]; - champ->resetToZero(); - dispMan._useByteBoxCoordinates = true; - { // limit destBox scope - Box &destBox = gBoxChampionPortrait; - dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), - champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency); - } - - champ->_actionIndex = kChampionActionNone; - champ->_enableActionEventIndex = -1; - champ->_hideDamageReceivedIndex = -1; - champ->_dir = dunMan._currMap._partyDir; - ViewCell AL_0_viewCell = kViewCellFronLeft; - while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone) - AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); - champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3); - champ->clearAttributes(kChampionAttributeIcon); - champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir; - champ->_food = 1500 + _vm->_rnd->getRandomNumber(256); - champ->_water = 1500 + _vm->_rnd->getRandomNumber(256); - int16 AL_0_slotIndex_Red; - for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) { - champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone); - } - Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY); - while (thing.getType() != kTextstringType) { - thing = dunMan.getNextThing(thing); - } - char decodedChampionText[77]; - char* character_Green = decodedChampionText; - dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible)); - int16 AL_0_characterIndex = 0; - uint16 AL_2_character; - while ((AL_2_character = *character_Green++) != '\n') { - champ->_name[AL_0_characterIndex++] = AL_2_character; - } - champ->_name[AL_0_characterIndex] = '\0'; - AL_0_characterIndex = 0; - bool AL_4_champTitleCopied = false; - for (;;) { // infinite - AL_2_character = *character_Green++; - if (AL_2_character == '\n') { - if (AL_4_champTitleCopied) - break; - AL_4_champTitleCopied = true; - } else { - champ->_title[AL_0_characterIndex++] = AL_2_character; - } - } - champ->_title[AL_0_characterIndex] = '\0'; - if (*character_Green++ == 'M') { - champ->setAttributeFlag(kChampionAttributeMale, true); - } - character_Green++; - champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4); - character_Green += 4; - champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4); - character_Green += 4; - champ->_currMana = champ->_maxMana = getDecodedValue(character_Green, 4); - character_Green += 4; - character_Green++; - - int16 AL_0_statisticIndex; - for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) { - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30); - uint16 currMaxVal = getDecodedValue(character_Green, 2); - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal); - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal); - character_Green += 2; - } - - champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10); - character_Green++; - - int16 AL_0_skillIndex; - int16 AL_2_skillValue; - for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) { - if ((AL_2_skillValue = *character_Green++ - 'A') > 0) { - champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue); - } - } - - for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) { - int32 baseSkillExp = 0; - int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2; - for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) { - baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience; - } - champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp); - } - - _candidateChampionOrdinal = prevChampCount + 1; - if (++_partyChampionCount == 1) { - _vm->_eventMan->commandSetLeader(kChampionFirst); - _vm->_menuMan->_shouldRefreshActionArea = true; - } else { - _vm->_menuMan->clearActingChampion(); - _vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1)); - } - - int16 mapX = _vm->_dungeonMan->_currMap._partyPosX; - int16 mapY = _vm->_dungeonMan->_currMap._partyPosY; - - uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir)); - mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir]; - mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir]; - thing = dunMan.getSquareFirstThing(mapX, mapY); - AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1; - uint16 slotIndex_Green; - while (thing != Thing::_thingEndOfList) { - ThingType AL_2_thingType = thing.getType(); - if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) { - int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots(); - switch (AL_2_thingType) { - case kArmourThingType: - for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) { - if (objectAllowedSlots & gSlotMasks[slotIndex_Green]) - goto T0280048; - } - if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { - slotIndex_Green = kChampionSlotNeck; - } else { - goto T0280046; - } - break; - case kWeaponThingType: - if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) { - slotIndex_Green = kChampionSlotActionHand; - } else { - goto T0280046; - } - break; - case kScrollThingType: - case kPotionThingType: - if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) { - slotIndex_Green = kChampionSlotPouch_1; - } else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) { - slotIndex_Green = kChampionSlotPouch_2; - } else { - goto T0280046; - } - break; - case kContainerThingType: - case kJunkThingType: -T0280046: - if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { - slotIndex_Green = kChampionSlotNeck; - } else { - slotIndex_Green = AL_0_slotIndex_Red++; - } - break; - } -T0280048: - if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) { - goto T0280046; - } - warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot"); - } - thing = dunMan.getNextThing(thing); - } - - _vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount); - _vm->_menuMan->drawDisabledMenu(); -} - -void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { - - Champion *curChampion = &_champions[champIndex]; - int16 barGraphIndex = 0; - int16 barGraphHeightArray[3]; - - if (curChampion->_currHealth > 0) { - uint32 barGraphHeight = (((uint32)(curChampion->_currHealth) << 10) * 25) / curChampion->_maxHealth; - if (barGraphHeight & 0x3FF) { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; - } else { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); - } - } else { - barGraphHeightArray[barGraphIndex++] = 0; - } - - if (curChampion->_currStamina > 0) { - uint32 barGraphHeight = (((uint32)(curChampion->_currStamina) << 10) * 25) / curChampion->_maxStamina; - if (barGraphHeight & 0x3FF) { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; - } else { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); - } - } else { - barGraphHeightArray[barGraphIndex++] = 0; - } - - if (curChampion->_currMana > 0) { - uint32 barGraphHeight = (((uint32)(curChampion->_currMana) << 10) * 25) / curChampion->_maxMana; - if (barGraphHeight & 0x3FF) { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; - } else { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); - } - } else { - barGraphHeightArray[barGraphIndex++] = 0; - } - warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - - Box box; - box._x1 = champIndex * kChampionStatusBoxSpacing + 46; - box._x2 = box._x1 + 3 + 1; - box._y1 = 2; - box._y2 = 26 + 1; - - for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) { - int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex]; - if (barGraphHeight < 25) { - box._y1 = 2; - box._y1 = 27 - barGraphHeight + 1; - _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); - } - if (barGraphHeight) { - box._y1 = 27 - barGraphHeight; - box._y2 = 26 + 1; - _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); - } - box._x1 += 7; - box._x2 += 7; - } - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); -} - - -uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) { - int16 currStamina = champ->_currStamina; - int16 halfMaxStamina = champ->_maxStamina / 2; - if (currStamina < halfMaxStamina) { - warning("Possible undefined behavior in the original code"); - val /= 2; - return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina; - } - return val; -} - -uint16 ChampionMan::getMaximumLoad(Champion *champ) { - uint16 maximumLoad = champ->getStatistic(kChampionStatStrength, kChampionStatCurrent) * 8 + 100; - maximumLoad = getStaminaAdjustedValue(champ, maximumLoad); - int16 wounds = champ->getWounds(); - if (wounds) { - maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kChampionWoundLegs) ? 2 : 3); - } - if (_vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotFeet)) == kIconIndiceArmourElvenBoots) { - maximumLoad += maximumLoad * 16; - } - maximumLoad += 9; - maximumLoad -= maximumLoad % 10; - return maximumLoad; -} - -void ChampionMan::drawChampionState(ChampionIndex champIndex) { - InventoryMan &invMan = *_vm->_inventoryMan; - DisplayMan &dispMan = *_vm->_displayMan; - MenuMan &menuMan = *_vm->_menuMan; - EventManager &eventMan = *_vm->_eventMan; - - Box box; - int16 champStatusBoxX = champIndex * kChampionStatusBoxSpacing; - Champion *champ = &_champions[champIndex]; - uint16 champAttributes = champ->getAttributes(); - if (!((champAttributes) & (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon | - kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport | - kChampionAttributeActionHand))) { - return; - } - bool isInventoryChamp = (indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal); - dispMan._useByteBoxCoordinates = false; - if (champAttributes & kChampionAttributeStatusBox) { - box._y1 = 0; - box._y2 = 28 + 1; - box._x1 = champStatusBoxX; - box._x2 = box._x1 + 66 + 1; - if (champ->_currHealth) { - dispMan.clearScreenBox(kColorDarkestGray, box); - int16 nativeBitmapIndices[3]; - for (int16 i = 0; i < 3; ++i) - nativeBitmapIndices[i] = 0; - int16 AL_0_borderCount = 0; - if (_party._fireShieldDefense > 0) - nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyFireshieldIndice; - if (_party._spellShieldDefense > 0) - nativeBitmapIndices[AL_0_borderCount++] = kBorderPartySpellshieldIndice; - if (_party._shieldDefense > 0) - nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyShieldIndice; - while (AL_0_borderCount--) { - dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, kColorFlesh); - } - if (isInventoryChamp) { - invMan.drawStatusBoxPortrait(champIndex); - champAttributes |= kChampionAttributeStatistics; - } else { - champAttributes |= (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeWounds | kChampionAttributeActionHand); - } - } else { - dispMan.blitToScreen(dispMan.getBitmap(kStatusBoxDeadChampion), 80, 0, 0, box, kColorNoTransparency); - warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen"); - menuMan.drawActionIcon(champIndex); - goto T0292042_green; - } - } - - if (!champ->_currHealth) - goto T0292042_green; - - if(champAttributes & kChampionAttributeNameTitle) { - int16 AL_0_colorIndex = (champIndex == _leaderIndex) ? kColorGold : kColorLightestGray; // unused because of missing functions - if(isInventoryChamp) { - char *champName = champ->_name; - warning("MISSING CODE: F0052_TEXT_PrintToViewport"); - int16 champTitleX = 6 * strlen(champName) + 3; - char champTitleFirstChar = champ->_title[0]; - if ((champTitleFirstChar != ',') && (champTitleFirstChar != ';') && (champTitleFirstChar != '-')) { - champTitleX += 6; - } - warning("MISSING CODE: F0052_TEXT_PrintToViewport"); - champAttributes |= kChampionAttributeViewport; - } else { - box._y1 = 0; - box._y2 = 6 + 1; - box._x1 = champStatusBoxX; - box._x2 = box._x1 + 42 + 1; - dispMan.clearScreenBox(kColorDarkGary, box); - warning("MISSING CODE: F0053_TEXT_PrintToLogicalScreen"); - } - } - - if (champAttributes & kChampionAttributeStatistics) { - drawChampionBarGraphs(champIndex); - if (isInventoryChamp) { - warning("MISSING CODE: F0290_CHAMPION_DrawHealthStaminaManaValues"); - int16 AL_2_nativeBitmapIndex; - if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) { - AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice; - } else { - AL_2_nativeBitmapIndex = kSlotBoxNormalIndice; - } - dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, kColorDarkestGray, gDungeonViewport); - AL_2_nativeBitmapIndex = kSlotBoxNormalIndice; - for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) { - if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent) - < champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum)) { - AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice; - break; - } - } - dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, kColorDarkestGray, gDungeonViewport); - champAttributes |= kChampionAttributeViewport; - } - } - - if (champAttributes & kChampionAttributeWounds) { - for (int16 AL_0_slotIndex = isInventoryChamp ? kChampionSlotFeet : kChampionSlotActionHand; AL_0_slotIndex >= kChampionSlotReadyHand; AL_0_slotIndex--) { - warning("MISSING CODE: F0291_CHAMPION_DrawSlot"); - } - if (isInventoryChamp) { - champAttributes |= kChampionAttributeViewport; - } - } - - if (champAttributes & kChampionAttributeLoad) { - warning("MISSING CODE: whole if branch, many F0052_TEXT_PrintToViewport-s"); - - - - champAttributes |= kChampionAttributeViewport; - } - - { // block so goto won't skip AL_0_championIconIndex initialization - int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir); - - if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != indexToOrdinal(AL_0_championIconIndex))) { - dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]); - dispMan.blitToScreen(dispMan.getBitmap(kChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0, - gBoxChampionIcons[AL_0_championIconIndex], kColorDarkestGray); - } - } - - if ((champAttributes & kChampionAttributePanel) && isInventoryChamp) { - if (_vm->_pressingMouth) { - invMan.drawPanelFoodWaterPoisoned(); - } else if (_vm->_pressingEye) { - if (_leaderEmptyHanded) { - warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics"); - } - } else { - invMan.drawPanel(); - } - champAttributes |= kChampionAttributeViewport; - } - - if (champAttributes & kChampionAttributeActionHand) { - warning("MISSING CODE: F0291_CHAMPION_DrawSlot"); - menuMan.drawActionIcon(champIndex); - if (isInventoryChamp) { - champAttributes |= kChampionAttributeViewport; - } - } - - if (champAttributes & kChampionAttributeViewport) { - warning("MISSGIN CODE: F0097_DUNGEONVIEW_DrawViewport"); - } - - -T0292042_green: - champ->setAttributeFlag((ChampionAttribute)(kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon | - kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport | - kChampionAttributeActionHand), false); - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); -} - -uint16 ChampionMan::championIconIndex(int16 val, direction dir) { - return ((val + 4 - dir) & 0x3); -} - -} +#include "champion.h" +#include "dungeonman.h" +#include "eventman.h" +#include "menus.h" +#include "inventory.h" +#include "objectman.h" +#include "text.h" + + +namespace DM { + +Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth +Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye +Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons + Box(281, 299, 0, 13), + Box(301, 319, 0, 13), + Box(301, 319, 15, 28), + Box(281, 299, 15, 28)}; +Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; // @ G0046_auc_Graphic562_ChampionColor + +uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks + /* 30 for champion inventory, 8 for chest */ + 0xFFFF, /* Ready Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Action Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0x0002, /* Head Head */ + 0x0008, /* Torso Torso */ + 0x0010, /* Legs Legs */ + 0x0020, /* Feet Feet */ + 0x0100, /* Pouch 2 Pouch */ + 0x0080, /* Quiver Line2 1 Quiver 2 */ + 0x0080, /* Quiver Line1 2 Quiver 2 */ + 0x0080, /* Quiver Line2 2 Quiver 2 */ + 0x0004, /* Neck Neck */ + 0x0100, /* Pouch 1 Pouch */ + 0x0040, /* Quiver Line1 1 Quiver 1 */ + 0xFFFF, /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0x0400, /* Chest 1 Chest */ + 0x0400, /* Chest 2 Chest */ + 0x0400, /* Chest 3 Chest */ + 0x0400, /* Chest 4 Chest */ + 0x0400, /* Chest 5 Chest */ + 0x0400, /* Chest 6 Chest */ + 0x0400, /* Chest 7 Chest */ + 0x0400}; /* Chest 8 Chest */ + +Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait + +ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { + _leaderIndex = kChampionNone; + + _partyDead = false; + _partyIsSleeping = false; + _leaderHandObjectIconIndex = kIconIndiceNone; + _leaderEmptyHanded = true; +} + +uint16 ChampionMan::getChampionPortraitX(uint16 index) { + return ((index) & 0x7) << 5; +} + +uint16 ChampionMan::getChampionPortraitY(uint16 index) { + return ((index) >> 3) * 29; +} + +int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) { + int val = 0; + for (uint16 i = 0; i < characterCount; ++i) { + val = (val << 4) + (string[i] - 'A'); + } + return val; +} + +void ChampionMan::drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) { + Common::String tmp = getStringFromInteger(currVal, true, 3).c_str(); + _vm->_textMan->printToViewport(55, posY, kColorLightestGray, tmp.c_str()); + _vm->_textMan->printToViewport(73, posY, kColorLightestGray, "/"); + tmp = getStringFromInteger(maxVal, true, 3); + _vm->_textMan->printToViewport(79, posY, kColorLightestGray, tmp.c_str()); +} + +Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) { + using namespace Common; + String valToStr = String::format("%d", val); + String result; + for (int16 i = 0, end = paddingCharCount - valToStr.size(); i < end; ++i) + result += ' '; + + return result += valToStr; +} + +ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { + for (uint16 i = 0; i < _partyChampionCount; ++i) { + if ((_champions[i]._cell == cell) && _champions[i]._currHealth) + return (ChampionIndex)i; + } + + return kChampionNone; +} + +void ChampionMan::resetDataToStartGame() { + if (!_vm->_dungeonMan->_messages._newGame) { + warning("MISSING CODE: stuff for resetting for loaded games"); + assert(false); + } + + _leaderHand = Thing::_thingNone; + _leaderHandObjectIconIndex = kIconIndiceNone; + _leaderEmptyHanded = true; +} + + +void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { + DisplayMan &dispMan = *_vm->_displayMan; + DungeonMan &dunMan = *_vm->_dungeonMan; + + if (!_leaderEmptyHanded || _partyChampionCount == 4) + return; + + uint16 prevChampCount = _partyChampionCount; + Champion *champ = &_champions[prevChampCount]; + champ->resetToZero(); + dispMan._useByteBoxCoordinates = true; + { // limit destBox scope + Box &destBox = gBoxChampionPortrait; + dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), + champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency); + } + + champ->_actionIndex = kChampionActionNone; + champ->_enableActionEventIndex = -1; + champ->_hideDamageReceivedIndex = -1; + champ->_dir = dunMan._currMap._partyDir; + ViewCell AL_0_viewCell = kViewCellFronLeft; + while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone) + AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); + champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3); + champ->clearAttributes(kChampionAttributeIcon); + champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir; + champ->_food = 1500 + _vm->_rnd->getRandomNumber(256); + champ->_water = 1500 + _vm->_rnd->getRandomNumber(256); + int16 AL_0_slotIndex_Red; + for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) { + champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone); + } + Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY); + while (thing.getType() != kTextstringType) { + thing = dunMan.getNextThing(thing); + } + char decodedChampionText[77]; + char* character_Green = decodedChampionText; + dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible)); + int16 AL_0_characterIndex = 0; + uint16 AL_2_character; + while ((AL_2_character = *character_Green++) != '\n') { + champ->_name[AL_0_characterIndex++] = AL_2_character; + } + champ->_name[AL_0_characterIndex] = '\0'; + AL_0_characterIndex = 0; + bool AL_4_champTitleCopied = false; + for (;;) { // infinite + AL_2_character = *character_Green++; + if (AL_2_character == '\n') { + if (AL_4_champTitleCopied) + break; + AL_4_champTitleCopied = true; + } else { + champ->_title[AL_0_characterIndex++] = AL_2_character; + } + } + champ->_title[AL_0_characterIndex] = '\0'; + if (*character_Green++ == 'M') { + champ->setAttributeFlag(kChampionAttributeMale, true); + } + character_Green++; + champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4); + character_Green += 4; + champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4); + character_Green += 4; + champ->_currMana = champ->_maxMana = getDecodedValue(character_Green, 4); + character_Green += 4; + character_Green++; + + int16 AL_0_statisticIndex; + for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) { + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30); + uint16 currMaxVal = getDecodedValue(character_Green, 2); + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal); + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal); + character_Green += 2; + } + + champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10); + character_Green++; + + int16 AL_0_skillIndex; + int16 AL_2_skillValue; + for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) { + if ((AL_2_skillValue = *character_Green++ - 'A') > 0) { + champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue); + } + } + + for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) { + int32 baseSkillExp = 0; + int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2; + for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) { + baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience; + } + champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp); + } + + _candidateChampionOrdinal = prevChampCount + 1; + if (++_partyChampionCount == 1) { + _vm->_eventMan->commandSetLeader(kChampionFirst); + _vm->_menuMan->_shouldRefreshActionArea = true; + } else { + _vm->_menuMan->clearActingChampion(); + _vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1)); + } + + int16 mapX = _vm->_dungeonMan->_currMap._partyPosX; + int16 mapY = _vm->_dungeonMan->_currMap._partyPosY; + + uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir)); + mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir]; + mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir]; + thing = dunMan.getSquareFirstThing(mapX, mapY); + AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1; + uint16 slotIndex_Green; + while (thing != Thing::_thingEndOfList) { + ThingType AL_2_thingType = thing.getType(); + if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) { + int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots(); + switch (AL_2_thingType) { + case kArmourThingType: + for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) { + if (objectAllowedSlots & gSlotMasks[slotIndex_Green]) + goto T0280048; + } + if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { + slotIndex_Green = kChampionSlotNeck; + } else { + goto T0280046; + } + break; + case kWeaponThingType: + if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) { + slotIndex_Green = kChampionSlotActionHand; + } else { + goto T0280046; + } + break; + case kScrollThingType: + case kPotionThingType: + if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) { + slotIndex_Green = kChampionSlotPouch_1; + } else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) { + slotIndex_Green = kChampionSlotPouch_2; + } else { + goto T0280046; + } + break; + case kContainerThingType: + case kJunkThingType: +T0280046: + if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { + slotIndex_Green = kChampionSlotNeck; + } else { + slotIndex_Green = AL_0_slotIndex_Red++; + } + break; + } +T0280048: + if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) { + goto T0280046; + } + warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot"); + } + thing = dunMan.getNextThing(thing); + } + + _vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount); + _vm->_menuMan->drawDisabledMenu(); +} + +void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { + + Champion *curChampion = &_champions[champIndex]; + int16 barGraphIndex = 0; + int16 barGraphHeightArray[3]; + + if (curChampion->_currHealth > 0) { + uint32 barGraphHeight = (((uint32)(curChampion->_currHealth) << 10) * 25) / curChampion->_maxHealth; + if (barGraphHeight & 0x3FF) { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; + } else { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); + } + } else { + barGraphHeightArray[barGraphIndex++] = 0; + } + + if (curChampion->_currStamina > 0) { + uint32 barGraphHeight = (((uint32)(curChampion->_currStamina) << 10) * 25) / curChampion->_maxStamina; + if (barGraphHeight & 0x3FF) { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; + } else { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); + } + } else { + barGraphHeightArray[barGraphIndex++] = 0; + } + + if (curChampion->_currMana > 0) { + uint32 barGraphHeight = (((uint32)(curChampion->_currMana) << 10) * 25) / curChampion->_maxMana; + if (barGraphHeight & 0x3FF) { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; + } else { + barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); + } + } else { + barGraphHeightArray[barGraphIndex++] = 0; + } + warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + + Box box; + box._x1 = champIndex * kChampionStatusBoxSpacing + 46; + box._x2 = box._x1 + 3 + 1; + box._y1 = 2; + box._y2 = 26 + 1; + + for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) { + int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex]; + if (barGraphHeight < 25) { + box._y1 = 2; + box._y1 = 27 - barGraphHeight + 1; + _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); + } + if (barGraphHeight) { + box._y1 = 27 - barGraphHeight; + box._y2 = 26 + 1; + _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); + } + box._x1 += 7; + box._x2 += 7; + } + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); +} + + +uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) { + int16 currStamina = champ->_currStamina; + int16 halfMaxStamina = champ->_maxStamina / 2; + if (currStamina < halfMaxStamina) { + warning("Possible undefined behavior in the original code"); + val /= 2; + return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina; + } + return val; +} + +uint16 ChampionMan::getMaximumLoad(Champion *champ) { + uint16 maximumLoad = champ->getStatistic(kChampionStatStrength, kChampionStatCurrent) * 8 + 100; + maximumLoad = getStaminaAdjustedValue(champ, maximumLoad); + int16 wounds = champ->getWounds(); + if (wounds) { + maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kChampionWoundLegs) ? 2 : 3); + } + if (_vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotFeet)) == kIconIndiceArmourElvenBoots) { + maximumLoad += maximumLoad * 16; + } + maximumLoad += 9; + maximumLoad -= maximumLoad % 10; + return maximumLoad; +} + +void ChampionMan::drawChampionState(ChampionIndex champIndex) { + InventoryMan &invMan = *_vm->_inventoryMan; + DisplayMan &dispMan = *_vm->_displayMan; + MenuMan &menuMan = *_vm->_menuMan; + EventManager &eventMan = *_vm->_eventMan; + + Box box; + int16 champStatusBoxX = champIndex * kChampionStatusBoxSpacing; + Champion *champ = &_champions[champIndex]; + uint16 champAttributes = champ->getAttributes(); + if (!((champAttributes) & (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon | + kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport | + kChampionAttributeActionHand))) { + return; + } + bool isInventoryChamp = (indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal); + dispMan._useByteBoxCoordinates = false; + if (champAttributes & kChampionAttributeStatusBox) { + box._y1 = 0; + box._y2 = 28 + 1; + box._x1 = champStatusBoxX; + box._x2 = box._x1 + 66 + 1; + if (champ->_currHealth) { + dispMan.clearScreenBox(kColorDarkestGray, box); + int16 nativeBitmapIndices[3]; + for (int16 i = 0; i < 3; ++i) + nativeBitmapIndices[i] = 0; + int16 AL_0_borderCount = 0; + if (_party._fireShieldDefense > 0) + nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyFireshieldIndice; + if (_party._spellShieldDefense > 0) + nativeBitmapIndices[AL_0_borderCount++] = kBorderPartySpellshieldIndice; + if (_party._shieldDefense > 0) + nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyShieldIndice; + while (AL_0_borderCount--) { + dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, kColorFlesh); + } + if (isInventoryChamp) { + invMan.drawStatusBoxPortrait(champIndex); + champAttributes |= kChampionAttributeStatistics; + } else { + champAttributes |= (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeWounds | kChampionAttributeActionHand); + } + } else { + dispMan.blitToScreen(dispMan.getBitmap(kStatusBoxDeadChampion), 80, 0, 0, box, kColorNoTransparency); + _vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, kColorLightestGray, kColorDarkGary, champ->_name); + menuMan.drawActionIcon(champIndex); + goto T0292042_green; + } + } + + if (!champ->_currHealth) + goto T0292042_green; + + if (champAttributes & kChampionAttributeNameTitle) { + Color AL_0_colorIndex = (champIndex == _leaderIndex) ? kColorGold : kColorLightestGray; // unused because of missing functions + if (isInventoryChamp) { + char *champName = champ->_name; + _vm->_textMan->printToViewport(3, 7, AL_0_colorIndex, champName); + int16 champTitleX = 6 * strlen(champName) + 3; + char champTitleFirstChar = champ->_title[0]; + if ((champTitleFirstChar != ',') && (champTitleFirstChar != ';') && (champTitleFirstChar != '-')) { + champTitleX += 6; + } + _vm->_textMan->printToViewport(champTitleX, 7, AL_0_colorIndex, champ->_title); + champAttributes |= kChampionAttributeViewport; + } else { + box._y1 = 0; + box._y2 = 6 + 1; + box._x1 = champStatusBoxX; + box._x2 = box._x1 + 42 + 1; + dispMan.clearScreenBox(kColorDarkGary, box); + _vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, kColorDarkGary, champ->_name); + } + } + + if (champAttributes & kChampionAttributeStatistics) { + drawChampionBarGraphs(champIndex); + if (isInventoryChamp) { + drawHealthStaminaManaValues(champ); + int16 AL_2_nativeBitmapIndex; + if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) { + AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice; + } else { + AL_2_nativeBitmapIndex = kSlotBoxNormalIndice; + } + dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, kColorDarkestGray, gDungeonViewport); + AL_2_nativeBitmapIndex = kSlotBoxNormalIndice; + for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) { + if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent) + < champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum)) { + AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice; + break; + } + } + dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, kColorDarkestGray, gDungeonViewport); + champAttributes |= kChampionAttributeViewport; + } + } + + if (champAttributes & kChampionAttributeWounds) { + for (int16 AL_0_slotIndex = isInventoryChamp ? kChampionSlotFeet : kChampionSlotActionHand; AL_0_slotIndex >= kChampionSlotReadyHand; AL_0_slotIndex--) { + warning("MISSING CODE: F0291_CHAMPION_DrawSlot"); + } + if (isInventoryChamp) { + champAttributes |= kChampionAttributeViewport; + } + } + + if (champAttributes & kChampionAttributeLoad) { + warning("MISSING CODE: whole if branch, many F0052_TEXT_PrintToViewport-s"); + + + + champAttributes |= kChampionAttributeViewport; + } + + { // block so goto won't skip AL_0_championIconIndex initialization + int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir); + + if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != indexToOrdinal(AL_0_championIconIndex))) { + dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]); + dispMan.blitToScreen(dispMan.getBitmap(kChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0, + gBoxChampionIcons[AL_0_championIconIndex], kColorDarkestGray); + } + } + + if ((champAttributes & kChampionAttributePanel) && isInventoryChamp) { + if (_vm->_pressingMouth) { + invMan.drawPanelFoodWaterPoisoned(); + } else if (_vm->_pressingEye) { + if (_leaderEmptyHanded) { + warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics"); + } + } else { + invMan.drawPanel(); + } + champAttributes |= kChampionAttributeViewport; + } + + if (champAttributes & kChampionAttributeActionHand) { + warning("MISSING CODE: F0291_CHAMPION_DrawSlot"); + menuMan.drawActionIcon(champIndex); + if (isInventoryChamp) { + champAttributes |= kChampionAttributeViewport; + } + } + + if (champAttributes & kChampionAttributeViewport) { + warning("MISSGIN CODE: F0097_DUNGEONVIEW_DrawViewport"); + } + + +T0292042_green: + champ->setAttributeFlag((ChampionAttribute)(kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon | + kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport | + kChampionAttributeActionHand), false); + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); +} + +uint16 ChampionMan::championIconIndex(int16 val, direction dir) { + return ((val + 4 - dir) & 0x3); +} + +void ChampionMan::drawHealthStaminaManaValues(Champion* champ) { + drawHealthOrStaminaOrManaValue(116, champ->_currHealth, champ->_maxHealth); + drawHealthOrStaminaOrManaValue(124, champ->_currStamina, champ->_maxStamina); + drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana); +} + +} diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 4e9e29d9c7..4cc32c51f4 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -1,6 +1,8 @@ #ifndef DM_CHAMPION_H #define DM_CHAMPION_H +#include "common/str.h" + #include "dm.h" #include "gfx.h" @@ -390,6 +392,8 @@ class ChampionMan { ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue + void drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue + Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger public: Champion _champions[4]; uint16 _partyChampionCount; // @ G0305_ui_PartyChampionCount @@ -411,6 +415,7 @@ public: uint16 getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad void drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState uint16 championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX + void drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues }; diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index bbf0c7ddd1..6ff8b7a58e 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1,5 +1,6 @@ #include "common/file.h" #include "common/memstream.h" + #include "dungeonman.h" diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index c5c356e888..59e1a821c5 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -2,7 +2,6 @@ #define DUNGEONMAN_H #include "dm.h" -#include "dungeonman.h" #include "gfx.h" diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index e2713a2536..18aaebe957 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -544,9 +544,9 @@ byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, -Viewport gDefultViewPort = {0, 0}; +Viewport gDefultViewPort = {0, 0, 320, 200}; // TODO: I guessed the numbers -Viewport gDungeonViewport = {0, 33}; // @ G0296_puc_Bitmap_Viewport +Viewport gDungeonViewport = {0, 33, 224, 126}; // @ G0296_puc_Bitmap_Viewport byte gPalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges @@ -684,7 +684,7 @@ void DisplayMan::unpackGraphics() { unpackedBitmapsSize += getWidth(i) * getHeight(i); for (uint16 i = 22; i <= 532; ++i) unpackedBitmapsSize += getWidth(i) * getHeight(i); - unpackedBitmapsSize += (5 + 1) * (6 + 1) * 128; // 5 x 6 characters, 128 of them, +1 for convenience padding + unpackedBitmapsSize += (5 + 1) * 6 * 128; // 5 x 6 characters, 128 of them, +1 for convenience padding // graphics items go from 0-20 and 22-532 inclusive, _unpackedItemPos 21 and 22 are there for indexing convenience if (_bitmaps) { delete[] _bitmaps[0]; @@ -719,8 +719,6 @@ void DisplayMan::loadFNT1intoBitmap(uint16 index, byte* destBitmap) } } } - memset(data, 0, 128); - data += 128; } void DisplayMan::loadPalette(uint16 *palette) { diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index e2f30f339c..ed246de912 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -7,6 +7,7 @@ namespace DM { + enum ViewCell { kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT @@ -144,9 +145,10 @@ enum Color { kColorWhite = 15 }; + struct Viewport { - // TODO: should probably add width and height, seems redundant right meow uint16 _posX, _posY; + uint16 _width, _height; }; struct CreatureAspect { diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index a67d308e68..271fd3b879 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -3,6 +3,7 @@ #include "eventman.h" #include "menus.h" #include "gfx.h" +#include "text.h" @@ -68,9 +69,9 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { if (cm._candidateChampionOrdinal) { dm.clearScreenBox(kColorDarkestGray, gBoxFloppyZzzCross, gDungeonViewport); } - warning("MISSING CODE: F0052_TEXT_PrintToViewport -> HEALTH"); - warning("MISSING CODE: F0052_TEXT_PrintToViewport -> STAMINA"); - warning("MISSING CODE: F0052_TEXT_PrintToViewport -> MANA"); + _vm->_textMan->printToViewport(5, 116, kColorLightestGray, "HEALTH"); + _vm->_textMan->printToViewport(5, 124, kColorLightestGray, "STAMINA"); + _vm->_textMan->printToViewport(5, 132, kColorLightestGray, "MANA"); warning("MISSING CODE: F0291_CHAMPION_DrawSlot in LOOOOOOOOOOOOP"); diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index d6d005fed4..5ad2ac7b6a 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -8,36 +8,42 @@ TextMan::TextMan(DMEngine* vm) : _vm(vm) {} #define kLetterWidth 5 #define kLetterHeight 6 -void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, Color textColor, Color bgColor, char* text, uint16 destHeight, Viewport &viewport) { +void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, + Color textColor, Color bgColor, const char* text, uint16 destHeight, Viewport &viewport) { + destX -= 1; // fixes missalignment, to be checked + destY -= 4; // fixes missalignment, to be checked + uint16 textLength = strlen(text); uint16 nextX = destX; uint16 nextY = destY; byte *srcBitmap = _vm->_displayMan->getBitmap(kFontGraphicIndice); byte *tmp = _vm->_displayMan->_tmpBitmap; - for (uint16 i = 0; i < (kLetterWidth + 1) * (kLetterHeight + 1) * 128; ++i) { + for (uint16 i = 0; i < (kLetterWidth + 1) * kLetterHeight * 128; ++i) { tmp[i] = srcBitmap[i] ? textColor : bgColor; } srcBitmap = tmp; - - for (char *begin = text, *end = text + textLength; begin != end; ++begin) { - // Note: this does no wraps in the middle of words - if (nextX + kLetterWidth + 1 > destPixelWidth || (*begin == '\n')) { + for (const char *begin = text, *end = text + textLength; begin != end; ++begin) { + if (nextX + kLetterWidth + 1 >= (viewport._posX + viewport._width) || (*begin == '\n')) { nextX = destX; nextY += kLetterHeight + 1; } - if (nextY + kLetterHeight + 1 > destHeight) + if (nextY + kLetterHeight >= (viewport._posY + viewport._height)) break; uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code - _vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, srcX, 0, destBitmap, destPixelWidth, - nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight + 1, kColorNoTransparency, viewport); + _vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth, + (nextX == destX) ? (nextX + 1) : nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight, kColorNoTransparency, viewport); nextX += kLetterWidth + 1; } } -void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, char* text, Viewport &viewport) { +void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text, Viewport &viewport) { printTextToBitmap(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport); } +void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text) { + printTextToScreen(posX, posY, textColor, kColorDarkestGray, text, gDungeonViewport); +} + } diff --git a/engines/dm/text.h b/engines/dm/text.h index 7f57525012..baf9b72851 100644 --- a/engines/dm/text.h +++ b/engines/dm/text.h @@ -11,8 +11,9 @@ class TextMan { public: TextMan(DMEngine *vm); void printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, - Color textColor, Color bgColor, char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print - void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, char *text, Viewport &viewport = gDefultViewPort); + Color textColor, Color bgColor, const char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print + void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, Viewport &viewport = gDefultViewPort); // @ F0053_TEXT_PrintToLogicalScreen + void printToViewport(int16 posX, int16 posY, Color textColor, const char *text); // @ F0052_TEXT_PrintToViewport }; } -- cgit v1.2.3 From a72bfe712da048fce3f32375826cd5724c6f9508 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 22 Jun 2016 23:20:58 +0200 Subject: DM: Fix link --- engines/dm/module.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/dm/module.mk b/engines/dm/module.mk index 3a7fa1038c..bc36e8b6eb 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -10,7 +10,8 @@ MODULE_OBJS := \ champion.o \ loadsave.o \ objectman.o \ - inventory.o + inventory.o \ + text.o MODULE_DIRS += \ engines/dm -- cgit v1.2.3 From 0ad91dfe6723e04271cbb44e7ccbce3071e1af6a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 22 Jun 2016 23:21:18 +0200 Subject: DM: Add missing explicit keyword --- engines/dm/text.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/dm/text.h b/engines/dm/text.h index baf9b72851..d273de3041 100644 --- a/engines/dm/text.h +++ b/engines/dm/text.h @@ -9,7 +9,7 @@ namespace DM { class TextMan { DMEngine *_vm; public: - TextMan(DMEngine *vm); + explicit TextMan(DMEngine *vm); void printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, Viewport &viewport = gDefultViewPort); // @ F0053_TEXT_PrintToLogicalScreen -- cgit v1.2.3 From 8ffd4a0bad2015af360d0949f5f12a02f5b93c1d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 23 Jun 2016 00:39:27 +0200 Subject: DM: Add some default statements in switches, change the scope of namespace DM in gfx.cpp --- engines/dm/gfx.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 18aaebe957..f430a6f769 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -558,9 +558,7 @@ byte gAlcoveOrnIndices[kAlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrna 1, /* Square Alcove */ 2, /* Vi Altar */ 3}; /* Arched Alcove */ -} -using namespace DM; DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _vgaBuffer = nullptr; @@ -805,13 +803,14 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight } void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) { - for (uint16 y = 0; y < height; ++y) + for (uint16 y = 0; y < height; ++y) { for (uint16 x = 0; x < width / 2; ++x) { byte tmp; tmp = bitmap[y*width + x]; bitmap[y*width + x] = bitmap[y*width + width - 1 - x]; bitmap[y*width + width - 1 - x] = tmp; } + } } void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) { @@ -875,6 +874,8 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { // ... missing code } break; + default: + break; } } @@ -895,6 +896,8 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { // ... missing code } break; + default: + break; } } void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) { @@ -913,6 +916,8 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) { //... missing code } break; + default: + break; } } void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) { @@ -935,6 +940,8 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) { case kStairsSideElemType: drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2L]); break; + default: + break; } } void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) { @@ -957,6 +964,8 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) { case kStairsSideElemType: drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]); break; + default: + break; } } void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) { @@ -975,6 +984,8 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) { // ... missing code } break; + default: + break; } } void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) { @@ -997,6 +1008,8 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) { else drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1L]); break; + default: + break; } } void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) { @@ -1019,6 +1032,8 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) { else drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1R]); break; + default: + break; } } void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) { @@ -1040,6 +1055,8 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) { // .... code not yet implemneted } break; + default: + break; } } @@ -1054,6 +1071,8 @@ void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) { case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]); break; + default: + break; } } @@ -1068,6 +1087,8 @@ void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) { case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D0R], gFrameWalls[kViewSquare_D0R]); break; + default: + break; } } @@ -1084,6 +1105,8 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) { drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0R]); } break; + default: + break; } } @@ -1531,3 +1554,5 @@ void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uin Color transparent, Viewport &viewport) { blitToScreen(srcBitmap, srcWidth, srcX, srcY, box._x1, box._x2, box._y1, box._y2, transparent, viewport); } + +} -- cgit v1.2.3 From 2f6e8a8e64ac2e5bc641532f0dd2ff10915cc469 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 23 Jun 2016 01:57:37 +0200 Subject: DM: Add G0030_as_Graphic562_SlotBoxes, SLOT_BOX, F0038_OBJECT_DrawIconInSlotBox --- engines/dm/objectman.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++++++-- engines/dm/objectman.h | 15 +++++++++ 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index c237b914a2..87d6992907 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -4,6 +4,55 @@ namespace DM { +SlotBox gSlotBoxes[46] = { +/* 8 for champion hands in status boxes, 30 for champion inventory, 8 for chest */ + SlotBox(4, 10, 0), /* Champion Status Box 0 Ready Hand */ + SlotBox(24, 10, 0), /* Champion Status Box 0 Action Hand */ + SlotBox(73, 10, 0), /* Champion Status Box 1 Ready Hand */ + SlotBox(93, 10, 0), /* Champion Status Box 1 Action Hand */ + SlotBox(142, 10, 0), /* Champion Status Box 2 Ready Hand */ + SlotBox(162, 10, 0), /* Champion Status Box 2 Action Hand */ + SlotBox(211, 10, 0), /* Champion Status Box 3 Ready Hand */ + SlotBox(231, 10, 0), /* Champion Status Box 3 Action Hand */ + SlotBox(6, 53, 0), /* Ready Hand */ + SlotBox(62, 53, 0), /* Action Hand */ + SlotBox(34, 26, 0), /* Head */ + SlotBox(34, 46, 0), /* Torso */ + SlotBox(34, 66, 0), /* Legs */ + SlotBox(34, 86, 0), /* Feet */ + SlotBox(6, 90, 0), /* Pouch 2 */ + SlotBox(79, 73, 0), /* Quiver Line2 1 */ + SlotBox(62, 90, 0), /* Quiver Line1 2 */ + SlotBox(79, 90, 0), /* Quiver Line2 2 */ + SlotBox(6, 33, 0), /* Neck */ + SlotBox(6, 73, 0), /* Pouch 1 */ + SlotBox(62, 73, 0), /* Quiver Line1 1 */ + SlotBox(66, 33, 0), /* Backpack Line1 1 */ + SlotBox(83, 16, 0), /* Backpack Line2 2 */ + SlotBox(100, 16, 0), /* Backpack Line2 3 */ + SlotBox(117, 16, 0), /* Backpack Line2 4 */ + SlotBox(134, 16, 0), /* Backpack Line2 5 */ + SlotBox(151, 16, 0), /* Backpack Line2 6 */ + SlotBox(168, 16, 0), /* Backpack Line2 7 */ + SlotBox(185, 16, 0), /* Backpack Line2 8 */ + SlotBox(202, 16, 0), /* Backpack Line2 9 */ + SlotBox(83, 33, 0), /* Backpack Line1 2 */ + SlotBox(100, 33, 0), /* Backpack Line1 3 */ + SlotBox(117, 33, 0), /* Backpack Line1 4 */ + SlotBox(134, 33, 0), /* Backpack Line1 5 */ + SlotBox(151, 33, 0), /* Backpack Line1 6 */ + SlotBox(168, 33, 0), /* Backpack Line1 7 */ + SlotBox(185, 33, 0), /* Backpack Line1 8 */ + SlotBox(202, 33, 0), /* Backpack Line1 9 */ + SlotBox(117, 59, 0), /* Chest 1 */ + SlotBox(106, 76, 0), /* Chest 2 */ + SlotBox(111, 93, 0), /* Chest 3 */ + SlotBox(128, 98, 0), /* Chest 4 */ + SlotBox(145, 101, 0), /* Chest 5 */ + SlotBox(162, 103, 0), /* Chest 6 */ + SlotBox(179, 104, 0), /* Chest 7 */ + SlotBox(196, 105, 0)}; /* Chest 8 */ + int16 gIconGraphicHeight[7] = {32, 32, 32, 32, 32, 32, 32}; // @ K0077_ai_IconGraphicHeight int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex @@ -34,7 +83,7 @@ IconIndice ObjectMan::getIconIndex(Thing thing) { IconIndice iconIndex = getObjectType(thing); if ((iconIndex != kIconIndiceNone) && - ((iconIndex < kIconIndiceWeaponDagger) &&(iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error + ((iconIndex < kIconIndiceWeaponDagger) && (iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error ((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) || (iconIndex == kIconIndicePotionEmptyFlask) ) { @@ -91,4 +140,34 @@ void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { } -} \ No newline at end of file +void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { + SlotBox *slotBox = &gSlotBoxes[slotBoxIndex]; + slotBox->_iconIndex = iconIndex; // yes, this modifies the global array + if (slotBox->_iconIndex == kIconIndiceNone) { + return; + } + Box box; + box._x1 = slotBox->_x; + box._y1 = slotBox->_y; + box._x2 = box._x1 + 15; // no need to add +1, comes from a global array + box._y2 = box._y1 + 15; // no need to add +1, comes from a global array + + uint16 iconGraphicIndex; + for (iconGraphicIndex = 0; iconGraphicIndex < 7; ++iconGraphicIndex) { + if (gIconGraphicFirstIndex[iconGraphicIndex] > iconIndex) { + break; + } + } + iconGraphicIndex--; + byte *iconsBitmap = _vm->_displayMan->getBitmap(iconGraphicIndex + kObjectIcons_000_TO_031); + iconIndex -= gIconGraphicFirstIndex[iconGraphicIndex]; + + _vm->_displayMan->_useByteBoxCoordinates = false; + if (slotBoxIndex >= kSlotBoxInventoryFirstSlot) { + _vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, box, kColorNoTransparency, gDungeonViewport); + } else { + _vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, box, kColorNoTransparency, gDefultViewPort); + } +} + +} diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index dd0150d747..fd0f5a1b6f 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -4,6 +4,20 @@ namespace DM { +#define kSlotBoxInventoryFirstSlot 8 // @ C08_SLOT_BOX_INVENTORY_FIRST_SLOT +#define kSlotBoxInventoryActionHand 9 // @ C09_SLOT_BOX_INVENTORY_ACTION_HAND +#define kSlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT + +class SlotBox { +public: + int16 _x; + int16 _y; + int16 _iconIndex; + SlotBox(int16 x, int16 y, int16 iconIndex): _x(x), _y(y), _iconIndex(iconIndex) {} +}; // @ SLOT_BOX + +extern SlotBox gSlotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes; + class ObjectMan { DMEngine *_vm; public: @@ -12,6 +26,7 @@ public: IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex void extractIconFromBitmap(uint16 iconIndex, byte *srcBitmap); // F0036_OBJECT_ExtractIconFromBitmap + void drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox }; } -- cgit v1.2.3 From 94bd6db7a61af0d5552f86eac06c785a027041bc Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 23 Jun 2016 03:16:36 +0200 Subject: DM: Add F0291_CHAMPION_DrawSlot, G0425_aT_ChestSlots and constructor to Viewport, swap some warnings for code --- engines/dm/champion.cpp | 91 ++++++++++++++++++++++++++++++++++++++++++++++-- engines/dm/champion.h | 1 + engines/dm/gfx.cpp | 4 +-- engines/dm/gfx.h | 9 +++-- engines/dm/inventory.cpp | 6 +++- engines/dm/inventory.h | 1 + engines/dm/objectman.cpp | 10 +++--- 7 files changed, 111 insertions(+), 11 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 79f4267c7d..2899f9093c 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -492,7 +492,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { if (champAttributes & kChampionAttributeWounds) { for (int16 AL_0_slotIndex = isInventoryChamp ? kChampionSlotFeet : kChampionSlotActionHand; AL_0_slotIndex >= kChampionSlotReadyHand; AL_0_slotIndex--) { - warning("MISSING CODE: F0291_CHAMPION_DrawSlot"); + drawSlot(champIndex, (ChampionSlot)AL_0_slotIndex); } if (isInventoryChamp) { champAttributes |= kChampionAttributeViewport; @@ -531,7 +531,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { } if (champAttributes & kChampionAttributeActionHand) { - warning("MISSING CODE: F0291_CHAMPION_DrawSlot"); + drawSlot(champIndex, kChampionSlotActionHand); menuMan.drawActionIcon(champIndex); if (isInventoryChamp) { champAttributes |= kChampionAttributeViewport; @@ -560,4 +560,91 @@ void ChampionMan::drawHealthStaminaManaValues(Champion* champ) { drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana); } +void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { + int16 nativeBitmapIndex = -1; + Champion *champ = &_champions[champIndex]; + bool isInventoryChamp = (_vm->_inventoryMan->_inventoryChampionOrdinal == indexToOrdinal(champIndex)); + + uint16 slotBoxIndex; + if (!isInventoryChamp) { /* If drawing a slot for a champion other than the champion whose inventory is open */ + if ((slotIndex > kChampionSlotActionHand) || (_candidateChampionOrdinal == indexToOrdinal(champIndex))) { + return; + } + slotBoxIndex = (champIndex << 1) + slotIndex; + } else { + slotBoxIndex = kSlotBoxInventoryFirstSlot + slotIndex; + } + + Thing thing; + if (slotIndex >= kChampionSlotChest_1) { + thing = _vm->_inventoryMan->_chestSlots[slotIndex - kChampionSlotChest_1]; + } else { + thing = champ->getSlot(slotIndex); + } + + SlotBox *slotBox = &gSlotBoxes[slotBoxIndex]; + Box box; + box._x1 = slotBox->_x - 1; + box._y1 = slotBox->_y - 1; + box._x2 = box._x1 + 17 + 1; + box._y2 = box._y1 + 17 + 1; + + + if (!isInventoryChamp) { + warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + } + + int16 iconIndex; + if (thing == Thing::_thingNone) { + if (slotIndex <= kChampionSlotFeet) { + iconIndex = kIconIndiceReadyHand + (slotIndex << 1); + if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) { + iconIndex++; + nativeBitmapIndex = kSlotBoxWoundedIndice; + } else { + nativeBitmapIndex = kSlotBoxNormalIndice; + } + } else { + if ((slotIndex >= kChampionSlotNeck) && (slotIndex <= kChampionSlotBackpackLine_1_1)) { + iconIndex = kIconIndiceNeck + (slotIndex - kChampionSlotNeck); + } else { + iconIndex = kIconIndiceEmptyBox; + } + } + } else { + warning("BUG0_35"); + iconIndex = _vm->_objectMan->getIconIndex(thing); // BUG0_35 + if (isInventoryChamp && (slotIndex == kChampionSlotActionHand) && ((iconIndex == kIconIndiceContainerChestClosed) || (iconIndex == kIconIndiceScrollOpen))) { + warning("BUG2_00"); + iconIndex++; + } // BUG2_00 + if (slotIndex <= kChampionSlotFeet) { + if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) { + nativeBitmapIndex = kSlotBoxWoundedIndice; + } else { + nativeBitmapIndex = kSlotBoxNormalIndice; + } + } + } + + if ((slotIndex == kChampionSlotActionHand) && (indexToOrdinal(champIndex) == _actingChampionOrdinal)) { + nativeBitmapIndex = kSlotBoxActingHandIndice; + } + + if (nativeBitmapIndex != -1) { + _vm->_displayMan->_useByteBoxCoordinates = false; + _vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0, + box, kColorDarkestGray, isInventoryChamp ? gDungeonViewport : gDefultViewPort); + } + + _vm->_objectMan->drawIconInSlotBox(slotBoxIndex, iconIndex); + + if (!isInventoryChamp) { + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + } } + + +} + + diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 4cc32c51f4..2b2aaf9cb1 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -416,6 +416,7 @@ public: void drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState uint16 championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX void drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues + void drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot }; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index f430a6f769..8c38f4bb25 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -544,9 +544,9 @@ byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, -Viewport gDefultViewPort = {0, 0, 320, 200}; +Viewport gDefultViewPort(0, 0, 320, 200); // TODO: I guessed the numbers -Viewport gDungeonViewport = {0, 33, 224, 126}; // @ G0296_puc_Bitmap_Viewport +Viewport gDungeonViewport(0, 33, 224, 126); // @ G0296_puc_Bitmap_Viewport byte gPalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index ed246de912..5e0307e7df 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -42,7 +42,8 @@ enum GraphicIndice { kSlotBoxNormalIndice = 33, // @ C033_GRAPHIC_SLOT_BOX_NORMAL kSlotBoxWoundedIndice = 34, // @ C034_GRAPHIC_SLOT_BOX_WOUNDED kChampionIcons = 28, // @ C028_GRAPHIC_CHAMPION_ICONS - kFontGraphicIndice = 557 // @ C557_GRAPHIC_FONT + kFontGraphicIndice = 557, // @ C557_GRAPHIC_FONT + kSlotBoxActingHandIndice = 35 // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND }; extern uint16 gPalSwoosh[16]; @@ -146,9 +147,13 @@ enum Color { }; -struct Viewport { +class Viewport { +public: uint16 _posX, _posY; uint16 _width, _height; + Viewport() {} + Viewport(uint16 posX, uint16 posY, uint16 width, uint16 height) + :_posX(posX), _posY(posY), _width(width), _height(height) {} }; struct CreatureAspect { diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 271fd3b879..31b495ca2b 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -17,6 +17,8 @@ Box gBoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) { _panelContent = kPanelContentFoodWaterPoisoned; + for (uint16 i = 0; i < 8; ++i) + _chestSlots[i] = Thing::_thingNone; } void InventoryMan::toggleInventory(ChampionIndex championIndex) { @@ -73,7 +75,9 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { _vm->_textMan->printToViewport(5, 124, kColorLightestGray, "STAMINA"); _vm->_textMan->printToViewport(5, 132, kColorLightestGray, "MANA"); - warning("MISSING CODE: F0291_CHAMPION_DrawSlot in LOOOOOOOOOOOOP"); + for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) { + _vm->_championMan->drawSlot(championIndex, (ChampionSlot)slotIndex); + } champion->setAttributeFlag(kChampionAttributeViewport, true); champion->setAttributeFlag(kChampionAttributeStatusBox, true); diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index b8fbe516a5..45bc3e9007 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -25,6 +25,7 @@ public: int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal PanelContent _panelContent; // @ G0424_i_PanelContent + Thing _chestSlots[8]; // @ G0425_aT_ChestSlots void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 87d6992907..96f95798f7 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -149,8 +149,8 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { Box box; box._x1 = slotBox->_x; box._y1 = slotBox->_y; - box._x2 = box._x1 + 15; // no need to add +1, comes from a global array - box._y2 = box._y1 + 15; // no need to add +1, comes from a global array + box._x2 = box._x1 + 15 + 1; + box._y2 = box._y1 + 15 + 1; uint16 iconGraphicIndex; for (iconGraphicIndex = 0; iconGraphicIndex < 7; ++iconGraphicIndex) { @@ -164,9 +164,11 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { _vm->_displayMan->_useByteBoxCoordinates = false; if (slotBoxIndex >= kSlotBoxInventoryFirstSlot) { - _vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, box, kColorNoTransparency, gDungeonViewport); + _vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, + box, kColorNoTransparency, gDungeonViewport); } else { - _vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, box, kColorNoTransparency, gDefultViewPort); + _vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, + box, kColorNoTransparency, gDefultViewPort); } } -- cgit v1.2.3 From 23e0dfcc282a27ff16ba2891971de5ea5fe336c9 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:36:31 +0200 Subject: DM: Add standard GPLv2 header --- engines/dm/champion.cpp | 27 ++++++ engines/dm/champion.h | 27 ++++++ engines/dm/configure.engine | 28 ++++++ engines/dm/detection.cpp | 27 ++++++ engines/dm/dm.cpp | 27 ++++++ engines/dm/dm.h | 27 ++++++ engines/dm/dungeonman.cpp | 27 ++++++ engines/dm/dungeonman.h | 27 ++++++ engines/dm/eventman.cpp | 27 ++++++ engines/dm/eventman.h | 27 ++++++ engines/dm/gfx.cpp | 27 ++++++ engines/dm/gfx.h | 27 ++++++ engines/dm/inventory.cpp | 27 ++++++ engines/dm/inventory.h | 27 ++++++ engines/dm/loadsave.cpp | 27 ++++++ engines/dm/loadsave.h | 27 ++++++ engines/dm/menus.cpp | 215 +++++++++++++++++++++++++------------------- engines/dm/menus.h | 27 ++++++ engines/dm/module.mk | 28 ++++++ engines/dm/objectman.cpp | 27 ++++++ engines/dm/objectman.h | 27 ++++++ engines/dm/text.cpp | 27 ++++++ engines/dm/text.h | 27 ++++++ 23 files changed, 717 insertions(+), 94 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 2899f9093c..28f477ccab 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #include "champion.h" #include "dungeonman.h" #include "eventman.h" diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 2b2aaf9cb1..0610f2913d 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #ifndef DM_CHAMPION_H #define DM_CHAMPION_H diff --git a/engines/dm/configure.engine b/engines/dm/configure.engine index 50a3d9975c..476044aab3 100644 --- a/engines/dm/configure.engine +++ b/engines/dm/configure.engine @@ -1,3 +1,31 @@ +# 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. +# +# +# +# +# Based on the Reverse Engineering work of Christophe Fontanel, +# maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +# + + # This file is included from the main "configure" script # add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] add_engine dm "Dungeon Master" yes diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp index 855d1284b9..1d31a7459d 100644 --- a/engines/dm/detection.cpp +++ b/engines/dm/detection.cpp @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #include "dm/dm.h" #include "common/config-manager.h" diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 61810e8376..c8b02e9823 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #include "common/scummsys.h" #include "common/system.h" diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 61583a39c1..430c7d39e2 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #ifndef DM_H #define DM_H diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 6ff8b7a58e..0041307d06 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #include "common/file.h" #include "common/memstream.h" diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 59e1a821c5..1ccb1d2c62 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #ifndef DUNGEONMAN_H #define DUNGEONMAN_H diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index b5937296c2..fd7f907a0f 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #include "common/system.h" #include "graphics/cursorman.h" diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index 4b62677474..bbf0b66164 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #ifndef DM_EVENTMAN_H #define DM_EVENTMAN_H diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 8c38f4bb25..14324bdcd6 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #include "engines/util.h" #include "common/system.h" #include "common/file.h" diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 5e0307e7df..11679ef891 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #ifndef GFX_H #define GFX_H diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 31b495ca2b..7dd1b0042f 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #include "inventory.h" #include "dungeonman.h" #include "eventman.h" diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 45bc3e9007..6c34e2a0d4 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #include "dm.h" #include "gfx.h" #include "champion.h" diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 1a07ae2e35..0251e8b0f2 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #include "loadsave.h" #include "dungeonman.h" #include "champion.h" diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h index abedf54908..71043a223c 100644 --- a/engines/dm/loadsave.h +++ b/engines/dm/loadsave.h @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #ifndef DM_LOADSAVE_H #define DM_LOADSAVE_H diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index b3464647a5..7b971e53e1 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -1,94 +1,121 @@ -#include "menus.h" -#include "gfx.h" -#include "champion.h" -#include "dungeonman.h" -#include "objectman.h" -#include "inventory.h" - - -namespace DM { - -byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon - -MenuMan::MenuMan(DMEngine *vm) : _vm(vm) { - _shouldRefreshActionArea = false; - _actionAreaContainsIcons = false; -} - -void MenuMan::drawMovementArrows() { - DisplayMan &disp = *_vm->_displayMan; - byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice); - Box &dest = gBoxMovementArrows; - uint16 w = disp.getWidth(kMovementArrowsIndice); - - disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency); -} -void MenuMan::clearActingChampion() { - ChampionMan &cm = *_vm->_championMan; - if (cm._actingChampionOrdinal) { - cm._actingChampionOrdinal--; - cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true); - cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal); - cm._actingChampionOrdinal = indexToOrdinal(kChampionNone); - _shouldRefreshActionArea = true; - } -} - -void MenuMan::drawActionIcon(ChampionIndex championIndex) { - if (!_actionAreaContainsIcons) - return; - DisplayMan &dm = *_vm->_displayMan; - Champion &champion = _vm->_championMan->_champions[championIndex]; - - Box box; - box._x1 = championIndex * 22 + 233; - box._x2 = box._x1 + 19 + 1; - box._y1 = 86; - box._y2 = 120 + 1; - dm._useByteBoxCoordinates = false; - if (!champion._currHealth) { - dm.clearScreenBox(kColorBlack, box); - return; - } - byte *bitmapIcon = dm._tmpBitmap; - Thing thing = champion.getSlot(kChampionSlotActionHand); - IconIndice iconIndex; - if (thing == Thing::_thingNone) { - iconIndex = kIconIndiceActionEmptyHand; - } else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) { - iconIndex = _vm->_objectMan->getIconIndex(thing); - } else { - dm.clearBitmap(bitmapIcon, 16, 16, kColorCyan); - goto T0386006; - } - _vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon); - dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon); -T0386006: - dm.clearScreenBox(kColorCyan, box); - Box box2; - box2._x1 = box._x1 + 2; - box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that - box2._y1 = 95; - box2._y2 = 110 + 1; - dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2); - if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) { - warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); - } -} - -void MenuMan::drawDisabledMenu() { - if (!_vm->_championMan->_partyIsSleeping) { - warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); - _vm->_displayMan->_useByteBoxCoordinates = false; - if (_vm->_inventoryMan->_inventoryChampionOrdinal) { - warning("MISSING CODE: F0334_INVENTORY_CloseChest"); - } else { - warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); - } - warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); - warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); - warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal"); - } -} - -} +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + +#include "menus.h" +#include "gfx.h" +#include "champion.h" +#include "dungeonman.h" +#include "objectman.h" +#include "inventory.h" + + +namespace DM { + +byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon + +MenuMan::MenuMan(DMEngine *vm) : _vm(vm) { + _shouldRefreshActionArea = false; + _actionAreaContainsIcons = false; +} + +void MenuMan::drawMovementArrows() { + DisplayMan &disp = *_vm->_displayMan; + byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice); + Box &dest = gBoxMovementArrows; + uint16 w = disp.getWidth(kMovementArrowsIndice); + + disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency); +} +void MenuMan::clearActingChampion() { + ChampionMan &cm = *_vm->_championMan; + if (cm._actingChampionOrdinal) { + cm._actingChampionOrdinal--; + cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true); + cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal); + cm._actingChampionOrdinal = indexToOrdinal(kChampionNone); + _shouldRefreshActionArea = true; + } +} + +void MenuMan::drawActionIcon(ChampionIndex championIndex) { + if (!_actionAreaContainsIcons) + return; + DisplayMan &dm = *_vm->_displayMan; + Champion &champion = _vm->_championMan->_champions[championIndex]; + + Box box; + box._x1 = championIndex * 22 + 233; + box._x2 = box._x1 + 19 + 1; + box._y1 = 86; + box._y2 = 120 + 1; + dm._useByteBoxCoordinates = false; + if (!champion._currHealth) { + dm.clearScreenBox(kColorBlack, box); + return; + } + byte *bitmapIcon = dm._tmpBitmap; + Thing thing = champion.getSlot(kChampionSlotActionHand); + IconIndice iconIndex; + if (thing == Thing::_thingNone) { + iconIndex = kIconIndiceActionEmptyHand; + } else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) { + iconIndex = _vm->_objectMan->getIconIndex(thing); + } else { + dm.clearBitmap(bitmapIcon, 16, 16, kColorCyan); + goto T0386006; + } + _vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon); + dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon); +T0386006: + dm.clearScreenBox(kColorCyan, box); + Box box2; + box2._x1 = box._x1 + 2; + box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that + box2._y1 = 95; + box2._y2 = 110 + 1; + dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2); + if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) { + warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); + } +} + +void MenuMan::drawDisabledMenu() { + if (!_vm->_championMan->_partyIsSleeping) { + warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); + _vm->_displayMan->_useByteBoxCoordinates = false; + if (_vm->_inventoryMan->_inventoryChampionOrdinal) { + warning("MISSING CODE: F0334_INVENTORY_CloseChest"); + } else { + warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); + } + warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); + warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); + warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal"); + } +} + +} diff --git a/engines/dm/menus.h b/engines/dm/menus.h index edaa970bd5..91f89cd7d5 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #ifndef DM_MENUS_H #define DM_MENUS_H diff --git a/engines/dm/module.mk b/engines/dm/module.mk index bc36e8b6eb..b78ad9679e 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -1,3 +1,31 @@ +# 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. +# +# +# +# +# Based on the Reverse Engineering work of Christophe Fontanel, +# maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +# + + MODULE := engines/dm MODULE_OBJS := \ diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 96f95798f7..f75b116427 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #include "objectman.h" #include "dungeonman.h" diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index fd0f5a1b6f..740ac0fd4e 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #include "dm.h" #include "champion.h" diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index 5ad2ac7b6a..3adc1a9ecb 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #include "text.h" diff --git a/engines/dm/text.h b/engines/dm/text.h index d273de3041..1a413ee87f 100644 --- a/engines/dm/text.h +++ b/engines/dm/text.h @@ -1,3 +1,30 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + #ifndef DM_TEXT_H #define DM_TEXT_H -- cgit v1.2.3 From 4b67e047eda34ae4ee54f416355f3154bb08d56d Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:37:14 +0200 Subject: DM: Add MovesensMan --- engines/dm/dm.cpp | 6 +++++- engines/dm/dm.h | 2 ++ engines/dm/module.mk | 3 ++- engines/dm/movesens.cpp | 37 +++++++++++++++++++++++++++++++++++++ engines/dm/movesens.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 engines/dm/movesens.cpp create mode 100644 engines/dm/movesens.h diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index c8b02e9823..fec043a253 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -48,6 +48,7 @@ #include "objectman.h" #include "inventory.h" #include "text.h" +#include "movesens.h" namespace DM { @@ -83,7 +84,8 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _objectMan = nullptr; _inventoryMan = nullptr; _textMan = nullptr; - + _movsens = nullptr; + _stopWaitingForPlayerInput = false; _gameTimeTicking = false; _restartGameAllowed = false; @@ -111,6 +113,7 @@ DMEngine::~DMEngine() { delete _objectMan; delete _inventoryMan; delete _textMan; + delete _movsens; // clear debug channels DebugMan.clearAllDebugChannels(); @@ -189,6 +192,7 @@ Common::Error DMEngine::run() { _objectMan = new ObjectMan(this); _inventoryMan = new InventoryMan(this); _textMan = new TextMan(this); + _movsens = new MovesensMan(this); _displayMan->setUpScreens(320, 200); initializeGame(); // @ F0463_START_InitializeGame_CPSADEF diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 430c7d39e2..aa37776286 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -45,6 +45,7 @@ class LoadsaveMan; class ObjectMan; class InventoryMan; class TextMan; +class MovesensMan; enum direction { @@ -133,6 +134,7 @@ public: ObjectMan *_objectMan; InventoryMan *_inventoryMan; TextMan *_textMan; + MovesensMan *_movsens; bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput bool _gameTimeTicking; // @ G0301_B_GameTimeTicking diff --git a/engines/dm/module.mk b/engines/dm/module.mk index b78ad9679e..bd9b57677b 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -39,7 +39,8 @@ MODULE_OBJS := \ loadsave.o \ objectman.o \ inventory.o \ - text.o + text.o \ + movesens.o MODULE_DIRS += \ engines/dm diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp new file mode 100644 index 0000000000..9654d779b5 --- /dev/null +++ b/engines/dm/movesens.cpp @@ -0,0 +1,37 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + + +#include "movesens.h" + + +namespace DM { + +MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {} + + +} \ No newline at end of file diff --git a/engines/dm/movesens.h b/engines/dm/movesens.h new file mode 100644 index 0000000000..e0f397df6d --- /dev/null +++ b/engines/dm/movesens.h @@ -0,0 +1,44 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + + +#ifndef DM_MOVESENS_H +#define DM_MOVESENS_H + +#include "dm.h" + +namespace DM { + +class MovesensMan { + DMEngine *_vm; +public: + explicit MovesensMan(DMEngine *vm); +}; + +} + +#endif -- cgit v1.2.3 From 18106aa967a3b0ff9a481c512f4ee91d5fd0eb09 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 23 Jun 2016 17:11:53 +0200 Subject: DM: Add Cell enum, F0275_SENSOR_IsTriggeredByClickOnWall --- engines/dm/dm.h | 8 +++ engines/dm/dungeonman.h | 6 ++ engines/dm/movesens.cpp | 160 +++++++++++++++++++++++++++++++++++++++++++++++- engines/dm/movesens.h | 1 + 4 files changed, 174 insertions(+), 1 deletion(-) diff --git a/engines/dm/dm.h b/engines/dm/dm.h index aa37776286..2c8ff1c1b9 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -83,6 +83,14 @@ enum ThingType { kThingTypeTotal = 16 // +1 than the last (explosionThingType) }; // @ C[00..15]_THING_TYPE_... +enum Cell { + kCellAny = -1, // @ CM1_CELL_ANY + kCellNorthWest = 0, // @ C00_CELL_NORTHWEST + kCellNorthEast = 1, // @ C01_CELL_NORTHEAST + kCellSouthEast = 2, // @ C02_CELL_SOUTHEAST + kCellSouthWest = 3 // @ C03_CELL_SOUTHWEST +}; + class Thing { uint16 _data; public: diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 1ccb1d2c62..4a80d0e2d1 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -278,6 +278,7 @@ public: explicit Sensor(uint16 *rawDat) : _nextThing(rawDat[0]), _datAndType(rawDat[1]), _attributes(rawDat[2]), _action(rawDat[3]) {} Thing getNextThing() { return _nextThing; } + void setNextThing(Thing thing) { _nextThing = thing; } SensorType getType() { return (SensorType)(_datAndType & 0x7F); } // @ M39_TYPE uint16 getData() { return _datAndType >> 7; } // @ M40_DATA uint16 getDataMask1() { return (_datAndType >> 7) & 0xF; } // @ M42_MASK1 @@ -295,6 +296,11 @@ public: uint16 getRemoteMapX() { return (_action >> 6) & 0x1F; } direction getRemoteDir() { return (direction)((_action >> 4) & 3); } uint16 getLocalAction() { return (_action >> 4); } + uint16 getEffectA() { return (_attributes >> 3) & 0x3; } + bool getRevertEffectA() { return (_attributes >> 5) & 0x1; } + bool getAudibleA() { return (_attributes >> 6) & 0x1; } + + // some macros missing, i got bored }; // @ SENSOR diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 9654d779b5..2c25251761 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -27,11 +27,169 @@ #include "movesens.h" +#include "champion.h" +#include "inventory.h" +#include "dungeonman.h" +#include "objectman.h" namespace DM { MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {} +bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam) { + ChampionMan &champMan = *_vm->_championMan; + DungeonMan &dunMan = *_vm->_dungeonMan; + ObjectMan &objMan = *_vm->_objectMan; -} \ No newline at end of file + + bool atLeastOneSensorWasTriggered = false; + Thing leaderHandObject = champMan._leaderHand; + int16 sensorCountToProcessPerCell[4]; + uint16 cell; + for (cell = kCellNorthWest; cell < kCellSouthWest; ++cell) { + sensorCountToProcessPerCell[cell] = 0; + } + Thing squareFirstThing; + Thing thingBeingProcessed = squareFirstThing = dunMan.getSquareFirstThing(mapX, mapY); + ThingType thingType; + while (thingBeingProcessed != Thing::_thingEndOfList) { + thingType = thingBeingProcessed.getType(); + if (thingType == kSensorThingType) { + sensorCountToProcessPerCell[thingBeingProcessed.getCell()]++; + } else if (thingType >= kGroupThingType) { + break; + } + thingBeingProcessed = dunMan.getNextThing(thingBeingProcessed); + } + Thing lastProcessedThing = thingBeingProcessed = squareFirstThing; + + while (thingBeingProcessed != Thing::_thingEndOfList) { + thingType = thingBeingProcessed.getType(); + if (thingType == kSensorThingType) { + cell = thingBeingProcessed.getCell(); + sensorCountToProcessPerCell[cell]--; + Sensor *sensor = (Sensor*)dunMan.getThingData(thingBeingProcessed); // IF YOU CHECK ME, I'LL CALL THE COPS! + SensorType sensorType = sensor->getType(); + if (sensorType == kSensorDisabled) + goto T0275058_ProceedToNextThing; + if ((champMan._leaderIndex == kChampionNone) && (sensorType != kSensorWallChampionPortrait)) + goto T0275058_ProceedToNextThing; + if (cell != cellParam) + goto T0275058_ProceedToNextThing; + int16 sensorData = sensor->getData(); + int16 sensorEffect = sensor->getEffectA(); + bool doNotTriggerSensor; + switch (sensorType) { + case kSensorWallOrnClick: + doNotTriggerSensor = false; + if (sensor->getEffectA() == kSensorEffHold) { + goto T0275058_ProceedToNextThing; + } + break; + case kSensorWallOrnClickWithAnyObj: + doNotTriggerSensor = (champMan._leaderEmptyHanded != sensor->getRevertEffectA()); + break; + case kSensorWallOrnClickWithSpecObjRemovedSensor: + case kSensorWallOrnClickWithSpecObjRemovedRotateSensors: + if (sensorCountToProcessPerCell[cell]) + goto T0275058_ProceedToNextThing; + case kSensorWallOrnClickWithSpecObj: + case kSensorWallOrnClickWithSpecObjRemoved: + doNotTriggerSensor = ((sensorData == objMan.getObjectType(leaderHandObject)) == sensor->getRevertEffectA()); + if (!doNotTriggerSensor && (sensorType == kSensorWallOrnClickWithSpecObjRemovedSensor)) { + if (lastProcessedThing == thingBeingProcessed) + break; + ((Sensor*)dunMan.getThingData(lastProcessedThing))->setNextThing(sensor->getNextThing()); + sensor->setNextThing(Thing::_thingNone); + thingBeingProcessed = lastProcessedThing; + } + if (!doNotTriggerSensor && (sensorType == kSensorWallOrnClickWithSpecObjRemovedRotateSensors)) { + warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect"); + } + break; + case kSensorWallObjGeneratorRotateSensors: + if (sensorCountToProcessPerCell[cell]) + goto T0275058_ProceedToNextThing; + doNotTriggerSensor = !champMan._leaderEmptyHanded; + if (!doNotTriggerSensor) { + warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect"); + } + break; + case kSensorWallSingleObjStorageRotateSensors: + if (champMan._leaderEmptyHanded) { + warning("MISSING CODE: F0273_SENSOR_GetObjectOfTypeInCell"); + warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList"); + warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand"); + } else { + warning("MISSING CODE: F0273_SENSOR_GetObjectOfTypeInCell"); + warning(("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand")); + warning("MISSING CODE: F0163_DUNGEON_LinkThingToList"); + leaderHandObject = Thing::_thingNone; + } + warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect"); + if ((sensorEffect == kSensorEffHold) && !champMan._leaderEmptyHanded) { + doNotTriggerSensor = true; + } else { + doNotTriggerSensor = false; + } + break; + case kSensorWallObjExchanger: { + if (sensorCountToProcessPerCell[cell]) + goto T0275058_ProceedToNextThing; + Thing thingOnSquare = dunMan.getSquareFirstThing(mapX, mapY); + if ((objMan.getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_thingNone)) + goto T0275058_ProceedToNextThing; + warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList"); + warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand"); + warning("MISSING CODE: F0163_DUNGEON_LinkThingToList"); + warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand"); + doNotTriggerSensor = false; + break; + } + case kSensorWallChampionPortrait: + champMan.addCandidateChampionToParty(sensorData); + goto T0275058_ProceedToNextThing; + default: + goto T0275058_ProceedToNextThing; + } + + if (sensorEffect == kSensorEffHold) { + sensorEffect = doNotTriggerSensor ? kSensorEffClear : kSensorEffSet; + doNotTriggerSensor = false; + } + + if (!doNotTriggerSensor) { + atLeastOneSensorWasTriggered = true; + if (sensor->getAudibleA()) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + if (!champMan._leaderEmptyHanded && + ((sensorType == kSensorWallOrnClickWithSpecObjRemoved) || + (sensorType == kSensorWallOrnClickWithSpecObjRemovedRotateSensors) || + (sensorType == kSensorWallOrnClickWithSpecObjRemovedSensor))) { + + *((Thing*)dunMan.getThingData(leaderHandObject)) = Thing::_thingNone; + warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand"); + leaderHandObject = Thing::_thingNone; + } else { + warning("MISSING CODE: (leaderHandObject = F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator(sensorData)"); + if (champMan._leaderEmptyHanded && (sensorType == kSensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_thingNone)) { + warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand"); + } + } + warning("MISSING CODE: F0272_SENSOR_TriggerEffect"); + } + goto T0275058_ProceedToNextThing; + } + if (thingType >= kGroupThingType) + break; +T0275058_ProceedToNextThing: + lastProcessedThing = thingBeingProcessed; + thingBeingProcessed = dunMan.getNextThing(thingBeingProcessed); + } + warning("MISSING CODE: F0271_SENSOR_ProcessRotationEffect"); + return atLeastOneSensorWasTriggered; +} + +} diff --git a/engines/dm/movesens.h b/engines/dm/movesens.h index e0f397df6d..b73f727f8b 100644 --- a/engines/dm/movesens.h +++ b/engines/dm/movesens.h @@ -37,6 +37,7 @@ class MovesensMan { DMEngine *_vm; public: explicit MovesensMan(DMEngine *vm); + bool sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam); // @ F0275_SENSOR_IsTriggeredByClickOnWall }; } -- cgit v1.2.3 From d40e328e519cafe25cd1f5c668b3dd90c993d865 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 23 Jun 2016 17:32:55 +0200 Subject: DM: Add F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall --- engines/dm/eventman.cpp | 19 +++++++++++++++++-- engines/dm/eventman.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index fd7f907a0f..50fba849b8 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -30,6 +30,7 @@ #include "eventman.h" #include "dungeonman.h" +#include "movesens.h" @@ -402,8 +403,8 @@ void EventManager::processCommandQueue() { if ((cmd._type >= kCommandMoveForward) && (cmd._type <= kCommandMoveLeft)) { commandMoveParty(cmd._type); return; - } - + } + if (cmd._type == kCommandClickInDungeonView) { warning("DUMMY CODE, all of this"); DungeonMan &dunMan = *_vm->_dungeonMan; @@ -495,4 +496,18 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) { } } +void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() { + DungeonMan &dunMan = *_vm->_dungeonMan; + CurrMapData &currMap = dunMan._currMap; + uint16 mapX = currMap._partyPosX; + uint16 mapY = currMap._partyPosY; + mapX += _dirIntoStepCountEast[currMap._partyDir]; + mapY += _dirIntoStepCountNorth[currMap._partyDir]; + if ((mapX >= 0) + && (mapX < currMap._width) + && (mapY >= 0) + && (mapY < currMap._height)) { + _vm->_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._partyDir)); + } +} }; // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index bbf0b66164..e0e78f9465 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -244,6 +244,7 @@ public: void processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC void commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader + void commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall }; } -- cgit v1.2.3 From 4044dfa3647f0ba40493d8f07863b2d1f5f76f09 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 23 Jun 2016 23:54:37 +0200 Subject: DM: Add F0157_DUNGEON_GetSquareFirstThingData, F0377_COMMAND_ProcessType80_ClickInDungeonView Also add ElementType enum and G0462_as_Graphic561_Box_ObjectPiles, refactor DungeonMan::_dungeonViewClickableBoxes into Box type --- engines/dm/dungeonman.cpp | 11 +++-- engines/dm/dungeonman.h | 23 +++++++++- engines/dm/eventman.cpp | 106 ++++++++++++++++++++++++++++++++++++++++++++-- engines/dm/eventman.h | 3 ++ engines/dm/gfx.cpp | 14 ++++-- engines/dm/gfx.h | 1 + engines/dm/objectman.h | 2 +- 7 files changed, 147 insertions(+), 13 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 0041307d06..dcf2325d2a 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -423,9 +423,8 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL _isFacingViAltar = false; _isFacingFountain = false; - for (int i = 0; i < 4; i++) - for (int j = 0; j < 6; j++) - _dungeonViewClickableBoxes[j][i] = 0; + for (int j = 0; j < 6; j++) + _dungeonViewClickableBoxes[j].setToZero(); } DungeonMan::~DungeonMan() { @@ -975,6 +974,10 @@ uint16 *DungeonMan::getThingData(Thing thing) { return _dunData._thingsData[thing.getType()][thing.getIndex()]; } +uint16* DungeonMan::getSquareFirstThingData(int16 mapX, int16 mapY) { + return getThingData(getSquareFirstThing(mapX, mapY)); +} + Thing DungeonMan::getNextThing(Thing thing) { return getThingData(thing)[0]; // :) } @@ -1151,7 +1154,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { uint16 DungeonMan::getObjectWeight(Thing thing) { static const uint16 junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo // COMPASS - WATERSKIN - JEWEL SYMAL - ILLUMULET - ASHES - 1, 3, 2, 2, 4, + 1, 3, 2, 2, 4, // BONES - COPPER COIN - SILVER COIN - GOLD COIN - IRON KEY 15, 1, 1, 1, 2, // KEY OF B - SOLID KEY - SQUARE KEY - TOURQUOISE KEY - CROSS KEY diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 4a80d0e2d1..df2069f937 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -34,6 +34,23 @@ namespace DM { +enum ElementType { + kElementTypeChampion = -2, // @ CM2_ELEMENT_CHAMPION /* Values -2 and -1 are only used as projectile impact types */ + kElementTypeCreature = -1, // @ CM1_ELEMENT_CREATURE + kElementTypeWall = 0, // @ C00_ELEMENT_WALL /* Values 0-6 are used as square types and projectile impact types. Values 0-2 and 5-6 are also used for square aspect */ + kElementTypeCorridor = 1, // @ C01_ELEMENT_CORRIDOR + kElementTypePit = 2, // @ C02_ELEMENT_PIT + kElementTypeStairs = 3, // @ C03_ELEMENT_STAIRS + kElementTypeDoor = 4, // @ C04_ELEMENT_DOOR + kElementTypeTeleporter = 5, // @ C05_ELEMENT_TELEPORTER + kElementTypeFakeWall = 6, // @ C06_ELEMENT_FAKEWALL + kElementTypeDoorSide = 16, // @ C16_ELEMENT_DOOR_SIDE /* Values 16-19 are only used for square aspect */ + kElementTypeDoorFront = 17, // @ C17_ELEMENT_DOOR_FRONT + kElementTypeStairsSide = 18, // @ C18_ELEMENT_STAIRS_SIDE + kElementTypeStaisFront = 19 // @ C19_ELEMENT_STAIRS_FRONT +}; + + enum ObjectAllowedSlot { kObjectAllowedSlotMouth = 0x0001, // @ MASK0x0001_MOUTH kObjectAllowedSlotHead = 0x0002, // @ MASK0x0002_HEAD @@ -399,6 +416,7 @@ public: explicit Potion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} PotionType getType() { return (PotionType)((_attributes >> 8) & 0x7F); } + void setType(PotionType val) { _attributes = (_attributes & ~(0x7F << 8)) | ((val & 0x7F) << 8); } Thing getNextThing() { return _nextThing; } }; // @ POTION @@ -435,6 +453,7 @@ public: JunkType getType() { return (JunkType)(_attributes & 0x7F); } uint16 getChargeCount() { return (_attributes >> 14) & 0x3; } + void setChargeCount(uint16 val) { _attributes = (_attributes & ~(0x3 << 14)) | ((val & 0x3) << 14); } Thing getNextThing() { return _nextThing; } }; // @ JUNK @@ -611,6 +630,7 @@ public: Thing getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing) uint16 *getThingData(Thing thing); // @ unsigned char* F0156_DUNGEON_GetThingData(register THING P0276_T_Thing) + uint16 *getSquareFirstThingData(int16 mapX, int16 mapY); // @ F0157_DUNGEON_GetSquareFirstThingData // TODO: this does stuff other than load the file! void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC @@ -639,10 +659,11 @@ public: Messages _messages; // @ NONE; int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex - uint16 _dungeonViewClickableBoxes[6][4]; // G0291_aauc_DungeonViewClickableBoxes + Box _dungeonViewClickableBoxes[6]; // G0291_aauc_DungeonViewClickableBoxes bool _isFacingAlcove; // @ G0286_B_FacingAlcove bool _isFacingViAltar; // @ G0287_B_FacingViAltar bool _isFacingFountain; // @ G0288_B_FacingFountain + ElementType _squareAheadElement; // @ G0285_i_SquareAheadElement }; } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 50fba849b8..fcfc975fca 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -31,12 +31,20 @@ #include "eventman.h" #include "dungeonman.h" #include "movesens.h" +#include "objectman.h" namespace DM { +Box gBoxObjectPiles[4] = { // @ G0462_as_Graphic561_Box_ObjectPiles + /* { X1, X2, Y1, Y2 } */ + Box(24, 111, 148, 168), /* Front left */ + Box(112, 199, 148, 168), /* Front right */ + Box(112, 183, 122, 147), /* Back right */ + Box(40, 111, 122, 147)}; /* Back left */ + MouseInput gPrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(kCommandEntranceEnterDungeon, 244, 298, 45, 58, kLeftMouseButton), @@ -390,7 +398,8 @@ void EventManager::processCommandQueue() { Command cmd = _commandQueue.pop(); - // MISSING CODE: for when movement is disabled + int16 commandX = cmd._pos.x; + int16 commandY = cmd._pos.y; _isCommandQueueLocked = false; processPendingClick(); @@ -406,7 +415,7 @@ void EventManager::processCommandQueue() { } if (cmd._type == kCommandClickInDungeonView) { - warning("DUMMY CODE, all of this"); + /*warning("DUMMY CODE, all of this"); DungeonMan &dunMan = *_vm->_dungeonMan; CurrMapData &currMap = dunMan._currMap; uint16 mapX = currMap._partyPosX; @@ -417,7 +426,8 @@ void EventManager::processCommandQueue() { Sensor sensor(dunMan.getThingData(squareFirstThing)); if (sensor.getType() == kSensorWallChampionPortrait) { _vm->_championMan->addCandidateChampionToParty(sensor.getData()); - } + }*/ + commandProcessType80ClickInDungeonView(commandX, commandY); } // MISSING CODE: the rest of the function @@ -510,4 +520,94 @@ void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() { _vm->_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._partyDir)); } } + +void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY) { + DungeonMan &dunMan = *_vm->_dungeonMan; + ChampionMan &champMan = *_vm->_championMan; + CurrMapData &currMap = _vm->_dungeonMan->_currMap; + + int16 mapX; + int16 mapY; + + + if (dunMan._squareAheadElement == kElementTypeDoorFront) { + if (champMan._leaderIndex == kChampionNone) { + return; + } + mapX = currMap._partyPosX; + mapY = currMap._partyPosY; + mapX += _dirIntoStepCountEast[currMap._partyDir]; + mapY += _dirIntoStepCountNorth[currMap._partyDir]; + + if (champMan._leaderEmptyHanded) { + if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() && + dunMan._dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { + _vm->_stopWaitingForPlayerInput = true; + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning("MISSING CODE: F0268_SENSOR_AddEvent"); + return; + } + + warning("MISSING CODE: F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown in elseif condition"); + } + } + + if (champMan._leaderEmptyHanded) { + for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellDoorButtonOrWallOrn; viewCell++) { + if (dunMan._dungeonViewClickableBoxes[viewCell].isPointInside(Common::Point(posX, posY - 33))) { + if (viewCell == kViewCellDoorButtonOrWallOrn) { + if (!dunMan._isFacingAlcove) { + commandProcessType80ClickInDungeonViewTouchFrontWall(); + } + } else { + warning("MISSING CODE: F0373_COMMAND_ProcessType80_ClickInDungeonView_GrabLeaderHandObject"); + } + return; + } + } + } else { + Thing thing = champMan._leaderHand; + uint16 *rawThingPointer = dunMan.getThingData(thing); + if (dunMan._squareAheadElement == kElementTypeWall) { + for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellFrontRight; ++viewCell) { + if (gBoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) { + warning("F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject"); + return; + } + } + + if (dunMan._dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { + if (dunMan._isFacingAlcove) { + warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject"); + } else { + if (dunMan._isFacingFountain) { + uint16 iconIndex = _vm->_objectMan->getIconIndex(thing); + int16 weight = dunMan.getObjectWeight(thing); + if ((iconIndex >= kIconIndiceJunkWater) && (iconIndex <= kIconIndiceJunkWaterSkin)) { + ((Junk*)rawThingPointer)->setChargeCount(3); + } else if (iconIndex == kIconIndicePotionEmptyFlask) { + ((Potion*)rawThingPointer)->setType(kPotionTypeWaterFlask); + } else { + goto T0377019; + } + warning("MISSING CODE: F0296_CHAMPION_DrawChangedObjectIcons"); + champMan._champions[champMan._leaderIndex]._load += dunMan.getObjectWeight(thing) - weight; + } +T0377019: + commandProcessType80ClickInDungeonViewTouchFrontWall(); + } + } + + } else { + warning("MISSING CODE: F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown in if branch"); + for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellBackLeft; viewCell++) { + if (gBoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) { + warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject"); + return; + } + } + } + } +} + }; // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index e0e78f9465..1a4d663714 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -37,6 +37,8 @@ namespace DM { + + enum MouseButton { kNoneMouseButton = 0, // present only because of typesafety kLeftMouseButton = 1, @@ -245,6 +247,7 @@ public: void commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader void commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall + void commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView }; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 14324bdcd6..d9bb6af6fa 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1146,9 +1146,11 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { byte *tmpBitmap = new byte[305 * 111]; clearBitmap(tmpBitmap, 305, 111, kColorBlack); - memset(_vm->_dungeonMan->_dungeonViewClickableBoxes, 0, sizeof(_vm->_dungeonMan->_dungeonViewClickableBoxes)); + for (int16 i = 0; i < 6; ++i) + _vm->_dungeonMan->_dungeonViewClickableBoxes[i].setToZero(); + for (uint16 i = 0; i < 6; ++i) { - _vm->_dungeonMan->_dungeonViewClickableBoxes[i][0] = 255; + _vm->_dungeonMan->_dungeonViewClickableBoxes[i]._x1 = 255 + 1; } if (flippedFloorCeiling) { @@ -1461,8 +1463,12 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex return isAlcove; } nativeBitmapIndex++; - for (uint16 i = 0; i < 4; ++i) - _vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn][i] = coordinateSetA[i]; + + _vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._x1 = coordinateSetA[0]; + _vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._x2 = coordinateSetA[1]; + _vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._y1 = coordinateSetA[2]; + _vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._y2 = coordinateSetA[3]; + _vm->_dungeonMan->_isFacingAlcove = isAlcove; _vm->_dungeonMan->_isFacingViAltar = (wallOrnIndex == _currMapViAltarIndex); _vm->_dungeonMan->_isFacingFountain = false; diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 11679ef891..e73c44e697 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -91,6 +91,7 @@ public: bool isPointInside(Common::Point point) { return (_x1 <= point.x) && (point.x < _x2) && (_y1 <= point.y) && (point.y < _y2); } + void setToZero() { _x1 = _x2 = _y1 = _y2 = 0; } }; // @ BOX_BYTE, BOX_WORD extern Box gBoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index 740ac0fd4e..fbf880db7e 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -43,7 +43,7 @@ public: SlotBox(int16 x, int16 y, int16 iconIndex): _x(x), _y(y), _iconIndex(iconIndex) {} }; // @ SLOT_BOX -extern SlotBox gSlotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes; +extern SlotBox gSlotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes class ObjectMan { DMEngine *_vm; -- cgit v1.2.3 From fab051093691fdcf3f29662e95699bc080f5602a Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:38:06 +0200 Subject: DM: Move gSlotBoxes to ObjectMan --- engines/dm/champion.cpp | 2 +- engines/dm/objectman.cpp | 108 +++++++++++++++++++++++------------------------ engines/dm/objectman.h | 6 ++- 3 files changed, 59 insertions(+), 57 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 28f477ccab..6f2aa4ac54 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -609,7 +609,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { thing = champ->getSlot(slotIndex); } - SlotBox *slotBox = &gSlotBoxes[slotBoxIndex]; + SlotBox *slotBox = &_vm->_objectMan->_slotBoxes[slotBoxIndex]; Box box; box._x1 = slotBox->_x - 1; box._y1 = slotBox->_y - 1; diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index f75b116427..4099b33b77 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -28,58 +28,8 @@ #include "objectman.h" #include "dungeonman.h" - namespace DM { -SlotBox gSlotBoxes[46] = { -/* 8 for champion hands in status boxes, 30 for champion inventory, 8 for chest */ - SlotBox(4, 10, 0), /* Champion Status Box 0 Ready Hand */ - SlotBox(24, 10, 0), /* Champion Status Box 0 Action Hand */ - SlotBox(73, 10, 0), /* Champion Status Box 1 Ready Hand */ - SlotBox(93, 10, 0), /* Champion Status Box 1 Action Hand */ - SlotBox(142, 10, 0), /* Champion Status Box 2 Ready Hand */ - SlotBox(162, 10, 0), /* Champion Status Box 2 Action Hand */ - SlotBox(211, 10, 0), /* Champion Status Box 3 Ready Hand */ - SlotBox(231, 10, 0), /* Champion Status Box 3 Action Hand */ - SlotBox(6, 53, 0), /* Ready Hand */ - SlotBox(62, 53, 0), /* Action Hand */ - SlotBox(34, 26, 0), /* Head */ - SlotBox(34, 46, 0), /* Torso */ - SlotBox(34, 66, 0), /* Legs */ - SlotBox(34, 86, 0), /* Feet */ - SlotBox(6, 90, 0), /* Pouch 2 */ - SlotBox(79, 73, 0), /* Quiver Line2 1 */ - SlotBox(62, 90, 0), /* Quiver Line1 2 */ - SlotBox(79, 90, 0), /* Quiver Line2 2 */ - SlotBox(6, 33, 0), /* Neck */ - SlotBox(6, 73, 0), /* Pouch 1 */ - SlotBox(62, 73, 0), /* Quiver Line1 1 */ - SlotBox(66, 33, 0), /* Backpack Line1 1 */ - SlotBox(83, 16, 0), /* Backpack Line2 2 */ - SlotBox(100, 16, 0), /* Backpack Line2 3 */ - SlotBox(117, 16, 0), /* Backpack Line2 4 */ - SlotBox(134, 16, 0), /* Backpack Line2 5 */ - SlotBox(151, 16, 0), /* Backpack Line2 6 */ - SlotBox(168, 16, 0), /* Backpack Line2 7 */ - SlotBox(185, 16, 0), /* Backpack Line2 8 */ - SlotBox(202, 16, 0), /* Backpack Line2 9 */ - SlotBox(83, 33, 0), /* Backpack Line1 2 */ - SlotBox(100, 33, 0), /* Backpack Line1 3 */ - SlotBox(117, 33, 0), /* Backpack Line1 4 */ - SlotBox(134, 33, 0), /* Backpack Line1 5 */ - SlotBox(151, 33, 0), /* Backpack Line1 6 */ - SlotBox(168, 33, 0), /* Backpack Line1 7 */ - SlotBox(185, 33, 0), /* Backpack Line1 8 */ - SlotBox(202, 33, 0), /* Backpack Line1 9 */ - SlotBox(117, 59, 0), /* Chest 1 */ - SlotBox(106, 76, 0), /* Chest 2 */ - SlotBox(111, 93, 0), /* Chest 3 */ - SlotBox(128, 98, 0), /* Chest 4 */ - SlotBox(145, 101, 0), /* Chest 5 */ - SlotBox(162, 103, 0), /* Chest 6 */ - SlotBox(179, 104, 0), /* Chest 7 */ - SlotBox(196, 105, 0)}; /* Chest 8 */ - int16 gIconGraphicHeight[7] = {32, 32, 32, 32, 32, 32, 32}; // @ K0077_ai_IconGraphicHeight int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex @@ -91,7 +41,55 @@ int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconI 160, /* First icon index in graphic #47 */ 192}; /* First icon index in graphic #48 */ -ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {} +ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) { + /* 8 for champion hands in status boxes, 30 for champion inventory, 8 for chest */ + _slotBoxes[0] = SlotBox(4, 10, 0); /* Champion Status Box 0 Ready Hand */ + _slotBoxes[1] = SlotBox(24, 10, 0); /* Champion Status Box 0 Action Hand */ + _slotBoxes[2] = SlotBox(73, 10, 0); /* Champion Status Box 1 Ready Hand */ + _slotBoxes[3] = SlotBox(93, 10, 0); /* Champion Status Box 1 Action Hand */ + _slotBoxes[4] = SlotBox(142, 10, 0); /* Champion Status Box 2 Ready Hand */ + _slotBoxes[5] = SlotBox(162, 10, 0); /* Champion Status Box 2 Action Hand */ + _slotBoxes[6] = SlotBox(211, 10, 0); /* Champion Status Box 3 Ready Hand */ + _slotBoxes[7] = SlotBox(231, 10, 0); /* Champion Status Box 3 Action Hand */ + _slotBoxes[8] = SlotBox(6, 53, 0); /* Ready Hand */ + _slotBoxes[9] = SlotBox(62, 53, 0); /* Action Hand */ + _slotBoxes[10] = SlotBox(34, 26, 0); /* Head */ + _slotBoxes[11] = SlotBox(34, 46, 0); /* Torso */ + _slotBoxes[12] = SlotBox(34, 66, 0); /* Legs */ + _slotBoxes[13] = SlotBox(34, 86, 0); /* Feet */ + _slotBoxes[14] = SlotBox(6, 90, 0); /* Pouch 2 */ + _slotBoxes[15] = SlotBox(79, 73, 0); /* Quiver Line2 1 */ + _slotBoxes[16] = SlotBox(62, 90, 0); /* Quiver Line1 2 */ + _slotBoxes[17] = SlotBox(79, 90, 0); /* Quiver Line2 2 */ + _slotBoxes[18] = SlotBox(6, 33, 0); /* Neck */ + _slotBoxes[19] = SlotBox(6, 73, 0); /* Pouch 1 */ + _slotBoxes[20] = SlotBox(62, 73, 0); /* Quiver Line1 1 */ + _slotBoxes[21] = SlotBox(66, 33, 0); /* Backpack Line1 1 */ + _slotBoxes[22] = SlotBox(83, 16, 0); /* Backpack Line2 2 */ + _slotBoxes[23] = SlotBox(100, 16, 0); /* Backpack Line2 3 */ + _slotBoxes[24] = SlotBox(117, 16, 0); /* Backpack Line2 4 */ + _slotBoxes[25] = SlotBox(134, 16, 0); /* Backpack Line2 5 */ + _slotBoxes[26] = SlotBox(151, 16, 0); /* Backpack Line2 6 */ + _slotBoxes[27] = SlotBox(168, 16, 0); /* Backpack Line2 7 */ + _slotBoxes[28] = SlotBox(185, 16, 0); /* Backpack Line2 8 */ + _slotBoxes[29] = SlotBox(202, 16, 0); /* Backpack Line2 9 */ + _slotBoxes[30] = SlotBox(83, 33, 0); /* Backpack Line1 2 */ + _slotBoxes[31] = SlotBox(100, 33, 0); /* Backpack Line1 3 */ + _slotBoxes[32] = SlotBox(117, 33, 0); /* Backpack Line1 4 */ + _slotBoxes[33] = SlotBox(134, 33, 0); /* Backpack Line1 5 */ + _slotBoxes[34] = SlotBox(151, 33, 0); /* Backpack Line1 6 */ + _slotBoxes[35] = SlotBox(168, 33, 0); /* Backpack Line1 7 */ + _slotBoxes[36] = SlotBox(185, 33, 0); /* Backpack Line1 8 */ + _slotBoxes[37] = SlotBox(202, 33, 0); /* Backpack Line1 9 */ + _slotBoxes[38] = SlotBox(117, 59, 0); /* Chest 1 */ + _slotBoxes[39] = SlotBox(106, 76, 0); /* Chest 2 */ + _slotBoxes[40] = SlotBox(111, 93, 0); /* Chest 3 */ + _slotBoxes[41] = SlotBox(128, 98, 0); /* Chest 4 */ + _slotBoxes[42] = SlotBox(145, 101, 0); /* Chest 5 */ + _slotBoxes[43] = SlotBox(162, 103, 0); /* Chest 6 */ + _slotBoxes[44] = SlotBox(179, 104, 0); /* Chest 7 */ + _slotBoxes[45] = SlotBox(196, 105, 0); /* Chest 8 */ +} IconIndice ObjectMan::getObjectType(Thing thing) { if (thing == Thing::_thingNone) @@ -156,23 +154,25 @@ IconIndice ObjectMan::getIconIndex(Thing thing) { void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { int16 i; - for (i = 0; i < 7; ++i) + for (i = 0; i < 7; ++i) { if (gIconGraphicFirstIndex[i] > iconIndex) break; + } + --i; byte *srcBitmap = _vm->_displayMan->getBitmap(kObjectIcons_000_TO_031 + i); iconIndex -= gIconGraphicFirstIndex[i]; _vm->_displayMan->_useByteBoxCoordinates = true; _vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, 0, 16, 0, 16, kColorNoTransparency); - } void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { - SlotBox *slotBox = &gSlotBoxes[slotBoxIndex]; + SlotBox *slotBox = &_slotBoxes[slotBoxIndex]; slotBox->_iconIndex = iconIndex; // yes, this modifies the global array if (slotBox->_iconIndex == kIconIndiceNone) { return; } + Box box; box._x1 = slotBox->_x; box._y1 = slotBox->_y; diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index fbf880db7e..a2ceafefbe 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -41,15 +41,17 @@ public: int16 _y; int16 _iconIndex; SlotBox(int16 x, int16 y, int16 iconIndex): _x(x), _y(y), _iconIndex(iconIndex) {} + SlotBox(): _x(-1), _y(-1), _iconIndex(-1) {} }; // @ SLOT_BOX -extern SlotBox gSlotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes - class ObjectMan { DMEngine *_vm; + public: explicit ObjectMan(DMEngine *vm); + SlotBox _slotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes; + IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex void extractIconFromBitmap(uint16 iconIndex, byte *srcBitmap); // F0036_OBJECT_ExtractIconFromBitmap -- cgit v1.2.3 From 45461a4908bfab95fa41ff90aba2e697b2581c96 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 23 Jun 2016 23:12:39 +0200 Subject: DM: Fix compilation on GCC --- engines/dm/champion.cpp | 10 +++++----- engines/dm/dm.cpp | 8 ++++++++ engines/dm/dm.h | 2 ++ engines/dm/dungeonman.cpp | 10 +++------- engines/dm/dungeonman.h | 5 ----- engines/dm/eventman.cpp | 2 +- engines/dm/gfx.cpp | 4 ++-- engines/dm/inventory.cpp | 12 ++++++------ engines/dm/menus.cpp | 2 +- 9 files changed, 28 insertions(+), 27 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 6f2aa4ac54..8579fb63a5 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -432,7 +432,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { kChampionAttributeActionHand))) { return; } - bool isInventoryChamp = (indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal); + bool isInventoryChamp = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal); dispMan._useByteBoxCoordinates = false; if (champAttributes & kChampionAttributeStatusBox) { box._y1 = 0; @@ -537,7 +537,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { { // block so goto won't skip AL_0_championIconIndex initialization int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir); - if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != indexToOrdinal(AL_0_championIconIndex))) { + if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) { dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]); dispMan.blitToScreen(dispMan.getBitmap(kChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0, gBoxChampionIcons[AL_0_championIconIndex], kColorDarkestGray); @@ -590,11 +590,11 @@ void ChampionMan::drawHealthStaminaManaValues(Champion* champ) { void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { int16 nativeBitmapIndex = -1; Champion *champ = &_champions[champIndex]; - bool isInventoryChamp = (_vm->_inventoryMan->_inventoryChampionOrdinal == indexToOrdinal(champIndex)); + bool isInventoryChamp = (_vm->_inventoryMan->_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)); uint16 slotBoxIndex; if (!isInventoryChamp) { /* If drawing a slot for a champion other than the champion whose inventory is open */ - if ((slotIndex > kChampionSlotActionHand) || (_candidateChampionOrdinal == indexToOrdinal(champIndex))) { + if ((slotIndex > kChampionSlotActionHand) || (_candidateChampionOrdinal == _vm->indexToOrdinal(champIndex))) { return; } slotBoxIndex = (champIndex << 1) + slotIndex; @@ -654,7 +654,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { } } - if ((slotIndex == kChampionSlotActionHand) && (indexToOrdinal(champIndex) == _actingChampionOrdinal)) { + if ((slotIndex == kChampionSlotActionHand) && (_vm->indexToOrdinal(champIndex) == _actingChampionOrdinal)) { nativeBitmapIndex = kSlotBoxActingHandIndice; } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index fec043a253..aa4290f0a8 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -232,4 +232,12 @@ void DMEngine::gameloop() { } } +int16 DMEngine::ordinalToIndex(int16 val) { + return val - 1; +} + +int16 DMEngine::indexToOrdinal(int16 val) { + return val + 1; +} + } // End of namespace DM diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 2c8ff1c1b9..e9ab80fff9 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -127,6 +127,8 @@ public: explicit DMEngine(OSystem *syst); ~DMEngine(); + int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX + int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL virtual Common::Error run(); // @ main private: diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index dcf2325d2a..d9480820ae 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -359,10 +359,6 @@ CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_Crea {25, 0, 0x38AA, 0x0000, 12, 22, 255, 180, 210, 0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}, {26, 0, 0x38AA, 0x0000, 12, 22, 255, 180, 210, 0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}}; -int16 DM::ordinalToIndex(int16 val) { return val - 1; } -int16 DM::indexToOrdinal(int16 val) { return val + 1; } - - void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) { posX += _dirIntoStepCountEast[dir] * stepsForward; posY += _dirIntoStepCountNorth[dir] * stepsForward; @@ -863,7 +859,7 @@ T0172010_ClosedFakeWall: Sensor sensor(getThingData(thing)); aspectArray[sideIndex + 1] = sensor.getOrnOrdinal(); if (sensor.getType() == kSensorWallChampionPortrait) { - _vm->_displayMan->_championPortraitOrdinal = indexToOrdinal(sensor.getData()); + _vm->_displayMan->_championPortraitOrdinal = _vm->indexToOrdinal(sensor.getData()); } } } @@ -946,7 +942,7 @@ void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowe if (isFakeWall || mapX < 0 || mapX >= _currMap._width || mapY < 0 || mapY >= _currMap._height) { for (uint16 i = kRightWallOrnOrdAspect; i <= kLeftWallOrnOrdAspect; ++i) { - if (isWallOrnAnAlcove(ordinalToIndex(aspectArray[i]))) + if (isWallOrnAnAlcove(_vm->ordinalToIndex(aspectArray[i]))) aspectArray[i] = 0; } } @@ -957,7 +953,7 @@ int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int + (3000 + (_currMap._index << 6) + _currMap._width + _currMap._height) * 11 + _fileHeader._ornamentRandomSeed) >> 2) % modulo; if (allowed && index < count) - return indexToOrdinal(index); + return _vm->indexToOrdinal(index); return 0; } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index df2069f937..5191ba9867 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -143,11 +143,6 @@ public: extern WeaponInfo gWeaponInfo[46]; - -int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX -int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL - - enum TextType { /* Used for text on walls */ kTextTypeInscription = 0, // @ C0_TEXT_TYPE_INSCRIPTION diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index fcfc975fca..0b76af34ef 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -499,7 +499,7 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) { Champion *champion = &cm._champions[cm._leaderIndex]; champion->_dir = _vm->_dungeonMan->_currMap._partyDir; cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHand); - if (indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) { + if (_vm->indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) { champion->setAttributeFlag(kChampionAttributeIcon, true); champion->setAttributeFlag(kChampionAttributeNameTitle, true); cm.drawChampionState(champIndex); diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index d9bb6af6fa..f5d58838fa 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1350,10 +1350,10 @@ void DisplayMan::loadCurrentMapGraphics() { CreatureAspect &aspect = gCreatureAspects[_currMapAllowedCreatureTypes[creatureType]]; uint16 replColorOrdinal = aspect.getReplColour9(); if (replColorOrdinal) - applyCreatureReplColors(9, ordinalToIndex(replColorOrdinal)); + applyCreatureReplColors(9, _vm->ordinalToIndex(replColorOrdinal)); replColorOrdinal = aspect.getReplColour10(); if (replColorOrdinal) - applyCreatureReplColors(10, ordinalToIndex(replColorOrdinal)); + applyCreatureReplColors(10, _vm->ordinalToIndex(replColorOrdinal)); } } diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 7dd1b0042f..ab57883fbf 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -59,18 +59,18 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { return; _vm->_stopWaitingForPlayerInput = true; int16 invChampOrdinal = _inventoryChampionOrdinal; // copy, as the original will be edited - if (indexToOrdinal(championIndex) == invChampOrdinal) { + if (_vm->indexToOrdinal(championIndex) == invChampOrdinal) { championIndex = kChmpionCloseInventory; } Champion *champion; if (invChampOrdinal) { - _inventoryChampionOrdinal = indexToOrdinal(kChampionNone); + _inventoryChampionOrdinal = _vm->indexToOrdinal(kChampionNone); warning("MISSING CODE: F0334_INVENTORY_CloseChest"); - champion = &cm._champions[ordinalToIndex(invChampOrdinal)]; + champion = &cm._champions[_vm->ordinalToIndex(invChampOrdinal)]; if (champion->_currHealth && !cm._candidateChampionOrdinal) { champion->setAttributeFlag(kChampionAttributeStatusBox, true); - cm.drawChampionState((ChampionIndex)ordinalToIndex(invChampOrdinal)); + cm.drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal)); } if (cm._partyIsSleeping) { return; @@ -86,7 +86,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { } dm._useByteBoxCoordinates = false; - _inventoryChampionOrdinal = indexToOrdinal(championIndex); + _inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex); if (!invChampOrdinal) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } @@ -185,7 +185,7 @@ void InventoryMan::drawPanel() { return; } - Thing thing = cm._champions[ordinalToIndex(_inventoryChampionOrdinal)].getSlot(kChampionSlotActionHand); + Thing thing = cm._champions[_vm->ordinalToIndex(_inventoryChampionOrdinal)].getSlot(kChampionSlotActionHand); _panelContent = kPanelContentFoodWaterPoisoned; switch (thing.getType()) { diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 7b971e53e1..f83fa6ecab 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -56,7 +56,7 @@ void MenuMan::clearActingChampion() { cm._actingChampionOrdinal--; cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true); cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal); - cm._actingChampionOrdinal = indexToOrdinal(kChampionNone); + cm._actingChampionOrdinal = _vm->indexToOrdinal(kChampionNone); _shouldRefreshActionArea = true; } } -- cgit v1.2.3 From c1abeffecccf5cd6096f3a780f17e1327ee744da Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 23 Jun 2016 23:22:50 +0200 Subject: DM: Fix some GCC warnings --- engines/dm/champion.cpp | 3 +++ engines/dm/dungeonman.cpp | 7 +++++++ engines/dm/eventman.cpp | 6 ++++++ engines/dm/objectman.cpp | 2 ++ 4 files changed, 18 insertions(+) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 8579fb63a5..b246eccbac 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -312,6 +312,9 @@ T0280046: slotIndex_Green = AL_0_slotIndex_Red++; } break; + + default: + break; } T0280048: if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) { diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index d9480820ae..ac38a07438 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -842,6 +842,8 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, frontOrnAllowed = square.get(kWallEastRandOrnAllowed); rightOrnAllowed = square.get(kWallSouthRandOrnAllowed); break; + default: + break; } T0172010_ClosedFakeWall: @@ -925,6 +927,9 @@ T0172049_Footprints: unsigned char scentOrdinal; // see next line comment if (footPrintsAllowed) // TODO: I skipped some party query code, must come back later and complete aspectArray[kFloorOrnOrdAspect] &= kFootprintsAspect; + break; + default: + break; } aspectArray[kFirstGroupOrObjectAspect] = thing.toUint16(); } @@ -1205,6 +1210,8 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { } case kScrollThingType: return 1; + default: + break; } assert(false); // this should never be taken diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 0b76af34ef..680c621434 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -340,6 +340,8 @@ void EventManager::processInput() { if (_dummyMapIndex > 0) dungeonMan.setCurrentMapAndPartyMap(--_dummyMapIndex); break; + default: + break; } case Common::EVENT_MOUSEMOVE: _mousePos = event.mouse; @@ -350,6 +352,8 @@ void EventManager::processInput() { _pendingClickPos = _mousePos; _pendingClickButton = (event.type == Common::EVENT_LBUTTONDOWN) ? kLeftMouseButton : kRightMouseButton; break; + default: + break; } } } @@ -471,6 +475,8 @@ void EventManager::commandMoveParty(CommandType cmdType) { case kCommandMoveRight: dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, 1, currMap._partyPosX, currMap._partyPosY); break; + default: + break; } // MISSING CODE: Lots of code diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 4099b33b77..d20c235aa0 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -146,6 +146,8 @@ IconIndice ObjectMan::getIconIndex(Thing thing) { iconIndex = (IconIndice)(iconIndex + 1); } break; + default: + break; } } -- cgit v1.2.3 From eddf2f494d3e750519e0d515d97834f05974c3c1 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 24 Jun 2016 01:43:43 +0200 Subject: DM: Add F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel --- engines/dm/champion.cpp | 8 ++--- engines/dm/champion.h | 11 ++++-- engines/dm/dm.cpp | 4 +-- engines/dm/dm.h | 4 +-- engines/dm/dungeonman.cpp | 8 ++--- engines/dm/eventman.cpp | 90 ++++++++++++++++++++++++++++++++++++++++++++--- engines/dm/eventman.h | 2 ++ engines/dm/inventory.cpp | 6 ++-- 8 files changed, 111 insertions(+), 22 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b246eccbac..03515a0a2a 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -38,12 +38,12 @@ namespace DM { Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye -Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons +Box gBoxChampionIcons[4] = { Box(281, 299, 0, 13), Box(301, 319, 0, 13), Box(301, 319, 15, 28), Box(281, 299, 15, 28)}; -Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; // @ G0046_auc_Graphic562_ChampionColor +Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks /* 30 for champion inventory, 8 for chest */ @@ -265,8 +265,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { int16 mapY = _vm->_dungeonMan->_currMap._partyPosY; uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir)); - mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir]; - mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir]; + mapX += gDirIntoStepCountEast[dunMan._currMap._partyDir]; + mapY += gDirIntoStepCountNorth[dunMan._currMap._partyDir]; thing = dunMan.getSquareFirstThing(mapX, mapY); AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1; uint16 slotIndex_Green; diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 0610f2913d..1a89bc2add 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -35,6 +35,9 @@ namespace DM { +extern Box gBoxChampionIcons[4]; // @ G0054_ai_Graphic562_Box_ChampionIcons +extern Color gChampionColor[4]; // @ G0046_auc_Graphic562_ChampionColor + class Scent { uint16 _scent; public: @@ -157,7 +160,7 @@ enum ChampionIndex { kChampionSecond = 1, kChampionThird = 2, kChampionFourth = 3, - kChmpionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY + kChampionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY kChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY }; @@ -366,7 +369,7 @@ public: void setSkillExp(ChampionSkill skill, int32 val) { _skills[skill]._experience = val; } void setSkillTempExp(ChampionSkill skill, int16 val) { _skills[skill]._temporaryExperience= val; } - byte getStatistic(ChampionStatisticType type, ChampionStatisticValue valType) { return _statistics[type][valType]; } + byte& getStatistic(ChampionStatisticType type, ChampionStatisticValue valType) { return _statistics[type][valType]; } void setStatistic(ChampionStatisticType type, ChampionStatisticValue valType, byte newVal) { _statistics[type][valType] = newVal; } uint16 getAttributes() { return _attributes; } @@ -409,6 +412,10 @@ public: _actionDefense = _food = _water = _load = _shieldDefense = 0; memset(_portrait, 0, 464); } + void resetSkillsToZero() { + for (int16 i = 0; i < 20; ++i) + _skills[i].resetToZero(); + } }; // @ CHAMPION_INCLUDING_PORTRAIT class ChampionMan { diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index aa4290f0a8..a28c14c000 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -52,8 +52,8 @@ namespace DM { -int8 _dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount -int8 _dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount +int8 gDirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount +int8 gDirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index e9ab80fff9..5a7e548448 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -56,8 +56,8 @@ enum direction { }; // TODO: refactor direction into a class -extern int8 _dirIntoStepCountEast[4]; -extern int8 _dirIntoStepCountNorth[4]; +extern int8 gDirIntoStepCountEast[4]; +extern int8 gDirIntoStepCountNorth[4]; void turnDirRight(direction &dir); void turnDirLeft(direction &dir); diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index ac38a07438..755a7d8cd7 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -360,11 +360,11 @@ CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_Crea {26, 0, 0x38AA, 0x0000, 12, 22, 255, 180, 210, 0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}}; void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) { - posX += _dirIntoStepCountEast[dir] * stepsForward; - posY += _dirIntoStepCountNorth[dir] * stepsForward; + posX += gDirIntoStepCountEast[dir] * stepsForward; + posY += gDirIntoStepCountNorth[dir] * stepsForward; turnDirRight(dir); - posX += _dirIntoStepCountEast[dir] * stepsRight; - posY += _dirIntoStepCountNorth[dir] * stepsRight; + posX += gDirIntoStepCountEast[dir] * stepsRight; + posY += gDirIntoStepCountNorth[dir] * stepsRight; } DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) { diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 680c621434..ca094210ec 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -32,6 +32,7 @@ #include "dungeonman.h" #include "movesens.h" #include "objectman.h" +#include "inventory.h" @@ -517,8 +518,8 @@ void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() { CurrMapData &currMap = dunMan._currMap; uint16 mapX = currMap._partyPosX; uint16 mapY = currMap._partyPosY; - mapX += _dirIntoStepCountEast[currMap._partyDir]; - mapY += _dirIntoStepCountNorth[currMap._partyDir]; + mapX += gDirIntoStepCountEast[currMap._partyDir]; + mapY += gDirIntoStepCountNorth[currMap._partyDir]; if ((mapX >= 0) && (mapX < currMap._width) && (mapY >= 0) @@ -542,8 +543,8 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY } mapX = currMap._partyPosX; mapY = currMap._partyPosY; - mapX += _dirIntoStepCountEast[currMap._partyDir]; - mapY += _dirIntoStepCountNorth[currMap._partyDir]; + mapX += gDirIntoStepCountEast[currMap._partyDir]; + mapY += gDirIntoStepCountNorth[currMap._partyDir]; if (champMan._leaderEmptyHanded) { if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() && @@ -564,7 +565,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY if (viewCell == kViewCellDoorButtonOrWallOrn) { if (!dunMan._isFacingAlcove) { commandProcessType80ClickInDungeonViewTouchFrontWall(); - } + } } else { warning("MISSING CODE: F0373_COMMAND_ProcessType80_ClickInDungeonView_GrabLeaderHandObject"); } @@ -616,4 +617,83 @@ T0377019: } } +void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType) { + ChampionMan &champMan = *_vm->_championMan; + InventoryMan &invMan = *_vm->_inventoryMan; + DisplayMan &dispMan = *_vm->_displayMan; + CurrMapData &currMap = _vm->_dungeonMan->_currMap; + DungeonMan &dunMan = *_vm->_dungeonMan; + + uint16 championIndex = champMan._partyChampionCount - 1; + Champion *champ = &champMan._champions[championIndex]; + if (commandType == kCommandClickInPanelCancel) { + invMan.toggleInventory(kChampionCloseInventory); + champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone); + if (champMan._partyChampionCount == 1) { + commandSetLeader(kChampionNone); + } + champMan._partyChampionCount--; + Box box; + box._y1 = 0; + box._y2 = 28 + 1; + box._x1 = championIndex * kChampionStatusBoxSpacing; + box._x2 = box._x1 + 66 + 1; + dispMan._useByteBoxCoordinates = false; + dispMan.clearScreenBox(kColorBlack, box); + dispMan.clearScreenBox(kColorBlack, gBoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._partyDir) * 2]); + warning("F0457_START_DrawEnabledMenus_CPSF"); + warning("F0078_MOUSE_ShowPointer"); + return; + } + + champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone); + int16 mapX = currMap._partyPosX; + int16 mapY = currMap._partyPosY; + + mapX += gDirIntoStepCountEast[currMap._partyDir]; + mapY += gDirIntoStepCountNorth[currMap._partyDir]; + for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) { + Thing thing = champ->getSlot((ChampionSlot)slotIndex); + if (thing != Thing::_thingNone) { + warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList"); + } + } + Thing thing = dunMan.getSquareFirstThing(mapX, mapY); + for (;;) { // infinite + if (thing.getType() == kSensorThingType) { + ((Sensor*)dunMan.getThingData(thing))->setTypeDisabled(); + break; + } + thing = dunMan.getNextThing(thing); + } + + if (commandType == kCommandClickInPanelReincarnate) { + warning("MISSING CODE: F0281_CHAMPION_Rename"); + champ->resetSkillsToZero(); + + for (uint16 i = 0; i < 12; i++) { + uint16 statIndex = _vm->_rnd->getRandomNumber(7); + champ->getStatistic((ChampionStatisticType)statIndex, kChampionStatCurrent)++; // returns reference + champ->getStatistic((ChampionStatisticType)statIndex, kChampionStatMaximum)++; // returns reference + } + } + + if (champMan._partyChampionCount == 1) { + warning("MISSING CODE: setting time, G0362_l_LastPartyMovementTime , G0313_ul_GameTime"); + commandSetLeader(kChampionFirst); + warning("MISSING CODE: F0394_MENUS_SetMagicCasterAndDrawSpellArea"); + } else { + warning("MISSING CODE: F0393_MENUS_DrawSpellAreaControls"); + } + + warning("MISSING CODE: F0051_TEXT_MESSAGEAREA_PrintLineFeed"); + Color champColor = gChampionColor[championIndex]; // unreferenced because of missing code + warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage"); + warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage"); + + invMan.toggleInventory(kChampionCloseInventory); + warning("MISSING CODE: F0457_START_DrawEnabledMenus_CPSF"); + warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal"); +} + }; // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index 1a4d663714..fa4728741d 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -31,6 +31,7 @@ #include "common/events.h" #include "common/queue.h" +#include "dm.h" #include "gfx.h" #include "champion.h" @@ -248,6 +249,7 @@ public: void commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader void commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall void commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView + void commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel }; } diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index ab57883fbf..2fd4f4157c 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -53,14 +53,14 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { EventManager &em = *_vm->_eventMan; DisplayMan &dm = *_vm->_displayMan; - if ((championIndex == kChmpionCloseInventory) && !cm._champions[championIndex]._currHealth) + if ((championIndex == kChampionCloseInventory) && !cm._champions[championIndex]._currHealth) return; if (_vm->_pressingEye || _vm->_pressingMouth) return; _vm->_stopWaitingForPlayerInput = true; int16 invChampOrdinal = _inventoryChampionOrdinal; // copy, as the original will be edited if (_vm->indexToOrdinal(championIndex) == invChampOrdinal) { - championIndex = kChmpionCloseInventory; + championIndex = kChampionCloseInventory; } Champion *champion; @@ -75,7 +75,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { if (cm._partyIsSleeping) { return; } - if (championIndex == kChmpionCloseInventory) { + if (championIndex == kChampionCloseInventory) { em._refreshMousePointerInMainLoop = true; _vm->_menuMan->drawMovementArrows(); em._secondaryMouseInput = gSecondaryMouseInput_Movement; -- cgit v1.2.3 From b820a36d3a94e9510e313144378b789efe954fe4 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 24 Jun 2016 02:08:26 +0200 Subject: DM: Add F0378_COMMAND_ProcessType81_ClickInPanel --- engines/dm/eventman.cpp | 38 ++++++++++++++++++++++++++------------ engines/dm/eventman.h | 1 + engines/dm/inventory.cpp | 2 +- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index ca094210ec..689d9fd551 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -420,20 +420,11 @@ void EventManager::processCommandQueue() { } if (cmd._type == kCommandClickInDungeonView) { - /*warning("DUMMY CODE, all of this"); - DungeonMan &dunMan = *_vm->_dungeonMan; - CurrMapData &currMap = dunMan._currMap; - uint16 mapX = currMap._partyPosX; - uint16 mapY = currMap._partyPosY; - mapX += gDirIntoStepCountEast[currMap._partyDir]; - mapY += gDirIntoStepCountNorth[currMap._partyDir]; - Thing squareFirstThing = dunMan.getSquareFirstThing(mapX, mapY); - Sensor sensor(dunMan.getThingData(squareFirstThing)); - if (sensor.getType() == kSensorWallChampionPortrait) { - _vm->_championMan->addCandidateChampionToParty(sensor.getData()); - }*/ commandProcessType80ClickInDungeonView(commandX, commandY); } + if (cmd._type == kCommandClickInPanel) { + commandProcess81ClickInPanel(commandX, commandY); + } // MISSING CODE: the rest of the function } @@ -696,4 +687,27 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal"); } +void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) { + ChampionMan &champMan = *_vm->_championMan; + InventoryMan &invMan = *_vm->_inventoryMan; + + CommandType commandType; + switch (invMan._panelContent) { + case kPanelContentChest: + if (champMan._leaderIndex == kChampionNone) // if no leader + return; + commandType = getCommandTypeFromMouseInput(gMouseInput_PanelChest, Common::Point(x, y), kLeftMouseButton); + if (commandType != kCommandNone) + warning("MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox"); + break; + case kPanelContentResurrectReincarnate: + if (!champMan._leaderEmptyHanded) + break; + commandType = getCommandTypeFromMouseInput(gMouseInput_PanelChest, Common::Point(x, y), kLeftMouseButton); + if (commandType != kCommandNone) + commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType); + break; + } +} + }; // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index fa4728741d..ca9587716c 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -250,6 +250,7 @@ public: void commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall void commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView void commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel + void commandProcess81ClickInPanel(int16 x, int16 y); // @ F0378_COMMAND_ProcessType81_ClickInPanel }; } diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 2fd4f4157c..550c4c85c6 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -53,7 +53,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { EventManager &em = *_vm->_eventMan; DisplayMan &dm = *_vm->_displayMan; - if ((championIndex == kChampionCloseInventory) && !cm._champions[championIndex]._currHealth) + if ((championIndex != kChampionCloseInventory) && !cm._champions[championIndex]._currHealth) return; if (_vm->_pressingEye || _vm->_pressingMouth) return; -- cgit v1.2.3 From c392f7e9772ad2d5a23b6c8407afa0f32ce4ebbc Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:38:51 +0200 Subject: DM: Add F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived --- engines/dm/champion.cpp | 2 +- engines/dm/dm.cpp | 8 +++++-- engines/dm/menus.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++-- engines/dm/menus.h | 4 +++- 4 files changed, 64 insertions(+), 6 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 03515a0a2a..f1c3c5ee77 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -255,7 +255,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { _candidateChampionOrdinal = prevChampCount + 1; if (++_partyChampionCount == 1) { _vm->_eventMan->commandSetLeader(kChampionFirst); - _vm->_menuMan->_shouldRefreshActionArea = true; + _vm->_menuMan->_refreshActionArea = true; } else { _vm->_menuMan->clearActingChampion(); _vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1)); diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index a28c14c000..eab2d1474c 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -213,16 +213,20 @@ void DMEngine::gameloop() { warning("DUMMY CODE: setting InventoryMan::_inventoryChampionOrdinal to zero"); _inventoryMan->_inventoryChampionOrdinal = 0; - warning("DUMMY CODE: clearing screen to black"); + warning("DUMMY CODE: clearing screen to black"); // in loop below while (true) { _stopWaitingForPlayerInput = false; + + _menuMan->refreshActionAreaAndSetChampDirMaxDamageReceived(); + //do { _eventMan->processInput(); _eventMan->processCommandQueue(); //} while (!_stopWaitingForPlayerInput || !_gameTimeTicking); if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) { - _displayMan->clearScreen(kColorBlack); // dummy code + Box box(0, 0 + 224 + 1, 33, 33 + 126 + 1); + _displayMan->clearScreenBox(kColorBlack, box); // dummy code _displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY); } // DUMMY CODE: next line diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index f83fa6ecab..25ed432621 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -38,8 +38,9 @@ namespace DM { byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon MenuMan::MenuMan(DMEngine *vm) : _vm(vm) { - _shouldRefreshActionArea = false; + _refreshActionArea = false; _actionAreaContainsIcons = false; + _actionDamage = 0; } void MenuMan::drawMovementArrows() { @@ -57,7 +58,7 @@ void MenuMan::clearActingChampion() { cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true); cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal); cm._actingChampionOrdinal = _vm->indexToOrdinal(kChampionNone); - _shouldRefreshActionArea = true; + _refreshActionArea = true; } } @@ -118,4 +119,55 @@ void MenuMan::drawDisabledMenu() { } } +void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() { + ChampionMan &champMan = *_vm->_championMan; + + if (!champMan._partyChampionCount) + return; + + Champion *champ = nullptr; + if (champMan._partyIsSleeping || champMan._candidateChampionOrdinal) { + if (champMan._actingChampionOrdinal) { + clearActingChampion(); + return; + } + if (!champMan._candidateChampionOrdinal) + return; + } else { + champ = champMan._champions; + int16 champIndex = kChampionFirst; + + do { + if ((champIndex != champMan._leaderIndex) + && (_vm->indexToOrdinal(champIndex) != champMan._actingChampionOrdinal) + && (champ->_maximumDamageReceived) + && (champ->_dir != champ->_directionMaximumDamageReceived)) { + + champ->_dir = (direction)champ->_directionMaximumDamageReceived; + champ->setAttributeFlag(kChampionAttributeIcon, true); + champMan.drawChampionState((ChampionIndex)champIndex); + } + champ->_maximumDamageReceived = 0; + champ++; + champIndex++; + } while (champIndex < champMan._partyChampionCount); + } + + if (_refreshActionArea) { + if (!champMan._actingChampionOrdinal) { + if (_actionDamage) { + warning("MISSING CODE: F0385_MENUS_DrawActionDamage"); + _actionDamage = 0; + } else { + _actionAreaContainsIcons = true; + warning("MISSING CODE: F0387_MENUS_DrawActionArea"); + } + } else { + _actionAreaContainsIcons = false; + champ->setAttributeFlag(kChampionAttributeActionHand, true); + champMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(champMan._actingChampionOrdinal)); + warning("MISSING CODE: F0387_MENUS_DrawActionArea"); + } + } +} } diff --git a/engines/dm/menus.h b/engines/dm/menus.h index 91f89cd7d5..3562ced34a 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -38,14 +38,16 @@ class MenuMan { public: explicit MenuMan(DMEngine *vm); - bool _shouldRefreshActionArea; // @ G0508_B_RefreshActionArea + bool _refreshActionArea; // @ G0508_B_RefreshActionArea bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons + int16 _actionDamage; void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon void drawMovementArrows(); // @ F0395_MENUS_DrawMovementArrows void drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus + void refreshActionAreaAndSetChampDirMaxDamageReceived(); // @ F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived }; } -- cgit v1.2.3 From dad087454c87059736fa69543124c7ac44085085 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 24 Jun 2016 10:39:25 +0200 Subject: DM: Add missing load display in ChampionMan::drawChampionState --- engines/dm/champion.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index f1c3c5ee77..ef4257fff9 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -529,11 +529,27 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { } } - if (champAttributes & kChampionAttributeLoad) { - warning("MISSING CODE: whole if branch, many F0052_TEXT_PrintToViewport-s"); - - - + if ((champAttributes & kChampionAttributeLoad) && isInventoryChamp) { + Color loadColor; + int16 champMaxLoad = getMaximumLoad(champ); + if (champ->_load > champMaxLoad) { + loadColor = kColorRed; + } else if (((int32)champ->_load) * 8 > ((int32)champMaxLoad) * 5) { + loadColor = kColorYellow; + } else { + loadColor = kColorLightestGray; + } + _vm->_textMan->printToViewport(104, 132, loadColor, "LOAD "); + + int16 loadTmp = champ->_load / 10; + Common::String str = getStringFromInteger(loadTmp, true, 3); + str += '.'; + loadTmp = champ->_load - (loadTmp * 10); + str += getStringFromInteger(loadTmp, false, 1); + str += '/'; + loadTmp = (getMaximumLoad(champ) + 5) / 10; + str += "KG"; + _vm->_textMan->printToViewport(148, 132, loadColor, str.c_str()); champAttributes |= kChampionAttributeViewport; } -- cgit v1.2.3 From 9c544a44f22cdf15662f90d0cdffe5770a77ce4c Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 25 Jun 2016 13:31:47 +0200 Subject: DM: Add renameChampion stub, fix wrong inputArray EventManager::commandProcess81ClickInPanel --- engines/dm/champion.cpp | 31 ++++++++++++++++++++++++++++--- engines/dm/champion.h | 1 + engines/dm/dm.cpp | 4 ++-- engines/dm/eventman.cpp | 10 ++++++++-- engines/dm/eventman.h | 2 ++ engines/dm/gfx.h | 3 ++- engines/dm/inventory.cpp | 2 +- engines/dm/inventory.h | 2 ++ 8 files changed, 46 insertions(+), 9 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index ef4257fff9..8b4149b464 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -38,12 +38,12 @@ namespace DM { Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye -Box gBoxChampionIcons[4] = { +Box gBoxChampionIcons[4] = { Box(281, 299, 0, 13), Box(301, 319, 0, 13), Box(301, 319, 15, 28), Box(281, 299, 15, 28)}; -Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; +Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks /* 30 for champion inventory, 8 for chest */ @@ -312,7 +312,7 @@ T0280046: slotIndex_Green = AL_0_slotIndex_Red++; } break; - + default: break; } @@ -690,7 +690,32 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { } } +void ChampionMan::renameChampion(Champion* champ) { + warning("STUB METHOD: Champion::renameChampion, F0281_CHAMPION_Rename"); + + DisplayMan &dispMan = *_vm->_displayMan; + TextMan &textMan = *_vm->_textMan; + Box box; + box._y1 = 3; + box._y2 = 8 + 1; + box._x1 = 3; + box._x2 = box._x1 + 167; + + dispMan.clearScreenBox(kColorDarkestGray, box, gDungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(kPanelRenameChampionIndice), 144, 0, 0, gBoxPanel, kColorCyan, gDungeonViewport); + textMan.printToViewport(177, 58, kColorLightestGray, "_______"); + textMan.printToViewport(105, 76, kColorLightestGray, "___________________"); + Common::Point clickPos; + static Box okButtonBox(197, 215, 147, 155); // inclusive boundaries, constructor adds +1 + for (;;) { + _vm->_eventMan->processInput(); + if (_vm->_eventMan->hasPendingClick(clickPos, kLeftMouseButton) && okButtonBox.isPointInside(clickPos)) { + return; + } + dispMan.updateScreen(); + } +} } diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 1a89bc2add..d5e74a6885 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -451,6 +451,7 @@ public: uint16 championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX void drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues void drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot + void renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename }; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index eab2d1474c..a3479d258a 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -225,8 +225,8 @@ void DMEngine::gameloop() { //} while (!_stopWaitingForPlayerInput || !_gameTimeTicking); if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) { - Box box(0, 0 + 224 + 1, 33, 33 + 126 + 1); - _displayMan->clearScreenBox(kColorBlack, box); // dummy code + Box box(0, 224, 0, 126); + _displayMan->clearScreenBox(kColorBlack, box, gDungeonViewport); // dummy code _displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY); } // DUMMY CODE: next line diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 689d9fd551..0a79b191c5 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -659,7 +659,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane } if (commandType == kCommandClickInPanelReincarnate) { - warning("MISSING CODE: F0281_CHAMPION_Rename"); + champMan.renameChampion(champ); champ->resetSkillsToZero(); for (uint16 i = 0; i < 12; i++) { @@ -703,11 +703,17 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) { case kPanelContentResurrectReincarnate: if (!champMan._leaderEmptyHanded) break; - commandType = getCommandTypeFromMouseInput(gMouseInput_PanelChest, Common::Point(x, y), kLeftMouseButton); + commandType = getCommandTypeFromMouseInput(gMouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), kLeftMouseButton); if (commandType != kCommandNone) commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType); break; } } + bool EventManager::hasPendingClick(Common::Point& point, MouseButton button) + { + if (_pendingClickButton && button == _pendingClickButton) + point = _pendingClickPos; + return _pendingClickPresent; + } }; // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index ca9587716c..ca60c46a7b 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -251,6 +251,8 @@ public: void commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView void commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel void commandProcess81ClickInPanel(int16 x, int16 y); // @ F0378_COMMAND_ProcessType81_ClickInPanel + + bool hasPendingClick(Common::Point &point, MouseButton button); }; } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index e73c44e697..5db354d458 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -70,7 +70,8 @@ enum GraphicIndice { kSlotBoxWoundedIndice = 34, // @ C034_GRAPHIC_SLOT_BOX_WOUNDED kChampionIcons = 28, // @ C028_GRAPHIC_CHAMPION_ICONS kFontGraphicIndice = 557, // @ C557_GRAPHIC_FONT - kSlotBoxActingHandIndice = 35 // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND + kSlotBoxActingHandIndice = 35, // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND + kPanelRenameChampionIndice = 27 // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION }; extern uint16 gPalSwoosh[16]; diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 550c4c85c6..f6fe61f78f 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -37,7 +37,7 @@ namespace DM { Box gBoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross -Box gBoxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel +Box gBoxPanel = Box(80, 223, 52, 124); Box gBoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food Box gBoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water Box gBoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 6c34e2a0d4..f225e417bd 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -36,6 +36,8 @@ namespace DM { #define kChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING +extern Box gBoxPanel; // @ G0032_s_Graphic562_Box_Panel + enum PanelContent { kPanelContentFoodWaterPoisoned = 0, // @ C00_PANEL_FOOD_WATER_POISONED kPanelContentScroll = 2, // @ C02_PANEL_SCROLL -- cgit v1.2.3 From d893075343c8b27a6f20eab436fea6aa6b02d800 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 25 Jun 2016 13:51:17 +0200 Subject: DM: Fix unused viewport in DisplayMan::clearScreenBox --- engines/dm/gfx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index f5d58838fa..f1a93a1c5f 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1578,8 +1578,8 @@ byte* DisplayMan::getBitmap(uint16 index) { void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) { uint16 width = box._x2 - box._x1; - for (int y = box._y1; y < box._y2; ++y) - memset(_vgaBuffer + y * _screenWidth + box._x1, color, sizeof(byte) * width); + for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y) + memset(_vgaBuffer + y * _screenWidth + box._x1 + viewport._posX, color, sizeof(byte) * width); } void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, -- cgit v1.2.3 From 12d359166ca87d74cfe6598162d78da97939c0d3 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 25 Jun 2016 16:27:31 +0200 Subject: DM: Add F0387_MENUS_DrawActionArea --- engines/dm/gfx.h | 3 ++- engines/dm/inventory.cpp | 2 +- engines/dm/menus.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++- engines/dm/menus.h | 19 ++++++++++++++++- engines/dm/text.cpp | 15 ++++++++++++- engines/dm/text.h | 4 ++++ 6 files changed, 93 insertions(+), 5 deletions(-) diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 5db354d458..d3e19479d8 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -71,7 +71,8 @@ enum GraphicIndice { kChampionIcons = 28, // @ C028_GRAPHIC_CHAMPION_ICONS kFontGraphicIndice = 557, // @ C557_GRAPHIC_FONT kSlotBoxActingHandIndice = 35, // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND - kPanelRenameChampionIndice = 27 // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION + kPanelRenameChampionIndice = 27, // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION + kMenuActionAreaIndice = 10 // @ C010_GRAPHIC_MENU_ACTION_AREA }; extern uint16 gPalSwoosh[16]; diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index f6fe61f78f..550c4c85c6 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -37,7 +37,7 @@ namespace DM { Box gBoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross -Box gBoxPanel = Box(80, 223, 52, 124); +Box gBoxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel Box gBoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food Box gBoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water Box gBoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 25ed432621..ec87a3b77c 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -31,10 +31,15 @@ #include "dungeonman.h" #include "objectman.h" #include "inventory.h" +#include "text.h" namespace DM { +Box gBoxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu +Box gBoxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu +Box gBoxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu +Box gBoxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon MenuMan::MenuMan(DMEngine *vm) : _vm(vm) { @@ -160,7 +165,7 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() { _actionDamage = 0; } else { _actionAreaContainsIcons = true; - warning("MISSING CODE: F0387_MENUS_DrawActionArea"); + drawActionArea(); } } else { _actionAreaContainsIcons = false; @@ -170,4 +175,52 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() { } } } + +#define kChampionNameMaximumLength 7 // @ C007_CHAMPION_NAME_MAXIMUM_LENGTH +#define kActionNameMaximumLength 12 // @ C012_ACTION_NAME_MAXIMUM_LENGTH + +void MenuMan::drawActionArea() { + DisplayMan &dispMan = *_vm->_displayMan; + ChampionMan &champMan = *_vm->_championMan; + TextMan &textMan = *_vm->_textMan; + + warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + dispMan._useByteBoxCoordinates = false; + dispMan.clearScreenBox(kColorBlack, gBoxActionArea); + if (_actionAreaContainsIcons) { + for (uint16 champIndex = kChampionFirst; champIndex < champMan._partyChampionCount; ++champIndex) + drawActionIcon((ChampionIndex)champIndex); + } else if (champMan._actingChampionOrdinal) { + Box box = gBoxActionArea3ActionMenu; + if (_actionList._actionIndices[2] == kChampionActionNone) + box = gBoxActionArea2ActionMenu; + if (_actionList._actionIndices[1] == kChampionActionNone) + box = gBoxActionArea1ActionMenu; + dispMan.blitToScreen(dispMan.getBitmap(kMenuActionAreaIndice), 96, 0, 0, box, kColorNoTransparency); + textMan.printWithTrailingSpacesToScreen(235, 83, kColorBlack, kColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._actingChampionOrdinal)]._name, + kChampionNameMaximumLength); + for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) { + textMan.printWithTrailingSpacesToScreen(241, 93 + actionListIndex * 12, kColorCyan, kColorBlack, + getActionName(_actionList._actionIndices[actionListIndex]), + kActionNameMaximumLength); + } + } + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + _refreshActionArea = false; +} + +const char *gChampionActionNames[44] = { + "N", "BLOCK", "CHOP", "X", "BLOW HORN", "FLIP", "PUNCH", + "KICK", "WAR CRY", "STAB", "CLIMB DOWN", "FREEZE LIFE", + "HIT", "SWING", "STAB", "THRUST", "JAB", "PARRY", "HACK", + "BERZERK", "FIREBALL", "DISPELL", "CONFUSE", "LIGHTNING", + "DISRUPT", "MELEE", "X", "INVOKE", "SLASH", "CLEAVE", + "BASH", "STUN", "SHOOT", "SPELLSHIELD", "FIRESHIELD", + "FLUXCAGE", "HEAL", "CALM", "LIGHT", "WINDOW", "SPIT", + "BRANDISH", "THROW", "FUSE"}; + +const char* MenuMan::getActionName(ChampionAction actionIndex) { + return (actionIndex == kChampionActionNone) ? "" : gChampionActionNames[actionIndex]; +} + } diff --git a/engines/dm/menus.h b/engines/dm/menus.h index 3562ced34a..4ae7784c4d 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -33,6 +33,20 @@ namespace DM { +extern Box gBoxActionArea; + +class ActionList { +public: + byte _minimumSkillLevel[3]; /* Bit 7: requires charge, Bit 6-0: minimum skill level. */ + ChampionAction _actionIndices[3]; + ActionList() { + for (uint16 i = 0; i < 3; ++i) { + _minimumSkillLevel[i] = 0; + _actionIndices[i] = kChampionActionNone; + } + } +}; // @ ACTION_LIST + class MenuMan { DMEngine *_vm; public: @@ -40,7 +54,8 @@ public: bool _refreshActionArea; // @ G0508_B_RefreshActionArea bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons - int16 _actionDamage; + int16 _actionDamage; // @ G0513_i_ActionDamage + ActionList _actionList; // @ G0713_s_ActionList void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon @@ -48,6 +63,8 @@ public: void drawMovementArrows(); // @ F0395_MENUS_DrawMovementArrows void drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus void refreshActionAreaAndSetChampDirMaxDamageReceived(); // @ F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived + void drawActionArea(); // @ F0387_MENUS_DrawActionArea + const char* getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName }; } diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index 3adc1a9ecb..ab22ac473e 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -60,7 +60,7 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 break; uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code _vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth, - (nextX == destX) ? (nextX + 1) : nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight, kColorNoTransparency, viewport); + (nextX == destX) ? (nextX + 1) : nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight, kColorNoTransparency, viewport); nextX += kLetterWidth + 1; } } @@ -73,4 +73,17 @@ void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const cha printTextToScreen(posX, posY, textColor, kColorDarkestGray, text, gDungeonViewport); } +void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, + Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight, Viewport& viewport) { + Common::String str = text; + for (int16 i = str.size(); i < requiredTextLength; ++i) + str += ' '; + printTextToBitmap(destBitmap, destPixelWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight, viewport); +} + +void TextMan::printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor, const char* text, int16 strLenght, Viewport& viewport) { + printWithTrailingSpaces(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY, + textColor, bgColor, text, strLenght, _vm->_displayMan->_screenHeight, viewport); +} + } diff --git a/engines/dm/text.h b/engines/dm/text.h index 1a413ee87f..b03d00a00d 100644 --- a/engines/dm/text.h +++ b/engines/dm/text.h @@ -41,6 +41,10 @@ public: Color textColor, Color bgColor, const char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, Viewport &viewport = gDefultViewPort); // @ F0053_TEXT_PrintToLogicalScreen void printToViewport(int16 posX, int16 posY, Color textColor, const char *text); // @ F0052_TEXT_PrintToViewport + void printWithTrailingSpaces(byte *destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor, + const char *text, int16 strLenght, int16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0041_TEXT_PrintWithTrailingSpaces + void printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor, + const char *text, int16 strLenght, Viewport &viewport = gDefultViewPort); // @ F0041_TEXT_PrintWithTrailingSpaces }; } -- cgit v1.2.3 From 5893dc7c981a3131882f705a5058a5e4e6af660f Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 25 Jun 2016 17:03:02 +0200 Subject: DM: Add F0393_MENUS_DrawSpellAreaControls --- engines/dm/champion.cpp | 1 + engines/dm/champion.h | 1 + engines/dm/eventman.cpp | 3 ++- engines/dm/menus.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/menus.h | 1 + 5 files changed, 76 insertions(+), 1 deletion(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 8b4149b464..b8676c803e 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -95,6 +95,7 @@ ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { _partyIsSleeping = false; _leaderHandObjectIconIndex = kIconIndiceNone; _leaderEmptyHanded = true; + _magicCasterChampionIndex = kChampionNone; } uint16 ChampionMan::getChampionPortraitX(uint16 index) { diff --git a/engines/dm/champion.h b/engines/dm/champion.h index d5e74a6885..3e72be3850 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -440,6 +440,7 @@ public: IconIndice _leaderHandObjectIconIndex; // @ G0413_i_LeaderHandObjectIconIndex bool _leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded Party _party; // @ G0407_s_Party + ChampionIndex _magicCasterChampionIndex; // @ G0514_i_MagicCasterChampionIndex explicit ChampionMan(DMEngine *vm); void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 0a79b191c5..9ebda0fbb0 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -33,6 +33,7 @@ #include "movesens.h" #include "objectman.h" #include "inventory.h" +#include "menus.h" @@ -674,7 +675,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane commandSetLeader(kChampionFirst); warning("MISSING CODE: F0394_MENUS_SetMagicCasterAndDrawSpellArea"); } else { - warning("MISSING CODE: F0393_MENUS_DrawSpellAreaControls"); + _vm->_menuMan->drawSpellAreaControls(champMan._magicCasterChampionIndex); } warning("MISSING CODE: F0051_TEXT_MESSAGEAREA_PrintLineFeed"); diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index ec87a3b77c..8014a82cca 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -223,4 +223,75 @@ const char* MenuMan::getActionName(ChampionAction actionIndex) { return (actionIndex == kChampionActionNone) ? "" : gChampionActionNames[actionIndex]; } + +Box gBoxSpellAreaControls = Box(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls + +void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) { + ChampionMan &champMan = *_vm->_championMan; + DisplayMan &dispMan = *_vm->_displayMan; + TextMan &textMan = *_vm->_textMan; + + Champion &champ = champMan._champions[champIndex]; + int16 champCurrHealth[4]; + for (uint16 i = 0; i < 4; ++i) + champCurrHealth[i] = champMan._champions[i]._currHealth; + warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + dispMan.clearScreenBox(kColorBlack, gBoxSpellAreaControls); + int16 champCount = champMan._partyChampionCount; + switch (champIndex) { + case kChampionFirst: + warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + textMan.printTextToScreen(235, 48, kColorBlack, kColorCyan, champ._name); + if (champCount) { + if (champCurrHealth[1]) { + warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + } +labelChamp2: + if (champCount > 2) { + if (champCurrHealth[2]) { + warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + } +labelChamp3: + if (champCount > 3) { + if (champCurrHealth[3]) { + warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + } + } + } + } + break; + case kChampionSecond: + if (champCurrHealth[0]) { + warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + } + warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + textMan.printTextToScreen(249, 48, kColorBlack, kColorCyan, champ._name); + goto labelChamp2; + case kChampionThird: + if (champCurrHealth[0]) { + warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + } + if (champCurrHealth[1]) { + warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + } + warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + textMan.printTextToScreen(263, 48, kColorBlack, kColorCyan, champ._name); + goto labelChamp3; + case kChampionFourth: + if (champCurrHealth[0]) { + warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + } + if (champCurrHealth[1]) { + warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + } + if (champCurrHealth[2]) { + warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + } + warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + textMan.printTextToScreen(277, 48, kColorBlack, kColorCyan, champ._name); + break; + } + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); +} + } diff --git a/engines/dm/menus.h b/engines/dm/menus.h index 4ae7784c4d..ac2f462bdf 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -65,6 +65,7 @@ public: void refreshActionAreaAndSetChampDirMaxDamageReceived(); // @ F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived void drawActionArea(); // @ F0387_MENUS_DrawActionArea const char* getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName + void drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls }; } -- cgit v1.2.3 From fc6837b9648797df5bc48cdde1b38e714b86187b Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 25 Jun 2016 21:05:29 +0200 Subject: DM: Add F0392_MENUS_BuildSpellAreaLine --- engines/dm/gfx.cpp | 7 ++++++- engines/dm/gfx.h | 5 ++++- engines/dm/menus.cpp | 39 +++++++++++++++++++++++++++++++++++++++ engines/dm/menus.h | 3 +++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index f1a93a1c5f..7466cb424a 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -817,7 +817,12 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uin } } -void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, + void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent, Viewport& viewport) + { + blitToBitmap(srcBitmap, srcWidth, srcX, srcY, destBitmap, destWidth, box._x1, box._x2, box._y1, box._y2, transparent, viewport); + } + + void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, Color transparent, Viewport &viewport) { blitToBitmap(srcBitmap, srcWidth, srcX, srcY, diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index d3e19479d8..209559b827 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -72,7 +72,8 @@ enum GraphicIndice { kFontGraphicIndice = 557, // @ C557_GRAPHIC_FONT kSlotBoxActingHandIndice = 35, // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND kPanelRenameChampionIndice = 27, // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION - kMenuActionAreaIndice = 10 // @ C010_GRAPHIC_MENU_ACTION_AREA + kMenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA + kMenuSpellAreLinesIndice = 11 // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES }; extern uint16 gPalSwoosh[16]; @@ -336,6 +337,8 @@ public: byte *destBitmap, uint16 destWidth, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort); + void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, + byte *destBitmap, uint16 destWidth, Box &box, Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort); void blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight, byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 8014a82cca..02a6689292 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -42,10 +42,19 @@ Box gBoxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_ Box gBoxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon +Box gBoxSpellAreaLine = Box(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine +Box gBoxSpellAreaLine2 = Box(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 +Box gBoxSpellAreaLine3 = Box(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 + MenuMan::MenuMan(DMEngine *vm) : _vm(vm) { _refreshActionArea = false; _actionAreaContainsIcons = false; _actionDamage = 0; + _bitmapSpellAreaLine = new byte[96 * 12]; +} + +MenuMan::~MenuMan() { + delete[] _bitmapSpellAreaLine; } void MenuMan::drawMovementArrows() { @@ -294,4 +303,34 @@ labelChamp3: warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } +#define kSpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS +#define kSpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS + +void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) { + DisplayMan &dispMan = *_vm->_displayMan; + + Champion &champ = _vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex]; + if (spellAreaBitmapLine == kSpellAreaAvailableSymbols) { + dispMan._useByteBoxCoordinates = false; + dispMan.blitToBitmap(dispMan.getBitmap(kMenuSpellAreLinesIndice), 96, 0, 12, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, kColorNoTransparency); + int16 x = 1; + char c = 96 + (6 * champ._symbolStep); + char spellSymbolString[2] = {'\0', '\0'}; + for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) { + spellSymbolString[0] = c++; + _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 14, 8, kColorCyan, kColorBlack, spellSymbolString, 12); + } + } else if (spellAreaBitmapLine == kSpellAreaChampionSymbols) { + dispMan._useByteBoxCoordinates = false; + dispMan.blitToBitmap(dispMan.getBitmap(kMenuSpellAreLinesIndice), 96, 0, 24, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, kColorNoTransparency); + int16 x = 8; + char spellSymbolString[2] = {'\0', '\0'}; + for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) { + if ((spellSymbolString[0] = champ._symbols[symbolIndex]) == '\0') + break; + _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 9, 8, kColorCyan, kColorBlack, spellSymbolString, 12); + } + } +} + } diff --git a/engines/dm/menus.h b/engines/dm/menus.h index ac2f462bdf..b4006e17b0 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -51,11 +51,13 @@ class MenuMan { DMEngine *_vm; public: explicit MenuMan(DMEngine *vm); + ~MenuMan(); bool _refreshActionArea; // @ G0508_B_RefreshActionArea bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons int16 _actionDamage; // @ G0513_i_ActionDamage ActionList _actionList; // @ G0713_s_ActionList + byte *_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon @@ -66,6 +68,7 @@ public: void drawActionArea(); // @ F0387_MENUS_DrawActionArea const char* getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName void drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls + void buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine }; } -- cgit v1.2.3 From 72506aebba96dec6e709a6efc8577ebee40407f9 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 26 Jun 2016 00:39:44 +0200 Subject: DM: Add MenuMan::setMagicCasterAndDrawSpellArea --- engines/dm/eventman.cpp | 2 +- engines/dm/gfx.h | 3 ++- engines/dm/menus.cpp | 32 ++++++++++++++++++++++++++++++++ engines/dm/menus.h | 4 +++- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 9ebda0fbb0..4e5a59cb91 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -673,7 +673,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane if (champMan._partyChampionCount == 1) { warning("MISSING CODE: setting time, G0362_l_LastPartyMovementTime , G0313_ul_GameTime"); commandSetLeader(kChampionFirst); - warning("MISSING CODE: F0394_MENUS_SetMagicCasterAndDrawSpellArea"); + _vm->_menuMan->setMagicCasterAndDrawSpellArea(kChampionFirst); } else { _vm->_menuMan->drawSpellAreaControls(champMan._magicCasterChampionIndex); } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 209559b827..9354b99de3 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -73,7 +73,8 @@ enum GraphicIndice { kSlotBoxActingHandIndice = 35, // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND kPanelRenameChampionIndice = 27, // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION kMenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA - kMenuSpellAreLinesIndice = 11 // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES + kMenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES + kMenuSpellAreaBackground = 9 // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND }; extern uint16 gPalSwoosh[16]; diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 02a6689292..47c35b926d 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -45,6 +45,7 @@ byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Box gBoxSpellAreaLine = Box(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine Box gBoxSpellAreaLine2 = Box(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 Box gBoxSpellAreaLine3 = Box(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 +Box gBoxSpellArea = Box(224, 319, 77, 121); MenuMan::MenuMan(DMEngine *vm) : _vm(vm) { _refreshActionArea = false; @@ -333,4 +334,35 @@ void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) { } } + void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) + { + ChampionMan &champMan = *_vm->_championMan; + DisplayMan &dispMan = *_vm->_displayMan; + + if((champIndex == champMan._magicCasterChampionIndex) + || ((champIndex != kChampionNone) && !champMan._champions[champIndex]._currHealth)) + return; + if (champMan._magicCasterChampionIndex == kChampionNone) { + warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + dispMan.blitToScreen(dispMan.getBitmap(kMenuSpellAreaBackground), 96, 0, 0, gBoxSpellArea); + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + } + if (champIndex == kChampionNone) { + champMan._magicCasterChampionIndex = kChampionNone; + warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + dispMan._useByteBoxCoordinates = false; + dispMan.clearScreenBox(kColorBlack, gBoxSpellArea); + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + return; + } + + champMan._magicCasterChampionIndex = champIndex; + buildSpellAreaLine(kSpellAreaAvailableSymbols); + warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + drawSpellAreaControls((ChampionIndex)champIndex); + dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine2); + buildSpellAreaLine(kSpellAreaChampionSymbols); + dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine3); + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + } } diff --git a/engines/dm/menus.h b/engines/dm/menus.h index b4006e17b0..a8df73531f 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -33,7 +33,8 @@ namespace DM { -extern Box gBoxActionArea; +extern Box gBoxActionArea; // @ G0001_s_Graphic562_Box_ActionArea +extern Box gBoxSpellArea; // @ G0000_s_Graphic562_Box_SpellArea class ActionList { public: @@ -69,6 +70,7 @@ public: const char* getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName void drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls void buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine + void setMagicCasterAndDrawSpellArea(int16 champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea }; } -- cgit v1.2.3 From bcd7c1d763e9ad8e5455808bcb7a6d5614035914 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 27 Jun 2016 19:40:13 +0200 Subject: DM: Fix possible bug in MenuMan::setMagicCasterAndDrawSpellArea --- engines/dm/menus.cpp | 59 ++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 47c35b926d..dfbe5b564e 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -45,7 +45,7 @@ byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Box gBoxSpellAreaLine = Box(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine Box gBoxSpellAreaLine2 = Box(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 Box gBoxSpellAreaLine3 = Box(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 -Box gBoxSpellArea = Box(224, 319, 77, 121); +Box gBoxSpellArea = Box(224, 319, 77, 121); MenuMan::MenuMan(DMEngine *vm) : _vm(vm) { _refreshActionArea = false; @@ -315,7 +315,7 @@ void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) { dispMan._useByteBoxCoordinates = false; dispMan.blitToBitmap(dispMan.getBitmap(kMenuSpellAreLinesIndice), 96, 0, 12, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, kColorNoTransparency); int16 x = 1; - char c = 96 + (6 * champ._symbolStep); + byte c = 96 + (6 * champ._symbolStep); char spellSymbolString[2] = {'\0', '\0'}; for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) { spellSymbolString[0] = c++; @@ -324,8 +324,8 @@ void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) { } else if (spellAreaBitmapLine == kSpellAreaChampionSymbols) { dispMan._useByteBoxCoordinates = false; dispMan.blitToBitmap(dispMan.getBitmap(kMenuSpellAreLinesIndice), 96, 0, 24, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, kColorNoTransparency); - int16 x = 8; char spellSymbolString[2] = {'\0', '\0'}; + int16 x = 8; for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) { if ((spellSymbolString[0] = champ._symbols[symbolIndex]) == '\0') break; @@ -334,35 +334,34 @@ void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) { } } - void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) - { - ChampionMan &champMan = *_vm->_championMan; - DisplayMan &dispMan = *_vm->_displayMan; - - if((champIndex == champMan._magicCasterChampionIndex) - || ((champIndex != kChampionNone) && !champMan._champions[champIndex]._currHealth)) - return; - if (champMan._magicCasterChampionIndex == kChampionNone) { - warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan.blitToScreen(dispMan.getBitmap(kMenuSpellAreaBackground), 96, 0, 0, gBoxSpellArea); - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); - } - if (champIndex == kChampionNone) { - champMan._magicCasterChampionIndex = kChampionNone; - warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan._useByteBoxCoordinates = false; - dispMan.clearScreenBox(kColorBlack, gBoxSpellArea); - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); - return; - } +void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) { + ChampionMan &champMan = *_vm->_championMan; + DisplayMan &dispMan = *_vm->_displayMan; - champMan._magicCasterChampionIndex = champIndex; - buildSpellAreaLine(kSpellAreaAvailableSymbols); + if ((champIndex == champMan._magicCasterChampionIndex) + || ((champIndex != kChampionNone) && !champMan._champions[champIndex]._currHealth)) + return; + if (champMan._magicCasterChampionIndex == kChampionNone) { warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - drawSpellAreaControls((ChampionIndex)champIndex); - dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine2); - buildSpellAreaLine(kSpellAreaChampionSymbols); - dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine3); + dispMan.blitToScreen(dispMan.getBitmap(kMenuSpellAreaBackground), 96, 0, 0, gBoxSpellArea); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } + if (champIndex == kChampionNone) { + champMan._magicCasterChampionIndex = kChampionNone; + warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + dispMan._useByteBoxCoordinates = false; + dispMan.clearScreenBox(kColorBlack, gBoxSpellArea); + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + return; + } + + champMan._magicCasterChampionIndex = (ChampionIndex)champIndex; + buildSpellAreaLine(kSpellAreaAvailableSymbols); + warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + drawSpellAreaControls((ChampionIndex)champIndex); + dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine2); + buildSpellAreaLine(kSpellAreaChampionSymbols); + dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine3); + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); +} } -- cgit v1.2.3 From 84a91022052bfcdf42f89823e3c24322ef147d26 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 27 Jun 2016 19:40:39 +0200 Subject: DM: Initial TODOs --- engines/dm/TODOs/methodtree.txt | 162 ++++++++++++++++++++++++++++++++++++++++ engines/dm/TODOs/todo.txt | 18 +++++ 2 files changed, 180 insertions(+) create mode 100644 engines/dm/TODOs/methodtree.txt create mode 100644 engines/dm/TODOs/todo.txt diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt new file mode 100644 index 0000000000..088796602e --- /dev/null +++ b/engines/dm/TODOs/methodtree.txt @@ -0,0 +1,162 @@ +F0380_COMMAND_ProcessQueue_CPSC // in progress + C080_COMMAND_CLICK_IN_DUNGEON_VIEW // cool + F0377_COMMAND_ProcessType80_ClickInDungeonView // done so-so + F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall // done so-so + F0275_SENSOR_IsTriggeredByClickOnWall // done so-so + F0280_CHAMPION_AddCandidateChampionToParty // done, so-so + + +F0378_COMMAND_ProcessType81_ClickInPanel + F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel // done + F0368_COMMAND_SetLeader // done + F0457_START_DrawEnabledMenus_CPSF // wat skip + F0281_CHAMPION_Rename // skip + F0394_MENUS_SetMagicCasterAndDrawSpellArea // post skip + F0393_MENUS_DrawSpellAreaControls // post skip + F0051_TEXT_MESSAGEAREA_PrintLineFeed // post skip + F0047_TEXT_MESSAGEAREA_PrintMessage // post skip + F0067_MOUSE_SetPointerToNormal // skip + + + +F0280_CHAMPION_AddCandidateChampionToParty // done, so-so + M27_PORTRAIT_X // done + M28_PORTRAIT_Y // done + F0285_CHAMPION_GetIndexInCell // done + F0279_CHAMPION_GetDecodedValue // done + F0368_COMMAND_SetLeader // done + F0292_CHAMPION_DrawState // done + G0407_s_Party // done + G0048_s_Graphic562_Box_Mouth // done + G0049_s_Graphic562_Box_Eye // done + G0054_ai_Graphic562_Box_ChampionIcons // done + G0353_ac_StringBuildBuffer // done + G0046_auc_Graphic562_ChampionColor // done + F0354_INVENTORY_DrawStatusBoxPortrait // done + F0287_CHAMPION_DrawBarGraphs // done + F0290_CHAMPION_DrawHealthStaminaManaValues // done + F0309_CHAMPION_GetMaximumLoad // done + F0306_CHAMPION_GetStaminaAdjustedValue // done + F0288_CHAMPION_GetStringFromInteger // done + F0345_INVENTORY_DrawPanel_FoodWaterPoisoned // done + F0344_INVENTORY_DrawPanel_FoodOrWaterBar // done + F0343_INVENTORY_DrawPanel_HorizontalBar // done + G0032_s_Graphic562_Box_Panel // done + G0035_s_Graphic562_Box_Food // done + G0036_s_Graphic562_Box_Water // done + G0037_s_Graphic562_Box_Poisoned // done + + F0351_INVENTORY_DrawChampionSkillsAndStatistics // skip ----------------- + F0347_INVENTORY_DrawPanel // done + F0342_INVENTORY_DrawPanel_Object // skip --------------------- + F0346_INVENTORY_DrawPanel_ResurrectReincarnate // done + + F0291_CHAMPION_DrawSlot // done + F0038_OBJECT_DrawIconInSlotBox // done + + + F0140_DUNGEON_GetObjectWeight // done + G0238_as_Graphic559_WeaponInfo // done + WEAPON_INFO // done + G0239_as_Graphic559_ArmourInfo // done + ARMOUR_INFO // done + G0241_auc_Graphic559_JunkInfo // done + JUNK_INFO // done + G0411_i_LeaderIndex // done + G0299_ui_CandidateChampionOrdinal // done + F0388_MENUS_ClearActingChampion // done. + F0292_CHAMPION_DrawState // done + G0508_B_RefreshActionArea // done + G0506_ui_ActingChampionOrdinal // done + F0386_MENUS_DrawActionIcon // done + F0141_DUNGEON_GetObjectInfoIndex // done + F0033_OBJECT_GetIconIndex // done + F0032_OBJECT_GetType // done + G0237_as_Graphic559_ObjectInfo // done + OBJECT_INFO // done + G0029_auc_Graphic562_ChargeCountToTorchType // done + F0134_VIDEO_FillBitmap // done + D24_FillScreenBox // done + F0036_OBJECT_ExtractIconFromBitmap // done + G0026_ai_Graphic562_IconGraphicFirstIconIndex // done + F0129_VIDEO_BlitShrinkWithPaletteChanges // eeeh + F0136_VIDEO_ShadeScreenBox // skip + G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon // done + G0237_as_Graphic559_ObjectInfo // done + G0509_B_ActionAreaContainsIcons // done + F0301_CHAMPION_AddObjectInSlot // skip + F0296_CHAMPION_DrawChangedObjectIcons + F0292_CHAMPION_DrawState // skip + F0034_OBJECT_DrawLeaderHandObjectName // skip + F0295_CHAMPION_HasObjectIconInSlotBoxChanged + M70_HAND_SLOT_INDEX + G0423_i_InventoryChampionOrdinal + G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen + G0412_puc_Bitmap_ObjectIconForMousePointer + G0424_i_PanelContent + G0425_aT_ChestSlots + F0337_INVENTORY_SetDungeonViewPalette + F0299_CHAMPION_ApplyObjectModifiersToStatistics + F0291_CHAMPION_DrawSlot + G0425_aT_ChestSlots + G0423_i_InventoryChampionOrdinal + G0039_ai_Graphic562_LightPowerToLightAmount + G0407_s_Party + F0355_INVENTORY_Toggle_CPSE // done + F0292_CHAMPION_DrawState // done + F0334_INVENTORY_CloseChest // skip + F0395_MENUS_DrawMovementArrows // done + F0357_COMMAND_DiscardAllInput // skip + F0098_DUNGEONVIEW_DrawFloorAndCeiling // wat + F0136_VIDEO_ShadeScreenBox // skip + D25_F0135_VIDEO_FillBox // done + G0423_i_InventoryChampionOrdinal + G0326_B_RefreshMousePointerInMainLoop // lol you wat m8 + G0002_s_Graphic562_Box_MovementArrows // done + G0041_s_Graphic562_Box_ViewportFloppyZzzCross // done + G0296_puc_Bitmap_Viewport // done + G0598_B_MousePointerBitmapUpdated // done + F0456_START_DrawDisabledMenus // done + G0415_B_LeaderEmptyHanded // done + G0305_ui_PartyChampionCount // done + G0578_B_UseByteBoxCoordinates // done + G0047_s_Graphic562_Box_ChampionPortrait // done + G0308_i_PartyDirection // done + G0306_i_PartyMapX // done + G0307_i_PartyMapY // done + G0299_ui_CandidateChampionOrdinal // done + G0508_B_RefreshActionArea // done + G0233_ai_Graphic559_DirectionToStepEastCount // done + G0234_ai_Graphic559_DirectionToStepNorthCount // done + G0237_as_Graphic559_ObjectInfo // done + G0038_ai_Graphic562_SlotMasks // done + +F0462_START_StartGame_CPSF + F0003_MAIN_ProcessNewPartyMap_CPSE // partially done + F0278_CHAMPION_ResetDataToStartGame // paritally done + + G0331_B_PressingEye // dm // done + G0332_B_StopPressingEye // dm // done + G0333_B_PressingMouth // dm // done + G0334_B_StopPressingMouth // dm // done + G0340_B_HighlightBoxInversionRequested // dm, useless // done + G0341_B_HighlightBoxEnabled // eventman // done + G0300_B_PartyIsSleeping // champion // done + G0506_ui_ActingChampionOrdinal // champion // done + G0509_B_ActionAreaContainsIcons // menus // done + G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap // eventman // done + +F0463_START_InitializeGame_CPSADEF // partially done + F0267_MOVE_GetMoveResult_CPSCE // skip, really though + F0357_COMMAND_DiscardAllInput // done + + +C013_GRAPHIC_MOVEMENT_ARROWS + F0395_MENUS_DrawMovementArrows + F0355_INVENTORY_Toggle_CPSE + F0462_START_StartGame_CPSF + F0457_START_DrawEnabledMenus_CPSF + F0314_CHAMPION_WakeUp + F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel + F0380_COMMAND_ProcessQueue_CPSC + F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt new file mode 100644 index 0000000000..ee198d8017 --- /dev/null +++ b/engines/dm/TODOs/todo.txt @@ -0,0 +1,18 @@ +Bugs: + Display: + Broken colour palette + Portraits, alcoves etc. look broken from afar + Ornaments are not displayed if looked at from certain angles + Ornaments are displayed where they should not be, probably error in the pseudo RNG + Command gui is broken + Logic: + Game crashes when reincaranting a fourth champion and trying to copy his portrait + + +Todo: + Add wiki entry for DM + Rename GraphicIndice enum entires and have their name include GraphicIndice + I forgot to add localization warnings + Attend to Arnaud's notes on github + Double check enums with hex literals, I think I screwed the regex when processing them + \ No newline at end of file -- cgit v1.2.3 From 398b309a0373c647ad9cd9c553ad626784d2b459 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 27 Jun 2016 21:46:05 +0200 Subject: DM: Add F0163_DUNGEON_LinkThingToList --- engines/dm/TODOs/methodtree.txt | 17 ++++++++++------ engines/dm/TODOs/todo.txt | 4 ++++ engines/dm/dungeonman.cpp | 45 ++++++++++++++++++++++++++++++++++++++++- engines/dm/dungeonman.h | 1 + 4 files changed, 60 insertions(+), 7 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 088796602e..15e01ee8ee 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -6,13 +6,13 @@ F0380_COMMAND_ProcessQueue_CPSC // in progress F0280_CHAMPION_AddCandidateChampionToParty // done, so-so -F0378_COMMAND_ProcessType81_ClickInPanel +F0378_COMMAND_ProcessType81_ClickInPanel // done so-so F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel // done F0368_COMMAND_SetLeader // done - F0457_START_DrawEnabledMenus_CPSF // wat skip - F0281_CHAMPION_Rename // skip - F0394_MENUS_SetMagicCasterAndDrawSpellArea // post skip - F0393_MENUS_DrawSpellAreaControls // post skip + F0457_START_DrawEnabledMenus_CPSF // can't yet see it's purpose + F0281_CHAMPION_Rename // stub + F0394_MENUS_SetMagicCasterAndDrawSpellArea // done + F0393_MENUS_DrawSpellAreaControls // done F0051_TEXT_MESSAGEAREA_PrintLineFeed // post skip F0047_TEXT_MESSAGEAREA_PrintMessage // post skip F0067_MOUSE_SetPointerToNormal // skip @@ -104,7 +104,12 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so G0407_s_Party F0355_INVENTORY_Toggle_CPSE // done F0292_CHAMPION_DrawState // done - F0334_INVENTORY_CloseChest // skip + F0334_INVENTORY_CloseChest + F0163_DUNGEON_LinkThingToList + G0426_T_OpenChest + G0425_aT_ChestSlots + + F0395_MENUS_DrawMovementArrows // done F0357_COMMAND_DiscardAllInput // skip F0098_DUNGEONVIEW_DrawFloorAndCeiling // wat diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index ee198d8017..558fc8a3e2 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -9,10 +9,14 @@ Bugs: Game crashes when reincaranting a fourth champion and trying to copy his portrait + Todo: Add wiki entry for DM Rename GraphicIndice enum entires and have their name include GraphicIndice I forgot to add localization warnings Attend to Arnaud's notes on github Double check enums with hex literals, I think I screwed the regex when processing them + + Missing functions: + Add missing F0163_DUNGEON_LinkThingToList in MovesensMan::sensorIsTriggeredByClickOnWall (I don't think it's safe yet) \ No newline at end of file diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 755a7d8cd7..7de4d76e60 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1246,4 +1246,47 @@ int16 DungeonMan::getObjectInfoIndex(Thing thing) { } } -} \ No newline at end of file +void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) { + if (thingToLink == Thing::_thingEndOfList) + return; + + uint16 *rawObjPtr = getThingData(thingToLink); + *rawObjPtr = Thing::_thingEndOfList.toUint16(); + + if (mapX >= 0) { + Square *squarePtr = (Square*)&_currMap._data[mapX][mapY]; + if (squarePtr->get(kThingListPresent)) { + thingInList = getSquareFirstThing(mapX, mapY); + } else { + squarePtr->set(kThingListPresent); + uint16 *cumulativeCount = &_currMap._colCumulativeSquareFirstThingCount[mapX + 1]; + uint16 column = _dunData._columCount - (_dunData._mapsFirstColumnIndex[_currMap._index] + mapX) - 1; + while (column--) { + (*cumulativeCount++)++; + } + uint16 mapYStep = 0; + squarePtr -= mapY; + uint16 squareFirstThingIndex = _currMap._colCumulativeSquareFirstThingCount[mapX]; + while (mapYStep++ != mapY) { + if (squarePtr->get(kThingListPresent)) { + squareFirstThingIndex++; + } + squarePtr++; + } + Thing* thingPtr = &_dunData._squareFirstThings[squareFirstThingIndex]; + memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_fileHeader._squareFirstThingCount - squareFirstThingIndex - 1)); + *thingPtr = thingToLink; + return; + } + } + + Thing thing = getNextThing(thingInList); + while (thing != Thing::_thingEndOfList) { + thing = getNextThing(thing); + thingInList = thing; + } + rawObjPtr = getThingData(thingInList); + *rawObjPtr = thingToLink.toUint16(); +} + +} diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 5191ba9867..064ea49056 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -641,6 +641,7 @@ public: uint16 getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight int16 getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex + void linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList uint32 _rawDunFileDataSize; // @ probably NONE byte *_rawDunFileData; // @ ??? -- cgit v1.2.3 From 7ecd3333d7821aa69fa3df4ebbffb33228f43171 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 27 Jun 2016 20:29:22 +0200 Subject: DM: Fix and simplify commandProcessType80ClickInDungeonViewTouchFrontWall() --- engines/dm/eventman.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 4e5a59cb91..6d39a12ef8 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -508,14 +508,9 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) { void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() { DungeonMan &dunMan = *_vm->_dungeonMan; CurrMapData &currMap = dunMan._currMap; - uint16 mapX = currMap._partyPosX; - uint16 mapY = currMap._partyPosY; - mapX += gDirIntoStepCountEast[currMap._partyDir]; - mapY += gDirIntoStepCountNorth[currMap._partyDir]; - if ((mapX >= 0) - && (mapX < currMap._width) - && (mapY >= 0) - && (mapY < currMap._height)) { + int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir]; + int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir]; + if ((mapX >= 0) && (mapX < currMap._width) && (mapY >= 0) && (mapY < currMap._height)) { _vm->_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._partyDir)); } } @@ -528,7 +523,6 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY int16 mapX; int16 mapY; - if (dunMan._squareAheadElement == kElementTypeDoorFront) { if (champMan._leaderIndex == kChampionNone) { return; -- cgit v1.2.3 From f00f5c19e73204ba44ed508871bb50d348e62a5b Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:40:13 +0200 Subject: DM: Add G0426_T_OpenChest, F0334_INVENTORY_CloseChest --- engines/dm/TODOs/methodtree.txt | 8 ++++---- engines/dm/dungeonman.cpp | 4 ++-- engines/dm/dungeonman.h | 10 ++++++---- engines/dm/inventory.cpp | 37 ++++++++++++++++++++++++++++++++++--- engines/dm/inventory.h | 2 ++ engines/dm/menus.cpp | 4 +++- 6 files changed, 51 insertions(+), 14 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 15e01ee8ee..36237c2205 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -104,10 +104,10 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so G0407_s_Party F0355_INVENTORY_Toggle_CPSE // done F0292_CHAMPION_DrawState // done - F0334_INVENTORY_CloseChest - F0163_DUNGEON_LinkThingToList - G0426_T_OpenChest - G0425_aT_ChestSlots + F0334_INVENTORY_CloseChest // done + F0163_DUNGEON_LinkThingToList // done + G0426_T_OpenChest // done + G0425_aT_ChestSlots // done F0395_MENUS_DrawMovementArrows // done diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 7de4d76e60..6d5a54069d 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1194,8 +1194,8 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { } case kContainerThingType: { uint16 weight = 50; - Container container = getThingData(thing); - Thing slotThing = container.getNextContainedThing(); + Container container(getThingData(thing)); + Thing slotThing = container.getSlot(); while (slotThing != Thing::_thingEndOfList) { weight += getObjectWeight(slotThing); slotThing = getNextThing(slotThing); diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 064ea49056..1175298917 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -34,6 +34,8 @@ namespace DM { +#define kMapXNotOnASquare -1 // @ CM1_MAPX_NOT_ON_A_SQUARE + enum ElementType { kElementTypeChampion = -2, // @ CM2_ELEMENT_CHAMPION /* Values -2 and -1 are only used as projectile impact types */ kElementTypeCreature = -1, // @ CM1_ELEMENT_CREATURE @@ -417,14 +419,14 @@ public: class Container { Thing _nextThing; - Thing _nextContainedThing; + Thing _slot; uint16 _type; public: - explicit Container(uint16 *rawDat) : _nextThing(rawDat[0]), _nextContainedThing(rawDat[1]), _type(rawDat[2]) {} + explicit Container(uint16 *rawDat) : _nextThing(rawDat[0]), _slot(rawDat[1]), _type(rawDat[2]) {} uint16 getType() { return (_type >> 1) & 0x3; } - Thing getNextContainedThing() { return _nextContainedThing; } - Thing getNextThing() { return _nextThing; } + Thing &getSlot() { return _slot; } + Thing &getNextThing() { return _nextThing; } }; // @ CONTAINER enum JunkType { diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 550c4c85c6..c02aed4494 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -46,6 +46,8 @@ InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) { _panelContent = kPanelContentFoodWaterPoisoned; for (uint16 i = 0; i < 8; ++i) _chestSlots[i] = Thing::_thingNone; + _openChest = Thing::_thingNone; + _openChest = Thing::_thingNone; } void InventoryMan::toggleInventory(ChampionIndex championIndex) { @@ -66,7 +68,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { Champion *champion; if (invChampOrdinal) { _inventoryChampionOrdinal = _vm->indexToOrdinal(kChampionNone); - warning("MISSING CODE: F0334_INVENTORY_CloseChest"); + closeChest(); champion = &cm._champions[_vm->ordinalToIndex(invChampOrdinal)]; if (champion->_currHealth && !cm._candidateChampionOrdinal) { champion->setAttributeFlag(kChampionAttributeStatusBox, true); @@ -159,7 +161,7 @@ void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) { void InventoryMan::drawPanelFoodWaterPoisoned() { Champion &champ = _vm->_championMan->_champions[_inventoryChampionOrdinal]; - warning("MISSING CODE: F0334_INVENTORY_CloseChest"); + closeChest(); DisplayMan &dispMan = *_vm->_displayMan; dispMan.blitToScreen(dispMan.getBitmap(kPanelEmptyIndice), 144, 0, 0, gBoxPanel, kColorRed); dispMan.blitToScreen(dispMan.getBitmap(kFoodLabelIndice), 48, 0, 0, gBoxFood, kColorDarkestGray); @@ -177,7 +179,8 @@ void InventoryMan::drawPanelResurrectReincarnate() { } void InventoryMan::drawPanel() { - warning("MISSING CODE: F0334_INVENTORY_CloseChest, altho adding it may reintroduce BUG0_48"); + warning("possible reintroduction of BUG0_48"); + closeChest(); // possibility of BUG0_48 ChampionMan &cm = *_vm->_championMan; if (cm._candidateChampionOrdinal) { @@ -205,4 +208,32 @@ void InventoryMan::drawPanel() { warning("MISSING CODE: F0342_INVENTORY_DrawPanel_Object(L1075_T_Thing, C0_FALSE);"); } } + +void InventoryMan::closeChest() { + DungeonMan &dunMan = *_vm->_dungeonMan; + + bool processFirstChestSlot = true; + if (_openChest == Thing::_thingNone) + return; + Container *container = (Container*)dunMan.getThingData(_openChest); + _openChest = Thing::_thingNone; + container->getSlot() = Thing::_thingEndOfList; + Thing prevThing; + for (int16 chestSlotIndex = 0; chestSlotIndex < 8; ++chestSlotIndex) { + Thing thing = _chestSlots[chestSlotIndex]; + if (thing != Thing::_thingNone) { + _chestSlots[chestSlotIndex] = Thing::_thingNone; // CHANGE8_09_FIX + + if (processFirstChestSlot) { + processFirstChestSlot = false; + *dunMan.getThingData(thing) = Thing::_thingEndOfList.toUint16(); + container->getSlot() = prevThing = thing; + } else { + dunMan.linkThingToList(thing, prevThing, kMapXNotOnASquare, 0); + prevThing = thing; + } + } + } +} + } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index f225e417bd..8457e98faa 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -55,6 +55,7 @@ public: int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal PanelContent _panelContent; // @ G0424_i_PanelContent Thing _chestSlots[8]; // @ G0425_aT_ChestSlots + Thing _openChest; // @ G0426_T_OpenChest void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait @@ -63,6 +64,7 @@ public: void drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned void drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate void drawPanel(); // @ F0347_INVENTORY_DrawPanel + void closeChest(); // @ F0334_INVENTORY_CloseChest }; diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index dfbe5b564e..d6c09d85e6 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -124,7 +124,9 @@ void MenuMan::drawDisabledMenu() { warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); _vm->_displayMan->_useByteBoxCoordinates = false; if (_vm->_inventoryMan->_inventoryChampionOrdinal) { - warning("MISSING CODE: F0334_INVENTORY_CloseChest"); + if (_vm->_inventoryMan->_panelContent == kPanelContentChest) { + _vm->_inventoryMan->closeChest(); + } } else { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } -- cgit v1.2.3 From d770ec0f61a8fea8a2e276be6c6b841dab01bae2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 27 Jun 2016 22:01:40 +0200 Subject: DM: Reduce scope of a couple of variables, simplify a couple of lines --- engines/dm/eventman.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 6d39a12ef8..96cda36747 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -520,19 +520,14 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY ChampionMan &champMan = *_vm->_championMan; CurrMapData &currMap = _vm->_dungeonMan->_currMap; - int16 mapX; - int16 mapY; - if (dunMan._squareAheadElement == kElementTypeDoorFront) { - if (champMan._leaderIndex == kChampionNone) { + if (champMan._leaderIndex == kChampionNone) return; - } - mapX = currMap._partyPosX; - mapY = currMap._partyPosY; - mapX += gDirIntoStepCountEast[currMap._partyDir]; - mapY += gDirIntoStepCountNorth[currMap._partyDir]; if (champMan._leaderEmptyHanded) { + int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir]; + int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir]; + if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() && dunMan._dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { _vm->_stopWaitingForPlayerInput = true; @@ -590,7 +585,6 @@ T0377019: commandProcessType80ClickInDungeonViewTouchFrontWall(); } } - } else { warning("MISSING CODE: F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown in if branch"); for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellBackLeft; viewCell++) { @@ -633,11 +627,9 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane } champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone); - int16 mapX = currMap._partyPosX; - int16 mapY = currMap._partyPosY; + int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir]; + int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir]; - mapX += gDirIntoStepCountEast[currMap._partyDir]; - mapY += gDirIntoStepCountNorth[currMap._partyDir]; for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) { Thing thing = champ->getSlot((ChampionSlot)slotIndex); if (thing != Thing::_thingNone) { -- cgit v1.2.3 From 0d314b9bea506a75da3e5d54763759a33851b18d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 27 Jun 2016 22:41:18 +0200 Subject: DM: Fix a GCC warning, fix code alignment in hasPendingClick --- engines/dm/eventman.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 96cda36747..437a02d01b 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -694,13 +694,16 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) { if (commandType != kCommandNone) commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType); break; + default: + break; } } - bool EventManager::hasPendingClick(Common::Point& point, MouseButton button) - { - if (_pendingClickButton && button == _pendingClickButton) - point = _pendingClickPos; - return _pendingClickPresent; - } +bool EventManager::hasPendingClick(Common::Point& point, MouseButton button) { + if (_pendingClickButton && button == _pendingClickButton) + point = _pendingClickPos; + + return _pendingClickPresent; +} + }; // end of namespace DM -- cgit v1.2.3 From 5859ff8aaf63772a19e3576f24cec24286d98dff Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 27 Jun 2016 23:00:33 +0200 Subject: DM: Remove extra semi-column --- engines/dm/eventman.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 437a02d01b..5c9e68bc05 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -706,4 +706,4 @@ bool EventManager::hasPendingClick(Common::Point& point, MouseButton button) { return _pendingClickPresent; } -}; // end of namespace DM +} // end of namespace DM -- cgit v1.2.3 From 703fd8aca2e15edc03aa854365e20bfdcf524add Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 27 Jun 2016 23:07:18 +0200 Subject: DM: Fix bug in getIconIndex --- engines/dm/objectman.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index d20c235aa0..c92427bf4b 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -108,9 +108,9 @@ IconIndice ObjectMan::getIconIndex(Thing thing) { IconIndice iconIndex = getObjectType(thing); if ((iconIndex != kIconIndiceNone) && - ((iconIndex < kIconIndiceWeaponDagger) && (iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error - ((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) || - (iconIndex == kIconIndicePotionEmptyFlask) + (((iconIndex < kIconIndiceWeaponDagger) && (iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error + ((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) || + (iconIndex == kIconIndicePotionEmptyFlask)) ) { uint16 *rawType = _vm->_dungeonMan->getThingData(thing); switch (iconIndex) { -- cgit v1.2.3 From 652b2c6f98f291a76397c9035e4f8338b9c792f9 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 27 Jun 2016 23:38:37 +0200 Subject: DM: Add F0340_INVENTORY_DrawPanel_ScrollTextLine --- engines/dm/TODOs/methodtree.txt | 28 +++++++++++++++++++--------- engines/dm/inventory.cpp | 12 +++++++++++- engines/dm/inventory.h | 1 + engines/dm/text.cpp | 4 ++-- engines/dm/text.h | 2 +- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 36237c2205..a672a8a9f3 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -45,16 +45,27 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so G0035_s_Graphic562_Box_Food // done G0036_s_Graphic562_Box_Water // done G0037_s_Graphic562_Box_Poisoned // done - F0351_INVENTORY_DrawChampionSkillsAndStatistics // skip ----------------- F0347_INVENTORY_DrawPanel // done - F0342_INVENTORY_DrawPanel_Object // skip --------------------- - F0346_INVENTORY_DrawPanel_ResurrectReincarnate // done + F0342_INVENTORY_DrawPanel_Object + F0341_INVENTORY_DrawPanel_Scroll + F0340_INVENTORY_DrawPanel_ScrollTextLine // done + F0333_INVENTORY_OpenAndDrawChest + F0303_CHAMPION_GetSkillLevel + F0332_INVENTORY_DrawIconToViewport + F0336_INVENTORY_DrawPanel_BuildObjectAttributesString + F0335_INVENTORY_DrawPanel_ObjectDescriptionString + F0339_INVENTORY_DrawPanel_ArrowOrEye + G0430_apc_DirectionNames + G0034_s_Graphic562_Box_ObjectDescriptionCircle + G0032_s_Graphic562_Box_Panel + G0352_apc_ObjectNames + G0237_as_Graphic559_ObjectInfo + G0422_i_ObjectDescriptionTextY + F0346_INVENTORY_DrawPanel_ResurrectReincarnate // done F0291_CHAMPION_DrawSlot // done F0038_OBJECT_DrawIconInSlotBox // done - - F0140_DUNGEON_GetObjectWeight // done G0238_as_Graphic559_WeaponInfo // done WEAPON_INFO // done @@ -108,8 +119,6 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so F0163_DUNGEON_LinkThingToList // done G0426_T_OpenChest // done G0425_aT_ChestSlots // done - - F0395_MENUS_DrawMovementArrows // done F0357_COMMAND_DiscardAllInput // skip F0098_DUNGEONVIEW_DrawFloorAndCeiling // wat @@ -135,11 +144,11 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so G0234_ai_Graphic559_DirectionToStepNorthCount // done G0237_as_Graphic559_ObjectInfo // done G0038_ai_Graphic562_SlotMasks // done - + + F0462_START_StartGame_CPSF F0003_MAIN_ProcessNewPartyMap_CPSE // partially done F0278_CHAMPION_ResetDataToStartGame // paritally done - G0331_B_PressingEye // dm // done G0332_B_StopPressingEye // dm // done G0333_B_PressingMouth // dm // done @@ -151,6 +160,7 @@ F0462_START_StartGame_CPSF G0509_B_ActionAreaContainsIcons // menus // done G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap // eventman // done + F0463_START_InitializeGame_CPSADEF // partially done F0267_MOVE_GetMoveResult_CPSCE // skip, really though F0357_COMMAND_DiscardAllInput // done diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index c02aed4494..1a08022e62 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -33,7 +33,6 @@ #include "text.h" - namespace DM { Box gBoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross @@ -236,4 +235,15 @@ void InventoryMan::closeChest() { } } +void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) { + warning("CHANGE5_03_IMPROVEMENT"); + for (char* iter = text; *iter != '\0'; ++iter) { + if ((*iter >= 'A') && (*iter <= 'Z')) { + *iter -= 64; + } else if (*iter >= '{') { // this branch is CHANGE5_03_IMPROVEMENT + *iter -= 96; + } + } + _vm->_textMan->printToViewport(162 - (6 * strlen(text) / 2), yPos, kColorBlack, text, kColorWhite); +} } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 8457e98faa..fe974b6c1b 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -65,6 +65,7 @@ public: void drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate void drawPanel(); // @ F0347_INVENTORY_DrawPanel void closeChest(); // @ F0334_INVENTORY_CloseChest + void drawPanelScrollTextLine(int16 yPos, char *text); // @ F0340_INVENTORY_DrawPanel_ScrollTextLine }; diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index ab22ac473e..f8aabb31df 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -69,8 +69,8 @@ void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Col printTextToBitmap(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport); } -void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text) { - printTextToScreen(posX, posY, textColor, kColorDarkestGray, text, gDungeonViewport); +void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) { + printTextToScreen(posX, posY, textColor, bgColor, text, gDungeonViewport); } void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, diff --git a/engines/dm/text.h b/engines/dm/text.h index b03d00a00d..590fade60d 100644 --- a/engines/dm/text.h +++ b/engines/dm/text.h @@ -40,7 +40,7 @@ public: void printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, Viewport &viewport = gDefultViewPort); // @ F0053_TEXT_PrintToLogicalScreen - void printToViewport(int16 posX, int16 posY, Color textColor, const char *text); // @ F0052_TEXT_PrintToViewport + void printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = kColorDarkestGray); // @ F0052_TEXT_PrintToViewport void printWithTrailingSpaces(byte *destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor, const char *text, int16 strLenght, int16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0041_TEXT_PrintWithTrailingSpaces void printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor, -- cgit v1.2.3 From 49aae8932bcb4698c37516f00ae2f6728044b0bd Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 28 Jun 2016 00:30:32 +0200 Subject: DM: Add F0341_INVENTORY_DrawPanel_Scroll --- engines/dm/dm.h | 2 +- engines/dm/dungeonman.h | 1 + engines/dm/gfx.h | 3 ++- engines/dm/inventory.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/inventory.h | 2 ++ 5 files changed, 54 insertions(+), 2 deletions(-) diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 5a7e548448..19eda10dfd 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -106,7 +106,7 @@ public: byte getCell() const { return _data >> 14; } ThingType getType() const { return (ThingType)((_data >> 10) & 0xF); } - uint16 getIndex() const { return _data & 0x1FF; } + uint16 getIndex() const { return _data & 0x3FF; } uint16 toUint16() const { return _data; } // I don't like 'em cast operators bool operator==(const Thing &rhs) const { return _data == rhs._data; } bool operator!=(const Thing &rhs) const { return _data != rhs._data; } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 1175298917..767044e9af 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -389,6 +389,7 @@ public: } Thing getNextThing() { return _nextThing; } uint16 getClosed() { return (_attributes >> 10) & 0x3F; } // ??? dunno why, the original bitfield is 6 bits long + uint16 getTextStringThingIndex() { return _attributes & 0x3FF; } }; // @ SCROLL enum PotionType { diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 9354b99de3..3ff4bf5c33 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -74,7 +74,8 @@ enum GraphicIndice { kPanelRenameChampionIndice = 27, // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION kMenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA kMenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES - kMenuSpellAreaBackground = 9 // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND + kMenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND + kPanelOpenScrollIndice = 23 // @ C023_GRAPHIC_PANEL_OPEN_SCROLL }; extern uint16 gPalSwoosh[16]; diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 1a08022e62..eb3192aae1 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -246,4 +246,52 @@ void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) { } _vm->_textMan->printToViewport(162 - (6 * strlen(text) / 2), yPos, kColorBlack, text, kColorWhite); } + +void InventoryMan::drawPanelScroll(Scroll* scroll) { + DisplayMan &dispMan = *_vm->_displayMan; + + char stringFirstLine[300]; + _vm->_dungeonMan->decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible)); + char *charRed = stringFirstLine; + while (*charRed && (*charRed != '\n')) { + charRed++; + } + *charRed = '\0'; + dispMan.blitToScreen(dispMan.getBitmap(kPanelOpenScrollIndice), 144, 0, 0, gBoxPanel, kColorRed, gDungeonViewport); + int16 lineCount = 1; + charRed++; + char *charGreen = charRed; // first char of the second line + while (*charGreen) { + warning("BUG0_47"); + /* BUG0_47 Graphical glitch when you open a scroll. If there is a single line of text in a scroll + (with no carriage return) then charGreen points to undefined data. This may result in a graphical + glitch and also corrupt other memory. This is not an issue in the original dungeons where all + scrolls contain at least one carriage return character */ + if (*charGreen == '\n') { + lineCount++; + } + charGreen++; + } + if (*(charGreen - 1) != '\n') { + lineCount++; + } else if (*(charGreen - 2) == '\n') { + lineCount--; + } + int16 yPos = 92 - (7 * lineCount) / 2; // center the text vertically + drawPanelScrollTextLine(yPos, stringFirstLine); + charGreen = charRed; + while (*charGreen) { + yPos += 7; + while (*charRed && (*charRed != '\n')) { + charRed++; + } + if (!(*charRed)) { + charRed[1] = '\0'; + } + *charRed++ = '\0'; + drawPanelScrollTextLine(yPos, charGreen); + charGreen = charRed; + } +} + } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index fe974b6c1b..3f6783b37c 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -28,6 +28,7 @@ #include "dm.h" #include "gfx.h" #include "champion.h" +#include "dungeonman.h" @@ -66,6 +67,7 @@ public: void drawPanel(); // @ F0347_INVENTORY_DrawPanel void closeChest(); // @ F0334_INVENTORY_CloseChest void drawPanelScrollTextLine(int16 yPos, char *text); // @ F0340_INVENTORY_DrawPanel_ScrollTextLine + void drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll }; -- cgit v1.2.3 From ebdcac50734b4a1e297e40af6d096c52b183e4d9 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 28 Jun 2016 01:13:52 +0200 Subject: DM: Add F0333_INVENTORY_OpenAndDrawChest --- engines/dm/TODOs/methodtree.txt | 4 ++-- engines/dm/gfx.h | 3 ++- engines/dm/inventory.cpp | 40 ++++++++++++++++++++++++++++++++++++++-- engines/dm/inventory.h | 2 ++ 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index a672a8a9f3..a352403ccb 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -48,9 +48,9 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so F0351_INVENTORY_DrawChampionSkillsAndStatistics // skip ----------------- F0347_INVENTORY_DrawPanel // done F0342_INVENTORY_DrawPanel_Object - F0341_INVENTORY_DrawPanel_Scroll + F0341_INVENTORY_DrawPanel_Scroll // done F0340_INVENTORY_DrawPanel_ScrollTextLine // done - F0333_INVENTORY_OpenAndDrawChest + F0333_INVENTORY_OpenAndDrawChest // done F0303_CHAMPION_GetSkillLevel F0332_INVENTORY_DrawIconToViewport F0336_INVENTORY_DrawPanel_BuildObjectAttributesString diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 3ff4bf5c33..25ffbb220e 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -75,7 +75,8 @@ enum GraphicIndice { kMenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA kMenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES kMenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND - kPanelOpenScrollIndice = 23 // @ C023_GRAPHIC_PANEL_OPEN_SCROLL + kPanelOpenScrollIndice = 23, // @ C023_GRAPHIC_PANEL_OPEN_SCROLL + kPanelOpenChestIndice = 25 // @ C025_GRAPHIC_PANEL_OPEN_CHEST }; extern uint16 gPalSwoosh[16]; diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index eb3192aae1..a64c489f45 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -31,6 +31,7 @@ #include "menus.h" #include "gfx.h" #include "text.h" +#include "objectman.h" namespace DM { @@ -254,7 +255,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) { _vm->_dungeonMan->decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible)); char *charRed = stringFirstLine; while (*charRed && (*charRed != '\n')) { - charRed++; + charRed++; } *charRed = '\0'; dispMan.blitToScreen(dispMan.getBitmap(kPanelOpenScrollIndice), 144, 0, 0, gBoxPanel, kColorRed, gDungeonViewport); @@ -265,7 +266,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) { warning("BUG0_47"); /* BUG0_47 Graphical glitch when you open a scroll. If there is a single line of text in a scroll (with no carriage return) then charGreen points to undefined data. This may result in a graphical - glitch and also corrupt other memory. This is not an issue in the original dungeons where all + glitch and also corrupt other memory. This is not an issue in the original dungeons where all scrolls contain at least one carriage return character */ if (*charGreen == '\n') { lineCount++; @@ -294,4 +295,39 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) { } } +void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool isPressingEye) { + DisplayMan &dispMan = *_vm->_displayMan; + ObjectMan &objMan = *_vm->_objectMan; + + if (_openChest == thingToOpen) + return; + + warning("CHANGE8_09_FIX"); + if (_openChest != Thing::_thingNone) + closeChest(); // CHANGE8_09_FIX + + _openChest = thingToOpen; + if (!isPressingEye) { + objMan.drawIconInSlotBox(kSlotBoxInventoryActionHand, kIconIndiceContainerChestOpen); + } + dispMan.blitToScreen(dispMan.getBitmap(kPanelOpenChestIndice), 144, 0, 0, gBoxPanel, kColorRed); + + int16 chestSlotIndex = 0; + Thing thing = chest->getSlot(); + int16 thingCount = 0; + while (thing != Thing::_thingEndOfList) { + warning("CHANGE8_08_FIX"); + if (++thingCount > 8) + break; // CHANGE8_08_FIX, make sure that no more than the first 8 objects in a chest are drawn + + objMan.drawIconInSlotBox(chestSlotIndex + kSlotBoxChestFirstSlot, objMan.getIconIndex(thing)); + _chestSlots[chestSlotIndex++] = thing; + thing = _vm->_dungeonMan->getNextThing(thing); + } + while (chestSlotIndex < 8) { + objMan.drawIconInSlotBox(chestSlotIndex + kSlotBoxChestFirstSlot, kIconIndiceNone); + _chestSlots[chestSlotIndex++] = Thing::_thingNone; + } +} + } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 3f6783b37c..3232ab5d1d 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -35,6 +35,7 @@ namespace DM { #define kChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING +#define kSlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT extern Box gBoxPanel; // @ G0032_s_Graphic562_Box_Panel @@ -68,6 +69,7 @@ public: void closeChest(); // @ F0334_INVENTORY_CloseChest void drawPanelScrollTextLine(int16 yPos, char *text); // @ F0340_INVENTORY_DrawPanel_ScrollTextLine void drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll + void openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye); // @ F0333_INVENTORY_OpenAndDrawChest }; -- cgit v1.2.3 From d6af931ad7d921e3a6e947634c4efcffef6545d0 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 28 Jun 2016 01:50:02 +0200 Subject: DM: Add F0303_CHAMPION_GetSkillLevel --- engines/dm/champion.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/champion.h | 6 ++++- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b8676c803e..c974a71d59 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -717,6 +717,68 @@ void ChampionMan::renameChampion(Champion* champ) { dispMan.updateScreen(); } } + +uint16 ChampionMan::getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex) { + if (_partyIsSleeping) + return 1; + + bool ignoreTempExp = skillIndex & kIgnoreTemporaryExperience; + bool ignoreObjModifiers = skillIndex & kIgnoreObjectModifiers; + skillIndex = (ChampionSkill)(skillIndex & ~(ignoreTempExp | ignoreObjModifiers)); + Champion *champ = &_champions[champIndex]; + Skill *skill = &champ->getSkill(skillIndex); + int32 experience = skill->_experience; + + if (!ignoreTempExp) + experience += skill->_temporaryExperience; + + if (skillIndex > kChampionSkillWizard) { // hidden skill + skill = &champ->getSkill((ChampionSkill)((skillIndex - kChampionSkillSwing) / 4)); + experience += skill->_experience; // add exp to the base skill + if (!ignoreTempExp) + experience += skill->_temporaryExperience; + + experience /= 2; // halve the exp to get avarage of base skill + hidden skill exp + } + + int16 skillLevel = 1; + while (experience >= 500) { + experience /= 2; + skillLevel++; + } + + if (!ignoreObjModifiers) { + IconIndice actionHandIconIndex = _vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotActionHand)); + if (actionHandIconIndex == kIconIndiceWeaponTheFirestaff) { + skillLevel++; + } else if (actionHandIconIndex == kIconIndiceWeaponTheFirestaffComplete) { + skillLevel += 2; + } + + IconIndice neckIconIndice = _vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotNeck)); + switch (skillIndex) { + case kChampionSkillWizard: + if (neckIconIndice == kIconIndiceJunkPendantFeral) + skillLevel++; + break; + case kChampionSkillDefend: + if (neckIconIndice == kIconIndiceJunkEkkhardCross) + skillLevel++; + break; + case kChampionSkillHeal: + // these two are not cummulative + if ((neckIconIndice == kIconIndiceJunkGemOfAges) || (neckIconIndice == kIconIndiceWeaponSceptreOfLyf)) + skillLevel++; + break; + case kChampionSkillInfluence: + if (neckIconIndice == kIconIndiceJunkMoonstone) + skillLevel++; + break; + } + } + return skillLevel; +} + } diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 3e72be3850..86425b48c7 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -35,6 +35,9 @@ namespace DM { +#define kIgnoreObjectModifiers 0x4000 // @ MASK0x4000_IGNORE_OBJECT_MODIFIERS +#define kIgnoreTemporaryExperience 0x8000 // @ MASK0x8000_IGNORE_TEMPORARY_EXPERIENCE + extern Box gBoxChampionIcons[4]; // @ G0054_ai_Graphic562_Box_ChampionIcons extern Color gChampionColor[4]; // @ G0046_auc_Graphic562_ChampionColor @@ -365,7 +368,7 @@ public: Thing getSlot(ChampionSlot slot) { return _slots[slot]; } void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; } - Skill getSkill(ChampionSkill skill) { return _skills[skill]; } + Skill &getSkill(ChampionSkill skill) { return _skills[skill]; } void setSkillExp(ChampionSkill skill, int32 val) { _skills[skill]._experience = val; } void setSkillTempExp(ChampionSkill skill, int16 val) { _skills[skill]._temporaryExperience= val; } @@ -453,6 +456,7 @@ public: void drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues void drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot void renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename + uint16 getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel }; -- cgit v1.2.3 From 17f2a7f2e64caddaf437bac9947c1e15e659725b Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 28 Jun 2016 13:07:50 +0200 Subject: DM: Add F0332_INVENTORY_DrawIconToViewport --- engines/dm/TODOs/methodtree.txt | 6 +++--- engines/dm/inventory.cpp | 10 +++++++++- engines/dm/inventory.h | 1 + engines/dm/objectman.h | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index a352403ccb..60f6b47034 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -51,8 +51,8 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so F0341_INVENTORY_DrawPanel_Scroll // done F0340_INVENTORY_DrawPanel_ScrollTextLine // done F0333_INVENTORY_OpenAndDrawChest // done - F0303_CHAMPION_GetSkillLevel - F0332_INVENTORY_DrawIconToViewport + F0303_CHAMPION_GetSkillLevel // done + F0332_INVENTORY_DrawIconToViewport // done F0336_INVENTORY_DrawPanel_BuildObjectAttributesString F0335_INVENTORY_DrawPanel_ObjectDescriptionString F0339_INVENTORY_DrawPanel_ArrowOrEye @@ -75,7 +75,7 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so JUNK_INFO // done G0411_i_LeaderIndex // done G0299_ui_CandidateChampionOrdinal // done - F0388_MENUS_ClearActingChampion // done. + F0388_MENUS_ClearActingChampion // done F0292_CHAMPION_DrawState // done G0508_B_RefreshActionArea // done G0506_ui_ActingChampionOrdinal // done diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index a64c489f45..7124e1b5ef 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -311,7 +311,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is objMan.drawIconInSlotBox(kSlotBoxInventoryActionHand, kIconIndiceContainerChestOpen); } dispMan.blitToScreen(dispMan.getBitmap(kPanelOpenChestIndice), 144, 0, 0, gBoxPanel, kColorRed); - + int16 chestSlotIndex = 0; Thing thing = chest->getSlot(); int16 thingCount = 0; @@ -330,4 +330,12 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is } } +void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos) { + static byte iconBitmap[16 * 16]; + Box box; + box._x2 = (box._x1 = xPos) + 15 + 1; + box._y2 = (box._y1 = yPos) + 15 + 1; + _vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap); + _vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, kColorNoTransparency, gDungeonViewport); +} } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 3232ab5d1d..4b06ce0e79 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -70,6 +70,7 @@ public: void drawPanelScrollTextLine(int16 yPos, char *text); // @ F0340_INVENTORY_DrawPanel_ScrollTextLine void drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll void openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye); // @ F0333_INVENTORY_OpenAndDrawChest + void drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos); // @ F0332_INVENTORY_DrawIconToViewport }; diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index a2ceafefbe..1dbba692bf 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -54,7 +54,7 @@ public: IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex - void extractIconFromBitmap(uint16 iconIndex, byte *srcBitmap); // F0036_OBJECT_ExtractIconFromBitmap + void extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // F0036_OBJECT_ExtractIconFromBitmap void drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox }; -- cgit v1.2.3 From cb9979fade6cd5746ea54c261bdaa8c28e375f3e Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 28 Jun 2016 13:23:12 +0200 Subject: DM: Add F0336_INVENTORY_DrawPanel_BuildObjectAttributesString --- engines/dm/TODOs/methodtree.txt | 2 +- engines/dm/inventory.cpp | 31 +++++++++++++++++++++++++++++++ engines/dm/inventory.h | 2 ++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 60f6b47034..064e09581a 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -53,7 +53,7 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so F0333_INVENTORY_OpenAndDrawChest // done F0303_CHAMPION_GetSkillLevel // done F0332_INVENTORY_DrawIconToViewport // done - F0336_INVENTORY_DrawPanel_BuildObjectAttributesString + F0336_INVENTORY_DrawPanel_BuildObjectAttributesString // done F0335_INVENTORY_DrawPanel_ObjectDescriptionString F0339_INVENTORY_DrawPanel_ArrowOrEye G0430_apc_DirectionNames diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 7124e1b5ef..b23321bb3c 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -338,4 +338,35 @@ void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yP _vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap); _vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, kColorNoTransparency, gDungeonViewport); } + +void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) { + uint16 identicalBitCount = 0; + int16 attribMask = 1; + for (uint16 stringIndex = 0; stringIndex < 16; stringIndex++, attribMask <<= 1) { + if (attribMask & potentialAttribMask & actualAttribMask) { + identicalBitCount++; + } + } + + if (identicalBitCount == 0) { + *destString = '\0'; + return; + } + + strcpy(destString, prefixString); + + attribMask = 1; + for (uint16 stringIndex = 0; stringIndex < 16; stringIndex++, attribMask <<= 1) { + if (attribMask & potentialAttribMask & actualAttribMask) { + strcat(destString, attribStrings[stringIndex]); + if (identicalBitCount-- > 2) { + strcat(destString, ", "); + } else if (identicalBitCount == 1) { + strcat(destString, " AND "); // TODO: localization + } + } + } + + strcat(destString, suffixString); +} } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 4b06ce0e79..ac68b544b9 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -71,6 +71,8 @@ public: void drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll void openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye); // @ F0333_INVENTORY_OpenAndDrawChest void drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos); // @ F0332_INVENTORY_DrawIconToViewport + void buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char ** attribStrings, + char *destString, char *prefixString, char *suffixString); // @ F0336_INVENTORY_DrawPanel_BuildObjectAttributesString }; -- cgit v1.2.3 From c40aca2d2d146ca6e3e56ee11dd504d9e4d31afb Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 28 Jun 2016 13:36:58 +0200 Subject: DM: Add F0335_INVENTORY_DrawPanel_ObjectDescriptionString --- engines/dm/TODOs/methodtree.txt | 6 ++++-- engines/dm/inventory.cpp | 36 ++++++++++++++++++++++++++++++++++++ engines/dm/inventory.h | 3 +++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 064e09581a..ab44a3f179 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -54,14 +54,16 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so F0303_CHAMPION_GetSkillLevel // done F0332_INVENTORY_DrawIconToViewport // done F0336_INVENTORY_DrawPanel_BuildObjectAttributesString // done - F0335_INVENTORY_DrawPanel_ObjectDescriptionString + F0335_INVENTORY_DrawPanel_ObjectDescriptionString // done + G0421_i_ObjectDescriptionTextX // done + G0422_i_ObjectDescriptionTextY // done F0339_INVENTORY_DrawPanel_ArrowOrEye G0430_apc_DirectionNames G0034_s_Graphic562_Box_ObjectDescriptionCircle G0032_s_Graphic562_Box_Panel G0352_apc_ObjectNames G0237_as_Graphic559_ObjectInfo - G0422_i_ObjectDescriptionTextY + G0422_i_ObjectDescriptionTextY // done F0346_INVENTORY_DrawPanel_ResurrectReincarnate // done F0291_CHAMPION_DrawSlot // done diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index b23321bb3c..fe7807de13 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -369,4 +369,40 @@ void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 a strcat(destString, suffixString); } + +void InventoryMan::drawPanelObjectDescriptionString(char* descString) { + if (descString[0] == '\f') { // form feed + descString++; + _objDescTextXpos = 108; + _objDescTextYpos = 59; + } + + if (descString[0]) { + char stringTmpBuff[128]; + strcpy(stringTmpBuff, descString); + + char *stringLine = stringTmpBuff; + bool severalLines = false; + char *string = nullptr; + while (*stringLine) { + if (strlen(stringLine) > 18) { // if string is too long to fit on one line + string = &stringLine[17]; + while (*string != ' ') // go back to the last space character + string--; + + *string = '\0'; // and split the string there + severalLines = true; + } + + _vm->_textMan->printToViewport(_objDescTextXpos, _objDescTextYpos, kColorLightestGray, stringLine); + _objDescTextYpos += 7; + if (severalLines) { + severalLines = false; + stringLine = ++string; + } else { + *stringLine = '\0'; + } + } + } +} } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index ac68b544b9..18fe179958 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -58,6 +58,8 @@ public: PanelContent _panelContent; // @ G0424_i_PanelContent Thing _chestSlots[8]; // @ G0425_aT_ChestSlots Thing _openChest; // @ G0426_T_OpenChest + int16 _objDescTextXpos; // @ G0421_i_ObjectDescriptionTextX + int16 _objDescTextYpos; // @ G0422_i_ObjectDescriptionTextY void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait @@ -73,6 +75,7 @@ public: void drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos); // @ F0332_INVENTORY_DrawIconToViewport void buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char ** attribStrings, char *destString, char *prefixString, char *suffixString); // @ F0336_INVENTORY_DrawPanel_BuildObjectAttributesString + void drawPanelObjectDescriptionString(char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString }; -- cgit v1.2.3 From 792f48858baec961fde793e5d80222e2bb03525d Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 28 Jun 2016 13:43:05 +0200 Subject: DM: Add F0339_INVENTORY_DrawPanel_ArrowOrEye, G0033_s_Graphic562_Box_ArrowOrEye --- engines/dm/TODOs/methodtree.txt | 2 +- engines/dm/gfx.h | 4 +++- engines/dm/inventory.cpp | 9 +++++++++ engines/dm/inventory.h | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index ab44a3f179..65b79bbc38 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -57,7 +57,7 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so F0335_INVENTORY_DrawPanel_ObjectDescriptionString // done G0421_i_ObjectDescriptionTextX // done G0422_i_ObjectDescriptionTextY // done - F0339_INVENTORY_DrawPanel_ArrowOrEye + F0339_INVENTORY_DrawPanel_ArrowOrEye // done G0430_apc_DirectionNames G0034_s_Graphic562_Box_ObjectDescriptionCircle G0032_s_Graphic562_Box_Panel diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 25ffbb220e..e4fe12ac68 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -76,7 +76,9 @@ enum GraphicIndice { kMenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES kMenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND kPanelOpenScrollIndice = 23, // @ C023_GRAPHIC_PANEL_OPEN_SCROLL - kPanelOpenChestIndice = 25 // @ C025_GRAPHIC_PANEL_OPEN_CHEST + kPanelOpenChestIndice = 25, // @ C025_GRAPHIC_PANEL_OPEN_CHEST + kEyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION + kArrowForChestContentIndice = 18 // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT }; extern uint16 gPalSwoosh[16]; diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index fe7807de13..9724d83ab6 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -405,4 +405,13 @@ void InventoryMan::drawPanelObjectDescriptionString(char* descString) { } } } + +Box gBoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye + +void InventoryMan::drawPanelArrowOrEye(bool pressingEye) { + DisplayMan &dispMan = *_vm->_displayMan; + dispMan.blitToScreen(dispMan.getBitmap(pressingEye ? kEyeForObjectDescriptionIndice : kArrowForChestContentIndice), + 16, 0, 0, gBoxArrowOrEye, kColorRed, gDungeonViewport); +} + } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 18fe179958..8868a53800 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -76,6 +76,7 @@ public: void buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char ** attribStrings, char *destString, char *prefixString, char *suffixString); // @ F0336_INVENTORY_DrawPanel_BuildObjectAttributesString void drawPanelObjectDescriptionString(char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString + void drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye }; -- cgit v1.2.3 From 1f73d771ce31223dc94743432ec8368905d408f1 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 28 Jun 2016 18:04:32 +0200 Subject: DM: F0342_INVENTORY_DrawPanel_Object, F0031_OBJECT_LoadNames --- engines/dm/TODOs/methodtree.txt | 12 ++-- engines/dm/TODOs/todo.txt | 1 + engines/dm/champion.h | 2 +- engines/dm/dm.cpp | 1 + engines/dm/dungeonman.cpp | 7 -- engines/dm/dungeonman.h | 32 ++++++--- engines/dm/gfx.cpp | 24 ++++--- engines/dm/gfx.h | 6 +- engines/dm/inventory.cpp | 142 +++++++++++++++++++++++++++++++++++++++- engines/dm/inventory.h | 1 + engines/dm/objectman.cpp | 119 ++++++++++++++++++++------------- engines/dm/objectman.h | 6 ++ 12 files changed, 274 insertions(+), 79 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 65b79bbc38..fb7021e64f 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -47,7 +47,7 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so G0037_s_Graphic562_Box_Poisoned // done F0351_INVENTORY_DrawChampionSkillsAndStatistics // skip ----------------- F0347_INVENTORY_DrawPanel // done - F0342_INVENTORY_DrawPanel_Object + F0342_INVENTORY_DrawPanel_Object // done F0341_INVENTORY_DrawPanel_Scroll // done F0340_INVENTORY_DrawPanel_ScrollTextLine // done F0333_INVENTORY_OpenAndDrawChest // done @@ -58,11 +58,11 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so G0421_i_ObjectDescriptionTextX // done G0422_i_ObjectDescriptionTextY // done F0339_INVENTORY_DrawPanel_ArrowOrEye // done - G0430_apc_DirectionNames - G0034_s_Graphic562_Box_ObjectDescriptionCircle - G0032_s_Graphic562_Box_Panel - G0352_apc_ObjectNames - G0237_as_Graphic559_ObjectInfo + G0430_apc_DirectionNames // done + G0034_s_Graphic562_Box_ObjectDescriptionCircle // done + G0032_s_Graphic562_Box_Panel // done + G0352_apc_ObjectNames // done + G0237_as_Graphic559_ObjectInfo // done G0422_i_ObjectDescriptionTextY // done F0346_INVENTORY_DrawPanel_ResurrectReincarnate // done diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 558fc8a3e2..196d68f27c 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -16,6 +16,7 @@ Todo: I forgot to add localization warnings Attend to Arnaud's notes on github Double check enums with hex literals, I think I screwed the regex when processing them + Double check strcat, strstr usages, I might have messed them up in many places Missing functions: Add missing F0163_DUNGEON_LinkThingToList in MovesensMan::sensorIsTriggeredByClickOnWall (I don't think it's safe yet) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 86425b48c7..8ea8a6d0a3 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -430,7 +430,6 @@ class ChampionMan { ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue void drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue - Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger public: Champion _champions[4]; uint16 _partyChampionCount; // @ G0305_ui_PartyChampionCount @@ -457,6 +456,7 @@ public: void drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot void renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename uint16 getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel + Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger }; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index a3479d258a..138e7b8777 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -132,6 +132,7 @@ void DMEngine::initializeGame() { _displayMan->loadFloorSet(kFloorSetStone); _displayMan->loadWallSet(kWallSetStone); + _objectMan->loadObjectNames(); startGame(); warning("MISSING CODE: F0267_MOVE_GetMoveResult_CPSCE (if newGame)"); diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 6d5a54069d..899e7911ad 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1218,13 +1218,6 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { return 0; // dummy } -/* Object info */ -#define kObjectInfoIndexFirstScroll 0 // @ C000_OBJECT_INFO_INDEX_FIRST_SCROLL -#define kObjectInfoIndexFirstContainer 1 // @ C001_OBJECT_INFO_INDEX_FIRST_CONTAINER -#define kObjectInfoIndexFirstPotion 2 // @ C002_OBJECT_INFO_INDEX_FIRST_POTION -#define kObjectInfoIndexFirstWeapon 23 // @ C023_OBJECT_INFO_INDEX_FIRST_WEAPON -#define kObjectInfoIndexFirstArmour 69 // @ C069_OBJECT_INFO_INDEX_FIRST_ARMOUR -#define kObjectInfoIndexFirstJunk 127 // @ C127_OBJECT_INFO_INDEX_FIRST_JUNK int16 DungeonMan::getObjectInfoIndex(Thing thing) { uint16 *rawType = getThingData(thing); diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 767044e9af..69746acff2 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -34,6 +34,14 @@ namespace DM { +/* Object info */ +#define kObjectInfoIndexFirstScroll 0 // @ C000_OBJECT_INFO_INDEX_FIRST_SCROLL +#define kObjectInfoIndexFirstContainer 1 // @ C001_OBJECT_INFO_INDEX_FIRST_CONTAINER +#define kObjectInfoIndexFirstPotion 2 // @ C002_OBJECT_INFO_INDEX_FIRST_POTION +#define kObjectInfoIndexFirstWeapon 23 // @ C023_OBJECT_INFO_INDEX_FIRST_WEAPON +#define kObjectInfoIndexFirstArmour 69 // @ C069_OBJECT_INFO_INDEX_FIRST_ARMOUR +#define kObjectInfoIndexFirstJunk 127 // @ C127_OBJECT_INFO_INDEX_FIRST_JUNK + #define kMapXNotOnASquare -1 // @ CM1_MAPX_NOT_ON_A_SQUARE enum ElementType { @@ -89,7 +97,7 @@ public: }; // @ OBJECT_INFO extern ObjectInfo gObjectInfo[180]; - + enum ArmourAttribute { kArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD kArmourAttributeSharpDefense = 0x0007 // @ MASK0x0007_SHARP_DEFENSE @@ -129,18 +137,18 @@ extern ArmourInfo gArmourInfo[58]; class WeaponInfo { public: - uint16 _weight; - uint16 _class; - uint16 _strength; - uint16 _kineticEnergy; + uint16 _weight; + uint16 _class; + uint16 _strength; + uint16 _kineticEnergy; private: uint16 _attributes; /* Bits 15-13 Unreferenced */ public: - WeaponInfo(uint16 weight, uint16 wClass, uint16 strength, uint16 kineticEnergy, uint16 attributes) - : _weight(weight), _class(wClass), _strength(strength), _kineticEnergy(kineticEnergy), _attributes(attributes) {} + WeaponInfo(uint16 weight, uint16 wClass, uint16 strength, uint16 kineticEnergy, uint16 attributes) + : _weight(weight), _class(wClass), _strength(strength), _kineticEnergy(kineticEnergy), _attributes(attributes) {} - uint16 getShootAttack() {return _attributes & 0xFF;} // @ M65_SHOOT_ATTACK - uint16 getProjectileAspectOrdinal() {return (_attributes >> 8) & 0x1F;} // @ M66_PROJECTILE_ASPECT_ORDINAL + uint16 getShootAttack() { return _attributes & 0xFF; } // @ M65_SHOOT_ATTACK + uint16 getProjectileAspectOrdinal() { return (_attributes >> 8) & 0x1F; } // @ M66_PROJECTILE_ASPECT_ORDINAL }; // @ WEAPON_INFO extern WeaponInfo gWeaponInfo[46]; @@ -359,6 +367,9 @@ public: bool isLit() { return (_desc >> 15) & 1; } uint16 getChargeCount() { return (_desc >> 10) & 0xF; } Thing getNextThing() { return _nextThing; } + uint16 getCursed() { return (_desc >> 8) & 1; } + uint16 getPoisoned() { return (_desc >> 9) & 1; } + uint16 getBroken() { return (_desc >> 14) & 1; } }; // @ WEAPON enum ArmourType { @@ -376,6 +387,8 @@ public: ArmourType getType() { return (ArmourType)(_attributes & 0x7F); } Thing getNextThing() { return _nextThing; } + uint16 getCursed() { return (_attributes >> 8) & 1; } + uint16 getBroken() { return (_attributes >> 13) & 1; } }; // @ ARMOUR class Scroll { @@ -416,6 +429,7 @@ public: PotionType getType() { return (PotionType)((_attributes >> 8) & 0x7F); } void setType(PotionType val) { _attributes = (_attributes & ~(0x7F << 8)) | ((val & 0x7F) << 8); } Thing getNextThing() { return _nextThing; } + uint16 getPower() { return _attributes & 0xFF; } }; // @ POTION class Container { diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 7466cb424a..b1c5c6a700 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -731,8 +731,7 @@ void DisplayMan::unpackGraphics() { loadFNT1intoBitmap(kFontGraphicIndice, _bitmaps[kFontGraphicIndice]); } -void DisplayMan::loadFNT1intoBitmap(uint16 index, byte* destBitmap) -{ +void DisplayMan::loadFNT1intoBitmap(uint16 index, byte* destBitmap) { uint8 *data = _packedBitmaps + _packedItemPos[index]; for (uint16 i = 0; i < 6; i++) { for (uint16 w = 0; w < 128; ++w) { @@ -817,12 +816,11 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uin } } - void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent, Viewport& viewport) - { - blitToBitmap(srcBitmap, srcWidth, srcX, srcY, destBitmap, destWidth, box._x1, box._x2, box._y1, box._y2, transparent, viewport); - } +void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent, Viewport& viewport) { + blitToBitmap(srcBitmap, srcWidth, srcX, srcY, destBitmap, destWidth, box._x1, box._x2, box._y1, box._y2, transparent, viewport); +} - void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, +void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, Color transparent, Viewport &viewport) { blitToBitmap(srcBitmap, srcWidth, srcX, srcY, @@ -1581,6 +1579,14 @@ byte* DisplayMan::getBitmap(uint16 index) { return _bitmaps[index]; } +Common::MemoryReadStream DisplayMan::getCompressedData(uint16 index) { + return Common::MemoryReadStream(_packedBitmaps + _packedItemPos[index], getCompressedDataSize(index), DisposeAfterUse::NO); +} + +uint32 DisplayMan::getCompressedDataSize(uint16 index) { + return _packedItemPos[index + 1] - _packedItemPos[index]; +} + void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) { uint16 width = box._x2 - box._x1; for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y) @@ -1588,8 +1594,8 @@ void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) { } void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, - Box &box, - Color transparent, Viewport &viewport) { + Box &box, + Color transparent, Viewport &viewport) { blitToScreen(srcBitmap, srcWidth, srcX, srcY, box._x1, box._x2, box._y1, box._y2, transparent, viewport); } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index e4fe12ac68..b6a32c5065 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -30,6 +30,7 @@ #include "common/scummsys.h" #include "common/rect.h" +#include "common/memstream.h" #include "dm.h" namespace DM { @@ -78,7 +79,8 @@ enum GraphicIndice { kPanelOpenScrollIndice = 23, // @ C023_GRAPHIC_PANEL_OPEN_SCROLL kPanelOpenChestIndice = 25, // @ C025_GRAPHIC_PANEL_OPEN_CHEST kEyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION - kArrowForChestContentIndice = 18 // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT + kArrowForChestContentIndice = 18, // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT + kObjectDescCircleIndice = 29 // @ C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE }; extern uint16 gPalSwoosh[16]; @@ -364,6 +366,8 @@ public: void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); byte* getBitmap(uint16 index); + Common::MemoryReadStream getCompressedData(uint16 index); + uint32 getCompressedDataSize(uint16 index); int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 9724d83ab6..4e3d0d31bc 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -205,7 +205,7 @@ void InventoryMan::drawPanel() { if (thing == Thing::_thingNone) { drawPanelFoodWaterPoisoned(); } else { - warning("MISSING CODE: F0342_INVENTORY_DrawPanel_Object(L1075_T_Thing, C0_FALSE);"); + drawPanelObject(thing, false); } } @@ -414,4 +414,144 @@ void InventoryMan::drawPanelArrowOrEye(bool pressingEye) { 16, 0, 0, gBoxArrowOrEye, kColorRed, gDungeonViewport); } + +Box gBoxObjectDescCircle = Box(105, 136, 53, 79); // @ G0034_s_Graphic562_Box_ObjectDescriptionCircle + +#define kDescriptionMaskConsumable 0x0001 // @ MASK0x0001_DESCRIPTION_CONSUMABLE +#define kDescriptionMaskPoisoned 0x0002 // @ MASK0x0002_DESCRIPTION_POISONED +#define kDescriptionMaskBroken 0x0004 // @ MASK0x0004_DESCRIPTION_BROKEN +#define kDescriptionMaskCursed 0x0008 // @ MASK0x0008_DESCRIPTION_CURSED + +void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { + DungeonMan &dunMan = *_vm->_dungeonMan; + ObjectMan &objMan = *_vm->_objectMan; + DisplayMan &dispMan = *_vm->_displayMan; + ChampionMan &champMan = *_vm->_championMan; + TextMan &textMan = *_vm->_textMan; + + if (_vm->_pressingEye || _vm->_pressingMouth) { + warning("BUG0_48 The contents of a chest are reorganized when an object with a statistic modifier is placed or removed on a champion"); + closeChest(); + } + + uint16 *rawThingPtr = dunMan.getThingData(thingToDraw); + drawPanelObjectDescriptionString("\f"); // form feed + ThingType thingType = thingToDraw.getType(); + if (thingType == kScrollThingType) { + drawPanelScroll((Scroll*)rawThingPtr); + } else if (thingType == kContainerThingType) { + openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye); + } else { + IconIndice iconIndex = objMan.getIconIndex(thingToDraw); + dispMan.blitToScreen(dispMan.getBitmap(kPanelEmptyIndice), 144, 0, 0, gBoxPanel, kColorRed, gDungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(kObjectDescCircleIndice), 32, 0, 0, gBoxObjectDescCircle, kColorDarkestGray, gDungeonViewport); + + char *descString = nullptr; + char str[40]; + if (iconIndex == kIconIndiceJunkChampionBones) { + strcpy(str, champMan._champions[((Junk*)rawThingPtr)->getChargeCount()]._name); // TODO: localization + strcat(str, " "); // TODO: localization + strcat(str, objMan._objectNames[iconIndex]); // TODO: localization + + descString = str; + } else if ((thingType == kPotionThingType) + && (iconIndex != kIconIndicePotionWaterFlask) + && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), kChampionSkillPriest) > 1)) { + str[0] = '_' + ((Potion*)rawThingPtr)->getPower() / 40; + str[1] = ' '; + str[2] = '\0'; + strcat(str, objMan._objectNames[iconIndex]); + descString = str; + } else { + descString = objMan._objectNames[iconIndex]; + } + + textMan.printToViewport(134, 68, kColorLightestGray, descString); + drawIconToViewport(iconIndex, 111, 59); + + char *attribString[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"}; // TODO: localization + + _objDescTextYpos = 87; + + uint16 potentialAttribMask; + uint16 actualAttribMask; + switch (thingType) { + case kWeaponThingType: { + potentialAttribMask = kDescriptionMaskCursed | kDescriptionMaskPoisoned | kDescriptionMaskBroken; + Weapon *weapon = (Weapon*)rawThingPtr; + actualAttribMask = (weapon->getCursed() << 3) | (weapon->getPoisoned() << 1) | (weapon->getBroken() << 2); + if ((iconIndex >= kIconIndiceWeaponTorchUnlit) + && (iconIndex <= kIconIndiceWeaponTorchLit) + && (weapon->getChargeCount() == 0)) { + drawPanelObjectDescriptionString("(BURNT OUT)"); // TODO: localization + } + break; + } + case kArmourThingType: { + potentialAttribMask = kDescriptionMaskCursed | kDescriptionMaskBroken; + Armour *armour = (Armour*)rawThingPtr; + actualAttribMask = (armour->getCursed() << 3) | (armour->getBroken() << 2); + break; + } + case kPotionThingType: { + actualAttribMask = kDescriptionMaskConsumable; + Potion *potion = (Potion*)rawThingPtr; + actualAttribMask = gObjectInfo[kObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots(); + break; + } + case kJunkThingType: { + Junk *junk = (Junk*)rawThingPtr; + if ((iconIndex >= kIconIndiceJunkWater) && (iconIndex <= kIconIndiceJunkWaterSkin)) { + potentialAttribMask = 0; + switch (junk->getChargeCount()) { + case 0: + descString = "(EMPTY)"; // TODO: localization + break; + case 1: + descString = "(ALMOST EMPTY)"; // TODO: localization + break; + case 2: + descString = "(ALMOST FULL)"; // TODO: localization + break; + case 3: + descString = "(FULL)"; // TODO: localization + break; + } + drawPanelObjectDescriptionString(descString); + } else if ((iconIndex >= kIconIndiceJunkCompassNorth) && (iconIndex <= kIconIndiceJunkCompassWest)) { + potentialAttribMask = 0; + strcpy(str, "PARTY FACING "); // TODO: localization + static char* directionName[4] = {"NORTH", "EAST", "SOUTH", "WEST"}; // G0430_apc_DirectionNames // TODO: localization + strcat(str, directionName[iconIndex]); + drawPanelObjectDescriptionString(str); + } else { + potentialAttribMask = kDescriptionMaskConsumable; + actualAttribMask = gObjectInfo[kObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots(); + } + break; + } + } // end of switch + + if (potentialAttribMask) { + buildObjectAttributeString(potentialAttribMask, actualAttribMask, attribString, str, "(", ")"); + drawPanelObjectDescriptionString(str); + } + + strcpy(str, "WEIGHS "); // TODO: localization + + uint16 weight = dunMan.getObjectWeight(thingToDraw); + strcat(str, champMan.getStringFromInteger(weight / 10, false, 3).c_str()); + + strcat(str, "."); // TODO: localization + + weight -= (weight / 10) * 10; + strcat(str, champMan.getStringFromInteger(weight, false, 1).c_str()); + + strcat(str, " KG."); // TODO: localization + + drawPanelObjectDescriptionString(str); + } + drawPanelArrowOrEye(pressingEye); + +} } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 8868a53800..952511d9e8 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -77,6 +77,7 @@ public: char *destString, char *prefixString, char *suffixString); // @ F0336_INVENTORY_DrawPanel_BuildObjectAttributesString void drawPanelObjectDescriptionString(char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString void drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye + void drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object }; diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index c92427bf4b..c83c16c9f6 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -43,52 +43,81 @@ int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconI ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) { /* 8 for champion hands in status boxes, 30 for champion inventory, 8 for chest */ - _slotBoxes[0] = SlotBox(4, 10, 0); /* Champion Status Box 0 Ready Hand */ - _slotBoxes[1] = SlotBox(24, 10, 0); /* Champion Status Box 0 Action Hand */ - _slotBoxes[2] = SlotBox(73, 10, 0); /* Champion Status Box 1 Ready Hand */ - _slotBoxes[3] = SlotBox(93, 10, 0); /* Champion Status Box 1 Action Hand */ - _slotBoxes[4] = SlotBox(142, 10, 0); /* Champion Status Box 2 Ready Hand */ - _slotBoxes[5] = SlotBox(162, 10, 0); /* Champion Status Box 2 Action Hand */ - _slotBoxes[6] = SlotBox(211, 10, 0); /* Champion Status Box 3 Ready Hand */ - _slotBoxes[7] = SlotBox(231, 10, 0); /* Champion Status Box 3 Action Hand */ - _slotBoxes[8] = SlotBox(6, 53, 0); /* Ready Hand */ - _slotBoxes[9] = SlotBox(62, 53, 0); /* Action Hand */ - _slotBoxes[10] = SlotBox(34, 26, 0); /* Head */ - _slotBoxes[11] = SlotBox(34, 46, 0); /* Torso */ - _slotBoxes[12] = SlotBox(34, 66, 0); /* Legs */ - _slotBoxes[13] = SlotBox(34, 86, 0); /* Feet */ - _slotBoxes[14] = SlotBox(6, 90, 0); /* Pouch 2 */ - _slotBoxes[15] = SlotBox(79, 73, 0); /* Quiver Line2 1 */ - _slotBoxes[16] = SlotBox(62, 90, 0); /* Quiver Line1 2 */ - _slotBoxes[17] = SlotBox(79, 90, 0); /* Quiver Line2 2 */ - _slotBoxes[18] = SlotBox(6, 33, 0); /* Neck */ - _slotBoxes[19] = SlotBox(6, 73, 0); /* Pouch 1 */ - _slotBoxes[20] = SlotBox(62, 73, 0); /* Quiver Line1 1 */ - _slotBoxes[21] = SlotBox(66, 33, 0); /* Backpack Line1 1 */ - _slotBoxes[22] = SlotBox(83, 16, 0); /* Backpack Line2 2 */ - _slotBoxes[23] = SlotBox(100, 16, 0); /* Backpack Line2 3 */ - _slotBoxes[24] = SlotBox(117, 16, 0); /* Backpack Line2 4 */ - _slotBoxes[25] = SlotBox(134, 16, 0); /* Backpack Line2 5 */ - _slotBoxes[26] = SlotBox(151, 16, 0); /* Backpack Line2 6 */ - _slotBoxes[27] = SlotBox(168, 16, 0); /* Backpack Line2 7 */ - _slotBoxes[28] = SlotBox(185, 16, 0); /* Backpack Line2 8 */ - _slotBoxes[29] = SlotBox(202, 16, 0); /* Backpack Line2 9 */ - _slotBoxes[30] = SlotBox(83, 33, 0); /* Backpack Line1 2 */ - _slotBoxes[31] = SlotBox(100, 33, 0); /* Backpack Line1 3 */ - _slotBoxes[32] = SlotBox(117, 33, 0); /* Backpack Line1 4 */ - _slotBoxes[33] = SlotBox(134, 33, 0); /* Backpack Line1 5 */ - _slotBoxes[34] = SlotBox(151, 33, 0); /* Backpack Line1 6 */ - _slotBoxes[35] = SlotBox(168, 33, 0); /* Backpack Line1 7 */ - _slotBoxes[36] = SlotBox(185, 33, 0); /* Backpack Line1 8 */ - _slotBoxes[37] = SlotBox(202, 33, 0); /* Backpack Line1 9 */ - _slotBoxes[38] = SlotBox(117, 59, 0); /* Chest 1 */ - _slotBoxes[39] = SlotBox(106, 76, 0); /* Chest 2 */ - _slotBoxes[40] = SlotBox(111, 93, 0); /* Chest 3 */ - _slotBoxes[41] = SlotBox(128, 98, 0); /* Chest 4 */ + _slotBoxes[0] = SlotBox(4, 10, 0); /* Champion Status Box 0 Ready Hand */ + _slotBoxes[1] = SlotBox(24, 10, 0); /* Champion Status Box 0 Action Hand */ + _slotBoxes[2] = SlotBox(73, 10, 0); /* Champion Status Box 1 Ready Hand */ + _slotBoxes[3] = SlotBox(93, 10, 0); /* Champion Status Box 1 Action Hand */ + _slotBoxes[4] = SlotBox(142, 10, 0); /* Champion Status Box 2 Ready Hand */ + _slotBoxes[5] = SlotBox(162, 10, 0); /* Champion Status Box 2 Action Hand */ + _slotBoxes[6] = SlotBox(211, 10, 0); /* Champion Status Box 3 Ready Hand */ + _slotBoxes[7] = SlotBox(231, 10, 0); /* Champion Status Box 3 Action Hand */ + _slotBoxes[8] = SlotBox(6, 53, 0); /* Ready Hand */ + _slotBoxes[9] = SlotBox(62, 53, 0); /* Action Hand */ + _slotBoxes[10] = SlotBox(34, 26, 0); /* Head */ + _slotBoxes[11] = SlotBox(34, 46, 0); /* Torso */ + _slotBoxes[12] = SlotBox(34, 66, 0); /* Legs */ + _slotBoxes[13] = SlotBox(34, 86, 0); /* Feet */ + _slotBoxes[14] = SlotBox(6, 90, 0); /* Pouch 2 */ + _slotBoxes[15] = SlotBox(79, 73, 0); /* Quiver Line2 1 */ + _slotBoxes[16] = SlotBox(62, 90, 0); /* Quiver Line1 2 */ + _slotBoxes[17] = SlotBox(79, 90, 0); /* Quiver Line2 2 */ + _slotBoxes[18] = SlotBox(6, 33, 0); /* Neck */ + _slotBoxes[19] = SlotBox(6, 73, 0); /* Pouch 1 */ + _slotBoxes[20] = SlotBox(62, 73, 0); /* Quiver Line1 1 */ + _slotBoxes[21] = SlotBox(66, 33, 0); /* Backpack Line1 1 */ + _slotBoxes[22] = SlotBox(83, 16, 0); /* Backpack Line2 2 */ + _slotBoxes[23] = SlotBox(100, 16, 0); /* Backpack Line2 3 */ + _slotBoxes[24] = SlotBox(117, 16, 0); /* Backpack Line2 4 */ + _slotBoxes[25] = SlotBox(134, 16, 0); /* Backpack Line2 5 */ + _slotBoxes[26] = SlotBox(151, 16, 0); /* Backpack Line2 6 */ + _slotBoxes[27] = SlotBox(168, 16, 0); /* Backpack Line2 7 */ + _slotBoxes[28] = SlotBox(185, 16, 0); /* Backpack Line2 8 */ + _slotBoxes[29] = SlotBox(202, 16, 0); /* Backpack Line2 9 */ + _slotBoxes[30] = SlotBox(83, 33, 0); /* Backpack Line1 2 */ + _slotBoxes[31] = SlotBox(100, 33, 0); /* Backpack Line1 3 */ + _slotBoxes[32] = SlotBox(117, 33, 0); /* Backpack Line1 4 */ + _slotBoxes[33] = SlotBox(134, 33, 0); /* Backpack Line1 5 */ + _slotBoxes[34] = SlotBox(151, 33, 0); /* Backpack Line1 6 */ + _slotBoxes[35] = SlotBox(168, 33, 0); /* Backpack Line1 7 */ + _slotBoxes[36] = SlotBox(185, 33, 0); /* Backpack Line1 8 */ + _slotBoxes[37] = SlotBox(202, 33, 0); /* Backpack Line1 9 */ + _slotBoxes[38] = SlotBox(117, 59, 0); /* Chest 1 */ + _slotBoxes[39] = SlotBox(106, 76, 0); /* Chest 2 */ + _slotBoxes[40] = SlotBox(111, 93, 0); /* Chest 3 */ + _slotBoxes[41] = SlotBox(128, 98, 0); /* Chest 4 */ _slotBoxes[42] = SlotBox(145, 101, 0); /* Chest 5 */ _slotBoxes[43] = SlotBox(162, 103, 0); /* Chest 6 */ _slotBoxes[44] = SlotBox(179, 104, 0); /* Chest 7 */ _slotBoxes[45] = SlotBox(196, 105, 0); /* Chest 8 */ + + _objectIconForMousePointer = nullptr; +} + +ObjectMan::~ObjectMan() { + delete[] _objectIconForMousePointer; + delete[] _objectNames[0]; +} + +#define kObjectNamesGraphicIndice 556 // @ C556_GRAPHIC_OBJECT_NAMES + +void ObjectMan::loadObjectNames() { + DisplayMan &dispMan = *_vm->_displayMan; + + _objectIconForMousePointer = new byte[16 * 16]; + + char *objectNames = new char[dispMan.getCompressedDataSize(kObjectNamesGraphicIndice) + kObjectNameCount]; + Common::MemoryReadStream stream = dispMan.getCompressedData(kObjectNamesGraphicIndice); + + for (uint16 objNameIndex = 0; objNameIndex < kObjectNameCount; ++objNameIndex) { + _objectNames[objNameIndex] = objectNames; + + byte tmpByte; + for (tmpByte = stream.readByte(); !(tmpByte & 0x80); tmpByte = stream.readByte()) // last char of object name has 7th bit on + *objectNames++ = tmpByte; // write while not last char + + *objectNames++ = tmpByte & 0x7F; // write without the 7th bit + *objectNames++ = '\0'; // terminate string + } } IconIndice ObjectMan::getObjectType(Thing thing) { @@ -109,7 +138,7 @@ IconIndice ObjectMan::getIconIndex(Thing thing) { if ((iconIndex != kIconIndiceNone) && (((iconIndex < kIconIndiceWeaponDagger) && (iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error - ((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) || + ((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) || (iconIndex == kIconIndicePotionEmptyFlask)) ) { uint16 *rawType = _vm->_dungeonMan->getThingData(thing); @@ -178,9 +207,9 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { Box box; box._x1 = slotBox->_x; box._y1 = slotBox->_y; - box._x2 = box._x1 + 15 + 1; + box._x2 = box._x1 + 15 + 1; box._y2 = box._y1 + 15 + 1; - + uint16 iconGraphicIndex; for (iconGraphicIndex = 0; iconGraphicIndex < 7; ++iconGraphicIndex) { if (gIconGraphicFirstIndex[iconGraphicIndex] > iconIndex) { diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index 1dbba692bf..e01d06404e 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -35,6 +35,8 @@ namespace DM { #define kSlotBoxInventoryActionHand 9 // @ C09_SLOT_BOX_INVENTORY_ACTION_HAND #define kSlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT +#define kObjectNameCount 199 // @ C199_OBJECT_NAME_COUNT + class SlotBox { public: int16 _x; @@ -49,8 +51,12 @@ class ObjectMan { public: explicit ObjectMan(DMEngine *vm); + ~ObjectMan(); + void loadObjectNames(); // @ F0031_OBJECT_LoadNames SlotBox _slotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes; + char *_objectNames[kObjectNameCount]; // @ G0352_apc_ObjectNames + byte *_objectIconForMousePointer; // @ G0412_puc_Bitmap_ObjectIconForMousePointer IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex -- cgit v1.2.3 From 3442019d941adb0f8f6f4bf7957e881daed32a41 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 28 Jun 2016 19:33:46 +0200 Subject: DM: Add F0299_CHAMPION_ApplyObjectModifiersToStatistics --- engines/dm/TODOs/todo.txt | 1 + engines/dm/champion.cpp | 135 ++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/champion.h | 2 + 3 files changed, 138 insertions(+) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 196d68f27c..0357673999 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -15,6 +15,7 @@ Todo: Rename GraphicIndice enum entires and have their name include GraphicIndice I forgot to add localization warnings Attend to Arnaud's notes on github + Attend to sev's notes on github Double check enums with hex literals, I think I screwed the regex when processing them Double check strcat, strstr usages, I might have messed them up in many places diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index c974a71d59..deae8b4247 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -132,6 +132,141 @@ Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint1 return result += valToStr; } +void ChampionMan::applyModifiersToStatistics(Champion* champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing) { + int16 statIndex; + int16 modifier = 0; + ThingType thingType = thing.getType(); + if (((thingType == kWeaponThingType) || (thingType == kArmourThingType)) + && (slotIndex >= kChampionSlotReadyHand) + && (slotIndex <= kChampionSlotQuiverLine_1_1)) { + Weapon *weapon = (Weapon*)_vm->_dungeonMan->getThingData(thing); + Armour *armour = (Armour*)_vm->_dungeonMan->getThingData(thing); + if (((thingType == kWeaponThingType) && weapon->getCursed()) + || ((thingType == kArmourThingType) && armour->getCursed())) { + statIndex = kChampionStatLuck; + modifier = -3; + goto T0299044_ApplyModifier; + } + } + + statIndex = (ChampionStatisticType)thingType; // variable sharing + + if ((iconIndex == kIconIndiceJunkRabbitsFoot) && (slotIndex < kChampionSlotChest_1)) { + statIndex = kChampionStatLuck; + modifier = 10; + } else if (slotIndex == kChampionSlotActionHand) { + + if (iconIndex == kIconIndiceWeaponMaceOfOrder) { + statIndex = kChampionStatStrength; + modifier = 5; + } else { + + statIndex = kChampionStatMana; + if ((iconIndex >= kIconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= kIconIndiceWeaponStaffOfClawsFull)) { + modifier = 4; + } else if ((iconIndex >= kIconIndiceWeaponStaff) && (iconIndex <= kIconIndiceWeaponSceptreOfLyf)) { + switch (iconIndex) { + case kIconIndiceWeaponStaff: + modifier = 2; + break; + case kIconIndiceWeaponWand: + modifier = 1; + break; + case kIconIndiceWeaponTeowand: + modifier = 6; + break; + case kIconIndiceWeaponYewStaff: + modifier = 4; + break; + case kIconIndiceWeaponStaffOfManarStaffOfIrra: + modifier = 10; + break; + case kIconIndiceWeaponSnakeStaffCrossOfNeta: + modifier = 8; + break; + case kIconIndiceWeaponTheConduitSerpentStaff: + modifier = 16; + break; + case kIconIndiceWeaponDragonSpit: + modifier = 7; + break; + case kIconIndiceWeaponSceptreOfLyf: + modifier = 5; + break; + } + } else { + switch (iconIndex) { + case kIconIndiceWeaponDeltaSideSplitter: + modifier = 1; + break; + case kIconIndiceWeaponTheInquisitorDragonFang: + modifier = 2; + break; + case kIconIndiceWeaponVorpalBlade: + modifier = 4; + break; + } + } // end of else + + } + + } else if (slotIndex == kChampionSlotLegs) { + + if (iconIndex == kIconIndiceArmourPowertowers) { + statIndex = kChampionStatStrength; + modifier = 10; + } + + } else if (slotIndex == kChampionSlotHead) { + + if (iconIndex == kIconIndiceArmourCrownOfNerra) { + statIndex = kChampionStatWisdom; + modifier = 10; + } else if (iconIndex == kIconIndiceArmourDexhelm) { + statIndex = kChampionStatDexterity; + modifier = 10; + } + + } else if (slotIndex == kChampionSlotTorso) { + + if (iconIndex == kIconIndiceArmourFlamebain) { + statIndex = kChampionStatAntifire; + modifier = 12; + } else if (iconIndex == kIconIndiceArmourCloakOfNight) { + statIndex = kChampionStatDexterity; + modifier = 8; + } + + } else if (slotIndex == kChampionSlotNeck) { + + if ((iconIndex >= kIconIndiceJunkJewelSymalUnequipped) && (iconIndex <= kIconIndiceJunkJewelSymalEquipped)) { + statIndex = kChampionStatAntimagic; + modifier = 15; + } else if (iconIndex == kIconIndiceArmourCloakOfNight) { + statIndex = kChampionStatDexterity; + modifier = 8; + } else if (iconIndex == kIconIndiceJunkMoonstone) { + statIndex = kChampionStatMana; + modifier = 3; + } + + } + +T0299044_ApplyModifier: + if (modifier) { + modifier *= modifierFactor; + if (statIndex == kChampionStatMana) { + champ->_maxMana += modifier; + } else if (statIndex < kChampionStatAntifire + 1) { + for (uint16 statValIndex = kChampionStatMaximum; statValIndex <= kChampionStatMinimum; ++statValIndex) { + champ->getStatistic((ChampionStatisticType)statIndex, (ChampionStatisticValue)statValIndex) += modifier; + warning("BUG0_38"); + } + } + } + +} + ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { for (uint16 i = 0; i < _partyChampionCount; ++i) { if ((_champions[i]._cell == cell) && _champions[i]._currHealth) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 8ea8a6d0a3..c61dbe4d70 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -457,6 +457,8 @@ public: void renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename uint16 getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger + void applyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex, + int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics }; -- cgit v1.2.3 From ae6f2d711ccf3a2351be2d98da07ed2daf95c017 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 28 Jun 2016 20:17:38 +0200 Subject: DM: Add F0034_OBJECT_DrawLeaderHandObjectName --- engines/dm/TODOs/methodtree.txt | 22 +++++++++++----------- engines/dm/TODOs/todo.txt | 1 + engines/dm/objectman.cpp | 19 ++++++++++++++++++- engines/dm/objectman.h | 1 + 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index fb7021e64f..92bbd38658 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -97,24 +97,24 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon // done G0237_as_Graphic559_ObjectInfo // done G0509_B_ActionAreaContainsIcons // done - F0301_CHAMPION_AddObjectInSlot // skip + F0301_CHAMPION_AddObjectInSlot + F0299_CHAMPION_ApplyObjectModifiersToStatistics // done F0296_CHAMPION_DrawChangedObjectIcons - F0292_CHAMPION_DrawState // skip - F0034_OBJECT_DrawLeaderHandObjectName // skip + F0068_MOUSE_SetPointerToObject // skip + F0077_MOUSE_HidePointer_CPSE // skip + F0078_MOUSE_ShowPointer // skip + F0034_OBJECT_DrawLeaderHandObjectName // done + F0386_MENUS_DrawActionIcon F0295_CHAMPION_HasObjectIconInSlotBoxChanged M70_HAND_SLOT_INDEX - G0423_i_InventoryChampionOrdinal G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen G0412_puc_Bitmap_ObjectIconForMousePointer - G0424_i_PanelContent - G0425_aT_ChestSlots + G0413_i_LeaderHandObjectIconIndex + G0414_T_LeaderHandObject F0337_INVENTORY_SetDungeonViewPalette - F0299_CHAMPION_ApplyObjectModifiersToStatistics - F0291_CHAMPION_DrawSlot - G0425_aT_ChestSlots - G0423_i_InventoryChampionOrdinal - G0039_ai_Graphic562_LightPowerToLightAmount G0407_s_Party + G0039_ai_Graphic562_LightPowerToLightAmount + F0355_INVENTORY_Toggle_CPSE // done F0292_CHAMPION_DrawState // done F0334_INVENTORY_CloseChest // done diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 0357673999..ca4bc3fbb1 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -18,6 +18,7 @@ Todo: Attend to sev's notes on github Double check enums with hex literals, I think I screwed the regex when processing them Double check strcat, strstr usages, I might have messed them up in many places + I forgot to add a bunch of warning for show/hide mouse pointer Missing functions: Add missing F0163_DUNGEON_LinkThingToList in MovesensMan::sensorIsTriggeredByClickOnWall (I don't think it's safe yet) diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index c83c16c9f6..0f04fb4c96 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -27,6 +27,7 @@ #include "objectman.h" #include "dungeonman.h" +#include "text.h" namespace DM { @@ -229,5 +230,21 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { box, kColorNoTransparency, gDefultViewPort); } } - + +#define kObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH + +void ObjectMan::drawLeaderObjectName(Thing thing) { + IconIndice iconIndex = getIconIndex(thing); + char *objName; + char objectNameBuffer[16]; + if (iconIndex == kIconIndiceJunkChampionBones) { + Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing); + strcpy(objectNameBuffer, _vm->_championMan->_champions[junk->getChargeCount()]._name); + strcat(objectNameBuffer, _objectNames[iconIndex]); + objName = objectNameBuffer; + } else { + objName = _objectNames[iconIndex]; + } + _vm->_textMan->printWithTrailingSpacesToScreen(233, 37, kColorCyan, kColorBlack, objName, kObjectNameMaximumLength); +} } diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index e01d06404e..e5e4cf3a21 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -62,6 +62,7 @@ public: IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex void extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // F0036_OBJECT_ExtractIconFromBitmap void drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox + void drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName }; } -- cgit v1.2.3 From 5ba83b8b4dfb3ed4bf4789c528d0c5d0d169fae8 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 28 Jun 2016 20:33:04 +0200 Subject: DM: Add F0295_CHAMPION_HasObjectIconInSlotBoxChanged, F0039_OBJECT_GetIconIndexInSlotBox --- engines/dm/TODOs/methodtree.txt | 7 ++++--- engines/dm/champion.cpp | 21 +++++++++++++++++++++ engines/dm/champion.h | 2 ++ engines/dm/objectman.cpp | 6 +++++- engines/dm/objectman.h | 3 +++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 92bbd38658..d213c03ab6 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -104,10 +104,11 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so F0077_MOUSE_HidePointer_CPSE // skip F0078_MOUSE_ShowPointer // skip F0034_OBJECT_DrawLeaderHandObjectName // done - F0386_MENUS_DrawActionIcon - F0295_CHAMPION_HasObjectIconInSlotBoxChanged + F0386_MENUS_DrawActionIcon // done + F0295_CHAMPION_HasObjectIconInSlotBoxChanged // done + F0039_OBJECT_GetIconIndexInSlotBox // done M70_HAND_SLOT_INDEX - G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen + G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen // done G0412_puc_Bitmap_ObjectIconForMousePointer G0413_i_LeaderHandObjectIconIndex G0414_T_LeaderHandObject diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index deae8b4247..d2df2ac022 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -267,6 +267,27 @@ T0299044_ApplyModifier: } +bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) { + ObjectMan &objMan = *_vm->_objectMan; + + IconIndice currIconIndex = objMan.getIconIndexInSlotBox(slotBoxIndex); + if (((currIconIndex < kIconIndiceWeaponDagger) && (currIconIndex >= kIconIndiceJunkCompassNorth)) + || ((currIconIndex >= kIconIndicePotionMaPotionMonPotion) && (currIconIndex <= kIconIndicePotionWaterFlask)) + || (currIconIndex == kIconIndicePotionEmptyFlask)) { + IconIndice newIconIndex = objMan.getIconIndex(thing); + if (newIconIndex != currIconIndex) { + if ((slotBoxIndex < kSlotBoxInventoryFirstSlot) && !_mousePointerHiddenToDrawChangedObjIconOnScreen) { + _mousePointerHiddenToDrawChangedObjIconOnScreen = true; + warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + } + objMan.drawIconInSlotBox(slotBoxIndex, newIconIndex); + return true; + } + } + + return false; +} + ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { for (uint16 i = 0; i < _partyChampionCount; ++i) { if ((_champions[i]._cell == cell) && _champions[i]._currHealth) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index c61dbe4d70..a85ab57537 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -443,6 +443,7 @@ public: bool _leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded Party _party; // @ G0407_s_Party ChampionIndex _magicCasterChampionIndex; // @ G0514_i_MagicCasterChampionIndex + bool _mousePointerHiddenToDrawChangedObjIconOnScreen; // @ G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen explicit ChampionMan(DMEngine *vm); void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame @@ -459,6 +460,7 @@ public: Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger void applyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics + bool hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged }; diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 0f04fb4c96..aed1c13a1d 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -230,7 +230,7 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { box, kColorNoTransparency, gDefultViewPort); } } - + #define kObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH void ObjectMan::drawLeaderObjectName(Thing thing) { @@ -247,4 +247,8 @@ void ObjectMan::drawLeaderObjectName(Thing thing) { } _vm->_textMan->printWithTrailingSpacesToScreen(233, 37, kColorCyan, kColorBlack, objName, kObjectNameMaximumLength); } + +IconIndice ObjectMan::getIconIndexInSlotBox(uint16 slotBoxIndex) { + return (IconIndice)_slotBoxes[slotBoxIndex]._iconIndex; +} } diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index e5e4cf3a21..f075076439 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -63,6 +63,9 @@ public: void extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // F0036_OBJECT_ExtractIconFromBitmap void drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox void drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName + IconIndice getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox + + }; } -- cgit v1.2.3 From d4ad444ecc753674c862d92f5e3533bdd799fef2 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 28 Jun 2016 23:16:34 +0200 Subject: DM: Add F0296_CHAMPION_DrawChangedObjectIcons --- engines/dm/champion.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++++++- engines/dm/champion.h | 6 ++-- engines/dm/eventman.cpp | 8 +++--- engines/dm/loadsave.cpp | 2 +- engines/dm/movesens.cpp | 2 +- 5 files changed, 83 insertions(+), 9 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index d2df2ac022..1d9e19ed9a 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -122,6 +122,10 @@ void ChampionMan::drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int1 _vm->_textMan->printToViewport(79, posY, kColorLightestGray, tmp.c_str()); } +uint16 ChampionMan::handSlotIndex(uint16 slotBoxIndex) { + return slotBoxIndex & 0x1; +} + Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) { using namespace Common; String valToStr = String::format("%d", val); @@ -288,6 +292,74 @@ bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) return false; } +void ChampionMan::drawChangedObjectIcons() { + InventoryMan &invMan = *_vm->_inventoryMan; + ObjectMan &objMan = *_vm->_objectMan; + MenuMan &menuMan = *_vm->_menuMan; + + uint16 invChampOrdinal = invMan._inventoryChampionOrdinal; + if (_candidateChampionOrdinal && !invChampOrdinal) + return; + + _mousePointerHiddenToDrawChangedObjIconOnScreen = false; + IconIndice leaderHandObjIconIndex = _leaderHandObjectIconIndex; + + if (((leaderHandObjIconIndex < kIconIndiceWeaponDagger) && (leaderHandObjIconIndex >= kIconIndiceJunkCompassNorth)) // < instead of <= is correct + || ((leaderHandObjIconIndex >= kIconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= kIconIndicePotionWaterFlask)) + || (leaderHandObjIconIndex == kIconIndicePotionEmptyFlask)) { + IconIndice iconIndex = objMan.getIconIndex(_leaderHandObject); + if (iconIndex != leaderHandObjIconIndex) { + _mousePointerHiddenToDrawChangedObjIconOnScreen = true; + warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + objMan.extractIconFromBitmap(iconIndex, objMan._objectIconForMousePointer); + warning("MISSING CODE: F0068_MOUSE_SetPointerToObject"); + _leaderHandObjectIconIndex = iconIndex; + objMan.drawLeaderObjectName(_leaderHandObject); + } + } + + for (uint16 slotBoxIndex = 0; slotBoxIndex < (_partyChampionCount * 2); ++slotBoxIndex) { + int16 champIndex = slotBoxIndex >> 1; + if(invChampOrdinal == _vm->indexToOrdinal(champIndex)) + continue; + + if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)handSlotIndex(slotBoxIndex))) + && (handSlotIndex(slotBoxIndex) == kChampionSlotActionHand)) { + + menuMan.drawActionIcon((ChampionIndex)champIndex); + } + } + + if (invChampOrdinal) { + Champion *champ = &_champions[_vm->ordinalToIndex(invChampOrdinal)]; + Thing *thing = &champ->getSlot(kChampionSlotReadyHand); + uint16 drawViewport = 0; + + for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++, thing++) { + uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + kSlotBoxInventoryFirstSlot, *thing) ? 1 : 0; + drawViewport |= objIconChanged; + if (objIconChanged && (slotIndex == kChampionSlotActionHand)) { + menuMan.drawActionIcon((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal)); + } + } + + if (invMan._panelContent = kPanelContentChest) { + thing = invMan._chestSlots; + for (int16 slotIndex = 0; slotIndex < 8; ++slotIndex, thing++) { + drawViewport |= (hasObjectIconInSlotBoxChanged(slotIndex + kSlotBoxChestFirstSlot, *thing) ? 1 : 0); + } + } + + if (drawViewport) { + champ->setAttributeFlag(kChampionAttributeViewport, true); + drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal)); + } + } + + if (_mousePointerHiddenToDrawChangedObjIconOnScreen) + warning("MISSING CODE: F0078_MOUSE_ShowPointer"); +} + ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { for (uint16 i = 0; i < _partyChampionCount; ++i) { if ((_champions[i]._cell == cell) && _champions[i]._currHealth) @@ -303,7 +375,7 @@ void ChampionMan::resetDataToStartGame() { assert(false); } - _leaderHand = Thing::_thingNone; + _leaderHandObject = Thing::_thingNone; _leaderHandObjectIconIndex = kIconIndiceNone; _leaderEmptyHanded = true; } diff --git a/engines/dm/champion.h b/engines/dm/champion.h index a85ab57537..f3a411646d 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -365,7 +365,7 @@ public: int16 _shieldDefense; byte _portrait[464]; // 32 x 29 pixel portrait - Thing getSlot(ChampionSlot slot) { return _slots[slot]; } + Thing &getSlot(ChampionSlot slot) { return _slots[slot]; } void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; } Skill &getSkill(ChampionSkill skill) { return _skills[skill]; } @@ -430,11 +430,12 @@ class ChampionMan { ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue void drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue + uint16 handSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX public: Champion _champions[4]; uint16 _partyChampionCount; // @ G0305_ui_PartyChampionCount bool _partyDead; // @ G0303_B_PartyDead - Thing _leaderHand; // @ G0414_T_LeaderHandObject + Thing _leaderHandObject; // @ G0414_T_LeaderHandObject ChampionIndex _leaderIndex; // @ G0411_i_LeaderIndex uint16 _candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal bool _partyIsSleeping; // @ G0300_B_PartyIsSleeping @@ -461,6 +462,7 @@ public: void applyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics bool hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged + void drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons }; diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 5c9e68bc05..20c2888aec 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -486,7 +486,7 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) { leaderIndex = cm._leaderIndex; cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeLoad, true); cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeNameTitle, true); - cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHand); + cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject); cm._leaderIndex = kChampionNone; cm.drawChampionState(leaderIndex); } @@ -497,7 +497,7 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) { cm._leaderIndex = champIndex; Champion *champion = &cm._champions[cm._leaderIndex]; champion->_dir = _vm->_dungeonMan->_currMap._partyDir; - cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHand); + cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject); if (_vm->indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) { champion->setAttributeFlag(kChampionAttributeIcon, true); champion->setAttributeFlag(kChampionAttributeNameTitle, true); @@ -554,7 +554,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY } } } else { - Thing thing = champMan._leaderHand; + Thing thing = champMan._leaderHandObject; uint16 *rawThingPointer = dunMan.getThingData(thing); if (dunMan._squareAheadElement == kElementTypeWall) { for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellFrontRight; ++viewCell) { @@ -578,7 +578,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY } else { goto T0377019; } - warning("MISSING CODE: F0296_CHAMPION_DrawChangedObjectIcons"); + champMan.drawChangedObjectIcons(); champMan._champions[champMan._leaderIndex]._load += dunMan.getObjectWeight(thing) - weight; } T0377019: diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 0251e8b0f2..7ac9283a17 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -43,7 +43,7 @@ LoadgameResponse LoadsaveMan::loadgame() { if (newGame) { _vm->_restartGameAllowed = false; cm._partyChampionCount = 0; - cm._leaderHand = Thing::_thingNone; + cm._leaderHandObject = Thing::_thingNone; _vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536); } else { assert(false); diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 2c25251761..8a833a37c3 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -44,7 +44,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 bool atLeastOneSensorWasTriggered = false; - Thing leaderHandObject = champMan._leaderHand; + Thing leaderHandObject = champMan._leaderHandObject; int16 sensorCountToProcessPerCell[4]; uint16 cell; for (cell = kCellNorthWest; cell < kCellSouthWest; ++cell) { -- cgit v1.2.3 From 6daa5c572e3a96602be4df5115126415cecc72f7 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 29 Jun 2016 00:23:40 +0200 Subject: DM: Add F0301_CHAMPION_AddObjectInSlot --- engines/dm/TODOs/methodtree.txt | 18 +++++----- engines/dm/champion.cpp | 73 +++++++++++++++++++++++++++++++++++++++-- engines/dm/champion.h | 3 ++ engines/dm/dungeonman.h | 12 +++++++ 4 files changed, 94 insertions(+), 12 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index d213c03ab6..71846ef3bc 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -97,9 +97,9 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon // done G0237_as_Graphic559_ObjectInfo // done G0509_B_ActionAreaContainsIcons // done - F0301_CHAMPION_AddObjectInSlot + F0301_CHAMPION_AddObjectInSlot // done F0299_CHAMPION_ApplyObjectModifiersToStatistics // done - F0296_CHAMPION_DrawChangedObjectIcons + F0296_CHAMPION_DrawChangedObjectIcons // done F0068_MOUSE_SetPointerToObject // skip F0077_MOUSE_HidePointer_CPSE // skip F0078_MOUSE_ShowPointer // skip @@ -107,14 +107,14 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so F0386_MENUS_DrawActionIcon // done F0295_CHAMPION_HasObjectIconInSlotBoxChanged // done F0039_OBJECT_GetIconIndexInSlotBox // done - M70_HAND_SLOT_INDEX + M70_HAND_SLOT_INDEX // done G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen // done - G0412_puc_Bitmap_ObjectIconForMousePointer - G0413_i_LeaderHandObjectIconIndex - G0414_T_LeaderHandObject - F0337_INVENTORY_SetDungeonViewPalette - G0407_s_Party - G0039_ai_Graphic562_LightPowerToLightAmount + G0412_puc_Bitmap_ObjectIconForMousePointer // done + G0413_i_LeaderHandObjectIconIndex // done + G0414_T_LeaderHandObject // done + F0337_INVENTORY_SetDungeonViewPalette // skip + G0407_s_Party // done + G0039_ai_Graphic562_LightPowerToLightAmount // skip F0355_INVENTORY_Toggle_CPSE // done F0292_CHAMPION_DrawState // done diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 1d9e19ed9a..cce3f558a7 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -45,6 +45,8 @@ Box gBoxChampionIcons[4] = { Box(281, 299, 15, 28)}; Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; +int16 gLightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100}; + uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks /* 30 for champion inventory, 8 for chest */ 0xFFFF, /* Ready Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ @@ -306,7 +308,7 @@ void ChampionMan::drawChangedObjectIcons() { if (((leaderHandObjIconIndex < kIconIndiceWeaponDagger) && (leaderHandObjIconIndex >= kIconIndiceJunkCompassNorth)) // < instead of <= is correct || ((leaderHandObjIconIndex >= kIconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= kIconIndicePotionWaterFlask)) - || (leaderHandObjIconIndex == kIconIndicePotionEmptyFlask)) { + || (leaderHandObjIconIndex == kIconIndicePotionEmptyFlask)) { IconIndice iconIndex = objMan.getIconIndex(_leaderHandObject); if (iconIndex != leaderHandObjIconIndex) { _mousePointerHiddenToDrawChangedObjIconOnScreen = true; @@ -320,7 +322,7 @@ void ChampionMan::drawChangedObjectIcons() { for (uint16 slotBoxIndex = 0; slotBoxIndex < (_partyChampionCount * 2); ++slotBoxIndex) { int16 champIndex = slotBoxIndex >> 1; - if(invChampOrdinal == _vm->indexToOrdinal(champIndex)) + if (invChampOrdinal == _vm->indexToOrdinal(champIndex)) continue; if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)handSlotIndex(slotBoxIndex))) @@ -360,6 +362,71 @@ void ChampionMan::drawChangedObjectIcons() { warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } +void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) { + InventoryMan &invMan = *_vm->_inventoryMan; + DungeonMan &dunMan = *_vm->_dungeonMan; + ObjectMan &objMan = *_vm->_objectMan; + MenuMan &menuMan = *_vm->_menuMan; + + if (thing == Thing::_thingNone) + return; + + Champion *champ = &_champions[champIndex]; + + if (slotIndex >= kChampionSlotChest_1) { + invMan._chestSlots[slotIndex - kChampionSlotChest_1] = thing; + } else { + champ->setSlot(slotIndex, thing); + } + + champ->_load += dunMan.getObjectWeight(thing); + champ->setAttributeFlag(kChampionAttributeLoad, true); + IconIndice iconIndex = objMan.getIconIndex(thing); + bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal); + applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing); + uint16 *rawObjPtr = dunMan.getThingData(thing); + + if (slotIndex < kChampionSlotHead) { + + if (slotIndex == kChampionSlotActionHand) { + champ->setAttributeFlag(kChampionAttributeActionHand, true); + if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex)) + menuMan.clearActingChampion(); + + if ((iconIndex >= kIconIndiceScrollOpen) && (iconIndex <= kIconIndiceScrollClosed)) { + ((Scroll*)rawObjPtr)->setClosed(false); + drawChangedObjectIcons(); + } + } + + if (iconIndex = kIconIndiceWeaponTorchUnlit) { + ((Weapon*)rawObjPtr)->setLit(true); + warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette"); + drawChangedObjectIcons(); + } else if (isInventoryChampion && (slotIndex == kChampionSlotActionHand) && + ((iconIndex == kIconIndiceContainerChestClosed) || ((iconIndex >= kIconIndiceScrollOpen) && (iconIndex <= kIconIndiceScrollClosed)))) { + champ->setAttributeFlag(kChampionAttributePanel, true); + } + + } else if (slotIndex == kChampionSlotNeck) { + + if ((iconIndex >= kIconIndiceJunkIllumuletUnequipped) && (iconIndex <= kIconIndiceJunkIllumuletEquipped)) { + ((Junk*)rawObjPtr)->setChargeCount(1); + _party._magicalLightAmount += gLightPowerToLightAmount[2]; + warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette"); + iconIndex = (IconIndice) (iconIndex + 1); + } else if ((iconIndex >= kIconIndiceJunkJewelSymalUnequipped) && (iconIndex <= kIconIndiceJunkJewelSymalEquipped)) { + ((Junk*)rawObjPtr)->setChargeCount(1); + iconIndex = (IconIndice) (iconIndex + 1); + } + + } + + drawSlot(champIndex, slotIndex); + if (isInventoryChampion) + champ->setAttributeFlag(kChampionAttributeViewport, true); +} + ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { for (uint16 i = 0; i < _partyChampionCount; ++i) { if ((_champions[i]._cell == cell) && _champions[i]._currHealth) @@ -549,7 +616,7 @@ T0280048: if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) { goto T0280046; } - warning("MISSING CODE: F0301_CHAMPION_AddObjectInSlot"); + addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green); } thing = dunMan.getNextThing(thing); } diff --git a/engines/dm/champion.h b/engines/dm/champion.h index f3a411646d..d712e6b6c2 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -41,6 +41,8 @@ namespace DM { extern Box gBoxChampionIcons[4]; // @ G0054_ai_Graphic562_Box_ChampionIcons extern Color gChampionColor[4]; // @ G0046_auc_Graphic562_ChampionColor +extern int16 gLightPowerToLightAmount[16]; // @ G0039_ai_Graphic562_LightPowerToLightAmount + class Scent { uint16 _scent; public: @@ -463,6 +465,7 @@ public: int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics bool hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged void drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons + void addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot }; diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 69746acff2..9a49fe9e7b 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -365,6 +365,12 @@ public: WeaponType getType() { return (WeaponType)(_desc & 0x7F); } bool isLit() { return (_desc >> 15) & 1; } + void setLit(bool val) { + if (val) + _desc |= (1 << 15); + else + _desc &= (~(1 << 15)); + } uint16 getChargeCount() { return (_desc >> 10) & 0xF; } Thing getNextThing() { return _nextThing; } uint16 getCursed() { return (_desc >> 8) & 1; } @@ -402,6 +408,12 @@ public: } Thing getNextThing() { return _nextThing; } uint16 getClosed() { return (_attributes >> 10) & 0x3F; } // ??? dunno why, the original bitfield is 6 bits long + void setClosed(bool val) { + if (val) + _attributes |= (1 << 10); + else + _attributes &= (~(0x3F << 10)); + } uint16 getTextStringThingIndex() { return _attributes & 0x3FF; } }; // @ SCROLL -- cgit v1.2.3 From e6c3389e53cad4069c696132ed4ef7a3c1d6991c Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 29 Jun 2016 22:08:10 +0200 Subject: DM: Continue F0460_START_InitializeGraphicData --- engines/dm/TODOs/methodtree.txt | 50 +++++++++++++ engines/dm/dm.cpp | 29 +++++--- engines/dm/dm.h | 5 ++ engines/dm/gfx.cpp | 156 ++++++++++++++++++++++++++++++++++++---- engines/dm/gfx.h | 107 +++++++++++++++++++++++---- 5 files changed, 313 insertions(+), 34 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 71846ef3bc..10ed85fa5c 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -1,3 +1,53 @@ +F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF + F0113_DUNGEONVIEW_DrawField // dummy + F0133_VIDEO_BlitBoxFilledWithMaskedBitmap + FIELD_ASPECT + F0114_DUNGEONVIEW_GetExplosionBitmap + F0133_VIDEO_BlitBoxFilledWithMaskedBitmap + F0141_DUNGEON_GetObjectInfoIndex + F0142_DUNGEON_GetProjectileAspect + F0176_GROUP_GetCreatureOrdinalInCell + G0017_auc_Graphic562_PaletteChanges_NoChanges + G0075_apuc_PaletteChanges_Projectile + G0077_B_DoNotDrawFluxcagesDuringEndgame + G0105_s_Graphic558_Box_ExplosionPattern_D0C + G0163_as_Graphic558_Frame_Walls + G0188_as_Graphic558_FieldAspects + G0209_as_Graphic558_ObjectAspects + G0210_as_Graphic558_ProjectileAspects + G0212_auc_Graphic558_PaletteChanges_Smoke + G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3 + G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2 + G0215_auc_Graphic558_ProjectileScales + G0216_auc_Graphic558_ExplosionBaseScales + G0217_aauc_Graphic558_ObjectPileShiftSetIndices + G0218_aaaauc_Graphic558_ObjectCoordinateSets + G0219_as_Graphic558_CreatureAspects + G0221_auc_Graphic558_PaletteChanges_Creature_D3 + G0222_auc_Graphic558_PaletteChanges_Creature_D2 + G0223_aac_Graphic558_ShiftSets + G0224_aaaauc_Graphic558_CreatureCoordinateSets + G0225_aai_Graphic558_CenteredExplosionCoordinates + G0226_aaai_Graphic558_ExplosionCoordinates + G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates + G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates + G0237_as_Graphic559_ObjectInfo + G0243_as_Graphic559_CreatureInfo + G0291_aauc_DungeonViewClickableBoxes + G0292_aT_PileTopObject + G0370_ps_Events + G0375_ps_ActiveGroups + OBJECT_ASPECT + GROUP + ACTIVE_GROUP + CREATURE_INFO + CREATURE_ASPECT + PROJECTILE + EXPLOSION + FIELD_ASPECT + + + F0380_COMMAND_ProcessQueue_CPSC // in progress C080_COMMAND_CLICK_IN_DUNGEON_VIEW // cool F0377_COMMAND_ProcessType80_ClickInDungeonView // done so-so diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 138e7b8777..0df836a45a 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -60,16 +60,27 @@ void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); } direction returnOppositeDir(direction dir) { return (direction)((dir + 2) & 3); } bool isOrientedWestEast(direction dir) { return dir & 1; } +uint16 getFlag(uint16 val, uint16 mask) { + return val & mask; +} + +void setFlag(uint16 &val, uint16 mask) { + val |= mask; +} + +void clearFlag(uint16 &val, uint16 mask) { + val &= ~mask; +} DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { - // Do not load data files - // Do not initialize graphics here - // Do not initialize audio devices here - // Do these from run - - //Specify all default directories - //const Common::FSNode gameDataDir(ConfMan.get("example")); - //SearchMan.addSubDirectoryMatching(gameDataDir, "example2"); +// Do not load data files +// Do not initialize graphics here +// Do not initialize audio devices here +// Do these from run + +//Specify all default directories +//const Common::FSNode gameDataDir(ConfMan.get("example")); +//SearchMan.addSubDirectoryMatching(gameDataDir, "example2"); DebugMan.addDebugChannel(kDMDebugExample, "example", "example desc"); // register random source @@ -210,7 +221,7 @@ void DMEngine::gameloop() { _dungeonMan->_currMap._partyPosX = 10; _dungeonMan->_currMap._partyPosY = 4; _dungeonMan->_currMap._partyDir = kDirNorth; - + warning("DUMMY CODE: setting InventoryMan::_inventoryChampionOrdinal to zero"); _inventoryMan->_inventoryChampionOrdinal = 0; diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 19eda10dfd..7b68e6d5a3 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -65,6 +65,11 @@ direction returnOppositeDir(direction dir); bool isOrientedWestEast(direction dir); +uint16 getFlag(uint16 val, uint16 mask); +void setFlag(uint16 &val, uint16 mask); +void clearFlag(uint16 &val, uint16 mask); + + enum ThingType { kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value kDoorThingType = 0, diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index b1c5c6a700..0c55fe557e 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -39,6 +39,24 @@ namespace DM { Box gBoxMovementArrows = Box(224, 319, 124, 168); +ExplosionAspect gExplosionAspects[kExplosionAspectCount] = { // @ G0211_as_Graphic558_ExplosionAspects + /* { ByteWidth, Height } */ + ExplosionAspect(80, 111), /* Fire */ +ExplosionAspect(64, 97), /* Spell */ +ExplosionAspect(80, 91), /* Poison */ +ExplosionAspect(80, 91)}; /* Death */ + +#define kDerivedBitmapMaximumCount 730 // @ C730_DERIVED_BITMAP_MAXIMUM_COUNT + +byte gProjectileScales[7] = { + 13, /* D4 Back */ + 16, /* D4 Front */ + 19, /* D3 Back */ + 22, /* D3 Front */ + 25, /* D2 Back */ + 28, /* D2 Front */ + 32}; /* D1 Back */ + enum StairFrameIndex { kFrameStairsUpFront_D3L = 0, // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L kFrameStairsUpFront_D3C = 1, // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C @@ -598,6 +616,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _floorBitmap = nullptr; _ceilingBitmap = nullptr; _currMapAllowedCreatureTypes = nullptr; + _derivedBitmapByteCount = nullptr; _screenWidth = _screenHeight = 0; _championPortraitOrdinal = 0; @@ -686,21 +705,126 @@ void DisplayMan::loadGraphics() { unpackGraphics(); - for (uint16 i = kDoorOrnDestroyedMask; i <= kDoorOrnThivesEyeMask; ++i) { - _currMapDoorOrnInfo[i][kNativeBitmapIndex] = i + (kDoorMaskDestroyedIndice - kDoorOrnDestroyedMask); - _currMapDoorOrnInfo[i][kNativeCoordinateSet] = 1; + loadFloorSet(kFloorSetStone); + loadWallSet(kWallSetStone); + + + + if (!_derivedBitmapByteCount) + _derivedBitmapByteCount = new uint16[kDerivedBitmapMaximumCount]; + + _derivedBitmapByteCount[kDerivedBitmapViewport] = 224 * 136; + _derivedBitmapByteCount[kDerivedBitmapThievesEyeVisibleArea] = 96 * 95; + _derivedBitmapByteCount[kDerivedBitmapDamageToCreatureMedium] = 64 * 37; + _derivedBitmapByteCount[kDerivedBitmapDamageToCreatureSmall] = 48 * 37; + + for (int16 doorOrnamentIndex = kDoorOrnDestroyedMask; doorOrnamentIndex <= kDoorOrnThivesEyeMask; doorOrnamentIndex++) { + _currMapDoorOrnInfo[doorOrnamentIndex][kNativeBitmapIndex] = doorOrnamentIndex + (kDoorMaskDestroyedIndice - kDoorOrnDestroyedMask); + _currMapDoorOrnInfo[doorOrnamentIndex][kCoordinateSet] = 1; + + _derivedBitmapByteCount[doorOrnamentIndex * 2 + kDerivedBitmapFirstDoorOrnament_D3] = 48 * 41; + _derivedBitmapByteCount[doorOrnamentIndex * 2 + kDerivedBitmapFirstDoorOrnament_D2] = 64 * 61; + } + + _currMapFloorOrnInfo[kFloorOrnFootprints][kNativeBitmapIndex] = kFloorOrn_15_D3L_footprints; + _currMapFloorOrnInfo[kFloorOrnFootprints][kCoordinateSet] = 1; + + ObjectAspect *objectAspect = gObjectAspects; + int16 derivedBitmapIndex; + for (int16 objectAspectIndex = 0; objectAspectIndex < kObjAspectCount; ++objectAspectIndex, ++objectAspect) { + derivedBitmapIndex = kDerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex; + + _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, kScale16_D3); + _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, kScale20_D2); + + if (getFlag(objectAspect->_graphicInfo, kObjectFlipOnRightMask)) { + _derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2]; + derivedBitmapIndex++; + _derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2]; + derivedBitmapIndex++; + } + + if (getFlag(objectAspect->_graphicInfo, kObjectAlcoveMask)) { + _derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2]; + derivedBitmapIndex++; + _derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2]; + } } - _currMapFloorOrnInfo[kFloorOrnFootprints][kNativeBitmapIndex] = 1; - _currMapFloorOrnInfo[kFloorOrnFootprints][kNativeCoordinateSet] = 1; + ProjectileAspect *projectileAspect = gProjectileAspect; + for (int16 projectileAspectIndex = 0; projectileAspectIndex < kProjectileAspectCount; projectileAspectIndex++, projectileAspect++) { + + if (!getFlag(projectileAspect->_graphicInfo, kProjectileScaleWithKineticEnergyMask)) { + derivedBitmapIndex = kDerivedBitmapFirstProjectile + projectileAspect->_firstDerivedBitmapRelativeIndex; + + for (int16 projectileScaleIndex = 0; projectileScaleIndex < 6; projectileScaleIndex++) { + int16 bitmapPixelCount = getScaledBitmapPixelCount(projectileAspect->_width, projectileAspect->_height, gProjectileScales[projectileScaleIndex]); + _derivedBitmapByteCount[derivedBitmapIndex] = bitmapPixelCount; + + if (getFlag(projectileAspect->_graphicInfo, kProjectileAspectTypeMask) != kProjectileAspectHasNone) { + _derivedBitmapByteCount[derivedBitmapIndex + 6] = bitmapPixelCount; + + if (getFlag(projectileAspect->_graphicInfo, kProjectileAspectTypeMask) != kProjectileAspectHasRotation) { + _derivedBitmapByteCount[derivedBitmapIndex + 12] = bitmapPixelCount; + } + } + } + } + } _palChangesProjectile[0] = gPalChangesFloorOrn_D3; _palChangesProjectile[1] = gPalChangesFloorOrn_D2; _palChangesProjectile[2] = _palChangesProjectile[3] = gPalChangesNoChanges; - loadFloorSet(kFloorSetStone); - loadWallSet(kWallSetStone); + derivedBitmapIndex = kDerivedBitmapFirstExplosion; + ExplosionAspect *expAsp = gExplosionAspects; + for (uint16 expAspIndex = 0; expAspIndex < kExplosionAspectCount; ++expAspIndex, expAsp++) { + for (int16 scale = 4; scale < 32; scale += 2) + _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(expAsp->_pixelWidth, expAsp->_height, scale); + + if (expAspIndex == kExplosionAspectSmoke) { + _derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_pixelWidth * expAsp->_height; + } + } + + derivedBitmapIndex = kDerivedBitmapFirstCreature; + CreatureAspect *creatureAsp; + for (int16 creatureIndex = 0; creatureIndex < kCreatureTypeCount; creatureIndex++) { + creatureAsp = &gCreatureAspects[creatureIndex]; + + int16 creatureGraphicInfo = gCreatureInfo[creatureIndex]._graphicInfo; + creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex; + + int16 creatureFrontBitmapD3PixelCount; + _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3); + + int16 creatureFrontBitmapD2PixelCount; + _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2); + + if (getFlag(creatureGraphicInfo, kCreatureInfoMaskSide)) { + _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale16_D3); + _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale20_D2); + } + if (getFlag(creatureGraphicInfo, kCreatureInfoMaskBack)) { + _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount; + _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount; + } + + if (getFlag(creatureGraphicInfo, kCreatureInfoMaskAttack)) { + _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, kScale16_D3); + _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, kScale20_D2); + } + + int16 additionalFronGraphicCount; + if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, kCreatureInfoMaskAdditional)) { + do { + _derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront; + _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3); + _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2); + } while (--additionalFronGraphicCount); + } + } } void DisplayMan::unpackGraphics() { @@ -1329,21 +1453,21 @@ void DisplayMan::loadCurrentMapGraphics() { if (ornIndice == gFountainOrnIndices[ornCounter]) _currMapFountainOrnIndices[fountainCount++] = i; - _currMapWallOrnInfo[i][kNativeCoordinateSet] = gWallOrnCoordSetIndices[ornIndice]; + _currMapWallOrnInfo[i][kCoordinateSet] = gWallOrnCoordSetIndices[ornIndice]; } for (uint16 i = 0; i < currMap._floorOrnCount; ++i) { uint16 ornIndice = _currMapFloorOrnIndices[i]; uint16 nativeIndice = kFirstFloorOrn + ornIndice * 6; _currMapFloorOrnInfo[i][kNativeBitmapIndex] = nativeIndice; - _currMapFloorOrnInfo[i][kNativeCoordinateSet] = gFloorOrnCoordSetIndices[ornIndice]; + _currMapFloorOrnInfo[i][kCoordinateSet] = gFloorOrnCoordSetIndices[ornIndice]; } for (uint16 i = 0; i < currMap._doorOrnCount; ++i) { uint16 ornIndice = _currMapDoorOrnIndices[i]; uint16 nativeIndice = kFirstDoorOrn + ornIndice; _currMapDoorOrnInfo[i][kNativeBitmapIndex] = nativeIndice; - _currMapDoorOrnInfo[i][kNativeCoordinateSet] = gDoorOrnCoordIndices[ornIndice]; + _currMapDoorOrnInfo[i][kCoordinateSet] = gDoorOrnCoordIndices[ornIndice]; } applyCreatureReplColors(9, 8); @@ -1432,7 +1556,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex int16 wallOrnIndex = wallOrnOrd - 1; int16 nativeBitmapIndex = _currMapWallOrnInfo[wallOrnIndex][kNativeBitmapIndex]; - uint16 *coordinateSetA = gWallOrnCoordSets[_currMapWallOrnInfo[wallOrnIndex][kNativeCoordinateSet]][viewWallIndex]; + uint16 *coordinateSetA = gWallOrnCoordSets[_currMapWallOrnInfo[wallOrnIndex][kCoordinateSet]][viewWallIndex]; isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnIndex); isInscription = (wallOrnIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex); if (isInscription) { @@ -1492,7 +1616,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex } else { coordinateSetOffset = 0; uint16 *coordSetB; - int16 wallOrnCoordSetIndex = _currMapWallOrnInfo[wallOrnIndex][kNativeCoordinateSet]; + int16 wallOrnCoordSetIndex = _currMapWallOrnInfo[wallOrnIndex][kCoordinateSet]; flipHorizontal = (viewWallIndex == kViewWall_D2R_LEFT) || (viewWallIndex == kViewWall_D3R_LEFT); if (flipHorizontal) { coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1R_LEFT]; @@ -1587,6 +1711,14 @@ uint32 DisplayMan::getCompressedDataSize(uint16 index) { return _packedItemPos[index + 1] - _packedItemPos[index]; } +int16 DisplayMan::getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale) { + return getScaledDimension(pixelWidth, scale) * getScaledDimension(pixelHeight, scale); +} + +int16 DisplayMan::getScaledDimension(int16 dimension, int16 scale) { + return (dimension * scale + scale / 2) / 32; +} + void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) { uint16 width = box._x2 - box._x1; for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y) diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index b6a32c5065..0e7bcf65ec 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -32,9 +32,89 @@ #include "common/rect.h" #include "common/memstream.h" #include "dm.h" +#include "common/array.h" namespace DM { +#define kFloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT +#define kWallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT +#define kStairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT +#define kDoorSetGraphicsCount 3 // @ C003_DOOR_SET_GRAPHIC_COUNT +#define kDoorButtonCount 1 // @ C001_DOOR_BUTTON_COUNT +#define kNativeBitmapIndex 0 // @ C0_NATIVE_BITMAP_INDEX +#define kCoordinateSet 1 // @ C1_COORDINATE_SET +#define kCreatureTypeCount 27 // @ C027_CREATURE_TYPE_COUNT +#define kExplosionAspectCount 4 // @ C004_EXPLOSION_ASPECT_COUNT +#define kObjAspectCount 85 // @ C085_OBJECT_ASPECT_COUNT +#define kProjectileAspectCount 14 // @ C014_PROJECTILE_ASPECT_COUNT + +/* Explosion aspects */ +#define kExplosionAspectFire 0 // @ C0_EXPLOSION_ASPECT_FIRE +#define kExplosionAspectSpell 1 // @ C1_EXPLOSION_ASPECT_SPELL +#define kExplosionAspectPoison 2 // @ C2_EXPLOSION_ASPECT_POISON +#define kExplosionAspectSmoke 3 // @ C3_EXPLOSION_ASPECT_SMOKE + +/* Creature info GraphicInfo */ +#define kCreatureInfoMaskAdditional 0x0003 // @ MASK0x0003_ADDITIONAL +#define kCreatureInfoMaskFlipNonAttack 0x0004 // @ MASK0x0004_FLIP_NON_ATTACK +#define kCreatureInfoMaskSide 0x0008 // @ MASK0x0008_SIDE +#define kCreatureInfoMaskBack 0x0010 // @ MASK0x0010_BACK +#define kCreatureInfoMaskAttack 0x0020 // @ MASK0x0020_ATTACK +#define kCreatureInfoMaskSpecialD2Front 0x0080 // @ MASK0x0080_SPECIAL_D2_FRONT +#define kCreatureInfoMaskSpecialD2FrontIsFlipped 0x0100 // @ MASK0x0100_SPECIAL_D2_FRONT_IS_FLIPPED_FRONT +#define kCreatureInfoMaskFlipAttack 0x0200 // @ MASK0x0200_FLIP_ATTACK +#define kCreatureInfoMaskFlipDuringAttack 0x0400 // @ MASK0x0400_FLIP_DURING_ATTACK + +class ExplosionAspect { +public: + uint16 _pixelWidth; + uint16 _height; + + ExplosionAspect(uint16 byteWidth, uint16 height) :_pixelWidth(byteWidth * 2), _height(height) {} +}; // @ EXPLOSION_ASPECT + +extern ExplosionAspect gExplosionAspects[kExplosionAspectCount]; + +extern byte gProjectileScales[7]; // @ G0215_auc_Graphic558_ProjectileScales + + +#define kDerivedBitmapViewport 0 // @ C000_DERIVED_BITMAP_VIEWPORT +#define kDerivedBitmapThievesEyeVisibleArea 1 // @ C001_DERIVED_BITMAP_THIEVES_EYE_VISIBLE_AREA +#define kDerivedBitmapDamageToCreatureMedium 2 // @ C002_DERIVED_BITMAP_DAMAGE_TO_CREATURE_MEDIUM +#define kDerivedBitmapDamageToCreatureSmall 3 // @ C003_DERIVED_BITMAP_DAMAGE_TO_CREATURE_SMALL +#define kDerivedBitmapFirstWallOrnament 4 // @ C004_DERIVED_BITMAP_FIRST_WALL_ORNAMENT +#define kDerivedBitmapFirstDoorOrnament_D3 68 // @ C068_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D3 +#define kDerivedBitmapFirstDoorOrnament_D2 69 // @ C069_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D2 +#define kDerivedBitmapFirstDoorButton 102 // @ C102_DERIVED_BITMAP_FIRST_DOOR_BUTTON +#define kDerivedBitmapFirstObject 104 // @ C104_DERIVED_BITMAP_FIRST_OBJECT +#define kDerivedBitmapFirstProjectile 282 // @ C282_DERIVED_BITMAP_FIRST_PROJECTILE +#define kDerivedBitmapFirstExplosion 438 // @ C438_DERIVED_BITMAP_FIRST_EXPLOSION +#define kDerivedBitmapFirstCreature 495 // @ C495_DERIVED_BITMAP_FIRST_CREATURE + + +#define kScale16_D3 16 // @ C16_SCALE_D3 +#define kScale20_D2 20 // @ C20_SCALE_D2 +/* Object aspect GraphicInfo */ +#define kObjectFlipOnRightMask 0x0001 // @ MASK0x0001_FLIP_ON_RIGHT +#define kObjectAlcoveMask 0x0010 // @ MASK0x0010_ALCOVE + +/* Projectile aspect GraphicInfo */ +#define kProjectileSideMask 0x0010 // @ MASK0x0010_SIDE +#define kProjectileScaleWithKineticEnergyMask 0x0100 // @ MASK0x0100_SCALE_WITH_KINETIC_ENERGY +#define kProjectileAspectTypeMask 0x0003 // @ MASK0x0003_ASPECT_TYPE + +/* Projectile aspect type */ +#define kProjectileAspectHasBackGraphicRotation 0 // @ C0_PROJECTILE_ASPECT_TYPE_HAS_BACK_GRAPHIC_AND_ROTATION +#define kProjectileAspectBackGraphic 1 // @ C1_PROJECTILE_ASPECT_TYPE_HAS_BACK_GRAPHIC_AND_NO_ROTATION +#define kProjectileAspectHasRotation 2 // @ C2_PROJECTILE_ASPECT_TYPE_NO_BACK_GRAPHIC_AND_ROTATION +#define kProjectileAspectHasNone 3 // @ C3_PROJECTILE_ASPECT_TYPE_NO_BACK_GRAPHIC_AND_NO_ROTATION + +/* Projectile aspects */ +#define kProjectileAspectExplosionLightningBolt 3 // @ C03_PROJECTILE_ASPECT_EXPLOSION_LIGHTNING_BOLT +#define kProjectileAspectExplosionFireBall 10 // @ C10_PROJECTILE_ASPECT_EXPLOSION_FIREBALL +#define kProjectileAspectExplosionDefault 11 // @ C11_PROJECTILE_ASPECT_EXPLOSION_DEFAULT +#define kProjectileAspectExplosionSlime 12 // @ C12_PROJECTILE_ASPECT_EXPLOSION_SLIME +#define kProjectileAspectExplosionPoisonBoltCloud 13 // @ C13_PROJECTILE_ASPECT_EXPLOSION_POISON_BOLT_POISON_CLOUD enum ViewCell { kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT @@ -80,7 +160,8 @@ enum GraphicIndice { kPanelOpenChestIndice = 25, // @ C025_GRAPHIC_PANEL_OPEN_CHEST kEyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION kArrowForChestContentIndice = 18, // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT - kObjectDescCircleIndice = 29 // @ C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE + kObjectDescCircleIndice = 29, // @ C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE + kFloorOrn_15_D3L_footprints = 241 // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS }; extern uint16 gPalSwoosh[16]; @@ -248,17 +329,6 @@ extern Viewport gDungeonViewport; #define kAlcoveOrnCount 3 #define kFountainOrnCount 1 -#define kFloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT -#define kWallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT -#define kStairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT -#define kDoorSetGraphicsCount 3 // @ C003_DOOR_SET_GRAPHIC_COUNT -#define kDoorButtonCount 1 // @ C001_DOOR_BUTTON_COUNT -#define kNativeBitmapIndex 0 // @ C0_NATIVE_BITMAP_INDEX -#define kNativeCoordinateSet 1 // @ C1_COORDINATE_SET -#define kCreatureTypeCount 27 // @ C027_CREATURE_TYPE_COUNT -#define kExplosionAspectCount 4 // @ C004_EXPLOSION_ASPECT_COUNT -#define kObjAspectCount 85 // @ C085_OBJECT_ASPECT_COUNT -#define kProjectileAspectCount 14 // @ C014_PROJECTILE_ASPECT_COUNT #define kDoorButton 0 // @ C0_DOOR_BUTTON #define kWallOrnInscription 0 // @ C0_WALL_ORNAMENT_INSCRIPTION @@ -320,6 +390,8 @@ class DisplayMan { bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF + uint16 *_derivedBitmapByteCount;// @ G0639_pui_DerivedBitmapByteCount + public: // some methods use this for a stratchpad, don't make assumptions about content between function calls byte *_tmpBitmap; @@ -332,7 +404,7 @@ public: void setUpScreens(uint16 width, uint16 height); void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader, F0460_START_InitializeGraphicData - void loadCurrentMapGraphics(); + void loadCurrentMapGraphics(); // @ F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF void loadPalette(uint16 *palette); /// Gives the width of an IMG0 type item @@ -369,6 +441,9 @@ public: Common::MemoryReadStream getCompressedData(uint16 index); uint32 getCompressedDataSize(uint16 index); + int16 getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount + int16 getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION + int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices int16 _currMapFountainOrnIndices[kFountainOrnCount]; // @ G0268_ai_CurrentMapFountainOrnamentIndices @@ -385,6 +460,12 @@ public: Thing _inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing bool _useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates + + bool isDerivedBitmapInCache(int16 derivedBitmapIndex); // @ F0491_CACHE_IsDerivedBitmapInCache + byte *getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap + + + }; } -- cgit v1.2.3 From 36a29bbe867206d2b0b408550ad4ee15610c9276 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Jun 2016 20:41:35 +0200 Subject: DM: Reorder files in MK file --- engines/dm/module.mk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/engines/dm/module.mk b/engines/dm/module.mk index bd9b57677b..d5756c9d5f 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -29,18 +29,18 @@ MODULE := engines/dm MODULE_OBJS := \ + champion.o \ detection.o \ dm.o \ - gfx.o \ dungeonman.o \ eventman.o \ - menus.o \ - champion.o \ + gfx.o \ + inventory.o \ loadsave.o \ + menus.o \ + movesens.o \ objectman.o \ - inventory.o \ - text.o \ - movesens.o + text.o MODULE_DIRS += \ engines/dm -- cgit v1.2.3 From 3f19bcdf6b47bc7227eb91c6eb95fb20335276f6 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 29 Jun 2016 23:02:34 +0200 Subject: DM: Add F0491_CACHE_IsDerivedBitmapInCache, F0492_CACHE_GetDerivedBitmap --- engines/dm/gfx.cpp | 33 +++++++++++++++++++++++++++++---- engines/dm/gfx.h | 3 ++- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 0c55fe557e..ea3a4b7b67 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -617,6 +617,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _ceilingBitmap = nullptr; _currMapAllowedCreatureTypes = nullptr; _derivedBitmapByteCount = nullptr; + _derivedBitmaps = nullptr; _screenWidth = _screenHeight = 0; _championPortraitOrdinal = 0; @@ -671,6 +672,13 @@ DisplayMan::~DisplayMan() { delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; // copy of another bitmap, but flipped for (uint16 i = kWall_D0L_Flipped; i <= kWall_D3LCR_Flipped; ++i) delete[] _wallSetBitMaps[i]; + + delete[] _derivedBitmapByteCount; + if (_derivedBitmaps) { + for (uint16 i = 0; i < kDerivedBitmapMaximumCount; ++i) + delete[] _derivedBitmaps; + delete[] _derivedBitmaps; + } } void DisplayMan::setUpScreens(uint16 width, uint16 height) { @@ -712,6 +720,11 @@ void DisplayMan::loadGraphics() { if (!_derivedBitmapByteCount) _derivedBitmapByteCount = new uint16[kDerivedBitmapMaximumCount]; + if (!_derivedBitmaps) { + _derivedBitmaps = new byte*[kDerivedBitmapMaximumCount]; + for (uint16 i = 0; i < kDerivedBitmapMaximumCount; ++i) + _derivedBitmaps[i] = nullptr; + } _derivedBitmapByteCount[kDerivedBitmapViewport] = 224 * 136; _derivedBitmapByteCount[kDerivedBitmapThievesEyeVisibleArea] = 96 * 95; @@ -791,16 +804,16 @@ void DisplayMan::loadGraphics() { CreatureAspect *creatureAsp; for (int16 creatureIndex = 0; creatureIndex < kCreatureTypeCount; creatureIndex++) { creatureAsp = &gCreatureAspects[creatureIndex]; - + int16 creatureGraphicInfo = gCreatureInfo[creatureIndex]._graphicInfo; creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex; - + int16 creatureFrontBitmapD3PixelCount; _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3); - + int16 creatureFrontBitmapD2PixelCount; _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2); - + if (getFlag(creatureGraphicInfo, kCreatureInfoMaskSide)) { _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale16_D3); _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale20_D2); @@ -1719,6 +1732,18 @@ int16 DisplayMan::getScaledDimension(int16 dimension, int16 scale) { return (dimension * scale + scale / 2) / 32; } +bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) { + if (_derivedBitmaps == nullptr) { + _derivedBitmaps[derivedBitmapIndex] = new byte[_derivedBitmapByteCount[derivedBitmapIndex]]; + return false; + } else + return true; +} + +byte* DisplayMan::getDerivedBitmap(int16 derivedBitmapIndex) { + return _derivedBitmaps[derivedBitmapIndex]; +} + void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) { uint16 width = box._x2 - box._x1; for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y) diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 0e7bcf65ec..ba6584f0f4 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -390,7 +390,8 @@ class DisplayMan { bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF - uint16 *_derivedBitmapByteCount;// @ G0639_pui_DerivedBitmapByteCount + uint16 *_derivedBitmapByteCount; // @ G0639_pui_DerivedBitmapByteCount + byte **_derivedBitmaps; // @ G0638_pui_DerivedBitmapBlockIndices public: // some methods use this for a stratchpad, don't make assumptions about content between function calls -- cgit v1.2.3 From 57ca9afcff6b688d438a7c02096141921f28fc36 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Jun 2016 22:51:40 +0200 Subject: DM: Move two global arrays to DMEngine --- engines/dm/champion.cpp | 4 ++-- engines/dm/dm.cpp | 3 --- engines/dm/dm.h | 10 +++++---- engines/dm/dmglobals.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/dungeonman.cpp | 8 +++---- engines/dm/eventman.cpp | 12 +++++------ engines/dm/module.mk | 1 + 7 files changed, 74 insertions(+), 19 deletions(-) create mode 100644 engines/dm/dmglobals.cpp diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index cce3f558a7..88e03a52d5 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -561,8 +561,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { int16 mapY = _vm->_dungeonMan->_currMap._partyPosY; uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir)); - mapX += gDirIntoStepCountEast[dunMan._currMap._partyDir]; - mapY += gDirIntoStepCountNorth[dunMan._currMap._partyDir]; + mapX += _vm->_dirIntoStepCountEast[dunMan._currMap._partyDir]; + mapY += _vm->_dirIntoStepCountNorth[dunMan._currMap._partyDir]; thing = dunMan.getSquareFirstThing(mapX, mapY); AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1; uint16 slotIndex_Green; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 0df836a45a..af0c9d587c 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -52,9 +52,6 @@ namespace DM { -int8 gDirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount -int8 gDirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount - void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); } direction returnOppositeDir(direction dir) { return (direction)((dir + 2) & 3); } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 7b68e6d5a3..4bf858422c 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -55,10 +55,6 @@ enum direction { kDirWest = 3 }; -// TODO: refactor direction into a class -extern int8 gDirIntoStepCountEast[4]; -extern int8 gDirIntoStepCountNorth[4]; - void turnDirRight(direction &dir); void turnDirLeft(direction &dir); direction returnOppositeDir(direction dir); @@ -128,6 +124,8 @@ class DMEngine : public Engine { void processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF + void initArrays(); + public: explicit DMEngine(OSystem *syst); ~DMEngine(); @@ -160,6 +158,10 @@ public: bool _pressingMouth; // @ G0333_B_PressingMouth bool _stopPressingMouth; // @ G0334_B_StopPressingMouth bool _highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested + + // TODO: refactor direction into a class + int8 _dirIntoStepCountEast[4]; + int8 _dirIntoStepCountNorth[4]; }; class Console : public GUI::Debugger { diff --git a/engines/dm/dmglobals.cpp b/engines/dm/dmglobals.cpp new file mode 100644 index 0000000000..c138453c31 --- /dev/null +++ b/engines/dm/dmglobals.cpp @@ -0,0 +1,55 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + +#include "dm/dm.h" +#include "gfx.h" +#include "dungeonman.h" +#include "eventman.h" +#include "menus.h" +#include "champion.h" +#include "loadsave.h" +#include "objectman.h" +#include "inventory.h" +#include "text.h" +#include "movesens.h" + +namespace DM { + +void DMEngine::initArrays() { + // G0233_ai_Graphic559_DirectionToStepEastCount + _dirIntoStepCountEast[0] = 0; // North + _dirIntoStepCountEast[1] = 1; // East + _dirIntoStepCountEast[2] = 0; // West + _dirIntoStepCountEast[3] = -1; // South + + // G0234_ai_Graphic559_DirectionToStepNorthCount + _dirIntoStepCountNorth[0] = -1; // North + _dirIntoStepCountNorth[1] = 0; // East + _dirIntoStepCountNorth[2] = 1; // West + _dirIntoStepCountNorth[3] = 0; // South +} +} // End of namespace DM diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 899e7911ad..83c43aac3d 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -360,11 +360,11 @@ CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_Crea {26, 0, 0x38AA, 0x0000, 12, 22, 255, 180, 210, 0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}}; void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) { - posX += gDirIntoStepCountEast[dir] * stepsForward; - posY += gDirIntoStepCountNorth[dir] * stepsForward; + posX += _vm->_dirIntoStepCountEast[dir] * stepsForward; + posY += _vm->_dirIntoStepCountNorth[dir] * stepsForward; turnDirRight(dir); - posX += gDirIntoStepCountEast[dir] * stepsRight; - posY += gDirIntoStepCountNorth[dir] * stepsRight; + posX += _vm->_dirIntoStepCountEast[dir] * stepsRight; + posY += _vm->_dirIntoStepCountNorth[dir] * stepsRight; } DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) { diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 20c2888aec..f26930c542 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -508,8 +508,8 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) { void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() { DungeonMan &dunMan = *_vm->_dungeonMan; CurrMapData &currMap = dunMan._currMap; - int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir]; - int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir]; + int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir]; + int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir]; if ((mapX >= 0) && (mapX < currMap._width) && (mapY >= 0) && (mapY < currMap._height)) { _vm->_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._partyDir)); } @@ -525,8 +525,8 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY return; if (champMan._leaderEmptyHanded) { - int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir]; - int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir]; + int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir]; + int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir]; if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() && dunMan._dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { @@ -627,8 +627,8 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane } champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone); - int16 mapX = currMap._partyPosX + gDirIntoStepCountEast[currMap._partyDir]; - int16 mapY = currMap._partyPosY + gDirIntoStepCountNorth[currMap._partyDir]; + int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir]; + int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir]; for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) { Thing thing = champ->getSlot((ChampionSlot)slotIndex); diff --git a/engines/dm/module.mk b/engines/dm/module.mk index d5756c9d5f..28bcaa2a54 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -32,6 +32,7 @@ MODULE_OBJS := \ champion.o \ detection.o \ dm.o \ + dmglobals.o \ dungeonman.o \ eventman.o \ gfx.o \ -- cgit v1.2.3 From bc583bf0d52cb2e9d959ad36a06e462707084d63 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 29 Jun 2016 23:17:04 +0200 Subject: DM: Fix missing call to initArrays() --- engines/dm/dm.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index af0c9d587c..2d55c5e8e3 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -189,6 +189,8 @@ void DMEngine::processNewPartyMap(uint16 mapIndex) { } Common::Error DMEngine::run() { + initArrays(); + // scummvm/engine specific initGraphics(320, 200, false); _console = new Console(this); -- cgit v1.2.3 From b3e1760bfb6113159a7a8d6079c358a451eee781 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 30 Jun 2016 12:12:22 +0200 Subject: DM: Add dummy blitBoxFilledWithMaskedBitmap and DisplayMan::drawField --- engines/dm/TODOs/methodtree.txt | 10 +++++----- engines/dm/gfx.cpp | 38 ++++++++++++++++++++++++++++++++++++++ engines/dm/gfx.h | 28 +++++++++++++++++++++++++++- 3 files changed, 70 insertions(+), 6 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 10ed85fa5c..7a05ad177f 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -1,9 +1,9 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF - F0113_DUNGEONVIEW_DrawField // dummy - F0133_VIDEO_BlitBoxFilledWithMaskedBitmap - FIELD_ASPECT + F0113_DUNGEONVIEW_DrawField // stub method + F0133_VIDEO_BlitBoxFilledWithMaskedBitmap // dummy + FIELD_ASPECT // done F0114_DUNGEONVIEW_GetExplosionBitmap - F0133_VIDEO_BlitBoxFilledWithMaskedBitmap + F0133_VIDEO_BlitBoxFilledWithMaskedBitmap // dummy F0141_DUNGEON_GetObjectInfoIndex F0142_DUNGEON_GetProjectileAspect F0176_GROUP_GetCreatureOrdinalInCell @@ -44,7 +44,7 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF CREATURE_ASPECT PROJECTILE EXPLOSION - FIELD_ASPECT + FIELD_ASPECT // done diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index ea3a4b7b67..2fa2bf5d5a 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -969,6 +969,12 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight memcpy(destBitmap + destWidth*(y + destY) + destX, srcBitmap + y * srcWidth, sizeof(byte)* srcWidth); } +void DisplayMan::blitBoxFilledWithMaskedBitmapToScreen(byte* src, byte* mask, byte* tmp, Box& box, + int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, + int16 xPos, int16 yPos, int16 height2, Viewport& viewport) { + blitBoxFilledWithMaskedBitmap(src, _vgaBuffer, mask, tmp, box, lastUnitIndex, firstUnitIndex, _screenWidth, transparent, xPos, yPos, _screenHeight, height2, viewport); +} + void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) { for (uint16 y = 0; y < height; ++y) { for (uint16 x = 0; x < width / 2; ++x) { @@ -1724,6 +1730,32 @@ uint32 DisplayMan::getCompressedDataSize(uint16 index) { return _packedItemPos[index + 1] - _packedItemPos[index]; } +/* Field Aspect Mask */ +#define kMaskFieldAspectFlipMask 0x0080 // @ MASK0x0080_FLIP_MASK +#define kMaskFieldAspectIndex 0x007F // @ MASK0x007F_MASK_INDEX +#define kMaskFieldAspectNoMask 255 // @ C255_NO_MASK + +void DisplayMan::drawField(FieldAspect* fieldAspect, Box& box) { + DisplayMan &dispMan = *_vm->_displayMan; + + byte *bitmapMask; + if (fieldAspect->_mask == kMaskFieldAspectNoMask) { + bitmapMask = nullptr; + } else { + bitmapMask = dispMan._tmpBitmap; + memcpy(bitmapMask, dispMan.getBitmap(kFieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)), + fieldAspect->_height * fieldAspect->_pixelWidth * sizeof(bitmapMask[0])); + if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) { + dispMan.flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height); + } + } + + byte *bitmap = dispMan.getBitmap(kFieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex); + warning("MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap"); + + warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock"); +} + int16 DisplayMan::getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale) { return getScaledDimension(pixelWidth, scale) * getScaledDimension(pixelHeight, scale); } @@ -1756,4 +1788,10 @@ void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uin blitToScreen(srcBitmap, srcWidth, srcX, srcY, box._x1, box._x2, box._y1, box._y2, transparent, viewport); } +void DisplayMan::blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box, + int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, + int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport) { + warning("STUB FUNCTION: does nothing at all"); +} + } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index ba6584f0f4..34a1399366 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -35,6 +35,9 @@ #include "common/array.h" namespace DM { + + + #define kFloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT #define kWallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT #define kStairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT @@ -161,7 +164,9 @@ enum GraphicIndice { kEyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION kArrowForChestContentIndice = 18, // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT kObjectDescCircleIndice = 29, // @ C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE - kFloorOrn_15_D3L_footprints = 241 // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS + kFloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS + kFieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R + kFieldTeleporterGraphicIndice = 73 // @ C073_GRAPHIC_FIELD_TELEPORTER }; extern uint16 gPalSwoosh[16]; @@ -265,6 +270,20 @@ enum Color { kColorWhite = 15 }; +class FieldAspect { +public: + uint16 _nativeBitmapRelativeIndex; + uint16 _baseStartUnitIndex; /* Index of the unit (16 pixels = 8 bytes) in bitmap where blit will start from. A random value of 0 or 1 is added to this base index */ + Color _transparentColor; /* Bit 7: Do not use mask if set, Bits 6-0: Transparent color index. 0xFF = no transparency */ + byte _mask; /* Bit 7: Flip, Bits 6-0: Mask index. 0xFF = no mask */ + uint16 _pixelWidth; + uint16 _height; + uint16 _xPos; + FieldAspect(uint16 native, uint16 base, Color transparent, byte mask, uint16 byteWidth, uint16 height, uint16 xPos) + : _nativeBitmapRelativeIndex(native), _baseStartUnitIndex(base), _transparentColor(transparent), _mask(mask), + _pixelWidth(byteWidth * 2), _height(height), _xPos(xPos) {} +}; // @ FIELD_ASPECT + class Viewport { public: @@ -429,6 +448,12 @@ public: void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, Box &box, Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort); + void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, + int16 firstUnitIndex, int16 destPixelWidth, Color transparent, + int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDefultViewPort); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap + void blitBoxFilledWithMaskedBitmapToScreen(byte *src, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, + int16 firstUnitIndex, int16 destPixelWidth, Color transparent, + int16 xPos, int16 yPos, int16 height2, Viewport &viewport = gDungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); @@ -441,6 +466,7 @@ public: byte* getBitmap(uint16 index); Common::MemoryReadStream getCompressedData(uint16 index); uint32 getCompressedDataSize(uint16 index); + void drawField(FieldAspect *fieldAspect, Box &box); // @ F0113_DUNGEONVIEW_DrawField int16 getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount int16 getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION -- cgit v1.2.3 From a09ff6a165ded27abed68edd4067acd494ec5221 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 30 Jun 2016 12:35:02 +0200 Subject: DM: Add F0114_DUNGEONVIEW_GetExplosionBitmap --- engines/dm/TODOs/methodtree.txt | 2 +- engines/dm/gfx.cpp | 26 ++++++++++++++++++++++++++ engines/dm/gfx.h | 4 +++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 7a05ad177f..da5e0ccca9 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -2,7 +2,7 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF F0113_DUNGEONVIEW_DrawField // stub method F0133_VIDEO_BlitBoxFilledWithMaskedBitmap // dummy FIELD_ASPECT // done - F0114_DUNGEONVIEW_GetExplosionBitmap + F0114_DUNGEONVIEW_GetExplosionBitmap // done F0133_VIDEO_BlitBoxFilledWithMaskedBitmap // dummy F0141_DUNGEON_GetObjectInfoIndex F0142_DUNGEON_GetProjectileAspect diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 2fa2bf5d5a..81b53d4ba6 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -39,6 +39,8 @@ namespace DM { Box gBoxMovementArrows = Box(224, 319, 124, 168); +byte gPalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke + ExplosionAspect gExplosionAspects[kExplosionAspectCount] = { // @ G0211_as_Graphic558_ExplosionAspects /* { ByteWidth, Height } */ ExplosionAspect(80, 111), /* Fire */ @@ -998,6 +1000,30 @@ void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) { delete[] tmp; } +byte* DisplayMan::getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnPixelWidth, int16& returnHeight) { + ExplosionAspect *explAsp = &gExplosionAspects[explosionAspIndex]; + if (scale > 32) + scale = 32; + int16 pixelWidth = getScaledDimension(explAsp->_pixelWidth, scale); + int16 height = getScaledDimension(explAsp->_height, scale); + byte *bitmap; + int16 derBitmapIndex = (explosionAspIndex * 14) + scale / 2 + kDerivedBitmapFirstExplosion - 2; + if ((scale == 32) && (explosionAspIndex != kExplosionAspectSmoke)) { + bitmap = getBitmap(explosionAspIndex + kFirstExplosionGraphicIndice); + } else if (isDerivedBitmapInCache(derBitmapIndex)) { + bitmap = getDerivedBitmap(derBitmapIndex); + } else { + byte *nativeBitmap = getBitmap(MIN(explosionAspIndex, (uint16)kExplosionAspectPoison) + kFirstExplosionGraphicIndice); + bitmap = getDerivedBitmap(derBitmapIndex); + blitToBitmapShrinkWithPalChange(nativeBitmap, explAsp->_pixelWidth, explAsp->_height, bitmap, pixelWidth, height, + (explosionAspIndex == kExplosionAspectSmoke) ? gPalChangeSmoke : gPalChangesNoChanges); + warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); + } + + returnPixelWidth = pixelWidth; + returnHeight = height; + return bitmap; +} void DisplayMan::updateScreen() { diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 34a1399366..2df0ac0a5c 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -166,7 +166,8 @@ enum GraphicIndice { kObjectDescCircleIndice = 29, // @ C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE kFloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS kFieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R - kFieldTeleporterGraphicIndice = 73 // @ C073_GRAPHIC_FIELD_TELEPORTER + kFieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER + kFirstExplosionGraphicIndice = 348 // @ C348_GRAPHIC_FIRST_EXPLOSION }; extern uint16 gPalSwoosh[16]; @@ -457,6 +458,7 @@ public: void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); + byte *getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color); void clearScreen(Color color); -- cgit v1.2.3 From f3d4b854b7544c1379414983fcc750d60dfe2151 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 30 Jun 2016 13:29:42 +0200 Subject: DM: Add F0142_DUNGEON_GetProjectileAspect --- engines/dm/TODOs/methodtree.txt | 6 ++-- engines/dm/champion.cpp | 22 ++++++------- engines/dm/champion.h | 2 +- engines/dm/dm.h | 17 ++++++++-- engines/dm/dungeonman.cpp | 71 +++++++++++++++++++++++++++++++++-------- engines/dm/dungeonman.h | 2 ++ engines/dm/eventman.cpp | 2 +- engines/dm/gfx.cpp | 2 +- engines/dm/inventory.cpp | 28 ++++++++-------- engines/dm/loadsave.cpp | 2 +- engines/dm/menus.cpp | 2 +- engines/dm/movesens.cpp | 16 +++++----- engines/dm/objectman.cpp | 2 +- 13 files changed, 117 insertions(+), 57 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index da5e0ccca9..9f09e9dd8c 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -4,8 +4,10 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF FIELD_ASPECT // done F0114_DUNGEONVIEW_GetExplosionBitmap // done F0133_VIDEO_BlitBoxFilledWithMaskedBitmap // dummy - F0141_DUNGEON_GetObjectInfoIndex - F0142_DUNGEON_GetProjectileAspect + F0141_DUNGEON_GetObjectInfoIndex // done + F0142_DUNGEON_GetProjectileAspect // done + F0158_DUNGEON_GetWeaponInfo // done + M66_PROJECTILE_ASPECT_ORDINAL // done F0176_GROUP_GetCreatureOrdinalInCell G0017_auc_Graphic562_PaletteChanges_NoChanges G0075_apuc_PaletteChanges_Projectile diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 88e03a52d5..730eaa2985 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -368,7 +368,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio ObjectMan &objMan = *_vm->_objectMan; MenuMan &menuMan = *_vm->_menuMan; - if (thing == Thing::_thingNone) + if (thing == Thing::_none) return; Champion *champ = &_champions[champIndex]; @@ -442,7 +442,7 @@ void ChampionMan::resetDataToStartGame() { assert(false); } - _leaderHandObject = Thing::_thingNone; + _leaderHandObject = Thing::_none; _leaderHandObjectIconIndex = kIconIndiceNone; _leaderEmptyHanded = true; } @@ -479,7 +479,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { champ->_water = 1500 + _vm->_rnd->getRandomNumber(256); int16 AL_0_slotIndex_Red; for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) { - champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_thingNone); + champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none); } Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY); while (thing.getType() != kTextstringType) { @@ -566,7 +566,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { thing = dunMan.getSquareFirstThing(mapX, mapY); AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1; uint16 slotIndex_Green; - while (thing != Thing::_thingEndOfList) { + while (thing != Thing::_endOfList) { ThingType AL_2_thingType = thing.getType(); if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) { int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots(); @@ -576,14 +576,14 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { if (objectAllowedSlots & gSlotMasks[slotIndex_Green]) goto T0280048; } - if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { + if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_none)) { slotIndex_Green = kChampionSlotNeck; } else { goto T0280046; } break; case kWeaponThingType: - if (champ->getSlot(kChampionSlotActionHand) == Thing::_thingNone) { + if (champ->getSlot(kChampionSlotActionHand) == Thing::_none) { slotIndex_Green = kChampionSlotActionHand; } else { goto T0280046; @@ -591,9 +591,9 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { break; case kScrollThingType: case kPotionThingType: - if (champ->getSlot(kChampionSlotPouch_1) == Thing::_thingNone) { + if (champ->getSlot(kChampionSlotPouch_1) == Thing::_none) { slotIndex_Green = kChampionSlotPouch_1; - } else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_thingNone) { + } else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_none) { slotIndex_Green = kChampionSlotPouch_2; } else { goto T0280046; @@ -602,7 +602,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { case kContainerThingType: case kJunkThingType: T0280046: - if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_thingNone)) { + if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_none)) { slotIndex_Green = kChampionSlotNeck; } else { slotIndex_Green = AL_0_slotIndex_Red++; @@ -613,7 +613,7 @@ T0280046: break; } T0280048: - if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_thingNone) { + if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_none) { goto T0280046; } addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green); @@ -937,7 +937,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { } int16 iconIndex; - if (thing == Thing::_thingNone) { + if (thing == Thing::_none) { if (slotIndex <= kChampionSlotFeet) { iconIndex = kIconIndiceReadyHand + (slotIndex << 1); if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) { diff --git a/engines/dm/champion.h b/engines/dm/champion.h index d712e6b6c2..e0390a4937 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -400,7 +400,7 @@ public: void clearWounds() { _wounds = kChampionWoundNone; } void resetToZero() { // oh boy > . < for (int16 i = 0; i < 30; ++i) - _slots[i] = Thing::_thingNone; + _slots[i] = Thing::_none; for (int16 i = 0; i < 20; ++i) _skills[i].resetToZero(); _attributes = _wounds = 0; diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 4bf858422c..251a0af680 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -95,8 +95,21 @@ enum Cell { class Thing { uint16 _data; public: - static const Thing _thingNone; - static const Thing _thingEndOfList; + static const Thing _none; // @ C0xFFFF_THING_NONE + static const Thing _endOfList; // @ C0xFFFE_THING_ENDOFLIST + static const Thing _firstExplosion; // @ C0xFF80_THING_FIRST_EXPLOSION + static const Thing _explFireBall; // @ C0xFF80_THING_EXPLOSION_FIREBALL + static const Thing _explSlime; // @ C0xFF81_THING_EXPLOSION_SLIME + static const Thing _explLightningBolt; // @ C0xFF82_THING_EXPLOSION_LIGHTNING_BOLT + static const Thing _explHarmNonMaterial; // @ C0xFF83_THING_EXPLOSION_HARM_NON_MATERIAL + static const Thing _explOpenDoor; // @ C0xFF84_THING_EXPLOSION_OPEN_DOOR + static const Thing _explPoisonBolt; // @ C0xFF86_THING_EXPLOSION_POISON_BOLT + static const Thing _explPoisonCloud; // @ C0xFF87_THING_EXPLOSION_POISON_CLOUD + static const Thing _explSmoke; // @ C0xFFA8_THING_EXPLOSION_SMOKE + static const Thing _explFluxcage; // @ C0xFFB2_THING_EXPLOSION_FLUXCAGE + static const Thing _explRebirthStep1; // @ C0xFFE4_THING_EXPLOSION_REBIRTH_STEP1 + static const Thing _explRebirthStep2; // @ C0xFFE5_THING_EXPLOSION_REBIRTH_STEP2 + static const Thing _party; // @ C0xFFFF_THING_PARTY Thing() : _data(0) {} explicit Thing(uint16 d) { set(d); } diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 83c43aac3d..12531b66ea 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -534,8 +534,21 @@ unsigned char gThingDataWordCount[16] = { 2 /* Explosion */ }; // @ G0235_auc_Graphic559_ThingDataByteCount -const Thing Thing::_thingNone(0); -const Thing Thing::_thingEndOfList(0xFFFE); +const Thing Thing::_none(0); // @ C0xFFFF_THING_NONE +const Thing Thing::_endOfList(0xFFFE); // @ C0xFFFE_THING_ENDOFLIST +const Thing Thing::_firstExplosion(0xFF80); // @ C0xFF80_THING_FIRST_EXPLOSION +const Thing Thing::_explFireBall(0xFF80); // @ C0xFF80_THING_EXPLOSION_FIREBALL +const Thing Thing::_explSlime(0xFF81); // @ C0xFF81_THING_EXPLOSION_SLIME +const Thing Thing::_explLightningBolt(0xFF82); // @ C0xFF82_THING_EXPLOSION_LIGHTNING_BOLT +const Thing Thing::_explHarmNonMaterial(0xFF83); // @ C0xFF83_THING_EXPLOSION_HARM_NON_MATERIAL +const Thing Thing::_explOpenDoor(0xFF84); // @ C0xFF84_THING_EXPLOSION_OPEN_DOOR +const Thing Thing::_explPoisonBolt(0xFF86); // @ C0xFF86_THING_EXPLOSION_POISON_BOLT +const Thing Thing::_explPoisonCloud(0xFF87); // @ C0xFF87_THING_EXPLOSION_POISON_CLOUD +const Thing Thing::_explSmoke(0xFFA8); // @ C0xFFA8_THING_EXPLOSION_SMOKE +const Thing Thing::_explFluxcage(0xFFB2); // @ C0xFFB2_THING_EXPLOSION_FLUXCAGE +const Thing Thing::_explRebirthStep1(0xFFE4); // @ C0xFFE4_THING_EXPLOSION_REBIRTH_STEP1 +const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIRTH_STEP2 +const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY void DungeonMan::loadDungeonFile() { if (_messages._newGame) @@ -627,7 +640,7 @@ void DungeonMan::loadDungeonFile() { _dunData._squareFirstThings[i].set(dunDataStream.readUint16BE()); if (_messages._newGame) for (uint16 i = 0; i < 300; ++i) - _dunData._squareFirstThings[actualSquareFirstThingCount + i] = Thing::_thingNone; + _dunData._squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none; // TODO: ??? is this - end @@ -688,7 +701,7 @@ void DungeonMan::loadDungeonFile() { if ((thingType == kGroupThingType) || thingType >= kProjectileThingType) _dunData._eventMaximumCount += _fileHeader._thingCounts[thingType]; for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) { - _dunData._thingsData[thingType][thingCount + i][0] = Thing::_thingNone.toUint16(); + _dunData._thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16(); } } } @@ -797,7 +810,7 @@ int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) { Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) { int16 index = getSquareFirstThingIndex(mapX, mapY); if (index == -1) - return Thing::_thingEndOfList; + return Thing::_endOfList; return _dunData._squareFirstThings[index]; } @@ -849,7 +862,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, T0172010_ClosedFakeWall: setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall); - while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType)) { + while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType)) { int16 sideIndex = (thing.getCell() - dir) & 3; if (sideIndex) { if (thing.getType() == kTextstringType) { @@ -868,7 +881,7 @@ T0172010_ClosedFakeWall: thing = getNextThing(thing); } if (squareIsFakeWall && (_currMap._partyPosX != mapX) && (_currMap._partyPosY != mapY)) { - aspectArray[kFirstGroupOrObjectAspect] = Thing::_thingEndOfList.toUint16(); + aspectArray[kFirstGroupOrObjectAspect] = Thing::_endOfList.toUint16(); return; } break; @@ -897,7 +910,7 @@ T0172010_ClosedFakeWall: T0172029_Teleporter: footPrintsAllowed = true; T0172030_Pit: - while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType)) { + while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType)) { if (thing.getType() == kSensorThingType) aspectArray[kFloorOrnOrdAspect] = Sensor(getThingData(thing)).getOrnOrdinal(); thing = getNextThing(thing); @@ -921,7 +934,7 @@ T0172030_Pit: } footPrintsAllowed = true; T0172046_Stairs: - while ((thing != Thing::_thingEndOfList) && (thing.getType() <= kSensorThingType)) + while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType)) thing = getNextThing(thing); T0172049_Footprints: unsigned char scentOrdinal; // see next line comment @@ -1178,7 +1191,7 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { 2, 0, 8 }; - if (thing == Thing::_thingNone) + if (thing == Thing::_none) return 0; switch (thing.getType()) { case kWeaponThingType: @@ -1196,7 +1209,7 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { uint16 weight = 50; Container container(getThingData(thing)); Thing slotThing = container.getSlot(); - while (slotThing != Thing::_thingEndOfList) { + while (slotThing != Thing::_endOfList) { weight += getObjectWeight(slotThing); slotThing = getNextThing(slotThing); } @@ -1240,11 +1253,11 @@ int16 DungeonMan::getObjectInfoIndex(Thing thing) { } void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) { - if (thingToLink == Thing::_thingEndOfList) + if (thingToLink == Thing::_endOfList) return; uint16 *rawObjPtr = getThingData(thingToLink); - *rawObjPtr = Thing::_thingEndOfList.toUint16(); + *rawObjPtr = Thing::_endOfList.toUint16(); if (mapX >= 0) { Square *squarePtr = (Square*)&_currMap._data[mapX][mapY]; @@ -1274,7 +1287,7 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map } Thing thing = getNextThing(thingInList); - while (thing != Thing::_thingEndOfList) { + while (thing != Thing::_endOfList) { thing = getNextThing(thing); thingInList = thing; } @@ -1282,4 +1295,34 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map *rawObjPtr = thingToLink.toUint16(); } +WeaponInfo* DungeonMan::getWeaponInfo(Thing thing) { + Weapon* weapon = (Weapon*)getThingData(thing); + return &gWeaponInfo[weapon->getType()]; +} + +int16 DungeonMan::getProjectileAspect(Thing thing) { + ThingType thingType; + int16 projAspOrd; + WeaponInfo *weaponInfo; + + if ((thingType == thing.getType()) == kExplosionThingType) { + if (thing == Thing::_explFireBall) + return -_vm->indexToOrdinal(kProjectileAspectExplosionFireBall); + if (thing == Thing::_explSlime) + return -_vm->indexToOrdinal(kProjectileAspectExplosionSlime); + if (thing == Thing::_explLightningBolt) + return -_vm->indexToOrdinal(kProjectileAspectExplosionLightningBolt); + if ((thing == Thing::_explPoisonBolt) || (thing == Thing::_explPoisonCloud)) + return -_vm->indexToOrdinal(kProjectileAspectExplosionPoisonBoltCloud); + + return -_vm->indexToOrdinal(kProjectileAspectExplosionDefault); + } else if (thingType == kWeaponThingType) { + weaponInfo = getWeaponInfo(thing); + if (projAspOrd = weaponInfo->getProjectileAspectOrdinal()) + return -projAspOrd; + } + + return gObjectInfo[getObjectInfoIndex(thing)]._objectAspectIndex; +} + } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 9a49fe9e7b..0e17f629d1 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -671,6 +671,8 @@ public: uint16 getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight int16 getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex void linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList + WeaponInfo *getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo + int16 getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect uint32 _rawDunFileDataSize; // @ probably NONE byte *_rawDunFileData; // @ ??? diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index f26930c542..e9abf94809 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -632,7 +632,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) { Thing thing = champ->getSlot((ChampionSlot)slotIndex); - if (thing != Thing::_thingNone) { + if (thing != Thing::_none) { warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList"); } } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 81b53d4ba6..177f9aec8f 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -658,7 +658,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { for (int i = 0; i < 18; i++) _currMapDoorOrnIndices[i] = 0; - _inscriptionThing = Thing::_thingNone; + _inscriptionThing = Thing::_none; _useByteBoxCoordinates = false; } diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 4e3d0d31bc..b3c3a900d2 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -45,9 +45,9 @@ Box gBoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) { _panelContent = kPanelContentFoodWaterPoisoned; for (uint16 i = 0; i < 8; ++i) - _chestSlots[i] = Thing::_thingNone; - _openChest = Thing::_thingNone; - _openChest = Thing::_thingNone; + _chestSlots[i] = Thing::_none; + _openChest = Thing::_none; + _openChest = Thing::_none; } void InventoryMan::toggleInventory(ChampionIndex championIndex) { @@ -199,10 +199,10 @@ void InventoryMan::drawPanel() { _panelContent = kPanelContentScroll; break; default: - thing = Thing::_thingNone; + thing = Thing::_none; break; } - if (thing == Thing::_thingNone) { + if (thing == Thing::_none) { drawPanelFoodWaterPoisoned(); } else { drawPanelObject(thing, false); @@ -213,20 +213,20 @@ void InventoryMan::closeChest() { DungeonMan &dunMan = *_vm->_dungeonMan; bool processFirstChestSlot = true; - if (_openChest == Thing::_thingNone) + if (_openChest == Thing::_none) return; Container *container = (Container*)dunMan.getThingData(_openChest); - _openChest = Thing::_thingNone; - container->getSlot() = Thing::_thingEndOfList; + _openChest = Thing::_none; + container->getSlot() = Thing::_endOfList; Thing prevThing; for (int16 chestSlotIndex = 0; chestSlotIndex < 8; ++chestSlotIndex) { Thing thing = _chestSlots[chestSlotIndex]; - if (thing != Thing::_thingNone) { - _chestSlots[chestSlotIndex] = Thing::_thingNone; // CHANGE8_09_FIX + if (thing != Thing::_none) { + _chestSlots[chestSlotIndex] = Thing::_none; // CHANGE8_09_FIX if (processFirstChestSlot) { processFirstChestSlot = false; - *dunMan.getThingData(thing) = Thing::_thingEndOfList.toUint16(); + *dunMan.getThingData(thing) = Thing::_endOfList.toUint16(); container->getSlot() = prevThing = thing; } else { dunMan.linkThingToList(thing, prevThing, kMapXNotOnASquare, 0); @@ -303,7 +303,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is return; warning("CHANGE8_09_FIX"); - if (_openChest != Thing::_thingNone) + if (_openChest != Thing::_none) closeChest(); // CHANGE8_09_FIX _openChest = thingToOpen; @@ -315,7 +315,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is int16 chestSlotIndex = 0; Thing thing = chest->getSlot(); int16 thingCount = 0; - while (thing != Thing::_thingEndOfList) { + while (thing != Thing::_endOfList) { warning("CHANGE8_08_FIX"); if (++thingCount > 8) break; // CHANGE8_08_FIX, make sure that no more than the first 8 objects in a chest are drawn @@ -326,7 +326,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is } while (chestSlotIndex < 8) { objMan.drawIconInSlotBox(chestSlotIndex + kSlotBoxChestFirstSlot, kIconIndiceNone); - _chestSlots[chestSlotIndex++] = Thing::_thingNone; + _chestSlots[chestSlotIndex++] = Thing::_none; } } diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 7ac9283a17..7da701b6c3 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -43,7 +43,7 @@ LoadgameResponse LoadsaveMan::loadgame() { if (newGame) { _vm->_restartGameAllowed = false; cm._partyChampionCount = 0; - cm._leaderHandObject = Thing::_thingNone; + cm._leaderHandObject = Thing::_none; _vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536); } else { assert(false); diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index d6c09d85e6..a09a33dbf1 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -96,7 +96,7 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) { byte *bitmapIcon = dm._tmpBitmap; Thing thing = champion.getSlot(kChampionSlotActionHand); IconIndice iconIndex; - if (thing == Thing::_thingNone) { + if (thing == Thing::_none) { iconIndex = kIconIndiceActionEmptyHand; } else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) { iconIndex = _vm->_objectMan->getIconIndex(thing); diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 8a833a37c3..1511146d69 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -53,7 +53,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 Thing squareFirstThing; Thing thingBeingProcessed = squareFirstThing = dunMan.getSquareFirstThing(mapX, mapY); ThingType thingType; - while (thingBeingProcessed != Thing::_thingEndOfList) { + while (thingBeingProcessed != Thing::_endOfList) { thingType = thingBeingProcessed.getType(); if (thingType == kSensorThingType) { sensorCountToProcessPerCell[thingBeingProcessed.getCell()]++; @@ -64,7 +64,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 } Thing lastProcessedThing = thingBeingProcessed = squareFirstThing; - while (thingBeingProcessed != Thing::_thingEndOfList) { + while (thingBeingProcessed != Thing::_endOfList) { thingType = thingBeingProcessed.getType(); if (thingType == kSensorThingType) { cell = thingBeingProcessed.getCell(); @@ -101,7 +101,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 if (lastProcessedThing == thingBeingProcessed) break; ((Sensor*)dunMan.getThingData(lastProcessedThing))->setNextThing(sensor->getNextThing()); - sensor->setNextThing(Thing::_thingNone); + sensor->setNextThing(Thing::_none); thingBeingProcessed = lastProcessedThing; } if (!doNotTriggerSensor && (sensorType == kSensorWallOrnClickWithSpecObjRemovedRotateSensors)) { @@ -125,7 +125,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 warning("MISSING CODE: F0273_SENSOR_GetObjectOfTypeInCell"); warning(("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand")); warning("MISSING CODE: F0163_DUNGEON_LinkThingToList"); - leaderHandObject = Thing::_thingNone; + leaderHandObject = Thing::_none; } warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect"); if ((sensorEffect == kSensorEffHold) && !champMan._leaderEmptyHanded) { @@ -138,7 +138,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 if (sensorCountToProcessPerCell[cell]) goto T0275058_ProceedToNextThing; Thing thingOnSquare = dunMan.getSquareFirstThing(mapX, mapY); - if ((objMan.getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_thingNone)) + if ((objMan.getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_none)) goto T0275058_ProceedToNextThing; warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList"); warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand"); @@ -169,12 +169,12 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 (sensorType == kSensorWallOrnClickWithSpecObjRemovedRotateSensors) || (sensorType == kSensorWallOrnClickWithSpecObjRemovedSensor))) { - *((Thing*)dunMan.getThingData(leaderHandObject)) = Thing::_thingNone; + *((Thing*)dunMan.getThingData(leaderHandObject)) = Thing::_none; warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand"); - leaderHandObject = Thing::_thingNone; + leaderHandObject = Thing::_none; } else { warning("MISSING CODE: (leaderHandObject = F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator(sensorData)"); - if (champMan._leaderEmptyHanded && (sensorType == kSensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_thingNone)) { + if (champMan._leaderEmptyHanded && (sensorType == kSensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_none)) { warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand"); } } diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index aed1c13a1d..458f3fd2b3 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -122,7 +122,7 @@ void ObjectMan::loadObjectNames() { } IconIndice ObjectMan::getObjectType(Thing thing) { - if (thing == Thing::_thingNone) + if (thing == Thing::_none) return kIconIndiceNone; int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing); -- cgit v1.2.3 From 5bb19fd2611dd28e6187b4d873de3f754a352b74 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:41:19 +0200 Subject: DM: Add GroupMan, Group, ActiveGroup, F0196_GROUP_InitializeActiveGroups --- engines/dm/TODOs/methodtree.txt | 6 ++- engines/dm/dm.cpp | 7 ++- engines/dm/dm.h | 2 + engines/dm/dungeonman.cpp | 2 +- engines/dm/dungeonman.h | 17 -------- engines/dm/group.cpp | 54 +++++++++++++++++++++++ engines/dm/group.h | 94 +++++++++++++++++++++++++++++++++++++++++ engines/dm/loadsave.cpp | 4 +- engines/dm/module.mk | 1 + 9 files changed, 165 insertions(+), 22 deletions(-) create mode 100644 engines/dm/group.cpp create mode 100644 engines/dm/group.h diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 9f09e9dd8c..ec7229b057 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -9,6 +9,10 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF F0158_DUNGEON_GetWeaponInfo // done M66_PROJECTILE_ASPECT_ORDINAL // done F0176_GROUP_GetCreatureOrdinalInCell + F0145_DUNGEON_GetGroupCells + F0147_DUNGEON_GetGroupDirections + GROUP // done + CreatureType G0017_auc_Graphic562_PaletteChanges_NoChanges G0075_apuc_PaletteChanges_Projectile G0077_B_DoNotDrawFluxcagesDuringEndgame @@ -40,7 +44,7 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF G0370_ps_Events G0375_ps_ActiveGroups OBJECT_ASPECT - GROUP + GROUP // done ACTIVE_GROUP CREATURE_INFO CREATURE_ASPECT diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 2d55c5e8e3..1b2edceb81 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -49,6 +49,7 @@ #include "inventory.h" #include "text.h" #include "movesens.h" +#include "group.h" namespace DM { @@ -93,7 +94,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _inventoryMan = nullptr; _textMan = nullptr; _movsens = nullptr; - + _groupMan = nullptr; _stopWaitingForPlayerInput = false; _gameTimeTicking = false; _restartGameAllowed = false; @@ -122,6 +123,7 @@ DMEngine::~DMEngine() { delete _inventoryMan; delete _textMan; delete _movsens; + delete _groupMan; // clear debug channels DebugMan.clearAllDebugChannels(); @@ -203,7 +205,8 @@ Common::Error DMEngine::run() { _objectMan = new ObjectMan(this); _inventoryMan = new InventoryMan(this); _textMan = new TextMan(this); - _movsens = new MovesensMan(this); + _movsens = new MovesensMan(this); + _groupMan = new GroupMan(this); _displayMan->setUpScreens(320, 200); initializeGame(); // @ F0463_START_InitializeGame_CPSADEF diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 251a0af680..5bbeb4f1ae 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -46,6 +46,7 @@ class ObjectMan; class InventoryMan; class TextMan; class MovesensMan; +class GroupMan; enum direction { @@ -161,6 +162,7 @@ public: InventoryMan *_inventoryMan; TextMan *_textMan; MovesensMan *_movsens; + GroupMan *_groupMan; bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput bool _gameTimeTicking; // @ G0301_B_GameTimeTicking diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 12531b66ea..e513e58f44 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1305,7 +1305,7 @@ int16 DungeonMan::getProjectileAspect(Thing thing) { int16 projAspOrd; WeaponInfo *weaponInfo; - if ((thingType == thing.getType()) == kExplosionThingType) { + if ((thingType = thing.getType()) == kExplosionThingType) { if (thing == Thing::_explFireBall) return -_vm->indexToOrdinal(kProjectileAspectExplosionFireBall); if (thing == Thing::_explSlime) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 0e17f629d1..a4f06ee963 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -326,23 +326,6 @@ public: // some macros missing, i got bored }; // @ SENSOR -class Group { - Thing _nextThing; - Thing _possessionID; - byte _type; - byte _position; - uint16 _health[4]; - uint16 _attributes; -public: - explicit Group(uint16 *rawDat) : _nextThing(rawDat[0]), _possessionID(rawDat[1]), _type(rawDat[2]), - _position(rawDat[3]), _attributes(rawDat[8]) { - _health[0] = rawDat[4]; - _health[1] = rawDat[5]; - _health[2] = rawDat[6]; - _health[3] = rawDat[7]; - } - Thing getNextThing() { return _nextThing; } -}; // @ GROUP enum WeaponType { kWeaponTypeTorch = 2, // @ C02_WEAPON_TORCH diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp new file mode 100644 index 0000000000..645d81fa62 --- /dev/null +++ b/engines/dm/group.cpp @@ -0,0 +1,54 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + +#include "group.h" +#include "dungeonman.h" + + + +namespace DM { + + +GroupMan::GroupMan(DMEngine* vm) : _vm(vm) { + _activeGroups = nullptr; +} + +GroupMan::~GroupMan() { + delete[] _activeGroups; +} + +void GroupMan::initActiveGroups() { + if (_vm->_dungeonMan->_messages._newGame) + _maxActiveGroupCount = 60; + if (_activeGroups) + delete[] _activeGroups; + _activeGroups = new ActiveGroup[_maxActiveGroupCount]; + for (uint16 i = 0; i < _maxActiveGroupCount; ++i) + _activeGroups[i]._groupThingIndex = -1; +} + +} diff --git a/engines/dm/group.h b/engines/dm/group.h new file mode 100644 index 0000000000..9e1300ccde --- /dev/null +++ b/engines/dm/group.h @@ -0,0 +1,94 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + + +#ifndef DM_GROUP_H +#define DM_GROUP_H + +#include "dm.h" + +namespace DM { + +class ActiveGroup { +public: + int _groupThingIndex; + byte _directions; + byte _cells; + byte _lastMoveTime; + byte _delayFleeingFromTarget; + byte _targetMapX; + byte _targetMapY; + byte _priorMapX; + byte _priorMapY; + byte _homeMapX; + byte _homeMapY; + byte _aspect[4]; +}; // @ ACTIVE_GROUP + + +class Group { +public: + Thing _nextThing; + Thing _slot; + byte _type; + byte _cells; + uint16 _health[4]; +private: + uint16 _flags; +public: + explicit Group(uint16 *rawDat) : _nextThing(rawDat[0]), _slot(rawDat[1]), _type(rawDat[2]), + _cells(rawDat[3]), _flags(rawDat[8]) { + _health[0] = rawDat[4]; + _health[1] = rawDat[5]; + _health[2] = rawDat[6]; + _health[3] = rawDat[7]; + } + + byte &getActiveGroupIndex() { return _cells; } + + uint16 getBehaviour() { return _flags & 0xF; } + uint16 getCount() { return (_flags >> 5) & 0x3; } + direction getDir() { return (direction)((_flags >> 8) & 0x3); } + uint16 getDoNotDiscard() { return (_flags >> 10) & 0x1; } +}; // @ GROUP + + +class GroupMan { + DMEngine *_vm; +public: + uint16 _maxActiveGroupCount = 60; // @ G0376_ui_MaximumActiveGroupCount + ActiveGroup *_activeGroups; // @ G0375_ps_ActiveGroups + GroupMan(DMEngine *vm); + ~GroupMan(); + void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups +}; + + + +} + +#endif diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 7da701b6c3..583762c9db 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -28,6 +28,7 @@ #include "loadsave.h" #include "dungeonman.h" #include "champion.h" +#include "group.h" @@ -53,7 +54,8 @@ LoadgameResponse LoadsaveMan::loadgame() { if (newGame) { - warning("MISSING CODE: Timline init, Group init"); + warning("MISSING CODE: Timline init"); + _vm->_groupMan->initActiveGroups(); } else { assert(false); // MISSING CODE: load game diff --git a/engines/dm/module.mk b/engines/dm/module.mk index 28bcaa2a54..721eb43db9 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -36,6 +36,7 @@ MODULE_OBJS := \ dungeonman.o \ eventman.o \ gfx.o \ + group.o \ inventory.o \ loadsave.o \ menus.o \ -- cgit v1.2.3 From 4f394fc301ed9ae087e6cabbf54607ea89629ffa Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 30 Jun 2016 14:54:54 +0200 Subject: DM: Add F0145_DUNGEON_GetGroupCells --- engines/dm/group.cpp | 8 ++++++++ engines/dm/group.h | 1 + 2 files changed, 9 insertions(+) diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 645d81fa62..10edf011a3 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -27,6 +27,7 @@ #include "group.h" #include "dungeonman.h" +#include "champion.h" @@ -51,4 +52,11 @@ void GroupMan::initActiveGroups() { _activeGroups[i]._groupThingIndex = -1; } +uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) { + byte cells; + cells = group->_cells; + if (mapIndex == _vm->_dungeonMan->_currMap._currPartyMapIndex) + cells = _activeGroups[cells]._cells; + return cells; +} } diff --git a/engines/dm/group.h b/engines/dm/group.h index 9e1300ccde..3cd286a132 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -85,6 +85,7 @@ public: GroupMan(DMEngine *vm); ~GroupMan(); void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups + uint16 getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells }; -- cgit v1.2.3 From cd7363f8de93001208f34d43bcb4f656b8514110 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 30 Jun 2016 15:00:42 +0200 Subject: DM: Add F0147_DUNGEON_GetGroupDirections --- engines/dm/TODOs/methodtree.txt | 2 +- engines/dm/group.cpp | 9 +++++++++ engines/dm/group.h | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index ec7229b057..2b9d6bd309 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -9,7 +9,7 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF F0158_DUNGEON_GetWeaponInfo // done M66_PROJECTILE_ASPECT_ORDINAL // done F0176_GROUP_GetCreatureOrdinalInCell - F0145_DUNGEON_GetGroupCells + F0145_DUNGEON_GetGroupCells // done F0147_DUNGEON_GetGroupDirections GROUP // done CreatureType diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 10edf011a3..4a1a7e1180 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -59,4 +59,13 @@ uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) { cells = _activeGroups[cells]._cells; return cells; } + +byte gGroupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_GroupDirections + +uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) { + if (mapIndex == _vm->_dungeonMan->_currMap._currPartyMapIndex) + return _activeGroups[group->getActiveGroupIndex()]._directions; + + return gGroupDirections[group->getDir()]; +} } diff --git a/engines/dm/group.h b/engines/dm/group.h index 3cd286a132..0ad9cbb545 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -36,7 +36,7 @@ namespace DM { class ActiveGroup { public: int _groupThingIndex; - byte _directions; + direction _directions; byte _cells; byte _lastMoveTime; byte _delayFleeingFromTarget; @@ -86,6 +86,7 @@ public: ~GroupMan(); void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups uint16 getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells + uint16 getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections }; -- cgit v1.2.3 From 6d2d839d2721917e2c512511da544a07a9382322 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 30 Jun 2016 15:48:23 +0200 Subject: DM: Add creature masks/types, F0176_GROUP_GetCreatureOrdinalInCell --- engines/dm/TODOs/methodtree.txt | 10 ++++---- engines/dm/dm.cpp | 11 ++++++++- engines/dm/dm.h | 6 +++-- engines/dm/dungeonman.h | 2 ++ engines/dm/gfx.cpp | 8 +++---- engines/dm/gfx.h | 18 +++++++-------- engines/dm/group.cpp | 29 +++++++++++++++++++++++ engines/dm/group.h | 51 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 114 insertions(+), 21 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 2b9d6bd309..894ea89bc5 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -8,11 +8,11 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF F0142_DUNGEON_GetProjectileAspect // done F0158_DUNGEON_GetWeaponInfo // done M66_PROJECTILE_ASPECT_ORDINAL // done - F0176_GROUP_GetCreatureOrdinalInCell + F0176_GROUP_GetCreatureOrdinalInCell // done F0145_DUNGEON_GetGroupCells // done - F0147_DUNGEON_GetGroupDirections + F0147_DUNGEON_GetGroupDirections // done GROUP // done - CreatureType + CreatureType // done G0017_auc_Graphic562_PaletteChanges_NoChanges G0075_apuc_PaletteChanges_Projectile G0077_B_DoNotDrawFluxcagesDuringEndgame @@ -46,8 +46,8 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF OBJECT_ASPECT GROUP // done ACTIVE_GROUP - CREATURE_INFO - CREATURE_ASPECT + CREATURE_INFO // done + CREATURE_ASPECT // done PROJECTILE EXPLOSION FIELD_ASPECT // done diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 1b2edceb81..924988d39d 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -56,6 +56,15 @@ namespace DM { void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); } direction returnOppositeDir(direction dir) { return (direction)((dir + 2) & 3); } + +uint16 returnPrevVal(uint16 val) { + return (direction)((val + 3) & 3); +} + +uint16 returnNextVal(uint16 val) { + return (val + 1) & 0x3; +} + bool isOrientedWestEast(direction dir) { return dir & 1; } uint16 getFlag(uint16 val, uint16 mask) { @@ -205,7 +214,7 @@ Common::Error DMEngine::run() { _objectMan = new ObjectMan(this); _inventoryMan = new InventoryMan(this); _textMan = new TextMan(this); - _movsens = new MovesensMan(this); + _movsens = new MovesensMan(this); _groupMan = new GroupMan(this); _displayMan->setUpScreens(320, 200); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 5bbeb4f1ae..b0d063125b 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -58,8 +58,10 @@ enum direction { void turnDirRight(direction &dir); void turnDirLeft(direction &dir); -direction returnOppositeDir(direction dir); -bool isOrientedWestEast(direction dir); +direction returnOppositeDir(direction dir); // @ M18_OPPOSITE +uint16 returnPrevVal(uint16 val); // @ M19_PREVIOUS +uint16 returnNextVal(uint16 val); // @ M17_NEXT +bool isOrientedWestEast(direction dir); // @ M16_IS_ORIENTED_WEST_EAST uint16 getFlag(uint16 val, uint16 mask); diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index a4f06ee963..ec04aa8c8f 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -177,6 +177,8 @@ enum SquareAspectIndice { kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS }; + + struct CreatureInfo { byte _creatureAspectIndex; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 177f9aec8f..67604f9ef0 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -816,23 +816,23 @@ void DisplayMan::loadGraphics() { int16 creatureFrontBitmapD2PixelCount; _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2); - if (getFlag(creatureGraphicInfo, kCreatureInfoMaskSide)) { + if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskSide)) { _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale16_D3); _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale20_D2); } - if (getFlag(creatureGraphicInfo, kCreatureInfoMaskBack)) { + if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskBack)) { _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount; _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount; } - if (getFlag(creatureGraphicInfo, kCreatureInfoMaskAttack)) { + if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskAttack)) { _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, kScale16_D3); _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, kScale20_D2); } int16 additionalFronGraphicCount; - if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, kCreatureInfoMaskAdditional)) { + if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskAdditional)) { do { _derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront; _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3); diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 2df0ac0a5c..3d5d46ea3c 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -57,15 +57,15 @@ namespace DM { #define kExplosionAspectSmoke 3 // @ C3_EXPLOSION_ASPECT_SMOKE /* Creature info GraphicInfo */ -#define kCreatureInfoMaskAdditional 0x0003 // @ MASK0x0003_ADDITIONAL -#define kCreatureInfoMaskFlipNonAttack 0x0004 // @ MASK0x0004_FLIP_NON_ATTACK -#define kCreatureInfoMaskSide 0x0008 // @ MASK0x0008_SIDE -#define kCreatureInfoMaskBack 0x0010 // @ MASK0x0010_BACK -#define kCreatureInfoMaskAttack 0x0020 // @ MASK0x0020_ATTACK -#define kCreatureInfoMaskSpecialD2Front 0x0080 // @ MASK0x0080_SPECIAL_D2_FRONT -#define kCreatureInfoMaskSpecialD2FrontIsFlipped 0x0100 // @ MASK0x0100_SPECIAL_D2_FRONT_IS_FLIPPED_FRONT -#define kCreatureInfoMaskFlipAttack 0x0200 // @ MASK0x0200_FLIP_ATTACK -#define kCreatureInfoMaskFlipDuringAttack 0x0400 // @ MASK0x0400_FLIP_DURING_ATTACK +#define kCreatureInfoGraphicMaskAdditional 0x0003 // @ MASK0x0003_ADDITIONAL +#define kCreatureInfoGraphicMaskFlipNonAttack 0x0004 // @ MASK0x0004_FLIP_NON_ATTACK +#define kCreatureInfoGraphicMaskSide 0x0008 // @ MASK0x0008_SIDE +#define kCreatureInfoGraphicMaskBack 0x0010 // @ MASK0x0010_BACK +#define kCreatureInfoGraphicMaskAttack 0x0020 // @ MASK0x0020_ATTACK +#define kCreatureInfoGraphicMaskSpecialD2Front 0x0080 // @ MASK0x0080_SPECIAL_D2_FRONT +#define kCreatureInfoGraphicMaskSpecialD2FrontIsFlipped 0x0100 // @ MASK0x0100_SPECIAL_D2_FRONT_IS_FLIPPED_FRONT +#define kCreatureInfoGraphicMaskFlipAttack 0x0200 // @ MASK0x0200_FLIP_ATTACK +#define kCreatureInfoGraphicMaskFlipDuringAttack 0x0400 // @ MASK0x0400_FLIP_DURING_ATTACK class ExplosionAspect { public: diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 4a1a7e1180..b224dff229 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -68,4 +68,33 @@ uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) { return gGroupDirections[group->getDir()]; } + +int16 GroupMan::getCreatureOrdinalInCell(Group* group, uint16 cell) { + uint16 currMapIndex = _vm->_dungeonMan->_currMap._index; + byte groupCells = getGroupCells(group, currMapIndex); + if (groupCells == kCreatureTypeSingleCenteredCreature) + return _vm->indexToOrdinal(0); + + byte creatureIndex = group->getCount(); + if (getFlag(gCreatureInfo[group->_type]._attributes, kMaskCreatureInfo_size) == kMaskCreatureSizeHalf) { + if ((getGroupDirections(group, currMapIndex) & 1) == (cell & 1)) + cell = returnPrevVal(cell); + + do { + byte creatureCell = getCreatureValue(groupCells, creatureIndex); + if (creatureCell == cell || creatureCell == returnNextVal(cell)) + return _vm->indexToOrdinal(creatureIndex); + } while (creatureIndex--); + } else { + do { + if (getCreatureValue(groupCells, creatureIndex) == cell) + return _vm->indexToOrdinal(creatureIndex); + } while (creatureIndex--); + } + return 0; +} + +uint16 GroupMan::getCreatureValue(uint16 groupVal, uint16 creatureIndex) { + return (groupVal >> (creatureIndex << 1)) & 0x3; +} } diff --git a/engines/dm/group.h b/engines/dm/group.h index 0ad9cbb545..49ec009d94 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -33,6 +33,55 @@ namespace DM { +/* Creature types */ +enum CreatureType { + kCreatureTypeGiantScorpionScorpion = 0, // @ C00_CREATURE_GIANT_SCORPION_SCORPION + kCreatureTypeSwampSlimeSlime = 1, // @ C01_CREATURE_SWAMP_SLIME_SLIME_DEVIL + kCreatureTypeGiggler = 2, // @ C02_CREATURE_GIGGLER + kCreatureTypeWizardEyeFlyingEye = 3, // @ C03_CREATURE_WIZARD_EYE_FLYING_EYE + kCreatureTypePainRatHellHound = 4, // @ C04_CREATURE_PAIN_RAT_HELLHOUND + kCreatureTypeRuster = 5, // @ C05_CREATURE_RUSTER + kCreatureTypeScreamer = 6, // @ C06_CREATURE_SCREAMER + kCreatureTypeRockpile = 7, // @ C07_CREATURE_ROCK_ROCKPILE + kCreatureTypeGhostRive = 8, // @ C08_CREATURE_GHOST_RIVE + kCreatureTypeStoneGolem = 9, // @ C09_CREATURE_STONE_GOLEM + kCreatureTypeMummy = 10, // @ C10_CREATURE_MUMMY + kCreatureTypeBlackFlame = 11, // @ C11_CREATURE_BLACK_FLAME + kCreatureTypeSkeleton = 12, // @ C12_CREATURE_SKELETON + kCreatureTypeCouatl = 13, // @ C13_CREATURE_COUATL + kCreatureTypeVexirk = 14, // @ C14_CREATURE_VEXIRK + kCreatureTypeMagnetaWormWorm = 15, // @ C15_CREATURE_MAGENTA_WORM_WORM + kCreatureTypeTrolinAntman = 16, // @ C16_CREATURE_TROLIN_ANTMAN + kCreatureTypeGiantWaspMuncher = 17, // @ C17_CREATURE_GIANT_WASP_MUNCHER + kCreatureTypeAnimatedArmourDethKnight = 18, // @ C18_CREATURE_ANIMATED_ARMOUR_DETH_KNIGHT + kCreatureTypeMaterializerZytaz = 19, // @ C19_CREATURE_MATERIALIZER_ZYTAZ + kCreatureTypeWaterElemental = 20, // @ C20_CREATURE_WATER_ELEMENTAL + kCreatureTypeOitu = 21, // @ C21_CREATURE_OITU + kCreatureTypeDemon = 22, // @ C22_CREATURE_DEMON + kCreatureTypeLordChaos = 23, // @ C23_CREATURE_LORD_CHAOS + kCreatureTypeRedDragon = 24, // @ C24_CREATURE_RED_DRAGON + kCreatureTypeLordOrder = 25, // @ C25_CREATURE_LORD_ORDER + kCreatureTypeGreyLord = 26, // @ C26_CREATURE_GREY_LORD + kCreatureTypeSingleCenteredCreature = 255 // @ C255_SINGLE_CENTERED_CREATURE +}; + +#define kMaskCreatureSizeQuarter 0 // @ C0_SIZE_QUARTER_SQUARE +#define kMaskCreatureSizeHalf 1 // @ C1_SIZE_HALF_SQUARE +#define kMaskCreatureSizeFull 2 // @ C2_SIZE_FULL_SQUARE + +#define kMaskCreatureInfo_size 0x0003 // @ MASK0x0003_SIZE +#define kMaskCreatureInfo_sideAttack 0x0004 // @ MASK0x0004_SIDE_ATTACK +#define kMaskCreatureInfo_preferBackRow 0x0008 // @ MASK0x0008_PREFER_BACK_ROW +#define kMaskCreatureInfo_attackAnyChamp 0x0010 // @ MASK0x0010_ATTACK_ANY_CHAMPION +#define kMaskCreatureInfo_levitation 0x0020 // @ MASK0x0020_LEVITATION +#define kMaskCreatureInfo_nonMaterial 0x0040 // @ MASK0x0040_NON_MATERIAL +#define kMaskCreatureInfo_dropFixedPoss 0x0200 // @ MASK0x0200_DROP_FIXED_POSSESSIONS +#define kMaskCreatureInfo_keepThrownSharpWeapon 0x0400 // @ MASK0x0400_KEEP_THROWN_SHARP_WEAPONS +#define kMaskCreatureInfo_seeInvisible 0x0800 // @ MASK0x0800_SEE_INVISIBLE +#define kMaskCreatureInfo_nightVision 0x1000 // @ MASK0x1000_NIGHT_VISION +#define kMaskCreatureInfo_archenemy 0x2000 // @ MASK0x2000_ARCHENEMY +#define kMaskCreatureInfo_magicmap 0x4000 // @ MASK0x4000_MAGICMAP + class ActiveGroup { public: int _groupThingIndex; @@ -87,6 +136,8 @@ public: void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups uint16 getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells uint16 getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections + int16 getCreatureOrdinalInCell(Group *group, uint16 cell); // @ F0176_GROUP_GetCreatureOrdinalInCell + uint16 getCreatureValue(uint16 groupVal, uint16 creatureIndex); // @ M50_CREATURE_VALUE }; -- cgit v1.2.3 From d312ac086d0a1cd19c784e1fd7752652f8896ad8 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 30 Jun 2016 19:59:35 +0200 Subject: DM: Add dependencies for F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF --- engines/dm/TODOs/methodtree.txt | 55 ++++--------- engines/dm/dm.cpp | 4 + engines/dm/dm.h | 2 + engines/dm/dungeonman.cpp | 6 +- engines/dm/dungeonman.h | 4 +- engines/dm/gfx.cpp | 176 ++++++++++++++++++++++++++++++++++++++++ engines/dm/gfx.h | 11 ++- engines/dm/loadsave.cpp | 3 +- engines/dm/module.mk | 3 +- engines/dm/timeline.cpp | 55 +++++++++++++ engines/dm/timeline.h | 162 ++++++++++++++++++++++++++++++++++++ 11 files changed, 431 insertions(+), 50 deletions(-) create mode 100644 engines/dm/timeline.cpp create mode 100644 engines/dm/timeline.h diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 894ea89bc5..f790d50c6e 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -12,45 +12,22 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF F0145_DUNGEON_GetGroupCells // done F0147_DUNGEON_GetGroupDirections // done GROUP // done - CreatureType // done - G0017_auc_Graphic562_PaletteChanges_NoChanges - G0075_apuc_PaletteChanges_Projectile - G0077_B_DoNotDrawFluxcagesDuringEndgame - G0105_s_Graphic558_Box_ExplosionPattern_D0C - G0163_as_Graphic558_Frame_Walls - G0188_as_Graphic558_FieldAspects - G0209_as_Graphic558_ObjectAspects - G0210_as_Graphic558_ProjectileAspects - G0212_auc_Graphic558_PaletteChanges_Smoke - G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3 - G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2 - G0215_auc_Graphic558_ProjectileScales - G0216_auc_Graphic558_ExplosionBaseScales - G0217_aauc_Graphic558_ObjectPileShiftSetIndices - G0218_aaaauc_Graphic558_ObjectCoordinateSets - G0219_as_Graphic558_CreatureAspects - G0221_auc_Graphic558_PaletteChanges_Creature_D3 - G0222_auc_Graphic558_PaletteChanges_Creature_D2 - G0223_aac_Graphic558_ShiftSets - G0224_aaaauc_Graphic558_CreatureCoordinateSets - G0225_aai_Graphic558_CenteredExplosionCoordinates - G0226_aaai_Graphic558_ExplosionCoordinates - G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates - G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates - G0237_as_Graphic559_ObjectInfo - G0243_as_Graphic559_CreatureInfo - G0291_aauc_DungeonViewClickableBoxes - G0292_aT_PileTopObject - G0370_ps_Events - G0375_ps_ActiveGroups - OBJECT_ASPECT - GROUP // done - ACTIVE_GROUP - CREATURE_INFO // done - CREATURE_ASPECT // done - PROJECTILE - EXPLOSION - FIELD_ASPECT // done + CreatureType // done + G0077_B_DoNotDrawFluxcagesDuringEndgame // done + G0105_s_Graphic558_Box_ExplosionPattern_D0C // one + G0188_as_Graphic558_FieldAspects // done + G0216_auc_Graphic558_ExplosionBaseScales // done + G0217_aauc_Graphic558_ObjectPileShiftSetIndices // done + G0218_aaaauc_Graphic558_ObjectCoordinateSets // done + G0223_aac_Graphic558_ShiftSets // done + G0224_aaaauc_Graphic558_CreatureCoordinateSets // done + G0225_aai_Graphic558_CenteredExplosionCoordinates // done + G0226_aaai_Graphic558_ExplosionCoordinates // done + G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates // done + G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates // done + G0292_aT_PileTopObject // done + G0370_ps_Events // done + diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 924988d39d..66a11250e8 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -50,6 +50,7 @@ #include "text.h" #include "movesens.h" #include "group.h" +#include "timeline.h" namespace DM { @@ -104,6 +105,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _textMan = nullptr; _movsens = nullptr; _groupMan = nullptr; + _timeline = nullptr; _stopWaitingForPlayerInput = false; _gameTimeTicking = false; _restartGameAllowed = false; @@ -133,6 +135,7 @@ DMEngine::~DMEngine() { delete _textMan; delete _movsens; delete _groupMan; + delete _timeline; // clear debug channels DebugMan.clearAllDebugChannels(); @@ -216,6 +219,7 @@ Common::Error DMEngine::run() { _textMan = new TextMan(this); _movsens = new MovesensMan(this); _groupMan = new GroupMan(this); + _timeline = new Timeline(this); _displayMan->setUpScreens(320, 200); initializeGame(); // @ F0463_START_InitializeGame_CPSADEF diff --git a/engines/dm/dm.h b/engines/dm/dm.h index b0d063125b..814b89da4e 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -47,6 +47,7 @@ class InventoryMan; class TextMan; class MovesensMan; class GroupMan; +class Timeline; enum direction { @@ -165,6 +166,7 @@ public: TextMan *_textMan; MovesensMan *_movsens; GroupMan *_groupMan; + Timeline *_timeline; bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput bool _gameTimeTicking; // @ G0301_B_GameTimeTicking diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index e513e58f44..8d5c99bde5 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -29,6 +29,7 @@ #include "common/memstream.h" #include "dungeonman.h" +#include "timeline.h" @@ -369,7 +370,6 @@ void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, in DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) { _dunData._columCount = 0; - _dunData._eventMaximumCount = 0; _dunData._mapsFirstColumnIndex = nullptr; _dunData._columnsCumulativeSquareThingCount = nullptr; @@ -652,7 +652,7 @@ void DungeonMan::loadDungeonFile() { // TODO: ??? what this if (_messages._newGame) - _dunData._eventMaximumCount = 100; + _vm->_timeline->_eventMaxCount = 100; // load things for (uint16 thingType = kDoorThingType; thingType < kThingTypeTotal; ++thingType) { @@ -699,7 +699,7 @@ void DungeonMan::loadDungeonFile() { if (_messages._newGame) { if ((thingType == kGroupThingType) || thingType >= kProjectileThingType) - _dunData._eventMaximumCount += _fileHeader._thingCounts[thingType]; + _vm->_timeline->_eventMaxCount += _fileHeader._thingCounts[thingType]; for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) { _dunData._thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16(); } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index ec04aa8c8f..f3faafdf21 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -589,9 +589,6 @@ struct DungeonData { uint16 **_thingsData[16]; // @ G0284_apuc_ThingData byte ***_mapData; // @ G0279_pppuc_DungeonMapData - - // TODO: ??? is this doing here - uint16 _eventMaximumCount; // @ G0369_ui_EventMaximumCount }; // @ AGGREGATE struct CurrMapData { @@ -676,6 +673,7 @@ public: bool _isFacingViAltar; // @ G0287_B_FacingViAltar bool _isFacingFountain; // @ G0288_B_FacingFountain ElementType _squareAheadElement; // @ G0285_i_SquareAheadElement + Thing _pileTopObject[5]; // @ G0292_aT_PileTopObject }; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 67604f9ef0..4506f3ec36 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -37,6 +37,21 @@ namespace DM { +FieldAspect gFieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects + /* { NativeBitmapRelativeIndex, BaseStartUnitIndex, Transparent color, Mask, ByteWidth, Height, X, BitPlaneWordCount } */ + FieldAspect(0, 63, 0x8A, 0xFF, 0, 0, 0, 64), /* D3C */ + FieldAspect(0, 63, 0x0A, 0x80, 48, 51, 11, 64), /* D3L */ + FieldAspect(0, 63, 0x0A, 0x00, 48, 51, 0, 64), /* D3R */ + FieldAspect(0, 60, 0x8A, 0xFF, 0, 0, 0, 64), /* D2C */ + FieldAspect(0, 63, 0x0A, 0x81, 40, 71, 5, 64), /* D2L */ + FieldAspect(0, 63, 0x0A, 0x01, 40, 71, 0, 64), /* D2R */ + FieldAspect(0, 61, 0x8A, 0xFF, 0, 0, 0, 64), /* D1C */ + FieldAspect(0, 63, 0x0A, 0x82, 32, 111, 0, 64), /* D1L */ + FieldAspect(0, 63, 0x0A, 0x02, 32, 111, 0, 64), /* D1R */ + FieldAspect(0, 59, 0x8A, 0xFF, 0, 0, 0, 64), /* D0C */ + FieldAspect(0, 63, 0x0A, 0x83, 16, 136, 0, 64), /* D0L */ + FieldAspect(0, 63, 0x0A, 0x03, 16, 136, 0, 64)}; /* D0R */ + Box gBoxMovementArrows = Box(224, 319, 124, 168); byte gPalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke @@ -1790,6 +1805,167 @@ int16 DisplayMan::getScaledDimension(int16 dimension, int16 scale) { return (dimension * scale + scale / 2) / 32; } +/* This is the full dungeon view */ +Box gBoxExplosionPattern_D0C = Box(0, 223, 0, 135); // @ G0105_s_Graphic558_Box_ExplosionPattern_D0C + +byte gExplosionBaseScales[5] = { // @ G0216_auc_Graphic558_ExplosionBaseScales + 10,/* D4 */ 16,/* D3 */ 23,/* D2 */ 32,/* D1 */ 32};/* D0 */ + +byte gObjectPileShiftSetIndices[16][2] = { // @ G0217_aauc_Graphic558_ObjectPileShiftSetIndices + /* { X shift index, Y shift index } */ + {2, 5}, + {0, 6}, + {5, 7}, + {3, 0}, + {7, 1}, + {1, 2}, + {6, 3}, + {3, 3}, + {5, 5}, + {2, 6}, + {7, 7}, + {1, 0}, + {3, 1}, + {6, 2}, + {1, 3}, + {5, 3}}; /* 16 pairs of X and Y shift values */ + +byte gObjectCoordinateSets[3][10][5][2] = { // @ G0218_aaaauc_Graphic558_ObjectCoordinateSets + /* { {X, Y }, {X, Y }, {X, Y }, {X, Y }, {X, Y } } */ + {{{0, 0},{0, 0},{125, 72},{95, 72},{112, 64}}, /* D3C */ + {{0, 0},{0, 0},{62, 72},{25, 72},{24, 64}}, /* D3L */ + {{0, 0},{0, 0},{200, 72},{162, 72},{194, 64}}, /* D3R */ + {{92, 78},{132, 78},{136, 86},{88, 86},{112, 74}}, /* D2C */ + {{10, 78},{53, 78},{41, 86},{0, 0},{3, 74}}, /* D2L */ + {{171, 78},{218, 78},{0, 0},{183, 86},{219, 74}}, /* D2R */ + {{83, 96},{141, 96},{148, 111},{76, 111},{112, 94}}, /* D1C */ + {{0, 0},{26, 96},{5, 111},{0, 0},{0, 0}}, /* D1L */ + {{197, 96},{0, 0},{0, 0},{220, 111},{0, 0}}, /* D1R */ + {{66, 131},{158, 131},{0, 0},{0, 0},{0, 0}}}, /* D0C */ + {{{0, 0},{0, 0},{125, 72},{95, 72},{112, 63}}, /* D3C */ + {{0, 0},{0, 0},{62, 72},{25, 72},{24, 63}}, /* D3L */ + {{0, 0},{0, 0},{200, 72},{162, 72},{194, 63}}, /* D3R */ + {{92, 78},{132, 78},{136, 86},{88, 86},{112, 73}}, /* D2C */ + {{10, 78},{53, 78},{41, 86},{0, 0},{3, 73}}, /* D2L */ + {{171, 78},{218, 78},{0, 0},{183, 86},{219, 73}}, /* D2R */ + {{83, 96},{141, 96},{148, 111},{76, 111},{112, 89}}, /* D1C */ + {{0, 0},{26, 96},{5, 111},{0, 0},{0, 0}}, /* D1L */ + {{197, 96},{0, 0},{0, 0},{220, 111},{0, 0}}, /* D1R */ + {{66, 131},{158, 131},{0, 0},{0, 0},{0, 0}}}, /* D0C */ + {{{0, 0},{0, 0},{125, 75},{95, 75},{112, 65}}, /* D3C */ + {{0, 0},{0, 0},{62, 75},{25, 75},{24, 65}}, /* D3L */ + {{0, 0},{0, 0},{200, 75},{162, 75},{194, 65}}, /* D3R */ + {{92, 81},{132, 81},{136, 88},{88, 88},{112, 76}}, /* D2C */ + {{10, 81},{53, 81},{41, 88},{0, 0},{3, 76}}, /* D2L */ + {{171, 81},{218, 81},{0, 0},{183, 88},{219, 76}}, /* D2R */ + {{83, 98},{141, 98},{148, 115},{76, 115},{112, 98}}, /* D1C */ + {{0, 0},{26, 98},{5, 115},{0, 0},{0, 0}}, /* D1L */ + {{197, 98},{0, 0},{0, 0},{220, 115},{0, 0}}, /* D1R */ + {{66, 135},{158, 135},{0, 0},{0, 0},{0, 0}}}}; /* D0C */ + + +int16 gShiftSets[3][8] = { // @ G0223_aac_Graphic558_ShiftSets + {0, 1, 2, 3, 0, -3, -2, -1}, /* D0 Back or D1 Front */ + {0, 1, 1, 2, 0, -2, -1, -1}, /* D1 Back or D2 Front */ + {0, 1, 1, 1, 0, -1, -1, -1}}; /* D2 Back or D3 Front */ + +byte gCreatureCoordinateSets[3][11][5][2] = { // @ G0224_aaaauc_Graphic558_CreatureCoordinateSets + /* { { X, Y }, { X, Y }, { X, Y }, { X, Y }, { X, Y } } */ + {{{95, 70},{127, 70},{129, 75},{93, 75},{111, 72}}, /* D3C */ + {{131, 70},{163, 70},{158, 75},{120, 75},{145, 72}}, /* D3L */ + {{59, 70},{91, 70},{107, 75},{66, 75},{79, 72}}, /* D3R */ + {{92, 81},{131, 81},{132, 90},{91, 90},{111, 85}}, /* D2C */ + {{99, 81},{146, 81},{135, 90},{80, 90},{120, 85}}, /* D2L */ + {{77, 81},{124, 81},{143, 90},{89, 90},{105, 85}}, /* D2R */ + {{83, 103},{141, 103},{148, 119},{76, 119},{109, 111}}, /* D1C */ + {{46, 103},{118, 103},{101, 119},{0, 0},{79, 111}}, /* D1L */ + {{107, 103},{177, 103},{0, 0},{123, 119},{144, 111}}, /* D1R */ + {{0, 0},{67, 135},{0, 0},{0, 0},{0, 0}}, /* D0L */ + {{156, 135},{0, 0},{0, 0},{0, 0},{0, 0}}}, /* D0R */ + {{{94, 75},{128, 75},{111, 70},{111, 72},{111, 75}}, /* D3C */ + {{120, 75},{158, 75},{149, 70},{145, 72},{150, 75}}, /* D3L */ + {{66, 75},{104, 75},{75, 70},{79, 72},{73, 75}}, /* D3R */ + {{91, 90},{132, 90},{111, 83},{111, 85},{111, 90}}, /* D2C */ + {{80, 90},{135, 90},{125, 83},{120, 85},{125, 90}}, /* D2L */ + {{89, 90},{143, 90},{99, 83},{105, 85},{98, 90}}, /* D2R */ + {{81, 119},{142, 119},{111, 105},{111, 111},{111, 119}}, /* D1C */ + {{0, 0},{101, 119},{84, 105},{70, 111},{77, 119}}, /* D1L */ + {{123, 119},{0, 0},{139, 105},{153, 111},{146, 119}}, /* D1R */ + {{0, 0},{83, 130},{57, 121},{47, 126},{57, 130}}, /* D0L */ + {{140, 130},{0, 0},{166, 121},{176, 126},{166, 130}}}, /* D0R */ + {{{95, 59},{127, 59},{129, 61},{93, 61},{111, 60}}, /* D3C */ + {{131, 59},{163, 59},{158, 61},{120, 61},{145, 60}}, /* D3L */ + {{59, 59},{91, 59},{107, 61},{66, 61},{79, 60}}, /* D3R */ + {{92, 65},{131, 65},{132, 67},{91, 67},{111, 66}}, /* D2C */ + {{99, 65},{146, 65},{135, 67},{80, 67},{120, 66}}, /* D2L */ + {{77, 65},{124, 65},{143, 67},{89, 67},{105, 66}}, /* D2R */ + {{83, 79},{141, 79},{148, 85},{76, 85},{111, 81}}, /* D1C */ + {{46, 79},{118, 79},{101, 85},{0, 0},{79, 81}}, /* D1L */ + {{107, 79},{177, 79},{0, 0},{123, 85},{144, 81}}, /* D1R */ + {{0, 0},{67, 96},{0, 0},{0, 0},{0, 0}}, /* D0L */ + {{156, 96},{0, 0},{0, 0},{0, 0},{0, 0}}}}; /* D0R */ + +int16 gExplosionCoordinates[15][2][2] = { // @ G0226_aaai_Graphic558_ExplosionCoordinates + /* { { Front Left X, Front Left Y }, { Front Right X, Front Right Y } } */ + {{100, 47},{122, 47}}, /* D4C */ + {{52, 47},{76, 47}}, /* D4L */ + {{148, 47},{172, 47}}, /* D4R */ + {{95, 50},{127, 50}}, /* D3C */ + {{31, 50},{63, 50}}, /* D3L */ + {{159, 50},{191, 50}}, /* D3R */ + {{92, 53},{131, 53}}, /* D2C */ + {{-3, 53},{46, 53}}, /* D2L */ + {{177, 53},{226, 53}}, /* D2R */ + {{83, 57},{141, 57}}, /* D1C */ + {{-54, 57},{18, 57}}, /* D1L */ + {{207, 57},{277, 57}}, /* D1R */ + {{0, 0},{0, 0}}, /* D0C */ + {{-73, 60},{-33, 60}}, /* D0L */ + {{256, 60},{296, 60}}}; /* D0R */ +int16 gRebirthStep2ExplosionCoordinates[7][3] = { // @ G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates + /* { X, Y, Scale } */ + {113, 57, 12}, /* D3C */ + {24, 57, 12}, /* D3L */ + {195, 57, 12}, /* D3R */ + {111, 63, 16}, /* D2C */ + {12, 63, 16}, /* D2L */ + {213, 63, 16}, /* D2R */ + {112, 76, 24}}; /* D1C */ +int16 gRebirthStep1ExplosionCoordinates[7][3] = { // @ G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates + /* { X, Y, Scale } */ + {112, 53, 15}, /* D3C */ + {24, 53, 15}, /* D3L */ + {194, 53, 15}, /* D3R */ + {112, 59, 20}, /* D2C */ + {15, 59, 20}, /* D2L */ + {208, 59, 20}, /* D2R */ + {112, 70, 32}}; /* D1C */ + +int16 gCenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_CenteredExplosionCoordinates + /* { X, Y } */ + {111, 47}, /* D4C */ + {57, 47}, /* D4L */ + {167, 47}, /* D4R */ + {111, 50}, /* D3C */ + {45, 50}, /* D3L */ + {179, 50}, /* D3R */ + {111, 53}, /* D2C */ + {20, 53}, /* D2L */ + {205, 53}, /* D2R */ + {111, 57}, /* D1C */ + {-30, 57}, /* D1L */ + {253, 57}, /* D1R */ + {111, 60}, /* D0C */ + {-53, 60}, /* D0L */ + {276, 60}}; /* D0R */ + +void DisplayMan::drawObjectsCreaturesProjectilesExplosions(Thing thingParam, direction directionParam, int16 mapXpos, + int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) { + +} + + + bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) { if (_derivedBitmaps == nullptr) { _derivedBitmaps[derivedBitmapIndex] = new byte[_derivedBitmapByteCount[derivedBitmapIndex]]; diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 3d5d46ea3c..07a0806ea4 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -275,14 +275,15 @@ class FieldAspect { public: uint16 _nativeBitmapRelativeIndex; uint16 _baseStartUnitIndex; /* Index of the unit (16 pixels = 8 bytes) in bitmap where blit will start from. A random value of 0 or 1 is added to this base index */ - Color _transparentColor; /* Bit 7: Do not use mask if set, Bits 6-0: Transparent color index. 0xFF = no transparency */ + uint16 _transparentColor; /* Bit 7: Do not use mask if set, Bits 6-0: Transparent color index. 0xFF = no transparency */ byte _mask; /* Bit 7: Flip, Bits 6-0: Mask index. 0xFF = no mask */ uint16 _pixelWidth; uint16 _height; uint16 _xPos; - FieldAspect(uint16 native, uint16 base, Color transparent, byte mask, uint16 byteWidth, uint16 height, uint16 xPos) + uint16 _bitplaneWordCount; + FieldAspect(uint16 native, uint16 base, uint16 transparent, byte mask, uint16 byteWidth, uint16 height, uint16 xPos, uint16 bitplane) : _nativeBitmapRelativeIndex(native), _baseStartUnitIndex(base), _transparentColor(transparent), _mask(mask), - _pixelWidth(byteWidth * 2), _height(height), _xPos(xPos) {} + _pixelWidth(byteWidth * 2), _height(height), _xPos(xPos), _bitplaneWordCount(bitplane) {} }; // @ FIELD_ASPECT @@ -472,6 +473,9 @@ public: int16 getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount int16 getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION + void drawObjectsCreaturesProjectilesExplosions(Thing thingParam, direction directionParam, + int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, + uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices @@ -489,6 +493,7 @@ public: Thing _inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing bool _useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates + bool _doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame bool isDerivedBitmapInCache(int16 derivedBitmapIndex); // @ F0491_CACHE_IsDerivedBitmapInCache byte *getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 583762c9db..463e02dade 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -29,6 +29,7 @@ #include "dungeonman.h" #include "champion.h" #include "group.h" +#include "timeline.h" @@ -54,7 +55,7 @@ LoadgameResponse LoadsaveMan::loadgame() { if (newGame) { - warning("MISSING CODE: Timline init"); + _vm->_timeline->initTimeline(); _vm->_groupMan->initActiveGroups(); } else { assert(false); diff --git a/engines/dm/module.mk b/engines/dm/module.mk index 721eb43db9..a1460ae944 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -42,7 +42,8 @@ MODULE_OBJS := \ menus.o \ movesens.o \ objectman.o \ - text.o + text.o \ + timeline.o MODULE_DIRS += \ engines/dm diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp new file mode 100644 index 0000000000..150c3c2ed6 --- /dev/null +++ b/engines/dm/timeline.cpp @@ -0,0 +1,55 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + +#include "timeline.h" +#include "dungeonman.h" + + +namespace DM { + +Timeline::Timeline(DMEngine* vm) : _vm(vm) { + _events = nullptr; + _timeline = nullptr; +} + +Timeline::~Timeline() { + delete[] _events; + delete[] _timeline; +} + +void Timeline::initTimeline() { + _events = new TimelineEvent[_eventMaxCount]; + _timeline = new uint16[_eventMaxCount]; + if (_vm->_dungeonMan->_messages._newGame) { + for (int16 i = 0; i < _eventMaxCount; ++i) + _events->_type = kTMEventTypeNone; + _eventCount = 0; + _firstUnusedEventIndex = 0; + } +} + +} diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h new file mode 100644 index 0000000000..f773530917 --- /dev/null +++ b/engines/dm/timeline.h @@ -0,0 +1,162 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + +#ifndef DM_TIMELINE_H +#define DM_TIMELINE_H + +#include "dm.h" + +namespace DM { + +/* Event types */ +enum TimelineEventType { +/* Used when a creature in a group was damaged or killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by = 3, Fluxcages */ +kTMEventTypeCreateReactionEvent29DangerOnSquare = 253, // @ CM3_EVENT_CREATE_REACTION_EVENT_29_DANGER_ON_SQUARE +/* Used when a projectile impacts with a creature in a group */ +kTMEventTypeCreateReactionEvent30HitByProjectile = 254, // @ CM2_EVENT_CREATE_REACTION_EVENT_30_HIT_BY_PROJECTILE +/* Used when the party bumps into a group or performs a melee attack */ +kTMEventTypeCreateReactionEvent31ParyIsAdjacent = 255, // @ CM1_EVENT_CREATE_REACTION_EVENT_31_PARTY_IS_ADJACENT +kTMEventTypeNone = 0, // @ C00_EVENT_NONE +kTMEventTypeDoorAnimation = 1, // @ C01_EVENT_DOOR_ANIMATION +kTMEventTypeDoorDestruction = 2, // @ C02_EVENT_DOOR_DESTRUCTION +kTMEventTypeCorridor = 5, // @ C05_EVENT_CORRIDOR +kTMEventTypeWall = 6, // @ C06_EVENT_WALL +kTMEventTypeFakeWall = 7, // @ C07_EVENT_FAKEWALL +kTMEventTypeTeleporter = 8, // @ C08_EVENT_TELEPORTER +kTMEventTypePit = 9, // @ C09_EVENT_PIT +kTMEventTypeDoor = 10, // @ C10_EVENT_DOOR +kTMEventTypeEnableChampionAction = 11, // @ C11_EVENT_ENABLE_CHAMPION_ACTION +kTMEventTypeHideDamageReceived = 12, // @ C12_EVENT_HIDE_DAMAGE_RECEIVED +kTMEventTypeViAltarRebirth = 13, // @ C13_EVENT_VI_ALTAR_REBIRTH +kTMEventTypePlaySound = 20, // @ C20_EVENT_PLAY_SOUND +kTMEventTypeCPSE = 22, // @ C22_EVENT_CPSE +kTMEventTypeRemoveFluxcage = 24, // @ C24_EVENT_REMOVE_FLUXCAGE +kTMEventTypeExplosion = 25, // @ C25_EVENT_EXPLOSION +kTMEventTypeGroupReactionDangerOnSquare = 29, // @ C29_EVENT_GROUP_REACTION_DANGER_ON_SQUARE +kTMEventTypeGroupReacionHitByProjectile = 30, // @ C30_EVENT_GROUP_REACTION_HIT_BY_PROJECTILE +kTMEventTypeGroupReactionPartyIsAdjecent = 31, // @ C31_EVENT_GROUP_REACTION_PARTY_IS_ADJACENT +kTMEventTypeUpdateAspectGroup = 32, // @ C32_EVENT_UPDATE_ASPECT_GROUP +/* Events = 33,-36 and = 38,-41 are used for individual creatures only while the group is attacking the party */ +kTMEventTypeUpdateAspectCreature_0 = 33, // @ C33_EVENT_UPDATE_ASPECT_CREATURE_0 +kTMEventTypeUpdateAspectCreature_1 = 34, // @ C34_EVENT_UPDATE_ASPECT_CREATURE_1 +kTMEventTypeUpdateAspectCreature_2 = 35, // @ C35_EVENT_UPDATE_ASPECT_CREATURE_2 +kTMEventTypeUpdateAspectCreature_3 = 36, // @ C36_EVENT_UPDATE_ASPECT_CREATURE_3 +kTMEventTypeUpdateBehaviourGroup = 37, // @ C37_EVENT_UPDATE_BEHAVIOR_GROUP +kTMEventTypeUpdateBehaviour_0 = 38, // @ C38_EVENT_UPDATE_BEHAVIOR_CREATURE_0 +kTMEventTypeUpdateBehaviour_1 = 39, // @ C39_EVENT_UPDATE_BEHAVIOR_CREATURE_1 +kTMEventTypeUpdateBehaviour_2 = 40, // @ C40_EVENT_UPDATE_BEHAVIOR_CREATURE_2 +kTMEventTypeUpdateBehaviour_3 = 41, // @ C41_EVENT_UPDATE_BEHAVIOR_CREATURE_3 +/* Projectiles created by a champion (by casting a spell, shooting a weapon or throwing an object) or by a creature (by casting a spell) ignore impacts during their first movement otherwise an impact would always occur immediately as these projectiles are created on the champion or creature square */ +kTMEventTypeMoveProjectileIgnoreImpacts = 48, // @ C48_EVENT_MOVE_PROJECTILE_IGNORE_IMPACTS +/* Projectiles created by projectile launcher sensors never ignore impacts as well as all other projectiles after their first movement */ +kTMEventTypeMoveProjectile = 49, // @ C49_EVENT_MOVE_PROJECTILE +kTMEventTypeWatchdoge = 53, // @ C53_EVENT_WATCHDOG +kTMEventTypeMoveGroupSilent = 60, // @ C60_EVENT_MOVE_GROUP_SILENT +kTMEventTypeMoveGroupAudible = 61, // @ C61_EVENT_MOVE_GROUP_AUDIBLE +kTMEventTypeEnableGroupGenerator = 65, // @ C65_EVENT_ENABLE_GROUP_GENERATOR +kTMEventTypeLight = 70, // @ C70_EVENT_LIGHT +kTMEventTypeInvisibility = 71, // @ C71_EVENT_INVISIBILITY +kTMEventTypeChampionShield = 72, // @ C72_EVENT_CHAMPION_SHIELD +kTMEventTypeThievesEye = 73, // @ C73_EVENT_THIEVES_EYE +kTMEventTypePartyShield = 74, // @ C74_EVENT_PARTY_SHIELD +kTMEventTypePoisonChampion = 75, // @ C75_EVENT_POISON_CHAMPION +kTMEventTypeSpellShield = 77, // @ C77_EVENT_SPELLSHIELD +kTMEventTypeFireShield = 78, // @ C78_EVENT_FIRESHIELD +kTMEventTypeFootprints = 79, // @ C79_EVENT_FOOTPRINTS +kTMEventTypeMagicMap_C80 = 80, // @ C80_EVENT_MAGIC_MAP +kTMEventTypeMagicMap_C81 = 81, // @ C81_EVENT_MAGIC_MAP +kTMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP +kTMEventTypeMagicMap_C83 = 83 // @ C83_EVENT_MAGIC_MAP +}; + +class TimelineEvent { +public: + int32 _mapTime; + byte _type; + byte _priority; + + uint16 getTypePriority() { return (_type << 8) + _priority; } + + union B_unionTimelineEvent { + struct { + byte _mapX; + byte _mapY; + } _location; + int16 _attack; + int16 _defense; + int16 _lightPower; + Thing _slot; + int16 _slotOrdinal; + B_unionTimelineEvent() {} + } _B; + + int16 getMapXY() { return (_B._location._mapX << 8) + _B._location._mapY; } + + union C_uionTimelineEvent { + struct { + byte _cell; + byte _effect; + } A; + + class { + uint16 _backing; + public: + uint16 getMapX() { return _backing & 0x1F; } + uint16 getMapY() { return (_backing >> 5) & 0x1F; } + direction getDir() { return (direction)((_backing >> 10) & 0x3); } + uint16 getStepEnergy() { return (_backing >> 12) & 0xF; } + void setMapX(uint16 val) { _backing = (_backing & ~0x1F) | (val & 0x1F); } + void setMapY(uint16 val) { _backing = (_backing & ~(0x1F << 5)) | ((val & 0x1F) << 5); } + void setDir(direction val) { _backing = (_backing & ~(0x3 << 10)) | ((val & 0x3) << 10); } + void setStepEnergy(uint16 val) { _backing = (_backing & ~(0xF << 12)) | ((val & 0xF) << 12); } + } _projectile; + + Thing _slot; + int16 _soundIndex; + byte _ticks; + C_uionTimelineEvent() {} + } _C; +}; // @ EVENT + +class Timeline { + DMEngine *_vm; +public: + uint16 _eventMaxCount; // @ G0369_ui_EventMaximumCount + TimelineEvent *_events; // @ G0370_ps_Events + uint16 _eventCount; // @ G0372_ui_EventCount + uint16 *_timeline; // @ G0371_pui_Timeline + uint16 _firstUnusedEventIndex; // @ G0373_ui_FirstUnusedEventIndex + + Timeline(DMEngine *vm); + ~Timeline(); + void initTimeline(); // @ F0233_TIMELINE_Initialize +}; + + +} + +#endif -- cgit v1.2.3 From bf4ae50e6ba18fdd9c7dedb1e40a467b58fd9ac1 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 1 Jul 2016 13:15:41 +0200 Subject: DM: Add F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF --- engines/dm/dungeonman.h | 17 +- engines/dm/gfx.cpp | 846 +++++++++++++++++++++++++++++++++++++++++++++++- engines/dm/gfx.h | 52 ++- engines/dm/group.h | 4 + 4 files changed, 913 insertions(+), 6 deletions(-) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index f3faafdf21..dcf1659c79 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -468,18 +468,30 @@ public: }; // @ JUNK class Projectile { +public: Thing _nextThing; Thing _object; byte _kineticEnergy; byte _damageEnergy; uint16 _timerIndex; -public: explicit Projectile(uint16 *rawDat) : _nextThing(rawDat[0]), _object(rawDat[1]), _kineticEnergy(rawDat[2]), _damageEnergy(rawDat[3]), _timerIndex(rawDat[4]) {} Thing getNextThing() { return _nextThing; } }; // @ PROJECTILE +#define kExplosionType_Fireball 0 // @ C000_EXPLOSION_FIREBALL +#define kExplosionType_Slime 1 // @ C001_EXPLOSION_SLIME +#define kExplosionType_LightningBolt 2 // @ C002_EXPLOSION_LIGHTNING_BOLT +#define kExplosionType_HarmNonMaterial 3 // @ C003_EXPLOSION_HARM_NON_MATERIAL +#define kExplosionType_OpenDoor 4 // @ C004_EXPLOSION_OPEN_DOOR +#define kExplosionType_PoisonBolt 6 // @ C006_EXPLOSION_POISON_BOLT +#define kExplosionType_PoisonCloud 7 // @ C007_EXPLOSION_POISON_CLOUD +#define kExplosionType_Smoke 40 // @ C040_EXPLOSION_SMOKE +#define kExplosionType_Fluxcage 50 // @ C050_EXPLOSION_FLUXCAGE +#define kExplosionType_RebirthStep1 100 // @ C100_EXPLOSION_REBIRTH_STEP1 +#define kExplosionType_RebirthStep2 101 // @ C101_EXPLOSION_REBIRTH_STEP2 + class Explosion { Thing _nextThing; uint16 _attributes; @@ -487,6 +499,9 @@ public: explicit Explosion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} Thing getNextThing() { return _nextThing; } + uint16 getType() { return _attributes & 0x7F; } + uint16 getAttack() { return (_attributes >> 8) & 0xFF; } + uint16 getCentered() { return (_attributes >> 7) & 0x1; } }; // @ EXPLOSION diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 4506f3ec36..81b7e64423 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -33,6 +33,8 @@ #include "gfx.h" #include "dungeonman.h" +#include "group.h" +#include "timeline.h" namespace DM { @@ -988,7 +990,7 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight void DisplayMan::blitBoxFilledWithMaskedBitmapToScreen(byte* src, byte* mask, byte* tmp, Box& box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, - int16 xPos, int16 yPos, int16 height2, Viewport& viewport) { + int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport& viewport) { blitBoxFilledWithMaskedBitmap(src, _vgaBuffer, mask, tmp, box, lastUnitIndex, firstUnitIndex, _screenWidth, transparent, xPos, yPos, _screenHeight, height2, viewport); } @@ -1959,12 +1961,852 @@ int16 gCenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_Centere {-53, 60}, /* D0L */ {276, 60}}; /* D0R */ -void DisplayMan::drawObjectsCreaturesProjectilesExplosions(Thing thingParam, direction directionParam, int16 mapXpos, +#define kBlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK + +void DisplayMan::cthulhu(Thing thingParam, direction directionParam, int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) { + DungeonMan &dunMan = *_vm->_dungeonMan; + + // AL_0 shared + uint16 &AL_0_creatureIndexRed = *(uint16*)&thingParam; + uint16 &AL_0_creatureGraphicInfoRed = *(uint16*)&thingParam; + uint16 &AL_0_creaturePosX = *(uint16*)&thingParam; + // AL_1 shared + int16 &AL_1_viewSquareExplosionIndex = viewSquareIndex; + // AL_2 shared + int16 L0126_i_Multiple; + int16 &AL_2_viewCell = L0126_i_Multiple; + int16 &AL_2_cellPurpleMan = L0126_i_Multiple; + int16 &AL_2_explosionSize = L0126_i_Multiple; + // AL_4 shared + int16 L0127_i_Multiple; + int16 &AL_4_thingType = L0127_i_Multiple; + int16 &AL_4_nativeBitmapIndex = L0127_i_Multiple; + int16 &AL_4_xPos = L0127_i_Multiple; + int16 &AL_4_groupCells = L0127_i_Multiple; + int16 &AL_4_normalizdByteWidth = L0127_i_Multiple; + int16 &AL_4_yPos = L0127_i_Multiple; + int16 &AL_4_projectileAspect = L0127_i_Multiple; + int16 &AL_4_explosionType = L0127_i_Multiple; + int16 &AL_4_explosionAspectIndex = L0127_i_Multiple; + // AL_6 shared + byte *L0128_puc_Multiple; + byte *&AL_6_bitmapRedBanana = L0128_puc_Multiple; + + ObjectAspect *objectAspect; + uint32 remainingViewCellOrdinalsToProcess; + byte* paletteChanges; + byte* bitmapGreenAnt; + byte* coordinateSet; + int16 derivedBitmapIndex; + + int16 byteWidth; + int16 heightRedEagle; + int16 viewLane; /* The lane (center/left/right) that the specified square is part of */ + int16 cellYellowBear; + int16 paddingPixelCount; + int16 heightGreenGoat; + bool useAlcoveObjectImage; /* C1_TRUE for objects that have a special graphic when drawn in an alcove, like the Chest */ + bool flipHorizontal; + bool drawingGrabbableObject; + Box boxByteGreen; + Thing firstThingToDraw; /* Initialized to thingParam and never changed afterwards. Used as a backup of the specified first object to draw */ + + int16 cellCounter; + uint16 objectShiftIndex; + + uint16 L0150_ui_Multiple; + uint16 &AL_8_shiftSetIndex = L0150_ui_Multiple; + uint16 &AL_8_projectileScaleIndex = L0150_ui_Multiple; + + Thing groupThing; + Group* group; + ActiveGroup* activeGroup; + CreatureInfo* creatureInfo; + CreatureAspect* creatureAspectStruct; + int16 creatureSize; + int16 creatureDirectionDelta; + int16 creatureGraphicInfoGreen; + int16 creatureAspectInt; + int16 creatureIndexGreen; + int16 transparentColor; + int16 sourceByteWidth; + int16 sourceHeight; + int16 creaturePaddingPixelCount; + bool twoHalfSquareCreaturesFrontView; + bool drawingLastBackRowCell; + bool useCreatureSideBitmap; + bool useCreatureBackBitmap; + bool useCreatureSpecialD2FrontBitmap; + bool useCreatureAttackBitmap; + bool useFlippedHorizontallyCreatureFrontImage; + +/* Set to C1_TRUE when the last creature that the function should draw is being drawn. This is used to avoid processing the code to draw creatures for the remaining square cells */ + bool drawCreaturesCompleted; + + int16 doorFrontViewDrawingPass; /* Value 0, 1 or 2 */ + int16 scale; + bool derivedBitmapInCache; + Projectile* projectile; + byte projectileCoordinates[2]; + int16 projectilePosX; + int16 projectileDirection; + int16 projectileAspectType; + int16 projectileBitmapIndexData; + bool doNotScaleWithKineticEnergy; + +/* When true, the code section to draw an object is called (with a goto) to draw the projectile, then the code section goes back to projectile processing with another goto */ + bool drawProjectileAsObject; + + bool sqaureHasProjectile; + uint16 currentViewCellToDraw; + bool projectileFlipVertical; + bool projectileAspectTypeHasBackGraphicAndRotation; + bool flipVertical; + Explosion* explosion; + Explosion* fluxcageExplosion; + int16* explosionCoordinates; + int16 explosionScale; + bool squareHasExplosion; + bool rebirthExplosion; + bool smoke; + FieldAspect fieldAspect; + + + if (thingParam == Thing::_endOfList) + return; + + group = 0; + groupThing = Thing::_none; + drawCreaturesCompleted = sqaureHasProjectile = squareHasExplosion = false; + cellCounter = 0; + firstThingToDraw = thingParam; + if (getFlag(orderedViewCellOrdinals, kCellOrder_DoorFront)) { /* If the function call is to draw objects on a door square viewed from the front */ +/* Two function calls are made in that case to draw objects on both sides of the door frame. +The door and its frame are drawn between the two calls. This value indicates the drawing pass so that +creatures are drawn in the right order and so that Fluxcages are not drawn twice */ + doorFrontViewDrawingPass = (orderedViewCellOrdinals & 0x1) + 1; + orderedViewCellOrdinals >>= 4; /* Remove the first nibble that was used for the door front view pass */ + } else { + doorFrontViewDrawingPass = 0; /* The function call is not to draw objects on a door square viewed from the front */ + } + + bool drawAlcoveObjects = !(remainingViewCellOrdinalsToProcess = orderedViewCellOrdinals); + uint16 viewSquareIndexBackup = viewSquareIndex; + viewLane = (viewSquareIndex + 3) % 3; + + + do { +/* Draw objects */ + if (drawAlcoveObjects) { + AL_2_viewCell = kViewCellAlcove; /* Index of coordinates to draw objects in alcoves */ + cellYellowBear = returnOppositeDir(directionParam); /* Alcove is on the opposite direction of the viewing direction */ + objectShiftIndex = 2; + } else { + AL_2_viewCell = _vm->ordinalToIndex((int16)remainingViewCellOrdinalsToProcess & 0x000F); /* View cell is the index of coordinates to draw object */ + currentViewCellToDraw = AL_2_viewCell; + remainingViewCellOrdinalsToProcess >>= 4; /* Proceed to the next cell ordinal */ + cellCounter++; + cellYellowBear = (AL_2_viewCell + directionParam) % 3; /* Convert view cell to absolute cell */ + thingParam = firstThingToDraw; + viewSquareIndex = viewSquareIndexBackup; /* Restore value as it may have been modified while drawing a creature */ + objectShiftIndex = 0; + } + + objectShiftIndex += (cellYellowBear & 0x0001) << 3; + drawProjectileAsObject = false; + do { + if ((AL_4_thingType = thingParam.getType()) == kGroupThingType) { + groupThing = thingParam; + continue; + } + if (AL_4_thingType == kProjectileThingType) { + sqaureHasProjectile = true; + continue; + } + if (AL_4_thingType == kExplosionThingType) { + squareHasExplosion = true; + continue; + } + + /* Square where objects are visible and object is located on cell being processed */ + if ((viewSquareIndex >= kViewSquare_D3C) && (viewSquareIndex <= kViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { + objectAspect = &(gObjectAspects[gObjectInfo[dunMan.getObjectInfoIndex(thingParam)]._objectAspectIndex]); + AL_4_nativeBitmapIndex = kFirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex; + if (useAlcoveObjectImage = (drawAlcoveObjects && getFlag(objectAspect->_graphicInfo, kObjectAlcoveMask) && !viewLane)) { + AL_4_nativeBitmapIndex++; + } + coordinateSet = gObjectCoordinateSets[objectAspect->_coordinateSet][viewSquareIndex][AL_2_viewCell]; + if (!coordinateSet[1]) /* If object is not visible */ + continue; +T0115015_DrawProjectileAsObject: + flipHorizontal = getFlag(objectAspect->_graphicInfo, kObjectFlipOnRightMask) && + !useAlcoveObjectImage && + ((viewLane == kViewLaneRight) || (!viewLane && ((AL_2_viewCell == kViewCellFrontRight) || (AL_2_viewCell == kViewCellBackRight)))); + /* Flip horizontally if object graphic requires it and is not being drawn in an alcove and the object is + either on the right lane or on the right column of the center lane */ + paddingPixelCount = 0; + + if ((viewSquareIndex == kViewSquare_D0C) || ((viewSquareIndex >= kViewSquare_D1C) && (AL_2_viewCell >= kViewCellBackRight))) { + /* If object is in the center lane (only D0C or D1C with condition above) and is not a projectile */ + drawingGrabbableObject = (!viewLane && !drawProjectileAsObject); + AL_8_shiftSetIndex = kShiftSet_D0BackD1Front; + AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */ + byteWidth = objectAspect->_width; + heightRedEagle = objectAspect->_height; + if (flipHorizontal) { + memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); + flipBitmapHorizontal(_tmpBitmap, byteWidth, heightRedEagle); + AL_6_bitmapRedBanana = _tmpBitmap; + } + } else { + drawingGrabbableObject = false; + derivedBitmapIndex = kDerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex; + if ((viewSquareIndex >= kViewSquare_D1C) || ((viewSquareIndex >= kViewSquare_D2C) && (AL_2_viewCell >= kViewCellBackRight))) { + derivedBitmapIndex++; + AL_8_shiftSetIndex = kShiftSet_D1BackD2Front; + byteWidth = getScaledDimension(objectAspect->_width, kScale20_D2); + heightRedEagle = getScaledDimension(objectAspect->_height, kScale20_D2); + paletteChanges = gPalChangesFloorOrn_D2; + } else { + AL_8_shiftSetIndex = kShiftSet_D2BackD3Front; + byteWidth = getScaledDimension(objectAspect->_width, kScale16_D3); + heightRedEagle = getScaledDimension(objectAspect->_height, kScale16_D3); + paletteChanges = gPalChangesFloorOrn_D3; + } + if (flipHorizontal) { + derivedBitmapIndex += 2; + paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; + } else if (useAlcoveObjectImage) { + derivedBitmapIndex += 4; + } + + if (isDerivedBitmapInCache(derivedBitmapIndex)) { + AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); + } else { + bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex); + blitToBitmapShrinkWithPalChange(bitmapGreenAnt, objectAspect->_width, objectAspect->_height, AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex), + byteWidth, heightRedEagle, paletteChanges); + if (flipHorizontal) { + flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); + } + warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); + } + } + AL_4_xPos = coordinateSet[0]; + boxByteGreen._y2 = coordinateSet[1] + 1; + if (!drawProjectileAsObject) { /* If drawing an object that is not a projectile */ + AL_4_xPos += gShiftSets[AL_8_shiftSetIndex][gObjectPileShiftSetIndices[objectShiftIndex][0]]; + boxByteGreen._y2 += gShiftSets[AL_8_shiftSetIndex][gObjectPileShiftSetIndices[objectShiftIndex][1]]; + objectShiftIndex++; /* The next object drawn will use the next shift values */ + if (drawAlcoveObjects) { + if (objectShiftIndex >= 14) { + objectShiftIndex = 2; + } + } else { + objectShiftIndex &= 0x000F; + } + } + boxByteGreen._y1 = boxByteGreen._y2 - (heightRedEagle - 1) - 1; + if (boxByteGreen._y2 > 136) { + boxByteGreen._y2 = 136; + } + boxByteGreen._x2 = MIN(224, AL_4_xPos + byteWidth); + if (boxByteGreen._x1 = MAX(0, AL_4_xPos - byteWidth + 1)) { + if (flipHorizontal) { + AL_4_xPos = paddingPixelCount; + } else { + AL_4_xPos = 0; + } + } else { + AL_4_xPos = byteWidth - AL_4_xPos - 1; + } + + if (drawingGrabbableObject) { + bitmapGreenAnt = AL_6_bitmapRedBanana; + Box *AL_6_boxPtrRed = &dunMan._dungeonViewClickableBoxes[AL_2_viewCell]; + if (AL_6_boxPtrRed->_x1 == 255) { /* If the grabbable object is the first */ + *AL_6_boxPtrRed = boxByteGreen; + + if ((heightGreenGoat = AL_6_boxPtrRed->_y2 - AL_6_boxPtrRed->_y1) < 15) { /* If the box is too small then enlarge it a little */ + heightGreenGoat = heightGreenGoat >> 1; + AL_6_boxPtrRed->_y1 += heightGreenGoat - 7; + if (heightGreenGoat < 4) { + AL_6_boxPtrRed->_y2 -= heightGreenGoat - 3; + } + } + } else { /* If there are several grabbable objects then enlarge the box so it includes all objects */ + AL_6_boxPtrRed->_x1 = MIN(AL_6_boxPtrRed->_x1, boxByteGreen._x1); + AL_6_boxPtrRed->_x2 = MIN(AL_6_boxPtrRed->_x2, boxByteGreen._x2); + AL_6_boxPtrRed->_y1 = MIN(AL_6_boxPtrRed->_y1, boxByteGreen._y1); + AL_6_boxPtrRed->_y2 = MIN(AL_6_boxPtrRed->_y2, boxByteGreen._y2); + } + AL_6_bitmapRedBanana = bitmapGreenAnt; + dunMan._pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */ + } + blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, kColorFlesh, gDungeonViewport); + + if (drawProjectileAsObject) + goto T0115171_BackFromT0115015_DrawProjectileAsObject; + } + } while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList); + if (AL_2_viewCell == kViewCellAlcove) + break; /* End of processing when drawing objects in an alcove */ + if (viewSquareIndex < kViewSquare_D3C) + break; /* End of processing if square is too far away at D4 */ + /* Draw creatures */ + + /* If (draw cell on the back row or second cell being processed) and (no more cells to draw or next cell to draw is a cell on the front row) */ + drawingLastBackRowCell = ((AL_2_viewCell <= kViewCellFrontRight) || (cellCounter == 1)) + && (!remainingViewCellOrdinalsToProcess || ((remainingViewCellOrdinalsToProcess & 0x0000000F) >= 3)); + + if ((groupThing == Thing::_none) || drawCreaturesCompleted) + goto T0115129_DrawProjectiles; /* Skip code to draw creatures */ + if (group == nullptr) { /* If all creature data and info has not already been gathered */ + group = (Group*)dunMan.getThingData(groupThing); + activeGroup = &_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()]; + creatureInfo = &gCreatureInfo[group->_type]; + creatureAspectStruct = &gCreatureAspects[creatureInfo->_creatureAspectIndex]; + creatureSize = getFlag(creatureInfo->_attributes, kMaskCreatureInfo_size); + creatureGraphicInfoGreen = creatureInfo->_graphicInfo; + } + objectAspect = (ObjectAspect*)creatureAspectStruct; + if (AL_0_creatureIndexRed = _vm->_groupMan->getCreatureOrdinalInCell(group, cellYellowBear)) { /* If there is a creature on the cell being processed */ + AL_0_creatureIndexRed--; /* Convert ordinal to index */ + creatureIndexGreen = AL_0_creatureIndexRed; + } else if (creatureSize == kMaskCreatureSizeHalf) { + AL_0_creatureIndexRed = 0; + creatureIndexGreen = -1; + } else { + goto T0115129_DrawProjectiles; /* No creature to draw at cell, skip to projectiles */ + } + + creatureDirectionDelta = (directionParam - _vm->_groupMan->getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed)) % 3; + twoHalfSquareCreaturesFrontView = false; + if ((AL_4_groupCells = activeGroup->_cells) == kCreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */ + if (remainingViewCellOrdinalsToProcess || (doorFrontViewDrawingPass == 1)) +/* Do not draw a single centered creature now, wait until second pass (for a front view door) + or until all cells have been drawn so the creature is drawn over all the objects on the floor */ + goto T0115129_DrawProjectiles; + drawCreaturesCompleted = true; + if ((creatureSize == kMaskCreatureSizeHalf) && (creatureDirectionDelta & 0x0001)) { /* Side view of half square creature */ + AL_2_viewCell = kHalfSizedViewCell_CenterColumn; + } else { + AL_2_viewCell = kHalfSizedViewCell_FrontRow; + } + } else if ((creatureSize == kMaskCreatureSizeHalf) && (drawingLastBackRowCell || !remainingViewCellOrdinalsToProcess || (creatureIndexGreen < 0))) { + if (drawingLastBackRowCell && (doorFrontViewDrawingPass != 2)) { + if ((creatureIndexGreen >= 0) && (creatureDirectionDelta & 0x0001)) { + AL_2_viewCell = kHalfSizedViewCell_BackRow; /* Side view of a half square creature on the back row. Drawn during pass 1 for a door square */ + } else { + goto T0115129_DrawProjectiles; + } + } else if ((doorFrontViewDrawingPass != 1) && !remainingViewCellOrdinalsToProcess) { + if (creatureDirectionDelta & 0x0001) { + if (creatureIndexGreen >= 0) { + AL_2_viewCell = kHalfSizedViewCell_FrontRow; /* Side view of a half square creature on the front row. Drawn during pass 2 for a door square */ + } else { + goto T0115129_DrawProjectiles; + } + } else { + drawCreaturesCompleted = true; + if (creatureIndexGreen < 0) { + creatureIndexGreen = 0; + } + twoHalfSquareCreaturesFrontView = group->getCount(); + if (((AL_4_groupCells = _vm->_groupMan->getCreatureValue(AL_4_groupCells, AL_0_creatureIndexRed)) == directionParam) + || (AL_4_groupCells == returnPrevVal(directionParam))) { + AL_2_viewCell = kHalfSizedViewCell_LeftColumn; + } else { + AL_2_viewCell = kHalfSizedViewCell_RightColumn; + } + } + } else { + goto T0115129_DrawProjectiles; + } + + } else if (creatureSize != kMaskCreatureSizeQuarter) + goto T0115129_DrawProjectiles; + + + creatureAspectInt = activeGroup->_aspect[creatureIndexGreen]; + if (viewSquareIndex > kViewSquare_D0C) { + viewSquareIndex--; + } +T0115077_DrawSecondHalfSquareCreature: + coordinateSet = gCreatureCoordinateSets[((CreatureAspect*)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell]; + if (!coordinateSet[1]) + goto T0115126_CreatureNotVisible; + AL_0_creatureGraphicInfoRed = creatureGraphicInfoGreen; + AL_4_nativeBitmapIndex = kFirstCreatureGraphicIndice + ((CreatureAspect*)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */ + derivedBitmapIndex = ((CreatureAspect*)objectAspect)->_firstDerivedBitmapIndex; + if (useCreatureSideBitmap = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide) && (creatureDirectionDelta & 0x0001)) { + useCreatureAttackBitmap = useFlippedHorizontallyCreatureFrontImage = useCreatureBackBitmap = false; + AL_4_nativeBitmapIndex++; /* Skip the front image. Side image is right after the front image */ + derivedBitmapIndex += 2; + sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthSide; + sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightSide; + } else { + useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0); + if (useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupIsAttacking) + && getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskAttack)) { + + useFlippedHorizontallyCreatureFrontImage = false; + sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthAttack; + sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightAttack; + AL_4_nativeBitmapIndex++; /* Skip the front image */ + derivedBitmapIndex += 2; + if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide)) { + AL_4_nativeBitmapIndex++; /* If the creature has a side image, it preceeds the attack image */ + derivedBitmapIndex += 2; + } + if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskBack)) { + AL_4_nativeBitmapIndex++; /* If the creature has a back image, it preceeds the attack image */ + derivedBitmapIndex += 2; + } + } else { + sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthFront; + sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightFront; + if (useCreatureBackBitmap) { + useFlippedHorizontallyCreatureFrontImage = false; + if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide)) { + AL_4_nativeBitmapIndex += 2; /* If the creature has a side image, it preceeds the back image */ + derivedBitmapIndex += 4; + } else { + AL_4_nativeBitmapIndex++; /* If the creature does not have a side image, the back image follows the front image */ + derivedBitmapIndex += 2; + } + } else { + if (useFlippedHorizontallyCreatureFrontImage = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskFlipNonAttack) + && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) { + derivedBitmapIndex += 2; + if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide)) { + derivedBitmapIndex += 2; + } + if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskBack)) { + derivedBitmapIndex += 2; + } + if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskAttack)) { + derivedBitmapIndex += 2; + } + } + } + } + } + if (viewSquareIndex >= kViewSquare_D1C) { /* Creature is on D1 */ + creaturePaddingPixelCount = 0; + AL_8_shiftSetIndex = kShiftSet_D0BackD1Front; + transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour(); + if (useCreatureSideBitmap) { + AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); + if (creatureDirectionDelta == 1) { + memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); + flipBitmapHorizontal(_tmpBitmap, byteWidth, heightRedEagle); + AL_6_bitmapRedBanana = _tmpBitmap; + } + } else { + if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) { + AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); + if (useCreatureAttackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) { + memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); + flipBitmapHorizontal(_tmpBitmap, byteWidth, heightRedEagle); + AL_6_bitmapRedBanana = _tmpBitmap; + } + } else { /* Use first additional derived graphic: front D1 */ + if (isDerivedBitmapInCache(derivedBitmapIndex)) { /* If derived graphic is already in memory */ + AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); + } else { + bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex); + if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskFlipNonAttack)) { + AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); + memcpy(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * heightRedEagle * sizeof(byte)); + flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); + } + warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); + } + } + } + } else { /* Creature is on D2 or D3 */ + if (useFlippedHorizontallyCreatureFrontImage) { + derivedBitmapIndex++; /* Skip front D1 image in additional graphics */ + } + if (viewSquareIndex >= kViewSquare_D2C) { /* Creature is on D2 */ + derivedBitmapIndex++; /* Skip front D3 image in additional graphics */ + AL_8_shiftSetIndex = kShiftSet_D1BackD2Front; + useCreatureSpecialD2FrontBitmap = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSpecialD2Front) + && !useCreatureSideBitmap && !useCreatureBackBitmap && !useCreatureAttackBitmap; + paletteChanges = gPalChangesCreature_D2; + scale = kScale20_D2; + } else { /* Creature is on D3 */ + AL_8_shiftSetIndex = kShiftSet_D2BackD3Front; + useCreatureSpecialD2FrontBitmap = false; + paletteChanges = gPalChangesCreature_D3; + scale = kScale16_D3; + } + byteWidth = getScaledDimension(sourceByteWidth, scale); + heightRedEagle = getScaledDimension(sourceHeight, scale); + transparentColor = paletteChanges[((CreatureAspect*)objectAspect)->getTranspColour()] / 10; + if (derivedBitmapInCache = isDerivedBitmapInCache(derivedBitmapIndex)) { + AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); + } else { + bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex); + AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); + blitToBitmapShrinkWithPalChange(bitmapGreenAnt, sourceByteWidth, sourceHeight, AL_6_bitmapRedBanana, byteWidth, heightRedEagle, paletteChanges); + warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); + } + if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */ + (useCreatureAttackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) || + (useCreatureSpecialD2FrontBitmap && getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSpecialD2FrontIsFlipped)) || + (useFlippedHorizontallyCreatureFrontImage && getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskFlipNonAttack))) { /* If the graphic should be flipped */ + if (!useFlippedHorizontallyCreatureFrontImage || !derivedBitmapInCache) { + AL_4_normalizdByteWidth = byteWidth; + warning("SUPER WARNING: we might need getNormalizedByteWidthM77"); + if (!useFlippedHorizontallyCreatureFrontImage) { + memcpy(_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte)); + AL_6_bitmapRedBanana = _tmpBitmap; + } + flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); + } + creaturePaddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; + } else { + creaturePaddingPixelCount = 0; + } + } + AL_4_yPos = coordinateSet[1]; + AL_4_yPos += gShiftSets[AL_8_shiftSetIndex][getVerticalOffsetM23(creatureAspectInt)]; + boxByteGreen._y2 = MIN(AL_4_yPos, (int16)135) + 1; + boxByteGreen._y1 = MIN(0, AL_4_yPos - (heightRedEagle - 1)); + AL_4_xPos = coordinateSet[0]; + AL_4_xPos += gShiftSets[AL_8_shiftSetIndex][getHorizontalOffsetM22(creatureAspectInt)]; + if (viewLane == kViewLaneLeft) { + AL_4_xPos -= 100; + } else { + if (viewLane) { /* Lane right */ + AL_4_xPos += 100; + } + } + if (boxByteGreen._x2 = 1 + MIN(MAX(0, AL_4_xPos + byteWidth), 223) <= 1) + goto T0115126_CreatureNotVisible; + if (boxByteGreen._x1 = MIN(MAX(0, AL_4_xPos - byteWidth + 1), 223)) { + if (boxByteGreen._x1 == 223) + goto T0115126_CreatureNotVisible; + AL_0_creaturePosX = creaturePaddingPixelCount; + } else { + AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1); + } + warning("SUPER WARNINIG: we might nee noralized with on byteWidth"); + blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, boxByteGreen, (Color)transparentColor, gDungeonViewport); + +T0115126_CreatureNotVisible: + if (twoHalfSquareCreaturesFrontView) { + twoHalfSquareCreaturesFrontView = false; + creatureAspectInt = activeGroup->_aspect[!creatureIndexGreen]; /* Aspect of the other creature in the pair */ + if (AL_2_viewCell == kHalfSizedViewCell_RightColumn) { + AL_2_viewCell = kHalfSizedViewCell_LeftColumn; + } else { + AL_2_viewCell = kHalfSizedViewCell_RightColumn; + } + goto T0115077_DrawSecondHalfSquareCreature; + } + /* Draw projectiles */ +T0115129_DrawProjectiles: + if (!sqaureHasProjectile + || ((viewSquareIndex = viewSquareIndexBackup) > kViewSquare_D0C) +/* If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn */ + || (!(projectilePosX = gObjectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0]))) + continue; + thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */ + + do { + if ((thingParam.getType() == kProjectileThingType) && (thingParam.getCell() == cellYellowBear)) { + projectile = (Projectile*)dunMan.getThingData(thingParam); + if ((AL_4_projectileAspect = dunMan.getProjectileAspect(projectile->_object)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */ + objectAspect = (ObjectAspect*)&gProjectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)]; + AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + kFirstProjectileGraphicIndice; + projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, kProjectileAspectTypeMask); + if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, kProjectileScaleWithKineticEnergyMask)) + || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == kViewSquare_D0C)) { + scale = 0; /* Use native bitmap without resizing */ + byteWidth = ((ProjectileAspect*)objectAspect)->_width; + heightRedEagle = ((ProjectileAspect*)objectAspect)->_height; + } else { + AL_8_projectileScaleIndex = ((viewSquareIndex / 3) << 1) + (AL_2_viewCell >> 1); + scale = gProjectileScales[AL_8_projectileScaleIndex]; + if (!doNotScaleWithKineticEnergy) { + scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8; + } + byteWidth = getScaledDimension(((ProjectileAspect*)objectAspect)->_width, scale); + heightRedEagle = getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale); + } + if (projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == kProjectileAspectHasBackGraphicRotation)) { + projectileFlipVertical = ((mapXpos + mapYpos) & 0x0001); + } + if (projectileAspectType == kProjectileAspectHasNone) { + projectileBitmapIndexData = 0; + flipVertical = flipHorizontal = false; + } else { + if (isOrientedWestEast((direction)(projectileDirection = _vm->_timeline->_events[projectile->_timerIndex]._C._projectile.getDir())) + != isOrientedWestEast(directionParam)) { + if (projectileAspectType == kProjectileAspectHasRotation) { + projectileBitmapIndexData = 1; + } else { + projectileBitmapIndexData = 2; + } + if (projectileAspectTypeHasBackGraphicAndRotation) { + flipHorizontal = !AL_2_viewCell || (AL_2_viewCell == kViewCellBackLeft); + if (!(flipVertical = projectileFlipVertical)) { + flipHorizontal = !flipHorizontal; + } + } else { + flipVertical = false; + flipHorizontal = (returnNextVal(directionParam) == projectileDirection); + } + } else { +/* If the projectile does not have a back graphic or has one but is not seen from the back or if it has a back graphic and rotation and should be flipped vertically */ + if ((projectileAspectType >= kProjectileAspectHasRotation) + || ((projectileAspectType == kProjectileAspectBackGraphic) + && (projectileDirection != directionParam)) || (projectileAspectTypeHasBackGraphicAndRotation && projectileFlipVertical)) { + projectileBitmapIndexData = 0; + } else { + projectileBitmapIndexData = 1; + } + flipVertical = projectileAspectTypeHasBackGraphicAndRotation && (AL_2_viewCell < kViewCellBackRight); + flipHorizontal = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, kProjectileSideMask) + && !((viewLane == kViewLaneRight) || (!viewLane && ((AL_2_viewCell == kViewCellFrontRight) || (AL_2_viewCell == kViewCellBackRight)))); + } + } + AL_4_nativeBitmapIndex += projectileBitmapIndexData; + paddingPixelCount = 0; + if (!scale) { + AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); + } else { + if (flipHorizontal) { + paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; + } + derivedBitmapIndex = kDerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6); + if (doNotScaleWithKineticEnergy && isDerivedBitmapInCache(derivedBitmapIndex) + AL_8_projectileScaleIndex) { + AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); + } else { + bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex); + if (doNotScaleWithKineticEnergy) { + AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); + } else { + AL_6_bitmapRedBanana = _tmpBitmap; + } + blitToBitmapShrinkWithPalChange(bitmapGreenAnt, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, + AL_6_bitmapRedBanana, byteWidth, heightRedEagle, _palChangesProjectile[AL_8_projectileScaleIndex >> 1]); + if (doNotScaleWithKineticEnergy) { + warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap"); + } + } + } + if (flipHorizontal || flipVertical) { + warning("might need noralized bytewidth"); + AL_4_normalizdByteWidth = byteWidth; + if (AL_6_bitmapRedBanana != _tmpBitmap) { + memcpy(_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte)); + AL_6_bitmapRedBanana = _tmpBitmap; + } + if (flipVertical) { + flipBitmapVertical(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); + } + if (flipHorizontal) { + flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); + } + } + boxByteGreen._y2 = (heightRedEagle >> 1) + 47 + 1; + boxByteGreen._y1 = 47 - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001); + boxByteGreen._x2 = MIN(223, projectilePosX + byteWidth) + 1; + if (boxByteGreen._x1 = MAX(0, projectilePosX - byteWidth + 1)) { + if (flipHorizontal) { + AL_4_xPos = paddingPixelCount; + } else { + AL_4_xPos = 0; + } + } else { +/* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap +is cropped because it is only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and +the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part of the bitmap is drawn on +screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */ + AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1)); + } + blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, kColorFlesh, gDungeonViewport); + } else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */ + useAlcoveObjectImage = false; + projectileCoordinates[0] = projectilePosX; + projectileCoordinates[1] = 47; + coordinateSet = projectileCoordinates; + objectAspect = &gObjectAspects[AL_4_projectileAspect]; + AL_4_nativeBitmapIndex = objectAspect->_firstNativeBitmapRelativeIndex + kFirstObjectGraphicIndice; + drawProjectileAsObject = true; +/* Go to code section to draw an object. Once completed, it jumps back to T0115171_BackFromT0115015_DrawProjectileAsObject below */ + goto T0115015_DrawProjectileAsObject; + } + } +T0115171_BackFromT0115015_DrawProjectileAsObject:; + } while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList); + + } while (remainingViewCellOrdinalsToProcess); + + + /* Draw explosions */ + if (!squareHasExplosion) + return; + fluxcageExplosion = 0; + AL_1_viewSquareExplosionIndex = viewSquareIndexBackup + 3; /* Convert square index to square index for explosions */ + uint16 explosionScaleIndex = AL_1_viewSquareExplosionIndex / 3; + thingParam = firstThingToDraw; /* Restart processing list of things from the beginning. The next loop draws only explosion things among the list */ + do { + if (thingParam.getType() == kExplosionThingType) { + AL_2_cellPurpleMan = thingParam.getCell(); + explosion = (Explosion*)dunMan.getThingData(thingParam); + if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= kExplosionType_RebirthStep1)) + && ((AL_1_viewSquareExplosionIndex < kViewSquare_D3C_Explosion) + || (AL_1_viewSquareExplosionIndex > kViewSquare_D1C_Explosion) + || (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */ + continue; + smoke = false; + if ((AL_4_explosionType == kExplosionType_Fireball) || (AL_4_explosionType == kExplosionType_LightningBolt) || (AL_4_explosionType == kExplosionType_RebirthStep2)) { + AL_4_explosionAspectIndex = kExplosionAspectFire; + } else { + if ((AL_4_explosionType == kExplosionType_PoisonBolt) || (AL_4_explosionType == kExplosionType_PoisonCloud)) { + AL_4_explosionAspectIndex = kExplosionAspectPoison; + } else { + if (AL_4_explosionType == kExplosionType_Smoke) { + smoke = true; + AL_4_explosionAspectIndex = kExplosionAspectSmoke; + } else { + if (AL_4_explosionType == kExplosionType_RebirthStep1) { + objectAspect = (ObjectAspect*)&gProjectileAspect[_vm->ordinalToIndex(-dunMan.getProjectileAspect(Thing::_explLightningBolt))]; + AL_6_bitmapRedBanana = getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (kFirstProjectileGraphicIndice + 1)); + explosionCoordinates = gRebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3]; + byteWidth = getScaledDimension((((ProjectileAspect*)objectAspect)->_width), explosionCoordinates[2]); + heightRedEagle = getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]); + if (AL_1_viewSquareExplosionIndex != kViewSquare_D1C_Explosion) { + blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, + ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, _tmpBitmap, + byteWidth, heightRedEagle, gPalChangesNoChanges); + AL_6_bitmapRedBanana = _tmpBitmap; + } + goto T0115200_DrawExplosion; + } + if (AL_4_explosionType == kExplosionType_Fluxcage) { + if (AL_1_viewSquareExplosionIndex >= kViewSquare_D3L_Explosion) { + fluxcageExplosion = explosion; + } + continue; + } + AL_4_explosionAspectIndex = kExplosionAspectSpell; + } + } + } + if (AL_1_viewSquareExplosionIndex == kViewSquare_D0C_Explosion) { + if (smoke) { + AL_4_explosionAspectIndex--; /* Smoke uses the same graphics as Poison Cloud, but with palette changes */ + } + AL_4_explosionAspectIndex = AL_4_explosionAspectIndex * 3; /* 3 graphics per explosion pattern */ + if (AL_2_explosionSize = (explosion->getAttack() >> 5)) { + AL_4_explosionAspectIndex++; /* Use second graphic in the pattern for medium explosion attack */ + if (AL_2_explosionSize > 3) { + AL_4_explosionAspectIndex++; /* Use third graphic in the pattern for large explosion attack */ + } + } + warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache"); + AL_6_bitmapRedBanana = getBitmap(AL_4_explosionAspectIndex + kFirstExplosionPatternGraphicIndice); + if (smoke) { + blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _tmpBitmap, 48, 32, gPalChangeSmoke); + AL_6_bitmapRedBanana = _tmpBitmap; + } + blitBoxFilledWithMaskedBitmapToScreen(AL_6_bitmapRedBanana, nullptr, getDerivedBitmap(kDerivedBitmapViewport), gBoxExplosionPattern_D0C, + _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64), + 224, (Color)(kBlitDoNotUseMask | kColorFlesh), 0, 0, 136, 93); + warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); + warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); + } else { + if (rebirthExplosion) { + explosionCoordinates = gRebirthStep2ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3]; + explosionScale = explosionCoordinates[2]; + } else { + if (explosion->getCentered()) { + explosionCoordinates = gCenteredExplosionCoordinates[AL_1_viewSquareExplosionIndex]; + } else { + if ((AL_2_cellPurpleMan == directionParam) || (AL_2_cellPurpleMan == returnPrevVal(directionParam))) { + AL_2_viewCell = kViewCellFronLeft; + } else { + AL_2_viewCell = kViewCellFrontRight; + } + explosionCoordinates = gExplosionCoordinates[AL_1_viewSquareExplosionIndex][AL_2_viewCell]; + } + explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * gExplosionBaseScales[explosionScaleIndex]) >> 8) & (int16)0xFFFE; + } + AL_6_bitmapRedBanana = getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle); +T0115200_DrawExplosion: + flipVertical = _vm->_rnd->getRandomNumber(2); + paddingPixelCount = 0; + if (flipHorizontal = _vm->_rnd->getRandomNumber(2)) { + paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; /* Number of unused pixels in the units on the right of the bitmap */ + } + boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1)) + 1; + AL_4_yPos = MAX(0, explosionCoordinates[1] - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001)); + if (AL_4_yPos >= 136) + continue; + boxByteGreen._y1 = AL_4_yPos; + if ((AL_4_xPos = MIN(223, explosionCoordinates[0] + byteWidth)) < 0) + continue; + boxByteGreen._x2 = AL_4_xPos + 1; + AL_4_xPos = explosionCoordinates[0]; + if (boxByteGreen._x1 = MIN(MAX(0, AL_4_xPos - byteWidth + 1), 223)) { + AL_4_xPos = paddingPixelCount; + } else { +/* BUG0_07 Graphical glitch when drawing explosions. If an explosion bitmap is cropped because it is only partly visible on the +left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is not flipped horizontally (flipHorizontal = C0_FALSE) then the +variable paddingPixelCount is not set before being used here. Its previous value (defined while drawing something else) is used +and may cause an incorrect bitmap to be drawn */ + AL_4_xPos = MIN(paddingPixelCount,(int16)( byteWidth / 2 - AL_4_xPos - 1)); + +/* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap is cropped because it is +only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) +then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */ + } + if (boxByteGreen._x2 - 1 <= boxByteGreen._x1) + continue; + warning("might need M77_NORMALIZED_BYTE_WIDTH"); + byteWidth = byteWidth; + if (flipHorizontal || flipVertical) { + memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle); + AL_6_bitmapRedBanana = _tmpBitmap; + } + if (flipHorizontal) { + flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); + } + if (flipVertical) { + flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); + } + blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, kColorFlesh, gDungeonViewport); + } + } + } while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList); +/* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */ + if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_doNotDrawFluxcagesDuringEndgame) { + AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */ + fieldAspect = gFieldAspects[viewSquareIndex]; + (fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */ + drawField(&fieldAspect, *(Box*)&gFrameWalls[viewSquareIndex]); + } } +uint16 DisplayMan::getNormalizedByteWidthM77(uint16 byteWidth) { + return (byteWidth + 7) & 0xFFF8; +} + +uint16 DisplayMan::getVerticalOffsetM23(uint16 val) { + return (val >> 3) & 0x7; +} +uint16 DisplayMan::getHorizontalOffsetM22(uint16 val) { + return (val & 0x7); +} bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) { if (_derivedBitmaps == nullptr) { diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 07a0806ea4..8a116b59c7 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -37,6 +37,44 @@ namespace DM { +/* View lanes */ +#define kViewLaneCenter 0 // @ C0_VIEW_LANE_CENTER +#define kViewLaneLeft 1 // @ C1_VIEW_LANE_LEFT +#define kViewLaneRight 2 // @ C2_VIEW_LANE_RIGHT + +#define kHalfSizedViewCell_LeftColumn 0 // @ C00_VIEW_CELL_LEFT_COLUMN +#define kHalfSizedViewCell_RightColumn 1 // @ C01_VIEW_CELL_RIGHT_COLUMN +#define kHalfSizedViewCell_BackRow 2 // @ C02_VIEW_CELL_BACK_ROW +#define kHalfSizedViewCell_CenterColumn 3 // @ C03_VIEW_CELL_CENTER_COLUMN +#define kHalfSizedViewCell_FrontRow 4 // @ C04_VIEW_CELL_FRONT_ROW + +/* Shift sets */ +#define kShiftSet_D0BackD1Front 0 // @ C0_SHIFT_SET_D0_BACK_OR_D1_FRONT +#define kShiftSet_D1BackD2Front 1 // @ C1_SHIFT_SET_D1_BACK_OR_D2_FRONT +#define kShiftSet_D2BackD3Front 2 // @ C2_SHIFT_SET_D2_BACK_OR_D3_FRONT + +#define kCellOrder_DoorFront 0x0008 // @ MASK0x0008_DOOR_FRONT +#define kCellOrder_Alcove 0x0000 // @ C0000_CELL_ORDER_ALCOVE +#define kCellOrder_BackLeft 0x0001 // @ C0001_CELL_ORDER_BACKLEFT +#define kCellOrder_BackRight 0x0002 // @ C0002_CELL_ORDER_BACKRIGHT +#define kCellOrder_DoorPass1_BackLeft 0x0018 // @ C0018_CELL_ORDER_DOORPASS1_BACKLEFT +#define kCellOrder_BackLeft_BackRight 0x0021 // @ C0021_CELL_ORDER_BACKLEFT_BACKRIGHT +#define kCellOrder_DoorPass1_BackRight 0x0028 // @ C0028_CELL_ORDER_DOORPASS1_BACKRIGHT +#define kCellOrder_BackRight_FrontRight 0x0032 // @ C0032_CELL_ORDER_BACKRIGHT_FRONTRIGHT +#define kCellOrder_DoorPass2_FrontRight 0x0039 // @ C0039_CELL_ORDER_DOORPASS2_FRONTRIGHT +#define kCellOrder_BackLeft_FrontLeft 0x0041 // @ C0041_CELL_ORDER_BACKLEFT_FRONTLEFT +#define kCellOrder_DoorPass2_FrontLeft 0x0049 // @ C0049_CELL_ORDER_DOORPASS2_FRONTLEFT +#define kCellOrder_DoorPass1_BackRight_BackLeft 0x0128 // @ C0128_CELL_ORDER_DOORPASS1_BACKRIGHT_BACKLEFT +#define kCellOrder_DoorPass1_BackLeft_BackRight 0x0218 // @ C0218_CELL_ORDER_DOORPASS1_BACKLEFT_BACKRIGHT +#define kCellOrder_BackLeft_BackRight_FrontRight 0x0321 // @ C0321_CELL_ORDER_BACKLEFT_BACKRIGHT_FRONTRIGHT +#define kCellOrder_BackRight_FrontLeft_FrontRight 0x0342 // @ C0342_CELL_ORDER_BACKRIGHT_FRONTLEFT_FRONTRIGHT +#define kCellOrder_DoorPass2_FrontLeft_FrontRight 0x0349 // @ C0349_CELL_ORDER_DOORPASS2_FRONTLEFT_FRONTRIGHT +#define kCellOrder_BackRight_BackLeft_FrontLeft 0x0412 // @ C0412_CELL_ORDER_BACKRIGHT_BACKLEFT_FRONTLEFT +#define kCellOrder_BackLeft_FrontRight_FrontLeft 0x0431 // @ C0431_CELL_ORDER_BACKLEFT_FRONTRIGHT_FRONTLEFT +#define kCellOrder_DoorPass2_FrontRight_FrontLeft 0x0439 // @ C0439_CELL_ORDER_DOORPASS2_FRONTRIGHT_FRONTLEFT +#define kCellOrder_BackLeft_BackRight_FrontLeft_FrontRight 0x3421 // @ C3421_CELL_ORDER_BACKLEFT_BACKRIGHT_FRONTLEFT_FRONTRIGHT +#define kCellOrder_BackRight_BackLeft_FrontRight_FrontLeft 0x4312 // @ C4312_CELL_ORDER_BACKRIGHT_BACKLEFT_FRONTRIGHT_FRONTLEFT + #define kFloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT #define kWallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT @@ -167,7 +205,11 @@ enum GraphicIndice { kFloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS kFieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R kFieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER - kFirstExplosionGraphicIndice = 348 // @ C348_GRAPHIC_FIRST_EXPLOSION + kFirstExplosionGraphicIndice = 348, // @ C348_GRAPHIC_FIRST_EXPLOSION + kFirstObjectGraphicIndice = 360, // @ C360_GRAPHIC_FIRST_OBJECT + kFirstCreatureGraphicIndice = 446, // @ C446_GRAPHIC_FIRST_CREATURE + kFirstProjectileGraphicIndice = 316, // @ C316_GRAPHIC_FIRST_PROJECTILE + kFirstExplosionPatternGraphicIndice = 351 // @ C351_GRAPHIC_FIRST_EXPLOSION_PATTERN }; extern uint16 gPalSwoosh[16]; @@ -284,6 +326,7 @@ public: FieldAspect(uint16 native, uint16 base, uint16 transparent, byte mask, uint16 byteWidth, uint16 height, uint16 xPos, uint16 bitplane) : _nativeBitmapRelativeIndex(native), _baseStartUnitIndex(base), _transparentColor(transparent), _mask(mask), _pixelWidth(byteWidth * 2), _height(height), _xPos(xPos), _bitplaneWordCount(bitplane) {} + FieldAspect() {} }; // @ FIELD_ASPECT @@ -455,7 +498,7 @@ public: int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDefultViewPort); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap void blitBoxFilledWithMaskedBitmapToScreen(byte *src, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, - int16 xPos, int16 yPos, int16 height2, Viewport &viewport = gDungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap + int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); @@ -473,9 +516,12 @@ public: int16 getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount int16 getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION - void drawObjectsCreaturesProjectilesExplosions(Thing thingParam, direction directionParam, + void cthulhu(Thing thingParam, direction directionParam, int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF + uint16 getNormalizedByteWidthM77(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH + uint16 getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET + uint16 getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices diff --git a/engines/dm/group.h b/engines/dm/group.h index 49ec009d94..0c2233dcb7 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -82,6 +82,10 @@ enum CreatureType { #define kMaskCreatureInfo_archenemy 0x2000 // @ MASK0x2000_ARCHENEMY #define kMaskCreatureInfo_magicmap 0x4000 // @ MASK0x4000_MAGICMAP + +#define kMaskActiveGroupFlipBitmap 0x0040 // @ MASK0x0040_FLIP_BITMAP +#define kMaskActiveGroupIsAttacking 0x0080 // @ MASK0x0080_IS_ATTACKING + class ActiveGroup { public: int _groupThingIndex; -- cgit v1.2.3 From 579b56d2124fabafd5f99ab6e308c9a286fc14af Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 1 Jul 2016 21:24:22 +0200 Subject: DM: Reversing several modifications and adding missing code warninings Add missing code warnings to DisplayMan::drawSquareD3L (@F0116_DUNGEONVIEW_DrawSquareD3L) Add missing annotations to SquareAspectIndice. Add several Frame globals. Remove StairIndex, replace DisplayMan::_stairIndices with direct class members. Refactor Frame into class, make it use Box type. Add several entries to GraphicIndices type. --- engines/dm/dungeonman.h | 25 +++--- engines/dm/gfx.cpp | 197 ++++++++++++++++++++++++++++++++++-------------- engines/dm/gfx.h | 62 ++++++++------- 3 files changed, 187 insertions(+), 97 deletions(-) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index dcf1659c79..df56ec229b 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -163,19 +163,20 @@ enum TextType { }; enum SquareAspectIndice { - kElemAspect = 0, - kFirstGroupOrObjectAspect = 1, - kRightWallOrnOrdAspect = 2, - kFrontWallOrnOrdAspect = 3, - kLeftWallOrnOrdAspect = 4, - kPitInvisibleAspect = 2, - kTeleporterVisibleAspect = 2, - kStairsUpAspect = 2, - kDoorStateAspect = 2, - kDoorThingIndexAspect = 3, - kFloorOrnOrdAspect = 4, - kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS + kElemAspect = 0, // @ C0_ELEMENT + kFirstGroupOrObjectAspect = 1, // @ C1_FIRST_GROUP_OR_OBJECT + kRightWallOrnOrdAspect = 2, // @ C2_RIGHT_WALL_ORNAMENT_ORDINAL + kFrontWallOrnOrdAspect = 3, // @ C3_FRONT_WALL_ORNAMENT_ORDINAL + kLeftWallOrnOrdAspect = 4, // @ C4_LEFT_WALL_ORNAMENT_ORDINAL + kPitInvisibleAspect = 2, // @ C2_PIT_INVISIBLE + kTeleporterVisibleAspect = 2, // @ C2_TELEPORTER_VISIBLE + kStairsUpAspect = 2, // @ C2_STAIRS_UP + kDoorStateAspect = 2, // @ C2_DOOR_STATE + kDoorThingIndexAspect = 3, // @ C3_DOOR_THING_INDEX + kFloorOrnOrdAspect = 4, // @ C4_FLOOR_ORNAMENT_ORDINAL + kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS }; +; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 81b7e64423..49f0d2e4d3 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -39,6 +39,43 @@ namespace DM { +Frame g0164Frame_DoorFrameLeft_D3L = Frame(0, 31, 28, 70, 16, 43, 0, 0); // @ G0164_s_Graphic558_Frame_DoorFrameLeft_D3L +Frame g0165Frame_DoorFrameRight_D3R = Frame(192, 223, 28, 70, 16, 43, 0, 0); // @ G0165_s_Graphic558_Frame_DoorFrameRight_D3R +Frame g0166Frame_DoorFrameLeft_D3C = Frame(64, 95, 27, 70, 16, 44, 0, 0); // @ G0166_s_Graphic558_Frame_DoorFrameLeft_D3C +Frame g0167Frame_DoorFrameRight_D3C = Frame(128, 159, 27, 70, 16, 44, 0, 0); // @ G0167_s_Graphic558_Frame_DoorFrameRight_D3C +Frame g0168Frame_DoorFrameLeft_D2C = Frame(48, 95, 22, 86, 24, 65, 0, 0); // @ G0168_s_Graphic558_Frame_DoorFrameLeft_D2C +Frame g0169Frame_DoorFrameRight_D2C = Frame(128, 175, 22, 86, 24, 65, 0, 0); // @ G0169_s_Graphic558_Frame_DoorFrameRight_D2C +Frame g0170Frame_DoorFrameLeft_D1C = Frame(43, 74, 14, 107, 16, 94, 0, 0); // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C +Frame g0171Frame_DoorFrameRight_D1C = Frame(149, 180, 14, 107, 16, 94, 0, 0); // @ G0171_s_Graphic558_Frame_DoorFrameRight_D1C +Frame g0172Frame_DoorFrame_D0C = Frame(96, 127, 0, 122, 16, 123, 0, 0); // @ G0172_s_Graphic558_Frame_DoorFrame_D0C +Frame g0173Frame_DoorFrameTop_D2L = Frame(0, 59, 22, 24, 48, 3, 16, 0); // @ G0173_s_Graphic558_Frame_DoorFrameTop_D2L +Frame g0174Frame_DoorFrameTop_D2C = Frame(64, 159, 22, 24, 48, 3, 0, 0); // @ G0174_s_Graphic558_Frame_DoorFrameTop_D2C +Frame g0175Frame_DoorFrameTop_D2R = Frame(164, 223, 22, 24, 48, 3, 16, 0); // @ G0175_s_Graphic558_Frame_DoorFrameTop_D2R +Frame g0176Frame_DoorFrameTop_D1L = Frame(0, 31, 14, 17, 64, 4, 16, 0); // @ G0176_s_Graphic558_Frame_DoorFrameTop_D1L +Frame g0177Frame_DoorFrameTop_D1C = Frame(48, 175, 14, 17, 64, 4, 0, 0); // @ G0177_s_Graphic558_Frame_DoorFrameTop_D1C +Frame g0178Frame_DoorFrameTop_D1R = Frame(192, 223, 14, 17, 64, 4, 16, 0); // @ G0178_s_Graphic558_Frame_DoorFrameTop_D1R +Frame g0140FrameFloorPit_D3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L +Frame g0141FrameFloorPit_D3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C +Frame g0142FrameFloorPit_D3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R +Frame g0143FrameFloorPit_D2L = Frame(0, 79, 77, 88, 40, 12, 0, 0); // @ G0143_s_Graphic558_Frame_FloorPit_D2L +Frame g0144FrameFloorPit_D2C = Frame(64, 159, 77, 88, 48, 12, 0, 0); // @ G0144_s_Graphic558_Frame_FloorPit_D2C +Frame g0145FrameFloorPit_D2R = Frame(144, 223, 77, 88, 40, 12, 0, 0); // @ G0145_s_Graphic558_Frame_FloorPit_D2R +Frame g0146FrameFloorPit_D1L = Frame(0, 63, 93, 116, 32, 24, 0, 0); // @ G0146_s_Graphic558_Frame_FloorPit_D1L +Frame g0147FrameFloorPit_D1C = Frame(32, 191, 93, 116, 80, 24, 0, 0); // @ G0147_s_Graphic558_Frame_FloorPit_D1C +Frame g0148FrameFloorPit_D1R = Frame(160, 223, 93, 116, 32, 24, 0, 0); // @ G0148_s_Graphic558_Frame_FloorPit_D1R +Frame g0149FrameFloorPit_D0L = Frame(0, 31, 124, 135, 16, 12, 0, 0); // @ G0149_s_Graphic558_Frame_FloorPit_D0L +Frame g0150FrameFloorPit_D0C = Frame(16, 207, 124, 135, 96, 12, 0, 0); // @ G0150_s_Graphic558_Frame_FloorPit_D0C +Frame g0151FrameFloorPit_D0R = Frame(192, 223, 124, 135, 16, 12, 0, 0); // @ G0151_s_Graphic558_Frame_FloorPit_D0R +Frame g0152FrameFloorPit_D2L = Frame(0, 79, 19, 23, 40, 5, 0, 0); // @ G0152_s_Graphic558_Frame_CeilingPit_D2L +Frame g0153FrameFloorPit_D2C = Frame(64, 159, 19, 23, 48, 5, 0, 0); // @ G0153_s_Graphic558_Frame_CeilingPit_D2C +Frame g0154FrameFloorPit_D2R = Frame(144, 223, 19, 23, 40, 5, 0, 0); // @ G0154_s_Graphic558_Frame_CeilingPit_D2R +Frame g0155FrameFloorPit_D1L = Frame(0, 63, 8, 16, 32, 9, 0, 0); // @ G0155_s_Graphic558_Frame_CeilingPit_D1L +Frame g0156FrameFloorPit_D1C = Frame(32, 191, 8, 16, 80, 9, 0, 0); // @ G0156_s_Graphic558_Frame_CeilingPit_D1C +Frame g0157FrameFloorPit_D1R = Frame(160, 223, 8, 16, 32, 9, 0, 0); // @ G0157_s_Graphic558_Frame_CeilingPit_D1R +Frame g0158FrameFloorPit_D0L = Frame(0, 15, 0, 3, 8, 4, 0, 0); // @ G0158_s_Graphic558_Frame_CeilingPit_D0L +Frame g0159FrameFloorPit_D0C = Frame(16, 207, 0, 3, 96, 4, 0, 0); // @ G0159_s_Graphic558_Frame_CeilingPit_D0C +Frame g0160FrameFloorPit_D0R = Frame(208, 223, 0, 3, 8, 4, 0, 0); // @ G0160_s_Graphic558_Frame_CeilingPit_D0R + FieldAspect gFieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects /* { NativeBitmapRelativeIndex, BaseStartUnitIndex, Transparent color, Mask, ByteWidth, Height, X, BitPlaneWordCount } */ FieldAspect(0, 63, 0x8A, 0xFF, 0, 0, 0, 64), /* D3C */ @@ -645,8 +682,8 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { for (int i = 0; i < 25; i++) _wallSetBitMaps[i] = nullptr; - for (int i = 0; i < kStairsGraphicCount; i++) - _stairIndices[i] = 0; + //for (int i = 0; i < kStairsGraphicCount; i++) + // _stairIndices[i] = 0; for (int i = 0; i < 4; i++) _palChangesProjectile[i] = nullptr; @@ -1065,33 +1102,62 @@ uint16 DisplayMan::getHeight(uint16 index) { void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { if (f._srcWidth) - blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorNoTransparency, gDungeonViewport); + blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, kColorNoTransparency, gDungeonViewport); } void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) { if (f._srcWidth) - blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorFlesh, gDungeonViewport); + blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, kColorFlesh, gDungeonViewport); } + +// NOTE: has been screened for missing code void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; + int16 order; + _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[kElemAspect]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3L]); + drawFloorPitOrStairsBitmap(_g0675stairsNativeBitmapIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3L]); else - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3L]); - break; + drawFloorPitOrStairsBitmap(_g0682stairsNativeBitmapIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3L]); + goto T0116015_redEagle; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3L]); isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], kViewWall_D3L_RIGHT); if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3L_FRONT)) { - // ... missing code + order = kCellOrder_Alcove; + goto T0116017_orangeElk; } - break; - default: - break; + return; + case kElementTypeDoorSide: + case kElementTypeStairsSide: + order = kCellOrder_BackLeft_BackRight_FrontRight; + goto T0116016_blueToad; + case kElementTypeDoorFront: + warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); + cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3L, kCellOrder_DoorPass1_BackLeft_BackRight); + drawWallSetBitmap(_wallSetBitMaps[kDoorFrameLeft_D3L], g0164Frame_DoorFrameLeft_D3L); + warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor"); + order = kCellOrder_DoorPass2_FrontLeft_FrontRight; + goto T0116017_orangeElk; + case kElementTypePit: + if (!squareAspect[kPitInvisibleAspect]) { + drawFloorPitOrStairsBitmap(k049FloorPit_D3L_GraphicIndice, g0140FrameFloorPit_D3L); + } + case kElementTypeTeleporter: + case kElementTypeCorridor: +T0116015_redEagle: + order = kCellOrder_BackLeft_BackRight_FrontLeft_FrontRight; +T0116016_blueToad: + warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); +T0116017_orangeElk: + cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3L, order); + } + if ((squareAspect[kElemAspect] == kElementTypeTeleporter) && squareAspect[kTeleporterVisibleAspect]) { + drawField(&gFieldAspects[kViewSquare_D3L], gFrameWalls[kViewSquare_D3L]._box); } } @@ -1101,9 +1167,9 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g0675stairsNativeBitmapIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3R]); else - drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g0682stairsNativeBitmapIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3R]); break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3R]); @@ -1122,9 +1188,9 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D3C, gStairFrames[kFrameStairsUpFront_D3C]); + drawFloorPitOrStairsBitmap(_g0676stairsNativeBitmapIndex_Up_Front_D3C, gStairFrames[kFrameStairsUpFront_D3C]); else - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D3C, gStairFrames[kFrameStairsDownFront_D3C]); + drawFloorPitOrStairsBitmap(_g0683stairsNativeBitmapIndex_Down_Front_D3C, gStairFrames[kFrameStairsDownFront_D3C]); break; case kWallElemType: drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3C]); @@ -1142,9 +1208,9 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2L]); + drawFloorPitOrStairsBitmap(_g0677stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2L]); else - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2L]); + drawFloorPitOrStairsBitmap(_g0684stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2L]); break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2L]); @@ -1154,7 +1220,7 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) { } break; case kStairsSideElemType: - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2L]); + drawFloorPitOrStairsBitmap(_g0689stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2L]); break; default: break; @@ -1166,9 +1232,9 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g0677stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2R]); else - drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g0684stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2R]); break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2R]); @@ -1178,7 +1244,7 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) { } break; case kStairsSideElemType: - drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g0689stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]); break; default: break; @@ -1190,9 +1256,9 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D2C, gStairFrames[kFrameStairsUpFront_D2C]); + drawFloorPitOrStairsBitmap(_g0678stairsNativeBitmapIndex_Up_Front_D2C, gStairFrames[kFrameStairsUpFront_D2C]); else - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D2C, gStairFrames[kFrameStairsDownFront_D2C]); + drawFloorPitOrStairsBitmap(_g0685stairsNativeBitmapIndex_Down_Front_D2C, gStairFrames[kFrameStairsDownFront_D2C]); break; case kWallElemType: drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2C]); @@ -1210,9 +1276,9 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1L]); + drawFloorPitOrStairsBitmap(_g0679stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1L]); else - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1L]); + drawFloorPitOrStairsBitmap(_g0686stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1L]); break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1L]); @@ -1220,9 +1286,9 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) { break; case kStairsSideElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1L]); + drawFloorPitOrStairsBitmap(_g0690stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1L]); else - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1L]); + drawFloorPitOrStairsBitmap(_g0691stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1L]); break; default: break; @@ -1234,9 +1300,9 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g0679stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1R]); else - drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g0686stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1R]); break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1R]); @@ -1244,9 +1310,9 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) { break; case kStairsSideElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g0690stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1R]); else - drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g0691stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1R]); break; default: break; @@ -1258,9 +1324,9 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D1C, gStairFrames[kFrameStairsUpFront_D1C]); + drawFloorPitOrStairsBitmap(_g0680stairsNativeBitmapIndex_Up_Front_D1C, gStairFrames[kFrameStairsUpFront_D1C]); else - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D1C, gStairFrames[kFrameStairsDownFront_D1C]); + drawFloorPitOrStairsBitmap(_g0687stairsNativeBitmapIndex_Down_Front_D1C, gStairFrames[kFrameStairsDownFront_D1C]); break; case kWallElemType: _vm->_dungeonMan->_isFacingAlcove = false; @@ -1282,7 +1348,7 @@ void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsSideElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0L]); + drawFloorPitOrStairsBitmap(_g0692stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0L]); break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]); @@ -1298,7 +1364,7 @@ void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsSideElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g0692stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0R]); return; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D0R], gFrameWalls[kViewSquare_D0R]); @@ -1314,11 +1380,11 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) { - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0L]); - drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0R]); + drawFloorPitOrStairsBitmap(_g0681stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0L]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g0681stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0R]); } else { - drawFloorPitOrStairsBitmap(kStairsNativeIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0L]); - drawFloorPitOrStairsBitmapFlippedHorizontally(kStairsNativeIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0R]); + drawFloorPitOrStairsBitmap(_g0688stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0L]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g0688stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0R]); } break; default: @@ -1481,8 +1547,27 @@ void DisplayMan::loadCurrentMapGraphics() { // the original loads some flipped walls here, I moved it to loadWallSet - for (uint16 i = 0, firstGraphicIndex = _vm->_dungeonMan->_currMap._map->_wallSet * kStairsGraphicCount + kFirstStairs; i < kStairsGraphicCount; ++i) - _stairIndices[i] = firstGraphicIndex + i; + { + int16 val = _vm->_dungeonMan->_currMap._map->_wallSet * kStairsGraphicCount + kFirstStairs; + _g0675stairsNativeBitmapIndex_Up_Front_D3L = val++; + _g0676stairsNativeBitmapIndex_Up_Front_D3C = val++; + _g0677stairsNativeBitmapIndex_Up_Front_D2L = val++; + _g0678stairsNativeBitmapIndex_Up_Front_D2C = val++; + _g0679stairsNativeBitmapIndex_Up_Front_D1L = val++; + _g0680stairsNativeBitmapIndex_Up_Front_D1C = val++; + _g0681stairsNativeBitmapIndex_Up_Front_D0C_Left = val++; + _g0682stairsNativeBitmapIndex_Down_Front_D3L = val++; + _g0683stairsNativeBitmapIndex_Down_Front_D3C = val++; + _g0684stairsNativeBitmapIndex_Down_Front_D2L = val++; + _g0685stairsNativeBitmapIndex_Down_Front_D2C = val++; + _g0686stairsNativeBitmapIndex_Down_Front_D1L = val++; + _g0687stairsNativeBitmapIndex_Down_Front_D1C = val++; + _g0688stairsNativeBitmapIndex_Down_Front_D0C_Left = val++; + _g0689stairsNativeBitmapIndex_Side_D2L = val++; + _g0690stairsNativeBitmapIndex_Up_Side_D1L = val++; + _g0691stairsNativeBitmapIndex_Down_Side_D1L = val++; + _g0692stairsNativeBitmapIndex_Side_D0L = val++; + } for (int16 i = 0; i < kAlcoveOrnCount; ++i) _currMapAlcoveOrnIndices[i] = -1; @@ -1554,17 +1639,17 @@ void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor gPalChangesCreature_D3[replacedColor] = gCreatureReplColorSets[replacementColor]._D3ReplacementColor; } -void DisplayMan::drawFloorPitOrStairsBitmap(StairIndex relIndex, Frame &f) { +void DisplayMan::drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) { if (f._srcWidth) { - blitToScreen(_bitmaps[_stairIndices[relIndex]], f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorFlesh, gDungeonViewport); + blitToScreen(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, f._box, kColorFlesh, gDungeonViewport); } } -void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relIndex, Frame &f) { +void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) { if (f._srcWidth) { - blitToBitmap(_bitmaps[_stairIndices[relIndex]], f._srcWidth, f._srcHeight, _tmpBitmap, f._srcWidth); + blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcHeight, _tmpBitmap, f._srcWidth); flipBitmapHorizontal(_tmpBitmap, f._srcWidth, f._srcHeight); - blitToScreen(_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._destFromX, f._destToX, f._destFromY, f._destToY, kColorFlesh, gDungeonViewport); + blitToScreen(_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._box, kColorFlesh, gDungeonViewport); } } @@ -1641,12 +1726,12 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex while (*character++ < 0x80) { characterCount++; } - frame._destToX = (frame._destFromX = 112 - (characterCount * 4)) + 7; - frame._destFromY = (frame._destToY = gInscriptionLineY[textLineIndex++]) - 7; + frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7; + frame._box._y1 = (frame._box._y2 = gInscriptionLineY[textLineIndex++]) - 7; while (characterCount--) { - blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._destFromX, frame._destToX, frame._destFromY, frame._destToY, kColorFlesh, gDungeonViewport); - frame._destFromX += 8; - frame._destToX += 8; + blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._box, kColorFlesh, gDungeonViewport); + frame._box._x1 += 8; + frame._box._x2 += 8; } } while (*string++ != 0x81); return isAlcove; @@ -1721,14 +1806,14 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex } while (*string++ != 0x81); if (unreadableTextLineCount < 4) { - frame._destFromX = coordinateSetA[0]; - frame._destToX = coordinateSetA[1]; - frame._destFromY = coordinateSetA[2]; - frame._destToY = coordinateSetA[3]; + frame._box._x1 = coordinateSetA[0]; + frame._box._x2 = coordinateSetA[1]; + frame._box._y1 = coordinateSetA[2]; + frame._box._y2 = coordinateSetA[3]; frame._srcWidth = coordinateSetA[4]; frame._srcHeight = coordinateSetA[5]; - coordinateSetA = &frame._destFromX; + coordinateSetA = (uint16*)&frame._box; coordinateSetA[3] = gUnreadableInscriptionBoxY2[gWallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1]; } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 8a116b59c7..397417fd75 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -209,7 +209,15 @@ enum GraphicIndice { kFirstObjectGraphicIndice = 360, // @ C360_GRAPHIC_FIRST_OBJECT kFirstCreatureGraphicIndice = 446, // @ C446_GRAPHIC_FIRST_CREATURE kFirstProjectileGraphicIndice = 316, // @ C316_GRAPHIC_FIRST_PROJECTILE - kFirstExplosionPatternGraphicIndice = 351 // @ C351_GRAPHIC_FIRST_EXPLOSION_PATTERN + kFirstExplosionPatternGraphicIndice = 351, // @ C351_GRAPHIC_FIRST_EXPLOSION_PATTERN + k049FloorPit_D3L_GraphicIndice = 49, // @ C049_GRAPHIC_FLOOR_PIT_D3L + k050FloorPit_D3C_GraphicIndice = 50, // @ C050_GRAPHIC_FLOOR_PIT_D3C + k051FloorPit_D2L_GraphicIndice = 51, // @ C051_GRAPHIC_FLOOR_PIT_D2L + k052FloorPit_D2C_GraphicIndice = 52, // @ C052_GRAPHIC_FLOOR_PIT_D2C + k053FloorPit_D1L_GraphicIndice = 53, // @ C053_GRAPHIC_FLOOR_PIT_D1L + k054FloorPit_D1C_GraphicIndice = 54, // @ C054_GRAPHIC_FLOOR_PIT_D1C + k055FloorPit_D0L_GraphicIndice = 55, // @ C055_GRAPHIC_FLOOR_PIT_D0L + k056FloorPit_D0C_GraphicIndice = 56 // @ C056_GRAPHIC_FLOOR_PIT_D0C }; extern uint16 gPalSwoosh[16]; @@ -235,16 +243,16 @@ public: extern Box gBoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows -// The frames in the original sources contain inclusive boundaries and byte widths, not pixel widths -struct Frame { - uint16 _destFromX, _destToX, _destFromY, _destToY; +class Frame { +public: + Box _box; uint16 _srcWidth, _srcHeight; uint16 _srcX, _srcY; Frame() {} Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) : - _destFromX(destFromX), _destToX(destToX + 1), _destFromY(destFromY), _destToY(destToY + 1), + _box(destFromX, destToX, destFromY, destToY), _srcWidth(srcWidth * 2), _srcHeight(srcHeight), _srcX(srcX), _srcY(srcY) {} }; @@ -256,27 +264,6 @@ enum FloorSet { kFloorSetStone = 0 // @ C0_FLOOR_SET_STONE }; -enum StairIndex { - kStairsNativeIndex_Up_Front_D3L = 0, // @ G0675_i_StairsNativeBitmapIndex_Up_Front_D3L - kStairsNativeIndex_Up_Front_D3C = 1, // @ G0676_i_StairsNativeBitmapIndex_Up_Front_D3C - kStairsNativeIndex_Up_Front_D2L = 2, // @ G0677_i_StairsNativeBitmapIndex_Up_Front_D2L - kStairsNativeIndex_Up_Front_D2C = 3, // @ G0678_i_StairsNativeBitmapIndex_Up_Front_D2C - kStairsNativeIndex_Up_Front_D1L = 4, // @ G0679_i_StairsNativeBitmapIndex_Up_Front_D1L - kStairsNativeIndex_Up_Front_D1C = 5, // @ G0680_i_StairsNativeBitmapIndex_Up_Front_D1C - kStairsNativeIndex_Up_Front_D0C_Left = 6, // @ G0681_i_StairsNativeBitmapIndex_Up_Front_D0C_Left - kStairsNativeIndex_Down_Front_D3L = 7, // @ G0682_i_StairsNativeBitmapIndex_Down_Front_D3L - kStairsNativeIndex_Down_Front_D3C = 8, // @ G0683_i_StairsNativeBitmapIndex_Down_Front_D3C - kStairsNativeIndex_Down_Front_D2L = 9, // @ G0684_i_StairsNativeBitmapIndex_Down_Front_D2L - kStairsNativeIndex_Down_Front_D2C = 10, // @ G0685_i_StairsNativeBitmapIndex_Down_Front_D2C - kStairsNativeIndex_Down_Front_D1L = 11, // @ G0686_i_StairsNativeBitmapIndex_Down_Front_D1L - kStairsNativeIndex_Down_Front_D1C = 12, // @ G0687_i_StairsNativeBitmapIndex_Down_Front_D1C - kStairsNativeIndex_Down_Front_D0C_Left = 13, // @ G0688_i_StairsNativeBitmapIndex_Down_Front_D0C_Left - kStairsNativeIndex_Side_D2L = 14, // @ G0689_i_StairsNativeBitmapIndex_Side_D2L - kStairsNativeIndex_Up_Side_D1L = 15, // @ G0690_i_StairsNativeBitmapIndex_Up_Side_D1L - kStairsNativeIndex_Down_Side_D1L = 16, // @ G0691_i_StairsNativeBitmapIndex_Down_Side_D1L - kStairsNativeIndex_Side_D0L = 17 // @ G0692_i_StairsNativeBitmapIndex_Side_D0L -}; - enum ViewWall { kViewWall_D3L_RIGHT = 0, // @ C00_VIEW_WALL_D3L_RIGHT kViewWall_D3R_LEFT = 1, // @ C01_VIEW_WALL_D3R_LEFT @@ -416,7 +403,6 @@ class DisplayMan { // pointers 13,14 and [15-19] are owned by this array byte *_wallSetBitMaps[25]; // @G[0696..0710]_puc_Bitmap_WallSet_... - uint16 _stairIndices[kStairsGraphicCount]; // pointers are not owned by these fields byte *_floorBitmap; @@ -432,8 +418,8 @@ class DisplayMan { void unpackGraphics(); void loadFNT1intoBitmap(uint16 index, byte *destBitmap); - void drawFloorPitOrStairsBitmapFlippedHorizontally(StairIndex relIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally - void drawFloorPitOrStairsBitmap(StairIndex relIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap + void drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally + void drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap void drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L @@ -457,6 +443,24 @@ class DisplayMan { uint16 *_derivedBitmapByteCount; // @ G0639_pui_DerivedBitmapByteCount byte **_derivedBitmaps; // @ G0638_pui_DerivedBitmapBlockIndices + int16 _g0675stairsNativeBitmapIndex_Up_Front_D3L; // @ G0675_i_StairsNativeBitmapIndex_Up_Front_D3L + int16 _g0676stairsNativeBitmapIndex_Up_Front_D3C; // @ G0676_i_StairsNativeBitmapIndex_Up_Front_D3C + int16 _g0677stairsNativeBitmapIndex_Up_Front_D2L; // @ G0677_i_StairsNativeBitmapIndex_Up_Front_D2L + int16 _g0678stairsNativeBitmapIndex_Up_Front_D2C; // @ G0678_i_StairsNativeBitmapIndex_Up_Front_D2C + int16 _g0679stairsNativeBitmapIndex_Up_Front_D1L; // @ G0679_i_StairsNativeBitmapIndex_Up_Front_D1L + int16 _g0680stairsNativeBitmapIndex_Up_Front_D1C; // @ G0680_i_StairsNativeBitmapIndex_Up_Front_D1C + int16 _g0681stairsNativeBitmapIndex_Up_Front_D0C_Left; // @ G0681_i_StairsNativeBitmapIndex_Up_Front_D0C_Left + int16 _g0682stairsNativeBitmapIndex_Down_Front_D3L; // @ G0682_i_StairsNativeBitmapIndex_Down_Front_D3L + int16 _g0683stairsNativeBitmapIndex_Down_Front_D3C; // @ G0683_i_StairsNativeBitmapIndex_Down_Front_D3C + int16 _g0684stairsNativeBitmapIndex_Down_Front_D2L; // @ G0684_i_StairsNativeBitmapIndex_Down_Front_D2L + int16 _g0685stairsNativeBitmapIndex_Down_Front_D2C; // @ G0685_i_StairsNativeBitmapIndex_Down_Front_D2C + int16 _g0686stairsNativeBitmapIndex_Down_Front_D1L; // @ G0686_i_StairsNativeBitmapIndex_Down_Front_D1L + int16 _g0687stairsNativeBitmapIndex_Down_Front_D1C; // @ G0687_i_StairsNativeBitmapIndex_Down_Front_D1C + int16 _g0688stairsNativeBitmapIndex_Down_Front_D0C_Left; // @ G0688_i_StairsNativeBitmapIndex_Down_Front_D0C_Left + int16 _g0689stairsNativeBitmapIndex_Side_D2L; // @ G0689_i_StairsNativeBitmapIndex_Side_D2L + int16 _g0690stairsNativeBitmapIndex_Up_Side_D1L; // @ G0690_i_StairsNativeBitmapIndex_Up_Side_D1L + int16 _g0691stairsNativeBitmapIndex_Down_Side_D1L; // @ G0691_i_StairsNativeBitmapIndex_Down_Side_D1L + int16 _g0692stairsNativeBitmapIndex_Side_D0L; // @ G0692_i_StairsNativeBitmapIndex_Side_D0L public: // some methods use this for a stratchpad, don't make assumptions about content between function calls byte *_tmpBitmap; -- cgit v1.2.3 From e95470d189cbe5877053b128c89a4aac6c973d54 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 1 Jul 2016 22:04:55 +0200 Subject: DM: Fix errors in DisplayMan::isDerivedBitmapInCache --- engines/dm/gfx.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 49f0d2e4d3..d8bf60eb58 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -2894,8 +2894,9 @@ uint16 DisplayMan::getHorizontalOffsetM22(uint16 val) { } bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) { - if (_derivedBitmaps == nullptr) { - _derivedBitmaps[derivedBitmapIndex] = new byte[_derivedBitmapByteCount[derivedBitmapIndex]]; + if (_derivedBitmaps[derivedBitmapIndex] == nullptr) { + // * 2, because the original uses 4 bits instead of 8 bits to store a pixel + _derivedBitmaps[derivedBitmapIndex] = new byte[_derivedBitmapByteCount[derivedBitmapIndex] * 2]; return false; } else return true; -- cgit v1.2.3 From 5f25c6aae28a3553183ee3c2e8af7b66e9622bf6 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 1 Jul 2016 22:43:19 +0200 Subject: DM: Add missing code to DisplayMan::drawSquareD3R (@F0117_DUNGEONVIEW_DrawSquareD3R) --- engines/dm/gfx.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 12 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index d8bf60eb58..ce31c499f5 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -54,6 +54,36 @@ Frame g0175Frame_DoorFrameTop_D2R = Frame(164, 223, 22, 24, 48, 3, 16, 0); // @ Frame g0176Frame_DoorFrameTop_D1L = Frame(0, 31, 14, 17, 64, 4, 16, 0); // @ G0176_s_Graphic558_Frame_DoorFrameTop_D1L Frame g0177Frame_DoorFrameTop_D1C = Frame(48, 175, 14, 17, 64, 4, 0, 0); // @ G0177_s_Graphic558_Frame_DoorFrameTop_D1C Frame g0178Frame_DoorFrameTop_D1R = Frame(192, 223, 14, 17, 64, 4, 16, 0); // @ G0178_s_Graphic558_Frame_DoorFrameTop_D1R +Frame g0110FrameStairsUpFront_D3L = Frame(0, 79, 25, 70, 40, 46, 0, 0); // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L +Frame g0111FrameStairsUpFront_D3C = Frame(64, 159, 25, 70, 48, 46, 0, 0); // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C +Frame g0112FrameStairsUpFront_D3R = Frame(149, 223, 25, 70, 40, 46, 5, 0); // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R +Frame g0113FrameStairsUpFront_D2L = Frame(0, 63, 22, 83, 32, 62, 0, 0); // @ G0113_s_Graphic558_Frame_StairsUpFront_D2L +Frame g0114FrameStairsUpFront_D2C = Frame(64, 159, 22, 83, 48, 62, 0, 0); // @ G0114_s_Graphic558_Frame_StairsUpFront_D2C +Frame g0115FrameStairsUpFront_D2R = Frame(160, 223, 22, 83, 32, 62, 0, 0); // @ G0115_s_Graphic558_Frame_StairsUpFront_D2R +Frame g0116FrameStairsUpFront_D1L = Frame(0, 31, 9, 108, 16, 100, 0, 0); // @ G0116_s_Graphic558_Frame_StairsUpFront_D1L +Frame g0117FrameStairsUpFront_D1C = Frame(32, 191, 9, 108, 80, 100, 0, 0); // @ G0117_s_Graphic558_Frame_StairsUpFront_D1C +Frame g0118FrameStairsUpFront_D1R = Frame(192, 223, 9, 108, 16, 100, 0, 0); // @ G0118_s_Graphic558_Frame_StairsUpFront_D1R +Frame g0119FrameStairsUpFront_D0L = Frame(0, 31, 58, 101, 16, 44, 0, 0); // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L +Frame g0120FrameStairsUpFront_D0R = Frame(192, 223, 58, 101, 16, 44, 0, 0); // @ G0120_s_Graphic558_Frame_StairsUpFront_D0R +Frame g0121FrameStairsDownFront_D3L = Frame(0, 79, 28, 68, 40, 41, 0, 0); // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L +Frame g0122FrameStairsDownFront_D3C = Frame(64, 159, 28, 70, 48, 43, 0, 0); // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C +Frame g0123FrameStairsDownFront_D3R = Frame(149, 223, 28, 68, 40, 41, 5, 0); // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R +Frame g0124FrameStairsDownFront_D2L = Frame(0, 63, 24, 85, 32, 62, 0, 0); // @ G0124_s_Graphic558_Frame_StairsDownFront_D2L +Frame g0125FrameStairsDownFront_D2C = Frame(64, 159, 24, 85, 48, 62, 0, 0); // @ G0125_s_Graphic558_Frame_StairsDownFront_D2C +Frame g0126FrameStairsDownFront_D2R = Frame(160, 223, 24, 85, 32, 62, 0, 0); // @ G0126_s_Graphic558_Frame_StairsDownFront_D2R +Frame g0127FrameStairsDownFront_D1L = Frame(0, 31, 18, 108, 16, 91, 0, 0); // @ G0127_s_Graphic558_Frame_StairsDownFront_D1L +Frame g0128FrameStairsDownFront_D1C = Frame(32, 191, 18, 108, 80, 91, 0, 0); // @ G0128_s_Graphic558_Frame_StairsDownFront_D1C +Frame g0129FrameStairsDownFront_D1R = Frame(192, 223, 18, 108, 16, 91, 0, 0); // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R +Frame g0130FrameStairsDownFront_D0L = Frame(0, 31, 76, 135, 16, 60, 0, 0); // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L +Frame g0131FrameStairsDownFront_D0R = Frame(192, 223, 76, 135, 16, 60, 0, 0); // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R +Frame g0132FrameStairsSide_D2L = Frame(60, 75, 57, 61, 8, 5, 0, 0); // @ G0132_s_Graphic558_Frame_StairsSide_D2L +Frame g0133FrameStairsSide_D2R = Frame(148, 163, 57, 61, 8, 5, 0, 0); // @ G0133_s_Graphic558_Frame_StairsSide_D2R +Frame g0134FrameStairsUpSide_D1L = Frame(32, 63, 57, 99, 16, 43, 0, 0); // @ G0134_s_Graphic558_Frame_StairsUpSide_D1L +Frame g0135FrameStairsUpSide_D1R = Frame(160, 191, 57, 99, 16, 43, 0, 0); // @ G0135_s_Graphic558_Frame_StairsUpSide_D1R +Frame g0136FrameStairsDownSide_D1L = Frame(32, 63, 60, 98, 16, 39, 0, 0); // @ G0136_s_Graphic558_Frame_StairsDownSide_D1L +Frame g0137FrameStairsDownSide_D1R = Frame(160, 191, 60, 98, 16, 39, 0, 0); // @ G0137_s_Graphic558_Frame_StairsDownSide_D1R +Frame g0138FrameStairsSide_D0L = Frame(0, 15, 73, 85, 8, 13, 0, 0); // @ G0138_s_Graphic558_Frame_StairsSide_D0L +Frame g0139FrameStairsSide_D0R = Frame(208, 223, 73, 85, 8, 13, 0, 0); // @ G0139_s_Graphic558_Frame_StairsSide_D0R Frame g0140FrameFloorPit_D3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L Frame g0141FrameFloorPit_D3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C Frame g0142FrameFloorPit_D3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R @@ -1161,27 +1191,62 @@ T0116017_orangeElk: } } +// NOTE: has been screened for missing code void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { + int16 order; uint16 squareAspect[5]; + + _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case kStairsFrontElemType: - if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(_g0675stairsNativeBitmapIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3R]); - else - drawFloorPitOrStairsBitmapFlippedHorizontally(_g0682stairsNativeBitmapIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3R]); - break; - case kWallElemType: + switch (squareAspect[kElemAspect]) { + case kElementTypeStaisFront: + if (squareAspect[kStairsUpAspect]) { + drawFloorPitOrStairsBitmapFlippedHorizontally(_g0675stairsNativeBitmapIndex_Up_Front_D3L, g0112FrameStairsUpFront_D3R); + } else { + drawFloorPitOrStairsBitmapFlippedHorizontally(_g0682stairsNativeBitmapIndex_Down_Front_D3L, g0123FrameStairsDownFront_D3R); + } + goto T0117016; + case kElementTypeWall: drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3R]); isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], kViewWall_D3R_LEFT); if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3R_FRONT)) { - // ... missing code + order = kCellOrder_Alcove; + goto T0117018; } - break; - default: - break; + return; + case kElementTypeDoorSide: + case kElementTypeStairsSide: + order = kCellOrder_BackRight_BackLeft_FrontLeft; + goto T0117017; + case kElementTypeDoorFront: + warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); + cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3R, kCellOrder_DoorPass1_BackRight_BackLeft); + memcpy(_tmpBitmap, _wallSetBitMaps[kDoorFrameLeft_D3L], 32 * 44); + warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally"); + if (((Door*)_vm->_dungeonMan->_dunData._thingsData[kDoorThingType])[squareAspect[kDoorThingIndexAspect]].hasButton()) { + warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton"); + } + warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor"); + order = kCellOrder_DoorPass2_FrontRight_FrontLeft; + goto T0117018; + case kElementTypePit: + if (!squareAspect[kPitInvisibleAspect]) { + drawFloorPitOrStairsBitmapFlippedHorizontally(k049FloorPit_D3L_GraphicIndice, g0142FrameFloorPit_D3R); + } + case kElementTypeTeleporter: + case kElementTypeCorridor: +T0117016: + order = kCellOrder_BackRight_BackLeft_FrontRight_FrontLeft; +T0117017: + warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); +T0117018: + cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3R, order); + } + if ((squareAspect[kElemAspect] == kElementTypeTeleporter) && squareAspect[kTeleporterVisibleAspect]) { + drawField(&gFieldAspects[kViewSquare_D3R], gFrameWalls[kViewSquare_D3R]._box); } } + void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); -- cgit v1.2.3 From e2300bd04c5aebe5736a5d0a431a9b85f53a9d17 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 2 Jul 2016 00:27:05 +0200 Subject: DM: Massive renaming in gfx.h --- engines/dm/champion.cpp | 82 ++--- engines/dm/champion.h | 2 +- engines/dm/dm.cpp | 10 +- engines/dm/dungeonman.cpp | 32 +- engines/dm/dungeonman.h | 2 +- engines/dm/eventman.cpp | 18 +- engines/dm/gfx.cpp | 823 +++++++++++++++++++++++----------------------- engines/dm/gfx.h | 507 ++++++++++++++-------------- engines/dm/inventory.cpp | 62 ++-- engines/dm/menus.cpp | 58 ++-- engines/dm/objectman.cpp | 16 +- engines/dm/text.cpp | 6 +- engines/dm/text.h | 2 +- 13 files changed, 819 insertions(+), 801 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 730eaa2985..fb2515bd63 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -118,10 +118,10 @@ int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) { void ChampionMan::drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) { Common::String tmp = getStringFromInteger(currVal, true, 3).c_str(); - _vm->_textMan->printToViewport(55, posY, kColorLightestGray, tmp.c_str()); - _vm->_textMan->printToViewport(73, posY, kColorLightestGray, "/"); + _vm->_textMan->printToViewport(55, posY, k13_ColorLightestGray, tmp.c_str()); + _vm->_textMan->printToViewport(73, posY, k13_ColorLightestGray, "/"); tmp = getStringFromInteger(maxVal, true, 3); - _vm->_textMan->printToViewport(79, posY, kColorLightestGray, tmp.c_str()); + _vm->_textMan->printToViewport(79, posY, k13_ColorLightestGray, tmp.c_str()); } uint16 ChampionMan::handSlotIndex(uint16 slotBoxIndex) { @@ -458,18 +458,18 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { uint16 prevChampCount = _partyChampionCount; Champion *champ = &_champions[prevChampCount]; champ->resetToZero(); - dispMan._useByteBoxCoordinates = true; + dispMan._g578_useByteBoxCoordinates = true; { // limit destBox scope Box &destBox = gBoxChampionPortrait; - dispMan.blitToBitmap(dispMan.getBitmap(kChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), - champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, kColorNoTransparency); + dispMan.blitToBitmap(dispMan.getBitmap(k26_ChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), + champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, k255_ColorNoTransparency); } champ->_actionIndex = kChampionActionNone; champ->_enableActionEventIndex = -1; champ->_hideDamageReceivedIndex = -1; champ->_dir = dunMan._currMap._partyDir; - ViewCell AL_0_viewCell = kViewCellFronLeft; + ViewCell AL_0_viewCell = k0_ViewCellFronLeft; while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone) AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3); @@ -732,26 +732,26 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { return; } bool isInventoryChamp = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal); - dispMan._useByteBoxCoordinates = false; + dispMan._g578_useByteBoxCoordinates = false; if (champAttributes & kChampionAttributeStatusBox) { box._y1 = 0; box._y2 = 28 + 1; box._x1 = champStatusBoxX; box._x2 = box._x1 + 66 + 1; if (champ->_currHealth) { - dispMan.clearScreenBox(kColorDarkestGray, box); + dispMan.clearScreenBox(k12_ColorDarkestGray, box); int16 nativeBitmapIndices[3]; for (int16 i = 0; i < 3; ++i) nativeBitmapIndices[i] = 0; int16 AL_0_borderCount = 0; if (_party._fireShieldDefense > 0) - nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyFireshieldIndice; + nativeBitmapIndices[AL_0_borderCount++] = k38_BorderPartyFireshieldIndice; if (_party._spellShieldDefense > 0) - nativeBitmapIndices[AL_0_borderCount++] = kBorderPartySpellshieldIndice; + nativeBitmapIndices[AL_0_borderCount++] = k39_BorderPartySpellshieldIndice; if (_party._shieldDefense > 0) - nativeBitmapIndices[AL_0_borderCount++] = kBorderPartyShieldIndice; + nativeBitmapIndices[AL_0_borderCount++] = k37_BorderPartyShieldIndice; while (AL_0_borderCount--) { - dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, kColorFlesh); + dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, k10_ColorFlesh); } if (isInventoryChamp) { invMan.drawStatusBoxPortrait(champIndex); @@ -760,8 +760,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { champAttributes |= (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeWounds | kChampionAttributeActionHand); } } else { - dispMan.blitToScreen(dispMan.getBitmap(kStatusBoxDeadChampion), 80, 0, 0, box, kColorNoTransparency); - _vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, kColorLightestGray, kColorDarkGary, champ->_name); + dispMan.blitToScreen(dispMan.getBitmap(k8_StatusBoxDeadChampion), 80, 0, 0, box, k255_ColorNoTransparency); + _vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, champ->_name); menuMan.drawActionIcon(champIndex); goto T0292042_green; } @@ -771,7 +771,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { goto T0292042_green; if (champAttributes & kChampionAttributeNameTitle) { - Color AL_0_colorIndex = (champIndex == _leaderIndex) ? kColorGold : kColorLightestGray; // unused because of missing functions + Color AL_0_colorIndex = (champIndex == _leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; // unused because of missing functions if (isInventoryChamp) { char *champName = champ->_name; _vm->_textMan->printToViewport(3, 7, AL_0_colorIndex, champName); @@ -787,8 +787,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { box._y2 = 6 + 1; box._x1 = champStatusBoxX; box._x2 = box._x1 + 42 + 1; - dispMan.clearScreenBox(kColorDarkGary, box); - _vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, kColorDarkGary, champ->_name); + dispMan.clearScreenBox(k1_ColorDarkGary, box); + _vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, k1_ColorDarkGary, champ->_name); } } @@ -798,20 +798,20 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { drawHealthStaminaManaValues(champ); int16 AL_2_nativeBitmapIndex; if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) { - AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice; + AL_2_nativeBitmapIndex = k34_SlotBoxWoundedIndice; } else { - AL_2_nativeBitmapIndex = kSlotBoxNormalIndice; + AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; } - dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, kColorDarkestGray, gDungeonViewport); - AL_2_nativeBitmapIndex = kSlotBoxNormalIndice; + dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, k12_ColorDarkestGray, gDungeonViewport); + AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) { if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent) < champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum)) { - AL_2_nativeBitmapIndex = kSlotBoxWoundedIndice; + AL_2_nativeBitmapIndex = k34_SlotBoxWoundedIndice; break; } } - dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, kColorDarkestGray, gDungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, k12_ColorDarkestGray, gDungeonViewport); champAttributes |= kChampionAttributeViewport; } } @@ -829,11 +829,11 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { Color loadColor; int16 champMaxLoad = getMaximumLoad(champ); if (champ->_load > champMaxLoad) { - loadColor = kColorRed; + loadColor = k8_ColorRed; } else if (((int32)champ->_load) * 8 > ((int32)champMaxLoad) * 5) { - loadColor = kColorYellow; + loadColor = k11_ColorYellow; } else { - loadColor = kColorLightestGray; + loadColor = k13_ColorLightestGray; } _vm->_textMan->printToViewport(104, 132, loadColor, "LOAD "); @@ -852,10 +852,10 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { { // block so goto won't skip AL_0_championIconIndex initialization int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir); - if ((champAttributes & kChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) { + if ((champAttributes & k28_ChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) { dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]); - dispMan.blitToScreen(dispMan.getBitmap(kChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0, - gBoxChampionIcons[AL_0_championIconIndex], kColorDarkestGray); + dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0, + gBoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray); } } @@ -942,9 +942,9 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { iconIndex = kIconIndiceReadyHand + (slotIndex << 1); if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) { iconIndex++; - nativeBitmapIndex = kSlotBoxWoundedIndice; + nativeBitmapIndex = k34_SlotBoxWoundedIndice; } else { - nativeBitmapIndex = kSlotBoxNormalIndice; + nativeBitmapIndex = k33_SlotBoxNormalIndice; } } else { if ((slotIndex >= kChampionSlotNeck) && (slotIndex <= kChampionSlotBackpackLine_1_1)) { @@ -962,21 +962,21 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { } // BUG2_00 if (slotIndex <= kChampionSlotFeet) { if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) { - nativeBitmapIndex = kSlotBoxWoundedIndice; + nativeBitmapIndex = k34_SlotBoxWoundedIndice; } else { - nativeBitmapIndex = kSlotBoxNormalIndice; + nativeBitmapIndex = k33_SlotBoxNormalIndice; } } } if ((slotIndex == kChampionSlotActionHand) && (_vm->indexToOrdinal(champIndex) == _actingChampionOrdinal)) { - nativeBitmapIndex = kSlotBoxActingHandIndice; + nativeBitmapIndex = k35_SlotBoxActingHandIndice; } if (nativeBitmapIndex != -1) { - _vm->_displayMan->_useByteBoxCoordinates = false; + _vm->_displayMan->_g578_useByteBoxCoordinates = false; _vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0, - box, kColorDarkestGray, isInventoryChamp ? gDungeonViewport : gDefultViewPort); + box, k12_ColorDarkestGray, isInventoryChamp ? gDungeonViewport : gDefultViewPort); } _vm->_objectMan->drawIconInSlotBox(slotBoxIndex, iconIndex); @@ -998,10 +998,10 @@ void ChampionMan::renameChampion(Champion* champ) { box._x1 = 3; box._x2 = box._x1 + 167; - dispMan.clearScreenBox(kColorDarkestGray, box, gDungeonViewport); - dispMan.blitToScreen(dispMan.getBitmap(kPanelRenameChampionIndice), 144, 0, 0, gBoxPanel, kColorCyan, gDungeonViewport); - textMan.printToViewport(177, 58, kColorLightestGray, "_______"); - textMan.printToViewport(105, 76, kColorLightestGray, "___________________"); + dispMan.clearScreenBox(k12_ColorDarkestGray, box, gDungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, gBoxPanel, k4_ColorCyan, gDungeonViewport); + textMan.printToViewport(177, 58, k13_ColorLightestGray, "_______"); + textMan.printToViewport(105, 76, k13_ColorLightestGray, "___________________"); Common::Point clickPos; static Box okButtonBox(197, 215, 147, 155); // inclusive boundaries, constructor adds +1 for (;;) { diff --git a/engines/dm/champion.h b/engines/dm/champion.h index e0390a4937..c1abca1888 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -408,7 +408,7 @@ public: memset(_name, '\0', 8); memset(_title, '\0', 20); _dir = kDirNorth; - _cell = kViewCellFronLeft; + _cell = k0_ViewCellFronLeft; _actionIndex = kChampionActionN; _symbolStep = 0; memset(_symbols, '\0', 5); diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 66a11250e8..be8da8b4b6 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -144,7 +144,7 @@ DMEngine::~DMEngine() { void DMEngine::initializeGame() { _displayMan->loadGraphics(); // DUMMY CODE: next line - _displayMan->loadPalette(gPalCredits); + _displayMan->loadPalette(g19_PalCredits); _eventMan->initMouse(); @@ -152,8 +152,8 @@ void DMEngine::initializeGame() { warning("TODO: F0441_STARTEND_ProcessEntrance"); } - _displayMan->loadFloorSet(kFloorSetStone); - _displayMan->loadWallSet(kWallSetStone); + _displayMan->loadFloorSet(k0_FloorSetStone); + _displayMan->loadWallSet(k0_WallSetStone); _objectMan->loadObjectNames(); startGame(); @@ -184,7 +184,7 @@ void DMEngine::startGame() { if (!_dungeonMan->_messages._newGame) { warning("TODO: loading game"); } else { - _displayMan->_useByteBoxCoordinates = false; + _displayMan->_g578_useByteBoxCoordinates = false; warning("TODO: clear screen"); } @@ -253,7 +253,7 @@ void DMEngine::gameloop() { if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) { Box box(0, 224, 0, 126); - _displayMan->clearScreenBox(kColorBlack, box, gDungeonViewport); // dummy code + _displayMan->clearScreenBox(k0_ColorBlack, box, gDungeonViewport); // dummy code _displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY); } // DUMMY CODE: next line diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 8d5c99bde5..1d74bec094 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -328,7 +328,7 @@ WeaponInfo gWeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo WeaponInfo(30, 26, 1, 220, 0x207D), /* SPEEDBOW */ WeaponInfo(36, 255, 100, 50, 0x20FF)}; /* THE FIRESTAFF */ -CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo +CreatureInfo gCreatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo /* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo, MovementTicks, AttackTicks, Defense, BaseHealth, Attack, PoisonAttack, Dexterity, Ranges, Properties, Resistances, AnimationTicks, WoundProbabilities, AttackType } */ @@ -742,19 +742,19 @@ void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) { setCurrentMap(mapIndex); byte *metaMapData = _currMap._data[_currMap._width - 1] + _currMap._height; - _vm->_displayMan->_currMapAllowedCreatureTypes = metaMapData; + _vm->_displayMan->_g264_currMapAllowedCreatureTypes = metaMapData; metaMapData += _currMap._map->_creatureTypeCount; - memcpy(_vm->_displayMan->_currMapWallOrnIndices, metaMapData, _currMap._map->_wallOrnCount); + memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _currMap._map->_wallOrnCount); metaMapData += _currMap._map->_wallOrnCount; - memcpy(_vm->_displayMan->_currMapFloorOrnIndices, metaMapData, _currMap._map->_floorOrnCount); + memcpy(_vm->_displayMan->_g262_currMapFloorOrnIndices, metaMapData, _currMap._map->_floorOrnCount); metaMapData += _currMap._map->_wallOrnCount; - memcpy(_vm->_displayMan->_currMapDoorOrnIndices, metaMapData, _currMap._map->_doorOrnCount); + memcpy(_vm->_displayMan->_g263_currMapDoorOrnIndices, metaMapData, _currMap._map->_doorOrnCount); _currMapInscriptionWallOrnIndex = _currMap._map->_wallOrnCount; - _vm->_displayMan->_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = kWallOrnInscription; + _vm->_displayMan->_g261_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = k0_WallOrnInscription; } @@ -817,7 +817,7 @@ Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) { // TODO: get rid of the GOTOs void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) { // complete, except where marked - _vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75, possible fix + _vm->_displayMan->_g289_championPortraitOrdinal = 0; // BUG0_75, possible fix for (uint16 i = 0; i < 5; ++i) aspectArray[i] = 0; @@ -868,13 +868,13 @@ T0172010_ClosedFakeWall: if (thing.getType() == kTextstringType) { if (TextString(getThingData(thing)).isVisible()) { aspectArray[sideIndex + 1] = _currMapInscriptionWallOrnIndex + 1; - _vm->_displayMan->_inscriptionThing = thing; // BUG0_76 + _vm->_displayMan->_g290_inscriptionThing = thing; // BUG0_76 } } else { Sensor sensor(getThingData(thing)); aspectArray[sideIndex + 1] = sensor.getOrnOrdinal(); if (sensor.getType() == kSensorWallChampionPortrait) { - _vm->_displayMan->_championPortraitOrdinal = _vm->indexToOrdinal(sensor.getData()); + _vm->_displayMan->_g289_championPortraitOrdinal = _vm->indexToOrdinal(sensor.getData()); } } } @@ -978,8 +978,8 @@ int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) { if (wallOrnIndex >= 0) - for (uint16 i = 0; i < kAlcoveOrnCount; ++i) - if (_vm->_displayMan->_currMapAlcoveOrnIndices[i] == wallOrnIndex) + for (uint16 i = 0; i < k3_AlcoveOrnCount; ++i) + if (_vm->_displayMan->_g267_currMapAlcoveOrnIndices[i] == wallOrnIndex) return true; return false; } @@ -1307,15 +1307,15 @@ int16 DungeonMan::getProjectileAspect(Thing thing) { if ((thingType = thing.getType()) == kExplosionThingType) { if (thing == Thing::_explFireBall) - return -_vm->indexToOrdinal(kProjectileAspectExplosionFireBall); + return -_vm->indexToOrdinal(k10_ProjectileAspectExplosionFireBall); if (thing == Thing::_explSlime) - return -_vm->indexToOrdinal(kProjectileAspectExplosionSlime); + return -_vm->indexToOrdinal(k12_ProjectileAspectExplosionSlime); if (thing == Thing::_explLightningBolt) - return -_vm->indexToOrdinal(kProjectileAspectExplosionLightningBolt); + return -_vm->indexToOrdinal(k3_ProjectileAspectExplosionLightningBolt); if ((thing == Thing::_explPoisonBolt) || (thing == Thing::_explPoisonCloud)) - return -_vm->indexToOrdinal(kProjectileAspectExplosionPoisonBoltCloud); + return -_vm->indexToOrdinal(k13_ProjectileAspectExplosionPoisonBoltCloud); - return -_vm->indexToOrdinal(kProjectileAspectExplosionDefault); + return -_vm->indexToOrdinal(k11_ProjectileAspectExplosionDefault); } else if (thingType == kWeaponThingType) { weaponInfo = getWeaponInfo(thing); if (projAspOrd = weaponInfo->getProjectileAspectOrdinal()) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index df56ec229b..b3f81d8746 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -202,7 +202,7 @@ struct CreatureInfo { }; // @ CREATURE_INFO -extern CreatureInfo gCreatureInfo[kCreatureTypeCount]; +extern CreatureInfo gCreatureInfo[k27_CreatureTypeCount]; class Door { Thing _nextThing; diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index e9abf94809..1adb396ab9 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -529,7 +529,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir]; if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() && - dunMan._dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { + dunMan._dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { _vm->_stopWaitingForPlayerInput = true; warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); warning("MISSING CODE: F0268_SENSOR_AddEvent"); @@ -541,9 +541,9 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY } if (champMan._leaderEmptyHanded) { - for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellDoorButtonOrWallOrn; viewCell++) { + for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k5_ViewCellDoorButtonOrWallOrn; viewCell++) { if (dunMan._dungeonViewClickableBoxes[viewCell].isPointInside(Common::Point(posX, posY - 33))) { - if (viewCell == kViewCellDoorButtonOrWallOrn) { + if (viewCell == k5_ViewCellDoorButtonOrWallOrn) { if (!dunMan._isFacingAlcove) { commandProcessType80ClickInDungeonViewTouchFrontWall(); } @@ -557,14 +557,14 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY Thing thing = champMan._leaderHandObject; uint16 *rawThingPointer = dunMan.getThingData(thing); if (dunMan._squareAheadElement == kElementTypeWall) { - for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellFrontRight; ++viewCell) { + for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k1_ViewCellFrontRight; ++viewCell) { if (gBoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) { warning("F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject"); return; } } - if (dunMan._dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { + if (dunMan._dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { if (dunMan._isFacingAlcove) { warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject"); } else { @@ -587,7 +587,7 @@ T0377019: } } else { warning("MISSING CODE: F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown in if branch"); - for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellBackLeft; viewCell++) { + for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k3_ViewCellBackLeft; viewCell++) { if (gBoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) { warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject"); return; @@ -618,9 +618,9 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane box._y2 = 28 + 1; box._x1 = championIndex * kChampionStatusBoxSpacing; box._x2 = box._x1 + 66 + 1; - dispMan._useByteBoxCoordinates = false; - dispMan.clearScreenBox(kColorBlack, box); - dispMan.clearScreenBox(kColorBlack, gBoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._partyDir) * 2]); + dispMan._g578_useByteBoxCoordinates = false; + dispMan.clearScreenBox(k0_ColorBlack, box); + dispMan.clearScreenBox(k0_ColorBlack, gBoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._partyDir) * 2]); warning("F0457_START_DrawEnabledMenus_CPSF"); warning("F0078_MOUSE_ShowPointer"); return; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index ce31c499f5..f6b1b0271a 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -121,11 +121,11 @@ FieldAspect gFieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects FieldAspect(0, 63, 0x0A, 0x83, 16, 136, 0, 64), /* D0L */ FieldAspect(0, 63, 0x0A, 0x03, 16, 136, 0, 64)}; /* D0R */ -Box gBoxMovementArrows = Box(224, 319, 124, 168); +Box g2_BoxMovementArrows = Box(224, 319, 124, 168); byte gPalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke -ExplosionAspect gExplosionAspects[kExplosionAspectCount] = { // @ G0211_as_Graphic558_ExplosionAspects +ExplosionAspect g211_ExplosionAspects[k4_ExplosionAspectCount] = { // @ G0211_as_Graphic558_ExplosionAspects /* { ByteWidth, Height } */ ExplosionAspect(80, 111), /* Fire */ ExplosionAspect(64, 97), /* Spell */ @@ -134,7 +134,7 @@ ExplosionAspect(80, 91)}; /* Death */ #define kDerivedBitmapMaximumCount 730 // @ C730_DERIVED_BITMAP_MAXIMUM_COUNT -byte gProjectileScales[7] = { +byte g215_ProjectileScales[7] = { 13, /* D4 Back */ 16, /* D4 Front */ 19, /* D3 Back */ @@ -490,39 +490,39 @@ byte gWallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoord 6, /* Wall Ornament 58 Amalgam (Without Gem) */ 7}; /* Wall Ornament 59 Lord Order (Outside) */ -CreatureAspect gCreatureAspects[kCreatureTypeCount] = { // @ G0219_as_Graphic558_CreatureAspects -/* { FirstNativeBitmapRelativeIndex, FirstDerivedBitmapIndex, pixelWidthFront, HeightFront, -pixelWidthSide, HeightSide, pixelWidthAttack, HeightAttack, CoordinateSet / TransparentColor, -Replacement Color Set Index for color 10 / Replacement Color Set Index for color 9 } */ - {0, 0, 56 * 2, 84, 56 * 2, 84, 56 * 2, 84, 0x1D, 0x01}, /* Creature #00 Giant Scorpion / Scorpion */ - {4, 0, 32 * 2, 66, 0 * 2, 0, 32 * 2, 69, 0x0B, 0x20}, /* Creature #01 Swamp Slime / Slime Devil */ - {6, 0, 24 * 2, 48, 24 * 2, 48, 0 * 2, 0, 0x0B, 0x00}, /* Creature #02 Giggler */ - {10, 0, 32 * 2, 61, 0 * 2, 0, 32 * 2, 61, 0x24, 0x31}, /* Creature #03 Wizard Eye / Flying Eye */ - {12, 0, 32 * 2, 64, 56 * 2, 64, 32 * 2, 64, 0x14, 0x34}, /* Creature #04 Pain Rat / Hellhound */ - {16, 0, 24 * 2, 49, 40 * 2, 49, 0 * 2, 0, 0x18, 0x34}, /* Creature #05 Ruster */ - {19, 0, 32 * 2, 60, 0 * 2, 0, 32 * 2, 60, 0x0D, 0x00}, /* Creature #06 Screamer */ - {21, 0, 32 * 2, 43, 0 * 2, 0, 32 * 2, 64, 0x04, 0x00}, /* Creature #07 Rockpile / Rock pile */ - {23, 0, 32 * 2, 83, 0 * 2, 0, 32 * 2, 93, 0x04, 0x00}, /* Creature #08 Ghost / Rive */ - {25, 0, 32 * 2, 101, 32 * 2, 101, 32 * 2, 101, 0x14, 0x00}, /* Creature #09 Stone Golem */ - {29, 0, 32 * 2, 82, 32 * 2, 82, 32 * 2, 83, 0x04, 0x00}, /* Creature #10 Mummy */ - {33, 0, 32 * 2, 80, 0 * 2, 0, 32 * 2, 99, 0x14, 0x00}, /* Creature #11 Black Flame */ - {35, 0, 32 * 2, 80, 32 * 2, 80, 32 * 2, 76, 0x04, 0x00}, /* Creature #12 Skeleton */ - {39, 0, 32 * 2, 96, 56 * 2, 93, 32 * 2, 90, 0x1D, 0x20}, /* Creature #13 Couatl */ - {43, 0, 32 * 2, 49, 16 * 2, 49, 32 * 2, 56, 0x04, 0x30}, /* Creature #14 Vexirk */ - {47, 0, 32 * 2, 59, 56 * 2, 43, 32 * 2, 67, 0x14, 0x78}, /* Creature #15 Magenta Worm / Worm */ - {51, 0, 32 * 2, 83, 32 * 2, 74, 32 * 2, 74, 0x04, 0x65}, /* Creature #16 Trolin / Ant Man */ - {55, 0, 24 * 2, 49, 24 * 2, 53, 24 * 2, 53, 0x24, 0x00}, /* Creature #17 Giant Wasp / Muncher */ - {59, 0, 32 * 2, 89, 32 * 2, 89, 32 * 2, 89, 0x04, 0x00}, /* Creature #18 Animated Armour / Deth Knight */ - {63, 0, 32 * 2, 84, 32 * 2, 84, 32 * 2, 84, 0x0D, 0xA9}, /* Creature #19 Materializer / Zytaz */ - {67, 0, 56 * 2, 27, 0 * 2, 0, 56 * 2, 80, 0x04, 0x65}, /* Creature #20 Water Elemental */ - {69, 0, 56 * 2, 77, 56 * 2, 81, 56 * 2, 77, 0x04, 0xA9}, /* Creature #21 Oitu */ - {73, 0, 32 * 2, 87, 32 * 2, 89, 32 * 2, 89, 0x04, 0xCB}, /* Creature #22 Demon */ - {77, 0, 32 * 2, 96, 32 * 2, 94, 32 * 2, 96, 0x04, 0x00}, /* Creature #23 Lord Chaos */ - {81, 0, 64 * 2, 94, 72 * 2, 94, 64 * 2, 94, 0x04, 0xCB}, /* Creature #24 Red Dragon / Dragon */ - {85, 0, 32 * 2, 93, 0 * 2, 0, 0 * 2, 0, 0x04, 0xCB}, /* Creature #25 Lord Order */ - {86, 0, 32 * 2, 93, 0 * 2, 0, 0 * 2, 0, 0x04, 0xCB}}; /* Creature #26 Grey Lord */ - -ObjectAspect gObjectAspects[kObjAspectCount] = { // @ G0209_as_Graphic558_ObjectAspects +CreatureAspect gCreatureAspects[k27_CreatureTypeCount] = { // @ G0219_as_Graphic558_CreatureAspects + /* { FirstNativeBitmapRelativeIndex, FirstDerivedBitmapIndex, pixelWidthFront, HeightFront, + pixelWidthSide, HeightSide, pixelWidthAttack, HeightAttack, CoordinateSet / TransparentColor, + Replacement Color Set Index for color 10 / Replacement Color Set Index for color 9 } */ + CreatureAspect(0, 0, 56 , 84, 56 , 84, 56 , 84, 0x1D, 0x01), /* Creature #00 Giant Scorpion / Scorpion */ + CreatureAspect(4, 0, 32 , 66, 0 , 0, 32 , 69, 0x0B, 0x20), /* Creature #01 Swamp Slime / Slime Devil */ + CreatureAspect(6, 0, 24 , 48, 24 , 48, 0 , 0, 0x0B, 0x00), /* Creature #02 Giggler */ + CreatureAspect(10, 0, 32 , 61, 0 , 0, 32 , 61, 0x24, 0x31), /* Creature #03 Wizard Eye / Flying Eye */ + CreatureAspect(12, 0, 32 , 64, 56 , 64, 32 , 64, 0x14, 0x34), /* Creature #04 Pain Rat / Hellhound */ + CreatureAspect(16, 0, 24 , 49, 40 , 49, 0 , 0, 0x18, 0x34), /* Creature #05 Ruster */ + CreatureAspect(19, 0, 32 , 60, 0 , 0, 32 , 60, 0x0D, 0x00), /* Creature #06 Screamer */ + CreatureAspect(21, 0, 32 , 43, 0 , 0, 32 , 64, 0x04, 0x00), /* Creature #07 Rockpile / Rock pile */ + CreatureAspect(23, 0, 32 , 83, 0 , 0, 32 , 93, 0x04, 0x00), /* Creature #08 Ghost / Rive */ + CreatureAspect(25, 0, 32 , 101, 32 , 101, 32 , 101, 0x14, 0x00), /* Creature #09 Stone Golem */ + CreatureAspect(29, 0, 32 , 82, 32 , 82, 32 , 83, 0x04, 0x00), /* Creature #10 Mummy */ + CreatureAspect(33, 0, 32 , 80, 0 , 0, 32 , 99, 0x14, 0x00), /* Creature #11 Black Flame */ + CreatureAspect(35, 0, 32 , 80, 32 , 80, 32 , 76, 0x04, 0x00), /* Creature #12 Skeleton */ + CreatureAspect(39, 0, 32 , 96, 56 , 93, 32 , 90, 0x1D, 0x20), /* Creature #13 Couatl */ + CreatureAspect(43, 0, 32 , 49, 16 , 49, 32 , 56, 0x04, 0x30), /* Creature #14 Vexirk */ + CreatureAspect(47, 0, 32 , 59, 56 , 43, 32 , 67, 0x14, 0x78), /* Creature #15 Magenta Worm / Worm */ + CreatureAspect(51, 0, 32 , 83, 32 , 74, 32 , 74, 0x04, 0x65), /* Creature #16 Trolin / Ant Man */ + CreatureAspect(55, 0, 24 , 49, 24 , 53, 24 , 53, 0x24, 0x00), /* Creature #17 Giant Wasp / Muncher */ + CreatureAspect(59, 0, 32 , 89, 32 , 89, 32 , 89, 0x04, 0x00), /* Creature #18 Animated Armour / Deth Knight */ + CreatureAspect(63, 0, 32 , 84, 32 , 84, 32 , 84, 0x0D, 0xA9), /* Creature #19 Materializer / Zytaz */ + CreatureAspect(67, 0, 56 , 27, 0 , 0, 56 , 80, 0x04, 0x65), /* Creature #20 Water Elemental */ + CreatureAspect(69, 0, 56 , 77, 56 , 81, 56 , 77, 0x04, 0xA9), /* Creature #21 Oitu */ + CreatureAspect(73, 0, 32 , 87, 32 , 89, 32 , 89, 0x04, 0xCB), /* Creature #22 Demon */ + CreatureAspect(77, 0, 32 , 96, 32 , 94, 32 , 96, 0x04, 0x00), /* Creature #23 Lord Chaos */ + CreatureAspect(81, 0, 64 , 94, 72 , 94, 64 , 94, 0x04, 0xCB), /* Creature #24 Red Dragon / Dragon */ + CreatureAspect(85, 0, 32 , 93, 0 , 0, 0 , 0, 0x04, 0xCB), /* Creature #25 Lord Order */ + CreatureAspect(86, 0, 32 , 93, 0 , 0, 0 , 0, 0x04, 0xCB)}; /* Creature #26 Grey Lord */ + +ObjectAspect gObjectAspects[k85_ObjAspectCount] = { // @ G0209_as_Graphic558_ObjectAspects /* FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo, CoordinateSet */ ObjectAspect(0, 0, 24, 27, 0x11, 0), ObjectAspect(2, 6, 24, 8, 0x00, 1), @@ -611,7 +611,7 @@ ObjectAspect gObjectAspects[kObjAspectCount] = { // @ G0209_as_Graphic558_Object ObjectAspect(85, 176, 32, 17, 0x00, 0) }; -ProjectileAspect gProjectileAspect[kProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects +ProjectileAspect gProjectileAspect[k14_ProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects /* ProjectileAspect( FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo ) */ ProjectileAspect(0, 0, 32, 11, 0x0011), /* Arrow */ ProjectileAspect(3, 18, 16, 11, 0x0011), /* Dagger */ @@ -632,13 +632,13 @@ ProjectileAspect gProjectileAspect[kProjectileAspectCount] = { // @ G0210_as_Gra // TODO: this is ONLY for the Amiga version, name will have to be refactored /* Identical to the palette at the end of the swoosh palette animation */ -uint16 gPalSwoosh[16] = {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}; // @ K0057_aui_Palette_Swoosh -uint16 gPalMousePointer[16] = {0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF}; // @ K0150_aui_Palette_MousePointer +uint16 gK57_PalSwoosh[16] = {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}; // @ K0057_aui_Palette_Swoosh +uint16 gK150_PalMousePointer[16] = {0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x000, 0xAAA, 0x00F, 0xFFF}; // @ K0150_aui_Palette_MousePointer /* Atari ST: { 0x003, 0x055, 0x773, 0x420, 0x774, 0x000, 0x040, 0x500, 0x642, 0x775, 0x742, 0x760, 0x750, 0x000, 0x310, 0x776 }, RGB colors are different */ -uint16 gPalCredits[16] = {0x006, 0x0AA, 0xFF6, 0x840, 0xFF8, 0x000, 0x080, 0xA00, 0xC84, 0xFFA, 0xF84, 0xFC0, 0xFA0, 0x000, 0x620, 0xFFC}; // @ G0019_aui_Graphic562_Palette_Credits +uint16 g19_PalCredits[16] = {0x006, 0x0AA, 0xFF6, 0x840, 0xFF8, 0x000, 0x080, 0xA00, 0xC84, 0xFFA, 0xF84, 0xFC0, 0xFA0, 0x000, 0x620, 0xFFC}; // @ G0019_aui_Graphic562_Palette_Credits /* Atari ST: { 0x000, 0x333, 0x444, 0x420, 0x654, 0x210, 0x040, 0x050, 0x432, 0x700, 0x543, 0x321, 0x222, 0x555, 0x310, 0x777 }, RGB colors are different */ -uint16 gPalEntrance[16] = {0x000, 0x666, 0x888, 0x840, 0xCA8, 0x0C0, 0x080, 0x0A0, 0x864, 0xF00, 0xA86, 0x642, 0x444, 0xAAA, 0x620, 0xFFF}; // @ G0020_aui_Graphic562_Palette_Entrance -uint16 gPalDungeonView[6][16] = { // @ G0021_aaui_Graphic562_Palette_DungeonView +uint16 g20_PalEntrance[16] = {0x000, 0x666, 0x888, 0x840, 0xCA8, 0x0C0, 0x080, 0x0A0, 0x864, 0xF00, 0xA86, 0x642, 0x444, 0xAAA, 0x620, 0xFFF}; // @ G0020_aui_Graphic562_Palette_Entrance +uint16 g21_PalDungeonView[6][16] = { // @ G0021_aaui_Graphic562_Palette_DungeonView /* Atari ST: { 0x000, 0x333, 0x444, 0x310, 0x066, 0x420, 0x040, 0x060, 0x700, 0x750, 0x643, 0x770, 0x222, 0x555, 0x007, 0x777 }, RGB colors are different */ 0x000, 0x666, 0x888, 0x620, 0x0CC, 0x840, 0x080, 0x0C0, 0xF00, 0xFA0, 0xC86, 0xFF0, 0x444, 0xAAA, 0x00F, 0xFFF, /* Atari ST: { 0x000, 0x222, 0x333, 0x310, 0x066, 0x410, 0x030, 0x050, 0x600, 0x640, 0x532, 0x760, 0x111, 0x444, 0x006, 0x666 }, RGB colors are different */ @@ -684,8 +684,8 @@ byte gPalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110 byte gPalChangesFloorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 140, 130}; // @ G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3 byte gPalChangesFloorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2 -int gFountainOrnIndices[kFountainOrnCount] = {35}; // @ G0193_ai_Graphic558_FountainOrnamentIndices -byte gAlcoveOrnIndices[kAlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrnamentIndices +int gFountainOrnIndices[k1_FountainOrnCount] = {35}; // @ G0193_ai_Graphic558_FountainOrnamentIndices +byte gAlcoveOrnIndices[k3_AlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrnamentIndices 1, /* Square Alcove */ 2, /* Vi Altar */ 3}; /* Arched Alcove */ @@ -698,52 +698,49 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _packedItemPos = nullptr; _packedBitmaps = nullptr; _bitmaps = nullptr; - _tmpBitmap = nullptr; - _floorBitmap = nullptr; - _ceilingBitmap = nullptr; - _currMapAllowedCreatureTypes = nullptr; - _derivedBitmapByteCount = nullptr; - _derivedBitmaps = nullptr; + _g74_tmpBitmap = nullptr; + _g84_floorBitmap = nullptr; + _g85_ceilingBitmap = nullptr; + _g264_currMapAllowedCreatureTypes = nullptr; + _g639_derivedBitmapByteCount = nullptr; + _g638_derivedBitmaps = nullptr; _screenWidth = _screenHeight = 0; - _championPortraitOrdinal = 0; - _currMapViAltarIndex = 0; + _g289_championPortraitOrdinal = 0; + _g266_currMapViAltarIndex = 0; for (int i = 0; i < 25; i++) _wallSetBitMaps[i] = nullptr; - //for (int i = 0; i < kStairsGraphicCount; i++) - // _stairIndices[i] = 0; - for (int i = 0; i < 4; i++) - _palChangesProjectile[i] = nullptr; + _g75_palChangesProjectile[i] = nullptr; - for (int i = 0; i < kAlcoveOrnCount; i++) - _currMapAlcoveOrnIndices[i] = 0; + for (int i = 0; i < k3_AlcoveOrnCount; i++) + _g267_currMapAlcoveOrnIndices[i] = 0; - for (int i = 0; i < kFountainOrnCount; i++) - _currMapFountainOrnIndices[i] = 0; + for (int i = 0; i < k1_FountainOrnCount; i++) + _g268_currMapFountainOrnIndices[i] = 0; for (int i = 0; i < 2; i++) { for (int j = 0; j < 16; j++) { - _currMapWallOrnInfo[j][i] = 0; - _currMapFloorOrnInfo[j][i] = 0; + _g101_currMapWallOrnInfo[j][i] = 0; + _g102_currMapFloorOrnInfo[j][i] = 0; } for (int j = 0; j < 17; j++) { - _currMapDoorOrnInfo[j][i] = 0; + _g103_currMapDoorOrnInfo[j][i] = 0; } } for (int i = 0; i < 16; i++) { - _currMapWallOrnIndices[i] = 0; - _currMapFloorOrnIndices[i] = 0; + _g261_currMapWallOrnIndices[i] = 0; + _g262_currMapFloorOrnIndices[i] = 0; } for (int i = 0; i < 18; i++) - _currMapDoorOrnIndices[i] = 0; + _g263_currMapDoorOrnIndices[i] = 0; - _inscriptionThing = Thing::_none; - _useByteBoxCoordinates = false; + _g290_inscriptionThing = Thing::_none; + _g578_useByteBoxCoordinates = false; } DisplayMan::~DisplayMan() { @@ -759,22 +756,22 @@ DisplayMan::~DisplayMan() { for (uint16 i = kWall_D0L_Flipped; i <= kWall_D3LCR_Flipped; ++i) delete[] _wallSetBitMaps[i]; - delete[] _derivedBitmapByteCount; - if (_derivedBitmaps) { + delete[] _g639_derivedBitmapByteCount; + if (_g638_derivedBitmaps) { for (uint16 i = 0; i < kDerivedBitmapMaximumCount; ++i) - delete[] _derivedBitmaps; - delete[] _derivedBitmaps; + delete[] _g638_derivedBitmaps; + delete[] _g638_derivedBitmaps; } } void DisplayMan::setUpScreens(uint16 width, uint16 height) { _screenWidth = width; _screenHeight = height; - delete[] _tmpBitmap; - _tmpBitmap = new byte[_screenWidth * _screenHeight]; + delete[] _g74_tmpBitmap; + _g74_tmpBitmap = new byte[_screenWidth * _screenHeight]; delete[] _vgaBuffer; _vgaBuffer = new byte[_screenWidth * _screenHeight]; - clearScreen(kColorBlack); + clearScreen(k0_ColorBlack); } void DisplayMan::loadGraphics() { @@ -799,128 +796,128 @@ void DisplayMan::loadGraphics() { unpackGraphics(); - loadFloorSet(kFloorSetStone); - loadWallSet(kWallSetStone); + loadFloorSet(k0_FloorSetStone); + loadWallSet(k0_WallSetStone); - if (!_derivedBitmapByteCount) - _derivedBitmapByteCount = new uint16[kDerivedBitmapMaximumCount]; - if (!_derivedBitmaps) { - _derivedBitmaps = new byte*[kDerivedBitmapMaximumCount]; + if (!_g639_derivedBitmapByteCount) + _g639_derivedBitmapByteCount = new uint16[kDerivedBitmapMaximumCount]; + if (!_g638_derivedBitmaps) { + _g638_derivedBitmaps = new byte*[kDerivedBitmapMaximumCount]; for (uint16 i = 0; i < kDerivedBitmapMaximumCount; ++i) - _derivedBitmaps[i] = nullptr; + _g638_derivedBitmaps[i] = nullptr; } - _derivedBitmapByteCount[kDerivedBitmapViewport] = 224 * 136; - _derivedBitmapByteCount[kDerivedBitmapThievesEyeVisibleArea] = 96 * 95; - _derivedBitmapByteCount[kDerivedBitmapDamageToCreatureMedium] = 64 * 37; - _derivedBitmapByteCount[kDerivedBitmapDamageToCreatureSmall] = 48 * 37; + _g639_derivedBitmapByteCount[k0_DerivedBitmapViewport] = 224 * 136; + _g639_derivedBitmapByteCount[k1_DerivedBitmapThievesEyeVisibleArea] = 96 * 95; + _g639_derivedBitmapByteCount[k2_DerivedBitmapDamageToCreatureMedium] = 64 * 37; + _g639_derivedBitmapByteCount[k3_DerivedBitmapDamageToCreatureSmall] = 48 * 37; - for (int16 doorOrnamentIndex = kDoorOrnDestroyedMask; doorOrnamentIndex <= kDoorOrnThivesEyeMask; doorOrnamentIndex++) { - _currMapDoorOrnInfo[doorOrnamentIndex][kNativeBitmapIndex] = doorOrnamentIndex + (kDoorMaskDestroyedIndice - kDoorOrnDestroyedMask); - _currMapDoorOrnInfo[doorOrnamentIndex][kCoordinateSet] = 1; + for (int16 doorOrnamentIndex = k15_DoorOrnDestroyedMask; doorOrnamentIndex <= k16_DoorOrnThivesEyeMask; doorOrnamentIndex++) { + _g103_currMapDoorOrnInfo[doorOrnamentIndex][k0_NativeBitmapIndex] = doorOrnamentIndex + (k301_DoorMaskDestroyedIndice - k15_DoorOrnDestroyedMask); + _g103_currMapDoorOrnInfo[doorOrnamentIndex][k1_CoordinateSet] = 1; - _derivedBitmapByteCount[doorOrnamentIndex * 2 + kDerivedBitmapFirstDoorOrnament_D3] = 48 * 41; - _derivedBitmapByteCount[doorOrnamentIndex * 2 + kDerivedBitmapFirstDoorOrnament_D2] = 64 * 61; + _g639_derivedBitmapByteCount[doorOrnamentIndex * 2 + k68_DerivedBitmapFirstDoorOrnament_D3] = 48 * 41; + _g639_derivedBitmapByteCount[doorOrnamentIndex * 2 + k69_DerivedBitmapFirstDoorOrnament_D2] = 64 * 61; } - _currMapFloorOrnInfo[kFloorOrnFootprints][kNativeBitmapIndex] = kFloorOrn_15_D3L_footprints; - _currMapFloorOrnInfo[kFloorOrnFootprints][kCoordinateSet] = 1; + _g102_currMapFloorOrnInfo[k15_FloorOrnFootprints][k0_NativeBitmapIndex] = k241_FloorOrn_15_D3L_footprints; + _g102_currMapFloorOrnInfo[k15_FloorOrnFootprints][k1_CoordinateSet] = 1; ObjectAspect *objectAspect = gObjectAspects; int16 derivedBitmapIndex; - for (int16 objectAspectIndex = 0; objectAspectIndex < kObjAspectCount; ++objectAspectIndex, ++objectAspect) { - derivedBitmapIndex = kDerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex; + for (int16 objectAspectIndex = 0; objectAspectIndex < k85_ObjAspectCount; ++objectAspectIndex, ++objectAspect) { + derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex; - _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, kScale16_D3); - _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, kScale20_D2); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k16_Scale_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k20_Scale_D2); - if (getFlag(objectAspect->_graphicInfo, kObjectFlipOnRightMask)) { - _derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2]; + if (getFlag(objectAspect->_graphicInfo, k0x0001_ObjectFlipOnRightMask)) { + _g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2]; derivedBitmapIndex++; - _derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2]; + _g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2]; derivedBitmapIndex++; } - if (getFlag(objectAspect->_graphicInfo, kObjectAlcoveMask)) { - _derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2]; + if (getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask)) { + _g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2]; derivedBitmapIndex++; - _derivedBitmapByteCount[derivedBitmapIndex] = _derivedBitmapByteCount[derivedBitmapIndex - 2]; + _g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2]; } } ProjectileAspect *projectileAspect = gProjectileAspect; - for (int16 projectileAspectIndex = 0; projectileAspectIndex < kProjectileAspectCount; projectileAspectIndex++, projectileAspect++) { + for (int16 projectileAspectIndex = 0; projectileAspectIndex < k14_ProjectileAspectCount; projectileAspectIndex++, projectileAspect++) { - if (!getFlag(projectileAspect->_graphicInfo, kProjectileScaleWithKineticEnergyMask)) { - derivedBitmapIndex = kDerivedBitmapFirstProjectile + projectileAspect->_firstDerivedBitmapRelativeIndex; + if (!getFlag(projectileAspect->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) { + derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + projectileAspect->_firstDerivedBitmapRelativeIndex; for (int16 projectileScaleIndex = 0; projectileScaleIndex < 6; projectileScaleIndex++) { - int16 bitmapPixelCount = getScaledBitmapPixelCount(projectileAspect->_width, projectileAspect->_height, gProjectileScales[projectileScaleIndex]); - _derivedBitmapByteCount[derivedBitmapIndex] = bitmapPixelCount; + int16 bitmapPixelCount = getScaledBitmapPixelCount(projectileAspect->_width, projectileAspect->_height, g215_ProjectileScales[projectileScaleIndex]); + _g639_derivedBitmapByteCount[derivedBitmapIndex] = bitmapPixelCount; - if (getFlag(projectileAspect->_graphicInfo, kProjectileAspectTypeMask) != kProjectileAspectHasNone) { - _derivedBitmapByteCount[derivedBitmapIndex + 6] = bitmapPixelCount; + if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k3_ProjectileAspectHasNone) { + _g639_derivedBitmapByteCount[derivedBitmapIndex + 6] = bitmapPixelCount; - if (getFlag(projectileAspect->_graphicInfo, kProjectileAspectTypeMask) != kProjectileAspectHasRotation) { - _derivedBitmapByteCount[derivedBitmapIndex + 12] = bitmapPixelCount; + if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k2_ProjectileAspectHasRotation) { + _g639_derivedBitmapByteCount[derivedBitmapIndex + 12] = bitmapPixelCount; } } } } } - _palChangesProjectile[0] = gPalChangesFloorOrn_D3; - _palChangesProjectile[1] = gPalChangesFloorOrn_D2; - _palChangesProjectile[2] = _palChangesProjectile[3] = gPalChangesNoChanges; + _g75_palChangesProjectile[0] = gPalChangesFloorOrn_D3; + _g75_palChangesProjectile[1] = gPalChangesFloorOrn_D2; + _g75_palChangesProjectile[2] = _g75_palChangesProjectile[3] = gPalChangesNoChanges; - derivedBitmapIndex = kDerivedBitmapFirstExplosion; - ExplosionAspect *expAsp = gExplosionAspects; - for (uint16 expAspIndex = 0; expAspIndex < kExplosionAspectCount; ++expAspIndex, expAsp++) { + derivedBitmapIndex = k438_DerivedBitmapFirstExplosion; + ExplosionAspect *expAsp = g211_ExplosionAspects; + for (uint16 expAspIndex = 0; expAspIndex < k4_ExplosionAspectCount; ++expAspIndex, expAsp++) { for (int16 scale = 4; scale < 32; scale += 2) - _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(expAsp->_pixelWidth, expAsp->_height, scale); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(expAsp->_pixelWidth, expAsp->_height, scale); - if (expAspIndex == kExplosionAspectSmoke) { - _derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_pixelWidth * expAsp->_height; + if (expAspIndex == k3_ExplosionAspectSmoke) { + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_pixelWidth * expAsp->_height; } } - derivedBitmapIndex = kDerivedBitmapFirstCreature; + derivedBitmapIndex = k495_DerivedBitmapFirstCreature; CreatureAspect *creatureAsp; - for (int16 creatureIndex = 0; creatureIndex < kCreatureTypeCount; creatureIndex++) { + for (int16 creatureIndex = 0; creatureIndex < k27_CreatureTypeCount; creatureIndex++) { creatureAsp = &gCreatureAspects[creatureIndex]; int16 creatureGraphicInfo = gCreatureInfo[creatureIndex]._graphicInfo; creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex; int16 creatureFrontBitmapD3PixelCount; - _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3); int16 creatureFrontBitmapD2PixelCount; - _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2); - if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskSide)) { - _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale16_D3); - _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale20_D2); + if (getFlag(creatureGraphicInfo, k0x0008_CreatureInfoGraphicMaskSide)) { + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k16_Scale_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k20_Scale_D2); } - if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskBack)) { - _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount; - _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount; + if (getFlag(creatureGraphicInfo, k0x0010_CreatureInfoGraphicMaskBack)) { + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount; + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount; } - if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskAttack)) { - _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, kScale16_D3); - _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, kScale20_D2); + if (getFlag(creatureGraphicInfo, k0x0020_CreatureInfoGraphicMaskAttack)) { + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k16_Scale_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k20_Scale_D2); } int16 additionalFronGraphicCount; - if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskAdditional)) { + if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, k0x0003_CreatureInfoGraphicMaskAdditional)) { do { - _derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront; - _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3); - _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront; + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2); } while (--additionalFronGraphicCount); } } @@ -950,15 +947,15 @@ void DisplayMan::unpackGraphics() { _bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1); loadIntoBitmap(i, _bitmaps[i]); } - _bitmaps[kFontGraphicIndice] = _bitmaps[532] + getWidth(532) * getHeight(532); - loadFNT1intoBitmap(kFontGraphicIndice, _bitmaps[kFontGraphicIndice]); + _bitmaps[k557_FontGraphicIndice] = _bitmaps[532] + getWidth(532) * getHeight(532); + loadFNT1intoBitmap(k557_FontGraphicIndice, _bitmaps[k557_FontGraphicIndice]); } void DisplayMan::loadFNT1intoBitmap(uint16 index, byte* destBitmap) { uint8 *data = _packedBitmaps + _packedItemPos[index]; for (uint16 i = 0; i < 6; i++) { for (uint16 w = 0; w < 128; ++w) { - *destBitmap++ = kColorBlack; + *destBitmap++ = k0_ColorBlack; uint16 nextByte = *data++; for (int16 pixel = 4; pixel >= 0; --pixel) { @@ -1085,22 +1082,22 @@ void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) { } byte* DisplayMan::getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnPixelWidth, int16& returnHeight) { - ExplosionAspect *explAsp = &gExplosionAspects[explosionAspIndex]; + ExplosionAspect *explAsp = &g211_ExplosionAspects[explosionAspIndex]; if (scale > 32) scale = 32; int16 pixelWidth = getScaledDimension(explAsp->_pixelWidth, scale); int16 height = getScaledDimension(explAsp->_height, scale); byte *bitmap; - int16 derBitmapIndex = (explosionAspIndex * 14) + scale / 2 + kDerivedBitmapFirstExplosion - 2; - if ((scale == 32) && (explosionAspIndex != kExplosionAspectSmoke)) { - bitmap = getBitmap(explosionAspIndex + kFirstExplosionGraphicIndice); + int16 derBitmapIndex = (explosionAspIndex * 14) + scale / 2 + k438_DerivedBitmapFirstExplosion - 2; + if ((scale == 32) && (explosionAspIndex != k3_ExplosionAspectSmoke)) { + bitmap = getBitmap(explosionAspIndex + k348_FirstExplosionGraphicIndice); } else if (isDerivedBitmapInCache(derBitmapIndex)) { bitmap = getDerivedBitmap(derBitmapIndex); } else { - byte *nativeBitmap = getBitmap(MIN(explosionAspIndex, (uint16)kExplosionAspectPoison) + kFirstExplosionGraphicIndice); + byte *nativeBitmap = getBitmap(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice); bitmap = getDerivedBitmap(derBitmapIndex); blitToBitmapShrinkWithPalChange(nativeBitmap, explAsp->_pixelWidth, explAsp->_height, bitmap, pixelWidth, height, - (explosionAspIndex == kExplosionAspectSmoke) ? gPalChangeSmoke : gPalChangesNoChanges); + (explosionAspIndex == k3_ExplosionAspectSmoke) ? gPalChangeSmoke : gPalChangesNoChanges); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } @@ -1132,12 +1129,12 @@ uint16 DisplayMan::getHeight(uint16 index) { void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { if (f._srcWidth) - blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, kColorNoTransparency, gDungeonViewport); + blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k255_ColorNoTransparency, gDungeonViewport); } void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) { if (f._srcWidth) - blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, kColorFlesh, gDungeonViewport); + blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, gDungeonViewport); } @@ -1150,37 +1147,37 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { switch (squareAspect[kElemAspect]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g0675stairsNativeBitmapIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3L]); + drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3L]); else - drawFloorPitOrStairsBitmap(_g0682stairsNativeBitmapIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3L]); + drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3L]); goto T0116015_redEagle; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3L]); - isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], kViewWall_D3L_RIGHT); - if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3L_FRONT)) { - order = kCellOrder_Alcove; + isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT); + if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) { + order = k0x0000_CellOrder_Alcove; goto T0116017_orangeElk; } return; case kElementTypeDoorSide: case kElementTypeStairsSide: - order = kCellOrder_BackLeft_BackRight_FrontRight; + order = k0x0321_CellOrder_BackLeft_BackRight_FrontRight; goto T0116016_blueToad; case kElementTypeDoorFront: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); - cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3L, kCellOrder_DoorPass1_BackLeft_BackRight); + cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); drawWallSetBitmap(_wallSetBitMaps[kDoorFrameLeft_D3L], g0164Frame_DoorFrameLeft_D3L); warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor"); - order = kCellOrder_DoorPass2_FrontLeft_FrontRight; + order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; goto T0116017_orangeElk; case kElementTypePit: if (!squareAspect[kPitInvisibleAspect]) { - drawFloorPitOrStairsBitmap(k049FloorPit_D3L_GraphicIndice, g0140FrameFloorPit_D3L); + drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, g0140FrameFloorPit_D3L); } case kElementTypeTeleporter: case kElementTypeCorridor: T0116015_redEagle: - order = kCellOrder_BackLeft_BackRight_FrontLeft_FrontRight; + order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight; T0116016_blueToad: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); T0116017_orangeElk: @@ -1201,44 +1198,44 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { switch (squareAspect[kElemAspect]) { case kElementTypeStaisFront: if (squareAspect[kStairsUpAspect]) { - drawFloorPitOrStairsBitmapFlippedHorizontally(_g0675stairsNativeBitmapIndex_Up_Front_D3L, g0112FrameStairsUpFront_D3R); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g0112FrameStairsUpFront_D3R); } else { - drawFloorPitOrStairsBitmapFlippedHorizontally(_g0682stairsNativeBitmapIndex_Down_Front_D3L, g0123FrameStairsDownFront_D3R); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g0123FrameStairsDownFront_D3R); } goto T0117016; case kElementTypeWall: drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3R]); - isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], kViewWall_D3R_LEFT); - if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3R_FRONT)) { - order = kCellOrder_Alcove; + isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT); + if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) { + order = k0x0000_CellOrder_Alcove; goto T0117018; } return; case kElementTypeDoorSide: case kElementTypeStairsSide: - order = kCellOrder_BackRight_BackLeft_FrontLeft; + order = k0x0412_CellOrder_BackRight_BackLeft_FrontLeft; goto T0117017; case kElementTypeDoorFront: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); - cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3R, kCellOrder_DoorPass1_BackRight_BackLeft); - memcpy(_tmpBitmap, _wallSetBitMaps[kDoorFrameLeft_D3L], 32 * 44); + cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); + memcpy(_g74_tmpBitmap, _wallSetBitMaps[kDoorFrameLeft_D3L], 32 * 44); warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally"); if (((Door*)_vm->_dungeonMan->_dunData._thingsData[kDoorThingType])[squareAspect[kDoorThingIndexAspect]].hasButton()) { warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton"); } warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor"); - order = kCellOrder_DoorPass2_FrontRight_FrontLeft; + order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft; goto T0117018; case kElementTypePit: if (!squareAspect[kPitInvisibleAspect]) { - drawFloorPitOrStairsBitmapFlippedHorizontally(k049FloorPit_D3L_GraphicIndice, g0142FrameFloorPit_D3R); + drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, g0142FrameFloorPit_D3R); } case kElementTypeTeleporter: case kElementTypeCorridor: T0117016: - order = kCellOrder_BackRight_BackLeft_FrontRight_FrontLeft; + order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft; T0117017: - warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); + warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); T0117018: cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3R, order); } @@ -1253,13 +1250,13 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g0676stairsNativeBitmapIndex_Up_Front_D3C, gStairFrames[kFrameStairsUpFront_D3C]); + drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, gStairFrames[kFrameStairsUpFront_D3C]); else - drawFloorPitOrStairsBitmap(_g0683stairsNativeBitmapIndex_Down_Front_D3C, gStairFrames[kFrameStairsDownFront_D3C]); + drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, gStairFrames[kFrameStairsDownFront_D3C]); break; case kWallElemType: drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3C]); - if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D3C_FRONT)) { + if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) { //... missing code } break; @@ -1273,19 +1270,19 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g0677stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2L]); + drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2L]); else - drawFloorPitOrStairsBitmap(_g0684stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2L]); + drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2L]); break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2L]); - isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], kViewWall_D2L_RIGHT); - if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D2L_FRONT)) { + isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT); + if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) { // ... missing code } break; case kStairsSideElemType: - drawFloorPitOrStairsBitmap(_g0689stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2L]); + drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2L]); break; default: break; @@ -1297,19 +1294,19 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(_g0677stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2R]); else - drawFloorPitOrStairsBitmapFlippedHorizontally(_g0684stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2R]); break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2R]); - isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], kViewWall_D2R_LEFT); - if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D2R_FRONT)) { + isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT); + if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) { // ... missing code } break; case kStairsSideElemType: - drawFloorPitOrStairsBitmapFlippedHorizontally(_g0689stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]); break; default: break; @@ -1321,13 +1318,13 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g0678stairsNativeBitmapIndex_Up_Front_D2C, gStairFrames[kFrameStairsUpFront_D2C]); + drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, gStairFrames[kFrameStairsUpFront_D2C]); else - drawFloorPitOrStairsBitmap(_g0685stairsNativeBitmapIndex_Down_Front_D2C, gStairFrames[kFrameStairsDownFront_D2C]); + drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, gStairFrames[kFrameStairsDownFront_D2C]); break; case kWallElemType: drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2C]); - if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D2C_FRONT)) { + if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) { // ... missing code } break; @@ -1341,19 +1338,19 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g0679stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1L]); + drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1L]); else - drawFloorPitOrStairsBitmap(_g0686stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1L]); + drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1L]); break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1L]); - isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], kViewWall_D1L_RIGHT); + isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT); break; case kStairsSideElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g0690stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1L]); + drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1L]); else - drawFloorPitOrStairsBitmap(_g0691stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1L]); + drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1L]); break; default: break; @@ -1365,19 +1362,19 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(_g0679stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1R]); else - drawFloorPitOrStairsBitmapFlippedHorizontally(_g0686stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1R]); break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1R]); - isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], kViewWall_D1R_LEFT); + isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT); break; case kStairsSideElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(_g0690stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1R]); else - drawFloorPitOrStairsBitmapFlippedHorizontally(_g0691stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1R]); break; default: break; @@ -1389,16 +1386,16 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g0680stairsNativeBitmapIndex_Up_Front_D1C, gStairFrames[kFrameStairsUpFront_D1C]); + drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, gStairFrames[kFrameStairsUpFront_D1C]); else - drawFloorPitOrStairsBitmap(_g0687stairsNativeBitmapIndex_Down_Front_D1C, gStairFrames[kFrameStairsDownFront_D1C]); + drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, gStairFrames[kFrameStairsDownFront_D1C]); break; case kWallElemType: _vm->_dungeonMan->_isFacingAlcove = false; _vm->_dungeonMan->_isFacingViAltar = false; _vm->_dungeonMan->_isFacingFountain = false; drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1C]); - if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], kViewWall_D1C_FRONT)) { + if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) { // .... code not yet implemneted } break; @@ -1413,7 +1410,7 @@ void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsSideElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g0692stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0L]); + drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0L]); break; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]); @@ -1429,7 +1426,7 @@ void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsSideElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(_g0692stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0R]); return; case kWallElemType: drawWallSetBitmap(_wallSetBitMaps[kWall_D0R], gFrameWalls[kViewSquare_D0R]); @@ -1445,11 +1442,11 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) { - drawFloorPitOrStairsBitmap(_g0681stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0L]); - drawFloorPitOrStairsBitmapFlippedHorizontally(_g0681stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0R]); + drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0L]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0R]); } else { - drawFloorPitOrStairsBitmap(_g0688stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0L]); - drawFloorPitOrStairsBitmapFlippedHorizontally(_g0688stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0R]); + drawFloorPitOrStairsBitmap(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0L]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0R]); } break; default: @@ -1458,13 +1455,13 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) { } void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { - loadPalette(gPalEntrance); + loadPalette(g20_PalEntrance); // TODO: this is a global variable, set from here bool flippedFloorCeiling = (posX + posY + dir) & 1; // NOTE: this can hold every bitmap, width and height is "flexible" byte *tmpBitmap = new byte[305 * 111]; - clearBitmap(tmpBitmap, 305, 111, kColorBlack); + clearBitmap(tmpBitmap, 305, 111, k10_ColorFlesh); for (int16 i = 0; i < 6; ++i) _vm->_dungeonMan->_dungeonViewClickableBoxes[i].setToZero(); @@ -1475,19 +1472,19 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { if (flippedFloorCeiling) { uint16 w = gFloorFrame._srcWidth, h = gFloorFrame._srcHeight; - blitToBitmap(_floorBitmap, w, h, tmpBitmap, w); + blitToBitmap(_g84_floorBitmap, w, h, tmpBitmap, w); flipBitmapHorizontal(tmpBitmap, w, h); drawWallSetBitmap(tmpBitmap, gFloorFrame); - drawWallSetBitmap(_ceilingBitmap, gCeilingFrame); + drawWallSetBitmap(_g85_ceilingBitmap, gCeilingFrame); for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i) _wallSetBitMaps[i + kWall_D0R] = _wallSetBitMaps[i + kWall_D0R_Flipped]; } else { uint16 w = gCeilingFrame._srcWidth, h = gCeilingFrame._srcHeight; - blitToBitmap(_ceilingBitmap, w, h, tmpBitmap, w); + blitToBitmap(_g85_ceilingBitmap, w, h, tmpBitmap, w); flipBitmapHorizontal(tmpBitmap, w, h); drawWallSetBitmap(tmpBitmap, gCeilingFrame); - drawWallSetBitmap(_floorBitmap, gFloorFrame); + drawWallSetBitmap(_g84_floorBitmap, gFloorFrame); } if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallElemType) @@ -1548,9 +1545,9 @@ void DisplayMan::clearBitmap(byte *bitmap, uint16 width, uint16 height, Color co void DisplayMan::loadFloorSet(FloorSet set) { // there are 2 bitmaps per set, first one is at 75 - GraphicIndice indice = (GraphicIndice)(kFirstFloorSet + (kFloorSetGraphicCount * set)); - _floorBitmap = _bitmaps[indice]; - _ceilingBitmap = _bitmaps[indice + 1]; + GraphicIndice indice = (GraphicIndice)(kFirstFloorSet + (k2_FloorSetGraphicCount * set)); + _g84_floorBitmap = _bitmaps[indice]; + _g85_ceilingBitmap = _bitmaps[indice + 1]; } @@ -1558,8 +1555,8 @@ Box gBoxWallBitmap_D3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallB Box gBoxWallBitmap_D2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR void DisplayMan::loadWallSet(WallSet set) { - uint16 firstIndice = (set * kWallSetGraphicCount) + kFirstWallSet; - for (uint16 i = 0; i < kWallSetGraphicCount; ++i) { + uint16 firstIndice = (set * k13_WallSetGraphicCount) + kFirstWallSet; + for (uint16 i = 0; i < k13_WallSetGraphicCount; ++i) { _wallSetBitMaps[i] = _bitmaps[i + firstIndice]; } @@ -1613,31 +1610,31 @@ void DisplayMan::loadCurrentMapGraphics() { // the original loads some flipped walls here, I moved it to loadWallSet { - int16 val = _vm->_dungeonMan->_currMap._map->_wallSet * kStairsGraphicCount + kFirstStairs; - _g0675stairsNativeBitmapIndex_Up_Front_D3L = val++; - _g0676stairsNativeBitmapIndex_Up_Front_D3C = val++; - _g0677stairsNativeBitmapIndex_Up_Front_D2L = val++; - _g0678stairsNativeBitmapIndex_Up_Front_D2C = val++; - _g0679stairsNativeBitmapIndex_Up_Front_D1L = val++; - _g0680stairsNativeBitmapIndex_Up_Front_D1C = val++; - _g0681stairsNativeBitmapIndex_Up_Front_D0C_Left = val++; - _g0682stairsNativeBitmapIndex_Down_Front_D3L = val++; - _g0683stairsNativeBitmapIndex_Down_Front_D3C = val++; - _g0684stairsNativeBitmapIndex_Down_Front_D2L = val++; - _g0685stairsNativeBitmapIndex_Down_Front_D2C = val++; - _g0686stairsNativeBitmapIndex_Down_Front_D1L = val++; - _g0687stairsNativeBitmapIndex_Down_Front_D1C = val++; - _g0688stairsNativeBitmapIndex_Down_Front_D0C_Left = val++; - _g0689stairsNativeBitmapIndex_Side_D2L = val++; - _g0690stairsNativeBitmapIndex_Up_Side_D1L = val++; - _g0691stairsNativeBitmapIndex_Down_Side_D1L = val++; - _g0692stairsNativeBitmapIndex_Side_D0L = val++; + int16 val = _vm->_dungeonMan->_currMap._map->_wallSet * k18_StairsGraphicCount + kFirstStairs; + _g675_stairsNativeBitmapIndex_Up_Front_D3L = val++; + _g676_stairsNativeBitmapIndex_Up_Front_D3C = val++; + _g677_stairsNativeBitmapIndex_Up_Front_D2L = val++; + _g678_stairsNativeBitmapIndex_Up_Front_D2C = val++; + _g679_stairsNativeBitmapIndex_Up_Front_D1L = val++; + _g680_stairsNativeBitmapIndex_Up_Front_D1C = val++; + _g681_stairsNativeBitmapIndex_Up_Front_D0C_Left = val++; + _g682_stairsNativeBitmapIndex_Down_Front_D3L = val++; + _g683_stairsNativeBitmapIndex_Down_Front_D3C = val++; + _g684_stairsNativeBitmapIndex_Down_Front_D2L = val++; + _g685_stairsNativeBitmapIndex_Down_Front_D2C = val++; + _g686_stairsNativeBitmapIndex_Down_Front_D1L = val++; + _g687_stairsNativeBitmapIndex_Down_Front_D1C = val++; + _g688_stairsNativeBitmapIndex_Down_Front_D0C_Left = val++; + _g689_stairsNativeBitmapIndex_Side_D2L = val++; + _g690_stairsNativeBitmapIndex_Up_Side_D1L = val++; + _g691_stairsNativeBitmapIndex_Down_Side_D1L = val++; + _g692_stairsNativeBitmapIndex_Side_D0L = val++; } - for (int16 i = 0; i < kAlcoveOrnCount; ++i) - _currMapAlcoveOrnIndices[i] = -1; - for (int16 i = 0; i < kFountainOrnCount; ++i) - _currMapFountainOrnIndices[i] = -1; + for (int16 i = 0; i < k3_AlcoveOrnCount; ++i) + _g267_currMapAlcoveOrnIndices[i] = -1; + for (int16 i = 0; i < k1_FountainOrnCount; ++i) + _g268_currMapFountainOrnIndices[i] = -1; @@ -1646,47 +1643,47 @@ void DisplayMan::loadCurrentMapGraphics() { uint16 fountainCount = 0; Map &currMap = *_vm->_dungeonMan->_currMap._map; - _currMapViAltarIndex = -1; + _g266_currMapViAltarIndex = -1; for (uint16 i = 0; i < currMap._wallOrnCount; ++i) { - uint16 ornIndice = _currMapWallOrnIndices[i]; + uint16 ornIndice = _g261_currMapWallOrnIndices[i]; uint16 nativeIndice = kFirstWallOrn + ornIndice * 2; - _currMapWallOrnInfo[i][kNativeBitmapIndex] = nativeIndice; - for (uint16 ornCounter = 0; ornCounter < kAlcoveOrnCount; ++ornCounter) { + _g101_currMapWallOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice; + for (uint16 ornCounter = 0; ornCounter < k3_AlcoveOrnCount; ++ornCounter) { if (ornIndice == gAlcoveOrnIndices[ornCounter]) { - _currMapAlcoveOrnIndices[alcoveCount++] = i; + _g267_currMapAlcoveOrnIndices[alcoveCount++] = i; if (ornIndice == 2) - _currMapViAltarIndex = i; + _g266_currMapViAltarIndex = i; } } - for (uint16 ornCounter = 0; ornCounter < kFountainOrnCount; ++ornCounter) + for (uint16 ornCounter = 0; ornCounter < k1_FountainOrnCount; ++ornCounter) if (ornIndice == gFountainOrnIndices[ornCounter]) - _currMapFountainOrnIndices[fountainCount++] = i; + _g268_currMapFountainOrnIndices[fountainCount++] = i; - _currMapWallOrnInfo[i][kCoordinateSet] = gWallOrnCoordSetIndices[ornIndice]; + _g101_currMapWallOrnInfo[i][k1_CoordinateSet] = gWallOrnCoordSetIndices[ornIndice]; } for (uint16 i = 0; i < currMap._floorOrnCount; ++i) { - uint16 ornIndice = _currMapFloorOrnIndices[i]; + uint16 ornIndice = _g262_currMapFloorOrnIndices[i]; uint16 nativeIndice = kFirstFloorOrn + ornIndice * 6; - _currMapFloorOrnInfo[i][kNativeBitmapIndex] = nativeIndice; - _currMapFloorOrnInfo[i][kCoordinateSet] = gFloorOrnCoordSetIndices[ornIndice]; + _g102_currMapFloorOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice; + _g102_currMapFloorOrnInfo[i][k1_CoordinateSet] = gFloorOrnCoordSetIndices[ornIndice]; } for (uint16 i = 0; i < currMap._doorOrnCount; ++i) { - uint16 ornIndice = _currMapDoorOrnIndices[i]; + uint16 ornIndice = _g263_currMapDoorOrnIndices[i]; uint16 nativeIndice = kFirstDoorOrn + ornIndice; - _currMapDoorOrnInfo[i][kNativeBitmapIndex] = nativeIndice; - _currMapDoorOrnInfo[i][kCoordinateSet] = gDoorOrnCoordIndices[ornIndice]; + _g103_currMapDoorOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice; + _g103_currMapDoorOrnInfo[i][k1_CoordinateSet] = gDoorOrnCoordIndices[ornIndice]; } applyCreatureReplColors(9, 8); applyCreatureReplColors(10, 12); for (uint16 creatureType = 0; creatureType < currMap._creatureTypeCount; ++creatureType) { - CreatureAspect &aspect = gCreatureAspects[_currMapAllowedCreatureTypes[creatureType]]; + CreatureAspect &aspect = gCreatureAspects[_g264_currMapAllowedCreatureTypes[creatureType]]; uint16 replColorOrdinal = aspect.getReplColour9(); if (replColorOrdinal) applyCreatureReplColors(9, _vm->ordinalToIndex(replColorOrdinal)); @@ -1698,7 +1695,7 @@ void DisplayMan::loadCurrentMapGraphics() { void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor) { for (int16 i = 0; i < 6; ++i) - gPalDungeonView[i][replacedColor] = gCreatureReplColorSets[replacementColor]._RGBColor[i]; + g21_PalDungeonView[i][replacedColor] = gCreatureReplColorSets[replacementColor]._RGBColor[i]; gPalChangesCreature_D2[replacedColor] = gCreatureReplColorSets[replacementColor]._D2ReplacementColor; gPalChangesCreature_D3[replacedColor] = gCreatureReplColorSets[replacementColor]._D3ReplacementColor; @@ -1706,15 +1703,15 @@ void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor void DisplayMan::drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) { if (f._srcWidth) { - blitToScreen(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, f._box, kColorFlesh, gDungeonViewport); + blitToScreen(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, gDungeonViewport); } } void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) { if (f._srcWidth) { - blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcHeight, _tmpBitmap, f._srcWidth); - flipBitmapHorizontal(_tmpBitmap, f._srcWidth, f._srcHeight); - blitToScreen(_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._box, kColorFlesh, gDungeonViewport); + blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcHeight, _g74_tmpBitmap, f._srcWidth); + flipBitmapHorizontal(_g74_tmpBitmap, f._srcWidth, f._srcHeight); + blitToScreen(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, gDungeonViewport); } } @@ -1766,24 +1763,24 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex if (wallOrnOrd) { int16 var_X; int16 wallOrnIndex = wallOrnOrd - 1; - int16 nativeBitmapIndex = _currMapWallOrnInfo[wallOrnIndex][kNativeBitmapIndex]; + int16 nativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k0_NativeBitmapIndex]; - uint16 *coordinateSetA = gWallOrnCoordSets[_currMapWallOrnInfo[wallOrnIndex][kCoordinateSet]][viewWallIndex]; + uint16 *coordinateSetA = gWallOrnCoordSets[_g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]][viewWallIndex]; isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnIndex); isInscription = (wallOrnIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex); if (isInscription) { - _vm->_dungeonMan->decodeText((char*)inscriptionString, _inscriptionThing, kTextTypeInscription); + _vm->_dungeonMan->decodeText((char*)inscriptionString, _g290_inscriptionThing, kTextTypeInscription); } - if (viewWallIndex >= kViewWall_D1L_RIGHT) { - if (viewWallIndex == kViewWall_D1C_FRONT) { + if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) { + if (viewWallIndex == k12_ViewWall_D1C_FRONT) { if (isInscription) { Frame &D1CFrame = gFrameWalls[kViewSquare_D1C]; blitToScreen(_wallSetBitMaps[kWall_D1LCR], D1CFrame._srcWidth, 94, 28, gBoxWallPatchBehindInscription._x1, gBoxWallPatchBehindInscription._x2, - gBoxWallPatchBehindInscription._y1, gBoxWallPatchBehindInscription._y2, kColorNoTransparency, gDungeonViewport); + gBoxWallPatchBehindInscription._y1, gBoxWallPatchBehindInscription._y2, k255_ColorNoTransparency, gDungeonViewport); unsigned char *string = inscriptionString; - bitmapRed = _bitmaps[kInscriptionFontIndice]; + bitmapRed = _bitmaps[k120_InscriptionFontIndice]; int16 textLineIndex = 0; do { int16 characterCount = 0; @@ -1794,7 +1791,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7; frame._box._y1 = (frame._box._y2 = gInscriptionLineY[textLineIndex++]) - 7; while (characterCount--) { - blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._box, kColorFlesh, gDungeonViewport); + blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._box, k10_ColorFlesh, gDungeonViewport); frame._box._x1 += 8; frame._box._x2 += 8; } @@ -1803,58 +1800,58 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex } nativeBitmapIndex++; - _vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._x1 = coordinateSetA[0]; - _vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._x2 = coordinateSetA[1]; - _vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._y1 = coordinateSetA[2]; - _vm->_dungeonMan->_dungeonViewClickableBoxes[kViewCellDoorButtonOrWallOrn]._y2 = coordinateSetA[3]; + _vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordinateSetA[0]; + _vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordinateSetA[1]; + _vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordinateSetA[2]; + _vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordinateSetA[3]; _vm->_dungeonMan->_isFacingAlcove = isAlcove; - _vm->_dungeonMan->_isFacingViAltar = (wallOrnIndex == _currMapViAltarIndex); + _vm->_dungeonMan->_isFacingViAltar = (wallOrnIndex == _g266_currMapViAltarIndex); _vm->_dungeonMan->_isFacingFountain = false; - for (int16 fountainOrnIndex = 0; fountainOrnIndex < kFountainOrnCount; ++fountainOrnIndex) { - if (_currMapFountainOrnIndices[fountainOrnIndex] == wallOrnIndex) { + for (int16 fountainOrnIndex = 0; fountainOrnIndex < k1_FountainOrnCount; ++fountainOrnIndex) { + if (_g268_currMapFountainOrnIndices[fountainOrnIndex] == wallOrnIndex) { _vm->_dungeonMan->_isFacingFountain = true; break; } } } bitmapGreen = _bitmaps[nativeBitmapIndex]; - if (viewWallIndex == kViewWall_D1R_LEFT) { - blitToBitmap(bitmapGreen, coordinateSetA[4], coordinateSetA[5], _tmpBitmap, coordinateSetA[4]); - flipBitmapHorizontal(_tmpBitmap, coordinateSetA[4], coordinateSetA[5]); - bitmapGreen = _tmpBitmap; + if (viewWallIndex == k11_ViewWall_D1R_LEFT) { + blitToBitmap(bitmapGreen, coordinateSetA[4], coordinateSetA[5], _g74_tmpBitmap, coordinateSetA[4]); + flipBitmapHorizontal(_g74_tmpBitmap, coordinateSetA[4], coordinateSetA[5]); + bitmapGreen = _g74_tmpBitmap; } var_X = 0; } else { coordinateSetOffset = 0; uint16 *coordSetB; - int16 wallOrnCoordSetIndex = _currMapWallOrnInfo[wallOrnIndex][kCoordinateSet]; - flipHorizontal = (viewWallIndex == kViewWall_D2R_LEFT) || (viewWallIndex == kViewWall_D3R_LEFT); + int16 wallOrnCoordSetIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]; + flipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT); if (flipHorizontal) { - coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1R_LEFT]; - } else if ((viewWallIndex == kViewWall_D2L_RIGHT) || (viewWallIndex == kViewWall_D3L_RIGHT)) { - coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1L_RIGHT]; + coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][k11_ViewWall_D1R_LEFT]; + } else if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) { + coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][k10_ViewWall_D1L_RIGHT]; } else { nativeBitmapIndex++; - coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][kViewWall_D1C_FRONT]; - if (viewWallIndex == kViewWall_D2L_FRONT) { + coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][k12_ViewWall_D1C_FRONT]; + if (viewWallIndex == k7_ViewWall_D2L_FRONT) { coordinateSetOffset = 6; - } else if (viewWallIndex == kViewWall_D2R_FRONT) { + } else if (viewWallIndex == k9_ViewWall_D2R_FRONT) { coordinateSetOffset = -6; } } int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0]; - blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], coordSetB[4] << 1, coordSetB[5], _tmpBitmap, pixelWidth + 1, coordinateSetA[5], - (viewWallIndex <= kViewWall_D3R_FRONT) ? gPalChangesDoorButtonAndWallOrn_D3 : gPalChangesDoorButtonAndWallOrn_D2); + blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], coordSetB[4] << 1, coordSetB[5], _g74_tmpBitmap, pixelWidth + 1, coordinateSetA[5], + (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? gPalChangesDoorButtonAndWallOrn_D3 : gPalChangesDoorButtonAndWallOrn_D2); bitmapGreen = _bitmaps[nativeBitmapIndex]; var_X = pixelWidth; if (flipHorizontal) { - if (bitmapGreen != _tmpBitmap) - blitToBitmap(bitmapGreen, coordSetB[4], coordSetB[5], _tmpBitmap, coordSetB[4]); - flipBitmapHorizontal(_tmpBitmap, coordSetB[4], coordSetB[5]); - bitmapGreen = _tmpBitmap; + if (bitmapGreen != _g74_tmpBitmap) + blitToBitmap(bitmapGreen, coordSetB[4], coordSetB[5], _g74_tmpBitmap, coordSetB[4]); + flipBitmapHorizontal(_g74_tmpBitmap, coordSetB[4], coordSetB[5]); + bitmapGreen = _g74_tmpBitmap; var_X = 15 - (var_X & 0xF); - } else if (viewWallIndex == kViewWall_D2L_FRONT) { + } else if (viewWallIndex == k7_ViewWall_D2L_FRONT) { var_X -= coordinateSetA[1] - coordinateSetA[0]; } else { var_X = 0; @@ -1883,12 +1880,12 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex coordinateSetA[3] = gUnreadableInscriptionBoxY2[gWallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1]; } } - blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, coordinateSetA[0], coordinateSetA[1], coordinateSetA[2], coordinateSetA[3], kColorFlesh, gDungeonViewport); + blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, coordinateSetA[0], coordinateSetA[1], coordinateSetA[2], coordinateSetA[3], k10_ColorFlesh, gDungeonViewport); - if ((viewWallIndex == kViewWall_D1C_FRONT) && _championPortraitOrdinal--) { + if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { Box &box = gBoxChampionPortraitOnWall; - blitToScreen(_bitmaps[kChampionPortraitsIndice], 256, (_championPortraitOrdinal & 0x7) << 5, (_championPortraitOrdinal >> 3) * 29, box._x1, box._x2, box._y1, box._y2, - kColorDarkGary, gDungeonViewport); + blitToScreen(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29, box._x1, box._x2, box._y1, box._y2, + k1_ColorDarkGary, gDungeonViewport); } return isAlcove; } @@ -1935,15 +1932,15 @@ void DisplayMan::drawField(FieldAspect* fieldAspect, Box& box) { if (fieldAspect->_mask == kMaskFieldAspectNoMask) { bitmapMask = nullptr; } else { - bitmapMask = dispMan._tmpBitmap; - memcpy(bitmapMask, dispMan.getBitmap(kFieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)), + bitmapMask = dispMan._g74_tmpBitmap; + memcpy(bitmapMask, dispMan.getBitmap(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)), fieldAspect->_height * fieldAspect->_pixelWidth * sizeof(bitmapMask[0])); if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) { dispMan.flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height); } } - byte *bitmap = dispMan.getBitmap(kFieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex); + byte *bitmap = dispMan.getBitmap(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex); warning("MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap"); warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock"); @@ -2114,7 +2111,7 @@ int16 gCenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_Centere #define kBlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK void DisplayMan::cthulhu(Thing thingParam, direction directionParam, int16 mapXpos, - int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) { + int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) { DungeonMan &dunMan = *_vm->_dungeonMan; @@ -2232,7 +2229,7 @@ void DisplayMan::cthulhu(Thing thingParam, direction directionParam, int16 mapXp drawCreaturesCompleted = sqaureHasProjectile = squareHasExplosion = false; cellCounter = 0; firstThingToDraw = thingParam; - if (getFlag(orderedViewCellOrdinals, kCellOrder_DoorFront)) { /* If the function call is to draw objects on a door square viewed from the front */ + if (getFlag(orderedViewCellOrdinals, k0x0008_CellOrder_DoorFront)) { /* If the function call is to draw objects on a door square viewed from the front */ /* Two function calls are made in that case to draw objects on both sides of the door frame. The door and its frame are drawn between the two calls. This value indicates the drawing pass so that creatures are drawn in the right order and so that Fluxcages are not drawn twice */ @@ -2250,7 +2247,7 @@ creatures are drawn in the right order and so that Fluxcages are not drawn twice do { /* Draw objects */ if (drawAlcoveObjects) { - AL_2_viewCell = kViewCellAlcove; /* Index of coordinates to draw objects in alcoves */ + AL_2_viewCell = k4_ViewCellAlcove; /* Index of coordinates to draw objects in alcoves */ cellYellowBear = returnOppositeDir(directionParam); /* Alcove is on the opposite direction of the viewing direction */ objectShiftIndex = 2; } else { @@ -2283,46 +2280,46 @@ creatures are drawn in the right order and so that Fluxcages are not drawn twice /* Square where objects are visible and object is located on cell being processed */ if ((viewSquareIndex >= kViewSquare_D3C) && (viewSquareIndex <= kViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { objectAspect = &(gObjectAspects[gObjectInfo[dunMan.getObjectInfoIndex(thingParam)]._objectAspectIndex]); - AL_4_nativeBitmapIndex = kFirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex; - if (useAlcoveObjectImage = (drawAlcoveObjects && getFlag(objectAspect->_graphicInfo, kObjectAlcoveMask) && !viewLane)) { + AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex; + if (useAlcoveObjectImage = (drawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane)) { AL_4_nativeBitmapIndex++; } coordinateSet = gObjectCoordinateSets[objectAspect->_coordinateSet][viewSquareIndex][AL_2_viewCell]; if (!coordinateSet[1]) /* If object is not visible */ continue; T0115015_DrawProjectileAsObject: - flipHorizontal = getFlag(objectAspect->_graphicInfo, kObjectFlipOnRightMask) && + flipHorizontal = getFlag(objectAspect->_graphicInfo, k0x0001_ObjectFlipOnRightMask) && !useAlcoveObjectImage && - ((viewLane == kViewLaneRight) || (!viewLane && ((AL_2_viewCell == kViewCellFrontRight) || (AL_2_viewCell == kViewCellBackRight)))); + ((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight)))); /* Flip horizontally if object graphic requires it and is not being drawn in an alcove and the object is either on the right lane or on the right column of the center lane */ paddingPixelCount = 0; - if ((viewSquareIndex == kViewSquare_D0C) || ((viewSquareIndex >= kViewSquare_D1C) && (AL_2_viewCell >= kViewCellBackRight))) { + if ((viewSquareIndex == kViewSquare_D0C) || ((viewSquareIndex >= kViewSquare_D1C) && (AL_2_viewCell >= k2_ViewCellBackRight))) { /* If object is in the center lane (only D0C or D1C with condition above) and is not a projectile */ drawingGrabbableObject = (!viewLane && !drawProjectileAsObject); - AL_8_shiftSetIndex = kShiftSet_D0BackD1Front; + AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front; AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */ byteWidth = objectAspect->_width; heightRedEagle = objectAspect->_height; if (flipHorizontal) { - memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); - flipBitmapHorizontal(_tmpBitmap, byteWidth, heightRedEagle); - AL_6_bitmapRedBanana = _tmpBitmap; + memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); + flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); + AL_6_bitmapRedBanana = _g74_tmpBitmap; } } else { drawingGrabbableObject = false; - derivedBitmapIndex = kDerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex; - if ((viewSquareIndex >= kViewSquare_D1C) || ((viewSquareIndex >= kViewSquare_D2C) && (AL_2_viewCell >= kViewCellBackRight))) { + derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex; + if ((viewSquareIndex >= kViewSquare_D1C) || ((viewSquareIndex >= kViewSquare_D2C) && (AL_2_viewCell >= k2_ViewCellBackRight))) { derivedBitmapIndex++; - AL_8_shiftSetIndex = kShiftSet_D1BackD2Front; - byteWidth = getScaledDimension(objectAspect->_width, kScale20_D2); - heightRedEagle = getScaledDimension(objectAspect->_height, kScale20_D2); + AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front; + byteWidth = getScaledDimension(objectAspect->_width, k20_Scale_D2); + heightRedEagle = getScaledDimension(objectAspect->_height, k20_Scale_D2); paletteChanges = gPalChangesFloorOrn_D2; } else { - AL_8_shiftSetIndex = kShiftSet_D2BackD3Front; - byteWidth = getScaledDimension(objectAspect->_width, kScale16_D3); - heightRedEagle = getScaledDimension(objectAspect->_height, kScale16_D3); + AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front; + byteWidth = getScaledDimension(objectAspect->_width, k16_Scale_D3); + heightRedEagle = getScaledDimension(objectAspect->_height, k16_Scale_D3); paletteChanges = gPalChangesFloorOrn_D3; } if (flipHorizontal) { @@ -2395,20 +2392,20 @@ T0115015_DrawProjectileAsObject: AL_6_bitmapRedBanana = bitmapGreenAnt; dunMan._pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */ } - blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, kColorFlesh, gDungeonViewport); + blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, gDungeonViewport); if (drawProjectileAsObject) goto T0115171_BackFromT0115015_DrawProjectileAsObject; } } while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList); - if (AL_2_viewCell == kViewCellAlcove) + if (AL_2_viewCell == k4_ViewCellAlcove) break; /* End of processing when drawing objects in an alcove */ if (viewSquareIndex < kViewSquare_D3C) break; /* End of processing if square is too far away at D4 */ /* Draw creatures */ /* If (draw cell on the back row or second cell being processed) and (no more cells to draw or next cell to draw is a cell on the front row) */ - drawingLastBackRowCell = ((AL_2_viewCell <= kViewCellFrontRight) || (cellCounter == 1)) + drawingLastBackRowCell = ((AL_2_viewCell <= k1_ViewCellFrontRight) || (cellCounter == 1)) && (!remainingViewCellOrdinalsToProcess || ((remainingViewCellOrdinalsToProcess & 0x0000000F) >= 3)); if ((groupThing == Thing::_none) || drawCreaturesCompleted) @@ -2438,24 +2435,24 @@ T0115015_DrawProjectileAsObject: if (remainingViewCellOrdinalsToProcess || (doorFrontViewDrawingPass == 1)) /* Do not draw a single centered creature now, wait until second pass (for a front view door) or until all cells have been drawn so the creature is drawn over all the objects on the floor */ - goto T0115129_DrawProjectiles; + goto T0115129_DrawProjectiles; drawCreaturesCompleted = true; if ((creatureSize == kMaskCreatureSizeHalf) && (creatureDirectionDelta & 0x0001)) { /* Side view of half square creature */ - AL_2_viewCell = kHalfSizedViewCell_CenterColumn; + AL_2_viewCell = k3_HalfSizedViewCell_CenterColumn; } else { - AL_2_viewCell = kHalfSizedViewCell_FrontRow; + AL_2_viewCell = k4_HalfSizedViewCell_FrontRow; } } else if ((creatureSize == kMaskCreatureSizeHalf) && (drawingLastBackRowCell || !remainingViewCellOrdinalsToProcess || (creatureIndexGreen < 0))) { if (drawingLastBackRowCell && (doorFrontViewDrawingPass != 2)) { if ((creatureIndexGreen >= 0) && (creatureDirectionDelta & 0x0001)) { - AL_2_viewCell = kHalfSizedViewCell_BackRow; /* Side view of a half square creature on the back row. Drawn during pass 1 for a door square */ + AL_2_viewCell = k2_HalfSizedViewCell_BackRow; /* Side view of a half square creature on the back row. Drawn during pass 1 for a door square */ } else { goto T0115129_DrawProjectiles; } } else if ((doorFrontViewDrawingPass != 1) && !remainingViewCellOrdinalsToProcess) { if (creatureDirectionDelta & 0x0001) { if (creatureIndexGreen >= 0) { - AL_2_viewCell = kHalfSizedViewCell_FrontRow; /* Side view of a half square creature on the front row. Drawn during pass 2 for a door square */ + AL_2_viewCell = k4_HalfSizedViewCell_FrontRow; /* Side view of a half square creature on the front row. Drawn during pass 2 for a door square */ } else { goto T0115129_DrawProjectiles; } @@ -2467,9 +2464,9 @@ T0115015_DrawProjectileAsObject: twoHalfSquareCreaturesFrontView = group->getCount(); if (((AL_4_groupCells = _vm->_groupMan->getCreatureValue(AL_4_groupCells, AL_0_creatureIndexRed)) == directionParam) || (AL_4_groupCells == returnPrevVal(directionParam))) { - AL_2_viewCell = kHalfSizedViewCell_LeftColumn; + AL_2_viewCell = k0_HalfSizedViewCell_LeftColumn; } else { - AL_2_viewCell = kHalfSizedViewCell_RightColumn; + AL_2_viewCell = k1_HalfSizedViewCell_RightColumn; } } } else { @@ -2489,29 +2486,29 @@ T0115077_DrawSecondHalfSquareCreature: if (!coordinateSet[1]) goto T0115126_CreatureNotVisible; AL_0_creatureGraphicInfoRed = creatureGraphicInfoGreen; - AL_4_nativeBitmapIndex = kFirstCreatureGraphicIndice + ((CreatureAspect*)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */ + AL_4_nativeBitmapIndex = k446_FirstCreatureGraphicIndice + ((CreatureAspect*)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */ derivedBitmapIndex = ((CreatureAspect*)objectAspect)->_firstDerivedBitmapIndex; - if (useCreatureSideBitmap = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide) && (creatureDirectionDelta & 0x0001)) { + if (useCreatureSideBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide) && (creatureDirectionDelta & 0x0001)) { useCreatureAttackBitmap = useFlippedHorizontallyCreatureFrontImage = useCreatureBackBitmap = false; AL_4_nativeBitmapIndex++; /* Skip the front image. Side image is right after the front image */ derivedBitmapIndex += 2; sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthSide; sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightSide; } else { - useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0); + useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0); if (useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupIsAttacking) - && getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskAttack)) { + && getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack)) { useFlippedHorizontallyCreatureFrontImage = false; sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthAttack; sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightAttack; AL_4_nativeBitmapIndex++; /* Skip the front image */ derivedBitmapIndex += 2; - if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide)) { + if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) { AL_4_nativeBitmapIndex++; /* If the creature has a side image, it preceeds the attack image */ derivedBitmapIndex += 2; } - if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskBack)) { + if (getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack)) { AL_4_nativeBitmapIndex++; /* If the creature has a back image, it preceeds the attack image */ derivedBitmapIndex += 2; } @@ -2520,7 +2517,7 @@ T0115077_DrawSecondHalfSquareCreature: sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightFront; if (useCreatureBackBitmap) { useFlippedHorizontallyCreatureFrontImage = false; - if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide)) { + if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) { AL_4_nativeBitmapIndex += 2; /* If the creature has a side image, it preceeds the back image */ derivedBitmapIndex += 4; } else { @@ -2528,16 +2525,16 @@ T0115077_DrawSecondHalfSquareCreature: derivedBitmapIndex += 2; } } else { - if (useFlippedHorizontallyCreatureFrontImage = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskFlipNonAttack) + if (useFlippedHorizontallyCreatureFrontImage = getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack) && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) { derivedBitmapIndex += 2; - if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSide)) { + if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) { derivedBitmapIndex += 2; } - if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskBack)) { + if (getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack)) { derivedBitmapIndex += 2; } - if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskAttack)) { + if (getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack)) { derivedBitmapIndex += 2; } } @@ -2546,29 +2543,29 @@ T0115077_DrawSecondHalfSquareCreature: } if (viewSquareIndex >= kViewSquare_D1C) { /* Creature is on D1 */ creaturePaddingPixelCount = 0; - AL_8_shiftSetIndex = kShiftSet_D0BackD1Front; + AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front; transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour(); if (useCreatureSideBitmap) { AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); if (creatureDirectionDelta == 1) { - memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); - flipBitmapHorizontal(_tmpBitmap, byteWidth, heightRedEagle); - AL_6_bitmapRedBanana = _tmpBitmap; + memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); + flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); + AL_6_bitmapRedBanana = _g74_tmpBitmap; } } else { if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) { AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); if (useCreatureAttackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) { - memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); - flipBitmapHorizontal(_tmpBitmap, byteWidth, heightRedEagle); - AL_6_bitmapRedBanana = _tmpBitmap; + memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); + flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); + AL_6_bitmapRedBanana = _g74_tmpBitmap; } } else { /* Use first additional derived graphic: front D1 */ if (isDerivedBitmapInCache(derivedBitmapIndex)) { /* If derived graphic is already in memory */ AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); } else { bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex); - if (getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskFlipNonAttack)) { + if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) { AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); memcpy(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * heightRedEagle * sizeof(byte)); flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); @@ -2583,16 +2580,16 @@ T0115077_DrawSecondHalfSquareCreature: } if (viewSquareIndex >= kViewSquare_D2C) { /* Creature is on D2 */ derivedBitmapIndex++; /* Skip front D3 image in additional graphics */ - AL_8_shiftSetIndex = kShiftSet_D1BackD2Front; - useCreatureSpecialD2FrontBitmap = getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSpecialD2Front) + AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front; + useCreatureSpecialD2FrontBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0080_CreatureInfoGraphicMaskSpecialD2Front) && !useCreatureSideBitmap && !useCreatureBackBitmap && !useCreatureAttackBitmap; paletteChanges = gPalChangesCreature_D2; - scale = kScale20_D2; + scale = k20_Scale_D2; } else { /* Creature is on D3 */ - AL_8_shiftSetIndex = kShiftSet_D2BackD3Front; + AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front; useCreatureSpecialD2FrontBitmap = false; paletteChanges = gPalChangesCreature_D3; - scale = kScale16_D3; + scale = k16_Scale_D3; } byteWidth = getScaledDimension(sourceByteWidth, scale); heightRedEagle = getScaledDimension(sourceHeight, scale); @@ -2607,14 +2604,14 @@ T0115077_DrawSecondHalfSquareCreature: } if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */ (useCreatureAttackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) || - (useCreatureSpecialD2FrontBitmap && getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskSpecialD2FrontIsFlipped)) || - (useFlippedHorizontallyCreatureFrontImage && getFlag(AL_0_creatureGraphicInfoRed, kCreatureInfoGraphicMaskFlipNonAttack))) { /* If the graphic should be flipped */ + (useCreatureSpecialD2FrontBitmap && getFlag(AL_0_creatureGraphicInfoRed, k0x0100_CreatureInfoGraphicMaskSpecialD2FrontIsFlipped)) || + (useFlippedHorizontallyCreatureFrontImage && getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack))) { /* If the graphic should be flipped */ if (!useFlippedHorizontallyCreatureFrontImage || !derivedBitmapInCache) { AL_4_normalizdByteWidth = byteWidth; warning("SUPER WARNING: we might need getNormalizedByteWidthM77"); if (!useFlippedHorizontallyCreatureFrontImage) { - memcpy(_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte)); - AL_6_bitmapRedBanana = _tmpBitmap; + memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte)); + AL_6_bitmapRedBanana = _g74_tmpBitmap; } flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); } @@ -2629,7 +2626,7 @@ T0115077_DrawSecondHalfSquareCreature: boxByteGreen._y1 = MIN(0, AL_4_yPos - (heightRedEagle - 1)); AL_4_xPos = coordinateSet[0]; AL_4_xPos += gShiftSets[AL_8_shiftSetIndex][getHorizontalOffsetM22(creatureAspectInt)]; - if (viewLane == kViewLaneLeft) { + if (viewLane == k1_ViewLaneLeft) { AL_4_xPos -= 100; } else { if (viewLane) { /* Lane right */ @@ -2652,10 +2649,10 @@ T0115126_CreatureNotVisible: if (twoHalfSquareCreaturesFrontView) { twoHalfSquareCreaturesFrontView = false; creatureAspectInt = activeGroup->_aspect[!creatureIndexGreen]; /* Aspect of the other creature in the pair */ - if (AL_2_viewCell == kHalfSizedViewCell_RightColumn) { - AL_2_viewCell = kHalfSizedViewCell_LeftColumn; + if (AL_2_viewCell == k1_HalfSizedViewCell_RightColumn) { + AL_2_viewCell = k0_HalfSizedViewCell_LeftColumn; } else { - AL_2_viewCell = kHalfSizedViewCell_RightColumn; + AL_2_viewCell = k1_HalfSizedViewCell_RightColumn; } goto T0115077_DrawSecondHalfSquareCreature; } @@ -2664,8 +2661,8 @@ T0115129_DrawProjectiles: if (!sqaureHasProjectile || ((viewSquareIndex = viewSquareIndexBackup) > kViewSquare_D0C) /* If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn */ - || (!(projectilePosX = gObjectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0]))) - continue; +|| (!(projectilePosX = gObjectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0]))) +continue; thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */ do { @@ -2673,38 +2670,38 @@ T0115129_DrawProjectiles: projectile = (Projectile*)dunMan.getThingData(thingParam); if ((AL_4_projectileAspect = dunMan.getProjectileAspect(projectile->_object)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */ objectAspect = (ObjectAspect*)&gProjectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)]; - AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + kFirstProjectileGraphicIndice; - projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, kProjectileAspectTypeMask); - if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, kProjectileScaleWithKineticEnergyMask)) + AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice; + projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask); + if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == kViewSquare_D0C)) { scale = 0; /* Use native bitmap without resizing */ byteWidth = ((ProjectileAspect*)objectAspect)->_width; heightRedEagle = ((ProjectileAspect*)objectAspect)->_height; } else { AL_8_projectileScaleIndex = ((viewSquareIndex / 3) << 1) + (AL_2_viewCell >> 1); - scale = gProjectileScales[AL_8_projectileScaleIndex]; + scale = g215_ProjectileScales[AL_8_projectileScaleIndex]; if (!doNotScaleWithKineticEnergy) { scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8; } byteWidth = getScaledDimension(((ProjectileAspect*)objectAspect)->_width, scale); heightRedEagle = getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale); } - if (projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == kProjectileAspectHasBackGraphicRotation)) { + if (projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == k0_ProjectileAspectHasBackGraphicRotation)) { projectileFlipVertical = ((mapXpos + mapYpos) & 0x0001); } - if (projectileAspectType == kProjectileAspectHasNone) { + if (projectileAspectType == k3_ProjectileAspectHasNone) { projectileBitmapIndexData = 0; flipVertical = flipHorizontal = false; } else { if (isOrientedWestEast((direction)(projectileDirection = _vm->_timeline->_events[projectile->_timerIndex]._C._projectile.getDir())) != isOrientedWestEast(directionParam)) { - if (projectileAspectType == kProjectileAspectHasRotation) { + if (projectileAspectType == k2_ProjectileAspectHasRotation) { projectileBitmapIndexData = 1; } else { projectileBitmapIndexData = 2; } if (projectileAspectTypeHasBackGraphicAndRotation) { - flipHorizontal = !AL_2_viewCell || (AL_2_viewCell == kViewCellBackLeft); + flipHorizontal = !AL_2_viewCell || (AL_2_viewCell == k3_ViewCellBackLeft); if (!(flipVertical = projectileFlipVertical)) { flipHorizontal = !flipHorizontal; } @@ -2714,16 +2711,16 @@ T0115129_DrawProjectiles: } } else { /* If the projectile does not have a back graphic or has one but is not seen from the back or if it has a back graphic and rotation and should be flipped vertically */ - if ((projectileAspectType >= kProjectileAspectHasRotation) - || ((projectileAspectType == kProjectileAspectBackGraphic) + if ((projectileAspectType >= k2_ProjectileAspectHasRotation) + || ((projectileAspectType == k1_ProjectileAspectBackGraphic) && (projectileDirection != directionParam)) || (projectileAspectTypeHasBackGraphicAndRotation && projectileFlipVertical)) { projectileBitmapIndexData = 0; } else { projectileBitmapIndexData = 1; } - flipVertical = projectileAspectTypeHasBackGraphicAndRotation && (AL_2_viewCell < kViewCellBackRight); - flipHorizontal = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, kProjectileSideMask) - && !((viewLane == kViewLaneRight) || (!viewLane && ((AL_2_viewCell == kViewCellFrontRight) || (AL_2_viewCell == kViewCellBackRight)))); + flipVertical = projectileAspectTypeHasBackGraphicAndRotation && (AL_2_viewCell < k2_ViewCellBackRight); + flipHorizontal = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0010_ProjectileSideMask) + && !((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight)))); } } AL_4_nativeBitmapIndex += projectileBitmapIndexData; @@ -2734,7 +2731,7 @@ T0115129_DrawProjectiles: if (flipHorizontal) { paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; } - derivedBitmapIndex = kDerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6); + derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6); if (doNotScaleWithKineticEnergy && isDerivedBitmapInCache(derivedBitmapIndex) + AL_8_projectileScaleIndex) { AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); } else { @@ -2742,10 +2739,10 @@ T0115129_DrawProjectiles: if (doNotScaleWithKineticEnergy) { AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); } else { - AL_6_bitmapRedBanana = _tmpBitmap; + AL_6_bitmapRedBanana = _g74_tmpBitmap; } blitToBitmapShrinkWithPalChange(bitmapGreenAnt, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, - AL_6_bitmapRedBanana, byteWidth, heightRedEagle, _palChangesProjectile[AL_8_projectileScaleIndex >> 1]); + AL_6_bitmapRedBanana, byteWidth, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]); if (doNotScaleWithKineticEnergy) { warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap"); } @@ -2754,9 +2751,9 @@ T0115129_DrawProjectiles: if (flipHorizontal || flipVertical) { warning("might need noralized bytewidth"); AL_4_normalizdByteWidth = byteWidth; - if (AL_6_bitmapRedBanana != _tmpBitmap) { - memcpy(_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte)); - AL_6_bitmapRedBanana = _tmpBitmap; + if (AL_6_bitmapRedBanana != _g74_tmpBitmap) { + memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte)); + AL_6_bitmapRedBanana = _g74_tmpBitmap; } if (flipVertical) { flipBitmapVertical(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); @@ -2781,17 +2778,17 @@ the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */ AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1)); } - blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, kColorFlesh, gDungeonViewport); + blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, gDungeonViewport); } else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */ useAlcoveObjectImage = false; projectileCoordinates[0] = projectilePosX; projectileCoordinates[1] = 47; coordinateSet = projectileCoordinates; objectAspect = &gObjectAspects[AL_4_projectileAspect]; - AL_4_nativeBitmapIndex = objectAspect->_firstNativeBitmapRelativeIndex + kFirstObjectGraphicIndice; + AL_4_nativeBitmapIndex = objectAspect->_firstNativeBitmapRelativeIndex + k360_FirstObjectGraphicIndice; drawProjectileAsObject = true; /* Go to code section to draw an object. Once completed, it jumps back to T0115171_BackFromT0115015_DrawProjectileAsObject below */ - goto T0115015_DrawProjectileAsObject; + goto T0115015_DrawProjectileAsObject; } } T0115171_BackFromT0115015_DrawProjectileAsObject:; @@ -2812,32 +2809,32 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; AL_2_cellPurpleMan = thingParam.getCell(); explosion = (Explosion*)dunMan.getThingData(thingParam); if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= kExplosionType_RebirthStep1)) - && ((AL_1_viewSquareExplosionIndex < kViewSquare_D3C_Explosion) + && ((AL_1_viewSquareExplosionIndex < kViewSquare_D3C_Explosion) || (AL_1_viewSquareExplosionIndex > kViewSquare_D1C_Explosion) || (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */ continue; smoke = false; if ((AL_4_explosionType == kExplosionType_Fireball) || (AL_4_explosionType == kExplosionType_LightningBolt) || (AL_4_explosionType == kExplosionType_RebirthStep2)) { - AL_4_explosionAspectIndex = kExplosionAspectFire; + AL_4_explosionAspectIndex = k0_ExplosionAspectFire; } else { if ((AL_4_explosionType == kExplosionType_PoisonBolt) || (AL_4_explosionType == kExplosionType_PoisonCloud)) { - AL_4_explosionAspectIndex = kExplosionAspectPoison; + AL_4_explosionAspectIndex = k2_ExplosionAspectPoison; } else { if (AL_4_explosionType == kExplosionType_Smoke) { smoke = true; - AL_4_explosionAspectIndex = kExplosionAspectSmoke; + AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke; } else { if (AL_4_explosionType == kExplosionType_RebirthStep1) { objectAspect = (ObjectAspect*)&gProjectileAspect[_vm->ordinalToIndex(-dunMan.getProjectileAspect(Thing::_explLightningBolt))]; - AL_6_bitmapRedBanana = getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (kFirstProjectileGraphicIndice + 1)); + AL_6_bitmapRedBanana = getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1)); explosionCoordinates = gRebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3]; byteWidth = getScaledDimension((((ProjectileAspect*)objectAspect)->_width), explosionCoordinates[2]); heightRedEagle = getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]); if (AL_1_viewSquareExplosionIndex != kViewSquare_D1C_Explosion) { blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, - ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, _tmpBitmap, - byteWidth, heightRedEagle, gPalChangesNoChanges); - AL_6_bitmapRedBanana = _tmpBitmap; + ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, _g74_tmpBitmap, + byteWidth, heightRedEagle, gPalChangesNoChanges); + AL_6_bitmapRedBanana = _g74_tmpBitmap; } goto T0115200_DrawExplosion; } @@ -2847,7 +2844,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; } continue; } - AL_4_explosionAspectIndex = kExplosionAspectSpell; + AL_4_explosionAspectIndex = k1_ExplosionAspectSpell; } } } @@ -2863,14 +2860,14 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; } } warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache"); - AL_6_bitmapRedBanana = getBitmap(AL_4_explosionAspectIndex + kFirstExplosionPatternGraphicIndice); + AL_6_bitmapRedBanana = getBitmap(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice); if (smoke) { - blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _tmpBitmap, 48, 32, gPalChangeSmoke); - AL_6_bitmapRedBanana = _tmpBitmap; + blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _g74_tmpBitmap, 48, 32, gPalChangeSmoke); + AL_6_bitmapRedBanana = _g74_tmpBitmap; } - blitBoxFilledWithMaskedBitmapToScreen(AL_6_bitmapRedBanana, nullptr, getDerivedBitmap(kDerivedBitmapViewport), gBoxExplosionPattern_D0C, + blitBoxFilledWithMaskedBitmapToScreen(AL_6_bitmapRedBanana, nullptr, getDerivedBitmap(k0_DerivedBitmapViewport), gBoxExplosionPattern_D0C, _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64), - 224, (Color)(kBlitDoNotUseMask | kColorFlesh), 0, 0, 136, 93); + 224, (Color)(kBlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } else { @@ -2882,9 +2879,9 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; explosionCoordinates = gCenteredExplosionCoordinates[AL_1_viewSquareExplosionIndex]; } else { if ((AL_2_cellPurpleMan == directionParam) || (AL_2_cellPurpleMan == returnPrevVal(directionParam))) { - AL_2_viewCell = kViewCellFronLeft; + AL_2_viewCell = k0_ViewCellFronLeft; } else { - AL_2_viewCell = kViewCellFrontRight; + AL_2_viewCell = k1_ViewCellFrontRight; } explosionCoordinates = gExplosionCoordinates[AL_1_viewSquareExplosionIndex][AL_2_viewCell]; } @@ -2897,7 +2894,7 @@ T0115200_DrawExplosion: if (flipHorizontal = _vm->_rnd->getRandomNumber(2)) { paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; /* Number of unused pixels in the units on the right of the bitmap */ } - boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1)) + 1; + boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1)) + 1; AL_4_yPos = MAX(0, explosionCoordinates[1] - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001)); if (AL_4_yPos >= 136) continue; @@ -2913,7 +2910,7 @@ T0115200_DrawExplosion: left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is not flipped horizontally (flipHorizontal = C0_FALSE) then the variable paddingPixelCount is not set before being used here. Its previous value (defined while drawing something else) is used and may cause an incorrect bitmap to be drawn */ - AL_4_xPos = MIN(paddingPixelCount,(int16)( byteWidth / 2 - AL_4_xPos - 1)); + AL_4_xPos = MIN(paddingPixelCount, (int16)(byteWidth / 2 - AL_4_xPos - 1)); /* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap is cropped because it is only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) @@ -2924,8 +2921,8 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP warning("might need M77_NORMALIZED_BYTE_WIDTH"); byteWidth = byteWidth; if (flipHorizontal || flipVertical) { - memcpy(_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle); - AL_6_bitmapRedBanana = _tmpBitmap; + memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle); + AL_6_bitmapRedBanana = _g74_tmpBitmap; } if (flipHorizontal) { flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); @@ -2933,12 +2930,12 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP if (flipVertical) { flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } - blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, kColorFlesh, gDungeonViewport); + blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, gDungeonViewport); } } } while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList); /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */ - if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_doNotDrawFluxcagesDuringEndgame) { + if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_g77_doNotDrawFluxcagesDuringEndgame) { AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */ fieldAspect = gFieldAspects[viewSquareIndex]; (fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */ @@ -2959,16 +2956,16 @@ uint16 DisplayMan::getHorizontalOffsetM22(uint16 val) { } bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) { - if (_derivedBitmaps[derivedBitmapIndex] == nullptr) { + if (_g638_derivedBitmaps[derivedBitmapIndex] == nullptr) { // * 2, because the original uses 4 bits instead of 8 bits to store a pixel - _derivedBitmaps[derivedBitmapIndex] = new byte[_derivedBitmapByteCount[derivedBitmapIndex] * 2]; + _g638_derivedBitmaps[derivedBitmapIndex] = new byte[_g639_derivedBitmapByteCount[derivedBitmapIndex] * 2]; return false; } else return true; } byte* DisplayMan::getDerivedBitmap(int16 derivedBitmapIndex) { - return _derivedBitmaps[derivedBitmapIndex]; + return _g638_derivedBitmaps[derivedBitmapIndex]; } void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) { diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 397417fd75..ca478b32b9 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -36,74 +36,78 @@ namespace DM { +#define k2_FloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT +#define k13_WallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT +#define k18_StairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT +#define k3_DoorSetGraphicsCount 3 // @ C003_DOOR_SET_GRAPHIC_COUNT +#define k1_DoorButtonCount 1 // @ C001_DOOR_BUTTON_COUNT +#define k3_AlcoveOrnCount 3 // @ C003_ALCOVE_ORNAMENT_COUNT +#define k1_FountainOrnCount 1 // @ C001_FOUNTAIN_ORNAMENT_COUNT +#define k27_CreatureTypeCount 27 // @ C027_CREATURE_TYPE_COUNT +#define k4_ExplosionAspectCount 4 // @ C004_EXPLOSION_ASPECT_COUNT +#define k14_ProjectileAspectCount 14 // @ C014_PROJECTILE_ASPECT_COUNT +#define k85_ObjAspectCount 85 // @ C085_OBJECT_ASPECT_COUNT + +#define k0_NativeBitmapIndex 0 // @ C0_NATIVE_BITMAP_INDEX +#define k1_CoordinateSet 1 // @ C1_COORDINATE_SET /* View lanes */ -#define kViewLaneCenter 0 // @ C0_VIEW_LANE_CENTER -#define kViewLaneLeft 1 // @ C1_VIEW_LANE_LEFT -#define kViewLaneRight 2 // @ C2_VIEW_LANE_RIGHT +#define k0_ViewLaneCenter 0 // @ C0_VIEW_LANE_CENTER +#define k1_ViewLaneLeft 1 // @ C1_VIEW_LANE_LEFT +#define k2_ViewLaneRight 2 // @ C2_VIEW_LANE_RIGHT -#define kHalfSizedViewCell_LeftColumn 0 // @ C00_VIEW_CELL_LEFT_COLUMN -#define kHalfSizedViewCell_RightColumn 1 // @ C01_VIEW_CELL_RIGHT_COLUMN -#define kHalfSizedViewCell_BackRow 2 // @ C02_VIEW_CELL_BACK_ROW -#define kHalfSizedViewCell_CenterColumn 3 // @ C03_VIEW_CELL_CENTER_COLUMN -#define kHalfSizedViewCell_FrontRow 4 // @ C04_VIEW_CELL_FRONT_ROW +#define k0_HalfSizedViewCell_LeftColumn 0 // @ C00_VIEW_CELL_LEFT_COLUMN +#define k1_HalfSizedViewCell_RightColumn 1 // @ C01_VIEW_CELL_RIGHT_COLUMN +#define k2_HalfSizedViewCell_BackRow 2 // @ C02_VIEW_CELL_BACK_ROW +#define k3_HalfSizedViewCell_CenterColumn 3 // @ C03_VIEW_CELL_CENTER_COLUMN +#define k4_HalfSizedViewCell_FrontRow 4 // @ C04_VIEW_CELL_FRONT_ROW /* Shift sets */ -#define kShiftSet_D0BackD1Front 0 // @ C0_SHIFT_SET_D0_BACK_OR_D1_FRONT -#define kShiftSet_D1BackD2Front 1 // @ C1_SHIFT_SET_D1_BACK_OR_D2_FRONT -#define kShiftSet_D2BackD3Front 2 // @ C2_SHIFT_SET_D2_BACK_OR_D3_FRONT - -#define kCellOrder_DoorFront 0x0008 // @ MASK0x0008_DOOR_FRONT -#define kCellOrder_Alcove 0x0000 // @ C0000_CELL_ORDER_ALCOVE -#define kCellOrder_BackLeft 0x0001 // @ C0001_CELL_ORDER_BACKLEFT -#define kCellOrder_BackRight 0x0002 // @ C0002_CELL_ORDER_BACKRIGHT -#define kCellOrder_DoorPass1_BackLeft 0x0018 // @ C0018_CELL_ORDER_DOORPASS1_BACKLEFT -#define kCellOrder_BackLeft_BackRight 0x0021 // @ C0021_CELL_ORDER_BACKLEFT_BACKRIGHT -#define kCellOrder_DoorPass1_BackRight 0x0028 // @ C0028_CELL_ORDER_DOORPASS1_BACKRIGHT -#define kCellOrder_BackRight_FrontRight 0x0032 // @ C0032_CELL_ORDER_BACKRIGHT_FRONTRIGHT -#define kCellOrder_DoorPass2_FrontRight 0x0039 // @ C0039_CELL_ORDER_DOORPASS2_FRONTRIGHT -#define kCellOrder_BackLeft_FrontLeft 0x0041 // @ C0041_CELL_ORDER_BACKLEFT_FRONTLEFT -#define kCellOrder_DoorPass2_FrontLeft 0x0049 // @ C0049_CELL_ORDER_DOORPASS2_FRONTLEFT -#define kCellOrder_DoorPass1_BackRight_BackLeft 0x0128 // @ C0128_CELL_ORDER_DOORPASS1_BACKRIGHT_BACKLEFT -#define kCellOrder_DoorPass1_BackLeft_BackRight 0x0218 // @ C0218_CELL_ORDER_DOORPASS1_BACKLEFT_BACKRIGHT -#define kCellOrder_BackLeft_BackRight_FrontRight 0x0321 // @ C0321_CELL_ORDER_BACKLEFT_BACKRIGHT_FRONTRIGHT -#define kCellOrder_BackRight_FrontLeft_FrontRight 0x0342 // @ C0342_CELL_ORDER_BACKRIGHT_FRONTLEFT_FRONTRIGHT -#define kCellOrder_DoorPass2_FrontLeft_FrontRight 0x0349 // @ C0349_CELL_ORDER_DOORPASS2_FRONTLEFT_FRONTRIGHT -#define kCellOrder_BackRight_BackLeft_FrontLeft 0x0412 // @ C0412_CELL_ORDER_BACKRIGHT_BACKLEFT_FRONTLEFT -#define kCellOrder_BackLeft_FrontRight_FrontLeft 0x0431 // @ C0431_CELL_ORDER_BACKLEFT_FRONTRIGHT_FRONTLEFT -#define kCellOrder_DoorPass2_FrontRight_FrontLeft 0x0439 // @ C0439_CELL_ORDER_DOORPASS2_FRONTRIGHT_FRONTLEFT -#define kCellOrder_BackLeft_BackRight_FrontLeft_FrontRight 0x3421 // @ C3421_CELL_ORDER_BACKLEFT_BACKRIGHT_FRONTLEFT_FRONTRIGHT -#define kCellOrder_BackRight_BackLeft_FrontRight_FrontLeft 0x4312 // @ C4312_CELL_ORDER_BACKRIGHT_BACKLEFT_FRONTRIGHT_FRONTLEFT - - -#define kFloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT -#define kWallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT -#define kStairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT -#define kDoorSetGraphicsCount 3 // @ C003_DOOR_SET_GRAPHIC_COUNT -#define kDoorButtonCount 1 // @ C001_DOOR_BUTTON_COUNT -#define kNativeBitmapIndex 0 // @ C0_NATIVE_BITMAP_INDEX -#define kCoordinateSet 1 // @ C1_COORDINATE_SET -#define kCreatureTypeCount 27 // @ C027_CREATURE_TYPE_COUNT -#define kExplosionAspectCount 4 // @ C004_EXPLOSION_ASPECT_COUNT -#define kObjAspectCount 85 // @ C085_OBJECT_ASPECT_COUNT -#define kProjectileAspectCount 14 // @ C014_PROJECTILE_ASPECT_COUNT +#define k0_ShiftSet_D0BackD1Front 0 // @ C0_SHIFT_SET_D0_BACK_OR_D1_FRONT +#define k1_ShiftSet_D1BackD2Front 1 // @ C1_SHIFT_SET_D1_BACK_OR_D2_FRONT +#define k2_ShiftSet_D2BackD3Front 2 // @ C2_SHIFT_SET_D2_BACK_OR_D3_FRONT + +#define k0x0008_CellOrder_DoorFront 0x0008 // @ MASK0x0008_DOOR_FRONT +#define k0x0000_CellOrder_Alcove 0x0000 // @ C0000_CELL_ORDER_ALCOVE +#define k0x0001_CellOrder_BackLeft 0x0001 // @ C0001_CELL_ORDER_BACKLEFT +#define k0x0002_CellOrder_BackRight 0x0002 // @ C0002_CELL_ORDER_BACKRIGHT +#define k0x0018_CellOrder_DoorPass1_BackLeft 0x0018 // @ C0018_CELL_ORDER_DOORPASS1_BACKLEFT +#define k0x0021_CellOrder_BackLeft_BackRight 0x0021 // @ C0021_CELL_ORDER_BACKLEFT_BACKRIGHT +#define k0x0028_CellOrder_DoorPass1_BackRight 0x0028 // @ C0028_CELL_ORDER_DOORPASS1_BACKRIGHT +#define k0x0032_CellOrder_BackRight_FrontRight 0x0032 // @ C0032_CELL_ORDER_BACKRIGHT_FRONTRIGHT +#define k0x0039_CellOrder_DoorPass2_FrontRight 0x0039 // @ C0039_CELL_ORDER_DOORPASS2_FRONTRIGHT +#define k0x0041_CellOrder_BackLeft_FrontLeft 0x0041 // @ C0041_CELL_ORDER_BACKLEFT_FRONTLEFT +#define k0x0049_CellOrder_DoorPass2_FrontLeft 0x0049 // @ C0049_CELL_ORDER_DOORPASS2_FRONTLEFT +#define k0x0128_CellOrder_DoorPass1_BackRight_BackLeft 0x0128 // @ C0128_CELL_ORDER_DOORPASS1_BACKRIGHT_BACKLEFT +#define k0x0218_CellOrder_DoorPass1_BackLeft_BackRight 0x0218 // @ C0218_CELL_ORDER_DOORPASS1_BACKLEFT_BACKRIGHT +#define k0x0321_CellOrder_BackLeft_BackRight_FrontRight 0x0321 // @ C0321_CELL_ORDER_BACKLEFT_BACKRIGHT_FRONTRIGHT +#define k0x0342_CellOrder_BackRight_FrontLeft_FrontRight 0x0342 // @ C0342_CELL_ORDER_BACKRIGHT_FRONTLEFT_FRONTRIGHT +#define k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight 0x0349 // @ C0349_CELL_ORDER_DOORPASS2_FRONTLEFT_FRONTRIGHT +#define k0x0412_CellOrder_BackRight_BackLeft_FrontLeft 0x0412 // @ C0412_CELL_ORDER_BACKRIGHT_BACKLEFT_FRONTLEFT +#define k0x0431_CellOrder_BackLeft_FrontRight_FrontLeft 0x0431 // @ C0431_CELL_ORDER_BACKLEFT_FRONTRIGHT_FRONTLEFT +#define k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft 0x0439 // @ C0439_CELL_ORDER_DOORPASS2_FRONTRIGHT_FRONTLEFT +#define k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight 0x3421 // @ C3421_CELL_ORDER_BACKLEFT_BACKRIGHT_FRONTLEFT_FRONTRIGHT +#define k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft 0x4312 // @ C4312_CELL_ORDER_BACKRIGHT_BACKLEFT_FRONTRIGHT_FRONTLEFT + + + /* Explosion aspects */ -#define kExplosionAspectFire 0 // @ C0_EXPLOSION_ASPECT_FIRE -#define kExplosionAspectSpell 1 // @ C1_EXPLOSION_ASPECT_SPELL -#define kExplosionAspectPoison 2 // @ C2_EXPLOSION_ASPECT_POISON -#define kExplosionAspectSmoke 3 // @ C3_EXPLOSION_ASPECT_SMOKE +#define k0_ExplosionAspectFire 0 // @ C0_EXPLOSION_ASPECT_FIRE +#define k1_ExplosionAspectSpell 1 // @ C1_EXPLOSION_ASPECT_SPELL +#define k2_ExplosionAspectPoison 2 // @ C2_EXPLOSION_ASPECT_POISON +#define k3_ExplosionAspectSmoke 3 // @ C3_EXPLOSION_ASPECT_SMOKE /* Creature info GraphicInfo */ -#define kCreatureInfoGraphicMaskAdditional 0x0003 // @ MASK0x0003_ADDITIONAL -#define kCreatureInfoGraphicMaskFlipNonAttack 0x0004 // @ MASK0x0004_FLIP_NON_ATTACK -#define kCreatureInfoGraphicMaskSide 0x0008 // @ MASK0x0008_SIDE -#define kCreatureInfoGraphicMaskBack 0x0010 // @ MASK0x0010_BACK -#define kCreatureInfoGraphicMaskAttack 0x0020 // @ MASK0x0020_ATTACK -#define kCreatureInfoGraphicMaskSpecialD2Front 0x0080 // @ MASK0x0080_SPECIAL_D2_FRONT -#define kCreatureInfoGraphicMaskSpecialD2FrontIsFlipped 0x0100 // @ MASK0x0100_SPECIAL_D2_FRONT_IS_FLIPPED_FRONT -#define kCreatureInfoGraphicMaskFlipAttack 0x0200 // @ MASK0x0200_FLIP_ATTACK -#define kCreatureInfoGraphicMaskFlipDuringAttack 0x0400 // @ MASK0x0400_FLIP_DURING_ATTACK +#define k0x0003_CreatureInfoGraphicMaskAdditional 0x0003 // @ MASK0x0003_ADDITIONAL +#define k0x0004_CreatureInfoGraphicMaskFlipNonAttack 0x0004 // @ MASK0x0004_FLIP_NON_ATTACK +#define k0x0008_CreatureInfoGraphicMaskSide 0x0008 // @ MASK0x0008_SIDE +#define k0x0010_CreatureInfoGraphicMaskBack 0x0010 // @ MASK0x0010_BACK +#define k0x0020_CreatureInfoGraphicMaskAttack 0x0020 // @ MASK0x0020_ATTACK +#define k0x0080_CreatureInfoGraphicMaskSpecialD2Front 0x0080 // @ MASK0x0080_SPECIAL_D2_FRONT +#define k0x0100_CreatureInfoGraphicMaskSpecialD2FrontIsFlipped 0x0100 // @ MASK0x0100_SPECIAL_D2_FRONT_IS_FLIPPED_FRONT +#define k0x0200_CreatureInfoGraphicMaskFlipAttack 0x0200 // @ MASK0x0200_FLIP_ATTACK +#define k0x0400_CreatureInfoGraphicMaskFlipDuringAttack 0x0400 // @ MASK0x0400_FLIP_DURING_ATTACK class ExplosionAspect { public: @@ -113,118 +117,118 @@ public: ExplosionAspect(uint16 byteWidth, uint16 height) :_pixelWidth(byteWidth * 2), _height(height) {} }; // @ EXPLOSION_ASPECT -extern ExplosionAspect gExplosionAspects[kExplosionAspectCount]; +extern ExplosionAspect g211_ExplosionAspects[k4_ExplosionAspectCount]; // @ G0211_as_Graphic558_ExplosionAspects -extern byte gProjectileScales[7]; // @ G0215_auc_Graphic558_ProjectileScales +extern byte g215_ProjectileScales[7]; // @ G0215_auc_Graphic558_ProjectileScales -#define kDerivedBitmapViewport 0 // @ C000_DERIVED_BITMAP_VIEWPORT -#define kDerivedBitmapThievesEyeVisibleArea 1 // @ C001_DERIVED_BITMAP_THIEVES_EYE_VISIBLE_AREA -#define kDerivedBitmapDamageToCreatureMedium 2 // @ C002_DERIVED_BITMAP_DAMAGE_TO_CREATURE_MEDIUM -#define kDerivedBitmapDamageToCreatureSmall 3 // @ C003_DERIVED_BITMAP_DAMAGE_TO_CREATURE_SMALL -#define kDerivedBitmapFirstWallOrnament 4 // @ C004_DERIVED_BITMAP_FIRST_WALL_ORNAMENT -#define kDerivedBitmapFirstDoorOrnament_D3 68 // @ C068_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D3 -#define kDerivedBitmapFirstDoorOrnament_D2 69 // @ C069_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D2 -#define kDerivedBitmapFirstDoorButton 102 // @ C102_DERIVED_BITMAP_FIRST_DOOR_BUTTON -#define kDerivedBitmapFirstObject 104 // @ C104_DERIVED_BITMAP_FIRST_OBJECT -#define kDerivedBitmapFirstProjectile 282 // @ C282_DERIVED_BITMAP_FIRST_PROJECTILE -#define kDerivedBitmapFirstExplosion 438 // @ C438_DERIVED_BITMAP_FIRST_EXPLOSION -#define kDerivedBitmapFirstCreature 495 // @ C495_DERIVED_BITMAP_FIRST_CREATURE +#define k0_DerivedBitmapViewport 0 // @ C000_DERIVED_BITMAP_VIEWPORT +#define k1_DerivedBitmapThievesEyeVisibleArea 1 // @ C001_DERIVED_BITMAP_THIEVES_EYE_VISIBLE_AREA +#define k2_DerivedBitmapDamageToCreatureMedium 2 // @ C002_DERIVED_BITMAP_DAMAGE_TO_CREATURE_MEDIUM +#define k3_DerivedBitmapDamageToCreatureSmall 3 // @ C003_DERIVED_BITMAP_DAMAGE_TO_CREATURE_SMALL +#define k4_DerivedBitmapFirstWallOrnament 4 // @ C004_DERIVED_BITMAP_FIRST_WALL_ORNAMENT +#define k68_DerivedBitmapFirstDoorOrnament_D3 68 // @ C068_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D3 +#define k69_DerivedBitmapFirstDoorOrnament_D2 69 // @ C069_DERIVED_BITMAP_FIRST_DOOR_ORNAMENT_D2 +#define k102_DerivedBitmapFirstDoorButton 102 // @ C102_DERIVED_BITMAP_FIRST_DOOR_BUTTON +#define k104_DerivedBitmapFirstObject 104 // @ C104_DERIVED_BITMAP_FIRST_OBJECT +#define k282_DerivedBitmapFirstProjectile 282 // @ C282_DERIVED_BITMAP_FIRST_PROJECTILE +#define k438_DerivedBitmapFirstExplosion 438 // @ C438_DERIVED_BITMAP_FIRST_EXPLOSION +#define k495_DerivedBitmapFirstCreature 495 // @ C495_DERIVED_BITMAP_FIRST_CREATURE -#define kScale16_D3 16 // @ C16_SCALE_D3 -#define kScale20_D2 20 // @ C20_SCALE_D2 +#define k16_Scale_D3 16 // @ C16_SCALE_D3 +#define k20_Scale_D2 20 // @ C20_SCALE_D2 /* Object aspect GraphicInfo */ -#define kObjectFlipOnRightMask 0x0001 // @ MASK0x0001_FLIP_ON_RIGHT -#define kObjectAlcoveMask 0x0010 // @ MASK0x0010_ALCOVE +#define k0x0001_ObjectFlipOnRightMask 0x0001 // @ MASK0x0001_FLIP_ON_RIGHT +#define k0x0010_ObjectAlcoveMask 0x0010 // @ MASK0x0010_ALCOVE /* Projectile aspect GraphicInfo */ -#define kProjectileSideMask 0x0010 // @ MASK0x0010_SIDE -#define kProjectileScaleWithKineticEnergyMask 0x0100 // @ MASK0x0100_SCALE_WITH_KINETIC_ENERGY -#define kProjectileAspectTypeMask 0x0003 // @ MASK0x0003_ASPECT_TYPE +#define k0x0010_ProjectileSideMask 0x0010 // @ MASK0x0010_SIDE +#define k0x0100_ProjectileScaleWithKineticEnergyMask 0x0100 // @ MASK0x0100_SCALE_WITH_KINETIC_ENERGY +#define k0x0003_ProjectileAspectTypeMask 0x0003 // @ MASK0x0003_ASPECT_TYPE /* Projectile aspect type */ -#define kProjectileAspectHasBackGraphicRotation 0 // @ C0_PROJECTILE_ASPECT_TYPE_HAS_BACK_GRAPHIC_AND_ROTATION -#define kProjectileAspectBackGraphic 1 // @ C1_PROJECTILE_ASPECT_TYPE_HAS_BACK_GRAPHIC_AND_NO_ROTATION -#define kProjectileAspectHasRotation 2 // @ C2_PROJECTILE_ASPECT_TYPE_NO_BACK_GRAPHIC_AND_ROTATION -#define kProjectileAspectHasNone 3 // @ C3_PROJECTILE_ASPECT_TYPE_NO_BACK_GRAPHIC_AND_NO_ROTATION +#define k0_ProjectileAspectHasBackGraphicRotation 0 // @ C0_PROJECTILE_ASPECT_TYPE_HAS_BACK_GRAPHIC_AND_ROTATION +#define k1_ProjectileAspectBackGraphic 1 // @ C1_PROJECTILE_ASPECT_TYPE_HAS_BACK_GRAPHIC_AND_NO_ROTATION +#define k2_ProjectileAspectHasRotation 2 // @ C2_PROJECTILE_ASPECT_TYPE_NO_BACK_GRAPHIC_AND_ROTATION +#define k3_ProjectileAspectHasNone 3 // @ C3_PROJECTILE_ASPECT_TYPE_NO_BACK_GRAPHIC_AND_NO_ROTATION /* Projectile aspects */ -#define kProjectileAspectExplosionLightningBolt 3 // @ C03_PROJECTILE_ASPECT_EXPLOSION_LIGHTNING_BOLT -#define kProjectileAspectExplosionFireBall 10 // @ C10_PROJECTILE_ASPECT_EXPLOSION_FIREBALL -#define kProjectileAspectExplosionDefault 11 // @ C11_PROJECTILE_ASPECT_EXPLOSION_DEFAULT -#define kProjectileAspectExplosionSlime 12 // @ C12_PROJECTILE_ASPECT_EXPLOSION_SLIME -#define kProjectileAspectExplosionPoisonBoltCloud 13 // @ C13_PROJECTILE_ASPECT_EXPLOSION_POISON_BOLT_POISON_CLOUD +#define k3_ProjectileAspectExplosionLightningBolt 3 // @ C03_PROJECTILE_ASPECT_EXPLOSION_LIGHTNING_BOLT +#define k10_ProjectileAspectExplosionFireBall 10 // @ C10_PROJECTILE_ASPECT_EXPLOSION_FIREBALL +#define k11_ProjectileAspectExplosionDefault 11 // @ C11_PROJECTILE_ASPECT_EXPLOSION_DEFAULT +#define k12_ProjectileAspectExplosionSlime 12 // @ C12_PROJECTILE_ASPECT_EXPLOSION_SLIME +#define k13_ProjectileAspectExplosionPoisonBoltCloud 13 // @ C13_PROJECTILE_ASPECT_EXPLOSION_POISON_BOLT_POISON_CLOUD enum ViewCell { - kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT - kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT - kViewCellBackRight = 2, // @ C02_VIEW_CELL_BACK_RIGHT - kViewCellBackLeft = 3, // @ C03_VIEW_CELL_BACK_LEFT - kViewCellAlcove = 4, // @ C04_VIEW_CELL_ALCOVE - kViewCellDoorButtonOrWallOrn = 5 // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT + k0_ViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT + k1_ViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT + k2_ViewCellBackRight = 2, // @ C02_VIEW_CELL_BACK_RIGHT + k3_ViewCellBackLeft = 3, // @ C03_VIEW_CELL_BACK_LEFT + k4_ViewCellAlcove = 4, // @ C04_VIEW_CELL_ALCOVE + k5_ViewCellDoorButtonOrWallOrn = 5 // @ C05_VIEW_CELL_DOOR_BUTTON_OR_WALL_ORNAMENT }; enum GraphicIndice { - kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT - kDoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED - kChampionPortraitsIndice = 26, // @ C026_GRAPHIC_CHAMPION_PORTRAITS - kMovementArrowsIndice = 13, // @ C013_GRAPHIC_MOVEMENT_ARROWS - kObjectIcons_000_TO_031 = 42, // @ C042_GRAPHIC_OBJECT_ICONS_000_TO_031 - kObjectIcons_032_TO_063 = 43, // @ C043_GRAPHIC_OBJECT_ICONS_032_TO_063 - kObjectIcons_064_TO_095 = 44, // @ C044_GRAPHIC_OBJECT_ICONS_064_TO_095 - kObjectIcons_096_TO_127 = 45, // @ C045_GRAPHIC_OBJECT_ICONS_096_TO_127 - kObjectIcons_128_TO_159 = 46, // @ C046_GRAPHIC_OBJECT_ICONS_128_TO_159 - kObjectIcons_160_TO_191 = 47, // @ C047_GRAPHIC_OBJECT_ICONS_160_TO_191 - kObjectIcons_192_TO_223 = 48, // @ C048_GRAPHIC_OBJECT_ICONS_192_TO_223 - kInventoryGraphicIndice = 17, // @ C017_GRAPHIC_INVENTORY - kPanelEmptyIndice = 20, // @ C020_GRAPHIC_PANEL_EMPTY - kFoodLabelIndice = 30, // @ C030_GRAPHIC_FOOD_LABEL - kWaterLabelIndice = 31, // @ C031_GRAPHIC_WATER_LABEL - kPoisionedLabelIndice = 32, // @ C032_GRAPHIC_POISONED_LABEL - kPanelResurectReincaranteIndice = 40, // @ C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE - kBorderPartyShieldIndice = 37, // @ C037_GRAPHIC_BORDER_PARTY_SHIELD - kBorderPartyFireshieldIndice = 38, // @ C038_GRAPHIC_BORDER_PARTY_FIRESHIELD - kBorderPartySpellshieldIndice = 39, // @ C039_GRAPHIC_BORDER_PARTY_SPELLSHIELD - kStatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION - kSlotBoxNormalIndice = 33, // @ C033_GRAPHIC_SLOT_BOX_NORMAL - kSlotBoxWoundedIndice = 34, // @ C034_GRAPHIC_SLOT_BOX_WOUNDED - kChampionIcons = 28, // @ C028_GRAPHIC_CHAMPION_ICONS - kFontGraphicIndice = 557, // @ C557_GRAPHIC_FONT - kSlotBoxActingHandIndice = 35, // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND - kPanelRenameChampionIndice = 27, // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION - kMenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA - kMenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES - kMenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND - kPanelOpenScrollIndice = 23, // @ C023_GRAPHIC_PANEL_OPEN_SCROLL - kPanelOpenChestIndice = 25, // @ C025_GRAPHIC_PANEL_OPEN_CHEST - kEyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION - kArrowForChestContentIndice = 18, // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT - kObjectDescCircleIndice = 29, // @ C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE - kFloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS - kFieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R - kFieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER - kFirstExplosionGraphicIndice = 348, // @ C348_GRAPHIC_FIRST_EXPLOSION - kFirstObjectGraphicIndice = 360, // @ C360_GRAPHIC_FIRST_OBJECT - kFirstCreatureGraphicIndice = 446, // @ C446_GRAPHIC_FIRST_CREATURE - kFirstProjectileGraphicIndice = 316, // @ C316_GRAPHIC_FIRST_PROJECTILE - kFirstExplosionPatternGraphicIndice = 351, // @ C351_GRAPHIC_FIRST_EXPLOSION_PATTERN - k049FloorPit_D3L_GraphicIndice = 49, // @ C049_GRAPHIC_FLOOR_PIT_D3L - k050FloorPit_D3C_GraphicIndice = 50, // @ C050_GRAPHIC_FLOOR_PIT_D3C - k051FloorPit_D2L_GraphicIndice = 51, // @ C051_GRAPHIC_FLOOR_PIT_D2L - k052FloorPit_D2C_GraphicIndice = 52, // @ C052_GRAPHIC_FLOOR_PIT_D2C - k053FloorPit_D1L_GraphicIndice = 53, // @ C053_GRAPHIC_FLOOR_PIT_D1L - k054FloorPit_D1C_GraphicIndice = 54, // @ C054_GRAPHIC_FLOOR_PIT_D1C - k055FloorPit_D0L_GraphicIndice = 55, // @ C055_GRAPHIC_FLOOR_PIT_D0L - k056FloorPit_D0C_GraphicIndice = 56 // @ C056_GRAPHIC_FLOOR_PIT_D0C + k8_StatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION + k9_MenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND + k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA + k11_MenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES + k13_MovementArrowsIndice = 13, // @ C013_GRAPHIC_MOVEMENT_ARROWS + k17_InventoryGraphicIndice = 17, // @ C017_GRAPHIC_INVENTORY + k18_ArrowForChestContentIndice = 18, // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT + k19_EyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION + k20_PanelEmptyIndice = 20, // @ C020_GRAPHIC_PANEL_EMPTY + k23_PanelOpenScrollIndice = 23, // @ C023_GRAPHIC_PANEL_OPEN_SCROLL + k25_PanelOpenChestIndice = 25, // @ C025_GRAPHIC_PANEL_OPEN_CHEST + k26_ChampionPortraitsIndice = 26, // @ C026_GRAPHIC_CHAMPION_PORTRAITS + k27_PanelRenameChampionIndice = 27, // @ C027_GRAPHIC_PANEL_RENAME_CHAMPION + k28_ChampionIcons = 28, // @ C028_GRAPHIC_CHAMPION_ICONS + k29_ObjectDescCircleIndice = 29, // @ C029_GRAPHIC_OBJECT_DESCRIPTION_CIRCLE + k30_FoodLabelIndice = 30, // @ C030_GRAPHIC_FOOD_LABEL + k31_WaterLabelIndice = 31, // @ C031_GRAPHIC_WATER_LABEL + k32_PoisionedLabelIndice = 32, // @ C032_GRAPHIC_POISONED_LABEL + k33_SlotBoxNormalIndice = 33, // @ C033_GRAPHIC_SLOT_BOX_NORMAL + k34_SlotBoxWoundedIndice = 34, // @ C034_GRAPHIC_SLOT_BOX_WOUNDED + k35_SlotBoxActingHandIndice = 35, // @ C035_GRAPHIC_SLOT_BOX_ACTING_HAND + k37_BorderPartyShieldIndice = 37, // @ C037_GRAPHIC_BORDER_PARTY_SHIELD + k38_BorderPartyFireshieldIndice = 38, // @ C038_GRAPHIC_BORDER_PARTY_FIRESHIELD + k39_BorderPartySpellshieldIndice = 39, // @ C039_GRAPHIC_BORDER_PARTY_SPELLSHIELD + k40_PanelResurectReincaranteIndice = 40, // @ C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE + k42_ObjectIcons_000_TO_031 = 42, // @ C042_GRAPHIC_OBJECT_ICONS_000_TO_031 + k43_ObjectIcons_032_TO_063 = 43, // @ C043_GRAPHIC_OBJECT_ICONS_032_TO_063 + k44_ObjectIcons_064_TO_095 = 44, // @ C044_GRAPHIC_OBJECT_ICONS_064_TO_095 + k45_ObjectIcons_096_TO_127 = 45, // @ C045_GRAPHIC_OBJECT_ICONS_096_TO_127 + k46_ObjectIcons_128_TO_159 = 46, // @ C046_GRAPHIC_OBJECT_ICONS_128_TO_159 + k47_ObjectIcons_160_TO_191 = 47, // @ C047_GRAPHIC_OBJECT_ICONS_160_TO_191 + k48_ObjectIcons_192_TO_223 = 48, // @ C048_GRAPHIC_OBJECT_ICONS_192_TO_223 + k49_FloorPit_D3L_GraphicIndice = 49, // @ C049_GRAPHIC_FLOOR_PIT_D3L + k50_FloorPit_D3C_GraphicIndice = 50, // @ C050_GRAPHIC_FLOOR_PIT_D3C + k51_FloorPit_D2L_GraphicIndice = 51, // @ C051_GRAPHIC_FLOOR_PIT_D2L + k52_FloorPit_D2C_GraphicIndice = 52, // @ C052_GRAPHIC_FLOOR_PIT_D2C + k53_FloorPit_D1L_GraphicIndice = 53, // @ C053_GRAPHIC_FLOOR_PIT_D1L + k54_FloorPit_D1C_GraphicIndice = 54, // @ C054_GRAPHIC_FLOOR_PIT_D1C + k55_FloorPit_D0L_GraphicIndice = 55, // @ C055_GRAPHIC_FLOOR_PIT_D0L + k56_FloorPit_D0C_GraphicIndice = 56, // @ C056_GRAPHIC_FLOOR_PIT_D0C + k69_FieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R + k73_FieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER + k120_InscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT + k241_FloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS + k301_DoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED + k316_FirstProjectileGraphicIndice = 316, // @ C316_GRAPHIC_FIRST_PROJECTILE + k348_FirstExplosionGraphicIndice = 348, // @ C348_GRAPHIC_FIRST_EXPLOSION + k351_FirstExplosionPatternGraphicIndice = 351, // @ C351_GRAPHIC_FIRST_EXPLOSION_PATTERN + k360_FirstObjectGraphicIndice = 360, // @ C360_GRAPHIC_FIRST_OBJECT + k446_FirstCreatureGraphicIndice = 446, // @ C446_GRAPHIC_FIRST_CREATURE + k557_FontGraphicIndice = 557 // @ C557_GRAPHIC_FONT }; -extern uint16 gPalSwoosh[16]; -extern uint16 gPalMousePointer[16]; -extern uint16 gPalCredits[16]; -extern uint16 gPalEntrance[16]; -extern uint16 gPalDungeonView[6][16]; +extern uint16 gK57_PalSwoosh[16]; // @ K0057_aui_Palette_Swoosh +extern uint16 gK150_PalMousePointer[16]; // @ K0150_aui_Palette_MousePointer +extern uint16 g19_PalCredits[16]; // @ G0019_aui_Graphic562_Palette_Credits +extern uint16 g20_PalEntrance[16]; // @ G0020_aui_Graphic562_Palette_Entrance +extern uint16 g21_PalDungeonView[6][16]; // @ G0021_aaui_Graphic562_Palette_DungeonView class Box { public: @@ -241,7 +245,7 @@ public: void setToZero() { _x1 = _x2 = _y1 = _y2 = 0; } }; // @ BOX_BYTE, BOX_WORD -extern Box gBoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows +extern Box g2_BoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows class Frame { public: @@ -257,47 +261,47 @@ public: }; enum WallSet { - kWallSetStone = 0 // @ C0_WALL_SET_STONE + k0_WallSetStone = 0 // @ C0_WALL_SET_STONE }; enum FloorSet { - kFloorSetStone = 0 // @ C0_FLOOR_SET_STONE + k0_FloorSetStone = 0 // @ C0_FLOOR_SET_STONE }; enum ViewWall { - kViewWall_D3L_RIGHT = 0, // @ C00_VIEW_WALL_D3L_RIGHT - kViewWall_D3R_LEFT = 1, // @ C01_VIEW_WALL_D3R_LEFT - kViewWall_D3L_FRONT = 2, // @ C02_VIEW_WALL_D3L_FRONT - kViewWall_D3C_FRONT = 3, // @ C03_VIEW_WALL_D3C_FRONT - kViewWall_D3R_FRONT = 4, // @ C04_VIEW_WALL_D3R_FRONT - kViewWall_D2L_RIGHT = 5, // @ C05_VIEW_WALL_D2L_RIGHT - kViewWall_D2R_LEFT = 6, // @ C06_VIEW_WALL_D2R_LEFT - kViewWall_D2L_FRONT = 7, // @ C07_VIEW_WALL_D2L_FRONT - kViewWall_D2C_FRONT = 8, // @ C08_VIEW_WALL_D2C_FRONT - kViewWall_D2R_FRONT = 9, // @ C09_VIEW_WALL_D2R_FRONT - kViewWall_D1L_RIGHT = 10, // @ C10_VIEW_WALL_D1L_RIGHT - kViewWall_D1R_LEFT = 11, // @ C11_VIEW_WALL_D1R_LEFT - kViewWall_D1C_FRONT = 12 // @ C12_VIEW_WALL_D1C_FRONT + k0_ViewWall_D3L_RIGHT = 0, // @ C00_VIEW_WALL_D3L_RIGHT + k1_ViewWall_D3R_LEFT = 1, // @ C01_VIEW_WALL_D3R_LEFT + k2_ViewWall_D3L_FRONT = 2, // @ C02_VIEW_WALL_D3L_FRONT + k3_ViewWall_D3C_FRONT = 3, // @ C03_VIEW_WALL_D3C_FRONT + k4_ViewWall_D3R_FRONT = 4, // @ C04_VIEW_WALL_D3R_FRONT + k5_ViewWall_D2L_RIGHT = 5, // @ C05_VIEW_WALL_D2L_RIGHT + k6_ViewWall_D2R_LEFT = 6, // @ C06_VIEW_WALL_D2R_LEFT + k7_ViewWall_D2L_FRONT = 7, // @ C07_VIEW_WALL_D2L_FRONT + k8_ViewWall_D2C_FRONT = 8, // @ C08_VIEW_WALL_D2C_FRONT + k9_ViewWall_D2R_FRONT = 9, // @ C09_VIEW_WALL_D2R_FRONT + k10_ViewWall_D1L_RIGHT = 10, // @ C10_VIEW_WALL_D1L_RIGHT + k11_ViewWall_D1R_LEFT = 11, // @ C11_VIEW_WALL_D1R_LEFT + k12_ViewWall_D1C_FRONT = 12 // @ C12_VIEW_WALL_D1C_FRONT }; enum Color { - kColorNoTransparency = 255, - kColorBlack = 0, - kColorDarkGary = 1, - kColorLightGray = 2, - kColorDarkBrown = 3, - kColorCyan = 4, - kColorLightBrown = 5, - kColorDarkGreen = 6, - kColorLightGreen = 7, - kColorRed = 8, - kColorGold = 9, - kColorFlesh = 10, - kColorYellow = 11, - kColorDarkestGray = 12, - kColorLightestGray = 13, - kColorBlue = 14, - kColorWhite = 15 + k255_ColorNoTransparency = 255, + k0_ColorBlack = 0, + k1_ColorDarkGary = 1, + k2_ColorLightGray = 2, + k3_ColorDarkBrown = 3, + k4_ColorCyan = 4, + k5_ColorLightBrown = 5, + k6_ColorDarkGreen = 6, + k7_ColorLightGreen = 7, + k8_ColorRed = 8, + k9_ColorGold = 9, + k10_ColorFlesh = 10, + k11_ColorYellow = 11, + k12_ColorDarkestGray = 12, + k13_ColorLightestGray = 13, + k14_ColorBlue = 14, + k15_ColorWhite = 15 }; class FieldAspect { @@ -326,7 +330,8 @@ public: :_posX(posX), _posY(posY), _width(width), _height(height) {} }; -struct CreatureAspect { +class CreatureAspect { +public: uint16 _firstNativeBitmapRelativeIndex; uint16 _firstDerivedBitmapIndex; byte _byteWidthFront; @@ -335,16 +340,33 @@ struct CreatureAspect { byte _heightSide; byte _byteWidthAttack; byte _heightAttack; +private: byte _coordinateSet_TransparentColor; byte _replacementColorSetIndices; +public: + + CreatureAspect(uint16 uint161, uint16 uint162, byte byte0, byte byte1, byte byte2, byte byte3, byte byte4, byte byte5, byte byte6, byte byte7) + : _firstNativeBitmapRelativeIndex(uint161), + _firstDerivedBitmapIndex(uint162), + _byteWidthFront(byte0 * 2), + _heightFront(byte1), + _byteWidthSide(byte2 * 2), + _heightSide(byte3), + _byteWidthAttack(byte4 * 2), + _heightAttack(byte5), + _coordinateSet_TransparentColor(byte6), + _replacementColorSetIndices(byte7) {} byte getCoordSet() { return (_coordinateSet_TransparentColor >> 4) & 0xF; } // @ M71_COORDINATE_SET byte getTranspColour() { return _coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR byte getReplColour10() { return (_replacementColorSetIndices >> 4) & 0xF; } // @ M74_COLOR_10_REPLACEMENT_COLOR_SET byte getReplColour9() { return _replacementColorSetIndices & 0xF; } // @ M73_COLOR_09_REPLACEMENT_COLOR_SET + + }; // @ CREATURE_ASPECT -struct ObjectAspect { +class ObjectAspect { +public: byte _firstNativeBitmapRelativeIndex; byte _firstDerivedBitmapRelativeIndex; byte _width; @@ -356,7 +378,8 @@ struct ObjectAspect { _width(byteWidth * 2), _height(h), _graphicInfo(grap), _coordinateSet(coord) {} }; // @ OBJECT_ASPECT -struct ProjectileAspect { +class ProjectileAspect { +public: byte _firstNativeBitmapRelativeIndex; byte _firstDerivedBitmapRelativeIndex; byte _width; @@ -368,7 +391,8 @@ struct ProjectileAspect { _width(byteWidth * 2), _height(h), _graphicInfo(grap) {} }; // @ PROJECTIL_ASPECT -struct CreatureReplColorSet { +class CreatureReplColorSet { +public: uint16 _RGBColor[6]; byte _D2ReplacementColor; byte _D3ReplacementColor; @@ -377,15 +401,12 @@ struct CreatureReplColorSet { extern Viewport gDefultViewPort; extern Viewport gDungeonViewport; -#define kAlcoveOrnCount 3 -#define kFountainOrnCount 1 - -#define kDoorButton 0 // @ C0_DOOR_BUTTON -#define kWallOrnInscription 0 // @ C0_WALL_ORNAMENT_INSCRIPTION -#define kFloorOrnFootprints 15 // @ C15_FLOOR_ORNAMENT_FOOTPRINTS -#define kDoorOrnDestroyedMask 15 // @ C15_DOOR_ORNAMENT_DESTROYED_MASK -#define kDoorOrnThivesEyeMask 16 // @ C16_DOOR_ORNAMENT_THIEVES_EYE_MASK +#define k0_DoorButton 0 // @ C0_DOOR_BUTTON +#define k0_WallOrnInscription 0 // @ C0_WALL_ORNAMENT_INSCRIPTION +#define k15_FloorOrnFootprints 15 // @ C15_FLOOR_ORNAMENT_FOOTPRINTS +#define k15_DoorOrnDestroyedMask 15 // @ C15_DOOR_ORNAMENT_DESTROYED_MASK +#define k16_DoorOrnThivesEyeMask 16 // @ C16_DOOR_ORNAMENT_THIEVES_EYE_MASK class DisplayMan { friend class DM::TextMan; @@ -405,9 +426,9 @@ class DisplayMan { byte *_wallSetBitMaps[25]; // @G[0696..0710]_puc_Bitmap_WallSet_... // pointers are not owned by these fields - byte *_floorBitmap; - byte *_ceilingBitmap; - byte *_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile + byte *_g84_floorBitmap; // @ G0084_puc_Bitmap_Floor + byte *_g85_ceilingBitmap; // @ G0085_puc_Bitmap_Ceiling + byte *_g75_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile DisplayMan(const DisplayMan &other); // no implementation on purpose void operator=(const DisplayMan &rhs); // no implementation on purpose @@ -440,30 +461,30 @@ class DisplayMan { bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF - uint16 *_derivedBitmapByteCount; // @ G0639_pui_DerivedBitmapByteCount - byte **_derivedBitmaps; // @ G0638_pui_DerivedBitmapBlockIndices - - int16 _g0675stairsNativeBitmapIndex_Up_Front_D3L; // @ G0675_i_StairsNativeBitmapIndex_Up_Front_D3L - int16 _g0676stairsNativeBitmapIndex_Up_Front_D3C; // @ G0676_i_StairsNativeBitmapIndex_Up_Front_D3C - int16 _g0677stairsNativeBitmapIndex_Up_Front_D2L; // @ G0677_i_StairsNativeBitmapIndex_Up_Front_D2L - int16 _g0678stairsNativeBitmapIndex_Up_Front_D2C; // @ G0678_i_StairsNativeBitmapIndex_Up_Front_D2C - int16 _g0679stairsNativeBitmapIndex_Up_Front_D1L; // @ G0679_i_StairsNativeBitmapIndex_Up_Front_D1L - int16 _g0680stairsNativeBitmapIndex_Up_Front_D1C; // @ G0680_i_StairsNativeBitmapIndex_Up_Front_D1C - int16 _g0681stairsNativeBitmapIndex_Up_Front_D0C_Left; // @ G0681_i_StairsNativeBitmapIndex_Up_Front_D0C_Left - int16 _g0682stairsNativeBitmapIndex_Down_Front_D3L; // @ G0682_i_StairsNativeBitmapIndex_Down_Front_D3L - int16 _g0683stairsNativeBitmapIndex_Down_Front_D3C; // @ G0683_i_StairsNativeBitmapIndex_Down_Front_D3C - int16 _g0684stairsNativeBitmapIndex_Down_Front_D2L; // @ G0684_i_StairsNativeBitmapIndex_Down_Front_D2L - int16 _g0685stairsNativeBitmapIndex_Down_Front_D2C; // @ G0685_i_StairsNativeBitmapIndex_Down_Front_D2C - int16 _g0686stairsNativeBitmapIndex_Down_Front_D1L; // @ G0686_i_StairsNativeBitmapIndex_Down_Front_D1L - int16 _g0687stairsNativeBitmapIndex_Down_Front_D1C; // @ G0687_i_StairsNativeBitmapIndex_Down_Front_D1C - int16 _g0688stairsNativeBitmapIndex_Down_Front_D0C_Left; // @ G0688_i_StairsNativeBitmapIndex_Down_Front_D0C_Left - int16 _g0689stairsNativeBitmapIndex_Side_D2L; // @ G0689_i_StairsNativeBitmapIndex_Side_D2L - int16 _g0690stairsNativeBitmapIndex_Up_Side_D1L; // @ G0690_i_StairsNativeBitmapIndex_Up_Side_D1L - int16 _g0691stairsNativeBitmapIndex_Down_Side_D1L; // @ G0691_i_StairsNativeBitmapIndex_Down_Side_D1L - int16 _g0692stairsNativeBitmapIndex_Side_D0L; // @ G0692_i_StairsNativeBitmapIndex_Side_D0L + uint16 *_g639_derivedBitmapByteCount; // @ G0639_pui_DerivedBitmapByteCount + byte **_g638_derivedBitmaps; // @ G0638_pui_DerivedBitmapBlockIndices + + int16 _g675_stairsNativeBitmapIndex_Up_Front_D3L; // @ G0675_i_StairsNativeBitmapIndex_Up_Front_D3L + int16 _g676_stairsNativeBitmapIndex_Up_Front_D3C; // @ G0676_i_StairsNativeBitmapIndex_Up_Front_D3C + int16 _g677_stairsNativeBitmapIndex_Up_Front_D2L; // @ G0677_i_StairsNativeBitmapIndex_Up_Front_D2L + int16 _g678_stairsNativeBitmapIndex_Up_Front_D2C; // @ G0678_i_StairsNativeBitmapIndex_Up_Front_D2C + int16 _g679_stairsNativeBitmapIndex_Up_Front_D1L; // @ G0679_i_StairsNativeBitmapIndex_Up_Front_D1L + int16 _g680_stairsNativeBitmapIndex_Up_Front_D1C; // @ G0680_i_StairsNativeBitmapIndex_Up_Front_D1C + int16 _g681_stairsNativeBitmapIndex_Up_Front_D0C_Left; // @ G0681_i_StairsNativeBitmapIndex_Up_Front_D0C_Left + int16 _g682_stairsNativeBitmapIndex_Down_Front_D3L; // @ G0682_i_StairsNativeBitmapIndex_Down_Front_D3L + int16 _g683_stairsNativeBitmapIndex_Down_Front_D3C; // @ G0683_i_StairsNativeBitmapIndex_Down_Front_D3C + int16 _g684_stairsNativeBitmapIndex_Down_Front_D2L; // @ G0684_i_StairsNativeBitmapIndex_Down_Front_D2L + int16 _g685_stairsNativeBitmapIndex_Down_Front_D2C; // @ G0685_i_StairsNativeBitmapIndex_Down_Front_D2C + int16 _g686_stairsNativeBitmapIndex_Down_Front_D1L; // @ G0686_i_StairsNativeBitmapIndex_Down_Front_D1L + int16 _g687_stairsNativeBitmapIndex_Down_Front_D1C; // @ G0687_i_StairsNativeBitmapIndex_Down_Front_D1C + int16 _g688_stairsNativeBitmapIndex_Down_Front_D0C_Left; // @ G0688_i_StairsNativeBitmapIndex_Down_Front_D0C_Left + int16 _g689_stairsNativeBitmapIndex_Side_D2L; // @ G0689_i_StairsNativeBitmapIndex_Side_D2L + int16 _g690_stairsNativeBitmapIndex_Up_Side_D1L; // @ G0690_i_StairsNativeBitmapIndex_Up_Side_D1L + int16 _g691_stairsNativeBitmapIndex_Down_Side_D1L; // @ G0691_i_StairsNativeBitmapIndex_Down_Side_D1L + int16 _g692_stairsNativeBitmapIndex_Side_D0L; // @ G0692_i_StairsNativeBitmapIndex_Side_D0L public: // some methods use this for a stratchpad, don't make assumptions about content between function calls - byte *_tmpBitmap; + byte *_g74_tmpBitmap; // @ G0074_puc_Bitmap_Temporary explicit DisplayMan(DMEngine *dmEngine); ~DisplayMan(); @@ -484,25 +505,25 @@ public: void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte *destBitmap, uint16 destWidth, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort); + Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort); void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, - byte *destBitmap, uint16 destWidth, Box &box, Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort); + byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort); void blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight, byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0); void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort); + Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort); void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, Box &box, - Color transparent = kColorNoTransparency, Viewport &viewport = gDefultViewPort); + Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort); void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDefultViewPort); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap void blitBoxFilledWithMaskedBitmapToScreen(byte *src, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, - int16 firstUnitIndex, int16 destPixelWidth, Color transparent, - int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap + int16 firstUnitIndex, int16 destPixelWidth, Color transparent, + int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); @@ -521,29 +542,29 @@ public: int16 getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount int16 getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION void cthulhu(Thing thingParam, direction directionParam, - int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, - uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF + int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, + uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF uint16 getNormalizedByteWidthM77(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH uint16 getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET uint16 getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET - int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal - int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices - int16 _currMapFountainOrnIndices[kFountainOrnCount]; // @ G0268_ai_CurrentMapFountainOrnamentIndices - int16 _currMapWallOrnInfo[16][2]; // @ G0101_aai_CurrentMapWallOrnamentsInfo - int16 _currMapFloorOrnInfo[16][2]; // @ G0102_aai_CurrentMapFloorOrnamentsInfo - int16 _currMapDoorOrnInfo[17][2]; // @ G0103_aai_CurrentMapDoorOrnamentsInfo - byte *_currMapAllowedCreatureTypes; // @ G0264_puc_CurrentMapAllowedCreatureTypes - byte _currMapWallOrnIndices[16]; // @ G0261_auc_CurrentMapWallOrnamentIndices - byte _currMapFloorOrnIndices[16]; // @ G0262_auc_CurrentMapFloorOrnamentIndices - byte _currMapDoorOrnIndices[18]; // @ G0263_auc_CurrentMapDoorOrnamentIndices + int16 _g289_championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal + int16 _g267_currMapAlcoveOrnIndices[k3_AlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices + int16 _g268_currMapFountainOrnIndices[k1_FountainOrnCount]; // @ G0268_ai_CurrentMapFountainOrnamentIndices + int16 _g101_currMapWallOrnInfo[16][2]; // @ G0101_aai_CurrentMapWallOrnamentsInfo + int16 _g102_currMapFloorOrnInfo[16][2]; // @ G0102_aai_CurrentMapFloorOrnamentsInfo + int16 _g103_currMapDoorOrnInfo[17][2]; // @ G0103_aai_CurrentMapDoorOrnamentsInfo + byte *_g264_currMapAllowedCreatureTypes; // @ G0264_puc_CurrentMapAllowedCreatureTypes + byte _g261_currMapWallOrnIndices[16]; // @ G0261_auc_CurrentMapWallOrnamentIndices + byte _g262_currMapFloorOrnIndices[16]; // @ G0262_auc_CurrentMapFloorOrnamentIndices + byte _g263_currMapDoorOrnIndices[18]; // @ G0263_auc_CurrentMapDoorOrnamentIndices - int16 _currMapViAltarIndex; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex + int16 _g266_currMapViAltarIndex; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex - Thing _inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing + Thing _g290_inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing - bool _useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates - bool _doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame + bool _g578_useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates + bool _g77_doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame bool isDerivedBitmapInCache(int16 derivedBitmapIndex); // @ F0491_CACHE_IsDerivedBitmapInCache byte *getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index b3c3a900d2..d7382340f3 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -87,22 +87,22 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { } } - dm._useByteBoxCoordinates = false; + dm._g578_useByteBoxCoordinates = false; _inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex); if (!invChampOrdinal) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } champion = &cm._champions[championIndex]; - int16 w = dm.getWidth(kInventoryGraphicIndice); - int16 h = dm.getHeight(kInventoryGraphicIndice); - dm.blitToScreen(dm.getBitmap(kInventoryGraphicIndice), w, 0, 0, 0, w, 0, h, kColorNoTransparency, gDungeonViewport); + int16 w = dm.getWidth(k17_InventoryGraphicIndice); + int16 h = dm.getHeight(k17_InventoryGraphicIndice); + dm.blitToScreen(dm.getBitmap(k17_InventoryGraphicIndice), w, 0, 0, 0, w, 0, h, k255_ColorNoTransparency, gDungeonViewport); if (cm._candidateChampionOrdinal) { - dm.clearScreenBox(kColorDarkestGray, gBoxFloppyZzzCross, gDungeonViewport); + dm.clearScreenBox(k12_ColorDarkestGray, gBoxFloppyZzzCross, gDungeonViewport); } - _vm->_textMan->printToViewport(5, 116, kColorLightestGray, "HEALTH"); - _vm->_textMan->printToViewport(5, 124, kColorLightestGray, "STAMINA"); - _vm->_textMan->printToViewport(5, 132, kColorLightestGray, "MANA"); + _vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "HEALTH"); + _vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "STAMINA"); + _vm->_textMan->printToViewport(5, 132, k13_ColorLightestGray, "MANA"); for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) { _vm->_championMan->drawSlot(championIndex, (ChampionSlot)slotIndex); @@ -124,13 +124,13 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) { DisplayMan &dispMan = *_vm->_displayMan; - dispMan._useByteBoxCoordinates = false; + dispMan._g578_useByteBoxCoordinates = false; Box box; box._y1 = 0; box._y2 = 28 + 1; box._x1 = championIndex * kChampionStatusBoxSpacing + 7; box._x2 = box._x1 + 31 + 1; - dispMan.blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0, box, kColorNoTransparency); + dispMan.blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0, box, k255_ColorNoTransparency); } void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) { @@ -139,15 +139,15 @@ void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Co box._x2 = box._x1 + pixelWidth + 1; box._y1 = y; box._y2 = box._y1 + 6 + 1; - _vm->_displayMan->_useByteBoxCoordinates = false; + _vm->_displayMan->_g578_useByteBoxCoordinates = false; _vm->_displayMan->clearScreenBox(color, box); } void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) { if (amount < -512) { - color = kColorRed; + color = k8_ColorRed; } else if (amount < 0) { - color = kColorYellow; + color = k11_ColorYellow; } int16 pixelWidth = amount + 1024; @@ -155,7 +155,7 @@ void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) { pixelWidth = 3071; } pixelWidth /= 32; - drawPanelHorizontalBar(115, y + 2, pixelWidth, kColorBlack); + drawPanelHorizontalBar(115, y + 2, pixelWidth, k0_ColorBlack); drawPanelHorizontalBar(113, y, pixelWidth, color); } @@ -163,19 +163,19 @@ void InventoryMan::drawPanelFoodWaterPoisoned() { Champion &champ = _vm->_championMan->_champions[_inventoryChampionOrdinal]; closeChest(); DisplayMan &dispMan = *_vm->_displayMan; - dispMan.blitToScreen(dispMan.getBitmap(kPanelEmptyIndice), 144, 0, 0, gBoxPanel, kColorRed); - dispMan.blitToScreen(dispMan.getBitmap(kFoodLabelIndice), 48, 0, 0, gBoxFood, kColorDarkestGray); - dispMan.blitToScreen(dispMan.getBitmap(kWaterLabelIndice), 48, 0, 0, gBoxWater, kColorDarkestGray); + dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, gBoxPanel, k8_ColorRed); + dispMan.blitToScreen(dispMan.getBitmap(k30_FoodLabelIndice), 48, 0, 0, gBoxFood, k12_ColorDarkestGray); + dispMan.blitToScreen(dispMan.getBitmap(k31_WaterLabelIndice), 48, 0, 0, gBoxWater, k12_ColorDarkestGray); if (champ._poisonEventCount) { - dispMan.blitToScreen(dispMan.getBitmap(kPoisionedLabelIndice), 96, 0, 0, gBoxPoisoned, kColorDarkestGray); + dispMan.blitToScreen(dispMan.getBitmap(k32_PoisionedLabelIndice), 96, 0, 0, gBoxPoisoned, k12_ColorDarkestGray); } - drawPanelFoodOrWaterBar(champ._food, 69, kColorLightBrown); - drawPanelFoodOrWaterBar(champ._water, 92, kColorBlue); + drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown); + drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue); } void InventoryMan::drawPanelResurrectReincarnate() { _panelContent = kPanelContentResurrectReincarnate; - _vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(kPanelResurectReincaranteIndice), 144, 0, 0, gBoxPanel, kColorDarkGreen, gDungeonViewport); + _vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, gBoxPanel, k6_ColorDarkGreen, gDungeonViewport); } void InventoryMan::drawPanel() { @@ -245,7 +245,7 @@ void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) { *iter -= 96; } } - _vm->_textMan->printToViewport(162 - (6 * strlen(text) / 2), yPos, kColorBlack, text, kColorWhite); + _vm->_textMan->printToViewport(162 - (6 * strlen(text) / 2), yPos, k0_ColorBlack, text, k15_ColorWhite); } void InventoryMan::drawPanelScroll(Scroll* scroll) { @@ -258,7 +258,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) { charRed++; } *charRed = '\0'; - dispMan.blitToScreen(dispMan.getBitmap(kPanelOpenScrollIndice), 144, 0, 0, gBoxPanel, kColorRed, gDungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, gDungeonViewport); int16 lineCount = 1; charRed++; char *charGreen = charRed; // first char of the second line @@ -310,7 +310,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is if (!isPressingEye) { objMan.drawIconInSlotBox(kSlotBoxInventoryActionHand, kIconIndiceContainerChestOpen); } - dispMan.blitToScreen(dispMan.getBitmap(kPanelOpenChestIndice), 144, 0, 0, gBoxPanel, kColorRed); + dispMan.blitToScreen(dispMan.getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, gBoxPanel, k8_ColorRed); int16 chestSlotIndex = 0; Thing thing = chest->getSlot(); @@ -336,7 +336,7 @@ void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yP box._x2 = (box._x1 = xPos) + 15 + 1; box._y2 = (box._y1 = yPos) + 15 + 1; _vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap); - _vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, kColorNoTransparency, gDungeonViewport); + _vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, k255_ColorNoTransparency, gDungeonViewport); } void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) { @@ -394,7 +394,7 @@ void InventoryMan::drawPanelObjectDescriptionString(char* descString) { severalLines = true; } - _vm->_textMan->printToViewport(_objDescTextXpos, _objDescTextYpos, kColorLightestGray, stringLine); + _vm->_textMan->printToViewport(_objDescTextXpos, _objDescTextYpos, k13_ColorLightestGray, stringLine); _objDescTextYpos += 7; if (severalLines) { severalLines = false; @@ -410,8 +410,8 @@ Box gBoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye void InventoryMan::drawPanelArrowOrEye(bool pressingEye) { DisplayMan &dispMan = *_vm->_displayMan; - dispMan.blitToScreen(dispMan.getBitmap(pressingEye ? kEyeForObjectDescriptionIndice : kArrowForChestContentIndice), - 16, 0, 0, gBoxArrowOrEye, kColorRed, gDungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice), + 16, 0, 0, gBoxArrowOrEye, k8_ColorRed, gDungeonViewport); } @@ -443,8 +443,8 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye); } else { IconIndice iconIndex = objMan.getIconIndex(thingToDraw); - dispMan.blitToScreen(dispMan.getBitmap(kPanelEmptyIndice), 144, 0, 0, gBoxPanel, kColorRed, gDungeonViewport); - dispMan.blitToScreen(dispMan.getBitmap(kObjectDescCircleIndice), 32, 0, 0, gBoxObjectDescCircle, kColorDarkestGray, gDungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, gDungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, gBoxObjectDescCircle, k12_ColorDarkestGray, gDungeonViewport); char *descString = nullptr; char str[40]; @@ -466,7 +466,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { descString = objMan._objectNames[iconIndex]; } - textMan.printToViewport(134, 68, kColorLightestGray, descString); + textMan.printToViewport(134, 68, k13_ColorLightestGray, descString); drawIconToViewport(iconIndex, 111, 59); char *attribString[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"}; // TODO: localization diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index a09a33dbf1..74ca0ac00c 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -60,11 +60,11 @@ MenuMan::~MenuMan() { void MenuMan::drawMovementArrows() { DisplayMan &disp = *_vm->_displayMan; - byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice); - Box &dest = gBoxMovementArrows; - uint16 w = disp.getWidth(kMovementArrowsIndice); + byte *arrowsBitmap = disp.getBitmap(k13_MovementArrowsIndice); + Box &dest = g2_BoxMovementArrows; + uint16 w = disp.getWidth(k13_MovementArrowsIndice); - disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency); + disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, k255_ColorNoTransparency); } void MenuMan::clearActingChampion() { ChampionMan &cm = *_vm->_championMan; @@ -88,12 +88,12 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) { box._x2 = box._x1 + 19 + 1; box._y1 = 86; box._y2 = 120 + 1; - dm._useByteBoxCoordinates = false; + dm._g578_useByteBoxCoordinates = false; if (!champion._currHealth) { - dm.clearScreenBox(kColorBlack, box); + dm.clearScreenBox(k0_ColorBlack, box); return; } - byte *bitmapIcon = dm._tmpBitmap; + byte *bitmapIcon = dm._g74_tmpBitmap; Thing thing = champion.getSlot(kChampionSlotActionHand); IconIndice iconIndex; if (thing == Thing::_none) { @@ -101,13 +101,13 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) { } else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) { iconIndex = _vm->_objectMan->getIconIndex(thing); } else { - dm.clearBitmap(bitmapIcon, 16, 16, kColorCyan); + dm.clearBitmap(bitmapIcon, 16, 16, k4_ColorCyan); goto T0386006; } _vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon); dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon); T0386006: - dm.clearScreenBox(kColorCyan, box); + dm.clearScreenBox(k4_ColorCyan, box); Box box2; box2._x1 = box._x1 + 2; box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that @@ -122,7 +122,7 @@ T0386006: void MenuMan::drawDisabledMenu() { if (!_vm->_championMan->_partyIsSleeping) { warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); - _vm->_displayMan->_useByteBoxCoordinates = false; + _vm->_displayMan->_g578_useByteBoxCoordinates = false; if (_vm->_inventoryMan->_inventoryChampionOrdinal) { if (_vm->_inventoryMan->_panelContent == kPanelContentChest) { _vm->_inventoryMan->closeChest(); @@ -197,8 +197,8 @@ void MenuMan::drawActionArea() { TextMan &textMan = *_vm->_textMan; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan._useByteBoxCoordinates = false; - dispMan.clearScreenBox(kColorBlack, gBoxActionArea); + dispMan._g578_useByteBoxCoordinates = false; + dispMan.clearScreenBox(k0_ColorBlack, gBoxActionArea); if (_actionAreaContainsIcons) { for (uint16 champIndex = kChampionFirst; champIndex < champMan._partyChampionCount; ++champIndex) drawActionIcon((ChampionIndex)champIndex); @@ -208,11 +208,11 @@ void MenuMan::drawActionArea() { box = gBoxActionArea2ActionMenu; if (_actionList._actionIndices[1] == kChampionActionNone) box = gBoxActionArea1ActionMenu; - dispMan.blitToScreen(dispMan.getBitmap(kMenuActionAreaIndice), 96, 0, 0, box, kColorNoTransparency); - textMan.printWithTrailingSpacesToScreen(235, 83, kColorBlack, kColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._actingChampionOrdinal)]._name, + dispMan.blitToScreen(dispMan.getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, box, k255_ColorNoTransparency); + textMan.printWithTrailingSpacesToScreen(235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._actingChampionOrdinal)]._name, kChampionNameMaximumLength); for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) { - textMan.printWithTrailingSpacesToScreen(241, 93 + actionListIndex * 12, kColorCyan, kColorBlack, + textMan.printWithTrailingSpacesToScreen(241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack, getActionName(_actionList._actionIndices[actionListIndex]), kActionNameMaximumLength); } @@ -248,12 +248,12 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) { for (uint16 i = 0; i < 4; ++i) champCurrHealth[i] = champMan._champions[i]._currHealth; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan.clearScreenBox(kColorBlack, gBoxSpellAreaControls); + dispMan.clearScreenBox(k0_ColorBlack, gBoxSpellAreaControls); int16 champCount = champMan._partyChampionCount; switch (champIndex) { case kChampionFirst: warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); - textMan.printTextToScreen(235, 48, kColorBlack, kColorCyan, champ._name); + textMan.printTextToScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ._name); if (champCount) { if (champCurrHealth[1]) { warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); @@ -277,7 +277,7 @@ labelChamp3: warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); } warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); - textMan.printTextToScreen(249, 48, kColorBlack, kColorCyan, champ._name); + textMan.printTextToScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ._name); goto labelChamp2; case kChampionThird: if (champCurrHealth[0]) { @@ -287,7 +287,7 @@ labelChamp3: warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); } warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); - textMan.printTextToScreen(263, 48, kColorBlack, kColorCyan, champ._name); + textMan.printTextToScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ._name); goto labelChamp3; case kChampionFourth: if (champCurrHealth[0]) { @@ -300,7 +300,7 @@ labelChamp3: warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); } warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); - textMan.printTextToScreen(277, 48, kColorBlack, kColorCyan, champ._name); + textMan.printTextToScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ._name); break; } warning("MISSING CODE: F0078_MOUSE_ShowPointer"); @@ -314,24 +314,24 @@ void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) { Champion &champ = _vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex]; if (spellAreaBitmapLine == kSpellAreaAvailableSymbols) { - dispMan._useByteBoxCoordinates = false; - dispMan.blitToBitmap(dispMan.getBitmap(kMenuSpellAreLinesIndice), 96, 0, 12, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, kColorNoTransparency); + dispMan._g578_useByteBoxCoordinates = false; + dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 12, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, k255_ColorNoTransparency); int16 x = 1; byte c = 96 + (6 * champ._symbolStep); char spellSymbolString[2] = {'\0', '\0'}; for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) { spellSymbolString[0] = c++; - _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 14, 8, kColorCyan, kColorBlack, spellSymbolString, 12); + _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12); } } else if (spellAreaBitmapLine == kSpellAreaChampionSymbols) { - dispMan._useByteBoxCoordinates = false; - dispMan.blitToBitmap(dispMan.getBitmap(kMenuSpellAreLinesIndice), 96, 0, 24, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, kColorNoTransparency); + dispMan._g578_useByteBoxCoordinates = false; + dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 24, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, k255_ColorNoTransparency); char spellSymbolString[2] = {'\0', '\0'}; int16 x = 8; for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) { if ((spellSymbolString[0] = champ._symbols[symbolIndex]) == '\0') break; - _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 9, 8, kColorCyan, kColorBlack, spellSymbolString, 12); + _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12); } } } @@ -345,14 +345,14 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) { return; if (champMan._magicCasterChampionIndex == kChampionNone) { warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan.blitToScreen(dispMan.getBitmap(kMenuSpellAreaBackground), 96, 0, 0, gBoxSpellArea); + dispMan.blitToScreen(dispMan.getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, gBoxSpellArea); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } if (champIndex == kChampionNone) { champMan._magicCasterChampionIndex = kChampionNone; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan._useByteBoxCoordinates = false; - dispMan.clearScreenBox(kColorBlack, gBoxSpellArea); + dispMan._g578_useByteBoxCoordinates = false; + dispMan.clearScreenBox(k0_ColorBlack, gBoxSpellArea); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); return; } diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 458f3fd2b3..ddb002d446 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -192,10 +192,10 @@ void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { } --i; - byte *srcBitmap = _vm->_displayMan->getBitmap(kObjectIcons_000_TO_031 + i); + byte *srcBitmap = _vm->_displayMan->getBitmap(k42_ObjectIcons_000_TO_031 + i); iconIndex -= gIconGraphicFirstIndex[i]; - _vm->_displayMan->_useByteBoxCoordinates = true; - _vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, 0, 16, 0, 16, kColorNoTransparency); + _vm->_displayMan->_g578_useByteBoxCoordinates = true; + _vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, 0, 16, 0, 16, k255_ColorNoTransparency); } void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { @@ -218,16 +218,16 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { } } iconGraphicIndex--; - byte *iconsBitmap = _vm->_displayMan->getBitmap(iconGraphicIndex + kObjectIcons_000_TO_031); + byte *iconsBitmap = _vm->_displayMan->getBitmap(iconGraphicIndex + k42_ObjectIcons_000_TO_031); iconIndex -= gIconGraphicFirstIndex[iconGraphicIndex]; - _vm->_displayMan->_useByteBoxCoordinates = false; + _vm->_displayMan->_g578_useByteBoxCoordinates = false; if (slotBoxIndex >= kSlotBoxInventoryFirstSlot) { _vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, - box, kColorNoTransparency, gDungeonViewport); + box, k255_ColorNoTransparency, gDungeonViewport); } else { _vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, - box, kColorNoTransparency, gDefultViewPort); + box, k255_ColorNoTransparency, gDefultViewPort); } } @@ -245,7 +245,7 @@ void ObjectMan::drawLeaderObjectName(Thing thing) { } else { objName = _objectNames[iconIndex]; } - _vm->_textMan->printWithTrailingSpacesToScreen(233, 37, kColorCyan, kColorBlack, objName, kObjectNameMaximumLength); + _vm->_textMan->printWithTrailingSpacesToScreen(233, 37, k4_ColorCyan, k0_ColorBlack, objName, kObjectNameMaximumLength); } IconIndice ObjectMan::getIconIndexInSlotBox(uint16 slotBoxIndex) { diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index f8aabb31df..d535194875 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -43,9 +43,9 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 uint16 textLength = strlen(text); uint16 nextX = destX; uint16 nextY = destY; - byte *srcBitmap = _vm->_displayMan->getBitmap(kFontGraphicIndice); + byte *srcBitmap = _vm->_displayMan->getBitmap(k557_FontGraphicIndice); - byte *tmp = _vm->_displayMan->_tmpBitmap; + byte *tmp = _vm->_displayMan->_g74_tmpBitmap; for (uint16 i = 0; i < (kLetterWidth + 1) * kLetterHeight * 128; ++i) { tmp[i] = srcBitmap[i] ? textColor : bgColor; } @@ -60,7 +60,7 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 break; uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code _vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth, - (nextX == destX) ? (nextX + 1) : nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight, kColorNoTransparency, viewport); + (nextX == destX) ? (nextX + 1) : nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight, k255_ColorNoTransparency, viewport); nextX += kLetterWidth + 1; } } diff --git a/engines/dm/text.h b/engines/dm/text.h index 590fade60d..48c2d6e7f9 100644 --- a/engines/dm/text.h +++ b/engines/dm/text.h @@ -40,7 +40,7 @@ public: void printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, Viewport &viewport = gDefultViewPort); // @ F0053_TEXT_PrintToLogicalScreen - void printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = kColorDarkestGray); // @ F0052_TEXT_PrintToViewport + void printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport void printWithTrailingSpaces(byte *destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor, const char *text, int16 strLenght, int16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0041_TEXT_PrintWithTrailingSpaces void printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor, -- cgit v1.2.3 From da317f14be4d2b6f1031d84b5fc7ee743998cf4c Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 2 Jul 2016 01:19:53 +0200 Subject: DM: Massive renameing in gfx.cpp --- engines/dm/champion.cpp | 10 +- engines/dm/dm.cpp | 2 +- engines/dm/gfx.cpp | 745 +++++++++++++++++++++-------------------------- engines/dm/gfx.h | 4 +- engines/dm/inventory.cpp | 16 +- engines/dm/objectman.cpp | 2 +- engines/dm/text.cpp | 2 +- 7 files changed, 348 insertions(+), 433 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index fb2515bd63..5f1b68c15b 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -802,7 +802,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { } else { AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; } - dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, k12_ColorDarkestGray, gDungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, k12_ColorDarkestGray, g296_DungeonViewport); AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) { if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent) @@ -811,7 +811,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { break; } } - dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, k12_ColorDarkestGray, gDungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, k12_ColorDarkestGray, g296_DungeonViewport); champAttributes |= kChampionAttributeViewport; } } @@ -976,7 +976,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { if (nativeBitmapIndex != -1) { _vm->_displayMan->_g578_useByteBoxCoordinates = false; _vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0, - box, k12_ColorDarkestGray, isInventoryChamp ? gDungeonViewport : gDefultViewPort); + box, k12_ColorDarkestGray, isInventoryChamp ? g296_DungeonViewport : gDefultViewPort); } _vm->_objectMan->drawIconInSlotBox(slotBoxIndex, iconIndex); @@ -998,8 +998,8 @@ void ChampionMan::renameChampion(Champion* champ) { box._x1 = 3; box._x2 = box._x1 + 167; - dispMan.clearScreenBox(k12_ColorDarkestGray, box, gDungeonViewport); - dispMan.blitToScreen(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, gBoxPanel, k4_ColorCyan, gDungeonViewport); + dispMan.clearScreenBox(k12_ColorDarkestGray, box, g296_DungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, gBoxPanel, k4_ColorCyan, g296_DungeonViewport); textMan.printToViewport(177, 58, k13_ColorLightestGray, "_______"); textMan.printToViewport(105, 76, k13_ColorLightestGray, "___________________"); Common::Point clickPos; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index be8da8b4b6..bf584fd6fe 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -253,7 +253,7 @@ void DMEngine::gameloop() { if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) { Box box(0, 224, 0, 126); - _displayMan->clearScreenBox(k0_ColorBlack, box, gDungeonViewport); // dummy code + _displayMan->clearScreenBox(k0_ColorBlack, box, g296_DungeonViewport); // dummy code _displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY); } // DUMMY CODE: next line diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index f6b1b0271a..35b30a3907 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -39,74 +39,73 @@ namespace DM { -Frame g0164Frame_DoorFrameLeft_D3L = Frame(0, 31, 28, 70, 16, 43, 0, 0); // @ G0164_s_Graphic558_Frame_DoorFrameLeft_D3L -Frame g0165Frame_DoorFrameRight_D3R = Frame(192, 223, 28, 70, 16, 43, 0, 0); // @ G0165_s_Graphic558_Frame_DoorFrameRight_D3R -Frame g0166Frame_DoorFrameLeft_D3C = Frame(64, 95, 27, 70, 16, 44, 0, 0); // @ G0166_s_Graphic558_Frame_DoorFrameLeft_D3C -Frame g0167Frame_DoorFrameRight_D3C = Frame(128, 159, 27, 70, 16, 44, 0, 0); // @ G0167_s_Graphic558_Frame_DoorFrameRight_D3C -Frame g0168Frame_DoorFrameLeft_D2C = Frame(48, 95, 22, 86, 24, 65, 0, 0); // @ G0168_s_Graphic558_Frame_DoorFrameLeft_D2C -Frame g0169Frame_DoorFrameRight_D2C = Frame(128, 175, 22, 86, 24, 65, 0, 0); // @ G0169_s_Graphic558_Frame_DoorFrameRight_D2C -Frame g0170Frame_DoorFrameLeft_D1C = Frame(43, 74, 14, 107, 16, 94, 0, 0); // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C -Frame g0171Frame_DoorFrameRight_D1C = Frame(149, 180, 14, 107, 16, 94, 0, 0); // @ G0171_s_Graphic558_Frame_DoorFrameRight_D1C -Frame g0172Frame_DoorFrame_D0C = Frame(96, 127, 0, 122, 16, 123, 0, 0); // @ G0172_s_Graphic558_Frame_DoorFrame_D0C -Frame g0173Frame_DoorFrameTop_D2L = Frame(0, 59, 22, 24, 48, 3, 16, 0); // @ G0173_s_Graphic558_Frame_DoorFrameTop_D2L -Frame g0174Frame_DoorFrameTop_D2C = Frame(64, 159, 22, 24, 48, 3, 0, 0); // @ G0174_s_Graphic558_Frame_DoorFrameTop_D2C -Frame g0175Frame_DoorFrameTop_D2R = Frame(164, 223, 22, 24, 48, 3, 16, 0); // @ G0175_s_Graphic558_Frame_DoorFrameTop_D2R -Frame g0176Frame_DoorFrameTop_D1L = Frame(0, 31, 14, 17, 64, 4, 16, 0); // @ G0176_s_Graphic558_Frame_DoorFrameTop_D1L -Frame g0177Frame_DoorFrameTop_D1C = Frame(48, 175, 14, 17, 64, 4, 0, 0); // @ G0177_s_Graphic558_Frame_DoorFrameTop_D1C -Frame g0178Frame_DoorFrameTop_D1R = Frame(192, 223, 14, 17, 64, 4, 16, 0); // @ G0178_s_Graphic558_Frame_DoorFrameTop_D1R -Frame g0110FrameStairsUpFront_D3L = Frame(0, 79, 25, 70, 40, 46, 0, 0); // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L -Frame g0111FrameStairsUpFront_D3C = Frame(64, 159, 25, 70, 48, 46, 0, 0); // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C -Frame g0112FrameStairsUpFront_D3R = Frame(149, 223, 25, 70, 40, 46, 5, 0); // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R -Frame g0113FrameStairsUpFront_D2L = Frame(0, 63, 22, 83, 32, 62, 0, 0); // @ G0113_s_Graphic558_Frame_StairsUpFront_D2L -Frame g0114FrameStairsUpFront_D2C = Frame(64, 159, 22, 83, 48, 62, 0, 0); // @ G0114_s_Graphic558_Frame_StairsUpFront_D2C -Frame g0115FrameStairsUpFront_D2R = Frame(160, 223, 22, 83, 32, 62, 0, 0); // @ G0115_s_Graphic558_Frame_StairsUpFront_D2R -Frame g0116FrameStairsUpFront_D1L = Frame(0, 31, 9, 108, 16, 100, 0, 0); // @ G0116_s_Graphic558_Frame_StairsUpFront_D1L -Frame g0117FrameStairsUpFront_D1C = Frame(32, 191, 9, 108, 80, 100, 0, 0); // @ G0117_s_Graphic558_Frame_StairsUpFront_D1C -Frame g0118FrameStairsUpFront_D1R = Frame(192, 223, 9, 108, 16, 100, 0, 0); // @ G0118_s_Graphic558_Frame_StairsUpFront_D1R -Frame g0119FrameStairsUpFront_D0L = Frame(0, 31, 58, 101, 16, 44, 0, 0); // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L -Frame g0120FrameStairsUpFront_D0R = Frame(192, 223, 58, 101, 16, 44, 0, 0); // @ G0120_s_Graphic558_Frame_StairsUpFront_D0R -Frame g0121FrameStairsDownFront_D3L = Frame(0, 79, 28, 68, 40, 41, 0, 0); // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L -Frame g0122FrameStairsDownFront_D3C = Frame(64, 159, 28, 70, 48, 43, 0, 0); // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C -Frame g0123FrameStairsDownFront_D3R = Frame(149, 223, 28, 68, 40, 41, 5, 0); // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R -Frame g0124FrameStairsDownFront_D2L = Frame(0, 63, 24, 85, 32, 62, 0, 0); // @ G0124_s_Graphic558_Frame_StairsDownFront_D2L -Frame g0125FrameStairsDownFront_D2C = Frame(64, 159, 24, 85, 48, 62, 0, 0); // @ G0125_s_Graphic558_Frame_StairsDownFront_D2C -Frame g0126FrameStairsDownFront_D2R = Frame(160, 223, 24, 85, 32, 62, 0, 0); // @ G0126_s_Graphic558_Frame_StairsDownFront_D2R -Frame g0127FrameStairsDownFront_D1L = Frame(0, 31, 18, 108, 16, 91, 0, 0); // @ G0127_s_Graphic558_Frame_StairsDownFront_D1L -Frame g0128FrameStairsDownFront_D1C = Frame(32, 191, 18, 108, 80, 91, 0, 0); // @ G0128_s_Graphic558_Frame_StairsDownFront_D1C -Frame g0129FrameStairsDownFront_D1R = Frame(192, 223, 18, 108, 16, 91, 0, 0); // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R -Frame g0130FrameStairsDownFront_D0L = Frame(0, 31, 76, 135, 16, 60, 0, 0); // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L -Frame g0131FrameStairsDownFront_D0R = Frame(192, 223, 76, 135, 16, 60, 0, 0); // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R -Frame g0132FrameStairsSide_D2L = Frame(60, 75, 57, 61, 8, 5, 0, 0); // @ G0132_s_Graphic558_Frame_StairsSide_D2L -Frame g0133FrameStairsSide_D2R = Frame(148, 163, 57, 61, 8, 5, 0, 0); // @ G0133_s_Graphic558_Frame_StairsSide_D2R -Frame g0134FrameStairsUpSide_D1L = Frame(32, 63, 57, 99, 16, 43, 0, 0); // @ G0134_s_Graphic558_Frame_StairsUpSide_D1L -Frame g0135FrameStairsUpSide_D1R = Frame(160, 191, 57, 99, 16, 43, 0, 0); // @ G0135_s_Graphic558_Frame_StairsUpSide_D1R -Frame g0136FrameStairsDownSide_D1L = Frame(32, 63, 60, 98, 16, 39, 0, 0); // @ G0136_s_Graphic558_Frame_StairsDownSide_D1L -Frame g0137FrameStairsDownSide_D1R = Frame(160, 191, 60, 98, 16, 39, 0, 0); // @ G0137_s_Graphic558_Frame_StairsDownSide_D1R -Frame g0138FrameStairsSide_D0L = Frame(0, 15, 73, 85, 8, 13, 0, 0); // @ G0138_s_Graphic558_Frame_StairsSide_D0L -Frame g0139FrameStairsSide_D0R = Frame(208, 223, 73, 85, 8, 13, 0, 0); // @ G0139_s_Graphic558_Frame_StairsSide_D0R -Frame g0140FrameFloorPit_D3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L -Frame g0141FrameFloorPit_D3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C -Frame g0142FrameFloorPit_D3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R -Frame g0143FrameFloorPit_D2L = Frame(0, 79, 77, 88, 40, 12, 0, 0); // @ G0143_s_Graphic558_Frame_FloorPit_D2L -Frame g0144FrameFloorPit_D2C = Frame(64, 159, 77, 88, 48, 12, 0, 0); // @ G0144_s_Graphic558_Frame_FloorPit_D2C -Frame g0145FrameFloorPit_D2R = Frame(144, 223, 77, 88, 40, 12, 0, 0); // @ G0145_s_Graphic558_Frame_FloorPit_D2R -Frame g0146FrameFloorPit_D1L = Frame(0, 63, 93, 116, 32, 24, 0, 0); // @ G0146_s_Graphic558_Frame_FloorPit_D1L -Frame g0147FrameFloorPit_D1C = Frame(32, 191, 93, 116, 80, 24, 0, 0); // @ G0147_s_Graphic558_Frame_FloorPit_D1C -Frame g0148FrameFloorPit_D1R = Frame(160, 223, 93, 116, 32, 24, 0, 0); // @ G0148_s_Graphic558_Frame_FloorPit_D1R -Frame g0149FrameFloorPit_D0L = Frame(0, 31, 124, 135, 16, 12, 0, 0); // @ G0149_s_Graphic558_Frame_FloorPit_D0L -Frame g0150FrameFloorPit_D0C = Frame(16, 207, 124, 135, 96, 12, 0, 0); // @ G0150_s_Graphic558_Frame_FloorPit_D0C -Frame g0151FrameFloorPit_D0R = Frame(192, 223, 124, 135, 16, 12, 0, 0); // @ G0151_s_Graphic558_Frame_FloorPit_D0R -Frame g0152FrameFloorPit_D2L = Frame(0, 79, 19, 23, 40, 5, 0, 0); // @ G0152_s_Graphic558_Frame_CeilingPit_D2L -Frame g0153FrameFloorPit_D2C = Frame(64, 159, 19, 23, 48, 5, 0, 0); // @ G0153_s_Graphic558_Frame_CeilingPit_D2C -Frame g0154FrameFloorPit_D2R = Frame(144, 223, 19, 23, 40, 5, 0, 0); // @ G0154_s_Graphic558_Frame_CeilingPit_D2R -Frame g0155FrameFloorPit_D1L = Frame(0, 63, 8, 16, 32, 9, 0, 0); // @ G0155_s_Graphic558_Frame_CeilingPit_D1L -Frame g0156FrameFloorPit_D1C = Frame(32, 191, 8, 16, 80, 9, 0, 0); // @ G0156_s_Graphic558_Frame_CeilingPit_D1C -Frame g0157FrameFloorPit_D1R = Frame(160, 223, 8, 16, 32, 9, 0, 0); // @ G0157_s_Graphic558_Frame_CeilingPit_D1R -Frame g0158FrameFloorPit_D0L = Frame(0, 15, 0, 3, 8, 4, 0, 0); // @ G0158_s_Graphic558_Frame_CeilingPit_D0L -Frame g0159FrameFloorPit_D0C = Frame(16, 207, 0, 3, 96, 4, 0, 0); // @ G0159_s_Graphic558_Frame_CeilingPit_D0C -Frame g0160FrameFloorPit_D0R = Frame(208, 223, 0, 3, 8, 4, 0, 0); // @ G0160_s_Graphic558_Frame_CeilingPit_D0R - -FieldAspect gFieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects +Frame g164_Frame_DoorFrameLeft_D3L = Frame(0, 31, 28, 70, 16, 43, 0, 0); // @ G0164_s_Graphic558_Frame_DoorFrameLeft_D3L +Frame g165_Frame_DoorFrameRight_D3R = Frame(192, 223, 28, 70, 16, 43, 0, 0); // @ G0165_s_Graphic558_Frame_DoorFrameRight_D3R +Frame g166_Frame_DoorFrameLeft_D3C = Frame(64, 95, 27, 70, 16, 44, 0, 0); // @ G0166_s_Graphic558_Frame_DoorFrameLeft_D3C +Frame g167_Frame_DoorFrameRight_D3C = Frame(128, 159, 27, 70, 16, 44, 0, 0); // @ G0167_s_Graphic558_Frame_DoorFrameRight_D3C +Frame g168_Frame_DoorFrameLeft_D2C = Frame(48, 95, 22, 86, 24, 65, 0, 0); // @ G0168_s_Graphic558_Frame_DoorFrameLeft_D2C +Frame g169_Frame_DoorFrameRight_D2C = Frame(128, 175, 22, 86, 24, 65, 0, 0); // @ G0169_s_Graphic558_Frame_DoorFrameRight_D2C +Frame g170_Frame_DoorFrameLeft_D1C = Frame(43, 74, 14, 107, 16, 94, 0, 0); // @ G0170_s_Graphic558_Frame_DoorFrameLeft_D1C +Frame g171_Frame_DoorFrameRight_D1C = Frame(149, 180, 14, 107, 16, 94, 0, 0); // @ G0171_s_Graphic558_Frame_DoorFrameRight_D1C +Frame g172_Frame_DoorFrame_D0C = Frame(96, 127, 0, 122, 16, 123, 0, 0); // @ G0172_s_Graphic558_Frame_DoorFrame_D0C +Frame g173_Frame_DoorFrameTop_D2L = Frame(0, 59, 22, 24, 48, 3, 16, 0); // @ G0173_s_Graphic558_Frame_DoorFrameTop_D2L +Frame g174_Frame_DoorFrameTop_D2C = Frame(64, 159, 22, 24, 48, 3, 0, 0); // @ G0174_s_Graphic558_Frame_DoorFrameTop_D2C +Frame g175_Frame_DoorFrameTop_D2R = Frame(164, 223, 22, 24, 48, 3, 16, 0); // @ G0175_s_Graphic558_Frame_DoorFrameTop_D2R +Frame g176_Frame_DoorFrameTop_D1L = Frame(0, 31, 14, 17, 64, 4, 16, 0); // @ G0176_s_Graphic558_Frame_DoorFrameTop_D1L +Frame g177_Frame_DoorFrameTop_D1C = Frame(48, 175, 14, 17, 64, 4, 0, 0); // @ G0177_s_Graphic558_Frame_DoorFrameTop_D1C +Frame g178_Frame_DoorFrameTop_D1R = Frame(192, 223, 14, 17, 64, 4, 16, 0); // @ G0178_s_Graphic558_Frame_DoorFrameTop_D1R +Frame g110_FrameStairsUpFront_D3L = Frame(0, 79, 25, 70, 40, 46, 0, 0); // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L +Frame g111_FrameStairsUpFront_D3C = Frame(64, 159, 25, 70, 48, 46, 0, 0); // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C +Frame g112_FrameStairsUpFront_D3R = Frame(149, 223, 25, 70, 40, 46, 5, 0); // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R +Frame g113_FrameStairsUpFront_D2L = Frame(0, 63, 22, 83, 32, 62, 0, 0); // @ G0113_s_Graphic558_Frame_StairsUpFront_D2L +Frame g114_FrameStairsUpFront_D2C = Frame(64, 159, 22, 83, 48, 62, 0, 0); // @ G0114_s_Graphic558_Frame_StairsUpFront_D2C +Frame g115_FrameStairsUpFront_D2R = Frame(160, 223, 22, 83, 32, 62, 0, 0); // @ G0115_s_Graphic558_Frame_StairsUpFront_D2R +Frame g116_FrameStairsUpFront_D1L = Frame(0, 31, 9, 108, 16, 100, 0, 0); // @ G0116_s_Graphic558_Frame_StairsUpFront_D1L +Frame g117_FrameStairsUpFront_D1C = Frame(32, 191, 9, 108, 80, 100, 0, 0); // @ G0117_s_Graphic558_Frame_StairsUpFront_D1C +Frame g118_FrameStairsUpFront_D1R = Frame(192, 223, 9, 108, 16, 100, 0, 0); // @ G0118_s_Graphic558_Frame_StairsUpFront_D1R +Frame g119_FrameStairsUpFront_D0L = Frame(0, 31, 58, 101, 16, 44, 0, 0); // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L +Frame g120_FrameStairsUpFront_D0R = Frame(192, 223, 58, 101, 16, 44, 0, 0); // @ G0120_s_Graphic558_Frame_StairsUpFront_D0R +Frame g121_FrameStairsDownFront_D3L = Frame(0, 79, 28, 68, 40, 41, 0, 0); // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L +Frame g122_FrameStairsDownFront_D3C = Frame(64, 159, 28, 70, 48, 43, 0, 0); // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C +Frame g123_FrameStairsDownFront_D3R = Frame(149, 223, 28, 68, 40, 41, 5, 0); // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R +Frame g124_FrameStairsDownFront_D2L = Frame(0, 63, 24, 85, 32, 62, 0, 0); // @ G0124_s_Graphic558_Frame_StairsDownFront_D2L +Frame g125_FrameStairsDownFront_D2C = Frame(64, 159, 24, 85, 48, 62, 0, 0); // @ G0125_s_Graphic558_Frame_StairsDownFront_D2C +Frame g126_FrameStairsDownFront_D2R = Frame(160, 223, 24, 85, 32, 62, 0, 0); // @ G0126_s_Graphic558_Frame_StairsDownFront_D2R +Frame g127_FrameStairsDownFront_D1L = Frame(0, 31, 18, 108, 16, 91, 0, 0); // @ G0127_s_Graphic558_Frame_StairsDownFront_D1L +Frame g128_FrameStairsDownFront_D1C = Frame(32, 191, 18, 108, 80, 91, 0, 0); // @ G0128_s_Graphic558_Frame_StairsDownFront_D1C +Frame g129_FrameStairsDownFront_D1R = Frame(192, 223, 18, 108, 16, 91, 0, 0); // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R +Frame g130_FrameStairsDownFront_D0L = Frame(0, 31, 76, 135, 16, 60, 0, 0); // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L +Frame g131_FrameStairsDownFront_D0R = Frame(192, 223, 76, 135, 16, 60, 0, 0); // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R +Frame g132_FrameStairsSide_D2L = Frame(60, 75, 57, 61, 8, 5, 0, 0); // @ G0132_s_Graphic558_Frame_StairsSide_D2L +Frame g133_FrameStairsSide_D2R = Frame(148, 163, 57, 61, 8, 5, 0, 0); // @ G0133_s_Graphic558_Frame_StairsSide_D2R +Frame g134_FrameStairsUpSide_D1L = Frame(32, 63, 57, 99, 16, 43, 0, 0); // @ G0134_s_Graphic558_Frame_StairsUpSide_D1L +Frame g135_FrameStairsUpSide_D1R = Frame(160, 191, 57, 99, 16, 43, 0, 0); // @ G0135_s_Graphic558_Frame_StairsUpSide_D1R +Frame g136_FrameStairsDownSide_D1L = Frame(32, 63, 60, 98, 16, 39, 0, 0); // @ G0136_s_Graphic558_Frame_StairsDownSide_D1L +Frame g137_FrameStairsDownSide_D1R = Frame(160, 191, 60, 98, 16, 39, 0, 0); // @ G0137_s_Graphic558_Frame_StairsDownSide_D1R +Frame g138_FrameStairsSide_D0L = Frame(0, 15, 73, 85, 8, 13, 0, 0); // @ G0138_s_Graphic558_Frame_StairsSide_D0L +Frame g139_FrameStairsSide_D0R = Frame(208, 223, 73, 85, 8, 13, 0, 0); // @ G0139_s_Graphic558_Frame_StairsSide_D0R +Frame g140_FrameFloorPit_D3L = Frame(0, 79, 66, 73, 40, 8, 0, 0); // @ G0140_s_Graphic558_Frame_FloorPit_D3L +Frame g141_FrameFloorPit_D3C = Frame(64, 159, 66, 73, 48, 8, 0, 0); // @ G0141_s_Graphic558_Frame_FloorPit_D3C +Frame g142_FrameFloorPit_D3R = Frame(144, 223, 66, 73, 40, 8, 0, 0); // @ G0142_s_Graphic558_Frame_FloorPit_D3R +Frame g143_FrameFloorPit_D2L = Frame(0, 79, 77, 88, 40, 12, 0, 0); // @ G0143_s_Graphic558_Frame_FloorPit_D2L +Frame g144_FrameFloorPit_D2C = Frame(64, 159, 77, 88, 48, 12, 0, 0); // @ G0144_s_Graphic558_Frame_FloorPit_D2C +Frame g145_FrameFloorPit_D2R = Frame(144, 223, 77, 88, 40, 12, 0, 0); // @ G0145_s_Graphic558_Frame_FloorPit_D2R +Frame g146_FrameFloorPit_D1L = Frame(0, 63, 93, 116, 32, 24, 0, 0); // @ G0146_s_Graphic558_Frame_FloorPit_D1L +Frame g147_FrameFloorPit_D1C = Frame(32, 191, 93, 116, 80, 24, 0, 0); // @ G0147_s_Graphic558_Frame_FloorPit_D1C +Frame g148_FrameFloorPit_D1R = Frame(160, 223, 93, 116, 32, 24, 0, 0); // @ G0148_s_Graphic558_Frame_FloorPit_D1R +Frame g149_FrameFloorPit_D0L = Frame(0, 31, 124, 135, 16, 12, 0, 0); // @ G0149_s_Graphic558_Frame_FloorPit_D0L +Frame g150_FrameFloorPit_D0C = Frame(16, 207, 124, 135, 96, 12, 0, 0); // @ G0150_s_Graphic558_Frame_FloorPit_D0C +Frame g151_FrameFloorPit_D0R = Frame(192, 223, 124, 135, 16, 12, 0, 0); // @ G0151_s_Graphic558_Frame_FloorPit_D0R +Frame g152_FrameFloorPit_D2L = Frame(0, 79, 19, 23, 40, 5, 0, 0); // @ G0152_s_Graphic558_Frame_CeilingPit_D2L +Frame g153_FrameFloorPit_D2C = Frame(64, 159, 19, 23, 48, 5, 0, 0); // @ G0153_s_Graphic558_Frame_CeilingPit_D2C +Frame g154_FrameFloorPit_D2R = Frame(144, 223, 19, 23, 40, 5, 0, 0); // @ G0154_s_Graphic558_Frame_CeilingPit_D2R +Frame g155_FrameFloorPit_D1L = Frame(0, 63, 8, 16, 32, 9, 0, 0); // @ G0155_s_Graphic558_Frame_CeilingPit_D1L +Frame g156_FrameFloorPit_D1C = Frame(32, 191, 8, 16, 80, 9, 0, 0); // @ G0156_s_Graphic558_Frame_CeilingPit_D1C +Frame g157_FrameFloorPit_D1R = Frame(160, 223, 8, 16, 32, 9, 0, 0); // @ G0157_s_Graphic558_Frame_CeilingPit_D1R +Frame g158_FrameFloorPit_D0L = Frame(0, 15, 0, 3, 8, 4, 0, 0); // @ G0158_s_Graphic558_Frame_CeilingPit_D0L +Frame g159_FrameFloorPit_D0C = Frame(16, 207, 0, 3, 96, 4, 0, 0); // @ G0159_s_Graphic558_Frame_CeilingPit_D0C +Frame g160_FrameFloorPit_D0R = Frame(208, 223, 0, 3, 8, 4, 0, 0); // @ G0160_s_Graphic558_Frame_CeilingPit_D0R +FieldAspect g188_FieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects /* { NativeBitmapRelativeIndex, BaseStartUnitIndex, Transparent color, Mask, ByteWidth, Height, X, BitPlaneWordCount } */ FieldAspect(0, 63, 0x8A, 0xFF, 0, 0, 0, 64), /* D3C */ FieldAspect(0, 63, 0x0A, 0x80, 48, 51, 11, 64), /* D3L */ @@ -123,7 +122,7 @@ FieldAspect gFieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects Box g2_BoxMovementArrows = Box(224, 319, 124, 168); -byte gPalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke +byte g212_PalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke ExplosionAspect g211_ExplosionAspects[k4_ExplosionAspectCount] = { // @ G0211_as_Graphic558_ExplosionAspects /* { ByteWidth, Height } */ @@ -132,7 +131,7 @@ ExplosionAspect(64, 97), /* Spell */ ExplosionAspect(80, 91), /* Poison */ ExplosionAspect(80, 91)}; /* Death */ -#define kDerivedBitmapMaximumCount 730 // @ C730_DERIVED_BITMAP_MAXIMUM_COUNT +#define k730_DerivedBitmapMaximumCount 730 // @ C730_DERIVED_BITMAP_MAXIMUM_COUNT byte g215_ProjectileScales[7] = { 13, /* D4 Back */ @@ -143,112 +142,46 @@ byte g215_ProjectileScales[7] = { 28, /* D2 Front */ 32}; /* D1 Back */ -enum StairFrameIndex { - kFrameStairsUpFront_D3L = 0, // @ G0110_s_Graphic558_Frame_StairsUpFront_D3L - kFrameStairsUpFront_D3C = 1, // @ G0111_s_Graphic558_Frame_StairsUpFront_D3C - kFrameStairsUpFront_D3R = 2, // @ G0112_s_Graphic558_Frame_StairsUpFront_D3R - kFrameStairsUpFront_D2L = 3, // @ G0113_s_Graphic558_Frame_StairsUpFront_D2L - kFrameStairsUpFront_D2C = 4, // @ G0114_s_Graphic558_Frame_StairsUpFront_D2C - kFrameStairsUpFront_D2R = 5, // @ G0115_s_Graphic558_Frame_StairsUpFront_D2R - kFrameStairsUpFront_D1L = 6, // @ G0116_s_Graphic558_Frame_StairsUpFront_D1L - kFrameStairsUpFront_D1C = 7, // @ G0117_s_Graphic558_Frame_StairsUpFront_D1C - kFrameStairsUpFront_D1R = 8, // @ G0118_s_Graphic558_Frame_StairsUpFront_D1R - kFrameStairsUpFront_D0L = 9, // @ G0119_s_Graphic558_Frame_StairsUpFront_D0L - kFrameStairsUpFront_D0R = 10, // @ G0120_s_Graphic558_Frame_StairsUpFront_D0R - kFrameStairsDownFront_D3L = 11, // @ G0121_s_Graphic558_Frame_StairsDownFront_D3L - kFrameStairsDownFront_D3C = 12, // @ G0122_s_Graphic558_Frame_StairsDownFront_D3C - kFrameStairsDownFront_D3R = 13, // @ G0123_s_Graphic558_Frame_StairsDownFront_D3R - kFrameStairsDownFront_D2L = 14, // @ G0124_s_Graphic558_Frame_StairsDownFront_D2L - kFrameStairsDownFront_D2C = 15, // @ G0125_s_Graphic558_Frame_StairsDownFront_D2C - kFrameStairsDownFront_D2R = 16, // @ G0126_s_Graphic558_Frame_StairsDownFront_D2R - kFrameStairsDownFront_D1L = 17, // @ G0127_s_Graphic558_Frame_StairsDownFront_D1L - kFrameStairsDownFront_D1C = 18, // @ G0128_s_Graphic558_Frame_StairsDownFront_D1C - kFrameStairsDownFront_D1R = 19, // @ G0129_s_Graphic558_Frame_StairsDownFront_D1R - kFrameStairsDownFront_D0L = 20, // @ G0130_s_Graphic558_Frame_StairsDownFront_D0L - kFrameStairsDownFront_D0R = 21, // @ G0131_s_Graphic558_Frame_StairsDownFront_D0R - kFrameStairsSide_D2L = 22, // @ G0132_s_Graphic558_Frame_StairsSide_D2L - kFrameStairsSide_D2R = 23, // @ G0133_s_Graphic558_Frame_StairsSide_D2R - kFrameStairsUpSide_D1L = 24, // @ G0134_s_Graphic558_Frame_StairsUpSide_D1L - kFrameStairsUpSide_D1R = 25, // @ G0135_s_Graphic558_Frame_StairsUpSide_D1R - kFrameStairsDownSide_D1L = 26, // @ G0136_s_Graphic558_Frame_StairsDownSide_D1L - kFrameStairsDownSide_D1R = 27, // @ G0137_s_Graphic558_Frame_StairsDownSide_D1R - kFrameStairsSide_D0L = 28, // @ G0138_s_Graphic558_Frame_StairsSide_D0L - kFrameStairsSide_D0R = 29 // @ G0139_s_Graphic558_Frame_StairsSide_D0R -}; - -Frame gStairFrames[] = { - Frame(0, 79, 25, 70, 40, 46, 0, 0), - Frame(64, 159, 25, 70, 48, 46, 0, 0), - Frame(149, 223, 25, 70, 40, 46, 5, 0), - Frame(0, 63, 22, 83, 32, 62, 0, 0), - Frame(64, 159, 22, 83, 48, 62, 0, 0), - Frame(160, 223, 22, 83, 32, 62, 0, 0), - Frame(0, 31, 9, 108, 16, 100, 0, 0), - Frame(32, 191, 9, 108, 80, 100, 0, 0), - Frame(192, 223, 9, 108, 16, 100, 0, 0), - Frame(0, 31, 58, 101, 16, 44, 0, 0), - Frame(192, 223, 58, 101, 16, 44, 0, 0), - Frame(0, 79, 28, 68, 40, 41, 0, 0), - Frame(64, 159, 28, 70, 48, 43, 0, 0), - Frame(149, 223, 28, 68, 40, 41, 5, 0), - Frame(0, 63, 24, 85, 32, 62, 0, 0), - Frame(64, 159, 24, 85, 48, 62, 0, 0), - Frame(160, 223, 24, 85, 32, 62, 0, 0), - Frame(0, 31, 18, 108, 16, 91, 0, 0), - Frame(32, 191, 18, 108, 80, 91, 0, 0), - Frame(192, 223, 18, 108, 16, 91, 0, 0), - Frame(0, 31, 76, 135, 16, 60, 0, 0), - Frame(192, 223, 76, 135, 16, 60, 0, 0), - Frame(60, 75, 57, 61, 8, 5, 0, 0), - Frame(148, 163, 57, 61, 8, 5, 0, 0), - Frame(32, 63, 57, 99, 16, 43, 0, 0), - Frame(160, 191, 57, 99, 16, 43, 0, 0), - Frame(32, 63, 60, 98, 16, 39, 0, 0), - Frame(160, 191, 60, 98, 16, 39, 0, 0), - Frame(0, 15, 73, 85, 8, 13, 0, 0), - Frame(208, 223, 73, 85, 8, 13, 0, 0) -}; - -#define kFirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT -#define kFirstFloorSet 75 // @ C075_GRAPHIC_FIRST_FLOOR_SET -#define kFirstWallSet 77 // @ C077_GRAPHIC_FIRST_WALL_SET -#define kFirstStairs 90 // @ C090_GRAPHIC_FIRST_STAIRS -#define kFirstDoorSet 108 // @ C108_GRAPHIC_FIRST_DOOR_SET -#define kInscriptionFont 120 // @ C120_GRAPHIC_INSCRIPTION_FONT -#define kFirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT -#define kFirstFloorOrn 247 // @ C247_GRAPHIC_FIRST_FLOOR_ORNAMENT -#define kFirstDoorOrn 303 // @ C303_GRAPHIC_FIRST_DOOR_ORNAMENT +#define k121_FirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT +#define k75_FirstFloorSet 75 // @ C075_GRAPHIC_FIRST_FLOOR_SET +#define k77_FirstWallSet 77 // @ C077_GRAPHIC_FIRST_WALL_SET +#define k90_FirstStairs 90 // @ C090_GRAPHIC_FIRST_STAIRS +#define k108_FirstDoorSet 108 // @ C108_GRAPHIC_FIRST_DOOR_SET +#define k120_InscriptionFont 120 // @ C120_GRAPHIC_INSCRIPTION_FONT +#define k121_FirstWallOrn 121 // @ C121_GRAPHIC_FIRST_WALL_ORNAMENT +#define k247_FirstFloorOrn 247 // @ C247_GRAPHIC_FIRST_FLOOR_ORNAMENT +#define k303_FirstDoorOrn 303 // @ C303_GRAPHIC_FIRST_DOOR_ORNAMENT enum ViewSquare { - kViewSquare_D4C = -3, // @ CM3_VIEW_SQUARE_D4C - kViewSquare_D4L = -2, // @ CM2_VIEW_SQUARE_D4L - kViewSquare_D4R = -1, // @ CM1_VIEW_SQUARE_D4R - kViewSquare_D3C = 0, // @ C00_VIEW_SQUARE_D3C - kViewSquare_D3L = 1, // @ C01_VIEW_SQUARE_D3L - kViewSquare_D3R = 2, // @ C02_VIEW_SQUARE_D3R - kViewSquare_D2C = 3, // @ C03_VIEW_SQUARE_D2C - kViewSquare_D2L = 4, // @ C04_VIEW_SQUARE_D2L - kViewSquare_D2R = 5, // @ C05_VIEW_SQUARE_D2R - kViewSquare_D1C = 6, // @ C06_VIEW_SQUARE_D1C - kViewSquare_D1L = 7, // @ C07_VIEW_SQUARE_D1L - kViewSquare_D1R = 8, // @ C08_VIEW_SQUARE_D1R - kViewSquare_D0C = 9, // @ C09_VIEW_SQUARE_D0C - kViewSquare_D0L = 10, // @ C10_VIEW_SQUARE_D0L - kViewSquare_D0R = 11, // @ C11_VIEW_SQUARE_D0R - kViewSquare_D3C_Explosion = 3, // @ C03_VIEW_SQUARE_D3C_EXPLOSION - kViewSquare_D3L_Explosion = 4, // @ C04_VIEW_SQUARE_D3L_EXPLOSION - kViewSquare_D1C_Explosion = 9, // @ C09_VIEW_SQUARE_D1C_EXPLOSION - kViewSquare_D0C_Explosion = 12 // @ C12_VIEW_SQUARE_D0C_EXPLOSION + kM3_ViewSquare_D4C = -3, // @ CM3_VIEW_SQUARE_D4C + kM2_ViewSquare_D4L = -2, // @ CM2_VIEW_SQUARE_D4L + kM1_ViewSquare_D4R = -1, // @ CM1_VIEW_SQUARE_D4R + k0_ViewSquare_D3C = 0, // @ C00_VIEW_SQUARE_D3C + k1_ViewSquare_D3L = 1, // @ C01_VIEW_SQUARE_D3L + k2_ViewSquare_D3R = 2, // @ C02_VIEW_SQUARE_D3R + k3_ViewSquare_D2C = 3, // @ C03_VIEW_SQUARE_D2C + k4_ViewSquare_D2L = 4, // @ C04_VIEW_SQUARE_D2L + k5_ViewSquare_D2R = 5, // @ C05_VIEW_SQUARE_D2R + k6_ViewSquare_D1C = 6, // @ C06_VIEW_SQUARE_D1C + k7_ViewSquare_D1L = 7, // @ C07_VIEW_SQUARE_D1L + k8_ViewSquare_D1R = 8, // @ C08_VIEW_SQUARE_D1R + k9_ViewSquare_D0C = 9, // @ C09_VIEW_SQUARE_D0C + k10_ViewSquare_D0L = 10, // @ C10_VIEW_SQUARE_D0L + k11_ViewSquare_D0R = 11, // @ C11_VIEW_SQUARE_D0R + k3_ViewSquare_D3C_Explosion = 3, // @ C03_VIEW_SQUARE_D3C_EXPLOSION + k4_ViewSquare_D3L_Explosion = 4, // @ C04_VIEW_SQUARE_D3L_EXPLOSION + k9_ViewSquare_D1C_Explosion = 9, // @ C09_VIEW_SQUARE_D1C_EXPLOSION + k12_ViewSquare_D0C_Explosion = 12 // @ C12_VIEW_SQUARE_D0C_EXPLOSION }; -Frame gCeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling -Frame gFloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor +Frame gK12_CeilingFrame(0, 223, 0, 28, 112, 29, 0, 0); // @ K0012_s_Frame_Ceiling +Frame gK13_FloorFrame(0, 223, 66, 135, 112, 70, 0, 0); // @ K0013_s_Frame_Floor -Frame gFrameWall_D3L2 = Frame(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2 -Frame gFrameWall_D3R2 = Frame(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2 -Frame gFrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls +Frame g711_FrameWall_D3L2 = Frame(0, 15, 25, 73, 8, 49, 0, 0); // @ G0711_s_Graphic558_Frame_Wall_D3L2 +Frame g712_FrameWall_D3R2 = Frame(208, 223, 25, 73, 8, 49, 0, 0); // @ G0712_s_Graphic558_Frame_Wall_D3R2 +Frame g163_FrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls /* { X1, X2, Y1, Y2, pixelWidth, Height, X, Y } */ Frame(74, 149, 25, 75, 64, 51, 18, 0), /* D3C */ Frame(0, 83, 25, 75, 64, 51, 32, 0), /* D3L */ @@ -264,39 +197,41 @@ Frame gFrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls Frame(192, 223, 0, 135, 16, 136, 0, 0) }; /* D0R */ + +// these denote the corresponding global in DisplayMan::_wallsetbitmaps enum WallSetIndices { - kDoorFrameFront = 0, // @ G0709_puc_Bitmap_WallSet_DoorFrameFront - kDoorFrameLeft_D1C = 1, // @ G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C - kDoorFameLeft_D2C = 2, // @ G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C - kDoorFrameLeft_D3C = 3, // @ G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C - kDoorFrameLeft_D3L = 4, // @ G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L - kDoorFrameTop_D1LCR = 5, // @ G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR - kDoorFrameTop_D2LCR = 6, // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR - kWall_D0R = 7, // @ G0702_puc_Bitmap_WallSet_Wall_D0R - kWall_D0L = 8, // @ G0701_puc_Bitmap_WallSet_Wall_D0L - kWall_D1LCR = 9, // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR - kWall_D2LCR = 10, // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR - kWall_D3LCR = 11, // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR - kWall_D3L2 = 12, // @ G0697_puc_Bitmap_WallSet_Wall_D3L2 - - kWall_D3R2 = 13, // @ G0696_puc_Bitmap_WallSet_Wall_D3R2 - kDoorFrameRight_D1C = 14, // @ G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C - - kWall_D0R_Flipped = 15, - kWall_D0L_Flipped = 16, - kWall_D1LCR_Flipped = 17, - kWall_D2LCR_Flipped = 18, - kWall_D3LCR_Flipped = 19, - - kWall_D0R_Native = 20, - kWall_D0L_Native = 21, - kWall_D1LCR_Native = 22, - kWall_D2LCR_Native = 23, - kWall_D3LCR_Native = 24 + kG709_DoorFrameFront = 0, // @ G0709_puc_Bitmap_WallSet_DoorFrameFront + kG708_DoorFrameLeft_D1C = 1, // @ G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C + kG707_DoorFameLeft_D2C = 2, // @ G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C + kG706_DoorFrameLeft_D3C = 3, // @ G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C + kG705_DoorFrameLeft_D3L = 4, // @ G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L + kG704_DoorFrameTop_D1LCR = 5, // @ G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR + kG703_DoorFrameTop_D2LCR = 6, // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR + kG702_Wall_D0R = 7, // @ G0702_puc_Bitmap_WallSet_Wall_D0R + kG701_Wall_D0L = 8, // @ G0701_puc_Bitmap_WallSet_Wall_D0L + kG700_Wall_D1LCR = 9, // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR + kG699_Wall_D2LCR = 10, // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR + kG698_Wall_D3LCR = 11, // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR + kG697_Wall_D3L2 = 12, // @ G0697_puc_Bitmap_WallSet_Wall_D3L2 + + kG696_Wall_D3R2 = 13, // @ G0696_puc_Bitmap_WallSet_Wall_D3R2 + kG710_DoorFrameRight_D1C = 14, // @ G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C + + kG94_Wall_D0R_Flipped = 15, // @ G0094_puc_Bitmap_WallD0R_Flipped + kG93_Wall_D0L_Flipped = 16, // @ G0093_puc_Bitmap_WallD0L_Flipped + kG92_Wall_D1LCR_Flipped = 17, // @ G0092_puc_Bitmap_WallD1LCR_Flipped + kG91_Wall_D2LCR_Flipped = 18, // @ G0091_puc_Bitmap_WallD2LCR_Flipped + kG90_Wall_D3LCR_Flipped = 19, // @ G0090_puc_Bitmap_WallD3LCR_Flipped + + kG99_Wall_D0R_Native = 20, // @ G0099_puc_Bitmap_WallD0R_Native + kG98_Wall_D0L_Native = 21, // @ G0098_puc_Bitmap_WallD0L_Native + kG97_Wall_D1LCR_Native = 22, // @ G0097_puc_Bitmap_WallD1LCR_Native + kG96_Wall_D2LCR_Native = 23, // @ G0096_puc_Bitmap_WallD2LCR_Native + kG95_Wall_D3LCR_Native = 24 // @ G0095_puc_Bitmap_WallD3LCR_Native }; -byte gDoorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordinateSetIndices +byte g196_DoorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordinateSetIndices 0, /* Door Ornament #00 Square Grid */ 1, /* Door Ornament #01 Iron Bars */ 1, /* Door Ornament #02 Jewels */ @@ -310,7 +245,7 @@ byte gDoorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordina 1, /* Door Ornament #10 Ra Door */ 1}; /* Door Ornament #11 Iron Door Damages */ -byte gFloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnamentCoordinateSetIndices +byte g195_FloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnamentCoordinateSetIndices 0, /* Floor Ornament 00 Square Grate */ 0, /* Floor Ornament 01 Square Pressure Pad */ 0, /* Floor Ornament 02 Moss */ @@ -321,7 +256,7 @@ byte gFloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnamentCoor 2, /* Floor Ornament 07 Tiny Pressure Pad */ 0}; /* Floor Ornament 08 Puddle */ -uint16 gWallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets +uint16 g205_WallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets /* { X1, X2, Y1, Y2, PixelWidth, Height } */ {{80, 83, 41, 45, 8 * 2, 5}, /* D3L */ {140, 143, 41, 45, 8 * 2, 5}, /* D3R */ @@ -428,7 +363,7 @@ uint16 gWallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentC {160, 191, 9, 119, 16 * 2, 111}, /* D1R */ {32, 191, 9, 119, 80 * 2, 111}}}; /* D1C */ -byte gWallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoordinateSetIndices +byte g194_WallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoordinateSetIndices 1, /* Wall Ornament 00 Unreadable Inscription */ 1, /* Wall Ornament 01 Square Alcove */ 1, /* Wall Ornament 02 Vi Altar */ @@ -490,7 +425,7 @@ byte gWallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoord 6, /* Wall Ornament 58 Amalgam (Without Gem) */ 7}; /* Wall Ornament 59 Lord Order (Outside) */ -CreatureAspect gCreatureAspects[k27_CreatureTypeCount] = { // @ G0219_as_Graphic558_CreatureAspects +CreatureAspect g219_CreatureAspects[k27_CreatureTypeCount] = { // @ G0219_as_Graphic558_CreatureAspects /* { FirstNativeBitmapRelativeIndex, FirstDerivedBitmapIndex, pixelWidthFront, HeightFront, pixelWidthSide, HeightSide, pixelWidthAttack, HeightAttack, CoordinateSet / TransparentColor, Replacement Color Set Index for color 10 / Replacement Color Set Index for color 9 } */ @@ -522,7 +457,7 @@ CreatureAspect gCreatureAspects[k27_CreatureTypeCount] = { // @ G0219_as_Graphic CreatureAspect(85, 0, 32 , 93, 0 , 0, 0 , 0, 0x04, 0xCB), /* Creature #25 Lord Order */ CreatureAspect(86, 0, 32 , 93, 0 , 0, 0 , 0, 0x04, 0xCB)}; /* Creature #26 Grey Lord */ -ObjectAspect gObjectAspects[k85_ObjAspectCount] = { // @ G0209_as_Graphic558_ObjectAspects +ObjectAspect g209_ObjectAspects[k85_ObjAspectCount] = { // @ G0209_as_Graphic558_ObjectAspects /* FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo, CoordinateSet */ ObjectAspect(0, 0, 24, 27, 0x11, 0), ObjectAspect(2, 6, 24, 8, 0x00, 1), @@ -611,7 +546,7 @@ ObjectAspect gObjectAspects[k85_ObjAspectCount] = { // @ G0209_as_Graphic558_Obj ObjectAspect(85, 176, 32, 17, 0x00, 0) }; -ProjectileAspect gProjectileAspect[k14_ProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects +ProjectileAspect g210_ProjectileAspect[k14_ProjectileAspectCount] = { // @ G0210_as_Graphic558_ProjectileAspects /* ProjectileAspect( FirstNativeBitmapRelativeIndex, FirstDerivedBitmapRelativeIndex, ByteWidth, Height, GraphicInfo ) */ ProjectileAspect(0, 0, 32, 11, 0x0011), /* Arrow */ ProjectileAspect(3, 18, 16, 11, 0x0011), /* Dagger */ @@ -653,7 +588,7 @@ uint16 g21_PalDungeonView[6][16] = { // @ G0021_aaui_Graphic562_Palette_DungeonV 0x000, 0x000, 0x000, 0x000, 0x0CC, 0x000, 0x000, 0x020, 0x400, 0x000, 0x000, 0x640, 0x000, 0x000, 0x004, 0x444 }; -CreatureReplColorSet gCreatureReplColorSets[13] = { // @ G0220_as_Graphic558_CreatureReplacementColorSets +CreatureReplColorSet g220_CreatureReplColorSets[13] = { // @ G0220_as_Graphic558_CreatureReplacementColorSets /* { Color, Color, Color, Color, Color, Color, D2 replacement color index (x10), D3 replacement color index (x10) } */ {0x0CA0, 0x0A80, 0x0860, 0x0640, 0x0420, 0x0200, 90, 90}, /* Atari ST: { 0x0650, 0x0540, 0x0430, 0x0320, 0x0210, 0x0100, 90, 90 }, RGB colors are different */ {0x0060, 0x0040, 0x0020, 0x0000, 0x0000, 0x0000, 0, 0}, /* Atari ST: { 0x0030, 0x0020, 0x0010, 0x0000, 0x0000, 0x0000, 0, 0 }, */ @@ -669,23 +604,23 @@ CreatureReplColorSet gCreatureReplColorSets[13] = { // @ G0220_as_Graphic558_Cre {0x0600, 0x0400, 0x0200, 0x0000, 0x0000, 0x0000, 120, 0}, /* Atari ST: { 0x0300, 0x0200, 0x0100, 0x0000, 0x0000, 0x0000, 120, 0 }, */ {0x0C86, 0x0A64, 0x0842, 0x0620, 0x0400, 0x0200, 100, 50}}; /* Atari ST: { 0x0643, 0x0532, 0x0421, 0x0310, 0x0200, 0x0100, 100, 50 } }; */ -byte gPalChangesCreature_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3 -byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, 120, 130, 140, 150}; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2 +byte g221_PalChangesCreature_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3 +byte g222_PalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, 120, 130, 140, 150}; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2 Viewport gDefultViewPort(0, 0, 320, 200); // TODO: I guessed the numbers -Viewport gDungeonViewport(0, 33, 224, 126); // @ G0296_puc_Bitmap_Viewport +Viewport g296_DungeonViewport(0, 33, 224, 126); // @ G0296_puc_Bitmap_Viewport -byte gPalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges +byte g17_PalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges -byte gPalChangesFloorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 140, 130}; // @ G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3 -byte gPalChangesFloorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2 +byte g213_PalChangesFloorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 140, 130}; // @ G0213_auc_Graphic558_PaletteChanges_FloorOrnament_D3 +byte g214_PalChangesFloorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0214_auc_Graphic558_PaletteChanges_FloorOrnament_D2 -int gFountainOrnIndices[k1_FountainOrnCount] = {35}; // @ G0193_ai_Graphic558_FountainOrnamentIndices -byte gAlcoveOrnIndices[k3_AlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrnamentIndices +int16 g193_FountainOrnIndices[k1_FountainOrnCount] = {35}; // @ G0193_ai_Graphic558_FountainOrnamentIndices +byte g192_AlcoveOrnIndices[k3_AlcoveOrnCount] = { // @ G0192_auc_Graphic558_AlcoveOrnamentIndices 1, /* Square Alcove */ 2, /* Vi Altar */ 3}; /* Arched Alcove */ @@ -751,14 +686,14 @@ DisplayMan::~DisplayMan() { delete[] _bitmaps[0]; delete[] _bitmaps; } - delete[] _wallSetBitMaps[kWall_D3R2]; // copy of another bitmap, but flipped - delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; // copy of another bitmap, but flipped - for (uint16 i = kWall_D0L_Flipped; i <= kWall_D3LCR_Flipped; ++i) + delete[] _wallSetBitMaps[kG696_Wall_D3R2]; // copy of another bitmap, but flipped + delete[] _wallSetBitMaps[kG710_DoorFrameRight_D1C]; // copy of another bitmap, but flipped + for (uint16 i = kG93_Wall_D0L_Flipped; i <= kG90_Wall_D3LCR_Flipped; ++i) delete[] _wallSetBitMaps[i]; delete[] _g639_derivedBitmapByteCount; if (_g638_derivedBitmaps) { - for (uint16 i = 0; i < kDerivedBitmapMaximumCount; ++i) + for (uint16 i = 0; i < k730_DerivedBitmapMaximumCount; ++i) delete[] _g638_derivedBitmaps; delete[] _g638_derivedBitmaps; } @@ -802,10 +737,10 @@ void DisplayMan::loadGraphics() { if (!_g639_derivedBitmapByteCount) - _g639_derivedBitmapByteCount = new uint16[kDerivedBitmapMaximumCount]; + _g639_derivedBitmapByteCount = new uint16[k730_DerivedBitmapMaximumCount]; if (!_g638_derivedBitmaps) { - _g638_derivedBitmaps = new byte*[kDerivedBitmapMaximumCount]; - for (uint16 i = 0; i < kDerivedBitmapMaximumCount; ++i) + _g638_derivedBitmaps = new byte*[k730_DerivedBitmapMaximumCount]; + for (uint16 i = 0; i < k730_DerivedBitmapMaximumCount; ++i) _g638_derivedBitmaps[i] = nullptr; } @@ -825,7 +760,7 @@ void DisplayMan::loadGraphics() { _g102_currMapFloorOrnInfo[k15_FloorOrnFootprints][k0_NativeBitmapIndex] = k241_FloorOrn_15_D3L_footprints; _g102_currMapFloorOrnInfo[k15_FloorOrnFootprints][k1_CoordinateSet] = 1; - ObjectAspect *objectAspect = gObjectAspects; + ObjectAspect *objectAspect = g209_ObjectAspects; int16 derivedBitmapIndex; for (int16 objectAspectIndex = 0; objectAspectIndex < k85_ObjAspectCount; ++objectAspectIndex, ++objectAspect) { derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex; @@ -847,7 +782,7 @@ void DisplayMan::loadGraphics() { } } - ProjectileAspect *projectileAspect = gProjectileAspect; + ProjectileAspect *projectileAspect = g210_ProjectileAspect; for (int16 projectileAspectIndex = 0; projectileAspectIndex < k14_ProjectileAspectCount; projectileAspectIndex++, projectileAspect++) { if (!getFlag(projectileAspect->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) { @@ -868,9 +803,9 @@ void DisplayMan::loadGraphics() { } } - _g75_palChangesProjectile[0] = gPalChangesFloorOrn_D3; - _g75_palChangesProjectile[1] = gPalChangesFloorOrn_D2; - _g75_palChangesProjectile[2] = _g75_palChangesProjectile[3] = gPalChangesNoChanges; + _g75_palChangesProjectile[0] = g213_PalChangesFloorOrn_D3; + _g75_palChangesProjectile[1] = g214_PalChangesFloorOrn_D2; + _g75_palChangesProjectile[2] = _g75_palChangesProjectile[3] = g17_PalChangesNoChanges; derivedBitmapIndex = k438_DerivedBitmapFirstExplosion; ExplosionAspect *expAsp = g211_ExplosionAspects; @@ -886,7 +821,7 @@ void DisplayMan::loadGraphics() { derivedBitmapIndex = k495_DerivedBitmapFirstCreature; CreatureAspect *creatureAsp; for (int16 creatureIndex = 0; creatureIndex < k27_CreatureTypeCount; creatureIndex++) { - creatureAsp = &gCreatureAspects[creatureIndex]; + creatureAsp = &g219_CreatureAspects[creatureIndex]; int16 creatureGraphicInfo = gCreatureInfo[creatureIndex]._graphicInfo; creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex; @@ -1097,7 +1032,7 @@ byte* DisplayMan::getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int byte *nativeBitmap = getBitmap(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice); bitmap = getDerivedBitmap(derBitmapIndex); blitToBitmapShrinkWithPalChange(nativeBitmap, explAsp->_pixelWidth, explAsp->_height, bitmap, pixelWidth, height, - (explosionAspIndex == k3_ExplosionAspectSmoke) ? gPalChangeSmoke : gPalChangesNoChanges); + (explosionAspIndex == k3_ExplosionAspectSmoke) ? g212_PalChangeSmoke : g17_PalChangesNoChanges); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } @@ -1129,12 +1064,12 @@ uint16 DisplayMan::getHeight(uint16 index) { void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { if (f._srcWidth) - blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k255_ColorNoTransparency, gDungeonViewport); + blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k255_ColorNoTransparency, g296_DungeonViewport); } void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) { if (f._srcWidth) - blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, gDungeonViewport); + blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, g296_DungeonViewport); } @@ -1147,12 +1082,12 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { switch (squareAspect[kElemAspect]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, gStairFrames[kFrameStairsUpFront_D3L]); + drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g110_FrameStairsUpFront_D3L); else - drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, gStairFrames[kFrameStairsDownFront_D3L]); + drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g121_FrameStairsDownFront_D3L); goto T0116015_redEagle; case kWallElemType: - drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3L]); + drawWallSetBitmap(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k1_ViewSquare_D3L]); isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT); if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) { order = k0x0000_CellOrder_Alcove; @@ -1165,14 +1100,14 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { goto T0116016_blueToad; case kElementTypeDoorFront: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); - cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); - drawWallSetBitmap(_wallSetBitMaps[kDoorFrameLeft_D3L], g0164Frame_DoorFrameLeft_D3L); + cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); + drawWallSetBitmap(_wallSetBitMaps[kG705_DoorFrameLeft_D3L], g164_Frame_DoorFrameLeft_D3L); warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor"); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; goto T0116017_orangeElk; case kElementTypePit: if (!squareAspect[kPitInvisibleAspect]) { - drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, g0140FrameFloorPit_D3L); + drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, g140_FrameFloorPit_D3L); } case kElementTypeTeleporter: case kElementTypeCorridor: @@ -1181,10 +1116,10 @@ T0116015_redEagle: T0116016_blueToad: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); T0116017_orangeElk: - cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3L, order); + cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order); } if ((squareAspect[kElemAspect] == kElementTypeTeleporter) && squareAspect[kTeleporterVisibleAspect]) { - drawField(&gFieldAspects[kViewSquare_D3L], gFrameWalls[kViewSquare_D3L]._box); + drawField(&g188_FieldAspects[k1_ViewSquare_D3L], g163_FrameWalls[k1_ViewSquare_D3L]._box); } } @@ -1198,13 +1133,13 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { switch (squareAspect[kElemAspect]) { case kElementTypeStaisFront: if (squareAspect[kStairsUpAspect]) { - drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g0112FrameStairsUpFront_D3R); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g112_FrameStairsUpFront_D3R); } else { - drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g0123FrameStairsDownFront_D3R); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g123_FrameStairsDownFront_D3R); } goto T0117016; case kElementTypeWall: - drawWallSetBitmap(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3R]); + drawWallSetBitmap(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k2_ViewSquare_D3R]); isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT); if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) { order = k0x0000_CellOrder_Alcove; @@ -1217,8 +1152,8 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { goto T0117017; case kElementTypeDoorFront: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); - cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); - memcpy(_g74_tmpBitmap, _wallSetBitMaps[kDoorFrameLeft_D3L], 32 * 44); + cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); + memcpy(_g74_tmpBitmap, _wallSetBitMaps[kG705_DoorFrameLeft_D3L], 32 * 44); warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally"); if (((Door*)_vm->_dungeonMan->_dunData._thingsData[kDoorThingType])[squareAspect[kDoorThingIndexAspect]].hasButton()) { warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton"); @@ -1228,7 +1163,7 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { goto T0117018; case kElementTypePit: if (!squareAspect[kPitInvisibleAspect]) { - drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, g0142FrameFloorPit_D3R); + drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, g142_FrameFloorPit_D3R); } case kElementTypeTeleporter: case kElementTypeCorridor: @@ -1237,10 +1172,10 @@ T0117016: T0117017: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); T0117018: - cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, kViewSquare_D3R, order); + cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order); } if ((squareAspect[kElemAspect] == kElementTypeTeleporter) && squareAspect[kTeleporterVisibleAspect]) { - drawField(&gFieldAspects[kViewSquare_D3R], gFrameWalls[kViewSquare_D3R]._box); + drawField(&g188_FieldAspects[k2_ViewSquare_D3R], g163_FrameWalls[k2_ViewSquare_D3R]._box); } } @@ -1250,12 +1185,12 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, gStairFrames[kFrameStairsUpFront_D3C]); + drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, g111_FrameStairsUpFront_D3C); else - drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, gStairFrames[kFrameStairsDownFront_D3C]); + drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, g122_FrameStairsDownFront_D3C); break; case kWallElemType: - drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D3LCR], gFrameWalls[kViewSquare_D3C]); + drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k0_ViewSquare_D3C]); if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) { //... missing code } @@ -1270,19 +1205,19 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2L]); + drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L); else - drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2L]); + drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L); break; case kWallElemType: - drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2L]); + drawWallSetBitmap(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k4_ViewSquare_D2L]); isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT); if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) { // ... missing code } break; case kStairsSideElemType: - drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2L]); + drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L); break; default: break; @@ -1294,19 +1229,19 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, gStairFrames[kFrameStairsUpFront_D2R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R); else - drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, gStairFrames[kFrameStairsDownFront_D2R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R); break; case kWallElemType: - drawWallSetBitmap(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2R]); + drawWallSetBitmap(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k5_ViewSquare_D2R]); isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT); if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) { // ... missing code } break; case kStairsSideElemType: - drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, gStairFrames[kFrameStairsSide_D2R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R); break; default: break; @@ -1318,12 +1253,12 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, gStairFrames[kFrameStairsUpFront_D2C]); + drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, g114_FrameStairsUpFront_D2C); else - drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, gStairFrames[kFrameStairsDownFront_D2C]); + drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, g125_FrameStairsDownFront_D2C); break; case kWallElemType: - drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D2LCR], gFrameWalls[kViewSquare_D2C]); + drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k3_ViewSquare_D2C]); if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) { // ... missing code } @@ -1338,19 +1273,19 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1L]); + drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g116_FrameStairsUpFront_D1L); else - drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1L]); + drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g127_FrameStairsDownFront_D1L); break; case kWallElemType: - drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1L]); + drawWallSetBitmap(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k7_ViewSquare_D1L]); isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT); break; case kStairsSideElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1L]); + drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g134_FrameStairsUpSide_D1L); else - drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1L]); + drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g136_FrameStairsDownSide_D1L); break; default: break; @@ -1362,19 +1297,19 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, gStairFrames[kFrameStairsUpFront_D1R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g118_FrameStairsUpFront_D1R); else - drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, gStairFrames[kFrameStairsDownFront_D1R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g129_FrameStairsDownFront_D1R); break; case kWallElemType: - drawWallSetBitmap(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1R]); + drawWallSetBitmap(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k8_ViewSquare_D1R]); isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT); break; case kStairsSideElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, gStairFrames[kFrameStairsUpSide_D1R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g135_FrameStairsUpSide_D1R); else - drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, gStairFrames[kFrameStairsDownSide_D1R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g137_FrameStairsDownSide_D1R); break; default: break; @@ -1386,15 +1321,15 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, gStairFrames[kFrameStairsUpFront_D1C]); + drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, g117_FrameStairsUpFront_D1C); else - drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, gStairFrames[kFrameStairsDownFront_D1C]); + drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, g128_FrameStairsDownFront_D1C); break; case kWallElemType: _vm->_dungeonMan->_isFacingAlcove = false; _vm->_dungeonMan->_isFacingViAltar = false; _vm->_dungeonMan->_isFacingFountain = false; - drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kWall_D1LCR], gFrameWalls[kViewSquare_D1C]); + drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k6_ViewSquare_D1C]); if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) { // .... code not yet implemneted } @@ -1410,10 +1345,10 @@ void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsSideElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0L]); + drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, g138_FrameStairsSide_D0L); break; case kWallElemType: - drawWallSetBitmap(_wallSetBitMaps[kWall_D0L], gFrameWalls[kViewSquare_D0L]); + drawWallSetBitmap(_wallSetBitMaps[kG701_Wall_D0L], g163_FrameWalls[k10_ViewSquare_D0L]); break; default: break; @@ -1426,10 +1361,10 @@ void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsSideElemType: if (squareAspect[kStairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, gStairFrames[kFrameStairsSide_D0R]); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R); return; case kWallElemType: - drawWallSetBitmap(_wallSetBitMaps[kWall_D0R], gFrameWalls[kViewSquare_D0R]); + drawWallSetBitmap(_wallSetBitMaps[kG702_Wall_D0R], g163_FrameWalls[k11_ViewSquare_D0R]); break; default: break; @@ -1442,11 +1377,11 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) { switch (squareAspect[0]) { case kStairsFrontElemType: if (squareAspect[kStairsUpAspect]) { - drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0L]); - drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, gStairFrames[kFrameStairsUpFront_D0R]); + drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g119_FrameStairsUpFront_D0L); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g120_FrameStairsUpFront_D0R); } else { - drawFloorPitOrStairsBitmap(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0L]); - drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, gStairFrames[kFrameStairsDownFront_D0R]); + drawFloorPitOrStairsBitmap(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g130_FrameStairsDownFront_D0L); + drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g131_FrameStairsDownFront_D0R); } break; default: @@ -1471,26 +1406,26 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { } if (flippedFloorCeiling) { - uint16 w = gFloorFrame._srcWidth, h = gFloorFrame._srcHeight; + uint16 w = gK13_FloorFrame._srcWidth, h = gK13_FloorFrame._srcHeight; blitToBitmap(_g84_floorBitmap, w, h, tmpBitmap, w); flipBitmapHorizontal(tmpBitmap, w, h); - drawWallSetBitmap(tmpBitmap, gFloorFrame); - drawWallSetBitmap(_g85_ceilingBitmap, gCeilingFrame); + drawWallSetBitmap(tmpBitmap, gK13_FloorFrame); + drawWallSetBitmap(_g85_ceilingBitmap, gK12_CeilingFrame); - for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i) - _wallSetBitMaps[i + kWall_D0R] = _wallSetBitMaps[i + kWall_D0R_Flipped]; + for (uint16 i = 0; i <= kG698_Wall_D3LCR - kG702_Wall_D0R; ++i) + _wallSetBitMaps[i + kG702_Wall_D0R] = _wallSetBitMaps[i + kG94_Wall_D0R_Flipped]; } else { - uint16 w = gCeilingFrame._srcWidth, h = gCeilingFrame._srcHeight; + uint16 w = gK12_CeilingFrame._srcWidth, h = gK12_CeilingFrame._srcHeight; blitToBitmap(_g85_ceilingBitmap, w, h, tmpBitmap, w); flipBitmapHorizontal(tmpBitmap, w, h); - drawWallSetBitmap(tmpBitmap, gCeilingFrame); - drawWallSetBitmap(_g84_floorBitmap, gFloorFrame); + drawWallSetBitmap(tmpBitmap, gK12_CeilingFrame); + drawWallSetBitmap(_g84_floorBitmap, gK13_FloorFrame); } if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallElemType) - drawWallSetBitmap(_wallSetBitMaps[kWall_D3L2], gFrameWall_D3L2); + drawWallSetBitmap(_wallSetBitMaps[kG697_Wall_D3L2], g711_FrameWall_D3L2); if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallElemType) - drawWallSetBitmap(_wallSetBitMaps[kWall_D3R2], gFrameWall_D3R2); + drawWallSetBitmap(_wallSetBitMaps[kG696_Wall_D3R2], g712_FrameWall_D3R2); int16 tmpPosX = posX, tmpPosY = posY; _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY); @@ -1528,8 +1463,8 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { drawSquareD0C(dir, posX, posY); - for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i) - _wallSetBitMaps[i + kWall_D0R] = _wallSetBitMaps[i + kWall_D0R_Native]; + for (uint16 i = 0; i <= kG698_Wall_D3LCR - kG702_Wall_D0R; ++i) + _wallSetBitMaps[i + kG702_Wall_D0R] = _wallSetBitMaps[i + kG99_Wall_D0R_Native]; delete[] tmpBitmap; } @@ -1545,29 +1480,29 @@ void DisplayMan::clearBitmap(byte *bitmap, uint16 width, uint16 height, Color co void DisplayMan::loadFloorSet(FloorSet set) { // there are 2 bitmaps per set, first one is at 75 - GraphicIndice indice = (GraphicIndice)(kFirstFloorSet + (k2_FloorSetGraphicCount * set)); + GraphicIndice indice = (GraphicIndice)(k75_FirstFloorSet + (k2_FloorSetGraphicCount * set)); _g84_floorBitmap = _bitmaps[indice]; _g85_ceilingBitmap = _bitmaps[indice + 1]; } -Box gBoxWallBitmap_D3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR -Box gBoxWallBitmap_D2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR +Box g161_BoxWallBitmap_D3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR +Box g162_BoxWallBitmap_D2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR void DisplayMan::loadWallSet(WallSet set) { - uint16 firstIndice = (set * k13_WallSetGraphicCount) + kFirstWallSet; + uint16 firstIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet; for (uint16 i = 0; i < k13_WallSetGraphicCount; ++i) { _wallSetBitMaps[i] = _bitmaps[i + firstIndice]; } - for (uint16 i = 0; i <= kWall_D3LCR - kWall_D0R; ++i) - _wallSetBitMaps[i + kWall_D0R_Native] = _wallSetBitMaps[i + kWall_D0R]; + for (uint16 i = 0; i <= kG698_Wall_D3LCR - kG702_Wall_D0R; ++i) + _wallSetBitMaps[i + kG99_Wall_D0R_Native] = _wallSetBitMaps[i + kG702_Wall_D0R]; - uint16 srcIndex[7] = {kDoorFrameLeft_D1C, kWall_D3L2, kWall_D1LCR, kWall_D0L, kWall_D0R, - kWall_D2LCR, kWall_D3LCR}; + uint16 srcIndex[7] = {kG708_DoorFrameLeft_D1C, kG697_Wall_D3L2, kG700_Wall_D1LCR, kG701_Wall_D0L, kG702_Wall_D0R, + kG699_Wall_D2LCR, kG698_Wall_D3LCR}; - uint16 destIndex[7] = {kDoorFrameRight_D1C, kWall_D3R2, kWall_D1LCR_Flipped, kWall_D0R_Flipped, kWall_D0L_Flipped, - kWall_D2LCR_Flipped, kWall_D3LCR_Flipped}; + uint16 destIndex[7] = {kG710_DoorFrameRight_D1C, kG696_Wall_D3R2, kG92_Wall_D1LCR_Flipped, kG94_Wall_D0R_Flipped, kG93_Wall_D0L_Flipped, + kG91_Wall_D2LCR_Flipped, kG90_Wall_D3LCR_Flipped}; // the original loads these flipped walls in loadCurrentMapGraphics @@ -1577,29 +1512,9 @@ void DisplayMan::loadWallSet(WallSet set) { delete[] _wallSetBitMaps[destIndex[i]]; _wallSetBitMaps[destIndex[i]] = new byte[w * h]; blitToBitmap(_wallSetBitMaps[srcIndex[i]], w, h, _wallSetBitMaps[destIndex[i]], w); - if (srcIndex[i] != kWall_D2LCR && srcIndex[i] != kWall_D3LCR) // TODO: implement flipping of these two bitmaps, disabled with if + if (srcIndex[i] != kG699_Wall_D2LCR && srcIndex[i] != kG698_Wall_D3LCR) // TODO: implement flipping of these two bitmaps, disabled with if flipBitmapHorizontal(_wallSetBitMaps[destIndex[i]], w, h); } - - - /* - uint16 graphicIndice = firstIndice + kWall_D2LCR; - uint16 w = width(graphicIndice), h = height(graphicIndice); - byte *tmp = new byte[w * h]; - clearBitmap(tmp, w, h, kColorFlesh); - Box *box = &gBoxWallBitmap_D2LCR; - blitToBitmap(_wallSetBitMaps[kWall_D2LCR_Flipped], w, 8, 0, tmp, w, box->X1, box->X2, box->Y1, box->Y2, kColorNoTransparency); - delete[] _wallSetBitMaps[kWall_D2LCR_Flipped]; - _wallSetBitMaps[kWall_D2LCR_Flipped] = tmp; - - graphicIndice = firstIndice + kWall_D3LCR; - w = width(graphicIndice), h = height(graphicIndice); - tmp = new byte[w * h]; - clearBitmap(tmp, w, h, kColorFlesh); - box = &gBoxWallBitmap_D3LCR; - blitToBitmap(_wallSetBitMaps[kWall_D3LCR_Flipped], w, 8, 0, tmp, w, box->X1, box->X2, box->Y1, box->Y2, kColorNoTransparency); - delete[] _wallSetBitMaps[kWall_D3LCR_Flipped]; - _wallSetBitMaps[kWall_D3LCR_Flipped] = tmp;*/ } @@ -1610,7 +1525,7 @@ void DisplayMan::loadCurrentMapGraphics() { // the original loads some flipped walls here, I moved it to loadWallSet { - int16 val = _vm->_dungeonMan->_currMap._map->_wallSet * k18_StairsGraphicCount + kFirstStairs; + int16 val = _vm->_dungeonMan->_currMap._map->_wallSet * k18_StairsGraphicCount + k90_FirstStairs; _g675_stairsNativeBitmapIndex_Up_Front_D3L = val++; _g676_stairsNativeBitmapIndex_Up_Front_D3C = val++; _g677_stairsNativeBitmapIndex_Up_Front_D2L = val++; @@ -1647,11 +1562,11 @@ void DisplayMan::loadCurrentMapGraphics() { for (uint16 i = 0; i < currMap._wallOrnCount; ++i) { uint16 ornIndice = _g261_currMapWallOrnIndices[i]; - uint16 nativeIndice = kFirstWallOrn + ornIndice * 2; + uint16 nativeIndice = k121_FirstWallOrn + ornIndice * 2; _g101_currMapWallOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice; for (uint16 ornCounter = 0; ornCounter < k3_AlcoveOrnCount; ++ornCounter) { - if (ornIndice == gAlcoveOrnIndices[ornCounter]) { + if (ornIndice == g192_AlcoveOrnIndices[ornCounter]) { _g267_currMapAlcoveOrnIndices[alcoveCount++] = i; if (ornIndice == 2) _g266_currMapViAltarIndex = i; @@ -1659,31 +1574,31 @@ void DisplayMan::loadCurrentMapGraphics() { } for (uint16 ornCounter = 0; ornCounter < k1_FountainOrnCount; ++ornCounter) - if (ornIndice == gFountainOrnIndices[ornCounter]) + if (ornIndice == g193_FountainOrnIndices[ornCounter]) _g268_currMapFountainOrnIndices[fountainCount++] = i; - _g101_currMapWallOrnInfo[i][k1_CoordinateSet] = gWallOrnCoordSetIndices[ornIndice]; + _g101_currMapWallOrnInfo[i][k1_CoordinateSet] = g194_WallOrnCoordSetIndices[ornIndice]; } for (uint16 i = 0; i < currMap._floorOrnCount; ++i) { uint16 ornIndice = _g262_currMapFloorOrnIndices[i]; - uint16 nativeIndice = kFirstFloorOrn + ornIndice * 6; + uint16 nativeIndice = k247_FirstFloorOrn + ornIndice * 6; _g102_currMapFloorOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice; - _g102_currMapFloorOrnInfo[i][k1_CoordinateSet] = gFloorOrnCoordSetIndices[ornIndice]; + _g102_currMapFloorOrnInfo[i][k1_CoordinateSet] = g195_FloorOrnCoordSetIndices[ornIndice]; } for (uint16 i = 0; i < currMap._doorOrnCount; ++i) { uint16 ornIndice = _g263_currMapDoorOrnIndices[i]; - uint16 nativeIndice = kFirstDoorOrn + ornIndice; + uint16 nativeIndice = k303_FirstDoorOrn + ornIndice; _g103_currMapDoorOrnInfo[i][k0_NativeBitmapIndex] = nativeIndice; - _g103_currMapDoorOrnInfo[i][k1_CoordinateSet] = gDoorOrnCoordIndices[ornIndice]; + _g103_currMapDoorOrnInfo[i][k1_CoordinateSet] = g196_DoorOrnCoordIndices[ornIndice]; } applyCreatureReplColors(9, 8); applyCreatureReplColors(10, 12); for (uint16 creatureType = 0; creatureType < currMap._creatureTypeCount; ++creatureType) { - CreatureAspect &aspect = gCreatureAspects[_g264_currMapAllowedCreatureTypes[creatureType]]; + CreatureAspect &aspect = g219_CreatureAspects[_g264_currMapAllowedCreatureTypes[creatureType]]; uint16 replColorOrdinal = aspect.getReplColour9(); if (replColorOrdinal) applyCreatureReplColors(9, _vm->ordinalToIndex(replColorOrdinal)); @@ -1695,15 +1610,15 @@ void DisplayMan::loadCurrentMapGraphics() { void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor) { for (int16 i = 0; i < 6; ++i) - g21_PalDungeonView[i][replacedColor] = gCreatureReplColorSets[replacementColor]._RGBColor[i]; + g21_PalDungeonView[i][replacedColor] = g220_CreatureReplColorSets[replacementColor]._RGBColor[i]; - gPalChangesCreature_D2[replacedColor] = gCreatureReplColorSets[replacementColor]._D2ReplacementColor; - gPalChangesCreature_D3[replacedColor] = gCreatureReplColorSets[replacementColor]._D3ReplacementColor; + g222_PalChangesCreature_D2[replacedColor] = g220_CreatureReplColorSets[replacementColor]._D2ReplacementColor; + g221_PalChangesCreature_D3[replacedColor] = g220_CreatureReplColorSets[replacementColor]._D3ReplacementColor; } void DisplayMan::drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) { if (f._srcWidth) { - blitToScreen(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, gDungeonViewport); + blitToScreen(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, g296_DungeonViewport); } } @@ -1711,18 +1626,18 @@ void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeInde if (f._srcWidth) { blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcHeight, _g74_tmpBitmap, f._srcWidth); flipBitmapHorizontal(_g74_tmpBitmap, f._srcWidth, f._srcHeight); - blitToScreen(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, gDungeonViewport); + blitToScreen(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, g296_DungeonViewport); } } -Box gBoxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription -byte gInscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY +Box g202_BoxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription +byte g203_InscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY 48, /* 1 Line */ 59, /* 2 lines */ 75, /* 3 lines */ 86}; /* 4 lines */ -byte gWallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_WallOrnamentDerivedBitmapIndexIncrement +byte g190_WallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_WallOrnamentDerivedBitmapIndexIncrement 0, /* D3L Right */ 0, /* D3R Left */ 1, /* D3L Front */ @@ -1736,10 +1651,10 @@ byte gWallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_WallO 4, /* D1L Right */ 4}; /* D1R Left */ -byte gPalChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3 -byte gPalChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2 +byte g198_PalChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3 +byte g199_PalChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2 -byte gUnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2 +byte g204_UnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2 /* { Y for 1 line, Y for 2 lines, Y for 3 lines } */ 45, 48, 53, /* D3L Right, D3R Left */ 43, 49, 56, /* D3L Front, D3C Front, D3R Front */ @@ -1747,7 +1662,7 @@ byte gUnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableIns 46, 53, 63, /* D2L Front, D2C Front, D2R Front */ 46, 57, 68}; /* D1L Right, D1R Left */ -Box gBoxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall +Box g109_BoxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) { byte *bitmapGreen; @@ -1765,7 +1680,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex int16 wallOrnIndex = wallOrnOrd - 1; int16 nativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k0_NativeBitmapIndex]; - uint16 *coordinateSetA = gWallOrnCoordSets[_g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]][viewWallIndex]; + uint16 *coordinateSetA = g205_WallOrnCoordSets[_g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]][viewWallIndex]; isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnIndex); isInscription = (wallOrnIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex); if (isInscription) { @@ -1775,9 +1690,9 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) { if (viewWallIndex == k12_ViewWall_D1C_FRONT) { if (isInscription) { - Frame &D1CFrame = gFrameWalls[kViewSquare_D1C]; - blitToScreen(_wallSetBitMaps[kWall_D1LCR], D1CFrame._srcWidth, 94, 28, gBoxWallPatchBehindInscription._x1, gBoxWallPatchBehindInscription._x2, - gBoxWallPatchBehindInscription._y1, gBoxWallPatchBehindInscription._y2, k255_ColorNoTransparency, gDungeonViewport); + Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C]; + blitToScreen(_wallSetBitMaps[kG700_Wall_D1LCR], D1CFrame._srcWidth, 94, 28, g202_BoxWallPatchBehindInscription._x1, g202_BoxWallPatchBehindInscription._x2, + g202_BoxWallPatchBehindInscription._y1, g202_BoxWallPatchBehindInscription._y2, k255_ColorNoTransparency, g296_DungeonViewport); unsigned char *string = inscriptionString; bitmapRed = _bitmaps[k120_InscriptionFontIndice]; @@ -1789,9 +1704,9 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex characterCount++; } frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7; - frame._box._y1 = (frame._box._y2 = gInscriptionLineY[textLineIndex++]) - 7; + frame._box._y1 = (frame._box._y2 = g203_InscriptionLineY[textLineIndex++]) - 7; while (characterCount--) { - blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._box, k10_ColorFlesh, gDungeonViewport); + blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._box, k10_ColorFlesh, g296_DungeonViewport); frame._box._x1 += 8; frame._box._x2 += 8; } @@ -1828,12 +1743,12 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex int16 wallOrnCoordSetIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]; flipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT); if (flipHorizontal) { - coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][k11_ViewWall_D1R_LEFT]; + coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k11_ViewWall_D1R_LEFT]; } else if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) { - coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][k10_ViewWall_D1L_RIGHT]; + coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k10_ViewWall_D1L_RIGHT]; } else { nativeBitmapIndex++; - coordSetB = gWallOrnCoordSets[wallOrnCoordSetIndex][k12_ViewWall_D1C_FRONT]; + coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k12_ViewWall_D1C_FRONT]; if (viewWallIndex == k7_ViewWall_D2L_FRONT) { coordinateSetOffset = 6; } else if (viewWallIndex == k9_ViewWall_D2R_FRONT) { @@ -1842,7 +1757,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex } int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0]; blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], coordSetB[4] << 1, coordSetB[5], _g74_tmpBitmap, pixelWidth + 1, coordinateSetA[5], - (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? gPalChangesDoorButtonAndWallOrn_D3 : gPalChangesDoorButtonAndWallOrn_D2); + (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2); bitmapGreen = _bitmaps[nativeBitmapIndex]; var_X = pixelWidth; if (flipHorizontal) { @@ -1877,15 +1792,15 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex coordinateSetA = (uint16*)&frame._box; - coordinateSetA[3] = gUnreadableInscriptionBoxY2[gWallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1]; + coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1]; } } - blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, coordinateSetA[0], coordinateSetA[1], coordinateSetA[2], coordinateSetA[3], k10_ColorFlesh, gDungeonViewport); + blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, coordinateSetA[0], coordinateSetA[1], coordinateSetA[2], coordinateSetA[3], k10_ColorFlesh, g296_DungeonViewport); if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { - Box &box = gBoxChampionPortraitOnWall; + Box &box = g109_BoxChampionPortraitOnWall; blitToScreen(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29, box._x1, box._x2, box._y1, box._y2, - k1_ColorDarkGary, gDungeonViewport); + k1_ColorDarkGary, g296_DungeonViewport); } return isAlcove; } @@ -1955,12 +1870,12 @@ int16 DisplayMan::getScaledDimension(int16 dimension, int16 scale) { } /* This is the full dungeon view */ -Box gBoxExplosionPattern_D0C = Box(0, 223, 0, 135); // @ G0105_s_Graphic558_Box_ExplosionPattern_D0C +Box g105_BoxExplosionPattern_D0C = Box(0, 223, 0, 135); // @ G0105_s_Graphic558_Box_ExplosionPattern_D0C -byte gExplosionBaseScales[5] = { // @ G0216_auc_Graphic558_ExplosionBaseScales +byte g216_ExplosionBaseScales[5] = { // @ G0216_auc_Graphic558_ExplosionBaseScales 10,/* D4 */ 16,/* D3 */ 23,/* D2 */ 32,/* D1 */ 32};/* D0 */ -byte gObjectPileShiftSetIndices[16][2] = { // @ G0217_aauc_Graphic558_ObjectPileShiftSetIndices +byte g217_ObjectPileShiftSetIndices[16][2] = { // @ G0217_aauc_Graphic558_ObjectPileShiftSetIndices /* { X shift index, Y shift index } */ {2, 5}, {0, 6}, @@ -1979,7 +1894,7 @@ byte gObjectPileShiftSetIndices[16][2] = { // @ G0217_aauc_Graphic558_ObjectPile {1, 3}, {5, 3}}; /* 16 pairs of X and Y shift values */ -byte gObjectCoordinateSets[3][10][5][2] = { // @ G0218_aaaauc_Graphic558_ObjectCoordinateSets +byte g218_ObjectCoordinateSets[3][10][5][2] = { // @ G0218_aaaauc_Graphic558_ObjectCoordinateSets /* { {X, Y }, {X, Y }, {X, Y }, {X, Y }, {X, Y } } */ {{{0, 0},{0, 0},{125, 72},{95, 72},{112, 64}}, /* D3C */ {{0, 0},{0, 0},{62, 72},{25, 72},{24, 64}}, /* D3L */ @@ -2013,12 +1928,12 @@ byte gObjectCoordinateSets[3][10][5][2] = { // @ G0218_aaaauc_Graphic558_ObjectC {{66, 135},{158, 135},{0, 0},{0, 0},{0, 0}}}}; /* D0C */ -int16 gShiftSets[3][8] = { // @ G0223_aac_Graphic558_ShiftSets +int16 g223_ShiftSets[3][8] = { // @ G0223_aac_Graphic558_ShiftSets {0, 1, 2, 3, 0, -3, -2, -1}, /* D0 Back or D1 Front */ {0, 1, 1, 2, 0, -2, -1, -1}, /* D1 Back or D2 Front */ {0, 1, 1, 1, 0, -1, -1, -1}}; /* D2 Back or D3 Front */ -byte gCreatureCoordinateSets[3][11][5][2] = { // @ G0224_aaaauc_Graphic558_CreatureCoordinateSets +byte g224_CreatureCoordinateSets[3][11][5][2] = { // @ G0224_aaaauc_Graphic558_CreatureCoordinateSets /* { { X, Y }, { X, Y }, { X, Y }, { X, Y }, { X, Y } } */ {{{95, 70},{127, 70},{129, 75},{93, 75},{111, 72}}, /* D3C */ {{131, 70},{163, 70},{158, 75},{120, 75},{145, 72}}, /* D3L */ @@ -2054,7 +1969,7 @@ byte gCreatureCoordinateSets[3][11][5][2] = { // @ G0224_aaaauc_Graphic558_Creat {{0, 0},{67, 96},{0, 0},{0, 0},{0, 0}}, /* D0L */ {{156, 96},{0, 0},{0, 0},{0, 0},{0, 0}}}}; /* D0R */ -int16 gExplosionCoordinates[15][2][2] = { // @ G0226_aaai_Graphic558_ExplosionCoordinates +int16 g226_ExplosionCoordinates[15][2][2] = { // @ G0226_aaai_Graphic558_ExplosionCoordinates /* { { Front Left X, Front Left Y }, { Front Right X, Front Right Y } } */ {{100, 47},{122, 47}}, /* D4C */ {{52, 47},{76, 47}}, /* D4L */ @@ -2071,7 +1986,7 @@ int16 gExplosionCoordinates[15][2][2] = { // @ G0226_aaai_Graphic558_ExplosionCo {{0, 0},{0, 0}}, /* D0C */ {{-73, 60},{-33, 60}}, /* D0L */ {{256, 60},{296, 60}}}; /* D0R */ -int16 gRebirthStep2ExplosionCoordinates[7][3] = { // @ G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates +int16 g227_RebirthStep2ExplosionCoordinates[7][3] = { // @ G0227_aai_Graphic558_RebirthStep2ExplosionCoordinates /* { X, Y, Scale } */ {113, 57, 12}, /* D3C */ {24, 57, 12}, /* D3L */ @@ -2080,7 +1995,7 @@ int16 gRebirthStep2ExplosionCoordinates[7][3] = { // @ G0227_aai_Graphic558_Rebi {12, 63, 16}, /* D2L */ {213, 63, 16}, /* D2R */ {112, 76, 24}}; /* D1C */ -int16 gRebirthStep1ExplosionCoordinates[7][3] = { // @ G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates +int16 g228_RebirthStep1ExplosionCoordinates[7][3] = { // @ G0228_aai_Graphic558_RebirthStep1ExplosionCoordinates /* { X, Y, Scale } */ {112, 53, 15}, /* D3C */ {24, 53, 15}, /* D3L */ @@ -2090,7 +2005,7 @@ int16 gRebirthStep1ExplosionCoordinates[7][3] = { // @ G0228_aai_Graphic558_Rebi {208, 59, 20}, /* D2R */ {112, 70, 32}}; /* D1C */ -int16 gCenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_CenteredExplosionCoordinates +int16 g225_CenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_CenteredExplosionCoordinates /* { X, Y } */ {111, 47}, /* D4C */ {57, 47}, /* D4L */ @@ -2108,7 +2023,7 @@ int16 gCenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_Centere {-53, 60}, /* D0L */ {276, 60}}; /* D0R */ -#define kBlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK +#define k0x0080_BlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK void DisplayMan::cthulhu(Thing thingParam, direction directionParam, int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) { @@ -2278,13 +2193,13 @@ creatures are drawn in the right order and so that Fluxcages are not drawn twice } /* Square where objects are visible and object is located on cell being processed */ - if ((viewSquareIndex >= kViewSquare_D3C) && (viewSquareIndex <= kViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { - objectAspect = &(gObjectAspects[gObjectInfo[dunMan.getObjectInfoIndex(thingParam)]._objectAspectIndex]); + if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { + objectAspect = &(g209_ObjectAspects[gObjectInfo[dunMan.getObjectInfoIndex(thingParam)]._objectAspectIndex]); AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex; if (useAlcoveObjectImage = (drawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane)) { AL_4_nativeBitmapIndex++; } - coordinateSet = gObjectCoordinateSets[objectAspect->_coordinateSet][viewSquareIndex][AL_2_viewCell]; + coordinateSet = g218_ObjectCoordinateSets[objectAspect->_coordinateSet][viewSquareIndex][AL_2_viewCell]; if (!coordinateSet[1]) /* If object is not visible */ continue; T0115015_DrawProjectileAsObject: @@ -2295,7 +2210,7 @@ T0115015_DrawProjectileAsObject: either on the right lane or on the right column of the center lane */ paddingPixelCount = 0; - if ((viewSquareIndex == kViewSquare_D0C) || ((viewSquareIndex >= kViewSquare_D1C) && (AL_2_viewCell >= k2_ViewCellBackRight))) { + if ((viewSquareIndex == k9_ViewSquare_D0C) || ((viewSquareIndex >= k6_ViewSquare_D1C) && (AL_2_viewCell >= k2_ViewCellBackRight))) { /* If object is in the center lane (only D0C or D1C with condition above) and is not a projectile */ drawingGrabbableObject = (!viewLane && !drawProjectileAsObject); AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front; @@ -2310,17 +2225,17 @@ T0115015_DrawProjectileAsObject: } else { drawingGrabbableObject = false; derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex; - if ((viewSquareIndex >= kViewSquare_D1C) || ((viewSquareIndex >= kViewSquare_D2C) && (AL_2_viewCell >= k2_ViewCellBackRight))) { + if ((viewSquareIndex >= k6_ViewSquare_D1C) || ((viewSquareIndex >= k3_ViewSquare_D2C) && (AL_2_viewCell >= k2_ViewCellBackRight))) { derivedBitmapIndex++; AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front; byteWidth = getScaledDimension(objectAspect->_width, k20_Scale_D2); heightRedEagle = getScaledDimension(objectAspect->_height, k20_Scale_D2); - paletteChanges = gPalChangesFloorOrn_D2; + paletteChanges = g214_PalChangesFloorOrn_D2; } else { AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front; byteWidth = getScaledDimension(objectAspect->_width, k16_Scale_D3); heightRedEagle = getScaledDimension(objectAspect->_height, k16_Scale_D3); - paletteChanges = gPalChangesFloorOrn_D3; + paletteChanges = g213_PalChangesFloorOrn_D3; } if (flipHorizontal) { derivedBitmapIndex += 2; @@ -2344,8 +2259,8 @@ T0115015_DrawProjectileAsObject: AL_4_xPos = coordinateSet[0]; boxByteGreen._y2 = coordinateSet[1] + 1; if (!drawProjectileAsObject) { /* If drawing an object that is not a projectile */ - AL_4_xPos += gShiftSets[AL_8_shiftSetIndex][gObjectPileShiftSetIndices[objectShiftIndex][0]]; - boxByteGreen._y2 += gShiftSets[AL_8_shiftSetIndex][gObjectPileShiftSetIndices[objectShiftIndex][1]]; + AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][g217_ObjectPileShiftSetIndices[objectShiftIndex][0]]; + boxByteGreen._y2 += g223_ShiftSets[AL_8_shiftSetIndex][g217_ObjectPileShiftSetIndices[objectShiftIndex][1]]; objectShiftIndex++; /* The next object drawn will use the next shift values */ if (drawAlcoveObjects) { if (objectShiftIndex >= 14) { @@ -2392,7 +2307,7 @@ T0115015_DrawProjectileAsObject: AL_6_bitmapRedBanana = bitmapGreenAnt; dunMan._pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */ } - blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, gDungeonViewport); + blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, g296_DungeonViewport); if (drawProjectileAsObject) goto T0115171_BackFromT0115015_DrawProjectileAsObject; @@ -2400,7 +2315,7 @@ T0115015_DrawProjectileAsObject: } while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList); if (AL_2_viewCell == k4_ViewCellAlcove) break; /* End of processing when drawing objects in an alcove */ - if (viewSquareIndex < kViewSquare_D3C) + if (viewSquareIndex < k0_ViewSquare_D3C) break; /* End of processing if square is too far away at D4 */ /* Draw creatures */ @@ -2414,7 +2329,7 @@ T0115015_DrawProjectileAsObject: group = (Group*)dunMan.getThingData(groupThing); activeGroup = &_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()]; creatureInfo = &gCreatureInfo[group->_type]; - creatureAspectStruct = &gCreatureAspects[creatureInfo->_creatureAspectIndex]; + creatureAspectStruct = &g219_CreatureAspects[creatureInfo->_creatureAspectIndex]; creatureSize = getFlag(creatureInfo->_attributes, kMaskCreatureInfo_size); creatureGraphicInfoGreen = creatureInfo->_graphicInfo; } @@ -2478,11 +2393,11 @@ T0115015_DrawProjectileAsObject: creatureAspectInt = activeGroup->_aspect[creatureIndexGreen]; - if (viewSquareIndex > kViewSquare_D0C) { + if (viewSquareIndex > k9_ViewSquare_D0C) { viewSquareIndex--; } T0115077_DrawSecondHalfSquareCreature: - coordinateSet = gCreatureCoordinateSets[((CreatureAspect*)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell]; + coordinateSet = g224_CreatureCoordinateSets[((CreatureAspect*)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell]; if (!coordinateSet[1]) goto T0115126_CreatureNotVisible; AL_0_creatureGraphicInfoRed = creatureGraphicInfoGreen; @@ -2541,7 +2456,7 @@ T0115077_DrawSecondHalfSquareCreature: } } } - if (viewSquareIndex >= kViewSquare_D1C) { /* Creature is on D1 */ + if (viewSquareIndex >= k6_ViewSquare_D1C) { /* Creature is on D1 */ creaturePaddingPixelCount = 0; AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front; transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour(); @@ -2578,17 +2493,17 @@ T0115077_DrawSecondHalfSquareCreature: if (useFlippedHorizontallyCreatureFrontImage) { derivedBitmapIndex++; /* Skip front D1 image in additional graphics */ } - if (viewSquareIndex >= kViewSquare_D2C) { /* Creature is on D2 */ + if (viewSquareIndex >= k3_ViewSquare_D2C) { /* Creature is on D2 */ derivedBitmapIndex++; /* Skip front D3 image in additional graphics */ AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front; useCreatureSpecialD2FrontBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0080_CreatureInfoGraphicMaskSpecialD2Front) && !useCreatureSideBitmap && !useCreatureBackBitmap && !useCreatureAttackBitmap; - paletteChanges = gPalChangesCreature_D2; + paletteChanges = g222_PalChangesCreature_D2; scale = k20_Scale_D2; } else { /* Creature is on D3 */ AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front; useCreatureSpecialD2FrontBitmap = false; - paletteChanges = gPalChangesCreature_D3; + paletteChanges = g221_PalChangesCreature_D3; scale = k16_Scale_D3; } byteWidth = getScaledDimension(sourceByteWidth, scale); @@ -2621,11 +2536,11 @@ T0115077_DrawSecondHalfSquareCreature: } } AL_4_yPos = coordinateSet[1]; - AL_4_yPos += gShiftSets[AL_8_shiftSetIndex][getVerticalOffsetM23(creatureAspectInt)]; + AL_4_yPos += g223_ShiftSets[AL_8_shiftSetIndex][getVerticalOffsetM23(creatureAspectInt)]; boxByteGreen._y2 = MIN(AL_4_yPos, (int16)135) + 1; boxByteGreen._y1 = MIN(0, AL_4_yPos - (heightRedEagle - 1)); AL_4_xPos = coordinateSet[0]; - AL_4_xPos += gShiftSets[AL_8_shiftSetIndex][getHorizontalOffsetM22(creatureAspectInt)]; + AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][getHorizontalOffsetM22(creatureAspectInt)]; if (viewLane == k1_ViewLaneLeft) { AL_4_xPos -= 100; } else { @@ -2643,7 +2558,7 @@ T0115077_DrawSecondHalfSquareCreature: AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1); } warning("SUPER WARNINIG: we might nee noralized with on byteWidth"); - blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, boxByteGreen, (Color)transparentColor, gDungeonViewport); + blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, boxByteGreen, (Color)transparentColor, g296_DungeonViewport); T0115126_CreatureNotVisible: if (twoHalfSquareCreaturesFrontView) { @@ -2659,9 +2574,9 @@ T0115126_CreatureNotVisible: /* Draw projectiles */ T0115129_DrawProjectiles: if (!sqaureHasProjectile - || ((viewSquareIndex = viewSquareIndexBackup) > kViewSquare_D0C) + || ((viewSquareIndex = viewSquareIndexBackup) > k9_ViewSquare_D0C) /* If there is no projectile to draw or if projectiles are not visible on the specified square or on the cell being drawn */ -|| (!(projectilePosX = gObjectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0]))) +|| (!(projectilePosX = g218_ObjectCoordinateSets[0][viewSquareIndex][AL_2_viewCell = currentViewCellToDraw][0]))) continue; thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */ @@ -2669,11 +2584,11 @@ continue; if ((thingParam.getType() == kProjectileThingType) && (thingParam.getCell() == cellYellowBear)) { projectile = (Projectile*)dunMan.getThingData(thingParam); if ((AL_4_projectileAspect = dunMan.getProjectileAspect(projectile->_object)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */ - objectAspect = (ObjectAspect*)&gProjectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)]; + objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)]; AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice; projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask); if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) - || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == kViewSquare_D0C)) { + || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == k9_ViewSquare_D0C)) { scale = 0; /* Use native bitmap without resizing */ byteWidth = ((ProjectileAspect*)objectAspect)->_width; heightRedEagle = ((ProjectileAspect*)objectAspect)->_height; @@ -2778,13 +2693,13 @@ the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */ AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1)); } - blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, gDungeonViewport); + blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, g296_DungeonViewport); } else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */ useAlcoveObjectImage = false; projectileCoordinates[0] = projectilePosX; projectileCoordinates[1] = 47; coordinateSet = projectileCoordinates; - objectAspect = &gObjectAspects[AL_4_projectileAspect]; + objectAspect = &g209_ObjectAspects[AL_4_projectileAspect]; AL_4_nativeBitmapIndex = objectAspect->_firstNativeBitmapRelativeIndex + k360_FirstObjectGraphicIndice; drawProjectileAsObject = true; /* Go to code section to draw an object. Once completed, it jumps back to T0115171_BackFromT0115015_DrawProjectileAsObject below */ @@ -2809,8 +2724,8 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; AL_2_cellPurpleMan = thingParam.getCell(); explosion = (Explosion*)dunMan.getThingData(thingParam); if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= kExplosionType_RebirthStep1)) - && ((AL_1_viewSquareExplosionIndex < kViewSquare_D3C_Explosion) - || (AL_1_viewSquareExplosionIndex > kViewSquare_D1C_Explosion) + && ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion) + || (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion) || (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */ continue; smoke = false; @@ -2825,21 +2740,21 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke; } else { if (AL_4_explosionType == kExplosionType_RebirthStep1) { - objectAspect = (ObjectAspect*)&gProjectileAspect[_vm->ordinalToIndex(-dunMan.getProjectileAspect(Thing::_explLightningBolt))]; + objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->ordinalToIndex(-dunMan.getProjectileAspect(Thing::_explLightningBolt))]; AL_6_bitmapRedBanana = getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1)); - explosionCoordinates = gRebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3]; + explosionCoordinates = g228_RebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3]; byteWidth = getScaledDimension((((ProjectileAspect*)objectAspect)->_width), explosionCoordinates[2]); heightRedEagle = getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]); - if (AL_1_viewSquareExplosionIndex != kViewSquare_D1C_Explosion) { + if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) { blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, _g74_tmpBitmap, - byteWidth, heightRedEagle, gPalChangesNoChanges); + byteWidth, heightRedEagle, g17_PalChangesNoChanges); AL_6_bitmapRedBanana = _g74_tmpBitmap; } goto T0115200_DrawExplosion; } if (AL_4_explosionType == kExplosionType_Fluxcage) { - if (AL_1_viewSquareExplosionIndex >= kViewSquare_D3L_Explosion) { + if (AL_1_viewSquareExplosionIndex >= k4_ViewSquare_D3L_Explosion) { fluxcageExplosion = explosion; } continue; @@ -2848,7 +2763,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; } } } - if (AL_1_viewSquareExplosionIndex == kViewSquare_D0C_Explosion) { + if (AL_1_viewSquareExplosionIndex == k12_ViewSquare_D0C_Explosion) { if (smoke) { AL_4_explosionAspectIndex--; /* Smoke uses the same graphics as Poison Cloud, but with palette changes */ } @@ -2862,30 +2777,30 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache"); AL_6_bitmapRedBanana = getBitmap(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice); if (smoke) { - blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _g74_tmpBitmap, 48, 32, gPalChangeSmoke); + blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _g74_tmpBitmap, 48, 32, g212_PalChangeSmoke); AL_6_bitmapRedBanana = _g74_tmpBitmap; } - blitBoxFilledWithMaskedBitmapToScreen(AL_6_bitmapRedBanana, nullptr, getDerivedBitmap(k0_DerivedBitmapViewport), gBoxExplosionPattern_D0C, + blitBoxFilledWithMaskedBitmapToScreen(AL_6_bitmapRedBanana, nullptr, getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C, _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64), - 224, (Color)(kBlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93); + 224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } else { if (rebirthExplosion) { - explosionCoordinates = gRebirthStep2ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3]; + explosionCoordinates = g227_RebirthStep2ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3]; explosionScale = explosionCoordinates[2]; } else { if (explosion->getCentered()) { - explosionCoordinates = gCenteredExplosionCoordinates[AL_1_viewSquareExplosionIndex]; + explosionCoordinates = g225_CenteredExplosionCoordinates[AL_1_viewSquareExplosionIndex]; } else { if ((AL_2_cellPurpleMan == directionParam) || (AL_2_cellPurpleMan == returnPrevVal(directionParam))) { AL_2_viewCell = k0_ViewCellFronLeft; } else { AL_2_viewCell = k1_ViewCellFrontRight; } - explosionCoordinates = gExplosionCoordinates[AL_1_viewSquareExplosionIndex][AL_2_viewCell]; + explosionCoordinates = g226_ExplosionCoordinates[AL_1_viewSquareExplosionIndex][AL_2_viewCell]; } - explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * gExplosionBaseScales[explosionScaleIndex]) >> 8) & (int16)0xFFFE; + explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * g216_ExplosionBaseScales[explosionScaleIndex]) >> 8) & (int16)0xFFFE; } AL_6_bitmapRedBanana = getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle); T0115200_DrawExplosion: @@ -2930,16 +2845,16 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP if (flipVertical) { flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } - blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, gDungeonViewport); + blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, g296_DungeonViewport); } } } while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList); /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */ if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_g77_doNotDrawFluxcagesDuringEndgame) { AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */ - fieldAspect = gFieldAspects[viewSquareIndex]; + fieldAspect = g188_FieldAspects[viewSquareIndex]; (fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */ - drawField(&fieldAspect, *(Box*)&gFrameWalls[viewSquareIndex]); + drawField(&fieldAspect, *(Box*)&g163_FrameWalls[viewSquareIndex]); } } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index ca478b32b9..80902e4e68 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -399,7 +399,7 @@ public: }; // @ CREATURE_REPLACEMENT_COLOR_SET extern Viewport gDefultViewPort; -extern Viewport gDungeonViewport; +extern Viewport g296_DungeonViewport; #define k0_DoorButton 0 // @ C0_DOOR_BUTTON @@ -523,7 +523,7 @@ public: int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDefultViewPort); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap void blitBoxFilledWithMaskedBitmapToScreen(byte *src, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, - int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap + int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = g296_DungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index d7382340f3..11ccd944d5 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -96,9 +96,9 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { champion = &cm._champions[championIndex]; int16 w = dm.getWidth(k17_InventoryGraphicIndice); int16 h = dm.getHeight(k17_InventoryGraphicIndice); - dm.blitToScreen(dm.getBitmap(k17_InventoryGraphicIndice), w, 0, 0, 0, w, 0, h, k255_ColorNoTransparency, gDungeonViewport); + dm.blitToScreen(dm.getBitmap(k17_InventoryGraphicIndice), w, 0, 0, 0, w, 0, h, k255_ColorNoTransparency, g296_DungeonViewport); if (cm._candidateChampionOrdinal) { - dm.clearScreenBox(k12_ColorDarkestGray, gBoxFloppyZzzCross, gDungeonViewport); + dm.clearScreenBox(k12_ColorDarkestGray, gBoxFloppyZzzCross, g296_DungeonViewport); } _vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "HEALTH"); _vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "STAMINA"); @@ -175,7 +175,7 @@ void InventoryMan::drawPanelFoodWaterPoisoned() { void InventoryMan::drawPanelResurrectReincarnate() { _panelContent = kPanelContentResurrectReincarnate; - _vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, gBoxPanel, k6_ColorDarkGreen, gDungeonViewport); + _vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, gBoxPanel, k6_ColorDarkGreen, g296_DungeonViewport); } void InventoryMan::drawPanel() { @@ -258,7 +258,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) { charRed++; } *charRed = '\0'; - dispMan.blitToScreen(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, gDungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, g296_DungeonViewport); int16 lineCount = 1; charRed++; char *charGreen = charRed; // first char of the second line @@ -336,7 +336,7 @@ void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yP box._x2 = (box._x1 = xPos) + 15 + 1; box._y2 = (box._y1 = yPos) + 15 + 1; _vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap); - _vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, k255_ColorNoTransparency, gDungeonViewport); + _vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, k255_ColorNoTransparency, g296_DungeonViewport); } void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) { @@ -411,7 +411,7 @@ Box gBoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye void InventoryMan::drawPanelArrowOrEye(bool pressingEye) { DisplayMan &dispMan = *_vm->_displayMan; dispMan.blitToScreen(dispMan.getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice), - 16, 0, 0, gBoxArrowOrEye, k8_ColorRed, gDungeonViewport); + 16, 0, 0, gBoxArrowOrEye, k8_ColorRed, g296_DungeonViewport); } @@ -443,8 +443,8 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye); } else { IconIndice iconIndex = objMan.getIconIndex(thingToDraw); - dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, gDungeonViewport); - dispMan.blitToScreen(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, gBoxObjectDescCircle, k12_ColorDarkestGray, gDungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, g296_DungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, gBoxObjectDescCircle, k12_ColorDarkestGray, g296_DungeonViewport); char *descString = nullptr; char str[40]; diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index ddb002d446..dd3550200d 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -224,7 +224,7 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { _vm->_displayMan->_g578_useByteBoxCoordinates = false; if (slotBoxIndex >= kSlotBoxInventoryFirstSlot) { _vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, - box, k255_ColorNoTransparency, gDungeonViewport); + box, k255_ColorNoTransparency, g296_DungeonViewport); } else { _vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, box, k255_ColorNoTransparency, gDefultViewPort); diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index d535194875..8f4e04c6be 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -70,7 +70,7 @@ void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Col } void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) { - printTextToScreen(posX, posY, textColor, bgColor, text, gDungeonViewport); + printTextToScreen(posX, posY, textColor, bgColor, text, g296_DungeonViewport); } void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, -- cgit v1.2.3 From 71e4b5b2bca49f0de8b07f4f85de9167dd9b5f99 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 2 Jul 2016 01:55:48 +0200 Subject: DM: Renaming in champion.c/h --- engines/dm/champion.cpp | 392 +++++++++++++++++++-------------------- engines/dm/champion.h | 468 +++++++++++++++++++++++------------------------ engines/dm/dm.cpp | 8 +- engines/dm/eventman.cpp | 82 ++++----- engines/dm/inventory.cpp | 52 +++--- engines/dm/loadsave.cpp | 6 +- engines/dm/menus.cpp | 78 ++++---- engines/dm/menus.h | 2 +- engines/dm/movesens.cpp | 16 +- engines/dm/objectman.cpp | 38 ++-- 10 files changed, 571 insertions(+), 571 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 5f1b68c15b..9302216766 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -38,14 +38,14 @@ namespace DM { Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye -Box gBoxChampionIcons[4] = { +Box g54_BoxChampionIcons[4] = { Box(281, 299, 0, 13), Box(301, 319, 0, 13), Box(301, 319, 15, 28), Box(281, 299, 15, 28)}; -Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; +Color g46_ChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; -int16 gLightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100}; +int16 g39_LightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100}; uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks /* 30 for champion inventory, 8 for chest */ @@ -91,13 +91,13 @@ uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { - _leaderIndex = kChampionNone; + _g411_leaderIndex = kM1_ChampionNone; - _partyDead = false; - _partyIsSleeping = false; - _leaderHandObjectIconIndex = kIconIndiceNone; - _leaderEmptyHanded = true; - _magicCasterChampionIndex = kChampionNone; + _303_partyDead = false; + _g300_partyIsSleeping = false; + _g413_leaderHandObjectIconIndex = kM1_IconIndiceNone; + _g415_leaderEmptyHanded = true; + _g514_magicCasterChampionIndex = kM1_ChampionNone; } uint16 ChampionMan::getChampionPortraitX(uint16 index) { @@ -143,13 +143,13 @@ void ChampionMan::applyModifiersToStatistics(Champion* champ, ChampionSlot slotI int16 modifier = 0; ThingType thingType = thing.getType(); if (((thingType == kWeaponThingType) || (thingType == kArmourThingType)) - && (slotIndex >= kChampionSlotReadyHand) - && (slotIndex <= kChampionSlotQuiverLine_1_1)) { + && (slotIndex >= k0_ChampionSlotReadyHand) + && (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) { Weapon *weapon = (Weapon*)_vm->_dungeonMan->getThingData(thing); Armour *armour = (Armour*)_vm->_dungeonMan->getThingData(thing); if (((thingType == kWeaponThingType) && weapon->getCursed()) || ((thingType == kArmourThingType) && armour->getCursed())) { - statIndex = kChampionStatLuck; + statIndex = k0_ChampionStatLuck; modifier = -3; goto T0299044_ApplyModifier; } @@ -157,58 +157,58 @@ void ChampionMan::applyModifiersToStatistics(Champion* champ, ChampionSlot slotI statIndex = (ChampionStatisticType)thingType; // variable sharing - if ((iconIndex == kIconIndiceJunkRabbitsFoot) && (slotIndex < kChampionSlotChest_1)) { - statIndex = kChampionStatLuck; + if ((iconIndex == k137_IconIndiceJunkRabbitsFoot) && (slotIndex < k30_ChampionSlotChest_1)) { + statIndex = k0_ChampionStatLuck; modifier = 10; - } else if (slotIndex == kChampionSlotActionHand) { + } else if (slotIndex == k1_ChampionSlotActionHand) { - if (iconIndex == kIconIndiceWeaponMaceOfOrder) { - statIndex = kChampionStatStrength; + if (iconIndex == k45_IconIndiceWeaponMaceOfOrder) { + statIndex = k1_ChampionStatStrength; modifier = 5; } else { - statIndex = kChampionStatMana; - if ((iconIndex >= kIconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= kIconIndiceWeaponStaffOfClawsFull)) { + statIndex = k8_ChampionStatMana; + if ((iconIndex >= k20_IconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= k22_IconIndiceWeaponStaffOfClawsFull)) { modifier = 4; - } else if ((iconIndex >= kIconIndiceWeaponStaff) && (iconIndex <= kIconIndiceWeaponSceptreOfLyf)) { + } else if ((iconIndex >= k58_IconIndiceWeaponStaff) && (iconIndex <= k66_IconIndiceWeaponSceptreOfLyf)) { switch (iconIndex) { - case kIconIndiceWeaponStaff: + case k58_IconIndiceWeaponStaff: modifier = 2; break; - case kIconIndiceWeaponWand: + case k59_IconIndiceWeaponWand: modifier = 1; break; - case kIconIndiceWeaponTeowand: + case k60_IconIndiceWeaponTeowand: modifier = 6; break; - case kIconIndiceWeaponYewStaff: + case k61_IconIndiceWeaponYewStaff: modifier = 4; break; - case kIconIndiceWeaponStaffOfManarStaffOfIrra: + case k62_IconIndiceWeaponStaffOfManarStaffOfIrra: modifier = 10; break; - case kIconIndiceWeaponSnakeStaffCrossOfNeta: + case k63_IconIndiceWeaponSnakeStaffCrossOfNeta: modifier = 8; break; - case kIconIndiceWeaponTheConduitSerpentStaff: + case k64_IconIndiceWeaponTheConduitSerpentStaff: modifier = 16; break; - case kIconIndiceWeaponDragonSpit: + case k65_IconIndiceWeaponDragonSpit: modifier = 7; break; - case kIconIndiceWeaponSceptreOfLyf: + case k66_IconIndiceWeaponSceptreOfLyf: modifier = 5; break; } } else { switch (iconIndex) { - case kIconIndiceWeaponDeltaSideSplitter: + case k38_IconIndiceWeaponDeltaSideSplitter: modifier = 1; break; - case kIconIndiceWeaponTheInquisitorDragonFang: + case k41_IconIndiceWeaponTheInquisitorDragonFang: modifier = 2; break; - case kIconIndiceWeaponVorpalBlade: + case k40_IconIndiceWeaponVorpalBlade: modifier = 4; break; } @@ -216,43 +216,43 @@ void ChampionMan::applyModifiersToStatistics(Champion* champ, ChampionSlot slotI } - } else if (slotIndex == kChampionSlotLegs) { + } else if (slotIndex == k4_ChampionSlotLegs) { - if (iconIndex == kIconIndiceArmourPowertowers) { - statIndex = kChampionStatStrength; + if (iconIndex == k142_IconIndiceArmourPowertowers) { + statIndex = k1_ChampionStatStrength; modifier = 10; } - } else if (slotIndex == kChampionSlotHead) { + } else if (slotIndex == k2_ChampionSlotHead) { - if (iconIndex == kIconIndiceArmourCrownOfNerra) { - statIndex = kChampionStatWisdom; + if (iconIndex == k104_IconIndiceArmourCrownOfNerra) { + statIndex = k3_ChampionStatWisdom; modifier = 10; - } else if (iconIndex == kIconIndiceArmourDexhelm) { - statIndex = kChampionStatDexterity; + } else if (iconIndex == k140_IconIndiceArmourDexhelm) { + statIndex = k2_ChampionStatDexterity; modifier = 10; } - } else if (slotIndex == kChampionSlotTorso) { + } else if (slotIndex == k3_ChampionSlotTorso) { - if (iconIndex == kIconIndiceArmourFlamebain) { - statIndex = kChampionStatAntifire; + if (iconIndex == k141_IconIndiceArmourFlamebain) { + statIndex = k6_ChampionStatAntifire; modifier = 12; - } else if (iconIndex == kIconIndiceArmourCloakOfNight) { - statIndex = kChampionStatDexterity; + } else if (iconIndex == k81_IconIndiceArmourCloakOfNight) { + statIndex = k2_ChampionStatDexterity; modifier = 8; } - } else if (slotIndex == kChampionSlotNeck) { + } else if (slotIndex == k10_ChampionSlotNeck) { - if ((iconIndex >= kIconIndiceJunkJewelSymalUnequipped) && (iconIndex <= kIconIndiceJunkJewelSymalEquipped)) { - statIndex = kChampionStatAntimagic; + if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) { + statIndex = k5_ChampionStatAntimagic; modifier = 15; - } else if (iconIndex == kIconIndiceArmourCloakOfNight) { - statIndex = kChampionStatDexterity; + } else if (iconIndex == k81_IconIndiceArmourCloakOfNight) { + statIndex = k2_ChampionStatDexterity; modifier = 8; - } else if (iconIndex == kIconIndiceJunkMoonstone) { - statIndex = kChampionStatMana; + } else if (iconIndex == k122_IconIndiceJunkMoonstone) { + statIndex = k8_ChampionStatMana; modifier = 3; } @@ -261,10 +261,10 @@ void ChampionMan::applyModifiersToStatistics(Champion* champ, ChampionSlot slotI T0299044_ApplyModifier: if (modifier) { modifier *= modifierFactor; - if (statIndex == kChampionStatMana) { + if (statIndex == k8_ChampionStatMana) { champ->_maxMana += modifier; - } else if (statIndex < kChampionStatAntifire + 1) { - for (uint16 statValIndex = kChampionStatMaximum; statValIndex <= kChampionStatMinimum; ++statValIndex) { + } else if (statIndex < k6_ChampionStatAntifire + 1) { + for (uint16 statValIndex = k0_ChampionStatMaximum; statValIndex <= k2_ChampionStatMinimum; ++statValIndex) { champ->getStatistic((ChampionStatisticType)statIndex, (ChampionStatisticValue)statValIndex) += modifier; warning("BUG0_38"); } @@ -277,13 +277,13 @@ bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) ObjectMan &objMan = *_vm->_objectMan; IconIndice currIconIndex = objMan.getIconIndexInSlotBox(slotBoxIndex); - if (((currIconIndex < kIconIndiceWeaponDagger) && (currIconIndex >= kIconIndiceJunkCompassNorth)) - || ((currIconIndex >= kIconIndicePotionMaPotionMonPotion) && (currIconIndex <= kIconIndicePotionWaterFlask)) - || (currIconIndex == kIconIndicePotionEmptyFlask)) { + if (((currIconIndex < k32_IconIndiceWeaponDagger) && (currIconIndex >= k0_IconIndiceJunkCompassNorth)) + || ((currIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (currIconIndex <= k163_IconIndicePotionWaterFlask)) + || (currIconIndex == k195_IconIndicePotionEmptyFlask)) { IconIndice newIconIndex = objMan.getIconIndex(thing); if (newIconIndex != currIconIndex) { - if ((slotBoxIndex < kSlotBoxInventoryFirstSlot) && !_mousePointerHiddenToDrawChangedObjIconOnScreen) { - _mousePointerHiddenToDrawChangedObjIconOnScreen = true; + if ((slotBoxIndex < kSlotBoxInventoryFirstSlot) && !_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) { + _g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); } objMan.drawIconInSlotBox(slotBoxIndex, newIconIndex); @@ -300,33 +300,33 @@ void ChampionMan::drawChangedObjectIcons() { MenuMan &menuMan = *_vm->_menuMan; uint16 invChampOrdinal = invMan._inventoryChampionOrdinal; - if (_candidateChampionOrdinal && !invChampOrdinal) + if (_g299_candidateChampionOrdinal && !invChampOrdinal) return; - _mousePointerHiddenToDrawChangedObjIconOnScreen = false; - IconIndice leaderHandObjIconIndex = _leaderHandObjectIconIndex; + _g420_mousePointerHiddenToDrawChangedObjIconOnScreen = false; + IconIndice leaderHandObjIconIndex = _g413_leaderHandObjectIconIndex; - if (((leaderHandObjIconIndex < kIconIndiceWeaponDagger) && (leaderHandObjIconIndex >= kIconIndiceJunkCompassNorth)) // < instead of <= is correct - || ((leaderHandObjIconIndex >= kIconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= kIconIndicePotionWaterFlask)) - || (leaderHandObjIconIndex == kIconIndicePotionEmptyFlask)) { - IconIndice iconIndex = objMan.getIconIndex(_leaderHandObject); + if (((leaderHandObjIconIndex < k32_IconIndiceWeaponDagger) && (leaderHandObjIconIndex >= k0_IconIndiceJunkCompassNorth)) // < instead of <= is correct + || ((leaderHandObjIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= k163_IconIndicePotionWaterFlask)) + || (leaderHandObjIconIndex == k195_IconIndicePotionEmptyFlask)) { + IconIndice iconIndex = objMan.getIconIndex(_414_leaderHandObject); if (iconIndex != leaderHandObjIconIndex) { - _mousePointerHiddenToDrawChangedObjIconOnScreen = true; + _g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); objMan.extractIconFromBitmap(iconIndex, objMan._objectIconForMousePointer); warning("MISSING CODE: F0068_MOUSE_SetPointerToObject"); - _leaderHandObjectIconIndex = iconIndex; - objMan.drawLeaderObjectName(_leaderHandObject); + _g413_leaderHandObjectIconIndex = iconIndex; + objMan.drawLeaderObjectName(_414_leaderHandObject); } } - for (uint16 slotBoxIndex = 0; slotBoxIndex < (_partyChampionCount * 2); ++slotBoxIndex) { + for (uint16 slotBoxIndex = 0; slotBoxIndex < (_g305_partyChampionCount * 2); ++slotBoxIndex) { int16 champIndex = slotBoxIndex >> 1; if (invChampOrdinal == _vm->indexToOrdinal(champIndex)) continue; if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)handSlotIndex(slotBoxIndex))) - && (handSlotIndex(slotBoxIndex) == kChampionSlotActionHand)) { + && (handSlotIndex(slotBoxIndex) == k1_ChampionSlotActionHand)) { menuMan.drawActionIcon((ChampionIndex)champIndex); } @@ -334,13 +334,13 @@ void ChampionMan::drawChangedObjectIcons() { if (invChampOrdinal) { Champion *champ = &_champions[_vm->ordinalToIndex(invChampOrdinal)]; - Thing *thing = &champ->getSlot(kChampionSlotReadyHand); + Thing *thing = &champ->getSlot(k0_ChampionSlotReadyHand); uint16 drawViewport = 0; - for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++, thing++) { + for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++, thing++) { uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + kSlotBoxInventoryFirstSlot, *thing) ? 1 : 0; drawViewport |= objIconChanged; - if (objIconChanged && (slotIndex == kChampionSlotActionHand)) { + if (objIconChanged && (slotIndex == k1_ChampionSlotActionHand)) { menuMan.drawActionIcon((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal)); } } @@ -353,12 +353,12 @@ void ChampionMan::drawChangedObjectIcons() { } if (drawViewport) { - champ->setAttributeFlag(kChampionAttributeViewport, true); + champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true); drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal)); } } - if (_mousePointerHiddenToDrawChangedObjIconOnScreen) + if (_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } @@ -373,49 +373,49 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio Champion *champ = &_champions[champIndex]; - if (slotIndex >= kChampionSlotChest_1) { - invMan._chestSlots[slotIndex - kChampionSlotChest_1] = thing; + if (slotIndex >= k30_ChampionSlotChest_1) { + invMan._chestSlots[slotIndex - k30_ChampionSlotChest_1] = thing; } else { champ->setSlot(slotIndex, thing); } champ->_load += dunMan.getObjectWeight(thing); - champ->setAttributeFlag(kChampionAttributeLoad, true); + champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true); IconIndice iconIndex = objMan.getIconIndex(thing); bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal); applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing); uint16 *rawObjPtr = dunMan.getThingData(thing); - if (slotIndex < kChampionSlotHead) { + if (slotIndex < k2_ChampionSlotHead) { - if (slotIndex == kChampionSlotActionHand) { - champ->setAttributeFlag(kChampionAttributeActionHand, true); - if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex)) + if (slotIndex == k1_ChampionSlotActionHand) { + champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true); + if (_g506_actingChampionOrdinal == _vm->indexToOrdinal(champIndex)) menuMan.clearActingChampion(); - if ((iconIndex >= kIconIndiceScrollOpen) && (iconIndex <= kIconIndiceScrollClosed)) { + if ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)) { ((Scroll*)rawObjPtr)->setClosed(false); drawChangedObjectIcons(); } } - if (iconIndex = kIconIndiceWeaponTorchUnlit) { + if (iconIndex = k4_IconIndiceWeaponTorchUnlit) { ((Weapon*)rawObjPtr)->setLit(true); warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette"); drawChangedObjectIcons(); - } else if (isInventoryChampion && (slotIndex == kChampionSlotActionHand) && - ((iconIndex == kIconIndiceContainerChestClosed) || ((iconIndex >= kIconIndiceScrollOpen) && (iconIndex <= kIconIndiceScrollClosed)))) { - champ->setAttributeFlag(kChampionAttributePanel, true); + } else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) && + ((iconIndex == k144_IconIndiceContainerChestClosed) || ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)))) { + champ->setAttributeFlag(k0x0800_ChampionAttributePanel, true); } - } else if (slotIndex == kChampionSlotNeck) { + } else if (slotIndex == k10_ChampionSlotNeck) { - if ((iconIndex >= kIconIndiceJunkIllumuletUnequipped) && (iconIndex <= kIconIndiceJunkIllumuletEquipped)) { + if ((iconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (iconIndex <= k13_IconIndiceJunkIllumuletEquipped)) { ((Junk*)rawObjPtr)->setChargeCount(1); - _party._magicalLightAmount += gLightPowerToLightAmount[2]; + _g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2]; warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette"); iconIndex = (IconIndice) (iconIndex + 1); - } else if ((iconIndex >= kIconIndiceJunkJewelSymalUnequipped) && (iconIndex <= kIconIndiceJunkJewelSymalEquipped)) { + } else if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) { ((Junk*)rawObjPtr)->setChargeCount(1); iconIndex = (IconIndice) (iconIndex + 1); } @@ -424,16 +424,16 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio drawSlot(champIndex, slotIndex); if (isInventoryChampion) - champ->setAttributeFlag(kChampionAttributeViewport, true); + champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true); } ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { - for (uint16 i = 0; i < _partyChampionCount; ++i) { + for (uint16 i = 0; i < _g305_partyChampionCount; ++i) { if ((_champions[i]._cell == cell) && _champions[i]._currHealth) return (ChampionIndex)i; } - return kChampionNone; + return kM1_ChampionNone; } void ChampionMan::resetDataToStartGame() { @@ -442,9 +442,9 @@ void ChampionMan::resetDataToStartGame() { assert(false); } - _leaderHandObject = Thing::_none; - _leaderHandObjectIconIndex = kIconIndiceNone; - _leaderEmptyHanded = true; + _414_leaderHandObject = Thing::_none; + _g413_leaderHandObjectIconIndex = kM1_IconIndiceNone; + _g415_leaderEmptyHanded = true; } @@ -452,10 +452,10 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { DisplayMan &dispMan = *_vm->_displayMan; DungeonMan &dunMan = *_vm->_dungeonMan; - if (!_leaderEmptyHanded || _partyChampionCount == 4) + if (!_g415_leaderEmptyHanded || _g305_partyChampionCount == 4) return; - uint16 prevChampCount = _partyChampionCount; + uint16 prevChampCount = _g305_partyChampionCount; Champion *champ = &_champions[prevChampCount]; champ->resetToZero(); dispMan._g578_useByteBoxCoordinates = true; @@ -465,20 +465,20 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, k255_ColorNoTransparency); } - champ->_actionIndex = kChampionActionNone; + champ->_actionIndex = k255_ChampionActionNone; champ->_enableActionEventIndex = -1; champ->_hideDamageReceivedIndex = -1; champ->_dir = dunMan._currMap._partyDir; ViewCell AL_0_viewCell = k0_ViewCellFronLeft; - while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kChampionNone) + while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kM1_ChampionNone) AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3); - champ->clearAttributes(kChampionAttributeIcon); + champ->clearAttributes(k0x0400_ChampionAttributeIcon); champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir; champ->_food = 1500 + _vm->_rnd->getRandomNumber(256); champ->_water = 1500 + _vm->_rnd->getRandomNumber(256); int16 AL_0_slotIndex_Red; - for (AL_0_slotIndex_Red = kChampionSlotReadyHand; AL_0_slotIndex_Red < kChampionSlotChest_1; ++AL_0_slotIndex_Red) { + for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) { champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none); } Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY); @@ -508,7 +508,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { } champ->_title[AL_0_characterIndex] = '\0'; if (*character_Green++ == 'M') { - champ->setAttributeFlag(kChampionAttributeMale, true); + champ->setAttributeFlag(k0x0010_ChampionAttributeMale, true); } character_Green++; champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4); @@ -520,26 +520,26 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { character_Green++; int16 AL_0_statisticIndex; - for (AL_0_statisticIndex = kChampionStatLuck; AL_0_statisticIndex <= kChampionStatAntifire; ++AL_0_statisticIndex) { - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMinimum, 30); + for (AL_0_statisticIndex = k0_ChampionStatLuck; AL_0_statisticIndex <= k6_ChampionStatAntifire; ++AL_0_statisticIndex) { + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k2_ChampionStatMinimum, 30); uint16 currMaxVal = getDecodedValue(character_Green, 2); - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent, currMaxVal); - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum, currMaxVal); + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent, currMaxVal); + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum, currMaxVal); character_Green += 2; } - champ->setStatistic(kChampionStatLuck, kChampionStatMinimum, 10); + champ->setStatistic(k0_ChampionStatLuck, k2_ChampionStatMinimum, 10); character_Green++; int16 AL_0_skillIndex; int16 AL_2_skillValue; - for (AL_0_skillIndex = kChampionSkillSwing; AL_0_skillIndex <= kChampionSkillWater; AL_0_skillIndex++) { + for (AL_0_skillIndex = k4_ChampionSkillSwing; AL_0_skillIndex <= k19_ChampionSkillWater; AL_0_skillIndex++) { if ((AL_2_skillValue = *character_Green++ - 'A') > 0) { champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue); } } - for (AL_0_skillIndex = kChampionSkillFighter; AL_0_skillIndex <= kChampionSkillWizard; ++AL_0_skillIndex) { + for (AL_0_skillIndex = k0_ChampionSkillFighter; AL_0_skillIndex <= k3_ChampionSkillWizard; ++AL_0_skillIndex) { int32 baseSkillExp = 0; int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2; for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) { @@ -548,13 +548,13 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp); } - _candidateChampionOrdinal = prevChampCount + 1; - if (++_partyChampionCount == 1) { - _vm->_eventMan->commandSetLeader(kChampionFirst); + _g299_candidateChampionOrdinal = prevChampCount + 1; + if (++_g305_partyChampionCount == 1) { + _vm->_eventMan->commandSetLeader(k0_ChampionFirst); _vm->_menuMan->_refreshActionArea = true; } else { _vm->_menuMan->clearActingChampion(); - _vm->_menuMan->drawActionIcon((ChampionIndex)(_partyChampionCount - 1)); + _vm->_menuMan->drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1)); } int16 mapX = _vm->_dungeonMan->_currMap._partyPosX; @@ -564,7 +564,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { mapX += _vm->_dirIntoStepCountEast[dunMan._currMap._partyDir]; mapY += _vm->_dirIntoStepCountNorth[dunMan._currMap._partyDir]; thing = dunMan.getSquareFirstThing(mapX, mapY); - AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1; + AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1; uint16 slotIndex_Green; while (thing != Thing::_endOfList) { ThingType AL_2_thingType = thing.getType(); @@ -572,29 +572,29 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots(); switch (AL_2_thingType) { case kArmourThingType: - for (slotIndex_Green = kChampionSlotHead; slotIndex_Green <= kChampionSlotFeet; slotIndex_Green++) { + for (slotIndex_Green = k2_ChampionSlotHead; slotIndex_Green <= k5_ChampionSlotFeet; slotIndex_Green++) { if (objectAllowedSlots & gSlotMasks[slotIndex_Green]) goto T0280048; } - if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_none)) { - slotIndex_Green = kChampionSlotNeck; + if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) { + slotIndex_Green = k10_ChampionSlotNeck; } else { goto T0280046; } break; case kWeaponThingType: - if (champ->getSlot(kChampionSlotActionHand) == Thing::_none) { - slotIndex_Green = kChampionSlotActionHand; + if (champ->getSlot(k1_ChampionSlotActionHand) == Thing::_none) { + slotIndex_Green = k1_ChampionSlotActionHand; } else { goto T0280046; } break; case kScrollThingType: case kPotionThingType: - if (champ->getSlot(kChampionSlotPouch_1) == Thing::_none) { - slotIndex_Green = kChampionSlotPouch_1; - } else if (champ->getSlot(kChampionSlotPouch_2) == Thing::_none) { - slotIndex_Green = kChampionSlotPouch_2; + if (champ->getSlot(k11_ChampionSlotPouch_1) == Thing::_none) { + slotIndex_Green = k11_ChampionSlotPouch_1; + } else if (champ->getSlot(k6_ChampionSlotPouch_2) == Thing::_none) { + slotIndex_Green = k6_ChampionSlotPouch_2; } else { goto T0280046; } @@ -602,8 +602,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { case kContainerThingType: case kJunkThingType: T0280046: - if ((objectAllowedSlots & gSlotMasks[kChampionSlotNeck]) && (champ->getSlot(kChampionSlotNeck) == Thing::_none)) { - slotIndex_Green = kChampionSlotNeck; + if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) { + slotIndex_Green = k10_ChampionSlotNeck; } else { slotIndex_Green = AL_0_slotIndex_Red++; } @@ -676,12 +676,12 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { if (barGraphHeight < 25) { box._y1 = 2; box._y1 = 27 - barGraphHeight + 1; - _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); + _vm->_displayMan->clearScreenBox(g46_ChampionColor[champIndex], box); } if (barGraphHeight) { box._y1 = 27 - barGraphHeight; box._y2 = 26 + 1; - _vm->_displayMan->clearScreenBox(gChampionColor[champIndex], box); + _vm->_displayMan->clearScreenBox(g46_ChampionColor[champIndex], box); } box._x1 += 7; box._x2 += 7; @@ -702,13 +702,13 @@ uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) { } uint16 ChampionMan::getMaximumLoad(Champion *champ) { - uint16 maximumLoad = champ->getStatistic(kChampionStatStrength, kChampionStatCurrent) * 8 + 100; + uint16 maximumLoad = champ->getStatistic(k1_ChampionStatStrength, k1_ChampionStatCurrent) * 8 + 100; maximumLoad = getStaminaAdjustedValue(champ, maximumLoad); int16 wounds = champ->getWounds(); if (wounds) { - maximumLoad -= maximumLoad >> (champ->getWoundsFlag(kChampionWoundLegs) ? 2 : 3); + maximumLoad -= maximumLoad >> (champ->getWoundsFlag(k0x0010_ChampionWoundLegs) ? 2 : 3); } - if (_vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotFeet)) == kIconIndiceArmourElvenBoots) { + if (_vm->_objectMan->getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots) { maximumLoad += maximumLoad * 16; } maximumLoad += 9; @@ -726,14 +726,14 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { int16 champStatusBoxX = champIndex * kChampionStatusBoxSpacing; Champion *champ = &_champions[champIndex]; uint16 champAttributes = champ->getAttributes(); - if (!((champAttributes) & (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon | - kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport | - kChampionAttributeActionHand))) { + if (!((champAttributes) & (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | + k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | + k0x8000_ChampionAttributeActionHand))) { return; } bool isInventoryChamp = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal); dispMan._g578_useByteBoxCoordinates = false; - if (champAttributes & kChampionAttributeStatusBox) { + if (champAttributes & k0x1000_ChampionAttributeStatusBox) { box._y1 = 0; box._y2 = 28 + 1; box._x1 = champStatusBoxX; @@ -744,20 +744,20 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { for (int16 i = 0; i < 3; ++i) nativeBitmapIndices[i] = 0; int16 AL_0_borderCount = 0; - if (_party._fireShieldDefense > 0) + if (_g407_party._fireShieldDefense > 0) nativeBitmapIndices[AL_0_borderCount++] = k38_BorderPartyFireshieldIndice; - if (_party._spellShieldDefense > 0) + if (_g407_party._spellShieldDefense > 0) nativeBitmapIndices[AL_0_borderCount++] = k39_BorderPartySpellshieldIndice; - if (_party._shieldDefense > 0) + if (_g407_party._shieldDefense > 0) nativeBitmapIndices[AL_0_borderCount++] = k37_BorderPartyShieldIndice; while (AL_0_borderCount--) { dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, k10_ColorFlesh); } if (isInventoryChamp) { invMan.drawStatusBoxPortrait(champIndex); - champAttributes |= kChampionAttributeStatistics; + champAttributes |= k0x0100_ChampionAttributeStatistics; } else { - champAttributes |= (kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeWounds | kChampionAttributeActionHand); + champAttributes |= (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand); } } else { dispMan.blitToScreen(dispMan.getBitmap(k8_StatusBoxDeadChampion), 80, 0, 0, box, k255_ColorNoTransparency); @@ -770,8 +770,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { if (!champ->_currHealth) goto T0292042_green; - if (champAttributes & kChampionAttributeNameTitle) { - Color AL_0_colorIndex = (champIndex == _leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; // unused because of missing functions + if (champAttributes & k0x0080_ChampionAttributeNameTitle) { + Color AL_0_colorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; // unused because of missing functions if (isInventoryChamp) { char *champName = champ->_name; _vm->_textMan->printToViewport(3, 7, AL_0_colorIndex, champName); @@ -781,7 +781,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { champTitleX += 6; } _vm->_textMan->printToViewport(champTitleX, 7, AL_0_colorIndex, champ->_title); - champAttributes |= kChampionAttributeViewport; + champAttributes |= k0x4000_ChampionAttributeViewport; } else { box._y1 = 0; box._y2 = 6 + 1; @@ -792,7 +792,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { } } - if (champAttributes & kChampionAttributeStatistics) { + if (champAttributes & k0x0100_ChampionAttributeStatistics) { drawChampionBarGraphs(champIndex); if (isInventoryChamp) { drawHealthStaminaManaValues(champ); @@ -804,28 +804,28 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { } dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, k12_ColorDarkestGray, g296_DungeonViewport); AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; - for (int16 AL_0_statisticIndex = kChampionStatStrength; AL_0_statisticIndex <= kChampionStatAntifire; AL_0_statisticIndex++) { - if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatCurrent) - < champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, kChampionStatMaximum)) { + for (int16 AL_0_statisticIndex = k1_ChampionStatStrength; AL_0_statisticIndex <= k6_ChampionStatAntifire; AL_0_statisticIndex++) { + if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent) + < champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum)) { AL_2_nativeBitmapIndex = k34_SlotBoxWoundedIndice; break; } } dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, k12_ColorDarkestGray, g296_DungeonViewport); - champAttributes |= kChampionAttributeViewport; + champAttributes |= k0x4000_ChampionAttributeViewport; } } - if (champAttributes & kChampionAttributeWounds) { - for (int16 AL_0_slotIndex = isInventoryChamp ? kChampionSlotFeet : kChampionSlotActionHand; AL_0_slotIndex >= kChampionSlotReadyHand; AL_0_slotIndex--) { + if (champAttributes & k0x2000_ChampionAttributeWounds) { + for (int16 AL_0_slotIndex = isInventoryChamp ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL_0_slotIndex >= k0_ChampionSlotReadyHand; AL_0_slotIndex--) { drawSlot(champIndex, (ChampionSlot)AL_0_slotIndex); } if (isInventoryChamp) { - champAttributes |= kChampionAttributeViewport; + champAttributes |= k0x4000_ChampionAttributeViewport; } } - if ((champAttributes & kChampionAttributeLoad) && isInventoryChamp) { + if ((champAttributes & k0x0200_ChampionAttributeLoad) && isInventoryChamp) { Color loadColor; int16 champMaxLoad = getMaximumLoad(champ); if (champ->_load > champMaxLoad) { @@ -846,49 +846,49 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { loadTmp = (getMaximumLoad(champ) + 5) / 10; str += "KG"; _vm->_textMan->printToViewport(148, 132, loadColor, str.c_str()); - champAttributes |= kChampionAttributeViewport; + champAttributes |= k0x4000_ChampionAttributeViewport; } { // block so goto won't skip AL_0_championIconIndex initialization int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir); if ((champAttributes & k28_ChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) { - dispMan.clearScreenBox(gChampionColor[champIndex], gBoxChampionIcons[AL_0_championIconIndex]); + dispMan.clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]); dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0, - gBoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray); + g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray); } } - if ((champAttributes & kChampionAttributePanel) && isInventoryChamp) { + if ((champAttributes & k0x0800_ChampionAttributePanel) && isInventoryChamp) { if (_vm->_pressingMouth) { invMan.drawPanelFoodWaterPoisoned(); } else if (_vm->_pressingEye) { - if (_leaderEmptyHanded) { + if (_g415_leaderEmptyHanded) { warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics"); } } else { invMan.drawPanel(); } - champAttributes |= kChampionAttributeViewport; + champAttributes |= k0x4000_ChampionAttributeViewport; } - if (champAttributes & kChampionAttributeActionHand) { - drawSlot(champIndex, kChampionSlotActionHand); + if (champAttributes & k0x8000_ChampionAttributeActionHand) { + drawSlot(champIndex, k1_ChampionSlotActionHand); menuMan.drawActionIcon(champIndex); if (isInventoryChamp) { - champAttributes |= kChampionAttributeViewport; + champAttributes |= k0x4000_ChampionAttributeViewport; } } - if (champAttributes & kChampionAttributeViewport) { + if (champAttributes & k0x4000_ChampionAttributeViewport) { warning("MISSGIN CODE: F0097_DUNGEONVIEW_DrawViewport"); } T0292042_green: - champ->setAttributeFlag((ChampionAttribute)(kChampionAttributeNameTitle | kChampionAttributeStatistics | kChampionAttributeLoad | kChampionAttributeIcon | - kChampionAttributePanel | kChampionAttributeStatusBox | kChampionAttributeWounds | kChampionAttributeViewport | - kChampionAttributeActionHand), false); + champ->setAttributeFlag((ChampionAttribute)(k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | + k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | + k0x8000_ChampionAttributeActionHand), false); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } @@ -909,7 +909,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { uint16 slotBoxIndex; if (!isInventoryChamp) { /* If drawing a slot for a champion other than the champion whose inventory is open */ - if ((slotIndex > kChampionSlotActionHand) || (_candidateChampionOrdinal == _vm->indexToOrdinal(champIndex))) { + if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->indexToOrdinal(champIndex))) { return; } slotBoxIndex = (champIndex << 1) + slotIndex; @@ -918,8 +918,8 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { } Thing thing; - if (slotIndex >= kChampionSlotChest_1) { - thing = _vm->_inventoryMan->_chestSlots[slotIndex - kChampionSlotChest_1]; + if (slotIndex >= k30_ChampionSlotChest_1) { + thing = _vm->_inventoryMan->_chestSlots[slotIndex - k30_ChampionSlotChest_1]; } else { thing = champ->getSlot(slotIndex); } @@ -938,8 +938,8 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { int16 iconIndex; if (thing == Thing::_none) { - if (slotIndex <= kChampionSlotFeet) { - iconIndex = kIconIndiceReadyHand + (slotIndex << 1); + if (slotIndex <= k5_ChampionSlotFeet) { + iconIndex = k212_IconIndiceReadyHand + (slotIndex << 1); if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) { iconIndex++; nativeBitmapIndex = k34_SlotBoxWoundedIndice; @@ -947,20 +947,20 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { nativeBitmapIndex = k33_SlotBoxNormalIndice; } } else { - if ((slotIndex >= kChampionSlotNeck) && (slotIndex <= kChampionSlotBackpackLine_1_1)) { - iconIndex = kIconIndiceNeck + (slotIndex - kChampionSlotNeck); + if ((slotIndex >= k10_ChampionSlotNeck) && (slotIndex <= k13_ChampionSlotBackpackLine_1_1)) { + iconIndex = k208_IconIndiceNeck + (slotIndex - k10_ChampionSlotNeck); } else { - iconIndex = kIconIndiceEmptyBox; + iconIndex = k204_IconIndiceEmptyBox; } } } else { warning("BUG0_35"); iconIndex = _vm->_objectMan->getIconIndex(thing); // BUG0_35 - if (isInventoryChamp && (slotIndex == kChampionSlotActionHand) && ((iconIndex == kIconIndiceContainerChestClosed) || (iconIndex == kIconIndiceScrollOpen))) { + if (isInventoryChamp && (slotIndex == k1_ChampionSlotActionHand) && ((iconIndex == k144_IconIndiceContainerChestClosed) || (iconIndex == k30_IconIndiceScrollOpen))) { warning("BUG2_00"); iconIndex++; } // BUG2_00 - if (slotIndex <= kChampionSlotFeet) { + if (slotIndex <= k5_ChampionSlotFeet) { if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) { nativeBitmapIndex = k34_SlotBoxWoundedIndice; } else { @@ -969,7 +969,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { } } - if ((slotIndex == kChampionSlotActionHand) && (_vm->indexToOrdinal(champIndex) == _actingChampionOrdinal)) { + if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->indexToOrdinal(champIndex) == _g506_actingChampionOrdinal)) { nativeBitmapIndex = k35_SlotBoxActingHandIndice; } @@ -1014,11 +1014,11 @@ void ChampionMan::renameChampion(Champion* champ) { } uint16 ChampionMan::getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex) { - if (_partyIsSleeping) + if (_g300_partyIsSleeping) return 1; - bool ignoreTempExp = skillIndex & kIgnoreTemporaryExperience; - bool ignoreObjModifiers = skillIndex & kIgnoreObjectModifiers; + bool ignoreTempExp = skillIndex & k0x8000_IgnoreTemporaryExperience; + bool ignoreObjModifiers = skillIndex & k0x4000_IgnoreObjectModifiers; skillIndex = (ChampionSkill)(skillIndex & ~(ignoreTempExp | ignoreObjModifiers)); Champion *champ = &_champions[champIndex]; Skill *skill = &champ->getSkill(skillIndex); @@ -1027,8 +1027,8 @@ uint16 ChampionMan::getSkillLevel(ChampionIndex champIndex, ChampionSkill skillI if (!ignoreTempExp) experience += skill->_temporaryExperience; - if (skillIndex > kChampionSkillWizard) { // hidden skill - skill = &champ->getSkill((ChampionSkill)((skillIndex - kChampionSkillSwing) / 4)); + if (skillIndex > k3_ChampionSkillWizard) { // hidden skill + skill = &champ->getSkill((ChampionSkill)((skillIndex - k4_ChampionSkillSwing) / 4)); experience += skill->_experience; // add exp to the base skill if (!ignoreTempExp) experience += skill->_temporaryExperience; @@ -1043,30 +1043,30 @@ uint16 ChampionMan::getSkillLevel(ChampionIndex champIndex, ChampionSkill skillI } if (!ignoreObjModifiers) { - IconIndice actionHandIconIndex = _vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotActionHand)); - if (actionHandIconIndex == kIconIndiceWeaponTheFirestaff) { + IconIndice actionHandIconIndex = _vm->_objectMan->getIconIndex(champ->getSlot(k1_ChampionSlotActionHand)); + if (actionHandIconIndex == k27_IconIndiceWeaponTheFirestaff) { skillLevel++; - } else if (actionHandIconIndex == kIconIndiceWeaponTheFirestaffComplete) { + } else if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete) { skillLevel += 2; } - IconIndice neckIconIndice = _vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotNeck)); + IconIndice neckIconIndice = _vm->_objectMan->getIconIndex(champ->getSlot(k10_ChampionSlotNeck)); switch (skillIndex) { - case kChampionSkillWizard: - if (neckIconIndice == kIconIndiceJunkPendantFeral) + case k3_ChampionSkillWizard: + if (neckIconIndice == k124_IconIndiceJunkPendantFeral) skillLevel++; break; - case kChampionSkillDefend: - if (neckIconIndice == kIconIndiceJunkEkkhardCross) + case k15_ChampionSkillDefend: + if (neckIconIndice == k121_IconIndiceJunkEkkhardCross) skillLevel++; break; - case kChampionSkillHeal: + case k13_ChampionSkillHeal: // these two are not cummulative - if ((neckIconIndice == kIconIndiceJunkGemOfAges) || (neckIconIndice == kIconIndiceWeaponSceptreOfLyf)) + if ((neckIconIndice == k120_IconIndiceJunkGemOfAges) || (neckIconIndice == k66_IconIndiceWeaponSceptreOfLyf)) skillLevel++; break; - case kChampionSkillInfluence: - if (neckIconIndice == kIconIndiceJunkMoonstone) + case k14_ChampionSkillInfluence: + if (neckIconIndice == k122_IconIndiceJunkMoonstone) skillLevel++; break; } diff --git a/engines/dm/champion.h b/engines/dm/champion.h index c1abca1888..cd6694669b 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -35,13 +35,13 @@ namespace DM { -#define kIgnoreObjectModifiers 0x4000 // @ MASK0x4000_IGNORE_OBJECT_MODIFIERS -#define kIgnoreTemporaryExperience 0x8000 // @ MASK0x8000_IGNORE_TEMPORARY_EXPERIENCE +#define k0x4000_IgnoreObjectModifiers 0x4000 // @ MASK0x4000_IGNORE_OBJECT_MODIFIERS +#define k0x8000_IgnoreTemporaryExperience 0x8000 // @ MASK0x8000_IGNORE_TEMPORARY_EXPERIENCE -extern Box gBoxChampionIcons[4]; // @ G0054_ai_Graphic562_Box_ChampionIcons -extern Color gChampionColor[4]; // @ G0046_auc_Graphic562_ChampionColor +extern Box g54_BoxChampionIcons[4]; // @ G0054_ai_Graphic562_Box_ChampionIcons +extern Color g46_ChampionColor[4]; // @ G0046_auc_Graphic562_ChampionColor -extern int16 gLightPowerToLightAmount[16]; // @ G0039_ai_Graphic562_LightPowerToLightAmount +extern int16 g39_LightPowerToLightAmount[16]; // @ G0039_ai_Graphic562_LightPowerToLightAmount class Scent { uint16 _scent; @@ -84,246 +84,246 @@ public: }; // @ PARTY enum IconIndice { - kIconIndiceNone = -1, // @ CM1_ICON_NONE - kIconIndiceJunkCompassNorth = 0, // @ C000_ICON_JUNK_COMPASS_NORTH - kIconIndiceJunkCompassWest = 3, // @ C003_ICON_JUNK_COMPASS_WEST - kIconIndiceWeaponTorchUnlit = 4, // @ C004_ICON_WEAPON_TORCH_UNLIT - kIconIndiceWeaponTorchLit = 7, // @ C007_ICON_WEAPON_TORCH_LIT - kIconIndiceJunkWater = 8, // @ C008_ICON_JUNK_WATER - kIconIndiceJunkWaterSkin = 9, // @ C009_ICON_JUNK_WATERSKIN - kIconIndiceJunkJewelSymalUnequipped = 10, // @ C010_ICON_JUNK_JEWEL_SYMAL_UNEQUIPPED - kIconIndiceJunkJewelSymalEquipped = 11, // @ C011_ICON_JUNK_JEWEL_SYMAL_EQUIPPED - kIconIndiceJunkIllumuletUnequipped = 12, // @ C012_ICON_JUNK_ILLUMULET_UNEQUIPPED - kIconIndiceJunkIllumuletEquipped = 13, // @ C013_ICON_JUNK_ILLUMULET_EQUIPPED - kIconIndiceWeaponFlamittEmpty = 14, // @ C014_ICON_WEAPON_FLAMITT_EMPTY - kIconIndiceWeaponEyeOfTimeEmpty = 16, // @ C016_ICON_WEAPON_EYE_OF_TIME_EMPTY - kIconIndiceWeaponStormringEmpty = 18, // @ C018_ICON_WEAPON_STORMRING_EMPTY - kIconIndiceWeaponStaffOfClawsEmpty = 20, // @ C020_ICON_WEAPON_STAFF_OF_CLAWS_EMPTY - kIconIndiceWeaponStaffOfClawsFull = 22, // @ C022_ICON_WEAPON_STAFF_OF_CLAWS_FULL - kIconIndiceWeaponBoltBladeStormEmpty = 23, // @ C023_ICON_WEAPON_BOLT_BLADE_STORM_EMPTY - kIconIndiceWeaponFuryRaBladeEmpty = 25, // @ C025_ICON_WEAPON_FURY_RA_BLADE_EMPTY - kIconIndiceWeaponTheFirestaff = 27, // @ C027_ICON_WEAPON_THE_FIRESTAFF - kIconIndiceWeaponTheFirestaffComplete = 28, // @ C028_ICON_WEAPON_THE_FIRESTAFF_COMPLETE - kIconIndiceScrollOpen = 30, // @ C030_ICON_SCROLL_SCROLL_OPEN - kIconIndiceScrollClosed = 31, // @ C031_ICON_SCROLL_SCROLL_CLOSED - kIconIndiceWeaponDagger = 32, // @ C032_ICON_WEAPON_DAGGER - kIconIndiceWeaponDeltaSideSplitter = 38, // @ C038_ICON_WEAPON_DELTA_SIDE_SPLITTER - kIconIndiceWeaponDiamondEdge = 39, // @ C039_ICON_WEAPON_DIAMOND_EDGE - kIconIndiceWeaponVorpalBlade = 40, // @ C040_ICON_WEAPON_VORPAL_BLADE - kIconIndiceWeaponTheInquisitorDragonFang = 41, // @ C041_ICON_WEAPON_THE_INQUISITOR_DRAGON_FANG - kIconIndiceWeaponHardcleaveExecutioner = 43, // @ C043_ICON_WEAPON_HARDCLEAVE_EXECUTIONER - kIconIndiceWeaponMaceOfOrder = 45, // @ C045_ICON_WEAPON_MACE_OF_ORDER - kIconIndiceWeaponArrow = 51, // @ C051_ICON_WEAPON_ARROW - kIconIndiceWeaponSlayer = 52, // @ C052_ICON_WEAPON_SLAYER - kIconIndiceWeaponRock = 54, // @ C054_ICON_WEAPON_ROCK - kIconIndiceWeaponPoisonDart = 55, // @ C055_ICON_WEAPON_POISON_DART - kIconIndiceWeaponThrowingStar = 56, // @ C056_ICON_WEAPON_THROWING_STAR - kIconIndiceWeaponStaff = 58, // @ C058_ICON_WEAPON_STAFF - kIconIndiceWeaponWand = 59, // @ C059_ICON_WEAPON_WAND - kIconIndiceWeaponTeowand = 60, // @ C060_ICON_WEAPON_TEOWAND - kIconIndiceWeaponYewStaff = 61, // @ C061_ICON_WEAPON_YEW_STAFF - kIconIndiceWeaponStaffOfManarStaffOfIrra = 62, // @ C062_ICON_WEAPON_STAFF_OF_MANAR_STAFF_OF_IRRA - kIconIndiceWeaponSnakeStaffCrossOfNeta = 63, // @ C063_ICON_WEAPON_SNAKE_STAFF_CROSS_OF_NETA - kIconIndiceWeaponTheConduitSerpentStaff = 64, // @ C064_ICON_WEAPON_THE_CONDUIT_SERPENT_STAFF - kIconIndiceWeaponDragonSpit = 65, // @ C065_ICON_WEAPON_DRAGON_SPIT - kIconIndiceWeaponSceptreOfLyf = 66, // @ C066_ICON_WEAPON_SCEPTRE_OF_LYF - kIconIndiceArmourCloakOfNight = 81, // @ C081_ICON_ARMOUR_CLOAK_OF_NIGHT - kIconIndiceArmourCrownOfNerra = 104, // @ C104_ICON_ARMOUR_CROWN_OF_NERRA - kIconIndiceArmourElvenBoots = 119, // @ C119_ICON_ARMOUR_ELVEN_BOOTS - kIconIndiceJunkGemOfAges = 120, // @ C120_ICON_JUNK_GEM_OF_AGES - kIconIndiceJunkEkkhardCross = 121, // @ C121_ICON_JUNK_EKKHARD_CROSS - kIconIndiceJunkMoonstone = 122, // @ C122_ICON_JUNK_MOONSTONE - kIconIndiceJunkPendantFeral = 124, // @ C124_ICON_JUNK_PENDANT_FERAL - kIconIndiceJunkBoulder = 128, // @ C128_ICON_JUNK_BOULDER - kIconIndiceJunkRabbitsFoot = 137, // @ C137_ICON_JUNK_RABBITS_FOOT - kIconIndiceArmourDexhelm = 140, // @ C140_ICON_ARMOUR_DEXHELM - kIconIndiceArmourFlamebain = 141, // @ C141_ICON_ARMOUR_FLAMEBAIN - kIconIndiceArmourPowertowers = 142, // @ C142_ICON_ARMOUR_POWERTOWERS - kIconIndiceContainerChestClosed = 144, // @ C144_ICON_CONTAINER_CHEST_CLOSED - kIconIndiceContainerChestOpen = 145, // @ C145_ICON_CONTAINER_CHEST_OPEN - kIconIndiceJunkChampionBones = 147, // @ C147_ICON_JUNK_CHAMPION_BONES - kIconIndicePotionMaPotionMonPotion = 148, // @ C148_ICON_POTION_MA_POTION_MON_POTION - kIconIndicePotionWaterFlask = 163, // @ C163_ICON_POTION_WATER_FLASK - kIconIndiceJunkApple = 168, // @ C168_ICON_JUNK_APPLE - kIconIndiceJunkIronKey = 176, // @ C176_ICON_JUNK_IRON_KEY - kIconIndiceJunkMasterKey = 191, // @ C191_ICON_JUNK_MASTER_KEY - kIconIndiceArmourBootOfSpeed = 194, // @ C194_ICON_ARMOUR_BOOT_OF_SPEED - kIconIndicePotionEmptyFlask = 195, // @ C195_ICON_POTION_EMPTY_FLASK - kIconIndiceJunkZokathra = 197, // @ C197_ICON_JUNK_ZOKATHRA - kIconIndiceActionEmptyHand = 201, // @ C201_ICON_ACTION_ICON_EMPTY_HAND - kIconIndiceEyeNotLooking = 202, // @ C202_ICON_EYE_NOT_LOOKING /* One pixel is different in this bitmap from the eye in C017_GRAPHIC_INVENTORY. This is visible by selecting another champion after clicking the eye */ - kIconIndiceEyeLooking = 203, // @ C203_ICON_EYE_LOOKING - kIconIndiceEmptyBox = 204, // @ C204_ICON_EMPTY_BOX - kIconIndiceMouthOpen = 205, // @ C205_ICON_MOUTH_OPEN - kIconIndiceNeck = 208, // @ C208_ICON_NECK - kIconIndiceReadyHand = 212 // @ C212_ICON_READY_HAND + kM1_IconIndiceNone = -1, // @ CM1_ICON_NONE + k0_IconIndiceJunkCompassNorth = 0, // @ C000_ICON_JUNK_COMPASS_NORTH + k3_IconIndiceJunkCompassWest = 3, // @ C003_ICON_JUNK_COMPASS_WEST + k4_IconIndiceWeaponTorchUnlit = 4, // @ C004_ICON_WEAPON_TORCH_UNLIT + k7_IconIndiceWeaponTorchLit = 7, // @ C007_ICON_WEAPON_TORCH_LIT + k8_IconIndiceJunkWater = 8, // @ C008_ICON_JUNK_WATER + k9_IconIndiceJunkWaterSkin = 9, // @ C009_ICON_JUNK_WATERSKIN + k10_IconIndiceJunkJewelSymalUnequipped = 10, // @ C010_ICON_JUNK_JEWEL_SYMAL_UNEQUIPPED + k11_IconIndiceJunkJewelSymalEquipped = 11, // @ C011_ICON_JUNK_JEWEL_SYMAL_EQUIPPED + k12_IconIndiceJunkIllumuletUnequipped = 12, // @ C012_ICON_JUNK_ILLUMULET_UNEQUIPPED + k13_IconIndiceJunkIllumuletEquipped = 13, // @ C013_ICON_JUNK_ILLUMULET_EQUIPPED + k14_IconIndiceWeaponFlamittEmpty = 14, // @ C014_ICON_WEAPON_FLAMITT_EMPTY + k16_IconIndiceWeaponEyeOfTimeEmpty = 16, // @ C016_ICON_WEAPON_EYE_OF_TIME_EMPTY + k18_IconIndiceWeaponStormringEmpty = 18, // @ C018_ICON_WEAPON_STORMRING_EMPTY + k20_IconIndiceWeaponStaffOfClawsEmpty = 20, // @ C020_ICON_WEAPON_STAFF_OF_CLAWS_EMPTY + k22_IconIndiceWeaponStaffOfClawsFull = 22, // @ C022_ICON_WEAPON_STAFF_OF_CLAWS_FULL + k23_IconIndiceWeaponBoltBladeStormEmpty = 23, // @ C023_ICON_WEAPON_BOLT_BLADE_STORM_EMPTY + k25_IconIndiceWeaponFuryRaBladeEmpty = 25, // @ C025_ICON_WEAPON_FURY_RA_BLADE_EMPTY + k27_IconIndiceWeaponTheFirestaff = 27, // @ C027_ICON_WEAPON_THE_FIRESTAFF + k28_IconIndiceWeaponTheFirestaffComplete = 28, // @ C028_ICON_WEAPON_THE_FIRESTAFF_COMPLETE + k30_IconIndiceScrollOpen = 30, // @ C030_ICON_SCROLL_SCROLL_OPEN + k31_IconIndiceScrollClosed = 31, // @ C031_ICON_SCROLL_SCROLL_CLOSED + k32_IconIndiceWeaponDagger = 32, // @ C032_ICON_WEAPON_DAGGER + k38_IconIndiceWeaponDeltaSideSplitter = 38, // @ C038_ICON_WEAPON_DELTA_SIDE_SPLITTER + k39_IconIndiceWeaponDiamondEdge = 39, // @ C039_ICON_WEAPON_DIAMOND_EDGE + k40_IconIndiceWeaponVorpalBlade = 40, // @ C040_ICON_WEAPON_VORPAL_BLADE + k41_IconIndiceWeaponTheInquisitorDragonFang = 41, // @ C041_ICON_WEAPON_THE_INQUISITOR_DRAGON_FANG + k43_IconIndiceWeaponHardcleaveExecutioner = 43, // @ C043_ICON_WEAPON_HARDCLEAVE_EXECUTIONER + k45_IconIndiceWeaponMaceOfOrder = 45, // @ C045_ICON_WEAPON_MACE_OF_ORDER + k51_IconIndiceWeaponArrow = 51, // @ C051_ICON_WEAPON_ARROW + k52_IconIndiceWeaponSlayer = 52, // @ C052_ICON_WEAPON_SLAYER + k54_IconIndiceWeaponRock = 54, // @ C054_ICON_WEAPON_ROCK + k55_IconIndiceWeaponPoisonDart = 55, // @ C055_ICON_WEAPON_POISON_DART + k56_IconIndiceWeaponThrowingStar = 56, // @ C056_ICON_WEAPON_THROWING_STAR + k58_IconIndiceWeaponStaff = 58, // @ C058_ICON_WEAPON_STAFF + k59_IconIndiceWeaponWand = 59, // @ C059_ICON_WEAPON_WAND + k60_IconIndiceWeaponTeowand = 60, // @ C060_ICON_WEAPON_TEOWAND + k61_IconIndiceWeaponYewStaff = 61, // @ C061_ICON_WEAPON_YEW_STAFF + k62_IconIndiceWeaponStaffOfManarStaffOfIrra = 62, // @ C062_ICON_WEAPON_STAFF_OF_MANAR_STAFF_OF_IRRA + k63_IconIndiceWeaponSnakeStaffCrossOfNeta = 63, // @ C063_ICON_WEAPON_SNAKE_STAFF_CROSS_OF_NETA + k64_IconIndiceWeaponTheConduitSerpentStaff = 64, // @ C064_ICON_WEAPON_THE_CONDUIT_SERPENT_STAFF + k65_IconIndiceWeaponDragonSpit = 65, // @ C065_ICON_WEAPON_DRAGON_SPIT + k66_IconIndiceWeaponSceptreOfLyf = 66, // @ C066_ICON_WEAPON_SCEPTRE_OF_LYF + k81_IconIndiceArmourCloakOfNight = 81, // @ C081_ICON_ARMOUR_CLOAK_OF_NIGHT + k104_IconIndiceArmourCrownOfNerra = 104, // @ C104_ICON_ARMOUR_CROWN_OF_NERRA + k119_IconIndiceArmourElvenBoots = 119, // @ C119_ICON_ARMOUR_ELVEN_BOOTS + k120_IconIndiceJunkGemOfAges = 120, // @ C120_ICON_JUNK_GEM_OF_AGES + k121_IconIndiceJunkEkkhardCross = 121, // @ C121_ICON_JUNK_EKKHARD_CROSS + k122_IconIndiceJunkMoonstone = 122, // @ C122_ICON_JUNK_MOONSTONE + k124_IconIndiceJunkPendantFeral = 124, // @ C124_ICON_JUNK_PENDANT_FERAL + k128_IconIndiceJunkBoulder = 128, // @ C128_ICON_JUNK_BOULDER + k137_IconIndiceJunkRabbitsFoot = 137, // @ C137_ICON_JUNK_RABBITS_FOOT + k140_IconIndiceArmourDexhelm = 140, // @ C140_ICON_ARMOUR_DEXHELM + k141_IconIndiceArmourFlamebain = 141, // @ C141_ICON_ARMOUR_FLAMEBAIN + k142_IconIndiceArmourPowertowers = 142, // @ C142_ICON_ARMOUR_POWERTOWERS + k144_IconIndiceContainerChestClosed = 144, // @ C144_ICON_CONTAINER_CHEST_CLOSED + k145_IconIndiceContainerChestOpen = 145, // @ C145_ICON_CONTAINER_CHEST_OPEN + k147_IconIndiceJunkChampionBones = 147, // @ C147_ICON_JUNK_CHAMPION_BONES + k148_IconIndicePotionMaPotionMonPotion = 148, // @ C148_ICON_POTION_MA_POTION_MON_POTION + k163_IconIndicePotionWaterFlask = 163, // @ C163_ICON_POTION_WATER_FLASK + k168_IconIndiceJunkApple = 168, // @ C168_ICON_JUNK_APPLE + k176_IconIndiceJunkIronKey = 176, // @ C176_ICON_JUNK_IRON_KEY + k191_IconIndiceJunkMasterKey = 191, // @ C191_ICON_JUNK_MASTER_KEY + k194_IconIndiceArmourBootOfSpeed = 194, // @ C194_ICON_ARMOUR_BOOT_OF_SPEED + k195_IconIndicePotionEmptyFlask = 195, // @ C195_ICON_POTION_EMPTY_FLASK + k197_IconIndiceJunkZokathra = 197, // @ C197_ICON_JUNK_ZOKATHRA + k201_IconIndiceActionEmptyHand = 201, // @ C201_ICON_ACTION_ICON_EMPTY_HAND + k202_IconIndiceEyeNotLooking = 202, // @ C202_ICON_EYE_NOT_LOOKING /* One pixel is different in this bitmap from the eye in C017_GRAPHIC_INVENTORY. This is visible by selecting another champion after clicking the eye */ + k203_IconIndiceEyeLooking = 203, // @ C203_ICON_EYE_LOOKING + k204_IconIndiceEmptyBox = 204, // @ C204_ICON_EMPTY_BOX + k205_IconIndiceMouthOpen = 205, // @ C205_ICON_MOUTH_OPEN + k208_IconIndiceNeck = 208, // @ C208_ICON_NECK + k212_IconIndiceReadyHand = 212 // @ C212_ICON_READY_HAND }; enum ChampionIndex { - kChampionNone = -1, // @ CM1_CHAMPION_NONE - kChampionFirst = 0, // @ C00_CHAMPION_FIRST - kChampionSecond = 1, - kChampionThird = 2, - kChampionFourth = 3, - kChampionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY - kChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY + kM1_ChampionNone = -1, // @ CM1_CHAMPION_NONE + k0_ChampionFirst = 0, // @ C00_CHAMPION_FIRST + k1_ChampionSecond = 1, + k2_ChampionThird = 2, + k3_ChampionFourth = 3, + k4_ChampionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY + k5_ChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY }; enum ChampionAttribute { - kChampionAttributNone = 0x0000, // @ MASK0x0000_NONE - kChampionAttributeDisableAction = 0x0008, // @ MASK0x0008_DISABLE_ACTION - kChampionAttributeMale = 0x0010, // @ MASK0x0010_MALE - kChampionAttributeNameTitle = 0x0080, // @ MASK0x0080_NAME_TITLE - kChampionAttributeStatistics = 0x0100, // @ MASK0x0100_STATISTICS - kChampionAttributeLoad = 0x0200, // @ MASK0x0200_LOAD - kChampionAttributeIcon = 0x0400, // @ MASK0x0400_ICON - kChampionAttributePanel = 0x0800, // @ MASK0x0800_PANEL - kChampionAttributeStatusBox = 0x1000, // @ MASK0x1000_STATUS_BOX - kChampionAttributeWounds = 0x2000, // @ MASK0x2000_WOUNDS - kChampionAttributeViewport = 0x4000, // @ MASK0x4000_VIEWPORT - kChampionAttributeActionHand = 0x8000 // @ MASK0x8000_ACTION_HAND + k0x0000_ChampionAttributNone = 0x0000, // @ MASK0x0000_NONE + k0x0008_ChampionAttributeDisableAction = 0x0008, // @ MASK0x0008_DISABLE_ACTION + k0x0010_ChampionAttributeMale = 0x0010, // @ MASK0x0010_MALE + k0x0080_ChampionAttributeNameTitle = 0x0080, // @ MASK0x0080_NAME_TITLE + k0x0100_ChampionAttributeStatistics = 0x0100, // @ MASK0x0100_STATISTICS + k0x0200_ChampionAttributeLoad = 0x0200, // @ MASK0x0200_LOAD + k0x0400_ChampionAttributeIcon = 0x0400, // @ MASK0x0400_ICON + k0x0800_ChampionAttributePanel = 0x0800, // @ MASK0x0800_PANEL + k0x1000_ChampionAttributeStatusBox = 0x1000, // @ MASK0x1000_STATUS_BOX + k0x2000_ChampionAttributeWounds = 0x2000, // @ MASK0x2000_WOUNDS + k0x4000_ChampionAttributeViewport = 0x4000, // @ MASK0x4000_VIEWPORT + k0x8000_ChampionAttributeActionHand = 0x8000 // @ MASK0x8000_ACTION_HAND }; enum ChampionWound { - kChampionWoundNone = 0x0000, // @ MASK0x0000_NO_WOUND - kChampionWoundReadHand = 0x0001, // @ MASK0x0001_READY_HAND - kChampionWoundActionHand = 0x0002, // @ MASK0x0002_ACTION_HAND - kChampionWoundHead = 0x0004, // @ MASK0x0004_HEAD - kChampionWoundTorso = 0x0008, // @ MASK0x0008_TORSO - kChampionWoundLegs = 0x0010, // @ MASK0x0010_LEGS - kChampionWoundFeet = 0x0020 // @ MASK0x0020_FEET + k0x0000_ChampionWoundNone = 0x0000, // @ MASK0x0000_NO_WOUND + k0x0001_ChampionWoundReadHand = 0x0001, // @ MASK0x0001_READY_HAND + k0x0002_ChampionWoundActionHand = 0x0002, // @ MASK0x0002_ACTION_HAND + k0x0004_ChampionWoundHead = 0x0004, // @ MASK0x0004_HEAD + k0x0008_ChampionWoundTorso = 0x0008, // @ MASK0x0008_TORSO + k0x0010_ChampionWoundLegs = 0x0010, // @ MASK0x0010_LEGS + k0x0020_ChampionWoundFeet = 0x0020 // @ MASK0x0020_FEET }; enum ChampionStatisticType { - kChampionStatLuck = 0, // @ C0_STATISTIC_LUCK - kChampionStatStrength = 1, // @ C1_STATISTIC_STRENGTH - kChampionStatDexterity = 2, // @ C2_STATISTIC_DEXTERITY - kChampionStatWisdom = 3, // @ C3_STATISTIC_WISDOM - kChampionStatVitality = 4, // @ C4_STATISTIC_VITALITY - kChampionStatAntimagic = 5, // @ C5_STATISTIC_ANTIMAGIC - kChampionStatAntifire = 6, // @ C6_STATISTIC_ANTIFIRE - kChampionStatMana = 8 // @ C8_STATISTIC_MANA /* Used as a fake statistic index for objects granting a Mana bonus */ + k0_ChampionStatLuck = 0, // @ C0_STATISTIC_LUCK + k1_ChampionStatStrength = 1, // @ C1_STATISTIC_STRENGTH + k2_ChampionStatDexterity = 2, // @ C2_STATISTIC_DEXTERITY + k3_ChampionStatWisdom = 3, // @ C3_STATISTIC_WISDOM + k4_ChampionStatVitality = 4, // @ C4_STATISTIC_VITALITY + k5_ChampionStatAntimagic = 5, // @ C5_STATISTIC_ANTIMAGIC + k6_ChampionStatAntifire = 6, // @ C6_STATISTIC_ANTIFIRE + k8_ChampionStatMana = 8 // @ C8_STATISTIC_MANA /* Used as a fake statistic index for objects granting a Mana bonus */ }; enum ChampionStatisticValue { - kChampionStatMaximum = 0, // @ C0_MAXIMUM - kChampionStatCurrent = 1, // @ C1_CURRENT - kChampionStatMinimum = 2 // @ C2_MINIMUM + k0_ChampionStatMaximum = 0, // @ C0_MAXIMUM + k1_ChampionStatCurrent = 1, // @ C1_CURRENT + k2_ChampionStatMinimum = 2 // @ C2_MINIMUM }; enum ChampionSkill { - kChampionSkillFighter = 0, // @ C00_SKILL_FIGHTER - kChampionSkillNinja = 1, // @ C01_SKILL_NINJA - kChampionSkillPriest = 2, // @ C02_SKILL_PRIEST - kChampionSkillWizard = 3, // @ C03_SKILL_WIZARD - kChampionSkillSwing = 4, // @ C04_SKILL_SWING - kChampionSkillThrust = 5, // @ C05_SKILL_THRUST - kChampionSkillClub = 6, // @ C06_SKILL_CLUB - kChampionSkillParry = 7, // @ C07_SKILL_PARRY - kChampionSkillSteal = 8, // @ C08_SKILL_STEAL - kChampionSkillFight = 9, // @ C09_SKILL_FIGHT - kChampionSkillThrow = 10, // @ C10_SKILL_THROW - kChampionSkillShoot = 11, // @ C11_SKILL_SHOOT - kChampionSkillIdentify = 12, // @ C12_SKILL_IDENTIFY - kChampionSkillHeal = 13, // @ C13_SKILL_HEAL - kChampionSkillInfluence = 14, // @ C14_SKILL_INFLUENCE - kChampionSkillDefend = 15, // @ C15_SKILL_DEFEND - kChampionSkillFire = 16, // @ C16_SKILL_FIRE - kChampionSkillAir = 17, // @ C17_SKILL_AIR - kChampionSkillEarth = 18, // @ C18_SKILL_EARTH - kChampionSkillWater = 19 // @ C19_SKILL_WATER + k0_ChampionSkillFighter = 0, // @ C00_SKILL_FIGHTER + k1_ChampionSkillNinja = 1, // @ C01_SKILL_NINJA + k2_ChampionSkillPriest = 2, // @ C02_SKILL_PRIEST + k3_ChampionSkillWizard = 3, // @ C03_SKILL_WIZARD + k4_ChampionSkillSwing = 4, // @ C04_SKILL_SWING + k5_ChampionSkillThrust = 5, // @ C05_SKILL_THRUST + k6_ChampionSkillClub = 6, // @ C06_SKILL_CLUB + k7_ChampionSkillParry = 7, // @ C07_SKILL_PARRY + k8_ChampionSkillSteal = 8, // @ C08_SKILL_STEAL + k9_ChampionSkillFight = 9, // @ C09_SKILL_FIGHT + k10_ChampionSkillThrow = 10, // @ C10_SKILL_THROW + k11_ChampionSkillShoot = 11, // @ C11_SKILL_SHOOT + k12_ChampionSkillIdentify = 12, // @ C12_SKILL_IDENTIFY + k13_ChampionSkillHeal = 13, // @ C13_SKILL_HEAL + k14_ChampionSkillInfluence = 14, // @ C14_SKILL_INFLUENCE + k15_ChampionSkillDefend = 15, // @ C15_SKILL_DEFEND + k16_ChampionSkillFire = 16, // @ C16_SKILL_FIRE + k17_ChampionSkillAir = 17, // @ C17_SKILL_AIR + k18_ChampionSkillEarth = 18, // @ C18_SKILL_EARTH + k19_ChampionSkillWater = 19 // @ C19_SKILL_WATER }; enum ChampionSlot { - kChampionSlotLeaderHand = -1, // @ CM1_SLOT_LEADER_HAND - kChampionSlotReadyHand = 0, // @ C00_SLOT_READY_HAND - kChampionSlotActionHand = 1, // @ C01_SLOT_ACTION_HAND - kChampionSlotHead = 2, // @ C02_SLOT_HEAD - kChampionSlotTorso = 3, // @ C03_SLOT_TORSO - kChampionSlotLegs = 4, // @ C04_SLOT_LEGS - kChampionSlotFeet = 5, // @ C05_SLOT_FEET - kChampionSlotPouch_2 = 6, // @ C06_SLOT_POUCH_2 - kChampionSlotQuiverLine_2_1 = 7, // @ C07_SLOT_QUIVER_LINE2_1 - kChampionSlotQuiverLine_1_2 = 8, // @ C08_SLOT_QUIVER_LINE1_2 - kChampionSlotQuiverLine_2_2 = 9, // @ C09_SLOT_QUIVER_LINE2_2 - kChampionSlotNeck = 10, // @ C10_SLOT_NECK - kChampionSlotPouch_1 = 11, // @ C11_SLOT_POUCH_1 - kChampionSlotQuiverLine_1_1 = 12, // @ C12_SLOT_QUIVER_LINE1_1 - kChampionSlotBackpackLine_1_1 = 13, // @ C13_SLOT_BACKPACK_LINE1_1 - kChampionSlotBackpackLine_2_2 = 14, // @ C14_SLOT_BACKPACK_LINE2_2 - kChampionSlotBackpackLine_2_3 = 15, // @ C15_SLOT_BACKPACK_LINE2_3 - kChampionSlotBackpackLine_2_4 = 16, // @ C16_SLOT_BACKPACK_LINE2_4 - kChampionSlotBackpackLine_2_5 = 17, // @ C17_SLOT_BACKPACK_LINE2_5 - kChampionSlotBackpackLine_2_6 = 18, // @ C18_SLOT_BACKPACK_LINE2_6 - kChampionSlotBackpackLine_2_7 = 19, // @ C19_SLOT_BACKPACK_LINE2_7 - kChampionSlotBackpackLine_2_8 = 20, // @ C20_SLOT_BACKPACK_LINE2_8 - kChampionSlotBackpackLine_2_9 = 21, // @ C21_SLOT_BACKPACK_LINE2_9 - kChampionSlotBackpackLine_1_2 = 22, // @ C22_SLOT_BACKPACK_LINE1_2 - kChampionSlotBackpackLine_1_3 = 23, // @ C23_SLOT_BACKPACK_LINE1_3 - kChampionSlotBackpackLine_1_4 = 24, // @ C24_SLOT_BACKPACK_LINE1_4 - kChampionSlotBackpackLine_1_5 = 25, // @ C25_SLOT_BACKPACK_LINE1_5 - kChampionSlotBackpackLine_1_6 = 26, // @ C26_SLOT_BACKPACK_LINE1_6 - kChampionSlotBackpackLine_1_7 = 27, // @ C27_SLOT_BACKPACK_LINE1_7 - kChampionSlotBackpackLine_1_8 = 28, // @ C28_SLOT_BACKPACK_LINE1_8 - kChampionSlotBackpackLine_1_9 = 29, // @ C29_SLOT_BACKPACK_LINE1_9 - kChampionSlotChest_1 = 30, // @ C30_SLOT_CHEST_1 - kChampionSlotChest_2 = 31, // @ C31_SLOT_CHEST_2 - kChampionSlotChest_3 = 32, // @ C32_SLOT_CHEST_3 - kChampionSlotChest_4 = 33, // @ C33_SLOT_CHEST_4 - kChampionSlotChest_5 = 34, // @ C34_SLOT_CHEST_5 - kChampionSlotChest_6 = 35, // @ C35_SLOT_CHEST_6 - kChampionSlotChest_7 = 36, // @ C36_SLOT_CHEST_7 - kChampionSlotChest_8 = 37 // @ C37_SLOT_CHEST_8 + kM1_ChampionSlotLeaderHand = -1, // @ CM1_SLOT_LEADER_HAND + k0_ChampionSlotReadyHand = 0, // @ C00_SLOT_READY_HAND + k1_ChampionSlotActionHand = 1, // @ C01_SLOT_ACTION_HAND + k2_ChampionSlotHead = 2, // @ C02_SLOT_HEAD + k3_ChampionSlotTorso = 3, // @ C03_SLOT_TORSO + k4_ChampionSlotLegs = 4, // @ C04_SLOT_LEGS + k5_ChampionSlotFeet = 5, // @ C05_SLOT_FEET + k6_ChampionSlotPouch_2 = 6, // @ C06_SLOT_POUCH_2 + k7_ChampionSlotQuiverLine_2_1 = 7, // @ C07_SLOT_QUIVER_LINE2_1 + k8_ChampionSlotQuiverLine_1_2 = 8, // @ C08_SLOT_QUIVER_LINE1_2 + k9_ChampionSlotQuiverLine_2_2 = 9, // @ C09_SLOT_QUIVER_LINE2_2 + k10_ChampionSlotNeck = 10, // @ C10_SLOT_NECK + k11_ChampionSlotPouch_1 = 11, // @ C11_SLOT_POUCH_1 + k12_ChampionSlotQuiverLine_1_1 = 12, // @ C12_SLOT_QUIVER_LINE1_1 + k13_ChampionSlotBackpackLine_1_1 = 13, // @ C13_SLOT_BACKPACK_LINE1_1 + k14_ChampionSlotBackpackLine_2_2 = 14, // @ C14_SLOT_BACKPACK_LINE2_2 + k15_ChampionSlotBackpackLine_2_3 = 15, // @ C15_SLOT_BACKPACK_LINE2_3 + k16_ChampionSlotBackpackLine_2_4 = 16, // @ C16_SLOT_BACKPACK_LINE2_4 + k17_ChampionSlotBackpackLine_2_5 = 17, // @ C17_SLOT_BACKPACK_LINE2_5 + k18_ChampionSlotBackpackLine_2_6 = 18, // @ C18_SLOT_BACKPACK_LINE2_6 + k19_ChampionSlotBackpackLine_2_7 = 19, // @ C19_SLOT_BACKPACK_LINE2_7 + k20_ChampionSlotBackpackLine_2_8 = 20, // @ C20_SLOT_BACKPACK_LINE2_8 + k21_ChampionSlotBackpackLine_2_9 = 21, // @ C21_SLOT_BACKPACK_LINE2_9 + k22_ChampionSlotBackpackLine_1_2 = 22, // @ C22_SLOT_BACKPACK_LINE1_2 + k23_ChampionSlotBackpackLine_1_3 = 23, // @ C23_SLOT_BACKPACK_LINE1_3 + k24_ChampionSlotBackpackLine_1_4 = 24, // @ C24_SLOT_BACKPACK_LINE1_4 + k25_ChampionSlotBackpackLine_1_5 = 25, // @ C25_SLOT_BACKPACK_LINE1_5 + k26_ChampionSlotBackpackLine_1_6 = 26, // @ C26_SLOT_BACKPACK_LINE1_6 + k27_ChampionSlotBackpackLine_1_7 = 27, // @ C27_SLOT_BACKPACK_LINE1_7 + k28_ChampionSlotBackpackLine_1_8 = 28, // @ C28_SLOT_BACKPACK_LINE1_8 + k29_ChampionSlotBackpackLine_1_9 = 29, // @ C29_SLOT_BACKPACK_LINE1_9 + k30_ChampionSlotChest_1 = 30, // @ C30_SLOT_CHEST_1 + k31_ChampionSlotChest_2 = 31, // @ C31_SLOT_CHEST_2 + k32_ChampionSlotChest_3 = 32, // @ C32_SLOT_CHEST_3 + k33_ChampionSlotChest_4 = 33, // @ C33_SLOT_CHEST_4 + k34_ChampionSlotChest_5 = 34, // @ C34_SLOT_CHEST_5 + k35_ChampionSlotChest_6 = 35, // @ C35_SLOT_CHEST_6 + k36_ChampionSlotChest_7 = 36, // @ C36_SLOT_CHEST_7 + k37_ChampionSlotChest_8 = 37 // @ C37_SLOT_CHEST_8 }; enum ChampionAction { - kChampionActionN = 0, // @ C000_ACTION_N - kChampionActionBlock = 1, // @ C001_ACTION_BLOCK - kChampionActionChop = 2, // @ C002_ACTION_CHOP - kChampionActionX_C003 = 3, // @ C003_ACTION_X - kChampionActionBlowHorn = 4, // @ C004_ACTION_BLOW_HORN - kChampionActionFlip = 5, // @ C005_ACTION_FLIP - kChampionActionPunch = 6, // @ C006_ACTION_PUNCH - kChampionActionKick = 7, // @ C007_ACTION_KICK - kChampionActionWarCry = 8, // @ C008_ACTION_WAR_CRY - kChampionActionStab_C009 = 9, // @ C009_ACTION_STAB - kChampionActionClimbDown = 10, // @ C010_ACTION_CLIMB_DOWN - kChampionActionFreezeLife = 11, // @ C011_ACTION_FREEZE_LIFE - kChampionActionHit = 12, // @ C012_ACTION_HIT - kChampionActionSwing = 13, // @ C013_ACTION_SWING - kChampionActionStab_C014 = 14, // @ C014_ACTION_STAB - kChampionActionThrust = 15, // @ C015_ACTION_THRUST - kChampionActionJab = 16, // @ C016_ACTION_JAB - kChampionActionParry = 17, // @ C017_ACTION_PARRY - kChampionActionHack = 18, // @ C018_ACTION_HACK - kChampionActionBerzerk = 19, // @ C019_ACTION_BERZERK - kChampionActionFireball = 20, // @ C020_ACTION_FIREBALL - kChampionActionDispel = 21, // @ C021_ACTION_DISPELL - kChampionActionConfuse = 22, // @ C022_ACTION_CONFUSE - kChampionActionLightning = 23, // @ C023_ACTION_LIGHTNING - kChampionActionDisrupt = 24, // @ C024_ACTION_DISRUPT - kChampionActionMelee = 25, // @ C025_ACTION_MELEE - kChampionActionX_C026 = 26, // @ C026_ACTION_X - kChampionActionInvoke = 27, // @ C027_ACTION_INVOKE - kChampionActionSlash = 28, // @ C028_ACTION_SLASH - kChampionActionCleave = 29, // @ C029_ACTION_CLEAVE - kChampionActionBash = 30, // @ C030_ACTION_BASH - kChampionActionStun = 31, // @ C031_ACTION_STUN - kChampionActionShoot = 32, // @ C032_ACTION_SHOOT - kChampionActionSpellshield = 33, // @ C033_ACTION_SPELLSHIELD - kChampionActionFireshield = 34, // @ C034_ACTION_FIRESHIELD - kChampionActionFluxcage = 35, // @ C035_ACTION_FLUXCAGE - kChampionActionHeal = 36, // @ C036_ACTION_HEAL - kChampionActionCalm = 37, // @ C037_ACTION_CALM - kChampionActionLight = 38, // @ C038_ACTION_LIGHT - kChampionActionWindow = 39, // @ C039_ACTION_WINDOW - kChampionActionSpit = 40, // @ C040_ACTION_SPIT - kChampionActionBrandish = 41, // @ C041_ACTION_BRANDISH - kChampionActionThrow = 42, // @ C042_ACTION_THROW - kChampionActionFuse = 43, // @ C043_ACTION_FUSE - kChampionActionNone = 255 // @ C255_ACTION_NONE + k0_ChampionActionN = 0, // @ C000_ACTION_N + k1_ChampionActionBlock = 1, // @ C001_ACTION_BLOCK + k2_ChampionActionChop = 2, // @ C002_ACTION_CHOP + k3_ChampionActionX_C003 = 3, // @ C003_ACTION_X + k4_ChampionActionBlowHorn = 4, // @ C004_ACTION_BLOW_HORN + k5_ChampionActionFlip = 5, // @ C005_ACTION_FLIP + k6_ChampionActionPunch = 6, // @ C006_ACTION_PUNCH + k7_ChampionActionKick = 7, // @ C007_ACTION_KICK + k8_ChampionActionWarCry = 8, // @ C008_ACTION_WAR_CRY + k9_ChampionActionStab_C009 = 9, // @ C009_ACTION_STAB + k10_ChampionActionClimbDown = 10, // @ C010_ACTION_CLIMB_DOWN + k11_ChampionActionFreezeLife = 11, // @ C011_ACTION_FREEZE_LIFE + k12_ChampionActionHit = 12, // @ C012_ACTION_HIT + k13_ChampionActionSwing = 13, // @ C013_ACTION_SWING + k14_ChampionActionStab_C014 = 14, // @ C014_ACTION_STAB + k15_ChampionActionThrust = 15, // @ C015_ACTION_THRUST + k16_ChampionActionJab = 16, // @ C016_ACTION_JAB + k17_ChampionActionParry = 17, // @ C017_ACTION_PARRY + k18_ChampionActionHack = 18, // @ C018_ACTION_HACK + k19_ChampionActionBerzerk = 19, // @ C019_ACTION_BERZERK + k20_ChampionActionFireball = 20, // @ C020_ACTION_FIREBALL + k21_ChampionActionDispel = 21, // @ C021_ACTION_DISPELL + k22_ChampionActionConfuse = 22, // @ C022_ACTION_CONFUSE + k23_ChampionActionLightning = 23, // @ C023_ACTION_LIGHTNING + k24_ChampionActionDisrupt = 24, // @ C024_ACTION_DISRUPT + k25_ChampionActionMelee = 25, // @ C025_ACTION_MELEE + k26_ChampionActionX_C026 = 26, // @ C026_ACTION_X + k27_ChampionActionInvoke = 27, // @ C027_ACTION_INVOKE + k28_ChampionActionSlash = 28, // @ C028_ACTION_SLASH + k29_ChampionActionCleave = 29, // @ C029_ACTION_CLEAVE + k30_ChampionActionBash = 30, // @ C030_ACTION_BASH + k31_ChampionActionStun = 31, // @ C031_ACTION_STUN + k32_ChampionActionShoot = 32, // @ C032_ACTION_SHOOT + k33_ChampionActionSpellshield = 33, // @ C033_ACTION_SPELLSHIELD + k34_ChampionActionFireshield = 34, // @ C034_ACTION_FIRESHIELD + k35_ChampionActionFluxcage = 35, // @ C035_ACTION_FLUXCAGE + k36_ChampionActionHeal = 36, // @ C036_ACTION_HEAL + k37_ChampionActionCalm = 37, // @ C037_ACTION_CALM + k38_ChampionActionLight = 38, // @ C038_ACTION_LIGHT + k39_ChampionActionWindow = 39, // @ C039_ACTION_WINDOW + k40_ChampionActionSpit = 40, // @ C040_ACTION_SPIT + k41_ChampionActionBrandish = 41, // @ C041_ACTION_BRANDISH + k42_ChampionActionThrow = 42, // @ C042_ACTION_THROW + k43_ChampionActionFuse = 43, // @ C043_ACTION_FUSE + k255_ChampionActionNone = 255 // @ C255_ACTION_NONE }; @@ -386,7 +386,7 @@ public: _attributes &= ~flag; } } - void clearAttributes(ChampionAttribute attribute = kChampionAttributNone) { _attributes = attribute; } + void clearAttributes(ChampionAttribute attribute = k0x0000_ChampionAttributNone) { _attributes = attribute; } uint16 getWounds() { return _wounds; } void setWoundsFlag(ChampionWound flag, bool value) { @@ -397,7 +397,7 @@ public: } } uint16 getWoundsFlag(ChampionWound wound) { return _wounds & wound; } - void clearWounds() { _wounds = kChampionWoundNone; } + void clearWounds() { _wounds = k0x0000_ChampionWoundNone; } void resetToZero() { // oh boy > . < for (int16 i = 0; i < 30; ++i) _slots[i] = Thing::_none; @@ -409,7 +409,7 @@ public: memset(_title, '\0', 20); _dir = kDirNorth; _cell = k0_ViewCellFronLeft; - _actionIndex = kChampionActionN; + _actionIndex = k0_ChampionActionN; _symbolStep = 0; memset(_symbols, '\0', 5); _directionMaximumDamageReceived = _maximumDamageReceived = _poisonEventCount = _enableActionEventIndex = 0; @@ -435,18 +435,18 @@ class ChampionMan { uint16 handSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX public: Champion _champions[4]; - uint16 _partyChampionCount; // @ G0305_ui_PartyChampionCount - bool _partyDead; // @ G0303_B_PartyDead - Thing _leaderHandObject; // @ G0414_T_LeaderHandObject - ChampionIndex _leaderIndex; // @ G0411_i_LeaderIndex - uint16 _candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal - bool _partyIsSleeping; // @ G0300_B_PartyIsSleeping - uint16 _actingChampionOrdinal; // @ G0506_ui_ActingChampionOrdinal - IconIndice _leaderHandObjectIconIndex; // @ G0413_i_LeaderHandObjectIconIndex - bool _leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded - Party _party; // @ G0407_s_Party - ChampionIndex _magicCasterChampionIndex; // @ G0514_i_MagicCasterChampionIndex - bool _mousePointerHiddenToDrawChangedObjIconOnScreen; // @ G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen + uint16 _g305_partyChampionCount; // @ G0305_ui_PartyChampionCount + bool _303_partyDead; // @ G0303_B_PartyDead + Thing _414_leaderHandObject; // @ G0414_T_LeaderHandObject + ChampionIndex _g411_leaderIndex; // @ G0411_i_LeaderIndex + uint16 _g299_candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal + bool _g300_partyIsSleeping; // @ G0300_B_PartyIsSleeping + uint16 _g506_actingChampionOrdinal; // @ G0506_ui_ActingChampionOrdinal + IconIndice _g413_leaderHandObjectIconIndex; // @ G0413_i_LeaderHandObjectIconIndex + bool _g415_leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded + Party _g407_party; // @ G0407_s_Party + ChampionIndex _g514_magicCasterChampionIndex; // @ G0514_i_MagicCasterChampionIndex + bool _g420_mousePointerHiddenToDrawChangedObjIconOnScreen; // @ G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen explicit ChampionMan(DMEngine *vm); void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index bf584fd6fe..adc842b0ab 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -170,10 +170,10 @@ void DMEngine::startGame() { _stopPressingMouth = false; _highlightBoxInversionRequested = false; _eventMan->_highlightBoxEnabled = false; - _championMan->_partyIsSleeping = false; - _championMan->_actingChampionOrdinal = indexToOrdinal(kChampionNone); + _championMan->_g300_partyIsSleeping = false; + _championMan->_g506_actingChampionOrdinal = indexToOrdinal(kM1_ChampionNone); _menuMan->_actionAreaContainsIcons = true; - _eventMan->_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kChampionNone); + _eventMan->_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone); _eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface; _eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement; @@ -251,7 +251,7 @@ void DMEngine::gameloop() { _eventMan->processCommandQueue(); //} while (!_stopWaitingForPlayerInput || !_gameTimeTicking); - if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_partyIsSleeping) { + if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { Box box(0, 224, 0, 126); _displayMan->clearScreenBox(k0_ColorBlack, box, g296_DungeonViewport); // dummy code _displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY); diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 1adb396ab9..82fd07caac 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -479,28 +479,28 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) { ChampionMan &cm = *_vm->_championMan; ChampionIndex leaderIndex; - if ((cm._leaderIndex == champIndex) || ((champIndex != kChampionNone) && !cm._champions[champIndex]._currHealth)) + if ((cm._g411_leaderIndex == champIndex) || ((champIndex != kM1_ChampionNone) && !cm._champions[champIndex]._currHealth)) return; - if (cm._leaderIndex != kChampionNone) { - leaderIndex = cm._leaderIndex; - cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeLoad, true); - cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeNameTitle, true); - cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject); - cm._leaderIndex = kChampionNone; + if (cm._g411_leaderIndex != kM1_ChampionNone) { + leaderIndex = cm._g411_leaderIndex; + cm._champions[leaderIndex].setAttributeFlag(k0x0200_ChampionAttributeLoad, true); + cm._champions[leaderIndex].setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true); + cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._414_leaderHandObject); + cm._g411_leaderIndex = kM1_ChampionNone; cm.drawChampionState(leaderIndex); } - if (champIndex == kChampionNone) { - cm._leaderIndex = kChampionNone; + if (champIndex == kM1_ChampionNone) { + cm._g411_leaderIndex = kM1_ChampionNone; return; } - cm._leaderIndex = champIndex; - Champion *champion = &cm._champions[cm._leaderIndex]; + cm._g411_leaderIndex = champIndex; + Champion *champion = &cm._champions[cm._g411_leaderIndex]; champion->_dir = _vm->_dungeonMan->_currMap._partyDir; - cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject); - if (_vm->indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) { - champion->setAttributeFlag(kChampionAttributeIcon, true); - champion->setAttributeFlag(kChampionAttributeNameTitle, true); + cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._414_leaderHandObject); + if (_vm->indexToOrdinal(champIndex) != cm._g299_candidateChampionOrdinal) { + champion->setAttributeFlag(k0x0400_ChampionAttributeIcon, true); + champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true); cm.drawChampionState(champIndex); } } @@ -521,10 +521,10 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY CurrMapData &currMap = _vm->_dungeonMan->_currMap; if (dunMan._squareAheadElement == kElementTypeDoorFront) { - if (champMan._leaderIndex == kChampionNone) + if (champMan._g411_leaderIndex == kM1_ChampionNone) return; - if (champMan._leaderEmptyHanded) { + if (champMan._g415_leaderEmptyHanded) { int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir]; int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir]; @@ -540,7 +540,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY } } - if (champMan._leaderEmptyHanded) { + if (champMan._g415_leaderEmptyHanded) { for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k5_ViewCellDoorButtonOrWallOrn; viewCell++) { if (dunMan._dungeonViewClickableBoxes[viewCell].isPointInside(Common::Point(posX, posY - 33))) { if (viewCell == k5_ViewCellDoorButtonOrWallOrn) { @@ -554,7 +554,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY } } } else { - Thing thing = champMan._leaderHandObject; + Thing thing = champMan._414_leaderHandObject; uint16 *rawThingPointer = dunMan.getThingData(thing); if (dunMan._squareAheadElement == kElementTypeWall) { for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k1_ViewCellFrontRight; ++viewCell) { @@ -571,15 +571,15 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY if (dunMan._isFacingFountain) { uint16 iconIndex = _vm->_objectMan->getIconIndex(thing); int16 weight = dunMan.getObjectWeight(thing); - if ((iconIndex >= kIconIndiceJunkWater) && (iconIndex <= kIconIndiceJunkWaterSkin)) { + if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) { ((Junk*)rawThingPointer)->setChargeCount(3); - } else if (iconIndex == kIconIndicePotionEmptyFlask) { + } else if (iconIndex == k195_IconIndicePotionEmptyFlask) { ((Potion*)rawThingPointer)->setType(kPotionTypeWaterFlask); } else { goto T0377019; } champMan.drawChangedObjectIcons(); - champMan._champions[champMan._leaderIndex]._load += dunMan.getObjectWeight(thing) - weight; + champMan._champions[champMan._g411_leaderIndex]._load += dunMan.getObjectWeight(thing) - weight; } T0377019: commandProcessType80ClickInDungeonViewTouchFrontWall(); @@ -604,15 +604,15 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane CurrMapData &currMap = _vm->_dungeonMan->_currMap; DungeonMan &dunMan = *_vm->_dungeonMan; - uint16 championIndex = champMan._partyChampionCount - 1; + uint16 championIndex = champMan._g305_partyChampionCount - 1; Champion *champ = &champMan._champions[championIndex]; if (commandType == kCommandClickInPanelCancel) { - invMan.toggleInventory(kChampionCloseInventory); - champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone); - if (champMan._partyChampionCount == 1) { - commandSetLeader(kChampionNone); + invMan.toggleInventory(k4_ChampionCloseInventory); + champMan._g299_candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone); + if (champMan._g305_partyChampionCount == 1) { + commandSetLeader(kM1_ChampionNone); } - champMan._partyChampionCount--; + champMan._g305_partyChampionCount--; Box box; box._y1 = 0; box._y2 = 28 + 1; @@ -620,17 +620,17 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane box._x2 = box._x1 + 66 + 1; dispMan._g578_useByteBoxCoordinates = false; dispMan.clearScreenBox(k0_ColorBlack, box); - dispMan.clearScreenBox(k0_ColorBlack, gBoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._partyDir) * 2]); + dispMan.clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._partyDir) * 2]); warning("F0457_START_DrawEnabledMenus_CPSF"); warning("F0078_MOUSE_ShowPointer"); return; } - champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone); + champMan._g299_candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone); int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir]; int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir]; - for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) { + for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) { Thing thing = champ->getSlot((ChampionSlot)slotIndex); if (thing != Thing::_none) { warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList"); @@ -651,25 +651,25 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane for (uint16 i = 0; i < 12; i++) { uint16 statIndex = _vm->_rnd->getRandomNumber(7); - champ->getStatistic((ChampionStatisticType)statIndex, kChampionStatCurrent)++; // returns reference - champ->getStatistic((ChampionStatisticType)statIndex, kChampionStatMaximum)++; // returns reference + champ->getStatistic((ChampionStatisticType)statIndex, k1_ChampionStatCurrent)++; // returns reference + champ->getStatistic((ChampionStatisticType)statIndex, k0_ChampionStatMaximum)++; // returns reference } } - if (champMan._partyChampionCount == 1) { + if (champMan._g305_partyChampionCount == 1) { warning("MISSING CODE: setting time, G0362_l_LastPartyMovementTime , G0313_ul_GameTime"); - commandSetLeader(kChampionFirst); - _vm->_menuMan->setMagicCasterAndDrawSpellArea(kChampionFirst); + commandSetLeader(k0_ChampionFirst); + _vm->_menuMan->setMagicCasterAndDrawSpellArea(k0_ChampionFirst); } else { - _vm->_menuMan->drawSpellAreaControls(champMan._magicCasterChampionIndex); + _vm->_menuMan->drawSpellAreaControls(champMan._g514_magicCasterChampionIndex); } warning("MISSING CODE: F0051_TEXT_MESSAGEAREA_PrintLineFeed"); - Color champColor = gChampionColor[championIndex]; // unreferenced because of missing code + Color champColor = g46_ChampionColor[championIndex]; // unreferenced because of missing code warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage"); warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage"); - invMan.toggleInventory(kChampionCloseInventory); + invMan.toggleInventory(k4_ChampionCloseInventory); warning("MISSING CODE: F0457_START_DrawEnabledMenus_CPSF"); warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal"); } @@ -681,14 +681,14 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) { CommandType commandType; switch (invMan._panelContent) { case kPanelContentChest: - if (champMan._leaderIndex == kChampionNone) // if no leader + if (champMan._g411_leaderIndex == kM1_ChampionNone) // if no leader return; commandType = getCommandTypeFromMouseInput(gMouseInput_PanelChest, Common::Point(x, y), kLeftMouseButton); if (commandType != kCommandNone) warning("MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox"); break; case kPanelContentResurrectReincarnate: - if (!champMan._leaderEmptyHanded) + if (!champMan._g415_leaderEmptyHanded) break; commandType = getCommandTypeFromMouseInput(gMouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), kLeftMouseButton); if (commandType != kCommandNone) diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 11ccd944d5..0779a7ee0f 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -55,29 +55,29 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { EventManager &em = *_vm->_eventMan; DisplayMan &dm = *_vm->_displayMan; - if ((championIndex != kChampionCloseInventory) && !cm._champions[championIndex]._currHealth) + if ((championIndex != k4_ChampionCloseInventory) && !cm._champions[championIndex]._currHealth) return; if (_vm->_pressingEye || _vm->_pressingMouth) return; _vm->_stopWaitingForPlayerInput = true; int16 invChampOrdinal = _inventoryChampionOrdinal; // copy, as the original will be edited if (_vm->indexToOrdinal(championIndex) == invChampOrdinal) { - championIndex = kChampionCloseInventory; + championIndex = k4_ChampionCloseInventory; } Champion *champion; if (invChampOrdinal) { - _inventoryChampionOrdinal = _vm->indexToOrdinal(kChampionNone); + _inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone); closeChest(); champion = &cm._champions[_vm->ordinalToIndex(invChampOrdinal)]; - if (champion->_currHealth && !cm._candidateChampionOrdinal) { - champion->setAttributeFlag(kChampionAttributeStatusBox, true); + if (champion->_currHealth && !cm._g299_candidateChampionOrdinal) { + champion->setAttributeFlag(k0x1000_ChampionAttributeStatusBox, true); cm.drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal)); } - if (cm._partyIsSleeping) { + if (cm._g300_partyIsSleeping) { return; } - if (championIndex == kChampionCloseInventory) { + if (championIndex == k4_ChampionCloseInventory) { em._refreshMousePointerInMainLoop = true; _vm->_menuMan->drawMovementArrows(); em._secondaryMouseInput = gSecondaryMouseInput_Movement; @@ -97,23 +97,23 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { int16 w = dm.getWidth(k17_InventoryGraphicIndice); int16 h = dm.getHeight(k17_InventoryGraphicIndice); dm.blitToScreen(dm.getBitmap(k17_InventoryGraphicIndice), w, 0, 0, 0, w, 0, h, k255_ColorNoTransparency, g296_DungeonViewport); - if (cm._candidateChampionOrdinal) { + if (cm._g299_candidateChampionOrdinal) { dm.clearScreenBox(k12_ColorDarkestGray, gBoxFloppyZzzCross, g296_DungeonViewport); } _vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "HEALTH"); _vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "STAMINA"); _vm->_textMan->printToViewport(5, 132, k13_ColorLightestGray, "MANA"); - for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) { + for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) { _vm->_championMan->drawSlot(championIndex, (ChampionSlot)slotIndex); } - champion->setAttributeFlag(kChampionAttributeViewport, true); - champion->setAttributeFlag(kChampionAttributeStatusBox, true); - champion->setAttributeFlag(kChampionAttributePanel, true); - champion->setAttributeFlag(kChampionAttributeLoad, true); - champion->setAttributeFlag(kChampionAttributeStatistics, true); - champion->setAttributeFlag(kChampionAttributeNameTitle, true); + champion->setAttributeFlag(k0x4000_ChampionAttributeViewport, true); + champion->setAttributeFlag(k0x1000_ChampionAttributeStatusBox, true); + champion->setAttributeFlag(k0x0800_ChampionAttributePanel, true); + champion->setAttributeFlag(k0x0200_ChampionAttributeLoad, true); + champion->setAttributeFlag(k0x0100_ChampionAttributeStatistics, true); + champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true); cm.drawChampionState(championIndex); em._mousePointerBitmapUpdated = true; @@ -183,12 +183,12 @@ void InventoryMan::drawPanel() { closeChest(); // possibility of BUG0_48 ChampionMan &cm = *_vm->_championMan; - if (cm._candidateChampionOrdinal) { + if (cm._g299_candidateChampionOrdinal) { drawPanelResurrectReincarnate(); return; } - Thing thing = cm._champions[_vm->ordinalToIndex(_inventoryChampionOrdinal)].getSlot(kChampionSlotActionHand); + Thing thing = cm._champions[_vm->ordinalToIndex(_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand); _panelContent = kPanelContentFoodWaterPoisoned; switch (thing.getType()) { @@ -308,7 +308,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is _openChest = thingToOpen; if (!isPressingEye) { - objMan.drawIconInSlotBox(kSlotBoxInventoryActionHand, kIconIndiceContainerChestOpen); + objMan.drawIconInSlotBox(kSlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen); } dispMan.blitToScreen(dispMan.getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, gBoxPanel, k8_ColorRed); @@ -325,7 +325,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is thing = _vm->_dungeonMan->getNextThing(thing); } while (chestSlotIndex < 8) { - objMan.drawIconInSlotBox(chestSlotIndex + kSlotBoxChestFirstSlot, kIconIndiceNone); + objMan.drawIconInSlotBox(chestSlotIndex + kSlotBoxChestFirstSlot, kM1_IconIndiceNone); _chestSlots[chestSlotIndex++] = Thing::_none; } } @@ -448,15 +448,15 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { char *descString = nullptr; char str[40]; - if (iconIndex == kIconIndiceJunkChampionBones) { + if (iconIndex == k147_IconIndiceJunkChampionBones) { strcpy(str, champMan._champions[((Junk*)rawThingPtr)->getChargeCount()]._name); // TODO: localization strcat(str, " "); // TODO: localization strcat(str, objMan._objectNames[iconIndex]); // TODO: localization descString = str; } else if ((thingType == kPotionThingType) - && (iconIndex != kIconIndicePotionWaterFlask) - && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), kChampionSkillPriest) > 1)) { + && (iconIndex != k163_IconIndicePotionWaterFlask) + && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) { str[0] = '_' + ((Potion*)rawThingPtr)->getPower() / 40; str[1] = ' '; str[2] = '\0'; @@ -480,8 +480,8 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { potentialAttribMask = kDescriptionMaskCursed | kDescriptionMaskPoisoned | kDescriptionMaskBroken; Weapon *weapon = (Weapon*)rawThingPtr; actualAttribMask = (weapon->getCursed() << 3) | (weapon->getPoisoned() << 1) | (weapon->getBroken() << 2); - if ((iconIndex >= kIconIndiceWeaponTorchUnlit) - && (iconIndex <= kIconIndiceWeaponTorchLit) + if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) + && (iconIndex <= k7_IconIndiceWeaponTorchLit) && (weapon->getChargeCount() == 0)) { drawPanelObjectDescriptionString("(BURNT OUT)"); // TODO: localization } @@ -501,7 +501,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { } case kJunkThingType: { Junk *junk = (Junk*)rawThingPtr; - if ((iconIndex >= kIconIndiceJunkWater) && (iconIndex <= kIconIndiceJunkWaterSkin)) { + if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) { potentialAttribMask = 0; switch (junk->getChargeCount()) { case 0: @@ -518,7 +518,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { break; } drawPanelObjectDescriptionString(descString); - } else if ((iconIndex >= kIconIndiceJunkCompassNorth) && (iconIndex <= kIconIndiceJunkCompassWest)) { + } else if ((iconIndex >= k0_IconIndiceJunkCompassNorth) && (iconIndex <= k3_IconIndiceJunkCompassWest)) { potentialAttribMask = 0; strcpy(str, "PARTY FACING "); // TODO: localization static char* directionName[4] = {"NORTH", "EAST", "SOUTH", "WEST"}; // G0430_apc_DirectionNames // TODO: localization diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 463e02dade..42f8bad5e0 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -44,8 +44,8 @@ LoadgameResponse LoadsaveMan::loadgame() { if (newGame) { _vm->_restartGameAllowed = false; - cm._partyChampionCount = 0; - cm._leaderHandObject = Thing::_none; + cm._g305_partyChampionCount = 0; + cm._414_leaderHandObject = Thing::_none; _vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536); } else { assert(false); @@ -61,7 +61,7 @@ LoadgameResponse LoadsaveMan::loadgame() { assert(false); // MISSING CODE: load game } - cm._partyDead = false; + cm._303_partyDead = false; return kLoadgameSuccess; } diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 74ca0ac00c..19912adc0a 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -68,11 +68,11 @@ void MenuMan::drawMovementArrows() { } void MenuMan::clearActingChampion() { ChampionMan &cm = *_vm->_championMan; - if (cm._actingChampionOrdinal) { - cm._actingChampionOrdinal--; - cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true); - cm.drawChampionState((ChampionIndex)cm._actingChampionOrdinal); - cm._actingChampionOrdinal = _vm->indexToOrdinal(kChampionNone); + if (cm._g506_actingChampionOrdinal) { + cm._g506_actingChampionOrdinal--; + cm._champions[cm._g506_actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true); + cm.drawChampionState((ChampionIndex)cm._g506_actingChampionOrdinal); + cm._g506_actingChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone); _refreshActionArea = true; } } @@ -94,10 +94,10 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) { return; } byte *bitmapIcon = dm._g74_tmpBitmap; - Thing thing = champion.getSlot(kChampionSlotActionHand); + Thing thing = champion.getSlot(k1_ChampionSlotActionHand); IconIndice iconIndex; if (thing == Thing::_none) { - iconIndex = kIconIndiceActionEmptyHand; + iconIndex = k201_IconIndiceActionEmptyHand; } else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) { iconIndex = _vm->_objectMan->getIconIndex(thing); } else { @@ -114,13 +114,13 @@ T0386006: box2._y1 = 95; box2._y2 = 110 + 1; dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2); - if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) { + if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } } void MenuMan::drawDisabledMenu() { - if (!_vm->_championMan->_partyIsSleeping) { + if (!_vm->_championMan->_g300_partyIsSleeping) { warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); _vm->_displayMan->_g578_useByteBoxCoordinates = false; if (_vm->_inventoryMan->_inventoryChampionOrdinal) { @@ -139,39 +139,39 @@ void MenuMan::drawDisabledMenu() { void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() { ChampionMan &champMan = *_vm->_championMan; - if (!champMan._partyChampionCount) + if (!champMan._g305_partyChampionCount) return; Champion *champ = nullptr; - if (champMan._partyIsSleeping || champMan._candidateChampionOrdinal) { - if (champMan._actingChampionOrdinal) { + if (champMan._g300_partyIsSleeping || champMan._g299_candidateChampionOrdinal) { + if (champMan._g506_actingChampionOrdinal) { clearActingChampion(); return; } - if (!champMan._candidateChampionOrdinal) + if (!champMan._g299_candidateChampionOrdinal) return; } else { champ = champMan._champions; - int16 champIndex = kChampionFirst; + int16 champIndex = k0_ChampionFirst; do { - if ((champIndex != champMan._leaderIndex) - && (_vm->indexToOrdinal(champIndex) != champMan._actingChampionOrdinal) + if ((champIndex != champMan._g411_leaderIndex) + && (_vm->indexToOrdinal(champIndex) != champMan._g506_actingChampionOrdinal) && (champ->_maximumDamageReceived) && (champ->_dir != champ->_directionMaximumDamageReceived)) { champ->_dir = (direction)champ->_directionMaximumDamageReceived; - champ->setAttributeFlag(kChampionAttributeIcon, true); + champ->setAttributeFlag(k0x0400_ChampionAttributeIcon, true); champMan.drawChampionState((ChampionIndex)champIndex); } champ->_maximumDamageReceived = 0; champ++; champIndex++; - } while (champIndex < champMan._partyChampionCount); + } while (champIndex < champMan._g305_partyChampionCount); } if (_refreshActionArea) { - if (!champMan._actingChampionOrdinal) { + if (!champMan._g506_actingChampionOrdinal) { if (_actionDamage) { warning("MISSING CODE: F0385_MENUS_DrawActionDamage"); _actionDamage = 0; @@ -181,8 +181,8 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() { } } else { _actionAreaContainsIcons = false; - champ->setAttributeFlag(kChampionAttributeActionHand, true); - champMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(champMan._actingChampionOrdinal)); + champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true); + champMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal)); warning("MISSING CODE: F0387_MENUS_DrawActionArea"); } } @@ -200,16 +200,16 @@ void MenuMan::drawActionArea() { dispMan._g578_useByteBoxCoordinates = false; dispMan.clearScreenBox(k0_ColorBlack, gBoxActionArea); if (_actionAreaContainsIcons) { - for (uint16 champIndex = kChampionFirst; champIndex < champMan._partyChampionCount; ++champIndex) + for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._g305_partyChampionCount; ++champIndex) drawActionIcon((ChampionIndex)champIndex); - } else if (champMan._actingChampionOrdinal) { + } else if (champMan._g506_actingChampionOrdinal) { Box box = gBoxActionArea3ActionMenu; - if (_actionList._actionIndices[2] == kChampionActionNone) + if (_actionList._actionIndices[2] == k255_ChampionActionNone) box = gBoxActionArea2ActionMenu; - if (_actionList._actionIndices[1] == kChampionActionNone) + if (_actionList._actionIndices[1] == k255_ChampionActionNone) box = gBoxActionArea1ActionMenu; dispMan.blitToScreen(dispMan.getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, box, k255_ColorNoTransparency); - textMan.printWithTrailingSpacesToScreen(235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._actingChampionOrdinal)]._name, + textMan.printWithTrailingSpacesToScreen(235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name, kChampionNameMaximumLength); for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) { textMan.printWithTrailingSpacesToScreen(241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack, @@ -232,7 +232,7 @@ const char *gChampionActionNames[44] = { "BRANDISH", "THROW", "FUSE"}; const char* MenuMan::getActionName(ChampionAction actionIndex) { - return (actionIndex == kChampionActionNone) ? "" : gChampionActionNames[actionIndex]; + return (actionIndex == k255_ChampionActionNone) ? "" : gChampionActionNames[actionIndex]; } @@ -249,9 +249,9 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) { champCurrHealth[i] = champMan._champions[i]._currHealth; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); dispMan.clearScreenBox(k0_ColorBlack, gBoxSpellAreaControls); - int16 champCount = champMan._partyChampionCount; + int16 champCount = champMan._g305_partyChampionCount; switch (champIndex) { - case kChampionFirst: + case k0_ChampionFirst: warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); textMan.printTextToScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ._name); if (champCount) { @@ -272,14 +272,14 @@ labelChamp3: } } break; - case kChampionSecond: + case k1_ChampionSecond: if (champCurrHealth[0]) { warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); } warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); textMan.printTextToScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ._name); goto labelChamp2; - case kChampionThird: + case k2_ChampionThird: if (champCurrHealth[0]) { warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); } @@ -289,7 +289,7 @@ labelChamp3: warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); textMan.printTextToScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ._name); goto labelChamp3; - case kChampionFourth: + case k3_ChampionFourth: if (champCurrHealth[0]) { warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); } @@ -312,7 +312,7 @@ labelChamp3: void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) { DisplayMan &dispMan = *_vm->_displayMan; - Champion &champ = _vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex]; + Champion &champ = _vm->_championMan->_champions[_vm->_championMan->_g514_magicCasterChampionIndex]; if (spellAreaBitmapLine == kSpellAreaAvailableSymbols) { dispMan._g578_useByteBoxCoordinates = false; dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 12, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, k255_ColorNoTransparency); @@ -340,16 +340,16 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) { ChampionMan &champMan = *_vm->_championMan; DisplayMan &dispMan = *_vm->_displayMan; - if ((champIndex == champMan._magicCasterChampionIndex) - || ((champIndex != kChampionNone) && !champMan._champions[champIndex]._currHealth)) + if ((champIndex == champMan._g514_magicCasterChampionIndex) + || ((champIndex != kM1_ChampionNone) && !champMan._champions[champIndex]._currHealth)) return; - if (champMan._magicCasterChampionIndex == kChampionNone) { + if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) { warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); dispMan.blitToScreen(dispMan.getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, gBoxSpellArea); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } - if (champIndex == kChampionNone) { - champMan._magicCasterChampionIndex = kChampionNone; + if (champIndex == kM1_ChampionNone) { + champMan._g514_magicCasterChampionIndex = kM1_ChampionNone; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); dispMan._g578_useByteBoxCoordinates = false; dispMan.clearScreenBox(k0_ColorBlack, gBoxSpellArea); @@ -357,7 +357,7 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) { return; } - champMan._magicCasterChampionIndex = (ChampionIndex)champIndex; + champMan._g514_magicCasterChampionIndex = (ChampionIndex)champIndex; buildSpellAreaLine(kSpellAreaAvailableSymbols); warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); drawSpellAreaControls((ChampionIndex)champIndex); diff --git a/engines/dm/menus.h b/engines/dm/menus.h index a8df73531f..b591872011 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -43,7 +43,7 @@ public: ActionList() { for (uint16 i = 0; i < 3; ++i) { _minimumSkillLevel[i] = 0; - _actionIndices[i] = kChampionActionNone; + _actionIndices[i] = k255_ChampionActionNone; } } }; // @ ACTION_LIST diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 1511146d69..0aca699aaf 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -44,7 +44,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 bool atLeastOneSensorWasTriggered = false; - Thing leaderHandObject = champMan._leaderHandObject; + Thing leaderHandObject = champMan._414_leaderHandObject; int16 sensorCountToProcessPerCell[4]; uint16 cell; for (cell = kCellNorthWest; cell < kCellSouthWest; ++cell) { @@ -73,7 +73,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 SensorType sensorType = sensor->getType(); if (sensorType == kSensorDisabled) goto T0275058_ProceedToNextThing; - if ((champMan._leaderIndex == kChampionNone) && (sensorType != kSensorWallChampionPortrait)) + if ((champMan._g411_leaderIndex == kM1_ChampionNone) && (sensorType != kSensorWallChampionPortrait)) goto T0275058_ProceedToNextThing; if (cell != cellParam) goto T0275058_ProceedToNextThing; @@ -88,7 +88,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 } break; case kSensorWallOrnClickWithAnyObj: - doNotTriggerSensor = (champMan._leaderEmptyHanded != sensor->getRevertEffectA()); + doNotTriggerSensor = (champMan._g415_leaderEmptyHanded != sensor->getRevertEffectA()); break; case kSensorWallOrnClickWithSpecObjRemovedSensor: case kSensorWallOrnClickWithSpecObjRemovedRotateSensors: @@ -111,13 +111,13 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 case kSensorWallObjGeneratorRotateSensors: if (sensorCountToProcessPerCell[cell]) goto T0275058_ProceedToNextThing; - doNotTriggerSensor = !champMan._leaderEmptyHanded; + doNotTriggerSensor = !champMan._g415_leaderEmptyHanded; if (!doNotTriggerSensor) { warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect"); } break; case kSensorWallSingleObjStorageRotateSensors: - if (champMan._leaderEmptyHanded) { + if (champMan._g415_leaderEmptyHanded) { warning("MISSING CODE: F0273_SENSOR_GetObjectOfTypeInCell"); warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList"); warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand"); @@ -128,7 +128,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 leaderHandObject = Thing::_none; } warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect"); - if ((sensorEffect == kSensorEffHold) && !champMan._leaderEmptyHanded) { + if ((sensorEffect == kSensorEffHold) && !champMan._g415_leaderEmptyHanded) { doNotTriggerSensor = true; } else { doNotTriggerSensor = false; @@ -164,7 +164,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 if (sensor->getAudibleA()) { warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } - if (!champMan._leaderEmptyHanded && + if (!champMan._g415_leaderEmptyHanded && ((sensorType == kSensorWallOrnClickWithSpecObjRemoved) || (sensorType == kSensorWallOrnClickWithSpecObjRemovedRotateSensors) || (sensorType == kSensorWallOrnClickWithSpecObjRemovedSensor))) { @@ -174,7 +174,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 leaderHandObject = Thing::_none; } else { warning("MISSING CODE: (leaderHandObject = F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator(sensorData)"); - if (champMan._leaderEmptyHanded && (sensorType == kSensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_none)) { + if (champMan._g415_leaderEmptyHanded && (sensorType == kSensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_none)) { warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand"); } } diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index dd3550200d..ae67904beb 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -123,7 +123,7 @@ void ObjectMan::loadObjectNames() { IconIndice ObjectMan::getObjectType(Thing thing) { if (thing == Thing::_none) - return kIconIndiceNone; + return kM1_IconIndiceNone; int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing); if (objectInfoIndex != -1) { @@ -137,41 +137,41 @@ byte gChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, IconIndice ObjectMan::getIconIndex(Thing thing) { IconIndice iconIndex = getObjectType(thing); - if ((iconIndex != kIconIndiceNone) && - (((iconIndex < kIconIndiceWeaponDagger) && (iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error - ((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) || - (iconIndex == kIconIndicePotionEmptyFlask)) + if ((iconIndex != kM1_IconIndiceNone) && + (((iconIndex < k32_IconIndiceWeaponDagger) && (iconIndex >= k0_IconIndiceJunkCompassNorth)) || // < instead of <= is no error + ((iconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (iconIndex <= k163_IconIndicePotionWaterFlask)) || + (iconIndex == k195_IconIndicePotionEmptyFlask)) ) { uint16 *rawType = _vm->_dungeonMan->getThingData(thing); switch (iconIndex) { - case kIconIndiceJunkCompassNorth: + case k0_IconIndiceJunkCompassNorth: iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_currMap._partyDir); break; - case kIconIndiceWeaponTorchUnlit: { + case k4_IconIndiceWeaponTorchUnlit: { Weapon weapon(rawType); if (weapon.isLit()) { iconIndex = (IconIndice)(iconIndex + gChargeCountToTorchType[weapon.getChargeCount()]); } break; } - case kIconIndiceScrollOpen: + case k30_IconIndiceScrollOpen: if (Scroll(rawType).getClosed()) { iconIndex = (IconIndice)(iconIndex + 1); } break; - case kIconIndiceJunkWater: - case kIconIndiceJunkIllumuletUnequipped: - case kIconIndiceJunkJewelSymalUnequipped: + case k8_IconIndiceJunkWater: + case k12_IconIndiceJunkIllumuletUnequipped: + case k10_IconIndiceJunkJewelSymalUnequipped: if (Junk(rawType).getChargeCount()) { iconIndex = (IconIndice)(iconIndex + 1); } break; - case kIconIndiceWeaponBoltBladeStormEmpty: - case kIconIndiceWeaponFlamittEmpty: - case kIconIndiceWeaponStormringEmpty: - case kIconIndiceWeaponFuryRaBladeEmpty: - case kIconIndiceWeaponEyeOfTimeEmpty: - case kIconIndiceWeaponStaffOfClawsEmpty: + case k23_IconIndiceWeaponBoltBladeStormEmpty: + case k14_IconIndiceWeaponFlamittEmpty: + case k18_IconIndiceWeaponStormringEmpty: + case k25_IconIndiceWeaponFuryRaBladeEmpty: + case k16_IconIndiceWeaponEyeOfTimeEmpty: + case k20_IconIndiceWeaponStaffOfClawsEmpty: if (Weapon(rawType).getChargeCount()) { iconIndex = (IconIndice)(iconIndex + 1); } @@ -201,7 +201,7 @@ void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { SlotBox *slotBox = &_slotBoxes[slotBoxIndex]; slotBox->_iconIndex = iconIndex; // yes, this modifies the global array - if (slotBox->_iconIndex == kIconIndiceNone) { + if (slotBox->_iconIndex == kM1_IconIndiceNone) { return; } @@ -237,7 +237,7 @@ void ObjectMan::drawLeaderObjectName(Thing thing) { IconIndice iconIndex = getIconIndex(thing); char *objName; char objectNameBuffer[16]; - if (iconIndex == kIconIndiceJunkChampionBones) { + if (iconIndex == k147_IconIndiceJunkChampionBones) { Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing); strcpy(objectNameBuffer, _vm->_championMan->_champions[junk->getChargeCount()]._name); strcat(objectNameBuffer, _objectNames[iconIndex]); -- cgit v1.2.3 From a9cda9df7c4f03aadf080c6c166b7a1a02987a1b Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:43:17 +0200 Subject: DM: More renaming --- engines/dm/champion.cpp | 56 ++--- engines/dm/dm.cpp | 44 ++-- engines/dm/dm.h | 58 ++--- engines/dm/dungeonman.cpp | 572 +++++++++++++++++++++++----------------------- engines/dm/dungeonman.h | 422 +++++++++++++++++----------------- engines/dm/eventman.cpp | 68 +++--- engines/dm/gfx.cpp | 228 +++++++++--------- engines/dm/group.cpp | 10 +- engines/dm/inventory.cpp | 32 +-- engines/dm/loadsave.cpp | 6 +- engines/dm/menus.cpp | 2 +- engines/dm/movesens.cpp | 54 ++--- engines/dm/objectman.cpp | 4 +- engines/dm/timeline.cpp | 2 +- 14 files changed, 779 insertions(+), 779 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 9302216766..b8dac7ff3e 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -142,13 +142,13 @@ void ChampionMan::applyModifiersToStatistics(Champion* champ, ChampionSlot slotI int16 statIndex; int16 modifier = 0; ThingType thingType = thing.getType(); - if (((thingType == kWeaponThingType) || (thingType == kArmourThingType)) + if (((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType)) && (slotIndex >= k0_ChampionSlotReadyHand) && (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) { Weapon *weapon = (Weapon*)_vm->_dungeonMan->getThingData(thing); Armour *armour = (Armour*)_vm->_dungeonMan->getThingData(thing); - if (((thingType == kWeaponThingType) && weapon->getCursed()) - || ((thingType == kArmourThingType) && armour->getCursed())) { + if (((thingType == k5_WeaponThingType) && weapon->getCursed()) + || ((thingType == k6_ArmourThingType) && armour->getCursed())) { statIndex = k0_ChampionStatLuck; modifier = -3; goto T0299044_ApplyModifier; @@ -437,7 +437,7 @@ ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { } void ChampionMan::resetDataToStartGame() { - if (!_vm->_dungeonMan->_messages._newGame) { + if (!_vm->_dungeonMan->_messages._g298_newGame) { warning("MISSING CODE: stuff for resetting for loaded games"); assert(false); } @@ -468,26 +468,26 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { champ->_actionIndex = k255_ChampionActionNone; champ->_enableActionEventIndex = -1; champ->_hideDamageReceivedIndex = -1; - champ->_dir = dunMan._currMap._partyDir; + champ->_dir = dunMan._currMap._g308_partyDir; ViewCell AL_0_viewCell = k0_ViewCellFronLeft; - while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3)) != kM1_ChampionNone) + while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._g308_partyDir) & 3)) != kM1_ChampionNone) AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); - champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._partyDir) & 3); + champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._g308_partyDir) & 3); champ->clearAttributes(k0x0400_ChampionAttributeIcon); - champ->_directionMaximumDamageReceived = dunMan._currMap._partyDir; + champ->_directionMaximumDamageReceived = dunMan._currMap._g308_partyDir; champ->_food = 1500 + _vm->_rnd->getRandomNumber(256); champ->_water = 1500 + _vm->_rnd->getRandomNumber(256); int16 AL_0_slotIndex_Red; for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) { champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none); } - Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._partyPosX, dunMan._currMap._partyPosY); - while (thing.getType() != kTextstringType) { + Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._g306_partyPosX, dunMan._currMap._g307_partyPosY); + while (thing.getType() != k2_TextstringType) { thing = dunMan.getNextThing(thing); } char decodedChampionText[77]; char* character_Green = decodedChampionText; - dunMan.decodeText(character_Green, thing, (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible)); + dunMan.decodeText(character_Green, thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible)); int16 AL_0_characterIndex = 0; uint16 AL_2_character; while ((AL_2_character = *character_Green++) != '\n') { @@ -557,21 +557,21 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { _vm->_menuMan->drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1)); } - int16 mapX = _vm->_dungeonMan->_currMap._partyPosX; - int16 mapY = _vm->_dungeonMan->_currMap._partyPosY; + int16 mapX = _vm->_dungeonMan->_currMap._g306_partyPosX; + int16 mapY = _vm->_dungeonMan->_currMap._g307_partyPosY; - uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir)); - mapX += _vm->_dirIntoStepCountEast[dunMan._currMap._partyDir]; - mapY += _vm->_dirIntoStepCountNorth[dunMan._currMap._partyDir]; + uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._g308_partyDir)); + mapX += _vm->_dirIntoStepCountEast[dunMan._currMap._g308_partyDir]; + mapY += _vm->_dirIntoStepCountNorth[dunMan._currMap._g308_partyDir]; thing = dunMan.getSquareFirstThing(mapX, mapY); AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1; uint16 slotIndex_Green; while (thing != Thing::_endOfList) { ThingType AL_2_thingType = thing.getType(); - if ((AL_2_thingType > kSensorThingType) && (thing.getCell() == championObjectsCell)) { - int16 objectAllowedSlots = gObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots(); + if ((AL_2_thingType > k3_SensorThingType) && (thing.getCell() == championObjectsCell)) { + int16 objectAllowedSlots = g237_ObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots(); switch (AL_2_thingType) { - case kArmourThingType: + case k6_ArmourThingType: for (slotIndex_Green = k2_ChampionSlotHead; slotIndex_Green <= k5_ChampionSlotFeet; slotIndex_Green++) { if (objectAllowedSlots & gSlotMasks[slotIndex_Green]) goto T0280048; @@ -582,15 +582,15 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { goto T0280046; } break; - case kWeaponThingType: + case k5_WeaponThingType: if (champ->getSlot(k1_ChampionSlotActionHand) == Thing::_none) { slotIndex_Green = k1_ChampionSlotActionHand; } else { goto T0280046; } break; - case kScrollThingType: - case kPotionThingType: + case k7_ScrollThingType: + case k8_PotionThingType: if (champ->getSlot(k11_ChampionSlotPouch_1) == Thing::_none) { slotIndex_Green = k11_ChampionSlotPouch_1; } else if (champ->getSlot(k6_ChampionSlotPouch_2) == Thing::_none) { @@ -599,8 +599,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { goto T0280046; } break; - case kContainerThingType: - case kJunkThingType: + case k9_ContainerThingType: + case k10_JunkThingType: T0280046: if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) { slotIndex_Green = k10_ChampionSlotNeck; @@ -850,19 +850,19 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { } { // block so goto won't skip AL_0_championIconIndex initialization - int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._partyDir); + int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._g308_partyDir); if ((champAttributes & k28_ChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) { dispMan.clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]); - dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._partyDir) * 19, 0, + dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._g308_partyDir) * 19, 0, g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray); } } if ((champAttributes & k0x0800_ChampionAttributePanel) && isInventoryChamp) { - if (_vm->_pressingMouth) { + if (_vm->_g333_pressingMouth) { invMan.drawPanelFoodWaterPoisoned(); - } else if (_vm->_pressingEye) { + } else if (_vm->_g331_pressingEye) { if (_g415_leaderEmptyHanded) { warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics"); } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index adc842b0ab..83fb506b6a 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -106,14 +106,14 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _movsens = nullptr; _groupMan = nullptr; _timeline = nullptr; - _stopWaitingForPlayerInput = false; - _gameTimeTicking = false; - _restartGameAllowed = false; - _pressingEye = false; - _pressingMouth = false; - _stopPressingEye = false; - _stopPressingMouth = false; - _highlightBoxInversionRequested = false; + _g321_stopWaitingForPlayerInput = false; + _g301_gameTimeTicking = false; + _g524_restartGameAllowed = false; + _g331_pressingEye = false; + _g333_pressingMouth = false; + _g332_stopPressingEye = false; + _g334_stopPressingMouth = false; + _g340_highlightBoxInversionRequested = false; debug("DMEngine::DMEngine"); } @@ -164,11 +164,11 @@ void DMEngine::initializeGame() { void DMEngine::startGame() { - _pressingEye = false; - _stopPressingEye = false; - _pressingMouth = false; - _stopPressingMouth = false; - _highlightBoxInversionRequested = false; + _g331_pressingEye = false; + _g332_stopPressingEye = false; + _g333_pressingMouth = false; + _g334_stopPressingMouth = false; + _g340_highlightBoxInversionRequested = false; _eventMan->_highlightBoxEnabled = false; _championMan->_g300_partyIsSleeping = false; _championMan->_g506_actingChampionOrdinal = indexToOrdinal(kM1_ChampionNone); @@ -179,9 +179,9 @@ void DMEngine::startGame() { _eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement; warning("MISSING CODE: set primary/secondary keyboard input"); - processNewPartyMap(_dungeonMan->_currMap._currPartyMapIndex); + processNewPartyMap(_dungeonMan->_currMap._g309_currPartyMapIndex); - if (!_dungeonMan->_messages._newGame) { + if (!_dungeonMan->_messages._g298_newGame) { warning("TODO: loading game"); } else { _displayMan->_g578_useByteBoxCoordinates = false; @@ -191,7 +191,7 @@ void DMEngine::startGame() { warning("TODO: build copper"); _menuMan->drawMovementArrows(); _championMan->resetDataToStartGame(); - _gameTimeTicking = true; + _g301_gameTimeTicking = true; } void DMEngine::processNewPartyMap(uint16 mapIndex) { @@ -233,28 +233,28 @@ Common::Error DMEngine::run() { void DMEngine::gameloop() { warning("DUMMY CODE SETTING PARTY POS AND DIRECTION"); - _dungeonMan->_currMap._partyPosX = 10; - _dungeonMan->_currMap._partyPosY = 4; - _dungeonMan->_currMap._partyDir = kDirNorth; + _dungeonMan->_currMap._g306_partyPosX = 10; + _dungeonMan->_currMap._g307_partyPosY = 4; + _dungeonMan->_currMap._g308_partyDir = kDirNorth; warning("DUMMY CODE: setting InventoryMan::_inventoryChampionOrdinal to zero"); _inventoryMan->_inventoryChampionOrdinal = 0; warning("DUMMY CODE: clearing screen to black"); // in loop below while (true) { - _stopWaitingForPlayerInput = false; + _g321_stopWaitingForPlayerInput = false; _menuMan->refreshActionAreaAndSetChampDirMaxDamageReceived(); //do { _eventMan->processInput(); _eventMan->processCommandQueue(); - //} while (!_stopWaitingForPlayerInput || !_gameTimeTicking); + //} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking); if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { Box box(0, 224, 0, 126); _displayMan->clearScreenBox(k0_ColorBlack, box, g296_DungeonViewport); // dummy code - _displayMan->drawDungeon(_dungeonMan->_currMap._partyDir, _dungeonMan->_currMap._partyPosX, _dungeonMan->_currMap._partyPosY); + _displayMan->drawDungeon(_dungeonMan->_currMap._g308_partyDir, _dungeonMan->_currMap._g306_partyPosX, _dungeonMan->_currMap._g307_partyPosY); } // DUMMY CODE: next line _menuMan->drawMovementArrows(); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 814b89da4e..4505c746c0 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -71,29 +71,29 @@ void clearFlag(uint16 &val, uint16 mask); enum ThingType { - kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value - kDoorThingType = 0, - kTeleporterThingType = 1, - kTextstringType = 2, - kSensorThingType = 3, - kGroupThingType = 4, - kWeaponThingType = 5, - kArmourThingType = 6, - kScrollThingType = 7, - kPotionThingType = 8, - kContainerThingType = 9, - kJunkThingType = 10, - kProjectileThingType = 14, - kExplosionThingType = 15, - kThingTypeTotal = 16 // +1 than the last (explosionThingType) + kM1_PartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value + k0_DoorThingType = 0, + k1_TeleporterThingType = 1, + k2_TextstringType = 2, + k3_SensorThingType = 3, + k4_GroupThingType = 4, + k5_WeaponThingType = 5, + k6_ArmourThingType = 6, + k7_ScrollThingType = 7, + k8_PotionThingType = 8, + k9_ContainerThingType = 9, + k10_JunkThingType = 10, + k14_ProjectileThingType = 14, + k15_ExplosionThingType = 15, + k16_ThingTypeTotal = 16 // +1 than the last (explosionThingType) }; // @ C[00..15]_THING_TYPE_... enum Cell { - kCellAny = -1, // @ CM1_CELL_ANY - kCellNorthWest = 0, // @ C00_CELL_NORTHWEST - kCellNorthEast = 1, // @ C01_CELL_NORTHEAST - kCellSouthEast = 2, // @ C02_CELL_SOUTHEAST - kCellSouthWest = 3 // @ C03_CELL_SOUTHWEST + kM1_CellAny = -1, // @ CM1_CELL_ANY + k0_CellNorthWest = 0, // @ C00_CELL_NORTHWEST + k1_CellNorthEast = 1, // @ C01_CELL_NORTHEAST + k2_CellSouthEast = 2, // @ C02_CELL_SOUTHEAST + k3_CellSouthWest = 3 // @ C03_CELL_SOUTHWEST }; class Thing { @@ -168,15 +168,15 @@ public: GroupMan *_groupMan; Timeline *_timeline; - bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput - bool _gameTimeTicking; // @ G0301_B_GameTimeTicking - bool _restartGameAllowed; // @ G0524_B_RestartGameAllowed - uint32 _gameId; // @ G0525_l_GameID, probably useless here - bool _pressingEye; // @ G0331_B_PressingEye - bool _stopPressingEye; // @ G0332_B_StopPressingEye - bool _pressingMouth; // @ G0333_B_PressingMouth - bool _stopPressingMouth; // @ G0334_B_StopPressingMouth - bool _highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested + bool _g321_stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput + bool _g301_gameTimeTicking; // @ G0301_B_GameTimeTicking + bool _g524_restartGameAllowed; // @ G0524_B_RestartGameAllowed + uint32 _g525_gameId; // @ G0525_l_GameID, probably useless here + bool _g331_pressingEye; // @ G0331_B_PressingEye + bool _g332_stopPressingEye; // @ G0332_B_StopPressingEye + bool _g333_pressingMouth; // @ G0333_B_PressingMouth + bool _g334_stopPressingMouth; // @ G0334_B_StopPressingMouth + bool _g340_highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested // TODO: refactor direction into a class int8 _dirIntoStepCountEast[4]; diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 1d74bec094..4ce3c186f9 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -35,7 +35,7 @@ namespace DM { -ObjectInfo gObjectInfo[180] = { // @ G0237_as_Graphic559_ObjectInfo +ObjectInfo g237_ObjectInfo[180] = { // @ G0237_as_Graphic559_ObjectInfo /* { Type, ObjectAspectIndex, ActionSetIndex, AllowedSlots } */ ObjectInfo(30, 1, 0, 0x0500), /* COMPASS Pouch/Chest */ ObjectInfo(144, 0, 0, 0x0200), /* COMPASS Hands */ @@ -218,7 +218,7 @@ ObjectInfo gObjectInfo[180] = { // @ G0237_as_Graphic559_ObjectInfo ObjectInfo(197, 74, 0, 0x0000), /* SOLID KEY */ ObjectInfo(198, 41, 0, 0x0400)}; /* SQUARE KEY Chest */ -ArmourInfo gArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo +ArmourInfo g239_ArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo /* { Weight, Defense, Attributes, Unreferenced } */ ArmourInfo(3, 5, 0x01), /* CAPE */ ArmourInfo(4, 10, 0x01), /* CLOAK OF NIGHT */ @@ -279,7 +279,7 @@ ArmourInfo gArmourInfo[58] = { // G0239_as_Graphic559_ArmourInfo ArmourInfo(3, 16, 0x02), /* BOOTS OF SPEED */ ArmourInfo(2, 3, 0x03)}; /* HALTER */ -WeaponInfo gWeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo +WeaponInfo g238_WeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo /* { Weight, Class, Strength, KineticEnergy, Attributes } */ WeaponInfo(1, 130, 2, 0, 0x2000), /* EYE OF TIME */ WeaponInfo(1, 131, 2, 0, 0x2000), /* STORMRING */ @@ -328,7 +328,7 @@ WeaponInfo gWeaponInfo[46] = { // @ G0238_as_Graphic559_WeaponInfo WeaponInfo(30, 26, 1, 220, 0x207D), /* SPEEDBOW */ WeaponInfo(36, 255, 100, 50, 0x20FF)}; /* THE FIRESTAFF */ -CreatureInfo gCreatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo +CreatureInfo g243_CreatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic559_CreatureInfo /* { CreatureAspectIndex, AttackSoundOrdinal, Attributes, GraphicInfo, MovementTicks, AttackTicks, Defense, BaseHealth, Attack, PoisonAttack, Dexterity, Ranges, Properties, Resistances, AnimationTicks, WoundProbabilities, AttackType } */ @@ -368,73 +368,73 @@ void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, in posY += _vm->_dirIntoStepCountNorth[dir] * stepsRight; } -DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) { - _dunData._columCount = 0; +DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _g277_maps(NULL), _g276_rawMapData(NULL) { + _dunData._g282_columCount = 0; - _dunData._mapsFirstColumnIndex = nullptr; - _dunData._columnsCumulativeSquareThingCount = nullptr; - _dunData._squareFirstThings = nullptr; - _dunData._textData = nullptr; - _dunData._mapData = nullptr; + _dunData._g281_mapsFirstColumnIndex = nullptr; + _dunData._g280_columnsCumulativeSquareThingCount = nullptr; + _dunData._g283_squareFirstThings = nullptr; + _dunData._g260_textData = nullptr; + _dunData._g279_mapData = nullptr; for (int i = 0; i < 16; i++) - _dunData._thingsData[i] = nullptr; + _dunData._g284_thingsData[i] = nullptr; - _currMap._partyDir = kDirNorth; - _currMap._partyPosX = 0; - _currMap._partyPosY = 0; - _currMap._currPartyMapIndex = 0; - _currMap._index = 0; - _currMap._width = 0; - _currMap._height = 0; + _currMap._g308_partyDir = kDirNorth; + _currMap._g306_partyPosX = 0; + _currMap._g307_partyPosY = 0; + _currMap._g309_currPartyMapIndex = 0; + _currMap._g272_index = 0; + _currMap._g273_width = 0; + _currMap._g274_height = 0; - _currMap._data = nullptr; - _currMap._map = nullptr; - _currMap._colCumulativeSquareFirstThingCount = nullptr; + _currMap._g271_data = nullptr; + _currMap._g269_map = nullptr; + _currMap._g270_colCumulativeSquareFirstThingCount = nullptr; - _messages._newGame = true; - _messages._restartGameRequest = false; + _messages._g298_newGame = true; + _messages._g523_restartGameRequest = false; _rawDunFileDataSize = 0; _rawDunFileData = nullptr; - _fileHeader._dungeonId = 0; - _fileHeader._ornamentRandomSeed = 0; - _fileHeader._rawMapDataSize = 0; - _fileHeader._mapCount = 0; - _fileHeader._textDataWordCount = 0; - _fileHeader._partyStartDir = kDirNorth; - _fileHeader._partyStartPosX = 0; - _fileHeader._partyStartPosY = 0; - _fileHeader._squareFirstThingCount = 0; + _g278_fileHeader._dungeonId = 0; + _g278_fileHeader._ornamentRandomSeed = 0; + _g278_fileHeader._rawMapDataSize = 0; + _g278_fileHeader._mapCount = 0; + _g278_fileHeader._textDataWordCount = 0; + _g278_fileHeader._partyStartDir = kDirNorth; + _g278_fileHeader._partyStartPosX = 0; + _g278_fileHeader._partyStartPosY = 0; + _g278_fileHeader._squareFirstThingCount = 0; for (int i = 0; i < 16; i++) - _fileHeader._thingCounts[i] = 0; + _g278_fileHeader._thingCounts[i] = 0; - _maps = nullptr; - _rawMapData = nullptr; + _g277_maps = nullptr; + _g276_rawMapData = nullptr; - _currMapInscriptionWallOrnIndex = 0; - _isFacingAlcove = false; - _isFacingViAltar = false; - _isFacingFountain = false; + _g265_currMapInscriptionWallOrnIndex = 0; + _g286_isFacingAlcove = false; + _g287_isFacingViAltar = false; + _g288_isFacingFountain = false; for (int j = 0; j < 6; j++) - _dungeonViewClickableBoxes[j].setToZero(); + _g291_dungeonViewClickableBoxes[j].setToZero(); } DungeonMan::~DungeonMan() { delete[] _rawDunFileData; - delete[] _maps; - delete[] _dunData._mapsFirstColumnIndex; - delete[] _dunData._columnsCumulativeSquareThingCount; - delete[] _dunData._squareFirstThings; - delete[] _dunData._textData; - delete[] _dunData._mapData; + delete[] _g277_maps; + delete[] _dunData._g281_mapsFirstColumnIndex; + delete[] _dunData._g280_columnsCumulativeSquareThingCount; + delete[] _dunData._g283_squareFirstThings; + delete[] _dunData._g260_textData; + delete[] _dunData._g279_mapData; for (uint16 i = 0; i < 16; ++i) { - if (_dunData._thingsData[i]) - delete[] _dunData._thingsData[i][0]; - delete[] _dunData._thingsData[i]; + if (_dunData._g284_thingsData[i]) + delete[] _dunData._g284_thingsData[i][0]; + delete[] _dunData._g284_thingsData[i]; } } @@ -551,177 +551,177 @@ const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIR const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY void DungeonMan::loadDungeonFile() { - if (_messages._newGame) + if (_messages._g298_newGame) decompressDungeonFile(); Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO); - // initialize _fileHeader - _fileHeader._dungeonId = _fileHeader._ornamentRandomSeed = dunDataStream.readUint16BE(); - _fileHeader._rawMapDataSize = dunDataStream.readUint16BE(); - _fileHeader._mapCount = dunDataStream.readByte(); + // initialize _g278_fileHeader + _g278_fileHeader._dungeonId = _g278_fileHeader._ornamentRandomSeed = dunDataStream.readUint16BE(); + _g278_fileHeader._rawMapDataSize = dunDataStream.readUint16BE(); + _g278_fileHeader._mapCount = dunDataStream.readByte(); dunDataStream.readByte(); // discard 1 byte - _fileHeader._textDataWordCount = dunDataStream.readUint16BE(); + _g278_fileHeader._textDataWordCount = dunDataStream.readUint16BE(); uint16 partyPosition = dunDataStream.readUint16BE(); - _fileHeader._partyStartDir = (direction)((partyPosition >> 10) & 3); - _fileHeader._partyStartPosY = (partyPosition >> 5) & 0x1F; - _fileHeader._partyStartPosX = (partyPosition >> 0) & 0x1F; - _fileHeader._squareFirstThingCount = dunDataStream.readUint16BE(); - for (uint16 i = 0; i < kThingTypeTotal; ++i) - _fileHeader._thingCounts[i] = dunDataStream.readUint16BE(); + _g278_fileHeader._partyStartDir = (direction)((partyPosition >> 10) & 3); + _g278_fileHeader._partyStartPosY = (partyPosition >> 5) & 0x1F; + _g278_fileHeader._partyStartPosX = (partyPosition >> 0) & 0x1F; + _g278_fileHeader._squareFirstThingCount = dunDataStream.readUint16BE(); + for (uint16 i = 0; i < k16_ThingTypeTotal; ++i) + _g278_fileHeader._thingCounts[i] = dunDataStream.readUint16BE(); // init party position and mapindex - if (_messages._newGame) { - _currMap._partyDir = _fileHeader._partyStartDir; - _currMap._partyPosX = _fileHeader._partyStartPosX; - _currMap._partyPosY = _fileHeader._partyStartPosY; - _currMap._currPartyMapIndex = 0; + if (_messages._g298_newGame) { + _currMap._g308_partyDir = _g278_fileHeader._partyStartDir; + _currMap._g306_partyPosX = _g278_fileHeader._partyStartPosX; + _currMap._g307_partyPosY = _g278_fileHeader._partyStartPosY; + _currMap._g309_currPartyMapIndex = 0; } // load map data - delete[] _maps; - _maps = new Map[_fileHeader._mapCount]; - for (uint16 i = 0; i < _fileHeader._mapCount; ++i) { - _maps[i]._rawDunDataOffset = dunDataStream.readUint16BE(); + delete[] _g277_maps; + _g277_maps = new Map[_g278_fileHeader._mapCount]; + for (uint16 i = 0; i < _g278_fileHeader._mapCount; ++i) { + _g277_maps[i]._rawDunDataOffset = dunDataStream.readUint16BE(); dunDataStream.readUint32BE(); // discard 4 bytes - _maps[i]._offsetMapX = dunDataStream.readByte(); - _maps[i]._offsetMapY = dunDataStream.readByte(); + _g277_maps[i]._offsetMapX = dunDataStream.readByte(); + _g277_maps[i]._offsetMapY = dunDataStream.readByte(); uint16 tmp = dunDataStream.readUint16BE(); - _maps[i]._height = tmp >> 11; - _maps[i]._width = (tmp >> 6) & 0x1F; - _maps[i]._level = tmp & 0x1F; // Only used in DMII + _g277_maps[i]._height = tmp >> 11; + _g277_maps[i]._width = (tmp >> 6) & 0x1F; + _g277_maps[i]._level = tmp & 0x1F; // Only used in DMII tmp = dunDataStream.readUint16BE(); - _maps[i]._randFloorOrnCount = tmp >> 12; - _maps[i]._floorOrnCount = (tmp >> 8) & 0xF; - _maps[i]._randWallOrnCount = (tmp >> 4) & 0xF; - _maps[i]._wallOrnCount = tmp & 0xF; + _g277_maps[i]._randFloorOrnCount = tmp >> 12; + _g277_maps[i]._floorOrnCount = (tmp >> 8) & 0xF; + _g277_maps[i]._randWallOrnCount = (tmp >> 4) & 0xF; + _g277_maps[i]._wallOrnCount = tmp & 0xF; tmp = dunDataStream.readUint16BE(); - _maps[i]._difficulty = tmp >> 12; - _maps[i]._creatureTypeCount = (tmp >> 4) & 0xF; - _maps[i]._doorOrnCount = tmp & 0xF; + _g277_maps[i]._difficulty = tmp >> 12; + _g277_maps[i]._creatureTypeCount = (tmp >> 4) & 0xF; + _g277_maps[i]._doorOrnCount = tmp & 0xF; tmp = dunDataStream.readUint16BE(); - _maps[i]._doorSet1 = (tmp >> 12) & 0xF; - _maps[i]._doorSet0 = (tmp >> 8) & 0xF; - _maps[i]._wallSet = (WallSet)((tmp >> 4) & 0xF); - _maps[i]._floorSet = (FloorSet)(tmp & 0xF); + _g277_maps[i]._doorSet1 = (tmp >> 12) & 0xF; + _g277_maps[i]._doorSet0 = (tmp >> 8) & 0xF; + _g277_maps[i]._wallSet = (WallSet)((tmp >> 4) & 0xF); + _g277_maps[i]._floorSet = (FloorSet)(tmp & 0xF); } // TODO: ??? is this - begin - delete[] _dunData._mapsFirstColumnIndex; - _dunData._mapsFirstColumnIndex = new uint16[_fileHeader._mapCount]; + delete[] _dunData._g281_mapsFirstColumnIndex; + _dunData._g281_mapsFirstColumnIndex = new uint16[_g278_fileHeader._mapCount]; uint16 columCount = 0; - for (uint16 i = 0; i < _fileHeader._mapCount; ++i) { - _dunData._mapsFirstColumnIndex[i] = columCount; - columCount += _maps[i]._width + 1; + for (uint16 i = 0; i < _g278_fileHeader._mapCount; ++i) { + _dunData._g281_mapsFirstColumnIndex[i] = columCount; + columCount += _g277_maps[i]._width + 1; } - _dunData._columCount = columCount; + _dunData._g282_columCount = columCount; // TODO: ??? is this - end - uint32 actualSquareFirstThingCount = _fileHeader._squareFirstThingCount; - if (_messages._newGame) // TODO: what purpose does this serve? - _fileHeader._squareFirstThingCount += 300; + uint32 actualSquareFirstThingCount = _g278_fileHeader._squareFirstThingCount; + if (_messages._g298_newGame) // TODO: what purpose does this serve? + _g278_fileHeader._squareFirstThingCount += 300; // TODO: ??? is this - begin - delete[] _dunData._columnsCumulativeSquareThingCount; - _dunData._columnsCumulativeSquareThingCount = new uint16[columCount]; + delete[] _dunData._g280_columnsCumulativeSquareThingCount; + _dunData._g280_columnsCumulativeSquareThingCount = new uint16[columCount]; for (uint16 i = 0; i < columCount; ++i) - _dunData._columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE(); + _dunData._g280_columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE(); // TODO: ??? is this - end // TODO: ??? is this - begin - delete[] _dunData._squareFirstThings; - _dunData._squareFirstThings = new Thing[_fileHeader._squareFirstThingCount]; + delete[] _dunData._g283_squareFirstThings; + _dunData._g283_squareFirstThings = new Thing[_g278_fileHeader._squareFirstThingCount]; for (uint16 i = 0; i < actualSquareFirstThingCount; ++i) - _dunData._squareFirstThings[i].set(dunDataStream.readUint16BE()); - if (_messages._newGame) + _dunData._g283_squareFirstThings[i].set(dunDataStream.readUint16BE()); + if (_messages._g298_newGame) for (uint16 i = 0; i < 300; ++i) - _dunData._squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none; + _dunData._g283_squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none; // TODO: ??? is this - end // load text data - delete[] _dunData._textData; - _dunData._textData = new uint16[_fileHeader._textDataWordCount]; - for (uint16 i = 0; i < _fileHeader._textDataWordCount; ++i) - _dunData._textData[i] = dunDataStream.readUint16BE(); + delete[] _dunData._g260_textData; + _dunData._g260_textData = new uint16[_g278_fileHeader._textDataWordCount]; + for (uint16 i = 0; i < _g278_fileHeader._textDataWordCount; ++i) + _dunData._g260_textData[i] = dunDataStream.readUint16BE(); // TODO: ??? what this - if (_messages._newGame) + if (_messages._g298_newGame) _vm->_timeline->_eventMaxCount = 100; // load things - for (uint16 thingType = kDoorThingType; thingType < kThingTypeTotal; ++thingType) { - uint16 thingCount = _fileHeader._thingCounts[thingType]; - if (_messages._newGame) { - _fileHeader._thingCounts[thingType] = MIN((thingType == kExplosionThingType) ? 768 : 1024, thingCount + gAdditionalThingCounts[thingType]); + for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) { + uint16 thingCount = _g278_fileHeader._thingCounts[thingType]; + if (_messages._g298_newGame) { + _g278_fileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + gAdditionalThingCounts[thingType]); } uint16 thingStoreWordCount = gThingDataWordCount[thingType]; if (thingStoreWordCount == 0) continue; - if (_dunData._thingsData[thingType]) { - delete[] _dunData._thingsData[thingType][0]; - delete[] _dunData._thingsData[thingType]; + if (_dunData._g284_thingsData[thingType]) { + delete[] _dunData._g284_thingsData[thingType][0]; + delete[] _dunData._g284_thingsData[thingType]; } - _dunData._thingsData[thingType] = new uint16*[_fileHeader._thingCounts[thingType]]; - _dunData._thingsData[thingType][0] = new uint16[_fileHeader._thingCounts[thingType] * thingStoreWordCount]; - for (uint16 i = 0; i < _fileHeader._thingCounts[thingType]; ++i) - _dunData._thingsData[thingType][i] = _dunData._thingsData[thingType][0] + i * thingStoreWordCount; + _dunData._g284_thingsData[thingType] = new uint16*[_g278_fileHeader._thingCounts[thingType]]; + _dunData._g284_thingsData[thingType][0] = new uint16[_g278_fileHeader._thingCounts[thingType] * thingStoreWordCount]; + for (uint16 i = 0; i < _g278_fileHeader._thingCounts[thingType]; ++i) + _dunData._g284_thingsData[thingType][i] = _dunData._g284_thingsData[thingType][0] + i * thingStoreWordCount; - if (thingType == kGroupThingType) { + if (thingType == k4_GroupThingType) { for (uint16 i = 0; i < thingCount; ++i) for (uint16 j = 0; j < thingStoreWordCount; ++j) { if (j == 2 || j == 3) - _dunData._thingsData[thingType][i][j] = dunDataStream.readByte(); + _dunData._g284_thingsData[thingType][i][j] = dunDataStream.readByte(); else - _dunData._thingsData[thingType][i][j] = dunDataStream.readUint16BE(); + _dunData._g284_thingsData[thingType][i][j] = dunDataStream.readUint16BE(); } - } else if (thingType == kProjectileThingType) { + } else if (thingType == k14_ProjectileThingType) { for (uint16 i = 0; i < thingCount; ++i) { - _dunData._thingsData[thingType][i][0] = dunDataStream.readUint16BE(); - _dunData._thingsData[thingType][i][1] = dunDataStream.readUint16BE(); - _dunData._thingsData[thingType][i][2] = dunDataStream.readByte(); - _dunData._thingsData[thingType][i][3] = dunDataStream.readByte(); - _dunData._thingsData[thingType][i][4] = dunDataStream.readUint16BE(); + _dunData._g284_thingsData[thingType][i][0] = dunDataStream.readUint16BE(); + _dunData._g284_thingsData[thingType][i][1] = dunDataStream.readUint16BE(); + _dunData._g284_thingsData[thingType][i][2] = dunDataStream.readByte(); + _dunData._g284_thingsData[thingType][i][3] = dunDataStream.readByte(); + _dunData._g284_thingsData[thingType][i][4] = dunDataStream.readUint16BE(); } } else { for (uint16 i = 0; i < thingCount; ++i) { for (uint16 j = 0; j < thingStoreWordCount; ++j) - _dunData._thingsData[thingType][i][j] = dunDataStream.readUint16BE(); + _dunData._g284_thingsData[thingType][i][j] = dunDataStream.readUint16BE(); } } - if (_messages._newGame) { - if ((thingType == kGroupThingType) || thingType >= kProjectileThingType) - _vm->_timeline->_eventMaxCount += _fileHeader._thingCounts[thingType]; + if (_messages._g298_newGame) { + if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType) + _vm->_timeline->_eventMaxCount += _g278_fileHeader._thingCounts[thingType]; for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) { - _dunData._thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16(); + _dunData._g284_thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16(); } } } // load map data - if (!_messages._restartGameRequest) - _rawMapData = _rawDunFileData + dunDataStream.pos(); + if (!_messages._g523_restartGameRequest) + _g276_rawMapData = _rawDunFileData + dunDataStream.pos(); - if (!_messages._restartGameRequest) { - uint8 mapCount = _fileHeader._mapCount; - delete[] _dunData._mapData; - _dunData._mapData = new byte**[_dunData._columCount + mapCount]; - byte **colFirstSquares = (byte**)_dunData._mapData + mapCount; + if (!_messages._g523_restartGameRequest) { + uint8 mapCount = _g278_fileHeader._mapCount; + delete[] _dunData._g279_mapData; + _dunData._g279_mapData = new byte**[_dunData._g282_columCount + mapCount]; + byte **colFirstSquares = (byte**)_dunData._g279_mapData + mapCount; for (uint8 i = 0; i < mapCount; ++i) { - _dunData._mapData[i] = colFirstSquares; - byte *square = _rawMapData + _maps[i]._rawDunDataOffset; + _dunData._g279_mapData[i] = colFirstSquares; + byte *square = _g276_rawMapData + _g277_maps[i]._rawDunDataOffset; *colFirstSquares++ = square; - for (uint16 w = 1; w <= _maps[i]._width; ++w) { - square += _maps[i]._height + 1; + for (uint16 w = 1; w <= _g277_maps[i]._width; ++w) { + square += _g277_maps[i]._height + 1; *colFirstSquares++ = square; } } @@ -729,63 +729,63 @@ void DungeonMan::loadDungeonFile() { } void DungeonMan::setCurrentMap(uint16 mapIndex) { - _currMap._index = mapIndex; - _currMap._data = _dunData._mapData[mapIndex]; - _currMap._map = _maps + mapIndex; - _currMap._width = _maps[mapIndex]._width + 1; - _currMap._height = _maps[mapIndex]._height + 1; - _currMap._colCumulativeSquareFirstThingCount - = &_dunData._columnsCumulativeSquareThingCount[_dunData._mapsFirstColumnIndex[mapIndex]]; + _currMap._g272_index = mapIndex; + _currMap._g271_data = _dunData._g279_mapData[mapIndex]; + _currMap._g269_map = _g277_maps + mapIndex; + _currMap._g273_width = _g277_maps[mapIndex]._width + 1; + _currMap._g274_height = _g277_maps[mapIndex]._height + 1; + _currMap._g270_colCumulativeSquareFirstThingCount + = &_dunData._g280_columnsCumulativeSquareThingCount[_dunData._g281_mapsFirstColumnIndex[mapIndex]]; } void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) { setCurrentMap(mapIndex); - byte *metaMapData = _currMap._data[_currMap._width - 1] + _currMap._height; + byte *metaMapData = _currMap._g271_data[_currMap._g273_width - 1] + _currMap._g274_height; _vm->_displayMan->_g264_currMapAllowedCreatureTypes = metaMapData; - metaMapData += _currMap._map->_creatureTypeCount; - memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _currMap._map->_wallOrnCount); + metaMapData += _currMap._g269_map->_creatureTypeCount; + memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _currMap._g269_map->_wallOrnCount); - metaMapData += _currMap._map->_wallOrnCount; - memcpy(_vm->_displayMan->_g262_currMapFloorOrnIndices, metaMapData, _currMap._map->_floorOrnCount); + metaMapData += _currMap._g269_map->_wallOrnCount; + memcpy(_vm->_displayMan->_g262_currMapFloorOrnIndices, metaMapData, _currMap._g269_map->_floorOrnCount); - metaMapData += _currMap._map->_wallOrnCount; - memcpy(_vm->_displayMan->_g263_currMapDoorOrnIndices, metaMapData, _currMap._map->_doorOrnCount); + metaMapData += _currMap._g269_map->_wallOrnCount; + memcpy(_vm->_displayMan->_g263_currMapDoorOrnIndices, metaMapData, _currMap._g269_map->_doorOrnCount); - _currMapInscriptionWallOrnIndex = _currMap._map->_wallOrnCount; - _vm->_displayMan->_g261_currMapWallOrnIndices[_currMapInscriptionWallOrnIndex] = k0_WallOrnInscription; + _g265_currMapInscriptionWallOrnIndex = _currMap._g269_map->_wallOrnCount; + _vm->_displayMan->_g261_currMapWallOrnIndices[_g265_currMapInscriptionWallOrnIndex] = k0_WallOrnInscription; } Square DungeonMan::getSquare(int16 mapX, int16 mapY) { - bool isInXBounds = (mapX >= 0) && (mapX < _currMap._width); - bool isInYBounds = (mapY >= 0) && (mapY < _currMap._height); + bool isInXBounds = (mapX >= 0) && (mapX < _currMap._g273_width); + bool isInYBounds = (mapY >= 0) && (mapY < _currMap._g274_height); if (isInXBounds && isInYBounds) - return _currMap._data[mapX][mapY]; + return Square(_currMap._g271_data[mapX][mapY]); Square tmpSquare; if (isInYBounds) { - tmpSquare.set(_currMap._data[0][mapY]); - if (mapX == -1 && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) - return Square(kWallElemType).set(kWallEastRandOrnAllowed); + tmpSquare.set(_currMap._g271_data[0][mapY]); + if (mapX == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) + return Square(k0_WallElemType).set(k0x0004_WallEastRandOrnAllowed); - tmpSquare.set(_currMap._data[_currMap._width - 1][mapY]); - if (mapX == _currMap._width && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) - return Square(kWallElemType).set(kWallWestRandOrnAllowed); + tmpSquare.set(_currMap._g271_data[_currMap._g273_width - 1][mapY]); + if (mapX == _currMap._g273_width && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) + return Square(k0_WallElemType).set(k0x0001_WallWestRandOrnAllowed); } else if (isInXBounds) { - tmpSquare.set(_currMap._data[mapX][0]); - if (mapY == -1 && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) - return Square(kWallElemType).set(kWallSouthRandOrnAllowed); + tmpSquare.set(_currMap._g271_data[mapX][0]); + if (mapY == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) + return Square(k0_WallElemType).set(k0x0002_WallSouthRandOrnAllowed); - tmpSquare.set(_currMap._data[mapX][_currMap._height - 1]); - if (mapY == _currMap._height && (tmpSquare.getType() == kCorridorElemType || tmpSquare.getType() == kPitElemType)) - return (kWallElemType << 5) | kWallNorthRandOrnAllowed; + tmpSquare.set(_currMap._g271_data[mapX][_currMap._g274_height - 1]); + if (mapY == _currMap._g274_height && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) + return Square((k0_WallElemType << 5) | k0x0008_WallNorthRandOrnAllowed); } - return Square(kWallElemType); + return Square(k0_WallElemType); } Square DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { @@ -794,14 +794,14 @@ Square DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRi } int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) { - if (mapX < 0 || mapX >= _currMap._width || mapY < 0 || mapY >= _currMap._height || !Square(_currMap._data[mapX][mapY]).get(kThingListPresent)) + if (mapX < 0 || mapX >= _currMap._g273_width || mapY < 0 || mapY >= _currMap._g274_height || !Square(_currMap._g271_data[mapX][mapY]).get(k0x0010_ThingListPresent)) return -1; int16 y = 0; - uint16 index = _currMap._colCumulativeSquareFirstThingCount[mapX]; - byte* square = _currMap._data[mapX]; + uint16 index = _currMap._g270_colCumulativeSquareFirstThingCount[mapX]; + byte* square = _currMap._g271_data[mapX]; while (y++ != mapY) - if (Square(*square++).get(kThingListPresent)) + if (Square(*square++).get(k0x0010_ThingListPresent)) index++; return index; @@ -811,7 +811,7 @@ Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) { int16 index = getSquareFirstThingIndex(mapX, mapY); if (index == -1) return Thing::_endOfList; - return _dunData._squareFirstThings[index]; + return _dunData._g283_squareFirstThings[index]; } @@ -825,7 +825,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, Thing thing = getSquareFirstThing(mapX, mapY); Square square = getSquare(mapX, mapY); - aspectArray[kElemAspect] = square.getType(); + aspectArray[k0_ElemAspect] = square.getType(); bool leftOrnAllowed = false; bool rightOrnAllowed = false; @@ -833,27 +833,27 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, bool squareIsFakeWall = false; bool footPrintsAllowed = false; switch (square.getType()) { - case kWallElemType: + case k0_WallElemType: switch (dir) { case kDirNorth: - leftOrnAllowed = square.get(kWallEastRandOrnAllowed); - frontOrnAllowed = square.get(kWallSouthRandOrnAllowed); - rightOrnAllowed = square.get(kWallWestRandOrnAllowed); + leftOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed); + frontOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed); + rightOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed); break; case kDirEast: - leftOrnAllowed = square.get(kWallSouthRandOrnAllowed); - frontOrnAllowed = square.get(kWallWestRandOrnAllowed); - rightOrnAllowed = square.get(kWallNorthRandOrnAllowed); + leftOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed); + frontOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed); + rightOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed); break; case kDirSouth: - leftOrnAllowed = square.get(kWallWestRandOrnAllowed); - frontOrnAllowed = square.get(kWallNorthRandOrnAllowed); - rightOrnAllowed = square.get(kWallEastRandOrnAllowed); + leftOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed); + frontOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed); + rightOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed); break; case kDirWest: - leftOrnAllowed = square.get(kWallNorthRandOrnAllowed); - frontOrnAllowed = square.get(kWallEastRandOrnAllowed); - rightOrnAllowed = square.get(kWallSouthRandOrnAllowed); + leftOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed); + frontOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed); + rightOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed); break; default: break; @@ -862,104 +862,104 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, T0172010_ClosedFakeWall: setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall); - while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType)) { + while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) { int16 sideIndex = (thing.getCell() - dir) & 3; if (sideIndex) { - if (thing.getType() == kTextstringType) { + if (thing.getType() == k2_TextstringType) { if (TextString(getThingData(thing)).isVisible()) { - aspectArray[sideIndex + 1] = _currMapInscriptionWallOrnIndex + 1; + aspectArray[sideIndex + 1] = _g265_currMapInscriptionWallOrnIndex + 1; _vm->_displayMan->_g290_inscriptionThing = thing; // BUG0_76 } } else { Sensor sensor(getThingData(thing)); aspectArray[sideIndex + 1] = sensor.getOrnOrdinal(); - if (sensor.getType() == kSensorWallChampionPortrait) { + if (sensor.getType() == k127_SensorWallChampionPortrait) { _vm->_displayMan->_g289_championPortraitOrdinal = _vm->indexToOrdinal(sensor.getData()); } } } thing = getNextThing(thing); } - if (squareIsFakeWall && (_currMap._partyPosX != mapX) && (_currMap._partyPosY != mapY)) { - aspectArray[kFirstGroupOrObjectAspect] = Thing::_endOfList.toUint16(); + if (squareIsFakeWall && (_currMap._g306_partyPosX != mapX) && (_currMap._g307_partyPosY != mapY)) { + aspectArray[k1_FirstGroupOrObjectAspect] = Thing::_endOfList.toUint16(); return; } break; - case kPitElemType: - if (square.get(kPitOpen)) { - aspectArray[kPitInvisibleAspect] = square.get(kPitInvisible); + case k2_PitElemType: + if (square.get(k0x0008_PitOpen)) { + aspectArray[k2_PitInvisibleAspect] = square.get(k0x0004_PitInvisible); footPrintsAllowed = square.toByte() & 1; } else { - aspectArray[kElemAspect] = kCorridorElemType; + aspectArray[k0_ElemAspect] = k1_CorridorElemType; footPrintsAllowed = true; } goto T0172030_Pit; - case kFakeWallElemType: - if (!square.get(kFakeWallOpen)) { - aspectArray[kElemAspect] = kWallElemType; - leftOrnAllowed = rightOrnAllowed = frontOrnAllowed = square.get(kFakeWallRandOrnOrFootPAllowed); + case k6_FakeWallElemType: + if (!square.get(k0x0004_FakeWallOpen)) { + aspectArray[k0_ElemAspect] = k0_WallElemType; + leftOrnAllowed = rightOrnAllowed = frontOrnAllowed = square.get(k0x0008_FakeWallRandOrnOrFootPAllowed); squareIsFakeWall = true; goto T0172010_ClosedFakeWall; } - aspectArray[kWallElemType] = kCorridorElemType; - footPrintsAllowed = square.get(kFakeWallRandOrnOrFootPAllowed); - square = footPrintsAllowed ? 8 : 0; + aspectArray[k0_WallElemType] = k1_CorridorElemType; + footPrintsAllowed = square.get(k0x0008_FakeWallRandOrnOrFootPAllowed); + square = Square(footPrintsAllowed ? 8 : 0); // intentional fallthrough - case kCorridorElemType: - aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap._map->_randFloorOrnCount, mapX, mapY, 30); + case k1_CorridorElemType: + aspectArray[k4_FloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(k0x0008_CorridorRandOrnAllowed), _currMap._g269_map->_randFloorOrnCount, mapX, mapY, 30); T0172029_Teleporter: footPrintsAllowed = true; T0172030_Pit: - while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType)) { - if (thing.getType() == kSensorThingType) - aspectArray[kFloorOrnOrdAspect] = Sensor(getThingData(thing)).getOrnOrdinal(); + while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) { + if (thing.getType() == k3_SensorThingType) + aspectArray[k4_FloorOrnOrdAspect] = Sensor(getThingData(thing)).getOrnOrdinal(); thing = getNextThing(thing); } goto T0172049_Footprints; - case kTeleporterElemType: - aspectArray[kTeleporterVisibleAspect] = square.get(kTeleporterOpen) && square.get(kTeleporterVisible); + case k5_TeleporterElemType: + aspectArray[k2_TeleporterVisibleAspect] = square.get(k0x0008_TeleporterOpen) && square.get(k0x0004_TeleporterVisible); goto T0172029_Teleporter; - case kStairsElemType: - aspectArray[kElemAspect] = ((square.get(kStairsNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) ? kStairsSideElemType : kStairsFrontElemType; - aspectArray[kStairsUpAspect] = square.get(kStairsUp); + case k3_StairsElemType: + aspectArray[k0_ElemAspect] = ((square.get(k0x0008_StairsNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) ? k18_StairsSideElemType : k19_StairsFrontElemType; + aspectArray[k2_StairsUpAspect] = square.get(k0x0004_StairsUp); footPrintsAllowed = false; goto T0172046_Stairs; - case kDoorElemType: - if ((square.get(kDoorNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) { - aspectArray[kElemAspect] = kDoorSideElemType; + case k4_DoorElemType: + if ((square.get(k0x0008_DoorNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) { + aspectArray[k0_ElemAspect] = k16_DoorSideElemType; } else { - aspectArray[kElemAspect] = kDoorFrontElemType; - aspectArray[kDoorStateAspect] = square.getDoorState(); - aspectArray[kDoorThingIndexAspect] = getSquareFirstThing(mapX, mapY).getIndex(); + aspectArray[k0_ElemAspect] = k17_DoorFrontElemType; + aspectArray[k2_DoorStateAspect] = square.getDoorState(); + aspectArray[k3_DoorThingIndexAspect] = getSquareFirstThing(mapX, mapY).getIndex(); } footPrintsAllowed = true; T0172046_Stairs: - while ((thing != Thing::_endOfList) && (thing.getType() <= kSensorThingType)) + while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) thing = getNextThing(thing); T0172049_Footprints: unsigned char scentOrdinal; // see next line comment if (footPrintsAllowed) // TODO: I skipped some party query code, must come back later and complete - aspectArray[kFloorOrnOrdAspect] &= kFootprintsAspect; + aspectArray[k4_FloorOrnOrdAspect] &= k0x8000_FootprintsAspect; break; default: break; } - aspectArray[kFirstGroupOrObjectAspect] = thing.toUint16(); + aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16(); } void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, int16 mapX, int16 mapY, bool isFakeWall) { - int16 ornCount = _currMap._map->_randWallOrnCount; + int16 ornCount = _currMap._g269_map->_randWallOrnCount; turnDirRight(dir); - aspectArray[kRightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); + aspectArray[k2_RightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); turnDirRight(dir); - aspectArray[kFrontWallOrnOrdAspect] = getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); + aspectArray[k3_FrontWallOrnOrdAspect] = getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); turnDirRight(dir); - aspectArray[kLeftWallOrnOrdAspect] = getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); + aspectArray[k4_LeftWallOrnOrdAspect] = getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - if (isFakeWall || mapX < 0 || mapX >= _currMap._width || mapY < 0 || mapY >= _currMap._height) { - for (uint16 i = kRightWallOrnOrdAspect; i <= kLeftWallOrnOrdAspect; ++i) { + if (isFakeWall || mapX < 0 || mapX >= _currMap._g273_width || mapY < 0 || mapY >= _currMap._g274_height) { + for (uint16 i = k2_RightWallOrnOrdAspect; i <= k4_LeftWallOrnOrdAspect; ++i) { if (isWallOrnAnAlcove(_vm->ordinalToIndex(aspectArray[i]))) aspectArray[i] = 0; } @@ -968,8 +968,8 @@ void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowe int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) { int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1) - + (3000 + (_currMap._index << 6) + _currMap._width + _currMap._height) * 11 - + _fileHeader._ornamentRandomSeed) >> 2) % modulo; + + (3000 + (_currMap._g272_index << 6) + _currMap._g273_width + _currMap._g274_height) * 11 + + _g278_fileHeader._ornamentRandomSeed) >> 2) % modulo; if (allowed && index < count) return _vm->indexToOrdinal(index); return 0; @@ -985,7 +985,7 @@ bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) { } uint16 *DungeonMan::getThingData(Thing thing) { - return _dunData._thingsData[thing.getType()][thing.getIndex()]; + return _dunData._g284_thingsData[thing.getType()][thing.getIndex()]; } uint16* DungeonMan::getSquareFirstThingData(int16 mapX, int16 mapY) { @@ -1099,20 +1099,20 @@ char gInscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_Insc void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { char sepChar; - TextString textString(_dunData._thingsData[kTextstringType][thing.getIndex()]); - if ((textString.isVisible()) || (type & kDecodeEvenIfInvisible)) { - type = (TextType)(type & ~kDecodeEvenIfInvisible); - if (type == kTextTypeMessage) { + TextString textString(_dunData._g284_thingsData[k2_TextstringType][thing.getIndex()]); + if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) { + type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible); + if (type == k1_TextTypeMessage) { *destString++ = '\n'; sepChar = ' '; - } else if (type == kTextTypeInscription) { + } else if (type == k0_TextTypeInscription) { sepChar = (char)0x80; } else { sepChar = '\n'; } uint16 codeCounter = 0; int16 escChar = 0; - uint16 *codeWord = _dunData._textData + textString.getWordOffset(); + uint16 *codeWord = _dunData._g260_textData + textString.getWordOffset(); uint16 code = 0, codes = 0; char *escReplString = nullptr; for (;;) { /*infinite loop*/ @@ -1130,7 +1130,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { if (escChar) { *destString = '\0'; if (escChar == 30) { - if (type != kTextTypeInscription) { + if (type != k0_TextTypeInscription) { escReplString = gMessageAndScrollEscReplacementStrings[code]; } else { escReplString = gInscriptionEscReplacementStrings[code]; @@ -1142,7 +1142,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { destString += strlen(escReplString); escChar = 0; } else if (code < 28) { - if (type != kTextTypeInscription) { + if (type != k0_TextTypeInscription) { if (code == 26) { code = ' '; } else if (code == 27) { @@ -1161,7 +1161,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { } } } - *destString = ((type == kTextTypeInscription) ? 0x81 : '\0'); + *destString = ((type == k0_TextTypeInscription) ? 0x81 : '\0'); } @@ -1194,18 +1194,18 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { if (thing == Thing::_none) return 0; switch (thing.getType()) { - case kWeaponThingType: - return gWeaponInfo[Weapon(getThingData(thing)).getType()]._weight; - case kArmourThingType: - return gArmourInfo[Armour(getThingData(thing)).getType()]._weight; - case kJunkThingType: { - Junk junk = getThingData(thing); + case k5_WeaponThingType: + return g238_WeaponInfo[Weapon(getThingData(thing)).getType()]._weight; + case k6_ArmourThingType: + return g239_ArmourInfo[Armour(getThingData(thing)).getType()]._weight; + case k10_JunkThingType: { + Junk junk(getThingData(thing)); uint16 weight = junkInfo[junk.getType()]; - if (junk.getType() == kJunkTypeWaterskin) + if (junk.getType() == k1_JunkTypeWaterskin) weight += junk.getChargeCount() * 2; return weight; } - case kContainerThingType: { + case k9_ContainerThingType: { uint16 weight = 50; Container container(getThingData(thing)); Thing slotThing = container.getSlot(); @@ -1215,13 +1215,13 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { } return weight; } - case kPotionThingType: - if (Junk(getThingData(thing)).getType() == kPotionTypeEmptyFlask) { + case k8_PotionThingType: + if (Junk(getThingData(thing)).getType() == k20_PotionTypeEmptyFlask) { return 1; } else { return 3; } - case kScrollThingType: + case k7_ScrollThingType: return 1; default: break; @@ -1235,18 +1235,18 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { int16 DungeonMan::getObjectInfoIndex(Thing thing) { uint16 *rawType = getThingData(thing); switch (thing.getType()) { - case kScrollThingType: - return kObjectInfoIndexFirstScroll; - case kContainerThingType: - return kObjectInfoIndexFirstContainer + Container(rawType).getType(); - case kJunkThingType: - return kObjectInfoIndexFirstJunk + Junk(rawType).getType(); - case kWeaponThingType: - return kObjectInfoIndexFirstWeapon + Weapon(rawType).getType(); - case kArmourThingType: - return kObjectInfoIndexFirstArmour + Armour(rawType).getType(); - case kPotionThingType: - return kObjectInfoIndexFirstPotion + Potion(rawType).getType(); + case k7_ScrollThingType: + return k0_ObjectInfoIndexFirstScroll; + case k9_ContainerThingType: + return k1_ObjectInfoIndexFirstContainer + Container(rawType).getType(); + case k10_JunkThingType: + return k127_ObjectInfoIndexFirstJunk + Junk(rawType).getType(); + case k5_WeaponThingType: + return k23_ObjectInfoIndexFirstWeapon + Weapon(rawType).getType(); + case k6_ArmourThingType: + return k69_ObjectInfoIndexFirstArmour + Armour(rawType).getType(); + case k8_PotionThingType: + return k2_ObjectInfoIndexFirstPotion + Potion(rawType).getType(); default: return -1; } @@ -1260,27 +1260,27 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map *rawObjPtr = Thing::_endOfList.toUint16(); if (mapX >= 0) { - Square *squarePtr = (Square*)&_currMap._data[mapX][mapY]; - if (squarePtr->get(kThingListPresent)) { + Square *squarePtr = (Square*)&_currMap._g271_data[mapX][mapY]; + if (squarePtr->get(k0x0010_ThingListPresent)) { thingInList = getSquareFirstThing(mapX, mapY); } else { - squarePtr->set(kThingListPresent); - uint16 *cumulativeCount = &_currMap._colCumulativeSquareFirstThingCount[mapX + 1]; - uint16 column = _dunData._columCount - (_dunData._mapsFirstColumnIndex[_currMap._index] + mapX) - 1; + squarePtr->set(k0x0010_ThingListPresent); + uint16 *cumulativeCount = &_currMap._g270_colCumulativeSquareFirstThingCount[mapX + 1]; + uint16 column = _dunData._g282_columCount - (_dunData._g281_mapsFirstColumnIndex[_currMap._g272_index] + mapX) - 1; while (column--) { (*cumulativeCount++)++; } uint16 mapYStep = 0; squarePtr -= mapY; - uint16 squareFirstThingIndex = _currMap._colCumulativeSquareFirstThingCount[mapX]; + uint16 squareFirstThingIndex = _currMap._g270_colCumulativeSquareFirstThingCount[mapX]; while (mapYStep++ != mapY) { - if (squarePtr->get(kThingListPresent)) { + if (squarePtr->get(k0x0010_ThingListPresent)) { squareFirstThingIndex++; } squarePtr++; } - Thing* thingPtr = &_dunData._squareFirstThings[squareFirstThingIndex]; - memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_fileHeader._squareFirstThingCount - squareFirstThingIndex - 1)); + Thing* thingPtr = &_dunData._g283_squareFirstThings[squareFirstThingIndex]; + memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_g278_fileHeader._squareFirstThingCount - squareFirstThingIndex - 1)); *thingPtr = thingToLink; return; } @@ -1297,7 +1297,7 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map WeaponInfo* DungeonMan::getWeaponInfo(Thing thing) { Weapon* weapon = (Weapon*)getThingData(thing); - return &gWeaponInfo[weapon->getType()]; + return &g238_WeaponInfo[weapon->getType()]; } int16 DungeonMan::getProjectileAspect(Thing thing) { @@ -1305,7 +1305,7 @@ int16 DungeonMan::getProjectileAspect(Thing thing) { int16 projAspOrd; WeaponInfo *weaponInfo; - if ((thingType = thing.getType()) == kExplosionThingType) { + if ((thingType = thing.getType()) == k15_ExplosionThingType) { if (thing == Thing::_explFireBall) return -_vm->indexToOrdinal(k10_ProjectileAspectExplosionFireBall); if (thing == Thing::_explSlime) @@ -1316,13 +1316,13 @@ int16 DungeonMan::getProjectileAspect(Thing thing) { return -_vm->indexToOrdinal(k13_ProjectileAspectExplosionPoisonBoltCloud); return -_vm->indexToOrdinal(k11_ProjectileAspectExplosionDefault); - } else if (thingType == kWeaponThingType) { + } else if (thingType == k5_WeaponThingType) { weaponInfo = getWeaponInfo(thing); if (projAspOrd = weaponInfo->getProjectileAspectOrdinal()) return -projAspOrd; } - return gObjectInfo[getObjectInfoIndex(thing)]._objectAspectIndex; + return g237_ObjectInfo[getObjectInfoIndex(thing)]._objectAspectIndex; } } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index b3f81d8746..d6ebdc09e9 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -35,44 +35,44 @@ namespace DM { /* Object info */ -#define kObjectInfoIndexFirstScroll 0 // @ C000_OBJECT_INFO_INDEX_FIRST_SCROLL -#define kObjectInfoIndexFirstContainer 1 // @ C001_OBJECT_INFO_INDEX_FIRST_CONTAINER -#define kObjectInfoIndexFirstPotion 2 // @ C002_OBJECT_INFO_INDEX_FIRST_POTION -#define kObjectInfoIndexFirstWeapon 23 // @ C023_OBJECT_INFO_INDEX_FIRST_WEAPON -#define kObjectInfoIndexFirstArmour 69 // @ C069_OBJECT_INFO_INDEX_FIRST_ARMOUR -#define kObjectInfoIndexFirstJunk 127 // @ C127_OBJECT_INFO_INDEX_FIRST_JUNK +#define k0_ObjectInfoIndexFirstScroll 0 // @ C000_OBJECT_INFO_INDEX_FIRST_SCROLL +#define k1_ObjectInfoIndexFirstContainer 1 // @ C001_OBJECT_INFO_INDEX_FIRST_CONTAINER +#define k2_ObjectInfoIndexFirstPotion 2 // @ C002_OBJECT_INFO_INDEX_FIRST_POTION +#define k23_ObjectInfoIndexFirstWeapon 23 // @ C023_OBJECT_INFO_INDEX_FIRST_WEAPON +#define k69_ObjectInfoIndexFirstArmour 69 // @ C069_OBJECT_INFO_INDEX_FIRST_ARMOUR +#define k127_ObjectInfoIndexFirstJunk 127 // @ C127_OBJECT_INFO_INDEX_FIRST_JUNK -#define kMapXNotOnASquare -1 // @ CM1_MAPX_NOT_ON_A_SQUARE +#define kM1_MapXNotOnASquare -1 // @ CM1_MAPX_NOT_ON_A_SQUARE enum ElementType { - kElementTypeChampion = -2, // @ CM2_ELEMENT_CHAMPION /* Values -2 and -1 are only used as projectile impact types */ - kElementTypeCreature = -1, // @ CM1_ELEMENT_CREATURE - kElementTypeWall = 0, // @ C00_ELEMENT_WALL /* Values 0-6 are used as square types and projectile impact types. Values 0-2 and 5-6 are also used for square aspect */ - kElementTypeCorridor = 1, // @ C01_ELEMENT_CORRIDOR - kElementTypePit = 2, // @ C02_ELEMENT_PIT - kElementTypeStairs = 3, // @ C03_ELEMENT_STAIRS - kElementTypeDoor = 4, // @ C04_ELEMENT_DOOR - kElementTypeTeleporter = 5, // @ C05_ELEMENT_TELEPORTER - kElementTypeFakeWall = 6, // @ C06_ELEMENT_FAKEWALL - kElementTypeDoorSide = 16, // @ C16_ELEMENT_DOOR_SIDE /* Values 16-19 are only used for square aspect */ - kElementTypeDoorFront = 17, // @ C17_ELEMENT_DOOR_FRONT - kElementTypeStairsSide = 18, // @ C18_ELEMENT_STAIRS_SIDE - kElementTypeStaisFront = 19 // @ C19_ELEMENT_STAIRS_FRONT + kM2_ElementTypeChampion = -2, // @ CM2_ELEMENT_CHAMPION /* Values -2 and -1 are only used as projectile impact types */ + kM1_ElementTypeCreature = -1, // @ CM1_ELEMENT_CREATURE + k0_ElementTypeWall = 0, // @ C00_ELEMENT_WALL /* Values 0-6 are used as square types and projectile impact types. Values 0-2 and 5-6 are also used for square aspect */ + k1_ElementTypeCorridor = 1, // @ C01_ELEMENT_CORRIDOR + k2_ElementTypePit = 2, // @ C02_ELEMENT_PIT + k3_ElementTypeStairs = 3, // @ C03_ELEMENT_STAIRS + k4_ElementTypeDoor = 4, // @ C04_ELEMENT_DOOR + k5_ElementTypeTeleporter = 5, // @ C05_ELEMENT_TELEPORTER + k6_ElementTypeFakeWall = 6, // @ C06_ELEMENT_FAKEWALL + k16_ElementTypeDoorSide = 16, // @ C16_ELEMENT_DOOR_SIDE /* Values 16-19 are only used for square aspect */ + k17_ElementTypeDoorFront = 17, // @ C17_ELEMENT_DOOR_FRONT + k18_ElementTypeStairsSide = 18, // @ C18_ELEMENT_STAIRS_SIDE + k19_ElementTypeStaisFront = 19 // @ C19_ELEMENT_STAIRS_FRONT }; enum ObjectAllowedSlot { - kObjectAllowedSlotMouth = 0x0001, // @ MASK0x0001_MOUTH - kObjectAllowedSlotHead = 0x0002, // @ MASK0x0002_HEAD - kObjectAllowedSlotNeck = 0x0004, // @ MASK0x0004_NECK - kObjectAllowedSlotTorso = 0x0008, // @ MASK0x0008_TORSO - kObjectAllowedSlotLegs = 0x0010, // @ MASK0x0010_LEGS - kObjectAllowedSlotFeet = 0x0020, // @ MASK0x0020_FEET - kObjectAllowedSlotQuiverLine_1 = 0x0040, // @ MASK0x0040_QUIVER_LINE1 - kObjectAllowedSlotQuiverLine_2 = 0x0080, // @ MASK0x0080_QUIVER_LINE2 - kObjectAllowedSlotPouchPassAndThroughDoors = 0x0100, // @ MASK0x0100_POUCH_PASS_AND_THROUGH_DOORS - kObjectAllowedSlotHands = 0x0200, // @ MASK0x0200_HANDS - kObjectAllowedSlotContainer = 0x0400 // @ MASK0x0400_CONTAINER + k0x0001_ObjectAllowedSlotMouth = 0x0001, // @ MASK0x0001_MOUTH + k0x0002_ObjectAllowedSlotHead = 0x0002, // @ MASK0x0002_HEAD + k0x0004_ObjectAllowedSlotNeck = 0x0004, // @ MASK0x0004_NECK + k0x0008_ObjectAllowedSlotTorso = 0x0008, // @ MASK0x0008_TORSO + k0x0010_ObjectAllowedSlotLegs = 0x0010, // @ MASK0x0010_LEGS + k0x0020_ObjectAllowedSlotFeet = 0x0020, // @ MASK0x0020_FEET + k0x0040_ObjectAllowedSlotQuiverLine_1 = 0x0040, // @ MASK0x0040_QUIVER_LINE1 + k0x0080_ObjectAllowedSlotQuiverLine_2 = 0x0080, // @ MASK0x0080_QUIVER_LINE2 + k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors = 0x0100, // @ MASK0x0100_POUCH_PASS_AND_THROUGH_DOORS + k0x0200_ObjectAllowedSlotHands = 0x0200, // @ MASK0x0200_HANDS + k0x0400_ObjectAllowedSlotContainer = 0x0400 // @ MASK0x0400_CONTAINER }; class ObjectInfo { @@ -96,11 +96,11 @@ public: } }; // @ OBJECT_INFO -extern ObjectInfo gObjectInfo[180]; +extern ObjectInfo g237_ObjectInfo[180]; // @ G0237_as_Graphic559_ObjectInfo enum ArmourAttribute { - kArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD - kArmourAttributeSharpDefense = 0x0007 // @ MASK0x0007_SHARP_DEFENSE + k0x0080_ArmourAttributeIsAShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD + k0x0007_ArmourAttributeSharpDefense = 0x0007 // @ MASK0x0007_SHARP_DEFENSE }; class ArmourInfo { @@ -117,22 +117,22 @@ public: void setAttribute(ArmourAttribute attribute) { _attributes |= attribute; } }; // @ ARMOUR_INFO -extern ArmourInfo gArmourInfo[58]; +extern ArmourInfo g239_ArmourInfo[58]; // G0239_as_Graphic559_ArmourInfo /* Class 0: SWING weapons */ -#define kWeaponClassSwingWeapon 0 // @ C000_CLASS_SWING_WEAPON +#define k0_WeaponClassSwingWeapon 0 // @ C000_CLASS_SWING_WEAPON /* Class 1 to 15: THROW weapons */ -#define kWeaponClassDaggerAndAxes 2 // @ C002_CLASS_DAGGER_AND_AXES -#define kWeaponClassBowAmmunition 10 // @ C010_CLASS_BOW_AMMUNITION -#define kWeaponClassSlingAmmunition 11 // @ C011_CLASS_SLING_AMMUNITION -#define kWeaponClassPoisinDart 12 // @ C012_CLASS_POISON_DART +#define k2_WeaponClassDaggerAndAxes 2 // @ C002_CLASS_DAGGER_AND_AXES +#define k10_WeaponClassBowAmmunition 10 // @ C010_CLASS_BOW_AMMUNITION +#define k11_WeaponClassSlingAmmunition 11 // @ C011_CLASS_SLING_AMMUNITION +#define k12_WeaponClassPoisinDart 12 // @ C012_CLASS_POISON_DART /* Class 16 to 111: SHOOT weapons */ -#define kWeaponClassFirstBow 16 // @ C016_CLASS_FIRST_BOW -#define kWeaponClassLastBow 31 // @ C031_CLASS_LAST_BOW -#define kWeaponClassFirstSling 32 // @ C032_CLASS_FIRST_SLING -#define kWeaponClassLastSling 47 // @ C047_CLASS_LAST_SLING +#define k16_WeaponClassFirstBow 16 // @ C016_CLASS_FIRST_BOW +#define k31_WeaponClassLastBow 31 // @ C031_CLASS_LAST_BOW +#define k32_WeaponClassFirstSling 32 // @ C032_CLASS_FIRST_SLING +#define k47_WeaponClassLastSling 47 // @ C047_CLASS_LAST_SLING /* Class 112 to 255: Magic and special weapons */ -#define kWeaponClassFirstMagicWeapon 112 // @ C112_CLASS_FIRST_MAGIC_WEAPON +#define k112_WeaponClassFirstMagicWeapon 112 // @ C112_CLASS_FIRST_MAGIC_WEAPON class WeaponInfo { @@ -151,32 +151,32 @@ public: uint16 getProjectileAspectOrdinal() { return (_attributes >> 8) & 0x1F; } // @ M66_PROJECTILE_ASPECT_ORDINAL }; // @ WEAPON_INFO -extern WeaponInfo gWeaponInfo[46]; +extern WeaponInfo g238_WeaponInfo[46]; // @ G0238_as_Graphic559_WeaponInfo; enum TextType { /* Used for text on walls */ - kTextTypeInscription = 0, // @ C0_TEXT_TYPE_INSCRIPTION + k0_TextTypeInscription = 0, // @ C0_TEXT_TYPE_INSCRIPTION /* Used for messages displayed when the party walks on a square */ - kTextTypeMessage = 1, // @ C1_TEXT_TYPE_MESSAGE + k1_TextTypeMessage = 1, // @ C1_TEXT_TYPE_MESSAGE /* Used for text on scrolls and champion information */ - kTextTypeScroll = 2 // @ C2_TEXT_TYPE_SCROLL + k2_TextTypeScroll = 2 // @ C2_TEXT_TYPE_SCROLL }; enum SquareAspectIndice { - kElemAspect = 0, // @ C0_ELEMENT - kFirstGroupOrObjectAspect = 1, // @ C1_FIRST_GROUP_OR_OBJECT - kRightWallOrnOrdAspect = 2, // @ C2_RIGHT_WALL_ORNAMENT_ORDINAL - kFrontWallOrnOrdAspect = 3, // @ C3_FRONT_WALL_ORNAMENT_ORDINAL - kLeftWallOrnOrdAspect = 4, // @ C4_LEFT_WALL_ORNAMENT_ORDINAL - kPitInvisibleAspect = 2, // @ C2_PIT_INVISIBLE - kTeleporterVisibleAspect = 2, // @ C2_TELEPORTER_VISIBLE - kStairsUpAspect = 2, // @ C2_STAIRS_UP - kDoorStateAspect = 2, // @ C2_DOOR_STATE - kDoorThingIndexAspect = 3, // @ C3_DOOR_THING_INDEX - kFloorOrnOrdAspect = 4, // @ C4_FLOOR_ORNAMENT_ORDINAL - kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS + k0_ElemAspect = 0, // @ C0_ELEMENT + k1_FirstGroupOrObjectAspect = 1, // @ C1_FIRST_GROUP_OR_OBJECT + k2_RightWallOrnOrdAspect = 2, // @ C2_RIGHT_WALL_ORNAMENT_ORDINAL + k3_FrontWallOrnOrdAspect = 3, // @ C3_FRONT_WALL_ORNAMENT_ORDINAL + k4_LeftWallOrnOrdAspect = 4, // @ C4_LEFT_WALL_ORNAMENT_ORDINAL + k2_PitInvisibleAspect = 2, // @ C2_PIT_INVISIBLE + k2_TeleporterVisibleAspect = 2, // @ C2_TELEPORTER_VISIBLE + k2_StairsUpAspect = 2, // @ C2_STAIRS_UP + k2_DoorStateAspect = 2, // @ C2_DOOR_STATE + k3_DoorThingIndexAspect = 3, // @ C3_DOOR_THING_INDEX + k4_FloorOrnOrdAspect = 4, // @ C4_FLOOR_ORNAMENT_ORDINAL + k0x8000_FootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS }; -; + @@ -202,7 +202,7 @@ struct CreatureInfo { }; // @ CREATURE_INFO -extern CreatureInfo gCreatureInfo[k27_CreatureTypeCount]; +extern CreatureInfo g243_CreatureInfo[k27_CreatureTypeCount]; // @ G0243_as_Graphic559_CreatureInfo class Door { Thing _nextThing; @@ -219,8 +219,8 @@ public: }; // @ DOOR enum TeleporterScope { - kTelepScopeCreatures = 1, // @ MASK0x0001_SCOPE_CREATURES - kTelepScopeObjOrParty = 2 // @ MASK0x0002_SCOPE_OBJECTS_OR_PARTY + k0x0001_TelepScopeCreatures = 1, // @ MASK0x0001_SCOPE_CREATURES + k0x0002_TelepScopeObjOrParty = 2 // @ MASK0x0002_SCOPE_OBJECTS_OR_PARTY }; @@ -254,44 +254,44 @@ public: }; // @ TEXTSTRING enum SensorActionType { - kSensorEffNone = -1, // @ CM1_EFFECT_NONE - kSensorEffSet = 0, // @ C00_EFFECT_SET - kSensorEffClear = 1, // @ C01_EFFECT_CLEAR - kSensorEffToggle = 2, // @ C02_EFFECT_TOGGLE - kSensorEffHold = 3, // @ C03_EFFECT_HOLD - kSensorEffAddExp = 10 // @ C10_EFFECT_ADD_EXPERIENCE + kM1_SensorEffNone = -1, // @ CM1_EFFECT_NONE + k0_SensorEffSet = 0, // @ C00_EFFECT_SET + k1_SensorEffClear = 1, // @ C01_EFFECT_CLEAR + k2_SensorEffToggle = 2, // @ C02_EFFECT_TOGGLE + k3_SensorEffHold = 3, // @ C03_EFFECT_HOLD + k10_SensorEffAddExp = 10 // @ C10_EFFECT_ADD_EXPERIENCE }; enum SensorType { - kSensorDisabled = 0, // @ C000_SENSOR_DISABLED /* Never triggered, may be used for a floor or wall ornament */ - kSensorFloorTheronPartyCreatureObj = 1, // @ C001_SENSOR_FLOOR_THERON_PARTY_CREATURE_OBJECT /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorFloorTheronPartyCreature = 2, // @ C002_SENSOR_FLOOR_THERON_PARTY_CREATURE /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorFloorParty = 3, // @ C003_SENSOR_FLOOR_PARTY /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorFloorObj = 4, // @ C004_SENSOR_FLOOR_OBJECT /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorFloorPartyOnStairs = 5, // @ C005_SENSOR_FLOOR_PARTY_ON_STAIRS /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorFloorGroupGenerator = 6, // @ C006_SENSOR_FLOOR_GROUP_GENERATOR /* Triggered by event F0245_TIMELINE_ProcessEvent5_Square_Corridor */ - kSensorFloorCreature = 7, // @ C007_SENSOR_FLOOR_CREATURE /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorFloorPartyPossession = 8, // @ C008_SENSOR_FLOOR_PARTY_POSSESSION /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorFloorVersionChecker = 9, // @ C009_SENSOR_FLOOR_VERSION_CHECKER /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ - kSensorWallOrnClick = 1, // @ C001_SENSOR_WALL_ORNAMENT_CLICK /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallOrnClickWithAnyObj = 2, // @ C002_SENSOR_WALL_ORNAMENT_CLICK_WITH_ANY_OBJECT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallOrnClickWithSpecObj = 3, // @ C003_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallOrnClickWithSpecObjRemoved = 4, // @ C004_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallAndOrGate = 5, // @ C005_SENSOR_WALL_AND_OR_GATE /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallCountdown = 6, // @ C006_SENSOR_WALL_COUNTDOWN /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallSingleProjLauncherNewObj = 7, // @ C007_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_NEW_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallSingleProjLauncherExplosion = 8, // @ C008_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_EXPLOSION /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallDoubleProjLauncherNewObj = 9, // @ C009_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_NEW_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallDoubleProjLauncherExplosion = 10, // @ C010_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_EXPLOSION /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallOrnClickWithSpecObjRemovedRotateSensors = 11, // @ C011_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_ROTATE_SENSORS /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallObjGeneratorRotateSensors = 12, // @ C012_SENSOR_WALL_OBJECT_GENERATOR_ROTATE_SENSORS /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallSingleObjStorageRotateSensors = 13, // @ C013_SENSOR_WALL_SINGLE_OBJECT_STORAGE_ROTATE_SENSORS /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallSingleProjLauncherSquareObj = 14, // @ C014_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallDoubleProjLauncherSquareObj = 15, // @ C015_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallObjExchanger = 16, // @ C016_SENSOR_WALL_OBJECT_EXCHANGER /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallOrnClickWithSpecObjRemovedSensor = 17, // @ C017_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_REMOVE_SENSOR /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ - kSensorWallEndGame = 18, // @ C018_SENSOR_WALL_END_GAME /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ - kSensorWallChampionPortrait = 127 // @ C127_SENSOR_WALL_CHAMPION_PORTRAIT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + k0_SensorDisabled = 0, // @ C000_SENSOR_DISABLED /* Never triggered, may be used for a floor or wall ornament */ + k1_SensorFloorTheronPartyCreatureObj = 1, // @ C001_SENSOR_FLOOR_THERON_PARTY_CREATURE_OBJECT /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + k2_SensorFloorTheronPartyCreature = 2, // @ C002_SENSOR_FLOOR_THERON_PARTY_CREATURE /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + k3_SensorFloorParty = 3, // @ C003_SENSOR_FLOOR_PARTY /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + k4_SensorFloorObj = 4, // @ C004_SENSOR_FLOOR_OBJECT /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + k5_SensorFloorPartyOnStairs = 5, // @ C005_SENSOR_FLOOR_PARTY_ON_STAIRS /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + k6_SensorFloorGroupGenerator = 6, // @ C006_SENSOR_FLOOR_GROUP_GENERATOR /* Triggered by event F0245_TIMELINE_ProcessEvent5_Square_Corridor */ + k7_SensorFloorCreature = 7, // @ C007_SENSOR_FLOOR_CREATURE /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + k8_SensorFloorPartyPossession = 8, // @ C008_SENSOR_FLOOR_PARTY_POSSESSION /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + k9_SensorFloorVersionChecker = 9, // @ C009_SENSOR_FLOOR_VERSION_CHECKER /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */ + k1_SensorWallOrnClick = 1, // @ C001_SENSOR_WALL_ORNAMENT_CLICK /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + k2_SensorWallOrnClickWithAnyObj = 2, // @ C002_SENSOR_WALL_ORNAMENT_CLICK_WITH_ANY_OBJECT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + k3_SensorWallOrnClickWithSpecObj = 3, // @ C003_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + k4_SensorWallOrnClickWithSpecObjRemoved = 4, // @ C004_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + k5_SensorWallAndOrGate = 5, // @ C005_SENSOR_WALL_AND_OR_GATE /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + k6_SensorWallCountdown = 6, // @ C006_SENSOR_WALL_COUNTDOWN /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + k7_SensorWallSingleProjLauncherNewObj = 7, // @ C007_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_NEW_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + k8_SensorWallSingleProjLauncherExplosion = 8, // @ C008_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_EXPLOSION /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + k9_SensorWallDoubleProjLauncherNewObj = 9, // @ C009_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_NEW_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + k10_SensorWallDoubleProjLauncherExplosion = 10, // @ C010_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_EXPLOSION /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors = 11, // @ C011_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_ROTATE_SENSORS /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + k12_SensorWallObjGeneratorRotateSensors = 12, // @ C012_SENSOR_WALL_OBJECT_GENERATOR_ROTATE_SENSORS /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + k13_SensorWallSingleObjStorageRotateSensors = 13, // @ C013_SENSOR_WALL_SINGLE_OBJECT_STORAGE_ROTATE_SENSORS /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + k14_SensorWallSingleProjLauncherSquareObj = 14, // @ C014_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + k15_SensorWallDoubleProjLauncherSquareObj = 15, // @ C015_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + k16_SensorWallObjExchanger = 16, // @ C016_SENSOR_WALL_OBJECT_EXCHANGER /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + k17_SensorWallOrnClickWithSpecObjRemovedSensor = 17, // @ C017_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_REMOVE_SENSOR /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ + k18_SensorWallEndGame = 18, // @ C018_SENSOR_WALL_END_GAME /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */ + k127_SensorWallChampionPortrait = 127 // @ C127_SENSOR_WALL_CHAMPION_PORTRAIT /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */ }; class Sensor { @@ -331,17 +331,17 @@ public: enum WeaponType { - kWeaponTypeTorch = 2, // @ C02_WEAPON_TORCH - kWeaponTypeDagger = 8, // @ C08_WEAPON_DAGGER - kWeaponTypeFalchion = 9, // @ C09_WEAPON_FALCHION - kWeaponTypeSword = 10, // @ C10_WEAPON_SWORD - kWeaponTypeClub = 23, // @ C23_WEAPON_CLUB - kWeaponTypeStoneClub = 24, // @ C24_WEAPON_STONE_CLUB - kWeaponTypeArrow = 27, // @ C27_WEAPON_ARROW - kWeaponTypeSlayer = 28, // @ C28_WEAPON_SLAYER - kWeaponTypeRock = 30, // @ C30_WEAPON_ROCK - kWeaponTypePoisonDart = 31, // @ C31_WEAPON_POISON_DART - kWeaponTypeThrowingStar = 32 // @ C32_WEAPON_THROWING_STAR + k2_WeaponTypeTorch = 2, // @ C02_WEAPON_TORCH + k8_WeaponTypeDagger = 8, // @ C08_WEAPON_DAGGER + k9_WeaponTypeFalchion = 9, // @ C09_WEAPON_FALCHION + k10_WeaponTypeSword = 10, // @ C10_WEAPON_SWORD + k23_WeaponTypeClub = 23, // @ C23_WEAPON_CLUB + k24_WeaponTypeStoneClub = 24, // @ C24_WEAPON_STONE_CLUB + k27_WeaponTypeArrow = 27, // @ C27_WEAPON_ARROW + k28_WeaponTypeSlayer = 28, // @ C28_WEAPON_SLAYER + k30_WeaponTypeRock = 30, // @ C30_WEAPON_ROCK + k31_WeaponTypePoisonDart = 31, // @ C31_WEAPON_POISON_DART + k32_WeaponTypeThrowingStar = 32 // @ C32_WEAPON_THROWING_STAR }; class Weapon { Thing _nextThing; @@ -365,11 +365,11 @@ public: }; // @ WEAPON enum ArmourType { - kArmourTypeWoodenShield = 30, // @ C30_ARMOUR_WOODEN_SHIELD - kArmourTypeArmet = 38, // @ C38_ARMOUR_ARMET - kArmourTypeTorsoPlate = 39, // @ C39_ARMOUR_TORSO_PLATE - kArmourTypeLegPlate = 40, // @ C40_ARMOUR_LEG_PLATE - kArmourTypeFootPlate = 41 // @ C41_ARMOUR_FOOT_PLATE + k30_ArmourTypeWoodenShield = 30, // @ C30_ARMOUR_WOODEN_SHIELD + k38_ArmourTypeArmet = 38, // @ C38_ARMOUR_ARMET + k39_ArmourTypeTorsoPlate = 39, // @ C39_ARMOUR_TORSO_PLATE + k40_ArmourTypeLegPlate = 40, // @ C40_ARMOUR_LEG_PLATE + k41_ArmourTypeFootPlate = 41 // @ C41_ARMOUR_FOOT_PLATE }; class Armour { Thing _nextThing; @@ -404,19 +404,19 @@ public: }; // @ SCROLL enum PotionType { - kPotionTypeVen = 3, // @ C03_POTION_VEN_POTION, - kPotionTypeRos = 6, // @ C06_POTION_ROS_POTION, - kPotionTypeKu = 7, // @ C07_POTION_KU_POTION, - kPotionTypeDane = 8, // @ C08_POTION_DANE_POTION, - kPotionTypeNeta = 9, // @ C09_POTION_NETA_POTION, - kPotionTypeAntivenin = 10, // @ C10_POTION_ANTIVENIN, - kPotionTypeMon = 11, // @ C11_POTION_MON_POTION, - kPotionTypeYa = 12, // @ C12_POTION_YA_POTION, - kPotionTypeEe = 13, // @ C13_POTION_EE_POTION, - kPotionTypeVi = 14, // @ C14_POTION_VI_POTION, - kPotionTypeWaterFlask = 15, // @ C15_POTION_WATER_FLASK, - kPotionTypeFulBomb = 19, // @ C19_POTION_FUL_BOMB, - kPotionTypeEmptyFlask = 20 // @ C20_POTION_EMPTY_FLASK, + k3_PotionTypeVen = 3, // @ C03_POTION_VEN_POTION, + k6_PotionTypeRos = 6, // @ C06_POTION_ROS_POTION, + k7_PotionTypeKu = 7, // @ C07_POTION_KU_POTION, + k8_PotionTypeDane = 8, // @ C08_POTION_DANE_POTION, + k9_PotionTypeNeta = 9, // @ C09_POTION_NETA_POTION, + k10_PotionTypeAntivenin = 10, // @ C10_POTION_ANTIVENIN, + k11_PotionTypeMon = 11, // @ C11_POTION_MON_POTION, + k12_PotionTypeYa = 12, // @ C12_POTION_YA_POTION, + k13_PotionTypeEe = 13, // @ C13_POTION_EE_POTION, + k14_PotionTypeVi = 14, // @ C14_POTION_VI_POTION, + k15_PotionTypeWaterFlask = 15, // @ C15_POTION_WATER_FLASK, + k19_PotionTypeFulBomb = 19, // @ C19_POTION_FUL_BOMB, + k20_PotionTypeEmptyFlask = 20 // @ C20_POTION_EMPTY_FLASK, }; class Potion { Thing _nextThing; @@ -443,16 +443,16 @@ public: }; // @ CONTAINER enum JunkType { - kJunkTypeWaterskin = 1, // @ C01_JUNK_WATERSKIN, - kJunkTypeBones = 5, // @ C05_JUNK_BONES, - kJunkTypeBoulder = 25, // @ C25_JUNK_BOULDER, - kJunkTypeScreamerSlice = 33, // @ C33_JUNK_SCREAMER_SLICE, - kJunkTypeWormRound = 34, // @ C34_JUNK_WORM_ROUND, - kJunkTypeDrumstickShank = 35, // @ C35_JUNK_DRUMSTICK_SHANK, - kJunkTypeDragonSteak = 36, // @ C36_JUNK_DRAGON_STEAK, - kJunkTypeMagicalBoxBlue = 42, // @ C42_JUNK_MAGICAL_BOX_BLUE, - kJunkTypeMagicalBoxGreen = 43, // @ C43_JUNK_MAGICAL_BOX_GREEN, - kJunkTypeZokathra = 51 // @ C51_JUNK_ZOKATHRA, + k1_JunkTypeWaterskin = 1, // @ C01_JUNK_WATERSKIN, + k5_JunkTypeBones = 5, // @ C05_JUNK_BONES, + k25_JunkTypeBoulder = 25, // @ C25_JUNK_BOULDER, + k33_JunkTypeScreamerSlice = 33, // @ C33_JUNK_SCREAMER_SLICE, + k34_JunkTypeWormRound = 34, // @ C34_JUNK_WORM_ROUND, + k35_JunkTypeDrumstickShank = 35, // @ C35_JUNK_DRUMSTICK_SHANK, + k36_JunkTypeDragonSteak = 36, // @ C36_JUNK_DRAGON_STEAK, + k42_JunkTypeMagicalBoxBlue = 42, // @ C42_JUNK_MAGICAL_BOX_BLUE, + k43_JunkTypeMagicalBoxGreen = 43, // @ C43_JUNK_MAGICAL_BOX_GREEN, + k51_JunkTypeZokathra = 51 // @ C51_JUNK_ZOKATHRA, }; class Junk { @@ -481,17 +481,17 @@ public: Thing getNextThing() { return _nextThing; } }; // @ PROJECTILE -#define kExplosionType_Fireball 0 // @ C000_EXPLOSION_FIREBALL -#define kExplosionType_Slime 1 // @ C001_EXPLOSION_SLIME -#define kExplosionType_LightningBolt 2 // @ C002_EXPLOSION_LIGHTNING_BOLT -#define kExplosionType_HarmNonMaterial 3 // @ C003_EXPLOSION_HARM_NON_MATERIAL -#define kExplosionType_OpenDoor 4 // @ C004_EXPLOSION_OPEN_DOOR -#define kExplosionType_PoisonBolt 6 // @ C006_EXPLOSION_POISON_BOLT -#define kExplosionType_PoisonCloud 7 // @ C007_EXPLOSION_POISON_CLOUD -#define kExplosionType_Smoke 40 // @ C040_EXPLOSION_SMOKE -#define kExplosionType_Fluxcage 50 // @ C050_EXPLOSION_FLUXCAGE -#define kExplosionType_RebirthStep1 100 // @ C100_EXPLOSION_REBIRTH_STEP1 -#define kExplosionType_RebirthStep2 101 // @ C101_EXPLOSION_REBIRTH_STEP2 +#define k0_ExplosionType_Fireball 0 // @ C000_EXPLOSION_FIREBALL +#define k1_ExplosionType_Slime 1 // @ C001_EXPLOSION_SLIME +#define k2_ExplosionType_LightningBolt 2 // @ C002_EXPLOSION_LIGHTNING_BOLT +#define k3_ExplosionType_HarmNonMaterial 3 // @ C003_EXPLOSION_HARM_NON_MATERIAL +#define k4_ExplosionType_OpenDoor 4 // @ C004_EXPLOSION_OPEN_DOOR +#define k6_ExplosionType_PoisonBolt 6 // @ C006_EXPLOSION_POISON_BOLT +#define k7_ExplosionType_PoisonCloud 7 // @ C007_EXPLOSION_POISON_CLOUD +#define k40_ExplosionType_Smoke 40 // @ C040_EXPLOSION_SMOKE +#define k50_ExplosionType_Fluxcage 50 // @ C050_EXPLOSION_FLUXCAGE +#define k100_ExplosionType_RebirthStep1 100 // @ C100_EXPLOSION_REBIRTH_STEP1 +#define k101_ExplosionType_RebirthStep2 101 // @ C101_EXPLOSION_REBIRTH_STEP2 class Explosion { Thing _nextThing; @@ -507,40 +507,40 @@ public: enum SquareMask { - kWallWestRandOrnAllowed = 0x1, - kWallSouthRandOrnAllowed = 0x2, - kWallEastRandOrnAllowed = 0x4, - kWallNorthRandOrnAllowed = 0x8, - kCorridorRandOrnAllowed = 0x8, - kPitImaginary = 0x1, - kPitInvisible = 0x4, - kPitOpen = 0x8, - kStairsUp = 0x4, - kStairsNorthSouthOrient = 0x8, - kDoorNorthSouthOrient = 0x8, - kTeleporterVisible = 0x4, - kTeleporterOpen = 0x8, - kFakeWallImaginary = 0x1, - kFakeWallOpen = 0x4, - kFakeWallRandOrnOrFootPAllowed = 0x8, - kThingListPresent = 0x10, - kDecodeEvenIfInvisible = 0x8000 + k0x0001_WallWestRandOrnAllowed = 0x1, // @ MASK0x0001_WALL_WEST_RANDOM_ORNAMENT_ALLOWED + k0x0002_WallSouthRandOrnAllowed = 0x2, // @ MASK0x0002_WALL_SOUTH_RANDOM_ORNAMENT_ALLOWED + k0x0004_WallEastRandOrnAllowed = 0x4, // @ MASK0x0004_WALL_EAST_RANDOM_ORNAMENT_ALLOWED + k0x0008_WallNorthRandOrnAllowed = 0x8, // @ MASK0x0008_WALL_NORTH_RANDOM_ORNAMENT_ALLOWED + k0x0008_CorridorRandOrnAllowed = 0x8, // @ MASK0x0008_CORRIDOR_RANDOM_ORNAMENT_ALLOWED + k0x0001_PitImaginary = 0x1, // @ MASK0x0001_PIT_IMAGINARY + k0x0004_PitInvisible = 0x4, // @ MASK0x0004_PIT_INVISIBLE + k0x0008_PitOpen = 0x8, // @ MASK0x0008_PIT_OPEN + k0x0004_StairsUp = 0x4, // @ MASK0x0004_STAIRS_UP + k0x0008_StairsNorthSouthOrient = 0x8, // @ MASK0x0008_STAIRS_NORTH_SOUTH_ORIENTATION + k0x0008_DoorNorthSouthOrient = 0x8, // @ MASK0x0008_DOOR_NORTH_SOUTH_ORIENTATION + k0x0004_TeleporterVisible = 0x4, // @ MASK0x0004_TELEPORTER_VISIBLE + k0x0008_TeleporterOpen = 0x8, // @ MASK0x0008_TELEPORTER_OPEN + k0x0001_FakeWallImaginary = 0x1, // @ MASK0x0001_FAKEWALL_IMAGINARY + k0x0004_FakeWallOpen = 0x4, // @ MASK0x0004_FAKEWALL_OPEN + k0x0008_FakeWallRandOrnOrFootPAllowed = 0x8, // @ MASK0x0008_FAKEWALL_RANDOM_ORNAMENT_OR_FOOTPRINTS_ALLOWED + k0x0010_ThingListPresent = 0x10, // @ MASK0x0010_THING_LIST_PRESENT + k0x8000_DecodeEvenIfInvisible = 0x8000 // @ MASK0x8000_DECODE_EVEN_IF_INVISIBLE }; enum SquareType { - kChampionElemType = -2, - kCreatureElemType = -1, - kWallElemType = 0, - kCorridorElemType = 1, - kPitElemType = 2, - kStairsElemType = 3, - kDoorElemType = 4, - kTeleporterElemType = 5, - kFakeWallElemType = 6, - kDoorSideElemType = 16, - kDoorFrontElemType = 17, - kStairsSideElemType = 18, - kStairsFrontElemType = 19 + kM2_ChampionElemType = -2, // @ CM2_ELEMENT_CHAMPION + kM1_CreatureElemType = -1, // @ CM1_ELEMENT_CREATURE + k0_WallElemType = 0, // @ C00_ELEMENT_WALL + k1_CorridorElemType = 1, // @ C01_ELEMENT_CORRIDOR + k2_PitElemType = 2, // @ C02_ELEMENT_PIT + k3_StairsElemType = 3, // @ C03_ELEMENT_STAIRS + k4_DoorElemType = 4, // @ C04_ELEMENT_DOOR + k5_TeleporterElemType = 5, // @ C05_ELEMENT_TELEPORTER + k6_FakeWallElemType = 6, // @ C06_ELEMENT_FAKEWALL + k16_DoorSideElemType = 16, // @ C16_ELEMENT_DOOR_SIDE + k17_DoorFrontElemType = 17, // @ C17_ELEMENT_DOOR_FRONT + k18_StairsSideElemType = 18, // @ C18_ELEMENT_STAIRS_SIDE + k19_StairsFrontElemType = 19 // @ C19_ELEMENT_STAIRS_FRONT }; // @ C[-2..19]_ELEMENT_... class Square { @@ -594,36 +594,36 @@ struct Map { struct DungeonData { // I have no idea the heck is this - uint16 *_mapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex - uint16 _columCount; // @ G0282_ui_DungeonColumnCount + uint16 *_g281_mapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex + uint16 _g282_columCount; // @ G0282_ui_DungeonColumnCount // I have no idea the heck is this - uint16 *_columnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount - Thing *_squareFirstThings; // @ G0283_pT_SquareFirstThings - uint16 *_textData; // @ G0260_pui_DungeonTextData + uint16 *_g280_columnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount + Thing *_g283_squareFirstThings; // @ G0283_pT_SquareFirstThings + uint16 *_g260_textData; // @ G0260_pui_DungeonTextData - uint16 **_thingsData[16]; // @ G0284_apuc_ThingData + uint16 **_g284_thingsData[16]; // @ G0284_apuc_ThingData - byte ***_mapData; // @ G0279_pppuc_DungeonMapData + byte ***_g279_mapData; // @ G0279_pppuc_DungeonMapData }; // @ AGGREGATE struct CurrMapData { - direction _partyDir; // @ G0308_i_PartyDirection - int16 _partyPosX; // @ G0306_i_PartyMapX - int16 _partyPosY; // @ G0307_i_PartyMapY - uint8 _currPartyMapIndex; // @ G0309_i_PartyMapIndex - - uint8 _index; // @ G0272_i_CurrentMapIndex - byte **_data; // @ G0271_ppuc_CurrentMapData - Map *_map; // @ G0269_ps_CurrentMap - uint16 _width; // @ G0273_i_CurrentMapWidth - uint16 _height; // @ G0274_i_CurrentMapHeight - uint16 *_colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount + direction _g308_partyDir; // @ G0308_i_PartyDirection + int16 _g306_partyPosX; // @ G0306_i_PartyMapX + int16 _g307_partyPosY; // @ G0307_i_PartyMapY + uint8 _g309_currPartyMapIndex; // @ G0309_i_PartyMapIndex + + uint8 _g272_index; // @ G0272_i_CurrentMapIndex + byte **_g271_data; // @ G0271_ppuc_CurrentMapData + Map *_g269_map; // @ G0269_ps_CurrentMap + uint16 _g273_width; // @ G0273_i_CurrentMapWidth + uint16 _g274_height; // @ G0274_i_CurrentMapHeight + uint16 *_g270_colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount }; // @ AGGREGATE struct Messages { - bool _newGame; // @ G0298_B_NewGame - bool _restartGameRequest; // @ G0523_B_RestartGameRequested + bool _g298_newGame; // @ G0298_B_NewGame + bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested }; // @ AGGREGATE class DungeonMan { @@ -674,22 +674,22 @@ public: uint32 _rawDunFileDataSize; // @ probably NONE byte *_rawDunFileData; // @ ??? - DungeonFileHeader _fileHeader; // @ G0278_ps_DungeonHeader + DungeonFileHeader _g278_fileHeader; // @ G0278_ps_DungeonHeader DungeonData _dunData; // @ NONE CurrMapData _currMap; // @ NONE - Map *_maps; // @ G0277_ps_DungeonMaps + Map *_g277_maps; // @ G0277_ps_DungeonMaps // does not have to be freed - byte *_rawMapData; // @ G0276_puc_DungeonRawMapData + byte *_g276_rawMapData; // @ G0276_puc_DungeonRawMapData Messages _messages; // @ NONE; - int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex - Box _dungeonViewClickableBoxes[6]; // G0291_aauc_DungeonViewClickableBoxes - bool _isFacingAlcove; // @ G0286_B_FacingAlcove - bool _isFacingViAltar; // @ G0287_B_FacingViAltar - bool _isFacingFountain; // @ G0288_B_FacingFountain - ElementType _squareAheadElement; // @ G0285_i_SquareAheadElement - Thing _pileTopObject[5]; // @ G0292_aT_PileTopObject + int16 _g265_currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex + Box _g291_dungeonViewClickableBoxes[6]; // G0291_aauc_DungeonViewClickableBoxes + bool _g286_isFacingAlcove; // @ G0286_B_FacingAlcove + bool _g287_isFacingViAltar; // @ G0287_B_FacingViAltar + bool _g288_isFacingFountain; // @ G0288_B_FacingFountain + ElementType _g285_squareAheadElement; // @ G0285_i_SquareAheadElement + Thing _g292_pileTopObject[5]; // @ G0292_aT_PileTopObject }; } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 82fd07caac..4a60768fda 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -317,22 +317,22 @@ void EventManager::processInput() { switch (event.kbd.keycode) { case Common::KEYCODE_w: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 1, 0, currMap._partyPosX, currMap._partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY); break; case Common::KEYCODE_a: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, -1, currMap._partyPosX, currMap._partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, -1, currMap._g306_partyPosX, currMap._g307_partyPosY); break; case Common::KEYCODE_s: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, -1, 0, currMap._partyPosX, currMap._partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, -1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY); break; case Common::KEYCODE_d: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, 1, currMap._partyPosX, currMap._partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, 1, currMap._g306_partyPosX, currMap._g307_partyPosY); break; case Common::KEYCODE_q: - turnDirLeft(currMap._partyDir); + turnDirLeft(currMap._g308_partyDir); break; case Common::KEYCODE_e: - turnDirRight(currMap._partyDir); + turnDirRight(currMap._g308_partyDir); break; case Common::KEYCODE_UP: if (_dummyMapIndex < 13) @@ -431,7 +431,7 @@ void EventManager::processCommandQueue() { } void EventManager::commandTurnParty(CommandType cmdType) { - _vm->_stopWaitingForPlayerInput = true; + _vm->_g321_stopWaitingForPlayerInput = true; // MISSING CODE: highlight turn left/right buttons @@ -440,14 +440,14 @@ void EventManager::commandTurnParty(CommandType cmdType) { // MISSING CODE: process sensors // DUMMY CODE: should call F0284_CHAMPION_SetPartyDirection instead - direction &partyDir = _vm->_dungeonMan->_currMap._partyDir; + direction &partyDir = _vm->_dungeonMan->_currMap._g308_partyDir; (cmdType == kCommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir); // MISSING CODE: process sensors } void EventManager::commandMoveParty(CommandType cmdType) { - _vm->_stopWaitingForPlayerInput = true; + _vm->_g321_stopWaitingForPlayerInput = true; // MISSING CODE: Lots of code @@ -457,16 +457,16 @@ void EventManager::commandMoveParty(CommandType cmdType) { switch (cmdType) { case kCommandMoveForward: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 1, 0, currMap._partyPosX, currMap._partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY); break; case kCommandMoveLeft: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, -1, currMap._partyPosX, currMap._partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, -1, currMap._g306_partyPosX, currMap._g307_partyPosY); break; case kCommandMoveBackward: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, -1, 0, currMap._partyPosX, currMap._partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, -1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY); break; case kCommandMoveRight: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._partyDir, 0, 1, currMap._partyPosX, currMap._partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, 1, currMap._g306_partyPosX, currMap._g307_partyPosY); break; default: break; @@ -496,7 +496,7 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) { } cm._g411_leaderIndex = champIndex; Champion *champion = &cm._champions[cm._g411_leaderIndex]; - champion->_dir = _vm->_dungeonMan->_currMap._partyDir; + champion->_dir = _vm->_dungeonMan->_currMap._g308_partyDir; cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._414_leaderHandObject); if (_vm->indexToOrdinal(champIndex) != cm._g299_candidateChampionOrdinal) { champion->setAttributeFlag(k0x0400_ChampionAttributeIcon, true); @@ -508,10 +508,10 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) { void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() { DungeonMan &dunMan = *_vm->_dungeonMan; CurrMapData &currMap = dunMan._currMap; - int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir]; - int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir]; - if ((mapX >= 0) && (mapX < currMap._width) && (mapY >= 0) && (mapY < currMap._height)) { - _vm->_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._partyDir)); + int16 mapX = currMap._g306_partyPosX + _vm->_dirIntoStepCountEast[currMap._g308_partyDir]; + int16 mapY = currMap._g307_partyPosY + _vm->_dirIntoStepCountNorth[currMap._g308_partyDir]; + if ((mapX >= 0) && (mapX < currMap._g273_width) && (mapY >= 0) && (mapY < currMap._g274_height)) { + _vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._g308_partyDir)); } } @@ -520,17 +520,17 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY ChampionMan &champMan = *_vm->_championMan; CurrMapData &currMap = _vm->_dungeonMan->_currMap; - if (dunMan._squareAheadElement == kElementTypeDoorFront) { + if (dunMan._g285_squareAheadElement == k17_ElementTypeDoorFront) { if (champMan._g411_leaderIndex == kM1_ChampionNone) return; if (champMan._g415_leaderEmptyHanded) { - int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir]; - int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir]; + int16 mapX = currMap._g306_partyPosX + _vm->_dirIntoStepCountEast[currMap._g308_partyDir]; + int16 mapY = currMap._g307_partyPosY + _vm->_dirIntoStepCountNorth[currMap._g308_partyDir]; if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() && - dunMan._dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { - _vm->_stopWaitingForPlayerInput = true; + dunMan._g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { + _vm->_g321_stopWaitingForPlayerInput = true; warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); warning("MISSING CODE: F0268_SENSOR_AddEvent"); return; @@ -542,9 +542,9 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY if (champMan._g415_leaderEmptyHanded) { for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k5_ViewCellDoorButtonOrWallOrn; viewCell++) { - if (dunMan._dungeonViewClickableBoxes[viewCell].isPointInside(Common::Point(posX, posY - 33))) { + if (dunMan._g291_dungeonViewClickableBoxes[viewCell].isPointInside(Common::Point(posX, posY - 33))) { if (viewCell == k5_ViewCellDoorButtonOrWallOrn) { - if (!dunMan._isFacingAlcove) { + if (!dunMan._g286_isFacingAlcove) { commandProcessType80ClickInDungeonViewTouchFrontWall(); } } else { @@ -556,7 +556,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY } else { Thing thing = champMan._414_leaderHandObject; uint16 *rawThingPointer = dunMan.getThingData(thing); - if (dunMan._squareAheadElement == kElementTypeWall) { + if (dunMan._g285_squareAheadElement == k0_ElementTypeWall) { for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k1_ViewCellFrontRight; ++viewCell) { if (gBoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) { warning("F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject"); @@ -564,17 +564,17 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY } } - if (dunMan._dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { - if (dunMan._isFacingAlcove) { + if (dunMan._g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { + if (dunMan._g286_isFacingAlcove) { warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject"); } else { - if (dunMan._isFacingFountain) { + if (dunMan._g288_isFacingFountain) { uint16 iconIndex = _vm->_objectMan->getIconIndex(thing); int16 weight = dunMan.getObjectWeight(thing); if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) { ((Junk*)rawThingPointer)->setChargeCount(3); } else if (iconIndex == k195_IconIndicePotionEmptyFlask) { - ((Potion*)rawThingPointer)->setType(kPotionTypeWaterFlask); + ((Potion*)rawThingPointer)->setType(k15_PotionTypeWaterFlask); } else { goto T0377019; } @@ -620,15 +620,15 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane box._x2 = box._x1 + 66 + 1; dispMan._g578_useByteBoxCoordinates = false; dispMan.clearScreenBox(k0_ColorBlack, box); - dispMan.clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._partyDir) * 2]); + dispMan.clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._g308_partyDir) * 2]); warning("F0457_START_DrawEnabledMenus_CPSF"); warning("F0078_MOUSE_ShowPointer"); return; } champMan._g299_candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone); - int16 mapX = currMap._partyPosX + _vm->_dirIntoStepCountEast[currMap._partyDir]; - int16 mapY = currMap._partyPosY + _vm->_dirIntoStepCountNorth[currMap._partyDir]; + int16 mapX = currMap._g306_partyPosX + _vm->_dirIntoStepCountEast[currMap._g308_partyDir]; + int16 mapY = currMap._g307_partyPosY + _vm->_dirIntoStepCountNorth[currMap._g308_partyDir]; for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) { Thing thing = champ->getSlot((ChampionSlot)slotIndex); @@ -638,7 +638,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane } Thing thing = dunMan.getSquareFirstThing(mapX, mapY); for (;;) { // infinite - if (thing.getType() == kSensorThingType) { + if (thing.getType() == k3_SensorThingType) { ((Sensor*)dunMan.getThingData(thing))->setTypeDisabled(); break; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 35b30a3907..c93bf1db6d 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -823,7 +823,7 @@ void DisplayMan::loadGraphics() { for (int16 creatureIndex = 0; creatureIndex < k27_CreatureTypeCount; creatureIndex++) { creatureAsp = &g219_CreatureAspects[creatureIndex]; - int16 creatureGraphicInfo = gCreatureInfo[creatureIndex]._graphicInfo; + int16 creatureGraphicInfo = g243_CreatureInfo[creatureIndex]._graphicInfo; creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex; int16 creatureFrontBitmapD3PixelCount; @@ -1079,46 +1079,46 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { int16 order; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[kElemAspect]) { - case kStairsFrontElemType: - if (squareAspect[kStairsUpAspect]) + switch (squareAspect[k0_ElemAspect]) { + case k19_StairsFrontElemType: + if (squareAspect[k2_StairsUpAspect]) drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g110_FrameStairsUpFront_D3L); else drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g121_FrameStairsDownFront_D3L); goto T0116015_redEagle; - case kWallElemType: + case k0_WallElemType: drawWallSetBitmap(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k1_ViewSquare_D3L]); - isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT); - if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) { + isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT); + if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) { order = k0x0000_CellOrder_Alcove; goto T0116017_orangeElk; } return; - case kElementTypeDoorSide: - case kElementTypeStairsSide: + case k16_ElementTypeDoorSide: + case k18_ElementTypeStairsSide: order = k0x0321_CellOrder_BackLeft_BackRight_FrontRight; goto T0116016_blueToad; - case kElementTypeDoorFront: + case k17_ElementTypeDoorFront: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); - cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); + cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); drawWallSetBitmap(_wallSetBitMaps[kG705_DoorFrameLeft_D3L], g164_Frame_DoorFrameLeft_D3L); warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor"); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; goto T0116017_orangeElk; - case kElementTypePit: - if (!squareAspect[kPitInvisibleAspect]) { + case k2_ElementTypePit: + if (!squareAspect[k2_PitInvisibleAspect]) { drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, g140_FrameFloorPit_D3L); } - case kElementTypeTeleporter: - case kElementTypeCorridor: + case k5_ElementTypeTeleporter: + case k1_ElementTypeCorridor: T0116015_redEagle: order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight; T0116016_blueToad: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); T0116017_orangeElk: - cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order); + cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order); } - if ((squareAspect[kElemAspect] == kElementTypeTeleporter) && squareAspect[kTeleporterVisibleAspect]) { + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { drawField(&g188_FieldAspects[k1_ViewSquare_D3L], g163_FrameWalls[k1_ViewSquare_D3L]._box); } } @@ -1130,51 +1130,51 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[kElemAspect]) { - case kElementTypeStaisFront: - if (squareAspect[kStairsUpAspect]) { + switch (squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g112_FrameStairsUpFront_D3R); } else { drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g123_FrameStairsDownFront_D3R); } goto T0117016; - case kElementTypeWall: + case k0_ElementTypeWall: drawWallSetBitmap(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k2_ViewSquare_D3R]); - isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT); - if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) { + isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT); + if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) { order = k0x0000_CellOrder_Alcove; goto T0117018; } return; - case kElementTypeDoorSide: - case kElementTypeStairsSide: + case k16_ElementTypeDoorSide: + case k18_ElementTypeStairsSide: order = k0x0412_CellOrder_BackRight_BackLeft_FrontLeft; goto T0117017; - case kElementTypeDoorFront: + case k17_ElementTypeDoorFront: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); - cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); + cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); memcpy(_g74_tmpBitmap, _wallSetBitMaps[kG705_DoorFrameLeft_D3L], 32 * 44); warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally"); - if (((Door*)_vm->_dungeonMan->_dunData._thingsData[kDoorThingType])[squareAspect[kDoorThingIndexAspect]].hasButton()) { + if (((Door*)_vm->_dungeonMan->_dunData._g284_thingsData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton"); } warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor"); order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft; goto T0117018; - case kElementTypePit: - if (!squareAspect[kPitInvisibleAspect]) { + case k2_ElementTypePit: + if (!squareAspect[k2_PitInvisibleAspect]) { drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, g142_FrameFloorPit_D3R); } - case kElementTypeTeleporter: - case kElementTypeCorridor: + case k5_ElementTypeTeleporter: + case k1_ElementTypeCorridor: T0117016: order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft; T0117017: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); T0117018: - cthulhu(Thing(squareAspect[kFirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order); + cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order); } - if ((squareAspect[kElemAspect] == kElementTypeTeleporter) && squareAspect[kTeleporterVisibleAspect]) { + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { drawField(&g188_FieldAspects[k2_ViewSquare_D3R], g163_FrameWalls[k2_ViewSquare_D3R]._box); } } @@ -1183,15 +1183,15 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { - case kStairsFrontElemType: - if (squareAspect[kStairsUpAspect]) + case k19_StairsFrontElemType: + if (squareAspect[k2_StairsUpAspect]) drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, g111_FrameStairsUpFront_D3C); else drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, g122_FrameStairsDownFront_D3C); break; - case kWallElemType: + case k0_WallElemType: drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k0_ViewSquare_D3C]); - if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) { + if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) { //... missing code } break; @@ -1203,20 +1203,20 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { - case kStairsFrontElemType: - if (squareAspect[kStairsUpAspect]) + case k19_StairsFrontElemType: + if (squareAspect[k2_StairsUpAspect]) drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L); else drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L); break; - case kWallElemType: + case k0_WallElemType: drawWallSetBitmap(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k4_ViewSquare_D2L]); - isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT); - if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) { + isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT); + if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) { // ... missing code } break; - case kStairsSideElemType: + case k18_StairsSideElemType: drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L); break; default: @@ -1227,20 +1227,20 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { - case kStairsFrontElemType: - if (squareAspect[kStairsUpAspect]) + case k19_StairsFrontElemType: + if (squareAspect[k2_StairsUpAspect]) drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R); else drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R); break; - case kWallElemType: + case k0_WallElemType: drawWallSetBitmap(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k5_ViewSquare_D2R]); - isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT); - if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) { + isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT); + if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) { // ... missing code } break; - case kStairsSideElemType: + case k18_StairsSideElemType: drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R); break; default: @@ -1251,15 +1251,15 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { - case kStairsFrontElemType: - if (squareAspect[kStairsUpAspect]) + case k19_StairsFrontElemType: + if (squareAspect[k2_StairsUpAspect]) drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, g114_FrameStairsUpFront_D2C); else drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, g125_FrameStairsDownFront_D2C); break; - case kWallElemType: + case k0_WallElemType: drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k3_ViewSquare_D2C]); - if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) { + if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) { // ... missing code } break; @@ -1271,18 +1271,18 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { - case kStairsFrontElemType: - if (squareAspect[kStairsUpAspect]) + case k19_StairsFrontElemType: + if (squareAspect[k2_StairsUpAspect]) drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g116_FrameStairsUpFront_D1L); else drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g127_FrameStairsDownFront_D1L); break; - case kWallElemType: + case k0_WallElemType: drawWallSetBitmap(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k7_ViewSquare_D1L]); - isDrawnWallOrnAnAlcove(squareAspect[kRightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT); + isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT); break; - case kStairsSideElemType: - if (squareAspect[kStairsUpAspect]) + case k18_StairsSideElemType: + if (squareAspect[k2_StairsUpAspect]) drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g134_FrameStairsUpSide_D1L); else drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g136_FrameStairsDownSide_D1L); @@ -1295,18 +1295,18 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { - case kStairsFrontElemType: - if (squareAspect[kStairsUpAspect]) + case k19_StairsFrontElemType: + if (squareAspect[k2_StairsUpAspect]) drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g118_FrameStairsUpFront_D1R); else drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g129_FrameStairsDownFront_D1R); break; - case kWallElemType: + case k0_WallElemType: drawWallSetBitmap(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k8_ViewSquare_D1R]); - isDrawnWallOrnAnAlcove(squareAspect[kLeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT); + isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT); break; - case kStairsSideElemType: - if (squareAspect[kStairsUpAspect]) + case k18_StairsSideElemType: + if (squareAspect[k2_StairsUpAspect]) drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g135_FrameStairsUpSide_D1R); else drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g137_FrameStairsDownSide_D1R); @@ -1319,18 +1319,18 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { - case kStairsFrontElemType: - if (squareAspect[kStairsUpAspect]) + case k19_StairsFrontElemType: + if (squareAspect[k2_StairsUpAspect]) drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, g117_FrameStairsUpFront_D1C); else drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, g128_FrameStairsDownFront_D1C); break; - case kWallElemType: - _vm->_dungeonMan->_isFacingAlcove = false; - _vm->_dungeonMan->_isFacingViAltar = false; - _vm->_dungeonMan->_isFacingFountain = false; + case k0_WallElemType: + _vm->_dungeonMan->_g286_isFacingAlcove = false; + _vm->_dungeonMan->_g287_isFacingViAltar = false; + _vm->_dungeonMan->_g288_isFacingFountain = false; drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k6_ViewSquare_D1C]); - if (isDrawnWallOrnAnAlcove(squareAspect[kFrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) { + if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) { // .... code not yet implemneted } break; @@ -1343,11 +1343,11 @@ void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { - case kStairsSideElemType: - if (squareAspect[kStairsUpAspect]) + case k18_StairsSideElemType: + if (squareAspect[k2_StairsUpAspect]) drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, g138_FrameStairsSide_D0L); break; - case kWallElemType: + case k0_WallElemType: drawWallSetBitmap(_wallSetBitMaps[kG701_Wall_D0L], g163_FrameWalls[k10_ViewSquare_D0L]); break; default: @@ -1359,11 +1359,11 @@ void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { - case kStairsSideElemType: - if (squareAspect[kStairsUpAspect]) + case k18_StairsSideElemType: + if (squareAspect[k2_StairsUpAspect]) drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R); return; - case kWallElemType: + case k0_WallElemType: drawWallSetBitmap(_wallSetBitMaps[kG702_Wall_D0R], g163_FrameWalls[k11_ViewSquare_D0R]); break; default: @@ -1375,8 +1375,8 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { - case kStairsFrontElemType: - if (squareAspect[kStairsUpAspect]) { + case k19_StairsFrontElemType: + if (squareAspect[k2_StairsUpAspect]) { drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g119_FrameStairsUpFront_D0L); drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g120_FrameStairsUpFront_D0R); } else { @@ -1399,10 +1399,10 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { clearBitmap(tmpBitmap, 305, 111, k10_ColorFlesh); for (int16 i = 0; i < 6; ++i) - _vm->_dungeonMan->_dungeonViewClickableBoxes[i].setToZero(); + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i].setToZero(); for (uint16 i = 0; i < 6; ++i) { - _vm->_dungeonMan->_dungeonViewClickableBoxes[i]._x1 = 255 + 1; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i]._x1 = 255 + 1; } if (flippedFloorCeiling) { @@ -1422,9 +1422,9 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { drawWallSetBitmap(_g84_floorBitmap, gK13_FloorFrame); } - if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallElemType) + if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == k0_WallElemType) drawWallSetBitmap(_wallSetBitMaps[kG697_Wall_D3L2], g711_FrameWall_D3L2); - if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallElemType) + if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == k0_WallElemType) drawWallSetBitmap(_wallSetBitMaps[kG696_Wall_D3R2], g712_FrameWall_D3R2); int16 tmpPosX = posX, tmpPosY = posY; @@ -1519,13 +1519,13 @@ void DisplayMan::loadWallSet(WallSet set) { void DisplayMan::loadCurrentMapGraphics() { - loadFloorSet(_vm->_dungeonMan->_currMap._map->_floorSet); - loadWallSet(_vm->_dungeonMan->_currMap._map->_wallSet); + loadFloorSet(_vm->_dungeonMan->_currMap._g269_map->_floorSet); + loadWallSet(_vm->_dungeonMan->_currMap._g269_map->_wallSet); // the original loads some flipped walls here, I moved it to loadWallSet { - int16 val = _vm->_dungeonMan->_currMap._map->_wallSet * k18_StairsGraphicCount + k90_FirstStairs; + int16 val = _vm->_dungeonMan->_currMap._g269_map->_wallSet * k18_StairsGraphicCount + k90_FirstStairs; _g675_stairsNativeBitmapIndex_Up_Front_D3L = val++; _g676_stairsNativeBitmapIndex_Up_Front_D3C = val++; _g677_stairsNativeBitmapIndex_Up_Front_D2L = val++; @@ -1556,7 +1556,7 @@ void DisplayMan::loadCurrentMapGraphics() { uint16 alcoveCount = 0; uint16 fountainCount = 0; - Map &currMap = *_vm->_dungeonMan->_currMap._map; + Map &currMap = *_vm->_dungeonMan->_currMap._g269_map; _g266_currMapViAltarIndex = -1; @@ -1682,9 +1682,9 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex uint16 *coordinateSetA = g205_WallOrnCoordSets[_g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]][viewWallIndex]; isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnIndex); - isInscription = (wallOrnIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex); + isInscription = (wallOrnIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex); if (isInscription) { - _vm->_dungeonMan->decodeText((char*)inscriptionString, _g290_inscriptionThing, kTextTypeInscription); + _vm->_dungeonMan->decodeText((char*)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription); } if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) { @@ -1715,17 +1715,17 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex } nativeBitmapIndex++; - _vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordinateSetA[0]; - _vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordinateSetA[1]; - _vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordinateSetA[2]; - _vm->_dungeonMan->_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordinateSetA[3]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordinateSetA[0]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordinateSetA[1]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordinateSetA[2]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordinateSetA[3]; - _vm->_dungeonMan->_isFacingAlcove = isAlcove; - _vm->_dungeonMan->_isFacingViAltar = (wallOrnIndex == _g266_currMapViAltarIndex); - _vm->_dungeonMan->_isFacingFountain = false; + _vm->_dungeonMan->_g286_isFacingAlcove = isAlcove; + _vm->_dungeonMan->_g287_isFacingViAltar = (wallOrnIndex == _g266_currMapViAltarIndex); + _vm->_dungeonMan->_g288_isFacingFountain = false; for (int16 fountainOrnIndex = 0; fountainOrnIndex < k1_FountainOrnCount; ++fountainOrnIndex) { if (_g268_currMapFountainOrnIndices[fountainOrnIndex] == wallOrnIndex) { - _vm->_dungeonMan->_isFacingFountain = true; + _vm->_dungeonMan->_g288_isFacingFountain = true; break; } } @@ -2179,22 +2179,22 @@ creatures are drawn in the right order and so that Fluxcages are not drawn twice objectShiftIndex += (cellYellowBear & 0x0001) << 3; drawProjectileAsObject = false; do { - if ((AL_4_thingType = thingParam.getType()) == kGroupThingType) { + if ((AL_4_thingType = thingParam.getType()) == k4_GroupThingType) { groupThing = thingParam; continue; } - if (AL_4_thingType == kProjectileThingType) { + if (AL_4_thingType == k14_ProjectileThingType) { sqaureHasProjectile = true; continue; } - if (AL_4_thingType == kExplosionThingType) { + if (AL_4_thingType == k15_ExplosionThingType) { squareHasExplosion = true; continue; } /* Square where objects are visible and object is located on cell being processed */ if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { - objectAspect = &(g209_ObjectAspects[gObjectInfo[dunMan.getObjectInfoIndex(thingParam)]._objectAspectIndex]); + objectAspect = &(g209_ObjectAspects[g237_ObjectInfo[dunMan.getObjectInfoIndex(thingParam)]._objectAspectIndex]); AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex; if (useAlcoveObjectImage = (drawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane)) { AL_4_nativeBitmapIndex++; @@ -2287,7 +2287,7 @@ T0115015_DrawProjectileAsObject: if (drawingGrabbableObject) { bitmapGreenAnt = AL_6_bitmapRedBanana; - Box *AL_6_boxPtrRed = &dunMan._dungeonViewClickableBoxes[AL_2_viewCell]; + Box *AL_6_boxPtrRed = &dunMan._g291_dungeonViewClickableBoxes[AL_2_viewCell]; if (AL_6_boxPtrRed->_x1 == 255) { /* If the grabbable object is the first */ *AL_6_boxPtrRed = boxByteGreen; @@ -2305,7 +2305,7 @@ T0115015_DrawProjectileAsObject: AL_6_boxPtrRed->_y2 = MIN(AL_6_boxPtrRed->_y2, boxByteGreen._y2); } AL_6_bitmapRedBanana = bitmapGreenAnt; - dunMan._pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */ + dunMan._g292_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */ } blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, g296_DungeonViewport); @@ -2328,7 +2328,7 @@ T0115015_DrawProjectileAsObject: if (group == nullptr) { /* If all creature data and info has not already been gathered */ group = (Group*)dunMan.getThingData(groupThing); activeGroup = &_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()]; - creatureInfo = &gCreatureInfo[group->_type]; + creatureInfo = &g243_CreatureInfo[group->_type]; creatureAspectStruct = &g219_CreatureAspects[creatureInfo->_creatureAspectIndex]; creatureSize = getFlag(creatureInfo->_attributes, kMaskCreatureInfo_size); creatureGraphicInfoGreen = creatureInfo->_graphicInfo; @@ -2581,7 +2581,7 @@ continue; thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */ do { - if ((thingParam.getType() == kProjectileThingType) && (thingParam.getCell() == cellYellowBear)) { + if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) { projectile = (Projectile*)dunMan.getThingData(thingParam); if ((AL_4_projectileAspect = dunMan.getProjectileAspect(projectile->_object)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */ objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)]; @@ -2720,26 +2720,26 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; uint16 explosionScaleIndex = AL_1_viewSquareExplosionIndex / 3; thingParam = firstThingToDraw; /* Restart processing list of things from the beginning. The next loop draws only explosion things among the list */ do { - if (thingParam.getType() == kExplosionThingType) { + if (thingParam.getType() == k15_ExplosionThingType) { AL_2_cellPurpleMan = thingParam.getCell(); explosion = (Explosion*)dunMan.getThingData(thingParam); - if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= kExplosionType_RebirthStep1)) + if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= k100_ExplosionType_RebirthStep1)) && ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion) || (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion) || (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */ continue; smoke = false; - if ((AL_4_explosionType == kExplosionType_Fireball) || (AL_4_explosionType == kExplosionType_LightningBolt) || (AL_4_explosionType == kExplosionType_RebirthStep2)) { + if ((AL_4_explosionType == k0_ExplosionType_Fireball) || (AL_4_explosionType == k2_ExplosionType_LightningBolt) || (AL_4_explosionType == k101_ExplosionType_RebirthStep2)) { AL_4_explosionAspectIndex = k0_ExplosionAspectFire; } else { - if ((AL_4_explosionType == kExplosionType_PoisonBolt) || (AL_4_explosionType == kExplosionType_PoisonCloud)) { + if ((AL_4_explosionType == k6_ExplosionType_PoisonBolt) || (AL_4_explosionType == k7_ExplosionType_PoisonCloud)) { AL_4_explosionAspectIndex = k2_ExplosionAspectPoison; } else { - if (AL_4_explosionType == kExplosionType_Smoke) { + if (AL_4_explosionType == k40_ExplosionType_Smoke) { smoke = true; AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke; } else { - if (AL_4_explosionType == kExplosionType_RebirthStep1) { + if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) { objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->ordinalToIndex(-dunMan.getProjectileAspect(Thing::_explLightningBolt))]; AL_6_bitmapRedBanana = getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1)); explosionCoordinates = g228_RebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3]; @@ -2753,7 +2753,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; } goto T0115200_DrawExplosion; } - if (AL_4_explosionType == kExplosionType_Fluxcage) { + if (AL_4_explosionType == k50_ExplosionType_Fluxcage) { if (AL_1_viewSquareExplosionIndex >= k4_ViewSquare_D3L_Explosion) { fluxcageExplosion = explosion; } diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index b224dff229..76aab71ff7 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -43,7 +43,7 @@ GroupMan::~GroupMan() { } void GroupMan::initActiveGroups() { - if (_vm->_dungeonMan->_messages._newGame) + if (_vm->_dungeonMan->_messages._g298_newGame) _maxActiveGroupCount = 60; if (_activeGroups) delete[] _activeGroups; @@ -55,7 +55,7 @@ void GroupMan::initActiveGroups() { uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) { byte cells; cells = group->_cells; - if (mapIndex == _vm->_dungeonMan->_currMap._currPartyMapIndex) + if (mapIndex == _vm->_dungeonMan->_currMap._g309_currPartyMapIndex) cells = _activeGroups[cells]._cells; return cells; } @@ -63,20 +63,20 @@ uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) { byte gGroupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_GroupDirections uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) { - if (mapIndex == _vm->_dungeonMan->_currMap._currPartyMapIndex) + if (mapIndex == _vm->_dungeonMan->_currMap._g309_currPartyMapIndex) return _activeGroups[group->getActiveGroupIndex()]._directions; return gGroupDirections[group->getDir()]; } int16 GroupMan::getCreatureOrdinalInCell(Group* group, uint16 cell) { - uint16 currMapIndex = _vm->_dungeonMan->_currMap._index; + uint16 currMapIndex = _vm->_dungeonMan->_currMap._g272_index; byte groupCells = getGroupCells(group, currMapIndex); if (groupCells == kCreatureTypeSingleCenteredCreature) return _vm->indexToOrdinal(0); byte creatureIndex = group->getCount(); - if (getFlag(gCreatureInfo[group->_type]._attributes, kMaskCreatureInfo_size) == kMaskCreatureSizeHalf) { + if (getFlag(g243_CreatureInfo[group->_type]._attributes, kMaskCreatureInfo_size) == kMaskCreatureSizeHalf) { if ((getGroupDirections(group, currMapIndex) & 1) == (cell & 1)) cell = returnPrevVal(cell); diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 0779a7ee0f..742f392865 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -57,9 +57,9 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { if ((championIndex != k4_ChampionCloseInventory) && !cm._champions[championIndex]._currHealth) return; - if (_vm->_pressingEye || _vm->_pressingMouth) + if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) return; - _vm->_stopWaitingForPlayerInput = true; + _vm->_g321_stopWaitingForPlayerInput = true; int16 invChampOrdinal = _inventoryChampionOrdinal; // copy, as the original will be edited if (_vm->indexToOrdinal(championIndex) == invChampOrdinal) { championIndex = k4_ChampionCloseInventory; @@ -192,10 +192,10 @@ void InventoryMan::drawPanel() { _panelContent = kPanelContentFoodWaterPoisoned; switch (thing.getType()) { - case kContainerThingType: + case k9_ContainerThingType: _panelContent = kPanelContentChest; break; - case kScrollThingType: + case k7_ScrollThingType: _panelContent = kPanelContentScroll; break; default: @@ -229,7 +229,7 @@ void InventoryMan::closeChest() { *dunMan.getThingData(thing) = Thing::_endOfList.toUint16(); container->getSlot() = prevThing = thing; } else { - dunMan.linkThingToList(thing, prevThing, kMapXNotOnASquare, 0); + dunMan.linkThingToList(thing, prevThing, kM1_MapXNotOnASquare, 0); prevThing = thing; } } @@ -252,7 +252,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) { DisplayMan &dispMan = *_vm->_displayMan; char stringFirstLine[300]; - _vm->_dungeonMan->decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(kTextTypeScroll | kDecodeEvenIfInvisible)); + _vm->_dungeonMan->decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible)); char *charRed = stringFirstLine; while (*charRed && (*charRed != '\n')) { charRed++; @@ -429,7 +429,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { ChampionMan &champMan = *_vm->_championMan; TextMan &textMan = *_vm->_textMan; - if (_vm->_pressingEye || _vm->_pressingMouth) { + if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) { warning("BUG0_48 The contents of a chest are reorganized when an object with a statistic modifier is placed or removed on a champion"); closeChest(); } @@ -437,9 +437,9 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { uint16 *rawThingPtr = dunMan.getThingData(thingToDraw); drawPanelObjectDescriptionString("\f"); // form feed ThingType thingType = thingToDraw.getType(); - if (thingType == kScrollThingType) { + if (thingType == k7_ScrollThingType) { drawPanelScroll((Scroll*)rawThingPtr); - } else if (thingType == kContainerThingType) { + } else if (thingType == k9_ContainerThingType) { openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye); } else { IconIndice iconIndex = objMan.getIconIndex(thingToDraw); @@ -454,7 +454,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { strcat(str, objMan._objectNames[iconIndex]); // TODO: localization descString = str; - } else if ((thingType == kPotionThingType) + } else if ((thingType == k8_PotionThingType) && (iconIndex != k163_IconIndicePotionWaterFlask) && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) { str[0] = '_' + ((Potion*)rawThingPtr)->getPower() / 40; @@ -476,7 +476,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { uint16 potentialAttribMask; uint16 actualAttribMask; switch (thingType) { - case kWeaponThingType: { + case k5_WeaponThingType: { potentialAttribMask = kDescriptionMaskCursed | kDescriptionMaskPoisoned | kDescriptionMaskBroken; Weapon *weapon = (Weapon*)rawThingPtr; actualAttribMask = (weapon->getCursed() << 3) | (weapon->getPoisoned() << 1) | (weapon->getBroken() << 2); @@ -487,19 +487,19 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { } break; } - case kArmourThingType: { + case k6_ArmourThingType: { potentialAttribMask = kDescriptionMaskCursed | kDescriptionMaskBroken; Armour *armour = (Armour*)rawThingPtr; actualAttribMask = (armour->getCursed() << 3) | (armour->getBroken() << 2); break; } - case kPotionThingType: { + case k8_PotionThingType: { actualAttribMask = kDescriptionMaskConsumable; Potion *potion = (Potion*)rawThingPtr; - actualAttribMask = gObjectInfo[kObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots(); + actualAttribMask = g237_ObjectInfo[k2_ObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots(); break; } - case kJunkThingType: { + case k10_JunkThingType: { Junk *junk = (Junk*)rawThingPtr; if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) { potentialAttribMask = 0; @@ -526,7 +526,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { drawPanelObjectDescriptionString(str); } else { potentialAttribMask = kDescriptionMaskConsumable; - actualAttribMask = gObjectInfo[kObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots(); + actualAttribMask = g237_ObjectInfo[k127_ObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots(); } break; } diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 42f8bad5e0..bd99345c41 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -39,14 +39,14 @@ LoadsaveMan::LoadsaveMan(DMEngine *vm) : _vm(vm) {} LoadgameResponse LoadsaveMan::loadgame() { - bool newGame = _vm->_dungeonMan->_messages._newGame; + bool newGame = _vm->_dungeonMan->_messages._g298_newGame; ChampionMan &cm = *_vm->_championMan; if (newGame) { - _vm->_restartGameAllowed = false; + _vm->_g524_restartGameAllowed = false; cm._g305_partyChampionCount = 0; cm._414_leaderHandObject = Thing::_none; - _vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536); + _vm->_g525_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536); } else { assert(false); // MISSING CODE: load game diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 19912adc0a..20d0f53646 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -98,7 +98,7 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) { IconIndice iconIndex; if (thing == Thing::_none) { iconIndex = k201_IconIndiceActionEmptyHand; - } else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) { + } else if (g237_ObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) { iconIndex = _vm->_objectMan->getIconIndex(thing); } else { dm.clearBitmap(bitmapIcon, 16, 16, k4_ColorCyan); diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 0aca699aaf..5d37884557 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -47,7 +47,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 Thing leaderHandObject = champMan._414_leaderHandObject; int16 sensorCountToProcessPerCell[4]; uint16 cell; - for (cell = kCellNorthWest; cell < kCellSouthWest; ++cell) { + for (cell = k0_CellNorthWest; cell < k3_CellSouthWest; ++cell) { sensorCountToProcessPerCell[cell] = 0; } Thing squareFirstThing; @@ -55,9 +55,9 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 ThingType thingType; while (thingBeingProcessed != Thing::_endOfList) { thingType = thingBeingProcessed.getType(); - if (thingType == kSensorThingType) { + if (thingType == k3_SensorThingType) { sensorCountToProcessPerCell[thingBeingProcessed.getCell()]++; - } else if (thingType >= kGroupThingType) { + } else if (thingType >= k4_GroupThingType) { break; } thingBeingProcessed = dunMan.getNextThing(thingBeingProcessed); @@ -66,14 +66,14 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 while (thingBeingProcessed != Thing::_endOfList) { thingType = thingBeingProcessed.getType(); - if (thingType == kSensorThingType) { + if (thingType == k3_SensorThingType) { cell = thingBeingProcessed.getCell(); sensorCountToProcessPerCell[cell]--; Sensor *sensor = (Sensor*)dunMan.getThingData(thingBeingProcessed); // IF YOU CHECK ME, I'LL CALL THE COPS! SensorType sensorType = sensor->getType(); - if (sensorType == kSensorDisabled) + if (sensorType == k0_SensorDisabled) goto T0275058_ProceedToNextThing; - if ((champMan._g411_leaderIndex == kM1_ChampionNone) && (sensorType != kSensorWallChampionPortrait)) + if ((champMan._g411_leaderIndex == kM1_ChampionNone) && (sensorType != k127_SensorWallChampionPortrait)) goto T0275058_ProceedToNextThing; if (cell != cellParam) goto T0275058_ProceedToNextThing; @@ -81,34 +81,34 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 int16 sensorEffect = sensor->getEffectA(); bool doNotTriggerSensor; switch (sensorType) { - case kSensorWallOrnClick: + case k1_SensorWallOrnClick: doNotTriggerSensor = false; - if (sensor->getEffectA() == kSensorEffHold) { + if (sensor->getEffectA() == k3_SensorEffHold) { goto T0275058_ProceedToNextThing; } break; - case kSensorWallOrnClickWithAnyObj: + case k2_SensorWallOrnClickWithAnyObj: doNotTriggerSensor = (champMan._g415_leaderEmptyHanded != sensor->getRevertEffectA()); break; - case kSensorWallOrnClickWithSpecObjRemovedSensor: - case kSensorWallOrnClickWithSpecObjRemovedRotateSensors: + case k17_SensorWallOrnClickWithSpecObjRemovedSensor: + case k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors: if (sensorCountToProcessPerCell[cell]) goto T0275058_ProceedToNextThing; - case kSensorWallOrnClickWithSpecObj: - case kSensorWallOrnClickWithSpecObjRemoved: + case k3_SensorWallOrnClickWithSpecObj: + case k4_SensorWallOrnClickWithSpecObjRemoved: doNotTriggerSensor = ((sensorData == objMan.getObjectType(leaderHandObject)) == sensor->getRevertEffectA()); - if (!doNotTriggerSensor && (sensorType == kSensorWallOrnClickWithSpecObjRemovedSensor)) { + if (!doNotTriggerSensor && (sensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) { if (lastProcessedThing == thingBeingProcessed) break; ((Sensor*)dunMan.getThingData(lastProcessedThing))->setNextThing(sensor->getNextThing()); sensor->setNextThing(Thing::_none); thingBeingProcessed = lastProcessedThing; } - if (!doNotTriggerSensor && (sensorType == kSensorWallOrnClickWithSpecObjRemovedRotateSensors)) { + if (!doNotTriggerSensor && (sensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors)) { warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect"); } break; - case kSensorWallObjGeneratorRotateSensors: + case k12_SensorWallObjGeneratorRotateSensors: if (sensorCountToProcessPerCell[cell]) goto T0275058_ProceedToNextThing; doNotTriggerSensor = !champMan._g415_leaderEmptyHanded; @@ -116,7 +116,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect"); } break; - case kSensorWallSingleObjStorageRotateSensors: + case k13_SensorWallSingleObjStorageRotateSensors: if (champMan._g415_leaderEmptyHanded) { warning("MISSING CODE: F0273_SENSOR_GetObjectOfTypeInCell"); warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList"); @@ -128,13 +128,13 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 leaderHandObject = Thing::_none; } warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect"); - if ((sensorEffect == kSensorEffHold) && !champMan._g415_leaderEmptyHanded) { + if ((sensorEffect == k3_SensorEffHold) && !champMan._g415_leaderEmptyHanded) { doNotTriggerSensor = true; } else { doNotTriggerSensor = false; } break; - case kSensorWallObjExchanger: { + case k16_SensorWallObjExchanger: { if (sensorCountToProcessPerCell[cell]) goto T0275058_ProceedToNextThing; Thing thingOnSquare = dunMan.getSquareFirstThing(mapX, mapY); @@ -147,15 +147,15 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 doNotTriggerSensor = false; break; } - case kSensorWallChampionPortrait: + case k127_SensorWallChampionPortrait: champMan.addCandidateChampionToParty(sensorData); goto T0275058_ProceedToNextThing; default: goto T0275058_ProceedToNextThing; } - if (sensorEffect == kSensorEffHold) { - sensorEffect = doNotTriggerSensor ? kSensorEffClear : kSensorEffSet; + if (sensorEffect == k3_SensorEffHold) { + sensorEffect = doNotTriggerSensor ? k1_SensorEffClear : k0_SensorEffSet; doNotTriggerSensor = false; } @@ -165,16 +165,16 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } if (!champMan._g415_leaderEmptyHanded && - ((sensorType == kSensorWallOrnClickWithSpecObjRemoved) || - (sensorType == kSensorWallOrnClickWithSpecObjRemovedRotateSensors) || - (sensorType == kSensorWallOrnClickWithSpecObjRemovedSensor))) { + ((sensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || + (sensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || + (sensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) { *((Thing*)dunMan.getThingData(leaderHandObject)) = Thing::_none; warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand"); leaderHandObject = Thing::_none; } else { warning("MISSING CODE: (leaderHandObject = F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator(sensorData)"); - if (champMan._g415_leaderEmptyHanded && (sensorType == kSensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_none)) { + if (champMan._g415_leaderEmptyHanded && (sensorType == k12_SensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_none)) { warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand"); } } @@ -182,7 +182,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 } goto T0275058_ProceedToNextThing; } - if (thingType >= kGroupThingType) + if (thingType >= k4_GroupThingType) break; T0275058_ProceedToNextThing: lastProcessedThing = thingBeingProcessed; diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index ae67904beb..810847caad 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -127,7 +127,7 @@ IconIndice ObjectMan::getObjectType(Thing thing) { int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing); if (objectInfoIndex != -1) { - objectInfoIndex = gObjectInfo[objectInfoIndex]._type; + objectInfoIndex = g237_ObjectInfo[objectInfoIndex]._type; } return (IconIndice)objectInfoIndex; } @@ -145,7 +145,7 @@ IconIndice ObjectMan::getIconIndex(Thing thing) { uint16 *rawType = _vm->_dungeonMan->getThingData(thing); switch (iconIndex) { case k0_IconIndiceJunkCompassNorth: - iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_currMap._partyDir); + iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_currMap._g308_partyDir); break; case k4_IconIndiceWeaponTorchUnlit: { Weapon weapon(rawType); diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 150c3c2ed6..101fccad42 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -44,7 +44,7 @@ Timeline::~Timeline() { void Timeline::initTimeline() { _events = new TimelineEvent[_eventMaxCount]; _timeline = new uint16[_eventMaxCount]; - if (_vm->_dungeonMan->_messages._newGame) { + if (_vm->_dungeonMan->_messages._g298_newGame) { for (int16 i = 0; i < _eventMaxCount; ++i) _events->_type = kTMEventTypeNone; _eventCount = 0; -- cgit v1.2.3 From ce45a71ba0d294f5282c05859ac4097d26482b44 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 2 Jul 2016 02:58:44 +0200 Subject: DM: More renaming --- engines/dm/champion.cpp | 4 +- engines/dm/dm.cpp | 8 +- engines/dm/dungeonman.cpp | 30 +-- engines/dm/eventman.cpp | 462 +++++++++++++++++++++++----------------------- engines/dm/eventman.h | 289 ++++++++++++++--------------- engines/dm/group.h | 2 +- engines/dm/inventory.cpp | 8 +- 7 files changed, 402 insertions(+), 401 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b8dac7ff3e..0e062bbee6 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -852,7 +852,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { { // block so goto won't skip AL_0_championIconIndex initialization int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._g308_partyDir); - if ((champAttributes & k28_ChampionIcons) && (eventMan._useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) { + if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) { dispMan.clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]); dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._g308_partyDir) * 19, 0, g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray); @@ -1006,7 +1006,7 @@ void ChampionMan::renameChampion(Champion* champ) { static Box okButtonBox(197, 215, 147, 155); // inclusive boundaries, constructor adds +1 for (;;) { _vm->_eventMan->processInput(); - if (_vm->_eventMan->hasPendingClick(clickPos, kLeftMouseButton) && okButtonBox.isPointInside(clickPos)) { + if (_vm->_eventMan->hasPendingClick(clickPos, k1_LeftMouseButton) && okButtonBox.isPointInside(clickPos)) { return; } dispMan.updateScreen(); diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 83fb506b6a..6f0c4658e4 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -169,14 +169,14 @@ void DMEngine::startGame() { _g333_pressingMouth = false; _g334_stopPressingMouth = false; _g340_highlightBoxInversionRequested = false; - _eventMan->_highlightBoxEnabled = false; + _eventMan->_g341_highlightBoxEnabled = false; _championMan->_g300_partyIsSleeping = false; _championMan->_g506_actingChampionOrdinal = indexToOrdinal(kM1_ChampionNone); _menuMan->_actionAreaContainsIcons = true; - _eventMan->_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone); + _eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone); - _eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface; - _eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement; + _eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface; + _eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement; warning("MISSING CODE: set primary/secondary keyboard input"); processNewPartyMap(_dungeonMan->_currMap._g309_currPartyMapIndex); diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 4ce3c186f9..7b12bf4752 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -495,7 +495,7 @@ void DungeonMan::decompressDungeonFile() { f.close(); } -uint8 gAdditionalThingCounts[16] = { +byte g236_AdditionalThingCounts[16] = { // @ G0236_auc_Graphic559_AdditionalThingCounts{ 0, /* Door */ 0, /* Teleporter */ 0, /* Text String */ @@ -512,10 +512,10 @@ uint8 gAdditionalThingCounts[16] = { 0, /* Unused */ 60, /* Projectile */ 50 /* Explosion */ -}; // @ G0236_auc_Graphic559_AdditionalThingCounts +}; // this is the number of uint16s the data has to be stored, not the length of the data in dungeon.dat! -unsigned char gThingDataWordCount[16] = { +byte g235_ThingDataWordCount[16] = { // @ G0235_auc_Graphic559_ThingDataByteCount 2, /* Door */ 3, /* Teleporter */ 2, /* Text String */ @@ -532,7 +532,7 @@ unsigned char gThingDataWordCount[16] = { 0, /* Unused */ 5, /* Projectile */ 2 /* Explosion */ -}; // @ G0235_auc_Graphic559_ThingDataByteCount +}; const Thing Thing::_none(0); // @ C0xFFFF_THING_NONE const Thing Thing::_endOfList(0xFFFE); // @ C0xFFFE_THING_ENDOFLIST @@ -658,9 +658,9 @@ void DungeonMan::loadDungeonFile() { for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) { uint16 thingCount = _g278_fileHeader._thingCounts[thingType]; if (_messages._g298_newGame) { - _g278_fileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + gAdditionalThingCounts[thingType]); + _g278_fileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + g236_AdditionalThingCounts[thingType]); } - uint16 thingStoreWordCount = gThingDataWordCount[thingType]; + uint16 thingStoreWordCount = g235_ThingDataWordCount[thingType]; if (thingStoreWordCount == 0) continue; @@ -700,7 +700,7 @@ void DungeonMan::loadDungeonFile() { if (_messages._g298_newGame) { if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType) _vm->_timeline->_eventMaxCount += _g278_fileHeader._thingCounts[thingType]; - for (uint16 i = 0; i < gAdditionalThingCounts[thingType]; ++i) { + for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) { _dunData._g284_thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16(); } } @@ -996,7 +996,7 @@ Thing DungeonMan::getNextThing(Thing thing) { return getThingData(thing)[0]; // :) } -char gMessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings +char g255_MessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings {'x', 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '?', 0, 0, 0, 0, 0, 0, 0 }, */ {'y', 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { '!', 0, 0, 0, 0, 0, 0, 0 }, */ {'T','H','E',' ', 0, 0, 0, 0}, @@ -1029,7 +1029,7 @@ char gMessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559 {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}}; -char gEscReplacementCharacters[32][2] = { // @ G0256_aac_Graphic559_EscapeReplacementCharacters +char g256_EscReplacementCharacters[32][2] = { // @ G0256_aac_Graphic559_EscapeReplacementCharacters {'a', 0}, {'b', 0}, {'c', 0}, @@ -1062,7 +1062,7 @@ char gEscReplacementCharacters[32][2] = { // @ G0256_aac_Graphic559_EscapeReplac {'5', 0}, {'6', 0}, {'7', 0}}; -char gInscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_InscriptionEscapeReplacementStrings +char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_InscriptionEscapeReplacementStrings {28, 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ {29, 0, 0, 0, 0, 0, 0, 0}, /* Atari ST Version 1.0 1987-12-08 1987-12-11 1.1 1.2EN 1.2GE: { 0, 0, 0, 0, 0, 0, 0, 0 }, */ {19, 7, 4, 26, 0, 0, 0, 0}, @@ -1131,12 +1131,12 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { *destString = '\0'; if (escChar == 30) { if (type != k0_TextTypeInscription) { - escReplString = gMessageAndScrollEscReplacementStrings[code]; + escReplString = g255_MessageAndScrollEscReplacementStrings[code]; } else { - escReplString = gInscriptionEscReplacementStrings[code]; + escReplString = g257_InscriptionEscReplacementStrings[code]; } } else { - escReplString = gEscReplacementCharacters[code]; + escReplString = g256_EscReplacementCharacters[code]; } strcat(destString, escReplString); destString += strlen(escReplString); @@ -1166,7 +1166,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { uint16 DungeonMan::getObjectWeight(Thing thing) { - static const uint16 junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo + static const uint16 g241_junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo // COMPASS - WATERSKIN - JEWEL SYMAL - ILLUMULET - ASHES 1, 3, 2, 2, 4, // BONES - COPPER COIN - SILVER COIN - GOLD COIN - IRON KEY @@ -1200,7 +1200,7 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { return g239_ArmourInfo[Armour(getThingData(thing)).getType()]._weight; case k10_JunkThingType: { Junk junk(getThingData(thing)); - uint16 weight = junkInfo[junk.getType()]; + uint16 weight = g241_junkInfo[junk.getType()]; if (junk.getType() == k1_JunkTypeWaterskin) weight += junk.getChargeCount() * 2; return weight; diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 4a60768fda..69886e54c6 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -40,226 +40,226 @@ namespace DM { -Box gBoxObjectPiles[4] = { // @ G0462_as_Graphic561_Box_ObjectPiles +Box g462_BoxObjectPiles[4] = { // @ G0462_as_Graphic561_Box_ObjectPiles /* { X1, X2, Y1, Y2 } */ Box(24, 111, 148, 168), /* Front left */ Box(112, 199, 148, 168), /* Front right */ Box(112, 183, 122, 147), /* Back right */ Box(40, 111, 122, 147)}; /* Back left */ -MouseInput gPrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4] +MouseInput g445_PrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ - MouseInput(kCommandEntranceEnterDungeon, 244, 298, 45, 58, kLeftMouseButton), + MouseInput(k200_CommandEntranceEnterDungeon, 244, 298, 45, 58, k1_LeftMouseButton), // Strangerke - C201_COMMAND_ENTRANCE_RESUME isn't present in the demo - MouseInput(kCommandEntranceResume, 244, 298, 76, 93, kLeftMouseButton), - MouseInput(kCommandEntranceDrawCredits, 248, 293, 187, 199, kLeftMouseButton), - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gPrimaryMouseInput_RestartGame[2] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2] + MouseInput(k201_CommandEntranceResume, 244, 298, 76, 93, k1_LeftMouseButton), + MouseInput(k202_CommandEntranceDrawCredits, 248, 293, 187, 199, k1_LeftMouseButton), + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g446_PrimaryMouseInput_RestartGame[2] = { // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ - MouseInput(kCommandRestartGame, 103, 217, 145, 159, kLeftMouseButton), - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gPrimaryMouseInput_Interface[20] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20] + MouseInput(k215_CommandRestartGame, 103, 217, 145, 159, k1_LeftMouseButton), + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g447_PrimaryMouseInput_Interface[20] = { // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ - MouseInput(kCommandClickInChampion_0_StatusBox, 0, 42, 0, 28, kLeftMouseButton), - MouseInput(kCommandClickInChampion_1_StatusBox, 69, 111, 0, 28, kLeftMouseButton), - MouseInput(kCommandClickInChampion_2_StatusBox, 138, 180, 0, 28, kLeftMouseButton), - MouseInput(kCommandClickInChampion_3_StatusBox, 207, 249, 0, 28, kLeftMouseButton), - MouseInput(kCommandClickOnChamptionIcon_Top_Left, 274, 299, 0, 13, kLeftMouseButton), - MouseInput(kCommandClickOnChamptionIcon_Top_Right, 301, 319, 0, 13, kLeftMouseButton), - MouseInput(kCommandClickOnChamptionIcon_Lower_Right, 301, 319, 15, 28, kLeftMouseButton), - MouseInput(kCommandClickOnChamptionIcon_Lower_Left, 274, 299, 15, 28, kLeftMouseButton), - MouseInput(kCommandToggleInventoryChampion_0, 43, 66, 0, 28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 44. swapped with 4 next entries */ - MouseInput(kCommandToggleInventoryChampion_1, 112, 135, 0, 28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 113. swapped with 4 next entries */ - MouseInput(kCommandToggleInventoryChampion_2, 181, 204, 0, 28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 182. swapped with 4 next entries */ - MouseInput(kCommandToggleInventoryChampion_3, 250, 273, 0, 28, kLeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 251. swapped with 4 next entries */ - MouseInput(kCommandToggleInventoryChampion_0, 0, 66, 0, 28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */ - MouseInput(kCommandToggleInventoryChampion_1, 69, 135, 0, 28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */ - MouseInput(kCommandToggleInventoryChampion_2, 138, 204, 0, 28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */ - MouseInput(kCommandToggleInventoryChampion_3, 207, 273, 0, 28, kRightMouseButton), /* Atari ST: swapped with 4 previous entries */ - MouseInput(kCommandClickInSpellArea, 233, 319, 42, 73, kLeftMouseButton), - MouseInput(kCommandClickInActionArea, 233, 319, 77, 121, kLeftMouseButton), - MouseInput(kCommandFreezeGame, 0, 1, 198, 199, kLeftMouseButton), - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gSecondaryMouseInput_Movement[9] = { // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9] + MouseInput(k12_CommandClickInChampion_0_StatusBox, 0, 42, 0, 28, k1_LeftMouseButton), + MouseInput(k13_CommandClickInChampion_1_StatusBox, 69, 111, 0, 28, k1_LeftMouseButton), + MouseInput(k14_CommandClickInChampion_2_StatusBox, 138, 180, 0, 28, k1_LeftMouseButton), + MouseInput(k15_CommandClickInChampion_3_StatusBox, 207, 249, 0, 28, k1_LeftMouseButton), + MouseInput(k125_CommandClickOnChamptionIcon_Top_Left, 274, 299, 0, 13, k1_LeftMouseButton), + MouseInput(k126_CommandClickOnChamptionIcon_Top_Right, 301, 319, 0, 13, k1_LeftMouseButton), + MouseInput(k127_CommandClickOnChamptionIcon_Lower_Right, 301, 319, 15, 28, k1_LeftMouseButton), + MouseInput(k128_CommandClickOnChamptionIcon_Lower_Left, 274, 299, 15, 28, k1_LeftMouseButton), + MouseInput(k7_CommandToggleInventoryChampion_0, 43, 66, 0, 28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 44. swapped with 4 next entries */ + MouseInput(k8_CommandToggleInventoryChampion_1, 112, 135, 0, 28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 113. swapped with 4 next entries */ + MouseInput(k9_CommandToggleInventoryChampion_2, 181, 204, 0, 28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 182. swapped with 4 next entries */ + MouseInput(k10_CommandToggleInventoryChampion_3, 250, 273, 0, 28, k1_LeftMouseButton), /* Atari ST: Only present in CSB 2.x and with Box.X1 = 251. swapped with 4 next entries */ + MouseInput(k7_CommandToggleInventoryChampion_0, 0, 66, 0, 28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */ + MouseInput(k8_CommandToggleInventoryChampion_1, 69, 135, 0, 28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */ + MouseInput(k9_CommandToggleInventoryChampion_2, 138, 204, 0, 28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */ + MouseInput(k10_CommandToggleInventoryChampion_3, 207, 273, 0, 28, k2_RightMouseButton), /* Atari ST: swapped with 4 previous entries */ + MouseInput(k100_CommandClickInSpellArea, 233, 319, 42, 73, k1_LeftMouseButton), + MouseInput(k111_CommandClickInActionArea, 233, 319, 77, 121, k1_LeftMouseButton), + MouseInput(k147_CommandFreezeGame, 0, 1, 198, 199, k1_LeftMouseButton), + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g448_SecondaryMouseInput_Movement[9] = { // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ - MouseInput(kCommandTurnLeft, 234, 261, 125, 145, kLeftMouseButton), - MouseInput(kCommandMoveForward, 263, 289, 125, 145, kLeftMouseButton), - MouseInput(kCommandTurnRight, 291, 318, 125, 145, kLeftMouseButton), - MouseInput(kCommandMoveLeft, 234, 261, 147, 167, kLeftMouseButton), - MouseInput(kCommandMoveBackward, 263, 289, 147, 167, kLeftMouseButton), - MouseInput(kCommandMoveRight, 291, 318, 147, 167, kLeftMouseButton), - MouseInput(kCommandClickInDungeonView, 0, 223, 33, 168, kLeftMouseButton), - MouseInput(kCommandToggleInventoryLeader, 0, 319, 33, 199, kRightMouseButton), - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gSecondaryMouseInput_ChampionInventory[38] = { // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38] + MouseInput(k1_CommandTurnLeft, 234, 261, 125, 145, k1_LeftMouseButton), + MouseInput(k3_CommandMoveForward, 263, 289, 125, 145, k1_LeftMouseButton), + MouseInput(k2_CommandTurnRight, 291, 318, 125, 145, k1_LeftMouseButton), + MouseInput(k6_CommandMoveLeft, 234, 261, 147, 167, k1_LeftMouseButton), + MouseInput(k5_CommandMoveBackward, 263, 289, 147, 167, k1_LeftMouseButton), + MouseInput(k4_CommandMoveRight, 291, 318, 147, 167, k1_LeftMouseButton), + MouseInput(k80_CommandClickInDungeonView, 0, 223, 33, 168, k1_LeftMouseButton), + MouseInput(k83_CommandToggleInventoryLeader, 0, 319, 33, 199, k2_RightMouseButton), + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g449_SecondaryMouseInput_ChampionInventory[38] = { // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ - MouseInput(kCommandCloseInventory, 0, 319, 0, 199, kRightMouseButton), - MouseInput(kCommandSaveGame, 174, 182, 36, 44, kLeftMouseButton), - MouseInput(kCommandSleep, 188, 204, 36, 44, kLeftMouseButton), - MouseInput(kCommandCloseInventory, 210, 218, 36, 44, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryReadyHand , 6, 21, 86, 101, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryActionHand, 62, 77, 86, 101, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryHead, 34, 49, 59, 74, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryTorso, 34, 49, 79, 94, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryLegs, 34, 49, 99, 114, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryFeet, 34, 49, 119, 134, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryPouch_2, 6, 21, 123, 138, kLeftMouseButton), - MouseInput(kCommandClickOnMouth, 56, 71, 46, 61, kLeftMouseButton), - MouseInput(kCommandClickOnEye, 12, 27, 46, 61, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_2_1, 79, 94, 106, 121, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_1_2, 62, 77, 123, 138, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_2_2, 79, 94, 123, 138, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryNeck, 6, 21, 66, 81, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryPouch_1, 6, 21, 106, 121, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryQuiverLine_1_1, 62, 77, 106, 121, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_1, 66, 81, 66, 81, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_2, 83, 98, 49, 64, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_3, 100, 115, 49, 64, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_4, 117, 132, 49, 64, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_5, 134, 149, 49, 64, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_6, 151, 166, 49, 64, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_7, 168, 183, 49, 64, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_8, 185, 200, 49, 64, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_2_9, 202, 217, 49, 64, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_2, 83, 98, 66, 81, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_3, 100, 115, 66, 81, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_4, 117, 132, 66, 81, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_5, 134, 149, 66, 81, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_6, 151, 166, 66, 81, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_7, 168, 183, 66, 81, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_8, 185, 200, 66, 81, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxInventoryBackpackLine_1_9, 202, 217, 66, 81, kLeftMouseButton), - MouseInput(kCommandClickInPanel, 96, 223, 83, 167, kLeftMouseButton), - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gPrimaryMouseInput_PartySleeping[3] = { // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3] + MouseInput(k11_CommandCloseInventory, 0, 319, 0, 199, k2_RightMouseButton), + MouseInput(k140_CommandSaveGame, 174, 182, 36, 44, k1_LeftMouseButton), + MouseInput(k145_CommandSleep, 188, 204, 36, 44, k1_LeftMouseButton), + MouseInput(k11_CommandCloseInventory, 210, 218, 36, 44, k1_LeftMouseButton), + MouseInput(k28_CommandClickOnSlotBoxInventoryReadyHand , 6, 21, 86, 101, k1_LeftMouseButton), + MouseInput(k29_CommandClickOnSlotBoxInventoryActionHand, 62, 77, 86, 101, k1_LeftMouseButton), + MouseInput(k30_CommandClickOnSlotBoxInventoryHead, 34, 49, 59, 74, k1_LeftMouseButton), + MouseInput(k31_CommandClickOnSlotBoxInventoryTorso, 34, 49, 79, 94, k1_LeftMouseButton), + MouseInput(k32_CommandClickOnSlotBoxInventoryLegs, 34, 49, 99, 114, k1_LeftMouseButton), + MouseInput(k33_CommandClickOnSlotBoxInventoryFeet, 34, 49, 119, 134, k1_LeftMouseButton), + MouseInput(k34_CommandClickOnSlotBoxInventoryPouch_2, 6, 21, 123, 138, k1_LeftMouseButton), + MouseInput(k70_CommandClickOnMouth, 56, 71, 46, 61, k1_LeftMouseButton), + MouseInput(k71_CommandClickOnEye, 12, 27, 46, 61, k1_LeftMouseButton), + MouseInput(k35_CommandClickOnSlotBoxInventoryQuiverLine_2_1, 79, 94, 106, 121, k1_LeftMouseButton), + MouseInput(k36_CommandClickOnSlotBoxInventoryQuiverLine_1_2, 62, 77, 123, 138, k1_LeftMouseButton), + MouseInput(k37_CommandClickOnSlotBoxInventoryQuiverLine_2_2, 79, 94, 123, 138, k1_LeftMouseButton), + MouseInput(k38_CommandClickOnSlotBoxInventoryNeck, 6, 21, 66, 81, k1_LeftMouseButton), + MouseInput(k39_CommandClickOnSlotBoxInventoryPouch_1, 6, 21, 106, 121, k1_LeftMouseButton), + MouseInput(k40_CommandClickOnSlotBoxInventoryQuiverLine_1_1, 62, 77, 106, 121, k1_LeftMouseButton), + MouseInput(k41_CommandClickOnSlotBoxInventoryBackpackLine_1_1, 66, 81, 66, 81, k1_LeftMouseButton), + MouseInput(k42_CommandClickOnSlotBoxInventoryBackpackLine_2_2, 83, 98, 49, 64, k1_LeftMouseButton), + MouseInput(k43_CommandClickOnSlotBoxInventoryBackpackLine_2_3, 100, 115, 49, 64, k1_LeftMouseButton), + MouseInput(k44_CommandClickOnSlotBoxInventoryBackpackLine_2_4, 117, 132, 49, 64, k1_LeftMouseButton), + MouseInput(k45_CommandClickOnSlotBoxInventoryBackpackLine_2_5, 134, 149, 49, 64, k1_LeftMouseButton), + MouseInput(k46_CommandClickOnSlotBoxInventoryBackpackLine_2_6, 151, 166, 49, 64, k1_LeftMouseButton), + MouseInput(k47_CommandClickOnSlotBoxInventoryBackpackLine_2_7, 168, 183, 49, 64, k1_LeftMouseButton), + MouseInput(k48_CommandClickOnSlotBoxInventoryBackpackLine_2_8, 185, 200, 49, 64, k1_LeftMouseButton), + MouseInput(k49_CommandClickOnSlotBoxInventoryBackpackLine_2_9, 202, 217, 49, 64, k1_LeftMouseButton), + MouseInput(k50_CommandClickOnSlotBoxInventoryBackpackLine_1_2, 83, 98, 66, 81, k1_LeftMouseButton), + MouseInput(k51_CommandClickOnSlotBoxInventoryBackpackLine_1_3, 100, 115, 66, 81, k1_LeftMouseButton), + MouseInput(k52_CommandClickOnSlotBoxInventoryBackpackLine_1_4, 117, 132, 66, 81, k1_LeftMouseButton), + MouseInput(k53_CommandClickOnSlotBoxInventoryBackpackLine_1_5, 134, 149, 66, 81, k1_LeftMouseButton), + MouseInput(k54_CommandClickOnSlotBoxInventoryBackpackLine_1_6, 151, 166, 66, 81, k1_LeftMouseButton), + MouseInput(k55_CommandClickOnSlotBoxInventoryBackpackLine_1_7, 168, 183, 66, 81, k1_LeftMouseButton), + MouseInput(k56_CommandClickOnSlotBoxInventoryBackpackLine_1_8, 185, 200, 66, 81, k1_LeftMouseButton), + MouseInput(k57_CommandClickOnSlotBoxInventoryBackpackLine_1_9, 202, 217, 66, 81, k1_LeftMouseButton), + MouseInput(k81_CommandClickInPanel, 96, 223, 83, 167, k1_LeftMouseButton), + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g450_PrimaryMouseInput_PartySleeping[3] = { // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ - MouseInput(kCommandWakeUp, 0, 223, 33, 168, kLeftMouseButton), - MouseInput(kCommandWakeUp, 0, 223, 33, 168, kRightMouseButton), - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gPrimaryMouseInput_FrozenGame[3] = { // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3] + MouseInput(k146_CommandWakeUp, 0, 223, 33, 168, k1_LeftMouseButton), + MouseInput(k146_CommandWakeUp, 0, 223, 33, 168, k2_RightMouseButton), + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g451_PrimaryMouseInput_FrozenGame[3] = { // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ - MouseInput(kCommandUnfreezeGame, 0, 319, 0, 199, kLeftMouseButton), - MouseInput(kCommandUnfreezeGame, 0, 319, 0, 199, kRightMouseButton), - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gMouseInput_ActionAreaNames[5] = { // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5] + MouseInput(k148_CommandUnfreezeGame, 0, 319, 0, 199, k1_LeftMouseButton), + MouseInput(k148_CommandUnfreezeGame, 0, 319, 0, 199, k2_RightMouseButton), + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g452_MouseInput_ActionAreaNames[5] = { // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ - MouseInput(kCommandClickInActionAreaPass, 285, 318, 77, 83, kLeftMouseButton), - MouseInput(kCommandClickInActionAreaAction_0, 234, 318, 86, 96, kLeftMouseButton), - MouseInput(kCommandClickInActionAreaAction_1, 234, 318, 98, 108, kLeftMouseButton), - MouseInput(kCommandClickInActionAreaAction_2, 234, 318, 110, 120, kLeftMouseButton), - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gMouseInput_ActionAreaIcons[5] = { // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5] + MouseInput(k112_CommandClickInActionAreaPass, 285, 318, 77, 83, k1_LeftMouseButton), + MouseInput(k113_CommandClickInActionAreaAction_0, 234, 318, 86, 96, k1_LeftMouseButton), + MouseInput(k114_CommandClickInActionAreaAction_1, 234, 318, 98, 108, k1_LeftMouseButton), + MouseInput(k115_CommandClickInActionAreaAction_2, 234, 318, 110, 120, k1_LeftMouseButton), + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g453_MouseInput_ActionAreaIcons[5] = { // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ - MouseInput(kCommandClickInActionAreaChampion_0_Action, 233, 252, 86, 120, kLeftMouseButton), - MouseInput(kCommandClickInActionAreaChampion_1_Action, 255, 274, 86, 120, kLeftMouseButton), - MouseInput(kCommandClickInActionAreaChampion_2_Action, 277, 296, 86, 120, kLeftMouseButton), - MouseInput(kCommandClickInActionAreaChampion_3_Action, 299, 318, 86, 120, kLeftMouseButton), - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gMouseInput_SpellArea[9] = { // @ G0454_as_Graphic561_MouseInput_SpellArea[9] + MouseInput(k116_CommandClickInActionAreaChampion_0_Action, 233, 252, 86, 120, k1_LeftMouseButton), + MouseInput(k117_CommandClickInActionAreaChampion_1_Action, 255, 274, 86, 120, k1_LeftMouseButton), + MouseInput(k118_CommandClickInActionAreaChampion_2_Action, 277, 296, 86, 120, k1_LeftMouseButton), + MouseInput(k119_CommandClickInActionAreaChampion_3_Action, 299, 318, 86, 120, k1_LeftMouseButton), + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g454_MouseInput_SpellArea[9] = { // @ G0454_as_Graphic561_MouseInput_SpellArea[9] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ - MouseInput(kCommandClickInSpellAreaSymbol_1, 235, 247, 51, 61, kLeftMouseButton), - MouseInput(kCommandClickInSpellAreaSymbol_2, 249, 261, 51, 61, kLeftMouseButton), - MouseInput(kCommandClickInSpellAreaSymbol_3, 263, 275, 51, 61, kLeftMouseButton), - MouseInput(kCommandClickInSpellAreaSymbol_4, 277, 289, 51, 61, kLeftMouseButton), - MouseInput(kCommandClickInSpellAreaSymbol_5, 291, 303, 51, 61, kLeftMouseButton), - MouseInput(kCommandClickInSpellAreaSymbol_6, 305, 317, 51, 61, kLeftMouseButton), - MouseInput(kCommandClickInSpeallAreaCastSpell, 234, 303, 63, 73, kLeftMouseButton), - MouseInput(kCommandClickInSpellAreaRecantSymbol, 305, 318, 63, 73, kLeftMouseButton), - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gMouseInput_ChampionNamesHands[13] = { // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13] + MouseInput(k101_CommandClickInSpellAreaSymbol_1, 235, 247, 51, 61, k1_LeftMouseButton), + MouseInput(k102_CommandClickInSpellAreaSymbol_2, 249, 261, 51, 61, k1_LeftMouseButton), + MouseInput(k103_CommandClickInSpellAreaSymbol_3, 263, 275, 51, 61, k1_LeftMouseButton), + MouseInput(k104_CommandClickInSpellAreaSymbol_4, 277, 289, 51, 61, k1_LeftMouseButton), + MouseInput(k105_CommandClickInSpellAreaSymbol_5, 291, 303, 51, 61, k1_LeftMouseButton), + MouseInput(k106_CommandClickInSpellAreaSymbol_6, 305, 317, 51, 61, k1_LeftMouseButton), + MouseInput(k108_CommandClickInSpeallAreaCastSpell, 234, 303, 63, 73, k1_LeftMouseButton), + MouseInput(k107_CommandClickInSpellAreaRecantSymbol, 305, 318, 63, 73, k1_LeftMouseButton), + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g455_MouseInput_ChampionNamesHands[13] = { // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ - MouseInput(kCommandSetLeaderChampion_0, 0, 42, 0, 6, kLeftMouseButton), - MouseInput(kCommandSetLeaderChampion_1, 69, 111, 0, 6, kLeftMouseButton), - MouseInput(kCommandSetLeaderChampion_2, 138, 180, 0, 6, kLeftMouseButton), - MouseInput(kCommandSetLeaderChampion_3, 207, 249, 0, 6, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChampion_0_StatusBoxReadyHand, 4, 19, 10, 25, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChampion_0_StatusBoxActionHand, 24, 39, 10, 25, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChampion_1_StatusBoxReadyHand, 73, 88, 10, 25, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChampion_1_StatusBoxActionHand, 93, 108, 10, 25, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChampion_2_StatusBoxReadyHand, 142, 157, 10, 25, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChampion_2_StatusBoxActionHand, 162, 177, 10, 25, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChampion_3_StatusBoxReadyHand, 211, 226, 10, 25, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChampion_3_StatusBoxActionHand, 231, 246, 10, 25, kLeftMouseButton), - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gMouseInput_PanelChest[9] = { // @ G0456_as_Graphic561_MouseInput_PanelChest[9] + MouseInput(k16_CommandSetLeaderChampion_0, 0, 42, 0, 6, k1_LeftMouseButton), + MouseInput(k17_CommandSetLeaderChampion_1, 69, 111, 0, 6, k1_LeftMouseButton), + MouseInput(k18_CommandSetLeaderChampion_2, 138, 180, 0, 6, k1_LeftMouseButton), + MouseInput(k19_CommandSetLeaderChampion_3, 207, 249, 0, 6, k1_LeftMouseButton), + MouseInput(k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand, 4, 19, 10, 25, k1_LeftMouseButton), + MouseInput(k21_CommandClickOnSlotBoxChampion_0_StatusBoxActionHand, 24, 39, 10, 25, k1_LeftMouseButton), + MouseInput(k22_CommandClickOnSlotBoxChampion_1_StatusBoxReadyHand, 73, 88, 10, 25, k1_LeftMouseButton), + MouseInput(k23_CommandClickOnSlotBoxChampion_1_StatusBoxActionHand, 93, 108, 10, 25, k1_LeftMouseButton), + MouseInput(k24_CommandClickOnSlotBoxChampion_2_StatusBoxReadyHand, 142, 157, 10, 25, k1_LeftMouseButton), + MouseInput(k25_CommandClickOnSlotBoxChampion_2_StatusBoxActionHand, 162, 177, 10, 25, k1_LeftMouseButton), + MouseInput(k26_CommandClickOnSlotBoxChampion_3_StatusBoxReadyHand, 211, 226, 10, 25, k1_LeftMouseButton), + MouseInput(k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand, 231, 246, 10, 25, k1_LeftMouseButton), + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g456_MouseInput_PanelChest[9] = { // @ G0456_as_Graphic561_MouseInput_PanelChest[9] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ - MouseInput(kCommandClickOnSlotBoxChest_1, 117, 132, 92, 107, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChest_2, 106, 121, 109, 124, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChest_3, 111, 126, 126, 141, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChest_4, 128, 143, 131, 146, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChest_5, 145, 160, 134, 149, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChest_6, 162, 177, 136, 151, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChest_7, 179, 194, 137, 152, kLeftMouseButton), - MouseInput(kCommandClickOnSlotBoxChest_8, 196, 211, 138, 153, kLeftMouseButton), - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gMouseInput_PanelResurrectReincarnateCancel[4] = { // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4] + MouseInput(k58_CommandClickOnSlotBoxChest_1, 117, 132, 92, 107, k1_LeftMouseButton), + MouseInput(k59_CommandClickOnSlotBoxChest_2, 106, 121, 109, 124, k1_LeftMouseButton), + MouseInput(k60_CommandClickOnSlotBoxChest_3, 111, 126, 126, 141, k1_LeftMouseButton), + MouseInput(k61_CommandClickOnSlotBoxChest_4, 128, 143, 131, 146, k1_LeftMouseButton), + MouseInput(k62_CommandClickOnSlotBoxChest_5, 145, 160, 134, 149, k1_LeftMouseButton), + MouseInput(k63_CommandClickOnSlotBoxChest_6, 162, 177, 136, 151, k1_LeftMouseButton), + MouseInput(k64_CommandClickOnSlotBoxChest_7, 179, 194, 137, 152, k1_LeftMouseButton), + MouseInput(k65_CommandClickOnSlotBoxChest_8, 196, 211, 138, 153, k1_LeftMouseButton), + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g457_MouseInput_PanelResurrectReincarnateCancel[4] = { // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ - MouseInput(kCommandClickInPanelResurrect, 108, 158, 90, 138, kLeftMouseButton), /* Atari ST: Box = 104, 158, 86, 142 */ - MouseInput(kCommandClickInPanelReincarnate, 161, 211, 90, 138, kLeftMouseButton), /* Atari ST: Box = 163, 217, 86, 142 */ - MouseInput(kCommandClickInPanelCancel, 108, 211, 141, 153, kLeftMouseButton), /* Atari ST: Box = 104, 217, 146, 156 */ - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; - - -MouseInput gPrimaryMouseInput_ViewportDialog1Choice[2] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2] - MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 138, 152, kLeftMouseButton), /* Bottom button */ - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gPrimaryMouseInput_ViewportDialog2Choices[3] = { // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3] - MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 101, 115, kLeftMouseButton), /* Top button */ - MouseInput(kCommandClickOnDialogChoice_2, 16, 207, 138, 152, kLeftMouseButton), /* Bottom button */ - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gPrimaryMouseInput_ViewportDialog3Choices[4] = { // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4] - MouseInput(kCommandClickOnDialogChoice_1, 16, 207, 101, 115, kLeftMouseButton), /* Top button */ - MouseInput(kCommandClickOnDialogChoice_2, 16, 101, 138, 152, kLeftMouseButton), /* Lower left button */ - MouseInput(kCommandClickOnDialogChoice_3, 123, 207, 138, 152, kLeftMouseButton), /* Lower right button */ - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gPrimaryMouseInput_ViewportDialog4Choices[5] = { // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5] - MouseInput(kCommandClickOnDialogChoice_1, 16, 101, 101, 115, kLeftMouseButton), /* Top left button */ - MouseInput(kCommandClickOnDialogChoice_2, 123, 207, 101, 115, kLeftMouseButton), /* Top right button */ - MouseInput(kCommandClickOnDialogChoice_3, 16, 101, 138, 152, kLeftMouseButton), /* Lower left button */ - MouseInput(kCommandClickOnDialogChoice_4, 123, 207, 138, 152, kLeftMouseButton), /* Lower right button */ - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gPrimaryMouseInput_ScreenDialog1Choice[2] = { // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2] - MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 138, 152, kLeftMouseButton), /* Bottom button */ - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gPrimaryMouseInput_ScreenDialog2Choices[3] = { // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3] - MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 101, 115, kLeftMouseButton), /* Top button */ - MouseInput(kCommandClickOnDialogChoice_2, 63, 254, 138, 152, kLeftMouseButton), /* Bottom button */ - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gPrimaryMouseInput_ScreenDialog3Choices[4] = { // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4] - MouseInput(kCommandClickOnDialogChoice_1, 63, 254, 101, 115, kLeftMouseButton), /* Top button */ - MouseInput(kCommandClickOnDialogChoice_2, 63, 148, 138, 152, kLeftMouseButton), /* Lower left button */ - MouseInput(kCommandClickOnDialogChoice_3, 170, 254, 138, 152, kLeftMouseButton), /* Lower right button */ - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; -MouseInput gPrimaryMouseInput_ScreenDialog4Choices[5] = { // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5] - MouseInput(kCommandClickOnDialogChoice_1, 63, 148, 101, 115, kLeftMouseButton), /* Top left button */ - MouseInput(kCommandClickOnDialogChoice_2, 170, 254, 101, 115, kLeftMouseButton), /* Top right button */ - MouseInput(kCommandClickOnDialogChoice_3, 63, 148, 138, 152, kLeftMouseButton), /* Lower left button */ - MouseInput(kCommandClickOnDialogChoice_4, 170, 254, 138, 152, kLeftMouseButton), /* Lower right button */ - MouseInput(kCommandNone, 0, 0, 0, 0, kNoneMouseButton)}; - -MouseInput* gPrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets - {gPrimaryMouseInput_ViewportDialog1Choice, - gPrimaryMouseInput_ViewportDialog2Choices, - gPrimaryMouseInput_ViewportDialog3Choices, - gPrimaryMouseInput_ViewportDialog4Choices}, - {gPrimaryMouseInput_ScreenDialog1Choice, - gPrimaryMouseInput_ScreenDialog2Choices, - gPrimaryMouseInput_ScreenDialog3Choices, - gPrimaryMouseInput_ScreenDialog4Choices},}; + MouseInput(k160_CommandClickInPanelResurrect, 108, 158, 90, 138, k1_LeftMouseButton), /* Atari ST: Box = 104, 158, 86, 142 */ + MouseInput(k161_CommandClickInPanelReincarnate, 161, 211, 90, 138, k1_LeftMouseButton), /* Atari ST: Box = 163, 217, 86, 142 */ + MouseInput(k162_CommandClickInPanelCancel, 108, 211, 141, 153, k1_LeftMouseButton), /* Atari ST: Box = 104, 217, 146, 156 */ + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; + + +MouseInput g471_PrimaryMouseInput_ViewportDialog1Choice[2] = { // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2] + MouseInput(k210_CommandClickOnDialogChoice_1, 16, 207, 138, 152, k1_LeftMouseButton), /* Bottom button */ + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g472_PrimaryMouseInput_ViewportDialog2Choices[3] = { // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3] + MouseInput(k210_CommandClickOnDialogChoice_1, 16, 207, 101, 115, k1_LeftMouseButton), /* Top button */ + MouseInput(k211_CommandClickOnDialogChoice_2, 16, 207, 138, 152, k1_LeftMouseButton), /* Bottom button */ + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g473_PrimaryMouseInput_ViewportDialog3Choices[4] = { // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4] + MouseInput(k210_CommandClickOnDialogChoice_1, 16, 207, 101, 115, k1_LeftMouseButton), /* Top button */ + MouseInput(k211_CommandClickOnDialogChoice_2, 16, 101, 138, 152, k1_LeftMouseButton), /* Lower left button */ + MouseInput(k212_CommandClickOnDialogChoice_3, 123, 207, 138, 152, k1_LeftMouseButton), /* Lower right button */ + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g474_PrimaryMouseInput_ViewportDialog4Choices[5] = { // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5] + MouseInput(k210_CommandClickOnDialogChoice_1, 16, 101, 101, 115, k1_LeftMouseButton), /* Top left button */ + MouseInput(k211_CommandClickOnDialogChoice_2, 123, 207, 101, 115, k1_LeftMouseButton), /* Top right button */ + MouseInput(k212_CommandClickOnDialogChoice_3, 16, 101, 138, 152, k1_LeftMouseButton), /* Lower left button */ + MouseInput(k213_CommandClickOnDialogChoice_4, 123, 207, 138, 152, k1_LeftMouseButton), /* Lower right button */ + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g475_PrimaryMouseInput_ScreenDialog1Choice[2] = { // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2] + MouseInput(k210_CommandClickOnDialogChoice_1, 63, 254, 138, 152, k1_LeftMouseButton), /* Bottom button */ + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g476_PrimaryMouseInput_ScreenDialog2Choices[3] = { // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3] + MouseInput(k210_CommandClickOnDialogChoice_1, 63, 254, 101, 115, k1_LeftMouseButton), /* Top button */ + MouseInput(k211_CommandClickOnDialogChoice_2, 63, 254, 138, 152, k1_LeftMouseButton), /* Bottom button */ + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g477_PrimaryMouseInput_ScreenDialog3Choices[4] = { // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4] + MouseInput(k210_CommandClickOnDialogChoice_1, 63, 254, 101, 115, k1_LeftMouseButton), /* Top button */ + MouseInput(k211_CommandClickOnDialogChoice_2, 63, 148, 138, 152, k1_LeftMouseButton), /* Lower left button */ + MouseInput(k212_CommandClickOnDialogChoice_3, 170, 254, 138, 152, k1_LeftMouseButton), /* Lower right button */ + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; +MouseInput g478_PrimaryMouseInput_ScreenDialog4Choices[5] = { // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5] + MouseInput(k210_CommandClickOnDialogChoice_1, 63, 148, 101, 115, k1_LeftMouseButton), /* Top left button */ + MouseInput(k211_CommandClickOnDialogChoice_2, 170, 254, 101, 115, k1_LeftMouseButton), /* Top right button */ + MouseInput(k212_CommandClickOnDialogChoice_3, 63, 148, 138, 152, k1_LeftMouseButton), /* Lower left button */ + MouseInput(k213_CommandClickOnDialogChoice_4, 170, 254, 138, 152, k1_LeftMouseButton), /* Lower right button */ + MouseInput(k0_CommandNone, 0, 0, 0, 0, k0_NoneMouseButton)}; + +MouseInput* g480_PrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryMouseInput_DialogSets + {g471_PrimaryMouseInput_ViewportDialog1Choice, + g472_PrimaryMouseInput_ViewportDialog2Choices, + g473_PrimaryMouseInput_ViewportDialog3Choices, + g474_PrimaryMouseInput_ViewportDialog4Choices}, + {g475_PrimaryMouseInput_ScreenDialog1Choice, + g476_PrimaryMouseInput_ScreenDialog2Choices, + g477_PrimaryMouseInput_ScreenDialog3Choices, + g478_PrimaryMouseInput_ScreenDialog4Choices},}; EventManager::EventManager(DMEngine *vm) : _vm(vm) { - _primaryMouseInput = nullptr; - _secondaryMouseInput = nullptr; + _g441_primaryMouseInput = nullptr; + _g442_secondaryMouseInput = nullptr; - _pendingClickPresent = false; - _isCommandQueueLocked = true; - _mousePointerBitmapUpdated = false; - _refreshMousePointerInMainLoop = false; - _highlightBoxEnabled = false; + _g436_pendingClickPresent = false; + _g435_isCommandQueueLocked = true; + _g598_mousePointerBitmapUpdated = false; + _g326_refreshMousePointerInMainLoop = false; + _g341_highlightBoxEnabled = false; _dummyMapIndex = 0; - _pendingClickButton = kNoneMouseButton; + _g439_pendingClickButton = k0_NoneMouseButton; } @@ -350,9 +350,9 @@ void EventManager::processInput() { break; case Common::EVENT_LBUTTONDOWN: case Common::EVENT_RBUTTONDOWN: - _pendingClickPresent = true; - _pendingClickPos = _mousePos; - _pendingClickButton = (event.type == Common::EVENT_LBUTTONDOWN) ? kLeftMouseButton : kRightMouseButton; + _g436_pendingClickPresent = true; + _g437_pendingClickPos = _mousePos; + _g439_pendingClickButton = (event.type == Common::EVENT_LBUTTONDOWN) ? k1_LeftMouseButton : k2_RightMouseButton; break; default: break; @@ -361,31 +361,31 @@ void EventManager::processInput() { } void EventManager::processPendingClick() { - if (_pendingClickPresent) { - _pendingClickPresent = false; - processClick(_pendingClickPos, _pendingClickButton); + if (_g436_pendingClickPresent) { + _g436_pendingClickPresent = false; + processClick(_g437_pendingClickPos, _g439_pendingClickButton); } } void EventManager::processClick(Common::Point mousePos, MouseButton button) { CommandType commandType; - commandType = getCommandTypeFromMouseInput(_primaryMouseInput, mousePos, button); - if (commandType == kCommandNone) - commandType = getCommandTypeFromMouseInput(_secondaryMouseInput, mousePos, button); + commandType = getCommandTypeFromMouseInput(_g441_primaryMouseInput, mousePos, button); + if (commandType == k0_CommandNone) + commandType = getCommandTypeFromMouseInput(_g442_secondaryMouseInput, mousePos, button); - if (commandType != kCommandNone) + if (commandType != k0_CommandNone) _commandQueue.push(Command(mousePos, commandType)); - _isCommandQueueLocked = false; + _g435_isCommandQueueLocked = false; } CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button) { if (!input) - return kCommandNone; - CommandType commandType = kCommandNone; + return k0_CommandNone; + CommandType commandType = k0_CommandNone; - while ((commandType = input->_commandTypeToIssue) != kCommandNone) { + while ((commandType = input->_commandTypeToIssue) != k0_CommandNone) { if (input->_hitbox.isPointInside(mousePos) && input->_button == button) break; input++; @@ -395,9 +395,9 @@ CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common void EventManager::processCommandQueue() { - _isCommandQueueLocked = true; + _g435_isCommandQueueLocked = true; if (_commandQueue.empty()) { - _isCommandQueueLocked = false; + _g435_isCommandQueueLocked = false; processPendingClick(); return; } @@ -407,23 +407,23 @@ void EventManager::processCommandQueue() { int16 commandX = cmd._pos.x; int16 commandY = cmd._pos.y; - _isCommandQueueLocked = false; + _g435_isCommandQueueLocked = false; processPendingClick(); - if ((cmd._type == kCommandTurnRight) || (cmd._type == kCommandTurnLeft)) { + if ((cmd._type == k2_CommandTurnRight) || (cmd._type == k1_CommandTurnLeft)) { commandTurnParty(cmd._type); return; } - if ((cmd._type >= kCommandMoveForward) && (cmd._type <= kCommandMoveLeft)) { + if ((cmd._type >= k3_CommandMoveForward) && (cmd._type <= k6_CommandMoveLeft)) { commandMoveParty(cmd._type); return; } - if (cmd._type == kCommandClickInDungeonView) { + if (cmd._type == k80_CommandClickInDungeonView) { commandProcessType80ClickInDungeonView(commandX, commandY); } - if (cmd._type == kCommandClickInPanel) { + if (cmd._type == k81_CommandClickInPanel) { commandProcess81ClickInPanel(commandX, commandY); } @@ -441,7 +441,7 @@ void EventManager::commandTurnParty(CommandType cmdType) { // DUMMY CODE: should call F0284_CHAMPION_SetPartyDirection instead direction &partyDir = _vm->_dungeonMan->_currMap._g308_partyDir; - (cmdType == kCommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir); + (cmdType == k1_CommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir); // MISSING CODE: process sensors } @@ -456,16 +456,16 @@ void EventManager::commandMoveParty(CommandType cmdType) { CurrMapData &currMap = dungeonMan._currMap; switch (cmdType) { - case kCommandMoveForward: + case k3_CommandMoveForward: dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY); break; - case kCommandMoveLeft: + case k6_CommandMoveLeft: dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, -1, currMap._g306_partyPosX, currMap._g307_partyPosY); break; - case kCommandMoveBackward: + case k5_CommandMoveBackward: dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, -1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY); break; - case kCommandMoveRight: + case k4_CommandMoveRight: dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, 1, currMap._g306_partyPosX, currMap._g307_partyPosY); break; default: @@ -558,7 +558,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY uint16 *rawThingPointer = dunMan.getThingData(thing); if (dunMan._g285_squareAheadElement == k0_ElementTypeWall) { for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k1_ViewCellFrontRight; ++viewCell) { - if (gBoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) { + if (g462_BoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) { warning("F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject"); return; } @@ -588,7 +588,7 @@ T0377019: } else { warning("MISSING CODE: F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown in if branch"); for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k3_ViewCellBackLeft; viewCell++) { - if (gBoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) { + if (g462_BoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) { warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject"); return; } @@ -606,7 +606,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane uint16 championIndex = champMan._g305_partyChampionCount - 1; Champion *champ = &champMan._champions[championIndex]; - if (commandType == kCommandClickInPanelCancel) { + if (commandType == k162_CommandClickInPanelCancel) { invMan.toggleInventory(k4_ChampionCloseInventory); champMan._g299_candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone); if (champMan._g305_partyChampionCount == 1) { @@ -645,7 +645,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane thing = dunMan.getNextThing(thing); } - if (commandType == kCommandClickInPanelReincarnate) { + if (commandType == k161_CommandClickInPanelReincarnate) { champMan.renameChampion(champ); champ->resetSkillsToZero(); @@ -683,15 +683,15 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) { case kPanelContentChest: if (champMan._g411_leaderIndex == kM1_ChampionNone) // if no leader return; - commandType = getCommandTypeFromMouseInput(gMouseInput_PanelChest, Common::Point(x, y), kLeftMouseButton); - if (commandType != kCommandNone) + commandType = getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton); + if (commandType != k0_CommandNone) warning("MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox"); break; case kPanelContentResurrectReincarnate: if (!champMan._g415_leaderEmptyHanded) break; - commandType = getCommandTypeFromMouseInput(gMouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), kLeftMouseButton); - if (commandType != kCommandNone) + commandType = getCommandTypeFromMouseInput(g457_MouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), k1_LeftMouseButton); + if (commandType != k0_CommandNone) commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType); break; default: @@ -700,10 +700,10 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) { } bool EventManager::hasPendingClick(Common::Point& point, MouseButton button) { - if (_pendingClickButton && button == _pendingClickButton) - point = _pendingClickPos; + if (_g439_pendingClickButton && button == _g439_pendingClickButton) + point = _g437_pendingClickPos; - return _pendingClickPresent; + return _g436_pendingClickPresent; } } // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index ca60c46a7b..35f8bd6dc3 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -41,121 +41,121 @@ namespace DM { enum MouseButton { - kNoneMouseButton = 0, // present only because of typesafety - kLeftMouseButton = 1, - kRightMouseButton = 2 + k0_NoneMouseButton = 0, // present only because of typesafety + k1_LeftMouseButton = 1, + k2_RightMouseButton = 2 }; enum CommandType { - kCommandNone = 0, // @ C000_COMMAND_NONE - kCommandTurnLeft = 1, // @ C001_COMMAND_TURN_LEFT - kCommandTurnRight = 2, // @ C002_COMMAND_TURN_RIGHT - kCommandMoveForward = 3, // @ C003_COMMAND_MOVE_FORWARD - kCommandMoveRight = 4, // @ C004_COMMAND_MOVE_RIGHT - kCommandMoveBackward = 5, // @ C005_COMMAND_MOVE_BACKWARD - kCommandMoveLeft = 6, // @ C006_COMMAND_MOVE_LEFT - kCommandToggleInventoryChampion_0 = 7, // @ C007_COMMAND_TOGGLE_INVENTORY_CHAMPION_0 - kCommandToggleInventoryChampion_1 = 8, // @ C008_COMMAND_TOGGLE_INVENTORY_CHAMPION_1 - kCommandToggleInventoryChampion_2 = 9, // @ C009_COMMAND_TOGGLE_INVENTORY_CHAMPION_2 - kCommandToggleInventoryChampion_3 = 10, // @ C010_COMMAND_TOGGLE_INVENTORY_CHAMPION_3 - kCommandCloseInventory = 11, // @ C011_COMMAND_CLOSE_INVENTORY - kCommandClickInChampion_0_StatusBox = 12, // @ C012_COMMAND_CLICK_IN_CHAMPION_0_STATUS_BOX - kCommandClickInChampion_1_StatusBox = 13, // @ C013_COMMAND_CLICK_IN_CHAMPION_1_STATUS_BOX - kCommandClickInChampion_2_StatusBox = 14, // @ C014_COMMAND_CLICK_IN_CHAMPION_2_STATUS_BOX - kCommandClickInChampion_3_StatusBox = 15, // @ C015_COMMAND_CLICK_IN_CHAMPION_3_STATUS_BOX - kCommandSetLeaderChampion_0 = 16, // @ C016_COMMAND_SET_LEADER_CHAMPION_0 - kCommandSetLeaderChampion_1 = 17, // @ C017_COMMAND_SET_LEADER_CHAMPION_1 - kCommandSetLeaderChampion_2 = 18, // @ C018_COMMAND_SET_LEADER_CHAMPION_2 - kCommandSetLeaderChampion_3 = 19, // @ C019_COMMAND_SET_LEADER_CHAMPION_3 - kCommandClickOnSlotBoxChampion_0_StatusBoxReadyHand = 20, // @ C020_COMMAND_CLICK_ON_SLOT_BOX_00_CHAMPION_0_STATUS_BOX_READY_HAND - kCommandClickOnSlotBoxChampion_0_StatusBoxActionHand = 21, // @ C021_COMMAND_CLICK_ON_SLOT_BOX_01_CHAMPION_0_STATUS_BOX_ACTION_HAND - kCommandClickOnSlotBoxChampion_1_StatusBoxReadyHand = 22, // @ C022_COMMAND_CLICK_ON_SLOT_BOX_02_CHAMPION_1_STATUS_BOX_READY_HAND - kCommandClickOnSlotBoxChampion_1_StatusBoxActionHand = 23, // @ C023_COMMAND_CLICK_ON_SLOT_BOX_03_CHAMPION_1_STATUS_BOX_ACTION_HAND - kCommandClickOnSlotBoxChampion_2_StatusBoxReadyHand = 24, // @ C024_COMMAND_CLICK_ON_SLOT_BOX_04_CHAMPION_2_STATUS_BOX_READY_HAND - kCommandClickOnSlotBoxChampion_2_StatusBoxActionHand = 25, // @ C025_COMMAND_CLICK_ON_SLOT_BOX_05_CHAMPION_2_STATUS_BOX_ACTION_HAND - kCommandClickOnSlotBoxChampion_3_StatusBoxReadyHand = 26, // @ C026_COMMAND_CLICK_ON_SLOT_BOX_06_CHAMPION_3_STATUS_BOX_READY_HAND - kCommandClickOnSlotBoxChampion_3_StatusBoxActionHand = 27, // @ C027_COMMAND_CLICK_ON_SLOT_BOX_07_CHAMPION_3_STATUS_BOX_ACTION_HAND - kCommandClickOnSlotBoxInventoryReadyHand = 28, // @ C028_COMMAND_CLICK_ON_SLOT_BOX_08_INVENTORY_READY_HAND - kCommandClickOnSlotBoxInventoryActionHand = 29, // @ C029_COMMAND_CLICK_ON_SLOT_BOX_09_INVENTORY_ACTION_HAND - kCommandClickOnSlotBoxInventoryHead = 30, // @ C030_COMMAND_CLICK_ON_SLOT_BOX_10_INVENTORY_HEAD - kCommandClickOnSlotBoxInventoryTorso = 31, // @ C031_COMMAND_CLICK_ON_SLOT_BOX_11_INVENTORY_TORSO - kCommandClickOnSlotBoxInventoryLegs = 32, // @ C032_COMMAND_CLICK_ON_SLOT_BOX_12_INVENTORY_LEGS - kCommandClickOnSlotBoxInventoryFeet = 33, // @ C033_COMMAND_CLICK_ON_SLOT_BOX_13_INVENTORY_FEET - kCommandClickOnSlotBoxInventoryPouch_2 = 34, // @ C034_COMMAND_CLICK_ON_SLOT_BOX_14_INVENTORY_POUCH_2 - kCommandClickOnSlotBoxInventoryQuiverLine_2_1 = 35, // @ C035_COMMAND_CLICK_ON_SLOT_BOX_15_INVENTORY_QUIVER_LINE2_1 - kCommandClickOnSlotBoxInventoryQuiverLine_1_2 = 36, // @ C036_COMMAND_CLICK_ON_SLOT_BOX_16_INVENTORY_QUIVER_LINE1_2 - kCommandClickOnSlotBoxInventoryQuiverLine_2_2 = 37, // @ C037_COMMAND_CLICK_ON_SLOT_BOX_17_INVENTORY_QUIVER_LINE2_2 - kCommandClickOnSlotBoxInventoryNeck = 38, // @ C038_COMMAND_CLICK_ON_SLOT_BOX_18_INVENTORY_NECK - kCommandClickOnSlotBoxInventoryPouch_1 = 39, // @ C039_COMMAND_CLICK_ON_SLOT_BOX_19_INVENTORY_POUCH_1 - kCommandClickOnSlotBoxInventoryQuiverLine_1_1 = 40, // @ C040_COMMAND_CLICK_ON_SLOT_BOX_20_INVENTORY_QUIVER_LINE1_1 - kCommandClickOnSlotBoxInventoryBackpackLine_1_1 = 41, // @ C041_COMMAND_CLICK_ON_SLOT_BOX_21_INVENTORY_BACKPACK_LINE1_1 - kCommandClickOnSlotBoxInventoryBackpackLine_2_2 = 42, // @ C042_COMMAND_CLICK_ON_SLOT_BOX_22_INVENTORY_BACKPACK_LINE2_2 - kCommandClickOnSlotBoxInventoryBackpackLine_2_3 = 43, // @ C043_COMMAND_CLICK_ON_SLOT_BOX_23_INVENTORY_BACKPACK_LINE2_3 - kCommandClickOnSlotBoxInventoryBackpackLine_2_4 = 44, // @ C044_COMMAND_CLICK_ON_SLOT_BOX_24_INVENTORY_BACKPACK_LINE2_4 - kCommandClickOnSlotBoxInventoryBackpackLine_2_5 = 45, // @ C045_COMMAND_CLICK_ON_SLOT_BOX_25_INVENTORY_BACKPACK_LINE2_5 - kCommandClickOnSlotBoxInventoryBackpackLine_2_6 = 46, // @ C046_COMMAND_CLICK_ON_SLOT_BOX_26_INVENTORY_BACKPACK_LINE2_6 - kCommandClickOnSlotBoxInventoryBackpackLine_2_7 = 47, // @ C047_COMMAND_CLICK_ON_SLOT_BOX_27_INVENTORY_BACKPACK_LINE2_7 - kCommandClickOnSlotBoxInventoryBackpackLine_2_8 = 48, // @ C048_COMMAND_CLICK_ON_SLOT_BOX_28_INVENTORY_BACKPACK_LINE2_8 - kCommandClickOnSlotBoxInventoryBackpackLine_2_9 = 49, // @ C049_COMMAND_CLICK_ON_SLOT_BOX_29_INVENTORY_BACKPACK_LINE2_9 - kCommandClickOnSlotBoxInventoryBackpackLine_1_2 = 50, // @ C050_COMMAND_CLICK_ON_SLOT_BOX_30_INVENTORY_BACKPACK_LINE1_2 - kCommandClickOnSlotBoxInventoryBackpackLine_1_3 = 51, // @ C051_COMMAND_CLICK_ON_SLOT_BOX_31_INVENTORY_BACKPACK_LINE1_3 - kCommandClickOnSlotBoxInventoryBackpackLine_1_4 = 52, // @ C052_COMMAND_CLICK_ON_SLOT_BOX_32_INVENTORY_BACKPACK_LINE1_4 - kCommandClickOnSlotBoxInventoryBackpackLine_1_5 = 53, // @ C053_COMMAND_CLICK_ON_SLOT_BOX_33_INVENTORY_BACKPACK_LINE1_5 - kCommandClickOnSlotBoxInventoryBackpackLine_1_6 = 54, // @ C054_COMMAND_CLICK_ON_SLOT_BOX_34_INVENTORY_BACKPACK_LINE1_6 - kCommandClickOnSlotBoxInventoryBackpackLine_1_7 = 55, // @ C055_COMMAND_CLICK_ON_SLOT_BOX_35_INVENTORY_BACKPACK_LINE1_7 - kCommandClickOnSlotBoxInventoryBackpackLine_1_8 = 56, // @ C056_COMMAND_CLICK_ON_SLOT_BOX_36_INVENTORY_BACKPACK_LINE1_8 - kCommandClickOnSlotBoxInventoryBackpackLine_1_9 = 57, // @ C057_COMMAND_CLICK_ON_SLOT_BOX_37_INVENTORY_BACKPACK_LINE1_9 - kCommandClickOnSlotBoxChest_1 = 58, // @ C058_COMMAND_CLICK_ON_SLOT_BOX_38_CHEST_1 - kCommandClickOnSlotBoxChest_2 = 59, // @ C059_COMMAND_CLICK_ON_SLOT_BOX_39_CHEST_2 - kCommandClickOnSlotBoxChest_3 = 60, // @ C060_COMMAND_CLICK_ON_SLOT_BOX_40_CHEST_3 - kCommandClickOnSlotBoxChest_4 = 61, // @ C061_COMMAND_CLICK_ON_SLOT_BOX_41_CHEST_4 - kCommandClickOnSlotBoxChest_5 = 62, // @ C062_COMMAND_CLICK_ON_SLOT_BOX_42_CHEST_5 - kCommandClickOnSlotBoxChest_6 = 63, // @ C063_COMMAND_CLICK_ON_SLOT_BOX_43_CHEST_6 - kCommandClickOnSlotBoxChest_7 = 64, // @ C064_COMMAND_CLICK_ON_SLOT_BOX_44_CHEST_7 - kCommandClickOnSlotBoxChest_8 = 65, // @ C065_COMMAND_CLICK_ON_SLOT_BOX_45_CHEST_8 - kCommandClickOnMouth = 70, // @ C070_COMMAND_CLICK_ON_MOUTH - kCommandClickOnEye = 71, // @ C071_COMMAND_CLICK_ON_EYE - kCommandClickInDungeonView = 80, // @ C080_COMMAND_CLICK_IN_DUNGEON_VIEW - kCommandClickInPanel = 81, // @ C081_COMMAND_CLICK_IN_PANEL - kCommandToggleInventoryLeader = 83, // @ C083_COMMAND_TOGGLE_INVENTORY_LEADER - kCommandClickInSpellArea = 100, // @ C100_COMMAND_CLICK_IN_SPELL_AREA - kCommandClickInSpellAreaSymbol_1 = 101, // @ C101_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_1 - kCommandClickInSpellAreaSymbol_2 = 102, // @ C102_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_2 - kCommandClickInSpellAreaSymbol_3 = 103, // @ C103_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_3 - kCommandClickInSpellAreaSymbol_4 = 104, // @ C104_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_4 - kCommandClickInSpellAreaSymbol_5 = 105, // @ C105_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_5 - kCommandClickInSpellAreaSymbol_6 = 106, // @ C106_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_6 - kCommandClickInSpellAreaRecantSymbol = 107, // @ C107_COMMAND_CLICK_IN_SPELL_AREA_RECANT_SYMBOL - kCommandClickInSpeallAreaCastSpell = 108, // @ C108_COMMAND_CLICK_IN_SPELL_AREA_CAST_SPELL - kCommandClickInActionArea = 111, // @ C111_COMMAND_CLICK_IN_ACTION_AREA - kCommandClickInActionAreaPass = 112, // @ C112_COMMAND_CLICK_IN_ACTION_AREA_PASS - kCommandClickInActionAreaAction_0 = 113, // @ C113_COMMAND_CLICK_IN_ACTION_AREA_ACTION_0 - kCommandClickInActionAreaAction_1 = 114, // @ C114_COMMAND_CLICK_IN_ACTION_AREA_ACTION_1 - kCommandClickInActionAreaAction_2 = 115, // @ C115_COMMAND_CLICK_IN_ACTION_AREA_ACTION_2 - kCommandClickInActionAreaChampion_0_Action = 116, // @ C116_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_0_ACTION - kCommandClickInActionAreaChampion_1_Action = 117, // @ C117_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_1_ACTION - kCommandClickInActionAreaChampion_2_Action = 118, // @ C118_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_2_ACTION - kCommandClickInActionAreaChampion_3_Action = 119, // @ C119_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_3_ACTION - kCommandClickOnChamptionIcon_Top_Left = 125, // @ C125_COMMAND_CLICK_ON_CHAMPION_ICON_TOP_LEFT - kCommandClickOnChamptionIcon_Top_Right = 126, // @ C126_COMMAND_CLICK_ON_CHAMPION_ICON_TOP_RIGHT - kCommandClickOnChamptionIcon_Lower_Right = 127, // @ C127_COMMAND_CLICK_ON_CHAMPION_ICON_LOWER_RIGHT - kCommandClickOnChamptionIcon_Lower_Left = 128, // @ C128_COMMAND_CLICK_ON_CHAMPION_ICON_LOWER_LEFT - kCommandSaveGame = 140, // @ C140_COMMAND_SAVE_GAME - kCommandSleep = 145, // @ C145_COMMAND_SLEEP - kCommandWakeUp = 146, // @ C146_COMMAND_WAKE_UP - kCommandFreezeGame = 147, // @ C147_COMMAND_FREEZE_GAME - kCommandUnfreezeGame = 148, // @ C148_COMMAND_UNFREEZE_GAME - kCommandClickInPanelResurrect = 160, // @ C160_COMMAND_CLICK_IN_PANEL_RESURRECT - kCommandClickInPanelReincarnate = 161, // @ C161_COMMAND_CLICK_IN_PANEL_REINCARNATE - kCommandClickInPanelCancel = 162, // @ C162_COMMAND_CLICK_IN_PANEL_CANCEL - kCommandEntranceEnterDungeon = 200, // @ C200_COMMAND_ENTRANCE_ENTER_DUNGEON - kCommandEntranceResume = 201, // @ C201_COMMAND_ENTRANCE_RESUME /* Versions 1.x and 2.x command */ - kCommandEntranceDrawCredits = 202, // @ C202_COMMAND_ENTRANCE_DRAW_CREDITS /* Versions 1.x and 2.x command */ - kCommandClickOnDialogChoice_1 = 210, // @ C210_COMMAND_CLICK_ON_DIALOG_CHOICE_1 - kCommandClickOnDialogChoice_2 = 211, // @ C211_COMMAND_CLICK_ON_DIALOG_CHOICE_2 - kCommandClickOnDialogChoice_3 = 212, // @ C212_COMMAND_CLICK_ON_DIALOG_CHOICE_3 - kCommandClickOnDialogChoice_4 = 213, // @ C213_COMMAND_CLICK_ON_DIALOG_CHOICE_4 - kCommandRestartGame = 215 // @ C215_COMMAND_RESTART_GAME + k0_CommandNone = 0, // @ C000_COMMAND_NONE + k1_CommandTurnLeft = 1, // @ C001_COMMAND_TURN_LEFT + k2_CommandTurnRight = 2, // @ C002_COMMAND_TURN_RIGHT + k3_CommandMoveForward = 3, // @ C003_COMMAND_MOVE_FORWARD + k4_CommandMoveRight = 4, // @ C004_COMMAND_MOVE_RIGHT + k5_CommandMoveBackward = 5, // @ C005_COMMAND_MOVE_BACKWARD + k6_CommandMoveLeft = 6, // @ C006_COMMAND_MOVE_LEFT + k7_CommandToggleInventoryChampion_0 = 7, // @ C007_COMMAND_TOGGLE_INVENTORY_CHAMPION_0 + k8_CommandToggleInventoryChampion_1 = 8, // @ C008_COMMAND_TOGGLE_INVENTORY_CHAMPION_1 + k9_CommandToggleInventoryChampion_2 = 9, // @ C009_COMMAND_TOGGLE_INVENTORY_CHAMPION_2 + k10_CommandToggleInventoryChampion_3 = 10, // @ C010_COMMAND_TOGGLE_INVENTORY_CHAMPION_3 + k11_CommandCloseInventory = 11, // @ C011_COMMAND_CLOSE_INVENTORY + k12_CommandClickInChampion_0_StatusBox = 12, // @ C012_COMMAND_CLICK_IN_CHAMPION_0_STATUS_BOX + k13_CommandClickInChampion_1_StatusBox = 13, // @ C013_COMMAND_CLICK_IN_CHAMPION_1_STATUS_BOX + k14_CommandClickInChampion_2_StatusBox = 14, // @ C014_COMMAND_CLICK_IN_CHAMPION_2_STATUS_BOX + k15_CommandClickInChampion_3_StatusBox = 15, // @ C015_COMMAND_CLICK_IN_CHAMPION_3_STATUS_BOX + k16_CommandSetLeaderChampion_0 = 16, // @ C016_COMMAND_SET_LEADER_CHAMPION_0 + k17_CommandSetLeaderChampion_1 = 17, // @ C017_COMMAND_SET_LEADER_CHAMPION_1 + k18_CommandSetLeaderChampion_2 = 18, // @ C018_COMMAND_SET_LEADER_CHAMPION_2 + k19_CommandSetLeaderChampion_3 = 19, // @ C019_COMMAND_SET_LEADER_CHAMPION_3 + k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand = 20, // @ C020_COMMAND_CLICK_ON_SLOT_BOX_00_CHAMPION_0_STATUS_BOX_READY_HAND + k21_CommandClickOnSlotBoxChampion_0_StatusBoxActionHand = 21, // @ C021_COMMAND_CLICK_ON_SLOT_BOX_01_CHAMPION_0_STATUS_BOX_ACTION_HAND + k22_CommandClickOnSlotBoxChampion_1_StatusBoxReadyHand = 22, // @ C022_COMMAND_CLICK_ON_SLOT_BOX_02_CHAMPION_1_STATUS_BOX_READY_HAND + k23_CommandClickOnSlotBoxChampion_1_StatusBoxActionHand = 23, // @ C023_COMMAND_CLICK_ON_SLOT_BOX_03_CHAMPION_1_STATUS_BOX_ACTION_HAND + k24_CommandClickOnSlotBoxChampion_2_StatusBoxReadyHand = 24, // @ C024_COMMAND_CLICK_ON_SLOT_BOX_04_CHAMPION_2_STATUS_BOX_READY_HAND + k25_CommandClickOnSlotBoxChampion_2_StatusBoxActionHand = 25, // @ C025_COMMAND_CLICK_ON_SLOT_BOX_05_CHAMPION_2_STATUS_BOX_ACTION_HAND + k26_CommandClickOnSlotBoxChampion_3_StatusBoxReadyHand = 26, // @ C026_COMMAND_CLICK_ON_SLOT_BOX_06_CHAMPION_3_STATUS_BOX_READY_HAND + k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand = 27, // @ C027_COMMAND_CLICK_ON_SLOT_BOX_07_CHAMPION_3_STATUS_BOX_ACTION_HAND + k28_CommandClickOnSlotBoxInventoryReadyHand = 28, // @ C028_COMMAND_CLICK_ON_SLOT_BOX_08_INVENTORY_READY_HAND + k29_CommandClickOnSlotBoxInventoryActionHand = 29, // @ C029_COMMAND_CLICK_ON_SLOT_BOX_09_INVENTORY_ACTION_HAND + k30_CommandClickOnSlotBoxInventoryHead = 30, // @ C030_COMMAND_CLICK_ON_SLOT_BOX_10_INVENTORY_HEAD + k31_CommandClickOnSlotBoxInventoryTorso = 31, // @ C031_COMMAND_CLICK_ON_SLOT_BOX_11_INVENTORY_TORSO + k32_CommandClickOnSlotBoxInventoryLegs = 32, // @ C032_COMMAND_CLICK_ON_SLOT_BOX_12_INVENTORY_LEGS + k33_CommandClickOnSlotBoxInventoryFeet = 33, // @ C033_COMMAND_CLICK_ON_SLOT_BOX_13_INVENTORY_FEET + k34_CommandClickOnSlotBoxInventoryPouch_2 = 34, // @ C034_COMMAND_CLICK_ON_SLOT_BOX_14_INVENTORY_POUCH_2 + k35_CommandClickOnSlotBoxInventoryQuiverLine_2_1 = 35, // @ C035_COMMAND_CLICK_ON_SLOT_BOX_15_INVENTORY_QUIVER_LINE2_1 + k36_CommandClickOnSlotBoxInventoryQuiverLine_1_2 = 36, // @ C036_COMMAND_CLICK_ON_SLOT_BOX_16_INVENTORY_QUIVER_LINE1_2 + k37_CommandClickOnSlotBoxInventoryQuiverLine_2_2 = 37, // @ C037_COMMAND_CLICK_ON_SLOT_BOX_17_INVENTORY_QUIVER_LINE2_2 + k38_CommandClickOnSlotBoxInventoryNeck = 38, // @ C038_COMMAND_CLICK_ON_SLOT_BOX_18_INVENTORY_NECK + k39_CommandClickOnSlotBoxInventoryPouch_1 = 39, // @ C039_COMMAND_CLICK_ON_SLOT_BOX_19_INVENTORY_POUCH_1 + k40_CommandClickOnSlotBoxInventoryQuiverLine_1_1 = 40, // @ C040_COMMAND_CLICK_ON_SLOT_BOX_20_INVENTORY_QUIVER_LINE1_1 + k41_CommandClickOnSlotBoxInventoryBackpackLine_1_1 = 41, // @ C041_COMMAND_CLICK_ON_SLOT_BOX_21_INVENTORY_BACKPACK_LINE1_1 + k42_CommandClickOnSlotBoxInventoryBackpackLine_2_2 = 42, // @ C042_COMMAND_CLICK_ON_SLOT_BOX_22_INVENTORY_BACKPACK_LINE2_2 + k43_CommandClickOnSlotBoxInventoryBackpackLine_2_3 = 43, // @ C043_COMMAND_CLICK_ON_SLOT_BOX_23_INVENTORY_BACKPACK_LINE2_3 + k44_CommandClickOnSlotBoxInventoryBackpackLine_2_4 = 44, // @ C044_COMMAND_CLICK_ON_SLOT_BOX_24_INVENTORY_BACKPACK_LINE2_4 + k45_CommandClickOnSlotBoxInventoryBackpackLine_2_5 = 45, // @ C045_COMMAND_CLICK_ON_SLOT_BOX_25_INVENTORY_BACKPACK_LINE2_5 + k46_CommandClickOnSlotBoxInventoryBackpackLine_2_6 = 46, // @ C046_COMMAND_CLICK_ON_SLOT_BOX_26_INVENTORY_BACKPACK_LINE2_6 + k47_CommandClickOnSlotBoxInventoryBackpackLine_2_7 = 47, // @ C047_COMMAND_CLICK_ON_SLOT_BOX_27_INVENTORY_BACKPACK_LINE2_7 + k48_CommandClickOnSlotBoxInventoryBackpackLine_2_8 = 48, // @ C048_COMMAND_CLICK_ON_SLOT_BOX_28_INVENTORY_BACKPACK_LINE2_8 + k49_CommandClickOnSlotBoxInventoryBackpackLine_2_9 = 49, // @ C049_COMMAND_CLICK_ON_SLOT_BOX_29_INVENTORY_BACKPACK_LINE2_9 + k50_CommandClickOnSlotBoxInventoryBackpackLine_1_2 = 50, // @ C050_COMMAND_CLICK_ON_SLOT_BOX_30_INVENTORY_BACKPACK_LINE1_2 + k51_CommandClickOnSlotBoxInventoryBackpackLine_1_3 = 51, // @ C051_COMMAND_CLICK_ON_SLOT_BOX_31_INVENTORY_BACKPACK_LINE1_3 + k52_CommandClickOnSlotBoxInventoryBackpackLine_1_4 = 52, // @ C052_COMMAND_CLICK_ON_SLOT_BOX_32_INVENTORY_BACKPACK_LINE1_4 + k53_CommandClickOnSlotBoxInventoryBackpackLine_1_5 = 53, // @ C053_COMMAND_CLICK_ON_SLOT_BOX_33_INVENTORY_BACKPACK_LINE1_5 + k54_CommandClickOnSlotBoxInventoryBackpackLine_1_6 = 54, // @ C054_COMMAND_CLICK_ON_SLOT_BOX_34_INVENTORY_BACKPACK_LINE1_6 + k55_CommandClickOnSlotBoxInventoryBackpackLine_1_7 = 55, // @ C055_COMMAND_CLICK_ON_SLOT_BOX_35_INVENTORY_BACKPACK_LINE1_7 + k56_CommandClickOnSlotBoxInventoryBackpackLine_1_8 = 56, // @ C056_COMMAND_CLICK_ON_SLOT_BOX_36_INVENTORY_BACKPACK_LINE1_8 + k57_CommandClickOnSlotBoxInventoryBackpackLine_1_9 = 57, // @ C057_COMMAND_CLICK_ON_SLOT_BOX_37_INVENTORY_BACKPACK_LINE1_9 + k58_CommandClickOnSlotBoxChest_1 = 58, // @ C058_COMMAND_CLICK_ON_SLOT_BOX_38_CHEST_1 + k59_CommandClickOnSlotBoxChest_2 = 59, // @ C059_COMMAND_CLICK_ON_SLOT_BOX_39_CHEST_2 + k60_CommandClickOnSlotBoxChest_3 = 60, // @ C060_COMMAND_CLICK_ON_SLOT_BOX_40_CHEST_3 + k61_CommandClickOnSlotBoxChest_4 = 61, // @ C061_COMMAND_CLICK_ON_SLOT_BOX_41_CHEST_4 + k62_CommandClickOnSlotBoxChest_5 = 62, // @ C062_COMMAND_CLICK_ON_SLOT_BOX_42_CHEST_5 + k63_CommandClickOnSlotBoxChest_6 = 63, // @ C063_COMMAND_CLICK_ON_SLOT_BOX_43_CHEST_6 + k64_CommandClickOnSlotBoxChest_7 = 64, // @ C064_COMMAND_CLICK_ON_SLOT_BOX_44_CHEST_7 + k65_CommandClickOnSlotBoxChest_8 = 65, // @ C065_COMMAND_CLICK_ON_SLOT_BOX_45_CHEST_8 + k70_CommandClickOnMouth = 70, // @ C070_COMMAND_CLICK_ON_MOUTH + k71_CommandClickOnEye = 71, // @ C071_COMMAND_CLICK_ON_EYE + k80_CommandClickInDungeonView = 80, // @ C080_COMMAND_CLICK_IN_DUNGEON_VIEW + k81_CommandClickInPanel = 81, // @ C081_COMMAND_CLICK_IN_PANEL + k83_CommandToggleInventoryLeader = 83, // @ C083_COMMAND_TOGGLE_INVENTORY_LEADER + k100_CommandClickInSpellArea = 100, // @ C100_COMMAND_CLICK_IN_SPELL_AREA + k101_CommandClickInSpellAreaSymbol_1 = 101, // @ C101_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_1 + k102_CommandClickInSpellAreaSymbol_2 = 102, // @ C102_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_2 + k103_CommandClickInSpellAreaSymbol_3 = 103, // @ C103_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_3 + k104_CommandClickInSpellAreaSymbol_4 = 104, // @ C104_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_4 + k105_CommandClickInSpellAreaSymbol_5 = 105, // @ C105_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_5 + k106_CommandClickInSpellAreaSymbol_6 = 106, // @ C106_COMMAND_CLICK_IN_SPELL_AREA_SYMBOL_6 + k107_CommandClickInSpellAreaRecantSymbol = 107, // @ C107_COMMAND_CLICK_IN_SPELL_AREA_RECANT_SYMBOL + k108_CommandClickInSpeallAreaCastSpell = 108, // @ C108_COMMAND_CLICK_IN_SPELL_AREA_CAST_SPELL + k111_CommandClickInActionArea = 111, // @ C111_COMMAND_CLICK_IN_ACTION_AREA + k112_CommandClickInActionAreaPass = 112, // @ C112_COMMAND_CLICK_IN_ACTION_AREA_PASS + k113_CommandClickInActionAreaAction_0 = 113, // @ C113_COMMAND_CLICK_IN_ACTION_AREA_ACTION_0 + k114_CommandClickInActionAreaAction_1 = 114, // @ C114_COMMAND_CLICK_IN_ACTION_AREA_ACTION_1 + k115_CommandClickInActionAreaAction_2 = 115, // @ C115_COMMAND_CLICK_IN_ACTION_AREA_ACTION_2 + k116_CommandClickInActionAreaChampion_0_Action = 116, // @ C116_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_0_ACTION + k117_CommandClickInActionAreaChampion_1_Action = 117, // @ C117_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_1_ACTION + k118_CommandClickInActionAreaChampion_2_Action = 118, // @ C118_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_2_ACTION + k119_CommandClickInActionAreaChampion_3_Action = 119, // @ C119_COMMAND_CLICK_IN_ACTION_AREA_CHAMPION_3_ACTION + k125_CommandClickOnChamptionIcon_Top_Left = 125, // @ C125_COMMAND_CLICK_ON_CHAMPION_ICON_TOP_LEFT + k126_CommandClickOnChamptionIcon_Top_Right = 126, // @ C126_COMMAND_CLICK_ON_CHAMPION_ICON_TOP_RIGHT + k127_CommandClickOnChamptionIcon_Lower_Right = 127, // @ C127_COMMAND_CLICK_ON_CHAMPION_ICON_LOWER_RIGHT + k128_CommandClickOnChamptionIcon_Lower_Left = 128, // @ C128_COMMAND_CLICK_ON_CHAMPION_ICON_LOWER_LEFT + k140_CommandSaveGame = 140, // @ C140_COMMAND_SAVE_GAME + k145_CommandSleep = 145, // @ C145_COMMAND_SLEEP + k146_CommandWakeUp = 146, // @ C146_COMMAND_WAKE_UP + k147_CommandFreezeGame = 147, // @ C147_COMMAND_FREEZE_GAME + k148_CommandUnfreezeGame = 148, // @ C148_COMMAND_UNFREEZE_GAME + k160_CommandClickInPanelResurrect = 160, // @ C160_COMMAND_CLICK_IN_PANEL_RESURRECT + k161_CommandClickInPanelReincarnate = 161, // @ C161_COMMAND_CLICK_IN_PANEL_REINCARNATE + k162_CommandClickInPanelCancel = 162, // @ C162_COMMAND_CLICK_IN_PANEL_CANCEL + k200_CommandEntranceEnterDungeon = 200, // @ C200_COMMAND_ENTRANCE_ENTER_DUNGEON + k201_CommandEntranceResume = 201, // @ C201_COMMAND_ENTRANCE_RESUME /* Versions 1.x and 2.x command */ + k202_CommandEntranceDrawCredits = 202, // @ C202_COMMAND_ENTRANCE_DRAW_CREDITS /* Versions 1.x and 2.x command */ + k210_CommandClickOnDialogChoice_1 = 210, // @ C210_COMMAND_CLICK_ON_DIALOG_CHOICE_1 + k211_CommandClickOnDialogChoice_2 = 211, // @ C211_COMMAND_CLICK_ON_DIALOG_CHOICE_2 + k212_CommandClickOnDialogChoice_3 = 212, // @ C212_COMMAND_CLICK_ON_DIALOG_CHOICE_3 + k213_CommandClickOnDialogChoice_4 = 213, // @ C213_COMMAND_CLICK_ON_DIALOG_CHOICE_4 + k215_CommandRestartGame = 215 // @ C215_COMMAND_RESTART_GAME }; // @ NONE class Command { @@ -177,28 +177,28 @@ public: : _commandTypeToIssue(type), _hitbox(x1, x2 + 1, y1, y2 + 1), _button(mouseButton) {} }; // @ MOUSE_INPUT -extern MouseInput gPrimaryMouseInput_Entrance[4]; // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4] -extern MouseInput gPrimaryMouseInput_RestartGame[2]; // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2] -extern MouseInput gPrimaryMouseInput_Interface[20]; // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20] -extern MouseInput gSecondaryMouseInput_Movement[9]; // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9] -extern MouseInput gSecondaryMouseInput_ChampionInventory[38]; // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38] -extern MouseInput gPrimaryMouseInput_PartySleeping[3]; // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3] -extern MouseInput gPrimaryMouseInput_FrozenGame[3]; // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3] -extern MouseInput gMouseInput_ActionAreaNames[5]; // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5] -extern MouseInput gMouseInput_ActionAreaIcons[5]; // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5] -extern MouseInput gMouseInput_SpellArea[9]; // @ G0454_as_Graphic561_MouseInput_SpellArea[9] -extern MouseInput gMouseInput_ChampionNamesHands[13]; // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13] -extern MouseInput gMouseInput_PanelChest[9]; // @ G0456_as_Graphic561_MouseInput_PanelChest[9] -extern MouseInput gMouseInput_PanelResurrectReincarnateCancel[4]; // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4] -extern MouseInput gPrimaryMouseInput_ViewportDialog1Choice[2]; // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2] -extern MouseInput gPrimaryMouseInput_ViewportDialog2Choices[3]; // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3] -extern MouseInput gPrimaryMouseInput_ViewportDialog3Choices[4]; // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4] -extern MouseInput gPrimaryMouseInput_ViewportDialog4Choices[5]; // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5] -extern MouseInput gPrimaryMouseInput_ScreenDialog1Choice[2]; // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2] -extern MouseInput gPrimaryMouseInput_ScreenDialog2Choices[3]; // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3] -extern MouseInput gPrimaryMouseInput_ScreenDialog3Choices[4]; // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4] -extern MouseInput gPrimaryMouseInput_ScreenDialog4Choices[5]; // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5] -extern MouseInput* gPrimaryMouseInput_DialogSets[2][4]; // @ G0480_aaps_PrimaryMouseInput_DialogSets +extern MouseInput g445_PrimaryMouseInput_Entrance[4]; // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4] +extern MouseInput g446_PrimaryMouseInput_RestartGame[2]; // @ G0446_as_Graphic561_PrimaryMouseInput_RestartGame[2] +extern MouseInput g447_PrimaryMouseInput_Interface[20]; // @ G0447_as_Graphic561_PrimaryMouseInput_Interface[20] +extern MouseInput g448_SecondaryMouseInput_Movement[9]; // @ G0448_as_Graphic561_SecondaryMouseInput_Movement[9] +extern MouseInput g449_SecondaryMouseInput_ChampionInventory[38]; // @ G0449_as_Graphic561_SecondaryMouseInput_ChampionInventory[38] +extern MouseInput g450_PrimaryMouseInput_PartySleeping[3]; // @ G0450_as_Graphic561_PrimaryMouseInput_PartySleeping[3] +extern MouseInput g451_PrimaryMouseInput_FrozenGame[3]; // @ G0451_as_Graphic561_PrimaryMouseInput_FrozenGame[3] +extern MouseInput g452_MouseInput_ActionAreaNames[5]; // @ G0452_as_Graphic561_MouseInput_ActionAreaNames[5] +extern MouseInput g453_MouseInput_ActionAreaIcons[5]; // @ G0453_as_Graphic561_MouseInput_ActionAreaIcons[5] +extern MouseInput g454_MouseInput_SpellArea[9]; // @ G0454_as_Graphic561_MouseInput_SpellArea[9] +extern MouseInput g455_MouseInput_ChampionNamesHands[13]; // @ G0455_as_Graphic561_MouseInput_ChampionNamesHands[13] +extern MouseInput g456_MouseInput_PanelChest[9]; // @ G0456_as_Graphic561_MouseInput_PanelChest[9] +extern MouseInput g457_MouseInput_PanelResurrectReincarnateCancel[4]; // @ G0457_as_Graphic561_MouseInput_PanelResurrectReincarnateCancel[4] +extern MouseInput g471_PrimaryMouseInput_ViewportDialog1Choice[2]; // @ G0471_as_Graphic561_PrimaryMouseInput_ViewportDialog1Choice[2] +extern MouseInput g472_PrimaryMouseInput_ViewportDialog2Choices[3]; // @ G0472_as_Graphic561_PrimaryMouseInput_ViewportDialog2Choices[3] +extern MouseInput g473_PrimaryMouseInput_ViewportDialog3Choices[4]; // @ G0473_as_Graphic561_PrimaryMouseInput_ViewportDialog3Choices[4] +extern MouseInput g474_PrimaryMouseInput_ViewportDialog4Choices[5]; // @ G0474_as_Graphic561_PrimaryMouseInput_ViewportDialog4Choices[5] +extern MouseInput g475_PrimaryMouseInput_ScreenDialog1Choice[2]; // @ G0475_as_Graphic561_PrimaryMouseInput_ScreenDialog1Choice[2] +extern MouseInput g476_PrimaryMouseInput_ScreenDialog2Choices[3]; // @ G0476_as_Graphic561_PrimaryMouseInput_ScreenDialog2Choices[3] +extern MouseInput g477_PrimaryMouseInput_ScreenDialog3Choices[4]; // @ G0477_as_Graphic561_PrimaryMouseInput_ScreenDialog3Choices[4] +extern MouseInput g478_PrimaryMouseInput_ScreenDialog4Choices[5]; // @ G0478_as_Graphic561_PrimaryMouseInput_ScreenDialog4Choices[5] +extern MouseInput* g480_PrimaryMouseInput_DialogSets[2][4]; // @ G0480_aaps_PrimaryMouseInput_DialogSets class KeyboardInput { public: @@ -217,11 +217,12 @@ class EventManager { Common::Point _mousePos; uint16 _dummyMapIndex; - bool _pendingClickPresent; // G0436_B_PendingClickPresent - Common::Point _pendingClickPos; // @ G0437_i_PendingClickX, G0438_i_PendingClickY - MouseButton _pendingClickButton; // @ G0439_i_PendingClickButtonsStatus + bool _g436_pendingClickPresent; // G0436_B_PendingClickPresent + Common::Point _g437_pendingClickPos; // @ G0437_i_PendingClickX, G0438_i_PendingClickY + MouseButton _g439_pendingClickButton; // @ G0439_i_PendingClickButtonsStatus - bool _isCommandQueueLocked; // this doesn't seem to be used anywhere at all +// this doesn't seem to be used anywhere at all + bool _g435_isCommandQueueLocked; // @ G0435_B_CommandQueueLocked Common::Queue _commandQueue; void commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty @@ -229,12 +230,12 @@ class EventManager { public: explicit EventManager(DMEngine *vm); - MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput - MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput - bool _mousePointerBitmapUpdated; // @ G0598_B_MousePointerBitmapUpdated - bool _refreshMousePointerInMainLoop; // @ G0326_B_RefreshMousePointerInMainLoop - bool _highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled - uint16 _useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap + MouseInput* _g441_primaryMouseInput;// @ G0441_ps_PrimaryMouseInput + MouseInput* _g442_secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput + bool _g598_mousePointerBitmapUpdated; // @ G0598_B_MousePointerBitmapUpdated + bool _g326_refreshMousePointerInMainLoop; // @ G0326_B_RefreshMousePointerInMainLoop + bool _g341_highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled + uint16 _g599_useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap void initMouse(); void showMouse(bool visibility); diff --git a/engines/dm/group.h b/engines/dm/group.h index 0c2233dcb7..b5198ed2a9 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -32,7 +32,7 @@ #include "dm.h" namespace DM { - +// this doesn't seem to be used anywhere at all /* Creature types */ enum CreatureType { kCreatureTypeGiantScorpionScorpion = 0, // @ C00_CREATURE_GIANT_SCORPION_SCORPION diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 742f392865..0a95b7b63e 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -78,9 +78,9 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { return; } if (championIndex == k4_ChampionCloseInventory) { - em._refreshMousePointerInMainLoop = true; + em._g326_refreshMousePointerInMainLoop = true; _vm->_menuMan->drawMovementArrows(); - em._secondaryMouseInput = gSecondaryMouseInput_Movement; + em._g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement; warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput"); warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); return; @@ -116,8 +116,8 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true); cm.drawChampionState(championIndex); - em._mousePointerBitmapUpdated = true; - em._secondaryMouseInput = gSecondaryMouseInput_ChampionInventory; + em._g598_mousePointerBitmapUpdated = true; + em._g442_secondaryMouseInput = g449_SecondaryMouseInput_ChampionInventory; warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput"); warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); } -- cgit v1.2.3 From 63ff1666d693b0078e5b6fd603240e9453c11918 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 2 Jul 2016 12:57:31 +0200 Subject: DM: More constant and global variable renaming --- engines/dm/champion.cpp | 36 ++++++------ engines/dm/dm.cpp | 10 ++-- engines/dm/dungeonman.cpp | 4 +- engines/dm/eventman.cpp | 8 +-- engines/dm/gfx.cpp | 24 ++++---- engines/dm/group.cpp | 24 ++++---- engines/dm/group.h | 94 +++++++++++++++--------------- engines/dm/inventory.cpp | 124 ++++++++++++++++++++-------------------- engines/dm/inventory.h | 26 ++++----- engines/dm/loadsave.cpp | 2 +- engines/dm/loadsave.h | 4 +- engines/dm/menus.cpp | 110 +++++++++++++++++------------------ engines/dm/menus.h | 14 ++--- engines/dm/objectman.cpp | 142 +++++++++++++++++++++++----------------------- engines/dm/objectman.h | 14 ++--- engines/dm/text.cpp | 16 +++--- engines/dm/timeline.cpp | 20 +++---- engines/dm/timeline.h | 112 ++++++++++++++++++------------------ 18 files changed, 392 insertions(+), 392 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 0e062bbee6..17ee18124b 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -282,7 +282,7 @@ bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) || (currIconIndex == k195_IconIndicePotionEmptyFlask)) { IconIndice newIconIndex = objMan.getIconIndex(thing); if (newIconIndex != currIconIndex) { - if ((slotBoxIndex < kSlotBoxInventoryFirstSlot) && !_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) { + if ((slotBoxIndex < k8_SlotBoxInventoryFirstSlot) && !_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) { _g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); } @@ -299,7 +299,7 @@ void ChampionMan::drawChangedObjectIcons() { ObjectMan &objMan = *_vm->_objectMan; MenuMan &menuMan = *_vm->_menuMan; - uint16 invChampOrdinal = invMan._inventoryChampionOrdinal; + uint16 invChampOrdinal = invMan._g432_inventoryChampionOrdinal; if (_g299_candidateChampionOrdinal && !invChampOrdinal) return; @@ -313,7 +313,7 @@ void ChampionMan::drawChangedObjectIcons() { if (iconIndex != leaderHandObjIconIndex) { _g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - objMan.extractIconFromBitmap(iconIndex, objMan._objectIconForMousePointer); + objMan.extractIconFromBitmap(iconIndex, objMan._g412_objectIconForMousePointer); warning("MISSING CODE: F0068_MOUSE_SetPointerToObject"); _g413_leaderHandObjectIconIndex = iconIndex; objMan.drawLeaderObjectName(_414_leaderHandObject); @@ -338,17 +338,17 @@ void ChampionMan::drawChangedObjectIcons() { uint16 drawViewport = 0; for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++, thing++) { - uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + kSlotBoxInventoryFirstSlot, *thing) ? 1 : 0; + uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + k8_SlotBoxInventoryFirstSlot, *thing) ? 1 : 0; drawViewport |= objIconChanged; if (objIconChanged && (slotIndex == k1_ChampionSlotActionHand)) { menuMan.drawActionIcon((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal)); } } - if (invMan._panelContent = kPanelContentChest) { - thing = invMan._chestSlots; + if (invMan._g424_panelContent = k4_PanelContentChest) { + thing = invMan._g425_chestSlots; for (int16 slotIndex = 0; slotIndex < 8; ++slotIndex, thing++) { - drawViewport |= (hasObjectIconInSlotBoxChanged(slotIndex + kSlotBoxChestFirstSlot, *thing) ? 1 : 0); + drawViewport |= (hasObjectIconInSlotBoxChanged(slotIndex + k38_SlotBoxChestFirstSlot, *thing) ? 1 : 0); } } @@ -374,7 +374,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio Champion *champ = &_champions[champIndex]; if (slotIndex >= k30_ChampionSlotChest_1) { - invMan._chestSlots[slotIndex - k30_ChampionSlotChest_1] = thing; + invMan._g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = thing; } else { champ->setSlot(slotIndex, thing); } @@ -382,7 +382,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio champ->_load += dunMan.getObjectWeight(thing); champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true); IconIndice iconIndex = objMan.getIconIndex(thing); - bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal); + bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal); applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing); uint16 *rawObjPtr = dunMan.getThingData(thing); @@ -551,7 +551,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { _g299_candidateChampionOrdinal = prevChampCount + 1; if (++_g305_partyChampionCount == 1) { _vm->_eventMan->commandSetLeader(k0_ChampionFirst); - _vm->_menuMan->_refreshActionArea = true; + _vm->_menuMan->_g508_refreshActionArea = true; } else { _vm->_menuMan->clearActingChampion(); _vm->_menuMan->drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1)); @@ -666,7 +666,7 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); Box box; - box._x1 = champIndex * kChampionStatusBoxSpacing + 46; + box._x1 = champIndex * k69_ChampionStatusBoxSpacing + 46; box._x2 = box._x1 + 3 + 1; box._y1 = 2; box._y2 = 26 + 1; @@ -723,7 +723,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { EventManager &eventMan = *_vm->_eventMan; Box box; - int16 champStatusBoxX = champIndex * kChampionStatusBoxSpacing; + int16 champStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing; Champion *champ = &_champions[champIndex]; uint16 champAttributes = champ->getAttributes(); if (!((champAttributes) & (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | @@ -731,7 +731,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { k0x8000_ChampionAttributeActionHand))) { return; } - bool isInventoryChamp = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal); + bool isInventoryChamp = (_vm->indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal); dispMan._g578_useByteBoxCoordinates = false; if (champAttributes & k0x1000_ChampionAttributeStatusBox) { box._y1 = 0; @@ -905,7 +905,7 @@ void ChampionMan::drawHealthStaminaManaValues(Champion* champ) { void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { int16 nativeBitmapIndex = -1; Champion *champ = &_champions[champIndex]; - bool isInventoryChamp = (_vm->_inventoryMan->_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)); + bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)); uint16 slotBoxIndex; if (!isInventoryChamp) { /* If drawing a slot for a champion other than the champion whose inventory is open */ @@ -914,17 +914,17 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { } slotBoxIndex = (champIndex << 1) + slotIndex; } else { - slotBoxIndex = kSlotBoxInventoryFirstSlot + slotIndex; + slotBoxIndex = k8_SlotBoxInventoryFirstSlot + slotIndex; } Thing thing; if (slotIndex >= k30_ChampionSlotChest_1) { - thing = _vm->_inventoryMan->_chestSlots[slotIndex - k30_ChampionSlotChest_1]; + thing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1]; } else { thing = champ->getSlot(slotIndex); } - SlotBox *slotBox = &_vm->_objectMan->_slotBoxes[slotBoxIndex]; + SlotBox *slotBox = &_vm->_objectMan->_g30_slotBoxes[slotBoxIndex]; Box box; box._x1 = slotBox->_x - 1; box._y1 = slotBox->_y - 1; @@ -999,7 +999,7 @@ void ChampionMan::renameChampion(Champion* champ) { box._x2 = box._x1 + 167; dispMan.clearScreenBox(k12_ColorDarkestGray, box, g296_DungeonViewport); - dispMan.blitToScreen(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, gBoxPanel, k4_ColorCyan, g296_DungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, g32_BoxPanel, k4_ColorCyan, g296_DungeonViewport); textMan.printToViewport(177, 58, k13_ColorLightestGray, "_______"); textMan.printToViewport(105, 76, k13_ColorLightestGray, "___________________"); Common::Point clickPos; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 6f0c4658e4..5c854d5209 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -148,7 +148,7 @@ void DMEngine::initializeGame() { _eventMan->initMouse(); - while (_loadsaveMan->loadgame() != kLoadgameSuccess) { + while (_loadsaveMan->loadgame() != k1_LoadgameSuccess) { warning("TODO: F0441_STARTEND_ProcessEntrance"); } @@ -172,7 +172,7 @@ void DMEngine::startGame() { _eventMan->_g341_highlightBoxEnabled = false; _championMan->_g300_partyIsSleeping = false; _championMan->_g506_actingChampionOrdinal = indexToOrdinal(kM1_ChampionNone); - _menuMan->_actionAreaContainsIcons = true; + _menuMan->_g509_actionAreaContainsIcons = true; _eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone); _eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface; @@ -238,8 +238,8 @@ void DMEngine::gameloop() { _dungeonMan->_currMap._g308_partyDir = kDirNorth; - warning("DUMMY CODE: setting InventoryMan::_inventoryChampionOrdinal to zero"); - _inventoryMan->_inventoryChampionOrdinal = 0; + warning("DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero"); + _inventoryMan->_g432_inventoryChampionOrdinal = 0; warning("DUMMY CODE: clearing screen to black"); // in loop below while (true) { _g321_stopWaitingForPlayerInput = false; @@ -251,7 +251,7 @@ void DMEngine::gameloop() { _eventMan->processCommandQueue(); //} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking); - if (!_inventoryMan->_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { + if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { Box box(0, 224, 0, 126); _displayMan->clearScreenBox(k0_ColorBlack, box, g296_DungeonViewport); // dummy code _displayMan->drawDungeon(_dungeonMan->_currMap._g308_partyDir, _dungeonMan->_currMap._g306_partyPosX, _dungeonMan->_currMap._g307_partyPosY); diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 7b12bf4752..df61b45149 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -652,7 +652,7 @@ void DungeonMan::loadDungeonFile() { // TODO: ??? what this if (_messages._g298_newGame) - _vm->_timeline->_eventMaxCount = 100; + _vm->_timeline->_g369_eventMaxCount = 100; // load things for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) { @@ -699,7 +699,7 @@ void DungeonMan::loadDungeonFile() { if (_messages._g298_newGame) { if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType) - _vm->_timeline->_eventMaxCount += _g278_fileHeader._thingCounts[thingType]; + _vm->_timeline->_g369_eventMaxCount += _g278_fileHeader._thingCounts[thingType]; for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) { _dunData._g284_thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16(); } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 69886e54c6..6d59727e2b 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -616,7 +616,7 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane Box box; box._y1 = 0; box._y2 = 28 + 1; - box._x1 = championIndex * kChampionStatusBoxSpacing; + box._x1 = championIndex * k69_ChampionStatusBoxSpacing; box._x2 = box._x1 + 66 + 1; dispMan._g578_useByteBoxCoordinates = false; dispMan.clearScreenBox(k0_ColorBlack, box); @@ -679,15 +679,15 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) { InventoryMan &invMan = *_vm->_inventoryMan; CommandType commandType; - switch (invMan._panelContent) { - case kPanelContentChest: + switch (invMan._g424_panelContent) { + case k4_PanelContentChest: if (champMan._g411_leaderIndex == kM1_ChampionNone) // if no leader return; commandType = getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton); if (commandType != k0_CommandNone) warning("MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox"); break; - case kPanelContentResurrectReincarnate: + case k5_PanelContentResurrectReincarnate: if (!champMan._g415_leaderEmptyHanded) break; commandType = getCommandTypeFromMouseInput(g457_MouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), k1_LeftMouseButton); diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index c93bf1db6d..62bf070579 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -2327,17 +2327,17 @@ T0115015_DrawProjectileAsObject: goto T0115129_DrawProjectiles; /* Skip code to draw creatures */ if (group == nullptr) { /* If all creature data and info has not already been gathered */ group = (Group*)dunMan.getThingData(groupThing); - activeGroup = &_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()]; + activeGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]; creatureInfo = &g243_CreatureInfo[group->_type]; creatureAspectStruct = &g219_CreatureAspects[creatureInfo->_creatureAspectIndex]; - creatureSize = getFlag(creatureInfo->_attributes, kMaskCreatureInfo_size); + creatureSize = getFlag(creatureInfo->_attributes, k0x0003_MaskCreatureInfo_size); creatureGraphicInfoGreen = creatureInfo->_graphicInfo; } objectAspect = (ObjectAspect*)creatureAspectStruct; if (AL_0_creatureIndexRed = _vm->_groupMan->getCreatureOrdinalInCell(group, cellYellowBear)) { /* If there is a creature on the cell being processed */ AL_0_creatureIndexRed--; /* Convert ordinal to index */ creatureIndexGreen = AL_0_creatureIndexRed; - } else if (creatureSize == kMaskCreatureSizeHalf) { + } else if (creatureSize == k1_MaskCreatureSizeHalf) { AL_0_creatureIndexRed = 0; creatureIndexGreen = -1; } else { @@ -2346,18 +2346,18 @@ T0115015_DrawProjectileAsObject: creatureDirectionDelta = (directionParam - _vm->_groupMan->getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed)) % 3; twoHalfSquareCreaturesFrontView = false; - if ((AL_4_groupCells = activeGroup->_cells) == kCreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */ + if ((AL_4_groupCells = activeGroup->_cells) == k255_CreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */ if (remainingViewCellOrdinalsToProcess || (doorFrontViewDrawingPass == 1)) /* Do not draw a single centered creature now, wait until second pass (for a front view door) or until all cells have been drawn so the creature is drawn over all the objects on the floor */ goto T0115129_DrawProjectiles; drawCreaturesCompleted = true; - if ((creatureSize == kMaskCreatureSizeHalf) && (creatureDirectionDelta & 0x0001)) { /* Side view of half square creature */ + if ((creatureSize == k1_MaskCreatureSizeHalf) && (creatureDirectionDelta & 0x0001)) { /* Side view of half square creature */ AL_2_viewCell = k3_HalfSizedViewCell_CenterColumn; } else { AL_2_viewCell = k4_HalfSizedViewCell_FrontRow; } - } else if ((creatureSize == kMaskCreatureSizeHalf) && (drawingLastBackRowCell || !remainingViewCellOrdinalsToProcess || (creatureIndexGreen < 0))) { + } else if ((creatureSize == k1_MaskCreatureSizeHalf) && (drawingLastBackRowCell || !remainingViewCellOrdinalsToProcess || (creatureIndexGreen < 0))) { if (drawingLastBackRowCell && (doorFrontViewDrawingPass != 2)) { if ((creatureIndexGreen >= 0) && (creatureDirectionDelta & 0x0001)) { AL_2_viewCell = k2_HalfSizedViewCell_BackRow; /* Side view of a half square creature on the back row. Drawn during pass 1 for a door square */ @@ -2388,7 +2388,7 @@ T0115015_DrawProjectileAsObject: goto T0115129_DrawProjectiles; } - } else if (creatureSize != kMaskCreatureSizeQuarter) + } else if (creatureSize != k0_MaskCreatureSizeQuarter) goto T0115129_DrawProjectiles; @@ -2411,7 +2411,7 @@ T0115077_DrawSecondHalfSquareCreature: sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightSide; } else { useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0); - if (useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupIsAttacking) + if (useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, k0x0080_MaskActiveGroupIsAttacking) && getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack)) { useFlippedHorizontallyCreatureFrontImage = false; @@ -2441,7 +2441,7 @@ T0115077_DrawSecondHalfSquareCreature: } } else { if (useFlippedHorizontallyCreatureFrontImage = getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack) - && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) { + && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) { derivedBitmapIndex += 2; if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) { derivedBitmapIndex += 2; @@ -2470,7 +2470,7 @@ T0115077_DrawSecondHalfSquareCreature: } else { if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) { AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); - if (useCreatureAttackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) { + if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) { memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; @@ -2518,7 +2518,7 @@ T0115077_DrawSecondHalfSquareCreature: warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */ - (useCreatureAttackBitmap && getFlag(creatureAspectInt, kMaskActiveGroupFlipBitmap)) || + (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) || (useCreatureSpecialD2FrontBitmap && getFlag(AL_0_creatureGraphicInfoRed, k0x0100_CreatureInfoGraphicMaskSpecialD2FrontIsFlipped)) || (useFlippedHorizontallyCreatureFrontImage && getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack))) { /* If the graphic should be flipped */ if (!useFlippedHorizontallyCreatureFrontImage || !derivedBitmapInCache) { @@ -2608,7 +2608,7 @@ continue; projectileBitmapIndexData = 0; flipVertical = flipHorizontal = false; } else { - if (isOrientedWestEast((direction)(projectileDirection = _vm->_timeline->_events[projectile->_timerIndex]._C._projectile.getDir())) + if (isOrientedWestEast((direction)(projectileDirection = _vm->_timeline->_g370_events[projectile->_timerIndex]._C._projectile.getDir())) != isOrientedWestEast(directionParam)) { if (projectileAspectType == k2_ProjectileAspectHasRotation) { projectileBitmapIndexData = 1; diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 76aab71ff7..2891da3ec5 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -35,28 +35,28 @@ namespace DM { GroupMan::GroupMan(DMEngine* vm) : _vm(vm) { - _activeGroups = nullptr; + _g375_activeGroups = nullptr; } GroupMan::~GroupMan() { - delete[] _activeGroups; + delete[] _g375_activeGroups; } void GroupMan::initActiveGroups() { if (_vm->_dungeonMan->_messages._g298_newGame) - _maxActiveGroupCount = 60; - if (_activeGroups) - delete[] _activeGroups; - _activeGroups = new ActiveGroup[_maxActiveGroupCount]; - for (uint16 i = 0; i < _maxActiveGroupCount; ++i) - _activeGroups[i]._groupThingIndex = -1; + _g376_maxActiveGroupCount = 60; + if (_g375_activeGroups) + delete[] _g375_activeGroups; + _g375_activeGroups = new ActiveGroup[_g376_maxActiveGroupCount]; + for (uint16 i = 0; i < _g376_maxActiveGroupCount; ++i) + _g375_activeGroups[i]._groupThingIndex = -1; } uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) { byte cells; cells = group->_cells; if (mapIndex == _vm->_dungeonMan->_currMap._g309_currPartyMapIndex) - cells = _activeGroups[cells]._cells; + cells = _g375_activeGroups[cells]._cells; return cells; } @@ -64,7 +64,7 @@ byte gGroupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_G uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) { if (mapIndex == _vm->_dungeonMan->_currMap._g309_currPartyMapIndex) - return _activeGroups[group->getActiveGroupIndex()]._directions; + return _g375_activeGroups[group->getActiveGroupIndex()]._directions; return gGroupDirections[group->getDir()]; } @@ -72,11 +72,11 @@ uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) { int16 GroupMan::getCreatureOrdinalInCell(Group* group, uint16 cell) { uint16 currMapIndex = _vm->_dungeonMan->_currMap._g272_index; byte groupCells = getGroupCells(group, currMapIndex); - if (groupCells == kCreatureTypeSingleCenteredCreature) + if (groupCells == k255_CreatureTypeSingleCenteredCreature) return _vm->indexToOrdinal(0); byte creatureIndex = group->getCount(); - if (getFlag(g243_CreatureInfo[group->_type]._attributes, kMaskCreatureInfo_size) == kMaskCreatureSizeHalf) { + if (getFlag(g243_CreatureInfo[group->_type]._attributes, k0x0003_MaskCreatureInfo_size) == k1_MaskCreatureSizeHalf) { if ((getGroupDirections(group, currMapIndex) & 1) == (cell & 1)) cell = returnPrevVal(cell); diff --git a/engines/dm/group.h b/engines/dm/group.h index b5198ed2a9..af7a4eb622 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -35,56 +35,56 @@ namespace DM { // this doesn't seem to be used anywhere at all /* Creature types */ enum CreatureType { - kCreatureTypeGiantScorpionScorpion = 0, // @ C00_CREATURE_GIANT_SCORPION_SCORPION - kCreatureTypeSwampSlimeSlime = 1, // @ C01_CREATURE_SWAMP_SLIME_SLIME_DEVIL - kCreatureTypeGiggler = 2, // @ C02_CREATURE_GIGGLER - kCreatureTypeWizardEyeFlyingEye = 3, // @ C03_CREATURE_WIZARD_EYE_FLYING_EYE - kCreatureTypePainRatHellHound = 4, // @ C04_CREATURE_PAIN_RAT_HELLHOUND - kCreatureTypeRuster = 5, // @ C05_CREATURE_RUSTER - kCreatureTypeScreamer = 6, // @ C06_CREATURE_SCREAMER - kCreatureTypeRockpile = 7, // @ C07_CREATURE_ROCK_ROCKPILE - kCreatureTypeGhostRive = 8, // @ C08_CREATURE_GHOST_RIVE - kCreatureTypeStoneGolem = 9, // @ C09_CREATURE_STONE_GOLEM - kCreatureTypeMummy = 10, // @ C10_CREATURE_MUMMY - kCreatureTypeBlackFlame = 11, // @ C11_CREATURE_BLACK_FLAME - kCreatureTypeSkeleton = 12, // @ C12_CREATURE_SKELETON - kCreatureTypeCouatl = 13, // @ C13_CREATURE_COUATL - kCreatureTypeVexirk = 14, // @ C14_CREATURE_VEXIRK - kCreatureTypeMagnetaWormWorm = 15, // @ C15_CREATURE_MAGENTA_WORM_WORM - kCreatureTypeTrolinAntman = 16, // @ C16_CREATURE_TROLIN_ANTMAN - kCreatureTypeGiantWaspMuncher = 17, // @ C17_CREATURE_GIANT_WASP_MUNCHER - kCreatureTypeAnimatedArmourDethKnight = 18, // @ C18_CREATURE_ANIMATED_ARMOUR_DETH_KNIGHT - kCreatureTypeMaterializerZytaz = 19, // @ C19_CREATURE_MATERIALIZER_ZYTAZ - kCreatureTypeWaterElemental = 20, // @ C20_CREATURE_WATER_ELEMENTAL - kCreatureTypeOitu = 21, // @ C21_CREATURE_OITU - kCreatureTypeDemon = 22, // @ C22_CREATURE_DEMON - kCreatureTypeLordChaos = 23, // @ C23_CREATURE_LORD_CHAOS - kCreatureTypeRedDragon = 24, // @ C24_CREATURE_RED_DRAGON - kCreatureTypeLordOrder = 25, // @ C25_CREATURE_LORD_ORDER - kCreatureTypeGreyLord = 26, // @ C26_CREATURE_GREY_LORD - kCreatureTypeSingleCenteredCreature = 255 // @ C255_SINGLE_CENTERED_CREATURE + k0_CreatureTypeGiantScorpionScorpion = 0, // @ C00_CREATURE_GIANT_SCORPION_SCORPION + k1_CreatureTypeSwampSlimeSlime = 1, // @ C01_CREATURE_SWAMP_SLIME_SLIME_DEVIL + k2_CreatureTypeGiggler = 2, // @ C02_CREATURE_GIGGLER + k3_CreatureTypeWizardEyeFlyingEye = 3, // @ C03_CREATURE_WIZARD_EYE_FLYING_EYE + k4_CreatureTypePainRatHellHound = 4, // @ C04_CREATURE_PAIN_RAT_HELLHOUND + k5_CreatureTypeRuster = 5, // @ C05_CREATURE_RUSTER + k6_CreatureTypeScreamer = 6, // @ C06_CREATURE_SCREAMER + k7_CreatureTypeRockpile = 7, // @ C07_CREATURE_ROCK_ROCKPILE + k8_CreatureTypeGhostRive = 8, // @ C08_CREATURE_GHOST_RIVE + k9_CreatureTypeStoneGolem = 9, // @ C09_CREATURE_STONE_GOLEM + k10_CreatureTypeMummy = 10, // @ C10_CREATURE_MUMMY + k11_CreatureTypeBlackFlame = 11, // @ C11_CREATURE_BLACK_FLAME + k12_CreatureTypeSkeleton = 12, // @ C12_CREATURE_SKELETON + k13_CreatureTypeCouatl = 13, // @ C13_CREATURE_COUATL + k14_CreatureTypeVexirk = 14, // @ C14_CREATURE_VEXIRK + k15_CreatureTypeMagnetaWormWorm = 15, // @ C15_CREATURE_MAGENTA_WORM_WORM + k16_CreatureTypeTrolinAntman = 16, // @ C16_CREATURE_TROLIN_ANTMAN + k17_CreatureTypeGiantWaspMuncher = 17, // @ C17_CREATURE_GIANT_WASP_MUNCHER + k18_CreatureTypeAnimatedArmourDethKnight = 18, // @ C18_CREATURE_ANIMATED_ARMOUR_DETH_KNIGHT + k19_CreatureTypeMaterializerZytaz = 19, // @ C19_CREATURE_MATERIALIZER_ZYTAZ + k20_CreatureTypeWaterElemental = 20, // @ C20_CREATURE_WATER_ELEMENTAL + k21_CreatureTypeOitu = 21, // @ C21_CREATURE_OITU + k22_CreatureTypeDemon = 22, // @ C22_CREATURE_DEMON + k23_CreatureTypeLordChaos = 23, // @ C23_CREATURE_LORD_CHAOS + k24_CreatureTypeRedDragon = 24, // @ C24_CREATURE_RED_DRAGON + k25_CreatureTypeLordOrder = 25, // @ C25_CREATURE_LORD_ORDER + k26_CreatureTypeGreyLord = 26, // @ C26_CREATURE_GREY_LORD + k255_CreatureTypeSingleCenteredCreature = 255 // @ C255_SINGLE_CENTERED_CREATURE }; -#define kMaskCreatureSizeQuarter 0 // @ C0_SIZE_QUARTER_SQUARE -#define kMaskCreatureSizeHalf 1 // @ C1_SIZE_HALF_SQUARE -#define kMaskCreatureSizeFull 2 // @ C2_SIZE_FULL_SQUARE +#define k0_MaskCreatureSizeQuarter 0 // @ C0_SIZE_QUARTER_SQUARE +#define k1_MaskCreatureSizeHalf 1 // @ C1_SIZE_HALF_SQUARE +#define k2_MaskCreatureSizeFull 2 // @ C2_SIZE_FULL_SQUARE -#define kMaskCreatureInfo_size 0x0003 // @ MASK0x0003_SIZE -#define kMaskCreatureInfo_sideAttack 0x0004 // @ MASK0x0004_SIDE_ATTACK -#define kMaskCreatureInfo_preferBackRow 0x0008 // @ MASK0x0008_PREFER_BACK_ROW -#define kMaskCreatureInfo_attackAnyChamp 0x0010 // @ MASK0x0010_ATTACK_ANY_CHAMPION -#define kMaskCreatureInfo_levitation 0x0020 // @ MASK0x0020_LEVITATION -#define kMaskCreatureInfo_nonMaterial 0x0040 // @ MASK0x0040_NON_MATERIAL -#define kMaskCreatureInfo_dropFixedPoss 0x0200 // @ MASK0x0200_DROP_FIXED_POSSESSIONS -#define kMaskCreatureInfo_keepThrownSharpWeapon 0x0400 // @ MASK0x0400_KEEP_THROWN_SHARP_WEAPONS -#define kMaskCreatureInfo_seeInvisible 0x0800 // @ MASK0x0800_SEE_INVISIBLE -#define kMaskCreatureInfo_nightVision 0x1000 // @ MASK0x1000_NIGHT_VISION -#define kMaskCreatureInfo_archenemy 0x2000 // @ MASK0x2000_ARCHENEMY -#define kMaskCreatureInfo_magicmap 0x4000 // @ MASK0x4000_MAGICMAP +#define k0x0003_MaskCreatureInfo_size 0x0003 // @ MASK0x0003_SIZE +#define k0x0004_MaskCreatureInfo_sideAttack 0x0004 // @ MASK0x0004_SIDE_ATTACK +#define k0x0008_MaskCreatureInfo_preferBackRow 0x0008 // @ MASK0x0008_PREFER_BACK_ROW +#define k0x0010_MaskCreatureInfo_attackAnyChamp 0x0010 // @ MASK0x0010_ATTACK_ANY_CHAMPION +#define k0x0020_MaskCreatureInfo_levitation 0x0020 // @ MASK0x0020_LEVITATION +#define k0x0040_MaskCreatureInfo_nonMaterial 0x0040 // @ MASK0x0040_NON_MATERIAL +#define k0x0200_MaskCreatureInfo_dropFixedPoss 0x0200 // @ MASK0x0200_DROP_FIXED_POSSESSIONS +#define k0x0400_MaskCreatureInfo_keepThrownSharpWeapon 0x0400 // @ MASK0x0400_KEEP_THROWN_SHARP_WEAPONS +#define k0x0800_MaskCreatureInfo_seeInvisible 0x0800 // @ MASK0x0800_SEE_INVISIBLE +#define k0x1000_MaskCreatureInfo_nightVision 0x1000 // @ MASK0x1000_NIGHT_VISION +#define k0x2000_MaskCreatureInfo_archenemy 0x2000 // @ MASK0x2000_ARCHENEMY +#define k0x4000_MaskCreatureInfo_magicmap 0x4000 // @ MASK0x4000_MAGICMAP -#define kMaskActiveGroupFlipBitmap 0x0040 // @ MASK0x0040_FLIP_BITMAP -#define kMaskActiveGroupIsAttacking 0x0080 // @ MASK0x0080_IS_ATTACKING +#define k0x0040_MaskActiveGroupFlipBitmap 0x0040 // @ MASK0x0040_FLIP_BITMAP +#define k0x0080_MaskActiveGroupIsAttacking 0x0080 // @ MASK0x0080_IS_ATTACKING class ActiveGroup { public: @@ -133,8 +133,8 @@ public: class GroupMan { DMEngine *_vm; public: - uint16 _maxActiveGroupCount = 60; // @ G0376_ui_MaximumActiveGroupCount - ActiveGroup *_activeGroups; // @ G0375_ps_ActiveGroups + uint16 _g376_maxActiveGroupCount = 60; // @ G0376_ui_MaximumActiveGroupCount + ActiveGroup *_g375_activeGroups; // @ G0375_ps_ActiveGroups GroupMan(DMEngine *vm); ~GroupMan(); void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 0a95b7b63e..1d7bd95b80 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -36,18 +36,18 @@ namespace DM { -Box gBoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross -Box gBoxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel -Box gBoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food -Box gBoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water -Box gBoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned +Box g41_BoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross +Box g32_BoxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel +Box g35_BoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food +Box g36_BoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water +Box g37_BoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) { - _panelContent = kPanelContentFoodWaterPoisoned; + _g424_panelContent = k0_PanelContentFoodWaterPoisoned; for (uint16 i = 0; i < 8; ++i) - _chestSlots[i] = Thing::_none; - _openChest = Thing::_none; - _openChest = Thing::_none; + _g425_chestSlots[i] = Thing::_none; + _g426_openChest = Thing::_none; + _g426_openChest = Thing::_none; } void InventoryMan::toggleInventory(ChampionIndex championIndex) { @@ -60,14 +60,14 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) return; _vm->_g321_stopWaitingForPlayerInput = true; - int16 invChampOrdinal = _inventoryChampionOrdinal; // copy, as the original will be edited + int16 invChampOrdinal = _g432_inventoryChampionOrdinal; // copy, as the original will be edited if (_vm->indexToOrdinal(championIndex) == invChampOrdinal) { championIndex = k4_ChampionCloseInventory; } Champion *champion; if (invChampOrdinal) { - _inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone); + _g432_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone); closeChest(); champion = &cm._champions[_vm->ordinalToIndex(invChampOrdinal)]; if (champion->_currHealth && !cm._g299_candidateChampionOrdinal) { @@ -88,7 +88,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { } dm._g578_useByteBoxCoordinates = false; - _inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex); + _g432_inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex); if (!invChampOrdinal) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } @@ -98,7 +98,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { int16 h = dm.getHeight(k17_InventoryGraphicIndice); dm.blitToScreen(dm.getBitmap(k17_InventoryGraphicIndice), w, 0, 0, 0, w, 0, h, k255_ColorNoTransparency, g296_DungeonViewport); if (cm._g299_candidateChampionOrdinal) { - dm.clearScreenBox(k12_ColorDarkestGray, gBoxFloppyZzzCross, g296_DungeonViewport); + dm.clearScreenBox(k12_ColorDarkestGray, g41_BoxFloppyZzzCross, g296_DungeonViewport); } _vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "HEALTH"); _vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "STAMINA"); @@ -128,7 +128,7 @@ void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) { Box box; box._y1 = 0; box._y2 = 28 + 1; - box._x1 = championIndex * kChampionStatusBoxSpacing + 7; + box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7; box._x2 = box._x1 + 31 + 1; dispMan.blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0, box, k255_ColorNoTransparency); } @@ -160,22 +160,22 @@ void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) { } void InventoryMan::drawPanelFoodWaterPoisoned() { - Champion &champ = _vm->_championMan->_champions[_inventoryChampionOrdinal]; + Champion &champ = _vm->_championMan->_champions[_g432_inventoryChampionOrdinal]; closeChest(); DisplayMan &dispMan = *_vm->_displayMan; - dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, gBoxPanel, k8_ColorRed); - dispMan.blitToScreen(dispMan.getBitmap(k30_FoodLabelIndice), 48, 0, 0, gBoxFood, k12_ColorDarkestGray); - dispMan.blitToScreen(dispMan.getBitmap(k31_WaterLabelIndice), 48, 0, 0, gBoxWater, k12_ColorDarkestGray); + dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed); + dispMan.blitToScreen(dispMan.getBitmap(k30_FoodLabelIndice), 48, 0, 0, g35_BoxFood, k12_ColorDarkestGray); + dispMan.blitToScreen(dispMan.getBitmap(k31_WaterLabelIndice), 48, 0, 0, g36_BoxWater, k12_ColorDarkestGray); if (champ._poisonEventCount) { - dispMan.blitToScreen(dispMan.getBitmap(k32_PoisionedLabelIndice), 96, 0, 0, gBoxPoisoned, k12_ColorDarkestGray); + dispMan.blitToScreen(dispMan.getBitmap(k32_PoisionedLabelIndice), 96, 0, 0, g37_BoxPoisoned, k12_ColorDarkestGray); } drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown); drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue); } void InventoryMan::drawPanelResurrectReincarnate() { - _panelContent = kPanelContentResurrectReincarnate; - _vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, gBoxPanel, k6_ColorDarkGreen, g296_DungeonViewport); + _g424_panelContent = k5_PanelContentResurrectReincarnate; + _vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, g32_BoxPanel, k6_ColorDarkGreen, g296_DungeonViewport); } void InventoryMan::drawPanel() { @@ -188,15 +188,15 @@ void InventoryMan::drawPanel() { return; } - Thing thing = cm._champions[_vm->ordinalToIndex(_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand); + Thing thing = cm._champions[_vm->ordinalToIndex(_g432_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand); - _panelContent = kPanelContentFoodWaterPoisoned; + _g424_panelContent = k0_PanelContentFoodWaterPoisoned; switch (thing.getType()) { case k9_ContainerThingType: - _panelContent = kPanelContentChest; + _g424_panelContent = k4_PanelContentChest; break; case k7_ScrollThingType: - _panelContent = kPanelContentScroll; + _g424_panelContent = k2_PanelContentScroll; break; default: thing = Thing::_none; @@ -213,16 +213,16 @@ void InventoryMan::closeChest() { DungeonMan &dunMan = *_vm->_dungeonMan; bool processFirstChestSlot = true; - if (_openChest == Thing::_none) + if (_g426_openChest == Thing::_none) return; - Container *container = (Container*)dunMan.getThingData(_openChest); - _openChest = Thing::_none; + Container *container = (Container*)dunMan.getThingData(_g426_openChest); + _g426_openChest = Thing::_none; container->getSlot() = Thing::_endOfList; Thing prevThing; for (int16 chestSlotIndex = 0; chestSlotIndex < 8; ++chestSlotIndex) { - Thing thing = _chestSlots[chestSlotIndex]; + Thing thing = _g425_chestSlots[chestSlotIndex]; if (thing != Thing::_none) { - _chestSlots[chestSlotIndex] = Thing::_none; // CHANGE8_09_FIX + _g425_chestSlots[chestSlotIndex] = Thing::_none; // CHANGE8_09_FIX if (processFirstChestSlot) { processFirstChestSlot = false; @@ -258,7 +258,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) { charRed++; } *charRed = '\0'; - dispMan.blitToScreen(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, g296_DungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed, g296_DungeonViewport); int16 lineCount = 1; charRed++; char *charGreen = charRed; // first char of the second line @@ -299,18 +299,18 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is DisplayMan &dispMan = *_vm->_displayMan; ObjectMan &objMan = *_vm->_objectMan; - if (_openChest == thingToOpen) + if (_g426_openChest == thingToOpen) return; warning("CHANGE8_09_FIX"); - if (_openChest != Thing::_none) + if (_g426_openChest != Thing::_none) closeChest(); // CHANGE8_09_FIX - _openChest = thingToOpen; + _g426_openChest = thingToOpen; if (!isPressingEye) { - objMan.drawIconInSlotBox(kSlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen); + objMan.drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen); } - dispMan.blitToScreen(dispMan.getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, gBoxPanel, k8_ColorRed); + dispMan.blitToScreen(dispMan.getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed); int16 chestSlotIndex = 0; Thing thing = chest->getSlot(); @@ -320,13 +320,13 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is if (++thingCount > 8) break; // CHANGE8_08_FIX, make sure that no more than the first 8 objects in a chest are drawn - objMan.drawIconInSlotBox(chestSlotIndex + kSlotBoxChestFirstSlot, objMan.getIconIndex(thing)); - _chestSlots[chestSlotIndex++] = thing; + objMan.drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, objMan.getIconIndex(thing)); + _g425_chestSlots[chestSlotIndex++] = thing; thing = _vm->_dungeonMan->getNextThing(thing); } while (chestSlotIndex < 8) { - objMan.drawIconInSlotBox(chestSlotIndex + kSlotBoxChestFirstSlot, kM1_IconIndiceNone); - _chestSlots[chestSlotIndex++] = Thing::_none; + objMan.drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, kM1_IconIndiceNone); + _g425_chestSlots[chestSlotIndex++] = Thing::_none; } } @@ -373,8 +373,8 @@ void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 a void InventoryMan::drawPanelObjectDescriptionString(char* descString) { if (descString[0] == '\f') { // form feed descString++; - _objDescTextXpos = 108; - _objDescTextYpos = 59; + _g421_objDescTextXpos = 108; + _g422_objDescTextYpos = 59; } if (descString[0]) { @@ -394,8 +394,8 @@ void InventoryMan::drawPanelObjectDescriptionString(char* descString) { severalLines = true; } - _vm->_textMan->printToViewport(_objDescTextXpos, _objDescTextYpos, k13_ColorLightestGray, stringLine); - _objDescTextYpos += 7; + _vm->_textMan->printToViewport(_g421_objDescTextXpos, _g422_objDescTextYpos, k13_ColorLightestGray, stringLine); + _g422_objDescTextYpos += 7; if (severalLines) { severalLines = false; stringLine = ++string; @@ -406,21 +406,21 @@ void InventoryMan::drawPanelObjectDescriptionString(char* descString) { } } -Box gBoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye +Box g33_BoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye void InventoryMan::drawPanelArrowOrEye(bool pressingEye) { DisplayMan &dispMan = *_vm->_displayMan; dispMan.blitToScreen(dispMan.getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice), - 16, 0, 0, gBoxArrowOrEye, k8_ColorRed, g296_DungeonViewport); + 16, 0, 0, g33_BoxArrowOrEye, k8_ColorRed, g296_DungeonViewport); } -Box gBoxObjectDescCircle = Box(105, 136, 53, 79); // @ G0034_s_Graphic562_Box_ObjectDescriptionCircle +Box g34_BoxObjectDescCircle = Box(105, 136, 53, 79); // @ G0034_s_Graphic562_Box_ObjectDescriptionCircle -#define kDescriptionMaskConsumable 0x0001 // @ MASK0x0001_DESCRIPTION_CONSUMABLE -#define kDescriptionMaskPoisoned 0x0002 // @ MASK0x0002_DESCRIPTION_POISONED -#define kDescriptionMaskBroken 0x0004 // @ MASK0x0004_DESCRIPTION_BROKEN -#define kDescriptionMaskCursed 0x0008 // @ MASK0x0008_DESCRIPTION_CURSED +#define k0x0001_DescriptionMaskConsumable 0x0001 // @ MASK0x0001_DESCRIPTION_CONSUMABLE +#define k0x0002_DescriptionMaskPoisoned 0x0002 // @ MASK0x0002_DESCRIPTION_POISONED +#define k0x0004_DescriptionMaskBroken 0x0004 // @ MASK0x0004_DESCRIPTION_BROKEN +#define k0x0008_DescriptionMaskCursed 0x0008 // @ MASK0x0008_DESCRIPTION_CURSED void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { DungeonMan &dunMan = *_vm->_dungeonMan; @@ -443,27 +443,27 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye); } else { IconIndice iconIndex = objMan.getIconIndex(thingToDraw); - dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, gBoxPanel, k8_ColorRed, g296_DungeonViewport); - dispMan.blitToScreen(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, gBoxObjectDescCircle, k12_ColorDarkestGray, g296_DungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed, g296_DungeonViewport); + dispMan.blitToScreen(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, g34_BoxObjectDescCircle, k12_ColorDarkestGray, g296_DungeonViewport); char *descString = nullptr; char str[40]; if (iconIndex == k147_IconIndiceJunkChampionBones) { strcpy(str, champMan._champions[((Junk*)rawThingPtr)->getChargeCount()]._name); // TODO: localization strcat(str, " "); // TODO: localization - strcat(str, objMan._objectNames[iconIndex]); // TODO: localization + strcat(str, objMan._g352_objectNames[iconIndex]); // TODO: localization descString = str; } else if ((thingType == k8_PotionThingType) && (iconIndex != k163_IconIndicePotionWaterFlask) - && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) { + && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_g432_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) { str[0] = '_' + ((Potion*)rawThingPtr)->getPower() / 40; str[1] = ' '; str[2] = '\0'; - strcat(str, objMan._objectNames[iconIndex]); + strcat(str, objMan._g352_objectNames[iconIndex]); descString = str; } else { - descString = objMan._objectNames[iconIndex]; + descString = objMan._g352_objectNames[iconIndex]; } textMan.printToViewport(134, 68, k13_ColorLightestGray, descString); @@ -471,13 +471,13 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { char *attribString[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"}; // TODO: localization - _objDescTextYpos = 87; + _g422_objDescTextYpos = 87; uint16 potentialAttribMask; uint16 actualAttribMask; switch (thingType) { case k5_WeaponThingType: { - potentialAttribMask = kDescriptionMaskCursed | kDescriptionMaskPoisoned | kDescriptionMaskBroken; + potentialAttribMask = k0x0008_DescriptionMaskCursed | k0x0002_DescriptionMaskPoisoned | k0x0004_DescriptionMaskBroken; Weapon *weapon = (Weapon*)rawThingPtr; actualAttribMask = (weapon->getCursed() << 3) | (weapon->getPoisoned() << 1) | (weapon->getBroken() << 2); if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) @@ -488,13 +488,13 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { break; } case k6_ArmourThingType: { - potentialAttribMask = kDescriptionMaskCursed | kDescriptionMaskBroken; + potentialAttribMask = k0x0008_DescriptionMaskCursed | k0x0004_DescriptionMaskBroken; Armour *armour = (Armour*)rawThingPtr; actualAttribMask = (armour->getCursed() << 3) | (armour->getBroken() << 2); break; } case k8_PotionThingType: { - actualAttribMask = kDescriptionMaskConsumable; + actualAttribMask = k0x0001_DescriptionMaskConsumable; Potion *potion = (Potion*)rawThingPtr; actualAttribMask = g237_ObjectInfo[k2_ObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots(); break; @@ -525,7 +525,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { strcat(str, directionName[iconIndex]); drawPanelObjectDescriptionString(str); } else { - potentialAttribMask = kDescriptionMaskConsumable; + potentialAttribMask = k0x0001_DescriptionMaskConsumable; actualAttribMask = g237_ObjectInfo[k127_ObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots(); } break; diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 952511d9e8..82865f5cc5 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -34,17 +34,17 @@ namespace DM { -#define kChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING -#define kSlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT +#define k69_ChampionStatusBoxSpacing 69 // @ C69_CHAMPION_STATUS_BOX_SPACING +#define k38_SlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT -extern Box gBoxPanel; // @ G0032_s_Graphic562_Box_Panel +extern Box g32_BoxPanel; // @ G0032_s_Graphic562_Box_Panel enum PanelContent { - kPanelContentFoodWaterPoisoned = 0, // @ C00_PANEL_FOOD_WATER_POISONED - kPanelContentScroll = 2, // @ C02_PANEL_SCROLL - kPanelContentChest = 4, // @ C04_PANEL_CHEST - kPanelContentResurrectReincarnate = 5 // @ C05_PANEL_RESURRECT_REINCARNATE + k0_PanelContentFoodWaterPoisoned = 0, // @ C00_PANEL_FOOD_WATER_POISONED + k2_PanelContentScroll = 2, // @ C02_PANEL_SCROLL + k4_PanelContentChest = 4, // @ C04_PANEL_CHEST + k5_PanelContentResurrectReincarnate = 5 // @ C05_PANEL_RESURRECT_REINCARNATE }; @@ -54,12 +54,12 @@ class InventoryMan { public: explicit InventoryMan(DMEngine *vm); - int16 _inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal - PanelContent _panelContent; // @ G0424_i_PanelContent - Thing _chestSlots[8]; // @ G0425_aT_ChestSlots - Thing _openChest; // @ G0426_T_OpenChest - int16 _objDescTextXpos; // @ G0421_i_ObjectDescriptionTextX - int16 _objDescTextYpos; // @ G0422_i_ObjectDescriptionTextY + int16 _g432_inventoryChampionOrdinal; // @ G0423_i_InventoryChampionOrdinal + PanelContent _g424_panelContent; // @ G0424_i_PanelContent + Thing _g425_chestSlots[8]; // @ G0425_aT_ChestSlots + Thing _g426_openChest; // @ G0426_T_OpenChest + int16 _g421_objDescTextXpos; // @ G0421_i_ObjectDescriptionTextX + int16 _g422_objDescTextYpos; // @ G0422_i_ObjectDescriptionTextY void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index bd99345c41..aabe88f032 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -62,7 +62,7 @@ LoadgameResponse LoadsaveMan::loadgame() { // MISSING CODE: load game } cm._303_partyDead = false; - return kLoadgameSuccess; + return k1_LoadgameSuccess; } } \ No newline at end of file diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h index 71043a223c..0ee7118582 100644 --- a/engines/dm/loadsave.h +++ b/engines/dm/loadsave.h @@ -33,8 +33,8 @@ namespace DM { enum LoadgameResponse { - kLoadgameFailure = -1, // @ CM1_LOAD_GAME_FAILURE - kLoadgameSuccess = 1// @ C01_LOAD_GAME_SUCCESS + kM1_LoadgameFailure = -1, // @ CM1_LOAD_GAME_FAILURE + k1_LoadgameSuccess = 1// @ C01_LOAD_GAME_SUCCESS }; class LoadsaveMan { diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 20d0f53646..ee27ee0f6b 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -36,26 +36,26 @@ namespace DM { -Box gBoxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu -Box gBoxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu -Box gBoxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu -Box gBoxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea -byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon +Box g499_BoxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu +Box g500_BoxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu +Box g501_BoxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu +Box g1_BoxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea +byte g498_PalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon -Box gBoxSpellAreaLine = Box(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine -Box gBoxSpellAreaLine2 = Box(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 -Box gBoxSpellAreaLine3 = Box(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 -Box gBoxSpellArea = Box(224, 319, 77, 121); +Box gK74_BoxSpellAreaLine = Box(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine +Box gK75_BoxSpellAreaLine2 = Box(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2 +Box gK76_BoxSpellAreaLine3 = Box(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3 +Box g0_BoxSpellArea = Box(224, 319, 77, 121); MenuMan::MenuMan(DMEngine *vm) : _vm(vm) { - _refreshActionArea = false; - _actionAreaContainsIcons = false; - _actionDamage = 0; - _bitmapSpellAreaLine = new byte[96 * 12]; + _g508_refreshActionArea = false; + _g509_actionAreaContainsIcons = false; + _g513_actionDamage = 0; + _gK72_bitmapSpellAreaLine = new byte[96 * 12]; } MenuMan::~MenuMan() { - delete[] _bitmapSpellAreaLine; + delete[] _gK72_bitmapSpellAreaLine; } void MenuMan::drawMovementArrows() { @@ -73,12 +73,12 @@ void MenuMan::clearActingChampion() { cm._champions[cm._g506_actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true); cm.drawChampionState((ChampionIndex)cm._g506_actingChampionOrdinal); cm._g506_actingChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone); - _refreshActionArea = true; + _g508_refreshActionArea = true; } } void MenuMan::drawActionIcon(ChampionIndex championIndex) { - if (!_actionAreaContainsIcons) + if (!_g509_actionAreaContainsIcons) return; DisplayMan &dm = *_vm->_displayMan; Champion &champion = _vm->_championMan->_champions[championIndex]; @@ -105,7 +105,7 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) { goto T0386006; } _vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon); - dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon); + dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, g498_PalChangesActionAreaObjectIcon); T0386006: dm.clearScreenBox(k4_ColorCyan, box); Box box2; @@ -123,8 +123,8 @@ void MenuMan::drawDisabledMenu() { if (!_vm->_championMan->_g300_partyIsSleeping) { warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); _vm->_displayMan->_g578_useByteBoxCoordinates = false; - if (_vm->_inventoryMan->_inventoryChampionOrdinal) { - if (_vm->_inventoryMan->_panelContent == kPanelContentChest) { + if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) { + if (_vm->_inventoryMan->_g424_panelContent == k4_PanelContentChest) { _vm->_inventoryMan->closeChest(); } } else { @@ -170,17 +170,17 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() { } while (champIndex < champMan._g305_partyChampionCount); } - if (_refreshActionArea) { + if (_g508_refreshActionArea) { if (!champMan._g506_actingChampionOrdinal) { - if (_actionDamage) { + if (_g513_actionDamage) { warning("MISSING CODE: F0385_MENUS_DrawActionDamage"); - _actionDamage = 0; + _g513_actionDamage = 0; } else { - _actionAreaContainsIcons = true; + _g509_actionAreaContainsIcons = true; drawActionArea(); } } else { - _actionAreaContainsIcons = false; + _g509_actionAreaContainsIcons = false; champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true); champMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal)); warning("MISSING CODE: F0387_MENUS_DrawActionArea"); @@ -188,8 +188,8 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() { } } -#define kChampionNameMaximumLength 7 // @ C007_CHAMPION_NAME_MAXIMUM_LENGTH -#define kActionNameMaximumLength 12 // @ C012_ACTION_NAME_MAXIMUM_LENGTH +#define k7_ChampionNameMaximumLength 7 // @ C007_CHAMPION_NAME_MAXIMUM_LENGTH +#define k12_ActionNameMaximumLength 12 // @ C012_ACTION_NAME_MAXIMUM_LENGTH void MenuMan::drawActionArea() { DisplayMan &dispMan = *_vm->_displayMan; @@ -198,30 +198,30 @@ void MenuMan::drawActionArea() { warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); dispMan._g578_useByteBoxCoordinates = false; - dispMan.clearScreenBox(k0_ColorBlack, gBoxActionArea); - if (_actionAreaContainsIcons) { + dispMan.clearScreenBox(k0_ColorBlack, g1_BoxActionArea); + if (_g509_actionAreaContainsIcons) { for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._g305_partyChampionCount; ++champIndex) drawActionIcon((ChampionIndex)champIndex); } else if (champMan._g506_actingChampionOrdinal) { - Box box = gBoxActionArea3ActionMenu; - if (_actionList._actionIndices[2] == k255_ChampionActionNone) - box = gBoxActionArea2ActionMenu; - if (_actionList._actionIndices[1] == k255_ChampionActionNone) - box = gBoxActionArea1ActionMenu; + Box box = g499_BoxActionArea3ActionMenu; + if (_g713_actionList._actionIndices[2] == k255_ChampionActionNone) + box = g500_BoxActionArea2ActionMenu; + if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone) + box = g501_BoxActionArea1ActionMenu; dispMan.blitToScreen(dispMan.getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, box, k255_ColorNoTransparency); textMan.printWithTrailingSpacesToScreen(235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name, - kChampionNameMaximumLength); + k7_ChampionNameMaximumLength); for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) { textMan.printWithTrailingSpacesToScreen(241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack, - getActionName(_actionList._actionIndices[actionListIndex]), - kActionNameMaximumLength); + getActionName(_g713_actionList._actionIndices[actionListIndex]), + k12_ActionNameMaximumLength); } } warning("MISSING CODE: F0078_MOUSE_ShowPointer"); - _refreshActionArea = false; + _g508_refreshActionArea = false; } -const char *gChampionActionNames[44] = { +const char *g490_ChampionActionNames[44] = { // @ G0490_ac_Graphic560_ActionNames "N", "BLOCK", "CHOP", "X", "BLOW HORN", "FLIP", "PUNCH", "KICK", "WAR CRY", "STAB", "CLIMB DOWN", "FREEZE LIFE", "HIT", "SWING", "STAB", "THRUST", "JAB", "PARRY", "HACK", @@ -232,11 +232,11 @@ const char *gChampionActionNames[44] = { "BRANDISH", "THROW", "FUSE"}; const char* MenuMan::getActionName(ChampionAction actionIndex) { - return (actionIndex == k255_ChampionActionNone) ? "" : gChampionActionNames[actionIndex]; + return (actionIndex == k255_ChampionActionNone) ? "" : g490_ChampionActionNames[actionIndex]; } -Box gBoxSpellAreaControls = Box(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls +Box g504_BoxSpellAreaControls = Box(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) { ChampionMan &champMan = *_vm->_championMan; @@ -248,7 +248,7 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) { for (uint16 i = 0; i < 4; ++i) champCurrHealth[i] = champMan._champions[i]._currHealth; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan.clearScreenBox(k0_ColorBlack, gBoxSpellAreaControls); + dispMan.clearScreenBox(k0_ColorBlack, g504_BoxSpellAreaControls); int16 champCount = champMan._g305_partyChampionCount; switch (champIndex) { case k0_ChampionFirst: @@ -306,32 +306,32 @@ labelChamp3: warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } -#define kSpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS -#define kSpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS +#define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS +#define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) { DisplayMan &dispMan = *_vm->_displayMan; Champion &champ = _vm->_championMan->_champions[_vm->_championMan->_g514_magicCasterChampionIndex]; - if (spellAreaBitmapLine == kSpellAreaAvailableSymbols) { + if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) { dispMan._g578_useByteBoxCoordinates = false; - dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 12, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, k255_ColorNoTransparency); + dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 12, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency); int16 x = 1; byte c = 96 + (6 * champ._symbolStep); char spellSymbolString[2] = {'\0', '\0'}; for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) { spellSymbolString[0] = c++; - _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12); + _vm->_textMan->printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12); } - } else if (spellAreaBitmapLine == kSpellAreaChampionSymbols) { + } else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) { dispMan._g578_useByteBoxCoordinates = false; - dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 24, _bitmapSpellAreaLine, 96, gBoxSpellAreaLine, k255_ColorNoTransparency); + dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 24, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency); char spellSymbolString[2] = {'\0', '\0'}; int16 x = 8; for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) { if ((spellSymbolString[0] = champ._symbols[symbolIndex]) == '\0') break; - _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 96, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12); + _vm->_textMan->printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12); } } } @@ -345,25 +345,25 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) { return; if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) { warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan.blitToScreen(dispMan.getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, gBoxSpellArea); + dispMan.blitToScreen(dispMan.getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, g0_BoxSpellArea); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } if (champIndex == kM1_ChampionNone) { champMan._g514_magicCasterChampionIndex = kM1_ChampionNone; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); dispMan._g578_useByteBoxCoordinates = false; - dispMan.clearScreenBox(k0_ColorBlack, gBoxSpellArea); + dispMan.clearScreenBox(k0_ColorBlack, g0_BoxSpellArea); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); return; } champMan._g514_magicCasterChampionIndex = (ChampionIndex)champIndex; - buildSpellAreaLine(kSpellAreaAvailableSymbols); + buildSpellAreaLine(k2_SpellAreaAvailableSymbols); warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); drawSpellAreaControls((ChampionIndex)champIndex); - dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine2); - buildSpellAreaLine(kSpellAreaChampionSymbols); - dispMan.blitToScreen(_bitmapSpellAreaLine, 96, 0, 0, gBoxSpellAreaLine3); + dispMan.blitToScreen(_gK72_bitmapSpellAreaLine, 96, 0, 0, gK75_BoxSpellAreaLine2); + buildSpellAreaLine(k3_SpellAreaChampionSymbols); + dispMan.blitToScreen(_gK72_bitmapSpellAreaLine, 96, 0, 0, gK76_BoxSpellAreaLine3); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } } diff --git a/engines/dm/menus.h b/engines/dm/menus.h index b591872011..30bf01c542 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -33,8 +33,8 @@ namespace DM { -extern Box gBoxActionArea; // @ G0001_s_Graphic562_Box_ActionArea -extern Box gBoxSpellArea; // @ G0000_s_Graphic562_Box_SpellArea +extern Box g1_BoxActionArea; // @ G0001_s_Graphic562_Box_ActionArea +extern Box g0_BoxSpellArea; // @ G0000_s_Graphic562_Box_SpellArea class ActionList { public: @@ -54,11 +54,11 @@ public: explicit MenuMan(DMEngine *vm); ~MenuMan(); - bool _refreshActionArea; // @ G0508_B_RefreshActionArea - bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons - int16 _actionDamage; // @ G0513_i_ActionDamage - ActionList _actionList; // @ G0713_s_ActionList - byte *_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine + bool _g508_refreshActionArea; // @ G0508_B_RefreshActionArea + bool _g509_actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons + int16 _g513_actionDamage; // @ G0513_i_ActionDamage + ActionList _g713_actionList; // @ G0713_s_ActionList + byte *_gK72_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 810847caad..9c3b2284bc 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -31,9 +31,9 @@ namespace DM { -int16 gIconGraphicHeight[7] = {32, 32, 32, 32, 32, 32, 32}; // @ K0077_ai_IconGraphicHeight +int16 gK77_IconGraphicHeight[7] = {32, 32, 32, 32, 32, 32, 32}; // @ K0077_ai_IconGraphicHeight -int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex +int16 g26_IconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex 0, /* First icon index in graphic #42 */ 32, /* First icon index in graphic #43 */ 64, /* First icon index in graphic #44 */ @@ -44,73 +44,73 @@ int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconI ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) { /* 8 for champion hands in status boxes, 30 for champion inventory, 8 for chest */ - _slotBoxes[0] = SlotBox(4, 10, 0); /* Champion Status Box 0 Ready Hand */ - _slotBoxes[1] = SlotBox(24, 10, 0); /* Champion Status Box 0 Action Hand */ - _slotBoxes[2] = SlotBox(73, 10, 0); /* Champion Status Box 1 Ready Hand */ - _slotBoxes[3] = SlotBox(93, 10, 0); /* Champion Status Box 1 Action Hand */ - _slotBoxes[4] = SlotBox(142, 10, 0); /* Champion Status Box 2 Ready Hand */ - _slotBoxes[5] = SlotBox(162, 10, 0); /* Champion Status Box 2 Action Hand */ - _slotBoxes[6] = SlotBox(211, 10, 0); /* Champion Status Box 3 Ready Hand */ - _slotBoxes[7] = SlotBox(231, 10, 0); /* Champion Status Box 3 Action Hand */ - _slotBoxes[8] = SlotBox(6, 53, 0); /* Ready Hand */ - _slotBoxes[9] = SlotBox(62, 53, 0); /* Action Hand */ - _slotBoxes[10] = SlotBox(34, 26, 0); /* Head */ - _slotBoxes[11] = SlotBox(34, 46, 0); /* Torso */ - _slotBoxes[12] = SlotBox(34, 66, 0); /* Legs */ - _slotBoxes[13] = SlotBox(34, 86, 0); /* Feet */ - _slotBoxes[14] = SlotBox(6, 90, 0); /* Pouch 2 */ - _slotBoxes[15] = SlotBox(79, 73, 0); /* Quiver Line2 1 */ - _slotBoxes[16] = SlotBox(62, 90, 0); /* Quiver Line1 2 */ - _slotBoxes[17] = SlotBox(79, 90, 0); /* Quiver Line2 2 */ - _slotBoxes[18] = SlotBox(6, 33, 0); /* Neck */ - _slotBoxes[19] = SlotBox(6, 73, 0); /* Pouch 1 */ - _slotBoxes[20] = SlotBox(62, 73, 0); /* Quiver Line1 1 */ - _slotBoxes[21] = SlotBox(66, 33, 0); /* Backpack Line1 1 */ - _slotBoxes[22] = SlotBox(83, 16, 0); /* Backpack Line2 2 */ - _slotBoxes[23] = SlotBox(100, 16, 0); /* Backpack Line2 3 */ - _slotBoxes[24] = SlotBox(117, 16, 0); /* Backpack Line2 4 */ - _slotBoxes[25] = SlotBox(134, 16, 0); /* Backpack Line2 5 */ - _slotBoxes[26] = SlotBox(151, 16, 0); /* Backpack Line2 6 */ - _slotBoxes[27] = SlotBox(168, 16, 0); /* Backpack Line2 7 */ - _slotBoxes[28] = SlotBox(185, 16, 0); /* Backpack Line2 8 */ - _slotBoxes[29] = SlotBox(202, 16, 0); /* Backpack Line2 9 */ - _slotBoxes[30] = SlotBox(83, 33, 0); /* Backpack Line1 2 */ - _slotBoxes[31] = SlotBox(100, 33, 0); /* Backpack Line1 3 */ - _slotBoxes[32] = SlotBox(117, 33, 0); /* Backpack Line1 4 */ - _slotBoxes[33] = SlotBox(134, 33, 0); /* Backpack Line1 5 */ - _slotBoxes[34] = SlotBox(151, 33, 0); /* Backpack Line1 6 */ - _slotBoxes[35] = SlotBox(168, 33, 0); /* Backpack Line1 7 */ - _slotBoxes[36] = SlotBox(185, 33, 0); /* Backpack Line1 8 */ - _slotBoxes[37] = SlotBox(202, 33, 0); /* Backpack Line1 9 */ - _slotBoxes[38] = SlotBox(117, 59, 0); /* Chest 1 */ - _slotBoxes[39] = SlotBox(106, 76, 0); /* Chest 2 */ - _slotBoxes[40] = SlotBox(111, 93, 0); /* Chest 3 */ - _slotBoxes[41] = SlotBox(128, 98, 0); /* Chest 4 */ - _slotBoxes[42] = SlotBox(145, 101, 0); /* Chest 5 */ - _slotBoxes[43] = SlotBox(162, 103, 0); /* Chest 6 */ - _slotBoxes[44] = SlotBox(179, 104, 0); /* Chest 7 */ - _slotBoxes[45] = SlotBox(196, 105, 0); /* Chest 8 */ - - _objectIconForMousePointer = nullptr; + _g30_slotBoxes[0] = SlotBox(4, 10, 0); /* Champion Status Box 0 Ready Hand */ + _g30_slotBoxes[1] = SlotBox(24, 10, 0); /* Champion Status Box 0 Action Hand */ + _g30_slotBoxes[2] = SlotBox(73, 10, 0); /* Champion Status Box 1 Ready Hand */ + _g30_slotBoxes[3] = SlotBox(93, 10, 0); /* Champion Status Box 1 Action Hand */ + _g30_slotBoxes[4] = SlotBox(142, 10, 0); /* Champion Status Box 2 Ready Hand */ + _g30_slotBoxes[5] = SlotBox(162, 10, 0); /* Champion Status Box 2 Action Hand */ + _g30_slotBoxes[6] = SlotBox(211, 10, 0); /* Champion Status Box 3 Ready Hand */ + _g30_slotBoxes[7] = SlotBox(231, 10, 0); /* Champion Status Box 3 Action Hand */ + _g30_slotBoxes[8] = SlotBox(6, 53, 0); /* Ready Hand */ + _g30_slotBoxes[9] = SlotBox(62, 53, 0); /* Action Hand */ + _g30_slotBoxes[10] = SlotBox(34, 26, 0); /* Head */ + _g30_slotBoxes[11] = SlotBox(34, 46, 0); /* Torso */ + _g30_slotBoxes[12] = SlotBox(34, 66, 0); /* Legs */ + _g30_slotBoxes[13] = SlotBox(34, 86, 0); /* Feet */ + _g30_slotBoxes[14] = SlotBox(6, 90, 0); /* Pouch 2 */ + _g30_slotBoxes[15] = SlotBox(79, 73, 0); /* Quiver Line2 1 */ + _g30_slotBoxes[16] = SlotBox(62, 90, 0); /* Quiver Line1 2 */ + _g30_slotBoxes[17] = SlotBox(79, 90, 0); /* Quiver Line2 2 */ + _g30_slotBoxes[18] = SlotBox(6, 33, 0); /* Neck */ + _g30_slotBoxes[19] = SlotBox(6, 73, 0); /* Pouch 1 */ + _g30_slotBoxes[20] = SlotBox(62, 73, 0); /* Quiver Line1 1 */ + _g30_slotBoxes[21] = SlotBox(66, 33, 0); /* Backpack Line1 1 */ + _g30_slotBoxes[22] = SlotBox(83, 16, 0); /* Backpack Line2 2 */ + _g30_slotBoxes[23] = SlotBox(100, 16, 0); /* Backpack Line2 3 */ + _g30_slotBoxes[24] = SlotBox(117, 16, 0); /* Backpack Line2 4 */ + _g30_slotBoxes[25] = SlotBox(134, 16, 0); /* Backpack Line2 5 */ + _g30_slotBoxes[26] = SlotBox(151, 16, 0); /* Backpack Line2 6 */ + _g30_slotBoxes[27] = SlotBox(168, 16, 0); /* Backpack Line2 7 */ + _g30_slotBoxes[28] = SlotBox(185, 16, 0); /* Backpack Line2 8 */ + _g30_slotBoxes[29] = SlotBox(202, 16, 0); /* Backpack Line2 9 */ + _g30_slotBoxes[30] = SlotBox(83, 33, 0); /* Backpack Line1 2 */ + _g30_slotBoxes[31] = SlotBox(100, 33, 0); /* Backpack Line1 3 */ + _g30_slotBoxes[32] = SlotBox(117, 33, 0); /* Backpack Line1 4 */ + _g30_slotBoxes[33] = SlotBox(134, 33, 0); /* Backpack Line1 5 */ + _g30_slotBoxes[34] = SlotBox(151, 33, 0); /* Backpack Line1 6 */ + _g30_slotBoxes[35] = SlotBox(168, 33, 0); /* Backpack Line1 7 */ + _g30_slotBoxes[36] = SlotBox(185, 33, 0); /* Backpack Line1 8 */ + _g30_slotBoxes[37] = SlotBox(202, 33, 0); /* Backpack Line1 9 */ + _g30_slotBoxes[38] = SlotBox(117, 59, 0); /* Chest 1 */ + _g30_slotBoxes[39] = SlotBox(106, 76, 0); /* Chest 2 */ + _g30_slotBoxes[40] = SlotBox(111, 93, 0); /* Chest 3 */ + _g30_slotBoxes[41] = SlotBox(128, 98, 0); /* Chest 4 */ + _g30_slotBoxes[42] = SlotBox(145, 101, 0); /* Chest 5 */ + _g30_slotBoxes[43] = SlotBox(162, 103, 0); /* Chest 6 */ + _g30_slotBoxes[44] = SlotBox(179, 104, 0); /* Chest 7 */ + _g30_slotBoxes[45] = SlotBox(196, 105, 0); /* Chest 8 */ + + _g412_objectIconForMousePointer = nullptr; } ObjectMan::~ObjectMan() { - delete[] _objectIconForMousePointer; - delete[] _objectNames[0]; + delete[] _g412_objectIconForMousePointer; + delete[] _g352_objectNames[0]; } -#define kObjectNamesGraphicIndice 556 // @ C556_GRAPHIC_OBJECT_NAMES +#define k556_ObjectNamesGraphicIndice 556 // @ C556_GRAPHIC_OBJECT_NAMES void ObjectMan::loadObjectNames() { DisplayMan &dispMan = *_vm->_displayMan; - _objectIconForMousePointer = new byte[16 * 16]; + _g412_objectIconForMousePointer = new byte[16 * 16]; - char *objectNames = new char[dispMan.getCompressedDataSize(kObjectNamesGraphicIndice) + kObjectNameCount]; - Common::MemoryReadStream stream = dispMan.getCompressedData(kObjectNamesGraphicIndice); + char *objectNames = new char[dispMan.getCompressedDataSize(k556_ObjectNamesGraphicIndice) + k199_ObjectNameCount]; + Common::MemoryReadStream stream = dispMan.getCompressedData(k556_ObjectNamesGraphicIndice); - for (uint16 objNameIndex = 0; objNameIndex < kObjectNameCount; ++objNameIndex) { - _objectNames[objNameIndex] = objectNames; + for (uint16 objNameIndex = 0; objNameIndex < k199_ObjectNameCount; ++objNameIndex) { + _g352_objectNames[objNameIndex] = objectNames; byte tmpByte; for (tmpByte = stream.readByte(); !(tmpByte & 0x80); tmpByte = stream.readByte()) // last char of object name has 7th bit on @@ -132,7 +132,7 @@ IconIndice ObjectMan::getObjectType(Thing thing) { return (IconIndice)objectInfoIndex; } -byte gChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType +byte g29_ChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType IconIndice ObjectMan::getIconIndex(Thing thing) { IconIndice iconIndex = getObjectType(thing); @@ -150,7 +150,7 @@ IconIndice ObjectMan::getIconIndex(Thing thing) { case k4_IconIndiceWeaponTorchUnlit: { Weapon weapon(rawType); if (weapon.isLit()) { - iconIndex = (IconIndice)(iconIndex + gChargeCountToTorchType[weapon.getChargeCount()]); + iconIndex = (IconIndice)(iconIndex + g29_ChargeCountToTorchType[weapon.getChargeCount()]); } break; } @@ -187,19 +187,19 @@ IconIndice ObjectMan::getIconIndex(Thing thing) { void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { int16 i; for (i = 0; i < 7; ++i) { - if (gIconGraphicFirstIndex[i] > iconIndex) + if (g26_IconGraphicFirstIndex[i] > iconIndex) break; } --i; byte *srcBitmap = _vm->_displayMan->getBitmap(k42_ObjectIcons_000_TO_031 + i); - iconIndex -= gIconGraphicFirstIndex[i]; + iconIndex -= g26_IconGraphicFirstIndex[i]; _vm->_displayMan->_g578_useByteBoxCoordinates = true; _vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, 0, 16, 0, 16, k255_ColorNoTransparency); } void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { - SlotBox *slotBox = &_slotBoxes[slotBoxIndex]; + SlotBox *slotBox = &_g30_slotBoxes[slotBoxIndex]; slotBox->_iconIndex = iconIndex; // yes, this modifies the global array if (slotBox->_iconIndex == kM1_IconIndiceNone) { return; @@ -213,16 +213,16 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { uint16 iconGraphicIndex; for (iconGraphicIndex = 0; iconGraphicIndex < 7; ++iconGraphicIndex) { - if (gIconGraphicFirstIndex[iconGraphicIndex] > iconIndex) { + if (g26_IconGraphicFirstIndex[iconGraphicIndex] > iconIndex) { break; } } iconGraphicIndex--; byte *iconsBitmap = _vm->_displayMan->getBitmap(iconGraphicIndex + k42_ObjectIcons_000_TO_031); - iconIndex -= gIconGraphicFirstIndex[iconGraphicIndex]; + iconIndex -= g26_IconGraphicFirstIndex[iconGraphicIndex]; _vm->_displayMan->_g578_useByteBoxCoordinates = false; - if (slotBoxIndex >= kSlotBoxInventoryFirstSlot) { + if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) { _vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, box, k255_ColorNoTransparency, g296_DungeonViewport); } else { @@ -231,7 +231,7 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { } } -#define kObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH +#define k14_ObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH void ObjectMan::drawLeaderObjectName(Thing thing) { IconIndice iconIndex = getIconIndex(thing); @@ -240,15 +240,15 @@ void ObjectMan::drawLeaderObjectName(Thing thing) { if (iconIndex == k147_IconIndiceJunkChampionBones) { Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing); strcpy(objectNameBuffer, _vm->_championMan->_champions[junk->getChargeCount()]._name); - strcat(objectNameBuffer, _objectNames[iconIndex]); + strcat(objectNameBuffer, _g352_objectNames[iconIndex]); objName = objectNameBuffer; } else { - objName = _objectNames[iconIndex]; + objName = _g352_objectNames[iconIndex]; } - _vm->_textMan->printWithTrailingSpacesToScreen(233, 37, k4_ColorCyan, k0_ColorBlack, objName, kObjectNameMaximumLength); + _vm->_textMan->printWithTrailingSpacesToScreen(233, 37, k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength); } IconIndice ObjectMan::getIconIndexInSlotBox(uint16 slotBoxIndex) { - return (IconIndice)_slotBoxes[slotBoxIndex]._iconIndex; + return (IconIndice)_g30_slotBoxes[slotBoxIndex]._iconIndex; } } diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index f075076439..f0d2bedf07 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -31,11 +31,11 @@ namespace DM { -#define kSlotBoxInventoryFirstSlot 8 // @ C08_SLOT_BOX_INVENTORY_FIRST_SLOT -#define kSlotBoxInventoryActionHand 9 // @ C09_SLOT_BOX_INVENTORY_ACTION_HAND -#define kSlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT +#define k8_SlotBoxInventoryFirstSlot 8 // @ C08_SLOT_BOX_INVENTORY_FIRST_SLOT +#define k9_SlotBoxInventoryActionHand 9 // @ C09_SLOT_BOX_INVENTORY_ACTION_HAND +#define k38_SlotBoxChestFirstSlot 38 // @ C38_SLOT_BOX_CHEST_FIRST_SLOT -#define kObjectNameCount 199 // @ C199_OBJECT_NAME_COUNT +#define k199_ObjectNameCount 199 // @ C199_OBJECT_NAME_COUNT class SlotBox { public: @@ -54,9 +54,9 @@ public: ~ObjectMan(); void loadObjectNames(); // @ F0031_OBJECT_LoadNames - SlotBox _slotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes; - char *_objectNames[kObjectNameCount]; // @ G0352_apc_ObjectNames - byte *_objectIconForMousePointer; // @ G0412_puc_Bitmap_ObjectIconForMousePointer + SlotBox _g30_slotBoxes[46]; // @ G0030_as_Graphic562_SlotBoxes; + char *_g352_objectNames[k199_ObjectNameCount]; // @ G0352_apc_ObjectNames + byte *_g412_objectIconForMousePointer; // @ G0412_puc_Bitmap_ObjectIconForMousePointer IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index 8f4e04c6be..f526faad88 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -32,8 +32,8 @@ namespace DM { TextMan::TextMan(DMEngine* vm) : _vm(vm) {} -#define kLetterWidth 5 -#define kLetterHeight 6 +#define k5_LetterWidth 5 +#define k6_LetterHeight 6 void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text, uint16 destHeight, Viewport &viewport) { @@ -46,22 +46,22 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 byte *srcBitmap = _vm->_displayMan->getBitmap(k557_FontGraphicIndice); byte *tmp = _vm->_displayMan->_g74_tmpBitmap; - for (uint16 i = 0; i < (kLetterWidth + 1) * kLetterHeight * 128; ++i) { + for (uint16 i = 0; i < (k5_LetterWidth + 1) * k6_LetterHeight * 128; ++i) { tmp[i] = srcBitmap[i] ? textColor : bgColor; } srcBitmap = tmp; for (const char *begin = text, *end = text + textLength; begin != end; ++begin) { - if (nextX + kLetterWidth + 1 >= (viewport._posX + viewport._width) || (*begin == '\n')) { + if (nextX + k5_LetterWidth + 1 >= (viewport._posX + viewport._width) || (*begin == '\n')) { nextX = destX; - nextY += kLetterHeight + 1; + nextY += k6_LetterHeight + 1; } - if (nextY + kLetterHeight >= (viewport._posY + viewport._height)) + if (nextY + k6_LetterHeight >= (viewport._posY + viewport._height)) break; uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code _vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth, - (nextX == destX) ? (nextX + 1) : nextX, nextX + kLetterWidth + 1, nextY, nextY + kLetterHeight, k255_ColorNoTransparency, viewport); - nextX += kLetterWidth + 1; + (nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight, k255_ColorNoTransparency, viewport); + nextX += k5_LetterWidth + 1; } } diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 101fccad42..d9e7806b35 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -32,23 +32,23 @@ namespace DM { Timeline::Timeline(DMEngine* vm) : _vm(vm) { - _events = nullptr; - _timeline = nullptr; + _g370_events = nullptr; + _g371_timeline = nullptr; } Timeline::~Timeline() { - delete[] _events; - delete[] _timeline; + delete[] _g370_events; + delete[] _g371_timeline; } void Timeline::initTimeline() { - _events = new TimelineEvent[_eventMaxCount]; - _timeline = new uint16[_eventMaxCount]; + _g370_events = new TimelineEvent[_g369_eventMaxCount]; + _g371_timeline = new uint16[_g369_eventMaxCount]; if (_vm->_dungeonMan->_messages._g298_newGame) { - for (int16 i = 0; i < _eventMaxCount; ++i) - _events->_type = kTMEventTypeNone; - _eventCount = 0; - _firstUnusedEventIndex = 0; + for (int16 i = 0; i < _g369_eventMaxCount; ++i) + _g370_events->_type = k0_TMEventTypeNone; + _g372_eventCount = 0; + _g373_firstUnusedEventIndex = 0; } } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index f773530917..47d339eb33 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -35,62 +35,62 @@ namespace DM { /* Event types */ enum TimelineEventType { /* Used when a creature in a group was damaged or killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by = 3, Fluxcages */ -kTMEventTypeCreateReactionEvent29DangerOnSquare = 253, // @ CM3_EVENT_CREATE_REACTION_EVENT_29_DANGER_ON_SQUARE +kM3_TMEventTypeCreateReactionEvent29DangerOnSquare = -3, // @ CM3_EVENT_CREATE_REACTION_EVENT_29_DANGER_ON_SQUARE /* Used when a projectile impacts with a creature in a group */ -kTMEventTypeCreateReactionEvent30HitByProjectile = 254, // @ CM2_EVENT_CREATE_REACTION_EVENT_30_HIT_BY_PROJECTILE +kM2_TMEventTypeCreateReactionEvent30HitByProjectile = -2, // @ CM2_EVENT_CREATE_REACTION_EVENT_30_HIT_BY_PROJECTILE /* Used when the party bumps into a group or performs a melee attack */ -kTMEventTypeCreateReactionEvent31ParyIsAdjacent = 255, // @ CM1_EVENT_CREATE_REACTION_EVENT_31_PARTY_IS_ADJACENT -kTMEventTypeNone = 0, // @ C00_EVENT_NONE -kTMEventTypeDoorAnimation = 1, // @ C01_EVENT_DOOR_ANIMATION -kTMEventTypeDoorDestruction = 2, // @ C02_EVENT_DOOR_DESTRUCTION -kTMEventTypeCorridor = 5, // @ C05_EVENT_CORRIDOR -kTMEventTypeWall = 6, // @ C06_EVENT_WALL -kTMEventTypeFakeWall = 7, // @ C07_EVENT_FAKEWALL -kTMEventTypeTeleporter = 8, // @ C08_EVENT_TELEPORTER -kTMEventTypePit = 9, // @ C09_EVENT_PIT -kTMEventTypeDoor = 10, // @ C10_EVENT_DOOR -kTMEventTypeEnableChampionAction = 11, // @ C11_EVENT_ENABLE_CHAMPION_ACTION -kTMEventTypeHideDamageReceived = 12, // @ C12_EVENT_HIDE_DAMAGE_RECEIVED -kTMEventTypeViAltarRebirth = 13, // @ C13_EVENT_VI_ALTAR_REBIRTH -kTMEventTypePlaySound = 20, // @ C20_EVENT_PLAY_SOUND -kTMEventTypeCPSE = 22, // @ C22_EVENT_CPSE -kTMEventTypeRemoveFluxcage = 24, // @ C24_EVENT_REMOVE_FLUXCAGE -kTMEventTypeExplosion = 25, // @ C25_EVENT_EXPLOSION -kTMEventTypeGroupReactionDangerOnSquare = 29, // @ C29_EVENT_GROUP_REACTION_DANGER_ON_SQUARE -kTMEventTypeGroupReacionHitByProjectile = 30, // @ C30_EVENT_GROUP_REACTION_HIT_BY_PROJECTILE -kTMEventTypeGroupReactionPartyIsAdjecent = 31, // @ C31_EVENT_GROUP_REACTION_PARTY_IS_ADJACENT -kTMEventTypeUpdateAspectGroup = 32, // @ C32_EVENT_UPDATE_ASPECT_GROUP +kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent = -1, // @ CM1_EVENT_CREATE_REACTION_EVENT_31_PARTY_IS_ADJACENT +k0_TMEventTypeNone = 0, // @ C00_EVENT_NONE +k1_TMEventTypeDoorAnimation = 1, // @ C01_EVENT_DOOR_ANIMATION +k2_TMEventTypeDoorDestruction = 2, // @ C02_EVENT_DOOR_DESTRUCTION +k5_TMEventTypeCorridor = 5, // @ C05_EVENT_CORRIDOR +k6_TMEventTypeWall = 6, // @ C06_EVENT_WALL +k7_TMEventTypeFakeWall = 7, // @ C07_EVENT_FAKEWALL +k8_TMEventTypeTeleporter = 8, // @ C08_EVENT_TELEPORTER +k9_TMEventTypePit = 9, // @ C09_EVENT_PIT +k10_TMEventTypeDoor = 10, // @ C10_EVENT_DOOR +k11_TMEventTypeEnableChampionAction = 11, // @ C11_EVENT_ENABLE_CHAMPION_ACTION +k12_TMEventTypeHideDamageReceived = 12, // @ C12_EVENT_HIDE_DAMAGE_RECEIVED +k13_TMEventTypeViAltarRebirth = 13, // @ C13_EVENT_VI_ALTAR_REBIRTH +k20_TMEventTypePlaySound = 20, // @ C20_EVENT_PLAY_SOUND +k22_TMEventTypeCPSE = 22, // @ C22_EVENT_CPSE +k24_TMEventTypeRemoveFluxcage = 24, // @ C24_EVENT_REMOVE_FLUXCAGE +k25_TMEventTypeExplosion = 25, // @ C25_EVENT_EXPLOSION +k29_TMEventTypeGroupReactionDangerOnSquare = 29, // @ C29_EVENT_GROUP_REACTION_DANGER_ON_SQUARE +k30_TMEventTypeGroupReacionHitByProjectile = 30, // @ C30_EVENT_GROUP_REACTION_HIT_BY_PROJECTILE +k31_TMEventTypeGroupReactionPartyIsAdjecent = 31, // @ C31_EVENT_GROUP_REACTION_PARTY_IS_ADJACENT +k32_TMEventTypeUpdateAspectGroup = 32, // @ C32_EVENT_UPDATE_ASPECT_GROUP /* Events = 33,-36 and = 38,-41 are used for individual creatures only while the group is attacking the party */ -kTMEventTypeUpdateAspectCreature_0 = 33, // @ C33_EVENT_UPDATE_ASPECT_CREATURE_0 -kTMEventTypeUpdateAspectCreature_1 = 34, // @ C34_EVENT_UPDATE_ASPECT_CREATURE_1 -kTMEventTypeUpdateAspectCreature_2 = 35, // @ C35_EVENT_UPDATE_ASPECT_CREATURE_2 -kTMEventTypeUpdateAspectCreature_3 = 36, // @ C36_EVENT_UPDATE_ASPECT_CREATURE_3 -kTMEventTypeUpdateBehaviourGroup = 37, // @ C37_EVENT_UPDATE_BEHAVIOR_GROUP -kTMEventTypeUpdateBehaviour_0 = 38, // @ C38_EVENT_UPDATE_BEHAVIOR_CREATURE_0 -kTMEventTypeUpdateBehaviour_1 = 39, // @ C39_EVENT_UPDATE_BEHAVIOR_CREATURE_1 -kTMEventTypeUpdateBehaviour_2 = 40, // @ C40_EVENT_UPDATE_BEHAVIOR_CREATURE_2 -kTMEventTypeUpdateBehaviour_3 = 41, // @ C41_EVENT_UPDATE_BEHAVIOR_CREATURE_3 +k33_TMEventTypeUpdateAspectCreature_0 = 33, // @ C33_EVENT_UPDATE_ASPECT_CREATURE_0 +k34_TMEventTypeUpdateAspectCreature_1 = 34, // @ C34_EVENT_UPDATE_ASPECT_CREATURE_1 +k35_TMEventTypeUpdateAspectCreature_2 = 35, // @ C35_EVENT_UPDATE_ASPECT_CREATURE_2 +k36_TMEventTypeUpdateAspectCreature_3 = 36, // @ C36_EVENT_UPDATE_ASPECT_CREATURE_3 +k37_TMEventTypeUpdateBehaviourGroup = 37, // @ C37_EVENT_UPDATE_BEHAVIOR_GROUP +k38_TMEventTypeUpdateBehaviour_0 = 38, // @ C38_EVENT_UPDATE_BEHAVIOR_CREATURE_0 +k39_TMEventTypeUpdateBehaviour_1 = 39, // @ C39_EVENT_UPDATE_BEHAVIOR_CREATURE_1 +k40_TMEventTypeUpdateBehaviour_2 = 40, // @ C40_EVENT_UPDATE_BEHAVIOR_CREATURE_2 +k41_TMEventTypeUpdateBehaviour_3 = 41, // @ C41_EVENT_UPDATE_BEHAVIOR_CREATURE_3 /* Projectiles created by a champion (by casting a spell, shooting a weapon or throwing an object) or by a creature (by casting a spell) ignore impacts during their first movement otherwise an impact would always occur immediately as these projectiles are created on the champion or creature square */ -kTMEventTypeMoveProjectileIgnoreImpacts = 48, // @ C48_EVENT_MOVE_PROJECTILE_IGNORE_IMPACTS +k48_TMEventTypeMoveProjectileIgnoreImpacts = 48, // @ C48_EVENT_MOVE_PROJECTILE_IGNORE_IMPACTS /* Projectiles created by projectile launcher sensors never ignore impacts as well as all other projectiles after their first movement */ -kTMEventTypeMoveProjectile = 49, // @ C49_EVENT_MOVE_PROJECTILE -kTMEventTypeWatchdoge = 53, // @ C53_EVENT_WATCHDOG -kTMEventTypeMoveGroupSilent = 60, // @ C60_EVENT_MOVE_GROUP_SILENT -kTMEventTypeMoveGroupAudible = 61, // @ C61_EVENT_MOVE_GROUP_AUDIBLE -kTMEventTypeEnableGroupGenerator = 65, // @ C65_EVENT_ENABLE_GROUP_GENERATOR -kTMEventTypeLight = 70, // @ C70_EVENT_LIGHT -kTMEventTypeInvisibility = 71, // @ C71_EVENT_INVISIBILITY -kTMEventTypeChampionShield = 72, // @ C72_EVENT_CHAMPION_SHIELD -kTMEventTypeThievesEye = 73, // @ C73_EVENT_THIEVES_EYE -kTMEventTypePartyShield = 74, // @ C74_EVENT_PARTY_SHIELD -kTMEventTypePoisonChampion = 75, // @ C75_EVENT_POISON_CHAMPION -kTMEventTypeSpellShield = 77, // @ C77_EVENT_SPELLSHIELD -kTMEventTypeFireShield = 78, // @ C78_EVENT_FIRESHIELD -kTMEventTypeFootprints = 79, // @ C79_EVENT_FOOTPRINTS -kTMEventTypeMagicMap_C80 = 80, // @ C80_EVENT_MAGIC_MAP -kTMEventTypeMagicMap_C81 = 81, // @ C81_EVENT_MAGIC_MAP -kTMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP -kTMEventTypeMagicMap_C83 = 83 // @ C83_EVENT_MAGIC_MAP +k49_TMEventTypeMoveProjectile = 49, // @ C49_EVENT_MOVE_PROJECTILE +k53_TMEventTypeWatchdoge = 53, // @ C53_EVENT_WATCHDOG +k60_TMEventTypeMoveGroupSilent = 60, // @ C60_EVENT_MOVE_GROUP_SILENT +k61_TMEventTypeMoveGroupAudible = 61, // @ C61_EVENT_MOVE_GROUP_AUDIBLE +k65_TMEventTypeEnableGroupGenerator = 65, // @ C65_EVENT_ENABLE_GROUP_GENERATOR +k70_TMEventTypeLight = 70, // @ C70_EVENT_LIGHT +k71_TMEventTypeInvisibility = 71, // @ C71_EVENT_INVISIBILITY +k72_TMEventTypeChampionShield = 72, // @ C72_EVENT_CHAMPION_SHIELD +k73_TMEventTypeThievesEye = 73, // @ C73_EVENT_THIEVES_EYE +k74_TMEventTypePartyShield = 74, // @ C74_EVENT_PARTY_SHIELD +k75_TMEventTypePoisonChampion = 75, // @ C75_EVENT_POISON_CHAMPION +k77_TMEventTypeSpellShield = 77, // @ C77_EVENT_SPELLSHIELD +k78_TMEventTypeFireShield = 78, // @ C78_EVENT_FIRESHIELD +k79_TMEventTypeFootprints = 79, // @ C79_EVENT_FOOTPRINTS +k80_TMEventTypeMagicMap_C80 = 80, // @ C80_EVENT_MAGIC_MAP +k81_TMEventTypeMagicMap_C81 = 81, // @ C81_EVENT_MAGIC_MAP +k82_TMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP +k83_TMEventTypeMagicMap_C83 = 83 // @ C83_EVENT_MAGIC_MAP }; class TimelineEvent { @@ -145,11 +145,11 @@ public: class Timeline { DMEngine *_vm; public: - uint16 _eventMaxCount; // @ G0369_ui_EventMaximumCount - TimelineEvent *_events; // @ G0370_ps_Events - uint16 _eventCount; // @ G0372_ui_EventCount - uint16 *_timeline; // @ G0371_pui_Timeline - uint16 _firstUnusedEventIndex; // @ G0373_ui_FirstUnusedEventIndex + uint16 _g369_eventMaxCount; // @ G0369_ui_EventMaximumCount + TimelineEvent *_g370_events; // @ G0370_ps_Events + uint16 _g372_eventCount; // @ G0372_ui_EventCount + uint16 *_g371_timeline; // @ G0371_pui_Timeline + uint16 _g373_firstUnusedEventIndex; // @ G0373_ui_FirstUnusedEventIndex Timeline(DMEngine *vm); ~Timeline(); -- cgit v1.2.3 From 46b9b1100ef315e4a29edda864204a2e74e9f725 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 2 Jul 2016 13:47:19 +0200 Subject: DM: Refactor DungeonMan --- engines/dm/champion.cpp | 26 ++-- engines/dm/dm.cpp | 12 +- engines/dm/dm.h | 4 + engines/dm/dungeonman.cpp | 348 +++++++++++++++++++++++----------------------- engines/dm/dungeonman.h | 65 ++++----- engines/dm/eventman.cpp | 47 +++---- engines/dm/gfx.cpp | 10 +- engines/dm/group.cpp | 8 +- engines/dm/loadsave.cpp | 2 +- engines/dm/objectman.cpp | 2 +- engines/dm/timeline.cpp | 2 +- 11 files changed, 256 insertions(+), 270 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 17ee18124b..5a85434aa3 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -437,7 +437,7 @@ ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { } void ChampionMan::resetDataToStartGame() { - if (!_vm->_dungeonMan->_messages._g298_newGame) { + if (!_vm->_g298_newGame) { warning("MISSING CODE: stuff for resetting for loaded games"); assert(false); } @@ -468,20 +468,20 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { champ->_actionIndex = k255_ChampionActionNone; champ->_enableActionEventIndex = -1; champ->_hideDamageReceivedIndex = -1; - champ->_dir = dunMan._currMap._g308_partyDir; + champ->_dir = dunMan._g308_partyDir; ViewCell AL_0_viewCell = k0_ViewCellFronLeft; - while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._currMap._g308_partyDir) & 3)) != kM1_ChampionNone) + while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3)) != kM1_ChampionNone) AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); - champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._currMap._g308_partyDir) & 3); + champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3); champ->clearAttributes(k0x0400_ChampionAttributeIcon); - champ->_directionMaximumDamageReceived = dunMan._currMap._g308_partyDir; + champ->_directionMaximumDamageReceived = dunMan._g308_partyDir; champ->_food = 1500 + _vm->_rnd->getRandomNumber(256); champ->_water = 1500 + _vm->_rnd->getRandomNumber(256); int16 AL_0_slotIndex_Red; for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) { champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none); } - Thing thing = dunMan.getSquareFirstThing(dunMan._currMap._g306_partyPosX, dunMan._currMap._g307_partyPosY); + Thing thing = dunMan.getSquareFirstThing(dunMan._g306_partyMapX, dunMan._g307_partyMapY); while (thing.getType() != k2_TextstringType) { thing = dunMan.getNextThing(thing); } @@ -557,12 +557,12 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { _vm->_menuMan->drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1)); } - int16 mapX = _vm->_dungeonMan->_currMap._g306_partyPosX; - int16 mapY = _vm->_dungeonMan->_currMap._g307_partyPosY; + int16 mapX = _vm->_dungeonMan->_g306_partyMapX; + int16 mapY = _vm->_dungeonMan->_g307_partyMapY; - uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._g308_partyDir)); - mapX += _vm->_dirIntoStepCountEast[dunMan._currMap._g308_partyDir]; - mapY += _vm->_dirIntoStepCountNorth[dunMan._currMap._g308_partyDir]; + uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._g308_partyDir)); + mapX += _vm->_dirIntoStepCountEast[dunMan._g308_partyDir]; + mapY += _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir]; thing = dunMan.getSquareFirstThing(mapX, mapY); AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1; uint16 slotIndex_Green; @@ -850,11 +850,11 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { } { // block so goto won't skip AL_0_championIconIndex initialization - int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_currMap._g308_partyDir); + int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_g308_partyDir); if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) { dispMan.clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]); - dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_currMap._g308_partyDir) * 19, 0, + dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray); } } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 5c854d5209..a32f059f7b 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -179,9 +179,9 @@ void DMEngine::startGame() { _eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement; warning("MISSING CODE: set primary/secondary keyboard input"); - processNewPartyMap(_dungeonMan->_currMap._g309_currPartyMapIndex); + processNewPartyMap(_dungeonMan->_g309_partyMapIndex); - if (!_dungeonMan->_messages._g298_newGame) { + if (!_g298_newGame) { warning("TODO: loading game"); } else { _displayMan->_g578_useByteBoxCoordinates = false; @@ -233,9 +233,9 @@ Common::Error DMEngine::run() { void DMEngine::gameloop() { warning("DUMMY CODE SETTING PARTY POS AND DIRECTION"); - _dungeonMan->_currMap._g306_partyPosX = 10; - _dungeonMan->_currMap._g307_partyPosY = 4; - _dungeonMan->_currMap._g308_partyDir = kDirNorth; + _dungeonMan->_g306_partyMapX = 10; + _dungeonMan->_g307_partyMapY = 4; + _dungeonMan->_g308_partyDir = kDirNorth; warning("DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero"); @@ -254,7 +254,7 @@ void DMEngine::gameloop() { if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { Box box(0, 224, 0, 126); _displayMan->clearScreenBox(k0_ColorBlack, box, g296_DungeonViewport); // dummy code - _displayMan->drawDungeon(_dungeonMan->_currMap._g308_partyDir, _dungeonMan->_currMap._g306_partyPosX, _dungeonMan->_currMap._g307_partyPosY); + _displayMan->drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); } // DUMMY CODE: next line _menuMan->drawMovementArrows(); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 4505c746c0..f627fcc406 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -168,6 +168,10 @@ public: GroupMan *_groupMan; Timeline *_timeline; + + bool _g298_newGame; // @ G0298_B_NewGame + bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested + bool _g321_stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput bool _g301_gameTimeTicking; // @ G0301_B_GameTimeTicking bool _g524_restartGameAllowed; // @ G0524_B_RestartGameAllowed diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index df61b45149..d75e92b124 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -368,51 +368,51 @@ void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, in posY += _vm->_dirIntoStepCountNorth[dir] * stepsRight; } -DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _g277_maps(NULL), _g276_rawMapData(NULL) { - _dunData._g282_columCount = 0; +DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _g277_dungeonMaps(NULL), _g276_dungeonRawMapData(NULL) { + _g282_dungeonColumCount = 0; - _dunData._g281_mapsFirstColumnIndex = nullptr; - _dunData._g280_columnsCumulativeSquareThingCount = nullptr; - _dunData._g283_squareFirstThings = nullptr; - _dunData._g260_textData = nullptr; - _dunData._g279_mapData = nullptr; + _g281_dungeonMapsFirstColumnIndex = nullptr; + _g280_dungeonColumnsCumulativeSquareThingCount = nullptr; + _g283_squareFirstThings = nullptr; + _g260_dungeonTextData = nullptr; + _g279_dungeonMapData = nullptr; for (int i = 0; i < 16; i++) - _dunData._g284_thingsData[i] = nullptr; + _g284_thingData[i] = nullptr; - _currMap._g308_partyDir = kDirNorth; - _currMap._g306_partyPosX = 0; - _currMap._g307_partyPosY = 0; - _currMap._g309_currPartyMapIndex = 0; - _currMap._g272_index = 0; - _currMap._g273_width = 0; - _currMap._g274_height = 0; + _g308_partyDir = kDirNorth; + _g306_partyMapX = 0; + _g307_partyMapY = 0; + _g309_partyMapIndex = 0; + _g272_currMapIndex = 0; + _g273_currMapWidth = 0; + _g274_currMapHeight = 0; - _currMap._g271_data = nullptr; - _currMap._g269_map = nullptr; - _currMap._g270_colCumulativeSquareFirstThingCount = nullptr; + _g271_currMapData = nullptr; + _g269_currMap = nullptr; + _g270_currMapColCumulativeSquareFirstThingCount = nullptr; - _messages._g298_newGame = true; - _messages._g523_restartGameRequest = false; + _vm->_g298_newGame = true; + _vm->_g523_restartGameRequest = false; _rawDunFileDataSize = 0; _rawDunFileData = nullptr; - _g278_fileHeader._dungeonId = 0; - _g278_fileHeader._ornamentRandomSeed = 0; - _g278_fileHeader._rawMapDataSize = 0; - _g278_fileHeader._mapCount = 0; - _g278_fileHeader._textDataWordCount = 0; - _g278_fileHeader._partyStartDir = kDirNorth; - _g278_fileHeader._partyStartPosX = 0; - _g278_fileHeader._partyStartPosY = 0; - _g278_fileHeader._squareFirstThingCount = 0; + _g278_dungeonFileHeader._dungeonId = 0; + _g278_dungeonFileHeader._ornamentRandomSeed = 0; + _g278_dungeonFileHeader._rawMapDataSize = 0; + _g278_dungeonFileHeader._mapCount = 0; + _g278_dungeonFileHeader._textDataWordCount = 0; + _g278_dungeonFileHeader._partyStartDir = kDirNorth; + _g278_dungeonFileHeader._partyStartPosX = 0; + _g278_dungeonFileHeader._partyStartPosY = 0; + _g278_dungeonFileHeader._squareFirstThingCount = 0; for (int i = 0; i < 16; i++) - _g278_fileHeader._thingCounts[i] = 0; + _g278_dungeonFileHeader._thingCounts[i] = 0; - _g277_maps = nullptr; - _g276_rawMapData = nullptr; + _g277_dungeonMaps = nullptr; + _g276_dungeonRawMapData = nullptr; _g265_currMapInscriptionWallOrnIndex = 0; _g286_isFacingAlcove = false; @@ -425,16 +425,16 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL DungeonMan::~DungeonMan() { delete[] _rawDunFileData; - delete[] _g277_maps; - delete[] _dunData._g281_mapsFirstColumnIndex; - delete[] _dunData._g280_columnsCumulativeSquareThingCount; - delete[] _dunData._g283_squareFirstThings; - delete[] _dunData._g260_textData; - delete[] _dunData._g279_mapData; + delete[] _g277_dungeonMaps; + delete[] _g281_dungeonMapsFirstColumnIndex; + delete[] _g280_dungeonColumnsCumulativeSquareThingCount; + delete[] _g283_squareFirstThings; + delete[] _g260_dungeonTextData; + delete[] _g279_dungeonMapData; for (uint16 i = 0; i < 16; ++i) { - if (_dunData._g284_thingsData[i]) - delete[] _dunData._g284_thingsData[i][0]; - delete[] _dunData._g284_thingsData[i]; + if (_g284_thingData[i]) + delete[] _g284_thingData[i][0]; + delete[] _g284_thingData[i]; } } @@ -551,177 +551,177 @@ const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIR const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY void DungeonMan::loadDungeonFile() { - if (_messages._g298_newGame) + if (_vm->_g298_newGame) decompressDungeonFile(); Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO); - // initialize _g278_fileHeader - _g278_fileHeader._dungeonId = _g278_fileHeader._ornamentRandomSeed = dunDataStream.readUint16BE(); - _g278_fileHeader._rawMapDataSize = dunDataStream.readUint16BE(); - _g278_fileHeader._mapCount = dunDataStream.readByte(); + // initialize _g278_dungeonFileHeader + _g278_dungeonFileHeader._dungeonId = _g278_dungeonFileHeader._ornamentRandomSeed = dunDataStream.readUint16BE(); + _g278_dungeonFileHeader._rawMapDataSize = dunDataStream.readUint16BE(); + _g278_dungeonFileHeader._mapCount = dunDataStream.readByte(); dunDataStream.readByte(); // discard 1 byte - _g278_fileHeader._textDataWordCount = dunDataStream.readUint16BE(); + _g278_dungeonFileHeader._textDataWordCount = dunDataStream.readUint16BE(); uint16 partyPosition = dunDataStream.readUint16BE(); - _g278_fileHeader._partyStartDir = (direction)((partyPosition >> 10) & 3); - _g278_fileHeader._partyStartPosY = (partyPosition >> 5) & 0x1F; - _g278_fileHeader._partyStartPosX = (partyPosition >> 0) & 0x1F; - _g278_fileHeader._squareFirstThingCount = dunDataStream.readUint16BE(); + _g278_dungeonFileHeader._partyStartDir = (direction)((partyPosition >> 10) & 3); + _g278_dungeonFileHeader._partyStartPosY = (partyPosition >> 5) & 0x1F; + _g278_dungeonFileHeader._partyStartPosX = (partyPosition >> 0) & 0x1F; + _g278_dungeonFileHeader._squareFirstThingCount = dunDataStream.readUint16BE(); for (uint16 i = 0; i < k16_ThingTypeTotal; ++i) - _g278_fileHeader._thingCounts[i] = dunDataStream.readUint16BE(); + _g278_dungeonFileHeader._thingCounts[i] = dunDataStream.readUint16BE(); // init party position and mapindex - if (_messages._g298_newGame) { - _currMap._g308_partyDir = _g278_fileHeader._partyStartDir; - _currMap._g306_partyPosX = _g278_fileHeader._partyStartPosX; - _currMap._g307_partyPosY = _g278_fileHeader._partyStartPosY; - _currMap._g309_currPartyMapIndex = 0; + if (_vm->_g298_newGame) { + _g308_partyDir = _g278_dungeonFileHeader._partyStartDir; + _g306_partyMapX = _g278_dungeonFileHeader._partyStartPosX; + _g307_partyMapY = _g278_dungeonFileHeader._partyStartPosY; + _g309_partyMapIndex = 0; } // load map data - delete[] _g277_maps; - _g277_maps = new Map[_g278_fileHeader._mapCount]; - for (uint16 i = 0; i < _g278_fileHeader._mapCount; ++i) { - _g277_maps[i]._rawDunDataOffset = dunDataStream.readUint16BE(); + delete[] _g277_dungeonMaps; + _g277_dungeonMaps = new Map[_g278_dungeonFileHeader._mapCount]; + for (uint16 i = 0; i < _g278_dungeonFileHeader._mapCount; ++i) { + _g277_dungeonMaps[i]._rawDunDataOffset = dunDataStream.readUint16BE(); dunDataStream.readUint32BE(); // discard 4 bytes - _g277_maps[i]._offsetMapX = dunDataStream.readByte(); - _g277_maps[i]._offsetMapY = dunDataStream.readByte(); + _g277_dungeonMaps[i]._offsetMapX = dunDataStream.readByte(); + _g277_dungeonMaps[i]._offsetMapY = dunDataStream.readByte(); uint16 tmp = dunDataStream.readUint16BE(); - _g277_maps[i]._height = tmp >> 11; - _g277_maps[i]._width = (tmp >> 6) & 0x1F; - _g277_maps[i]._level = tmp & 0x1F; // Only used in DMII + _g277_dungeonMaps[i]._height = tmp >> 11; + _g277_dungeonMaps[i]._width = (tmp >> 6) & 0x1F; + _g277_dungeonMaps[i]._level = tmp & 0x1F; // Only used in DMII tmp = dunDataStream.readUint16BE(); - _g277_maps[i]._randFloorOrnCount = tmp >> 12; - _g277_maps[i]._floorOrnCount = (tmp >> 8) & 0xF; - _g277_maps[i]._randWallOrnCount = (tmp >> 4) & 0xF; - _g277_maps[i]._wallOrnCount = tmp & 0xF; + _g277_dungeonMaps[i]._randFloorOrnCount = tmp >> 12; + _g277_dungeonMaps[i]._floorOrnCount = (tmp >> 8) & 0xF; + _g277_dungeonMaps[i]._randWallOrnCount = (tmp >> 4) & 0xF; + _g277_dungeonMaps[i]._wallOrnCount = tmp & 0xF; tmp = dunDataStream.readUint16BE(); - _g277_maps[i]._difficulty = tmp >> 12; - _g277_maps[i]._creatureTypeCount = (tmp >> 4) & 0xF; - _g277_maps[i]._doorOrnCount = tmp & 0xF; + _g277_dungeonMaps[i]._difficulty = tmp >> 12; + _g277_dungeonMaps[i]._creatureTypeCount = (tmp >> 4) & 0xF; + _g277_dungeonMaps[i]._doorOrnCount = tmp & 0xF; tmp = dunDataStream.readUint16BE(); - _g277_maps[i]._doorSet1 = (tmp >> 12) & 0xF; - _g277_maps[i]._doorSet0 = (tmp >> 8) & 0xF; - _g277_maps[i]._wallSet = (WallSet)((tmp >> 4) & 0xF); - _g277_maps[i]._floorSet = (FloorSet)(tmp & 0xF); + _g277_dungeonMaps[i]._doorSet1 = (tmp >> 12) & 0xF; + _g277_dungeonMaps[i]._doorSet0 = (tmp >> 8) & 0xF; + _g277_dungeonMaps[i]._wallSet = (WallSet)((tmp >> 4) & 0xF); + _g277_dungeonMaps[i]._floorSet = (FloorSet)(tmp & 0xF); } // TODO: ??? is this - begin - delete[] _dunData._g281_mapsFirstColumnIndex; - _dunData._g281_mapsFirstColumnIndex = new uint16[_g278_fileHeader._mapCount]; + delete[] _g281_dungeonMapsFirstColumnIndex; + _g281_dungeonMapsFirstColumnIndex = new uint16[_g278_dungeonFileHeader._mapCount]; uint16 columCount = 0; - for (uint16 i = 0; i < _g278_fileHeader._mapCount; ++i) { - _dunData._g281_mapsFirstColumnIndex[i] = columCount; - columCount += _g277_maps[i]._width + 1; + for (uint16 i = 0; i < _g278_dungeonFileHeader._mapCount; ++i) { + _g281_dungeonMapsFirstColumnIndex[i] = columCount; + columCount += _g277_dungeonMaps[i]._width + 1; } - _dunData._g282_columCount = columCount; + _g282_dungeonColumCount = columCount; // TODO: ??? is this - end - uint32 actualSquareFirstThingCount = _g278_fileHeader._squareFirstThingCount; - if (_messages._g298_newGame) // TODO: what purpose does this serve? - _g278_fileHeader._squareFirstThingCount += 300; + uint32 actualSquareFirstThingCount = _g278_dungeonFileHeader._squareFirstThingCount; + if (_vm->_g298_newGame) // TODO: what purpose does this serve? + _g278_dungeonFileHeader._squareFirstThingCount += 300; // TODO: ??? is this - begin - delete[] _dunData._g280_columnsCumulativeSquareThingCount; - _dunData._g280_columnsCumulativeSquareThingCount = new uint16[columCount]; + delete[] _g280_dungeonColumnsCumulativeSquareThingCount; + _g280_dungeonColumnsCumulativeSquareThingCount = new uint16[columCount]; for (uint16 i = 0; i < columCount; ++i) - _dunData._g280_columnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE(); + _g280_dungeonColumnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE(); // TODO: ??? is this - end // TODO: ??? is this - begin - delete[] _dunData._g283_squareFirstThings; - _dunData._g283_squareFirstThings = new Thing[_g278_fileHeader._squareFirstThingCount]; + delete[] _g283_squareFirstThings; + _g283_squareFirstThings = new Thing[_g278_dungeonFileHeader._squareFirstThingCount]; for (uint16 i = 0; i < actualSquareFirstThingCount; ++i) - _dunData._g283_squareFirstThings[i].set(dunDataStream.readUint16BE()); - if (_messages._g298_newGame) + _g283_squareFirstThings[i].set(dunDataStream.readUint16BE()); + if (_vm->_g298_newGame) for (uint16 i = 0; i < 300; ++i) - _dunData._g283_squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none; + _g283_squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none; // TODO: ??? is this - end // load text data - delete[] _dunData._g260_textData; - _dunData._g260_textData = new uint16[_g278_fileHeader._textDataWordCount]; - for (uint16 i = 0; i < _g278_fileHeader._textDataWordCount; ++i) - _dunData._g260_textData[i] = dunDataStream.readUint16BE(); + delete[] _g260_dungeonTextData; + _g260_dungeonTextData = new uint16[_g278_dungeonFileHeader._textDataWordCount]; + for (uint16 i = 0; i < _g278_dungeonFileHeader._textDataWordCount; ++i) + _g260_dungeonTextData[i] = dunDataStream.readUint16BE(); // TODO: ??? what this - if (_messages._g298_newGame) + if (_vm->_g298_newGame) _vm->_timeline->_g369_eventMaxCount = 100; // load things for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) { - uint16 thingCount = _g278_fileHeader._thingCounts[thingType]; - if (_messages._g298_newGame) { - _g278_fileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + g236_AdditionalThingCounts[thingType]); + uint16 thingCount = _g278_dungeonFileHeader._thingCounts[thingType]; + if (_vm->_g298_newGame) { + _g278_dungeonFileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + g236_AdditionalThingCounts[thingType]); } uint16 thingStoreWordCount = g235_ThingDataWordCount[thingType]; if (thingStoreWordCount == 0) continue; - if (_dunData._g284_thingsData[thingType]) { - delete[] _dunData._g284_thingsData[thingType][0]; - delete[] _dunData._g284_thingsData[thingType]; + if (_g284_thingData[thingType]) { + delete[] _g284_thingData[thingType][0]; + delete[] _g284_thingData[thingType]; } - _dunData._g284_thingsData[thingType] = new uint16*[_g278_fileHeader._thingCounts[thingType]]; - _dunData._g284_thingsData[thingType][0] = new uint16[_g278_fileHeader._thingCounts[thingType] * thingStoreWordCount]; - for (uint16 i = 0; i < _g278_fileHeader._thingCounts[thingType]; ++i) - _dunData._g284_thingsData[thingType][i] = _dunData._g284_thingsData[thingType][0] + i * thingStoreWordCount; + _g284_thingData[thingType] = new uint16*[_g278_dungeonFileHeader._thingCounts[thingType]]; + _g284_thingData[thingType][0] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount]; + for (uint16 i = 0; i < _g278_dungeonFileHeader._thingCounts[thingType]; ++i) + _g284_thingData[thingType][i] = _g284_thingData[thingType][0] + i * thingStoreWordCount; if (thingType == k4_GroupThingType) { for (uint16 i = 0; i < thingCount; ++i) for (uint16 j = 0; j < thingStoreWordCount; ++j) { if (j == 2 || j == 3) - _dunData._g284_thingsData[thingType][i][j] = dunDataStream.readByte(); + _g284_thingData[thingType][i][j] = dunDataStream.readByte(); else - _dunData._g284_thingsData[thingType][i][j] = dunDataStream.readUint16BE(); + _g284_thingData[thingType][i][j] = dunDataStream.readUint16BE(); } } else if (thingType == k14_ProjectileThingType) { for (uint16 i = 0; i < thingCount; ++i) { - _dunData._g284_thingsData[thingType][i][0] = dunDataStream.readUint16BE(); - _dunData._g284_thingsData[thingType][i][1] = dunDataStream.readUint16BE(); - _dunData._g284_thingsData[thingType][i][2] = dunDataStream.readByte(); - _dunData._g284_thingsData[thingType][i][3] = dunDataStream.readByte(); - _dunData._g284_thingsData[thingType][i][4] = dunDataStream.readUint16BE(); + _g284_thingData[thingType][i][0] = dunDataStream.readUint16BE(); + _g284_thingData[thingType][i][1] = dunDataStream.readUint16BE(); + _g284_thingData[thingType][i][2] = dunDataStream.readByte(); + _g284_thingData[thingType][i][3] = dunDataStream.readByte(); + _g284_thingData[thingType][i][4] = dunDataStream.readUint16BE(); } } else { for (uint16 i = 0; i < thingCount; ++i) { for (uint16 j = 0; j < thingStoreWordCount; ++j) - _dunData._g284_thingsData[thingType][i][j] = dunDataStream.readUint16BE(); + _g284_thingData[thingType][i][j] = dunDataStream.readUint16BE(); } } - if (_messages._g298_newGame) { + if (_vm->_g298_newGame) { if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType) - _vm->_timeline->_g369_eventMaxCount += _g278_fileHeader._thingCounts[thingType]; + _vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType]; for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) { - _dunData._g284_thingsData[thingType][thingCount + i][0] = Thing::_none.toUint16(); + _g284_thingData[thingType][thingCount + i][0] = Thing::_none.toUint16(); } } } // load map data - if (!_messages._g523_restartGameRequest) - _g276_rawMapData = _rawDunFileData + dunDataStream.pos(); + if (!_vm->_g523_restartGameRequest) + _g276_dungeonRawMapData = _rawDunFileData + dunDataStream.pos(); - if (!_messages._g523_restartGameRequest) { - uint8 mapCount = _g278_fileHeader._mapCount; - delete[] _dunData._g279_mapData; - _dunData._g279_mapData = new byte**[_dunData._g282_columCount + mapCount]; - byte **colFirstSquares = (byte**)_dunData._g279_mapData + mapCount; + if (!_vm->_g523_restartGameRequest) { + uint8 mapCount = _g278_dungeonFileHeader._mapCount; + delete[] _g279_dungeonMapData; + _g279_dungeonMapData = new byte**[_g282_dungeonColumCount + mapCount]; + byte **colFirstSquares = (byte**)_g279_dungeonMapData + mapCount; for (uint8 i = 0; i < mapCount; ++i) { - _dunData._g279_mapData[i] = colFirstSquares; - byte *square = _g276_rawMapData + _g277_maps[i]._rawDunDataOffset; + _g279_dungeonMapData[i] = colFirstSquares; + byte *square = _g276_dungeonRawMapData + _g277_dungeonMaps[i]._rawDunDataOffset; *colFirstSquares++ = square; - for (uint16 w = 1; w <= _g277_maps[i]._width; ++w) { - square += _g277_maps[i]._height + 1; + for (uint16 w = 1; w <= _g277_dungeonMaps[i]._width; ++w) { + square += _g277_dungeonMaps[i]._height + 1; *colFirstSquares++ = square; } } @@ -729,59 +729,59 @@ void DungeonMan::loadDungeonFile() { } void DungeonMan::setCurrentMap(uint16 mapIndex) { - _currMap._g272_index = mapIndex; - _currMap._g271_data = _dunData._g279_mapData[mapIndex]; - _currMap._g269_map = _g277_maps + mapIndex; - _currMap._g273_width = _g277_maps[mapIndex]._width + 1; - _currMap._g274_height = _g277_maps[mapIndex]._height + 1; - _currMap._g270_colCumulativeSquareFirstThingCount - = &_dunData._g280_columnsCumulativeSquareThingCount[_dunData._g281_mapsFirstColumnIndex[mapIndex]]; + _g272_currMapIndex = mapIndex; + _g271_currMapData = _g279_dungeonMapData[mapIndex]; + _g269_currMap = _g277_dungeonMaps + mapIndex; + _g273_currMapWidth = _g277_dungeonMaps[mapIndex]._width + 1; + _g274_currMapHeight = _g277_dungeonMaps[mapIndex]._height + 1; + _g270_currMapColCumulativeSquareFirstThingCount + = &_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]]; } void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) { setCurrentMap(mapIndex); - byte *metaMapData = _currMap._g271_data[_currMap._g273_width - 1] + _currMap._g274_height; + byte *metaMapData = _g271_currMapData[_g273_currMapWidth - 1] + _g274_currMapHeight; _vm->_displayMan->_g264_currMapAllowedCreatureTypes = metaMapData; - metaMapData += _currMap._g269_map->_creatureTypeCount; - memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _currMap._g269_map->_wallOrnCount); + metaMapData += _g269_currMap->_creatureTypeCount; + memcpy(_vm->_displayMan->_g261_currMapWallOrnIndices, metaMapData, _g269_currMap->_wallOrnCount); - metaMapData += _currMap._g269_map->_wallOrnCount; - memcpy(_vm->_displayMan->_g262_currMapFloorOrnIndices, metaMapData, _currMap._g269_map->_floorOrnCount); + metaMapData += _g269_currMap->_wallOrnCount; + memcpy(_vm->_displayMan->_g262_currMapFloorOrnIndices, metaMapData, _g269_currMap->_floorOrnCount); - metaMapData += _currMap._g269_map->_wallOrnCount; - memcpy(_vm->_displayMan->_g263_currMapDoorOrnIndices, metaMapData, _currMap._g269_map->_doorOrnCount); + metaMapData += _g269_currMap->_wallOrnCount; + memcpy(_vm->_displayMan->_g263_currMapDoorOrnIndices, metaMapData, _g269_currMap->_doorOrnCount); - _g265_currMapInscriptionWallOrnIndex = _currMap._g269_map->_wallOrnCount; + _g265_currMapInscriptionWallOrnIndex = _g269_currMap->_wallOrnCount; _vm->_displayMan->_g261_currMapWallOrnIndices[_g265_currMapInscriptionWallOrnIndex] = k0_WallOrnInscription; } Square DungeonMan::getSquare(int16 mapX, int16 mapY) { - bool isInXBounds = (mapX >= 0) && (mapX < _currMap._g273_width); - bool isInYBounds = (mapY >= 0) && (mapY < _currMap._g274_height); + bool isInXBounds = (mapX >= 0) && (mapX < _g273_currMapWidth); + bool isInYBounds = (mapY >= 0) && (mapY < _g274_currMapHeight); if (isInXBounds && isInYBounds) - return Square(_currMap._g271_data[mapX][mapY]); + return Square(_g271_currMapData[mapX][mapY]); Square tmpSquare; if (isInYBounds) { - tmpSquare.set(_currMap._g271_data[0][mapY]); + tmpSquare.set(_g271_currMapData[0][mapY]); if (mapX == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) return Square(k0_WallElemType).set(k0x0004_WallEastRandOrnAllowed); - tmpSquare.set(_currMap._g271_data[_currMap._g273_width - 1][mapY]); - if (mapX == _currMap._g273_width && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) + tmpSquare.set(_g271_currMapData[_g273_currMapWidth - 1][mapY]); + if (mapX == _g273_currMapWidth && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) return Square(k0_WallElemType).set(k0x0001_WallWestRandOrnAllowed); } else if (isInXBounds) { - tmpSquare.set(_currMap._g271_data[mapX][0]); + tmpSquare.set(_g271_currMapData[mapX][0]); if (mapY == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) return Square(k0_WallElemType).set(k0x0002_WallSouthRandOrnAllowed); - tmpSquare.set(_currMap._g271_data[mapX][_currMap._g274_height - 1]); - if (mapY == _currMap._g274_height && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) + tmpSquare.set(_g271_currMapData[mapX][_g274_currMapHeight - 1]); + if (mapY == _g274_currMapHeight && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) return Square((k0_WallElemType << 5) | k0x0008_WallNorthRandOrnAllowed); } @@ -794,12 +794,12 @@ Square DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRi } int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) { - if (mapX < 0 || mapX >= _currMap._g273_width || mapY < 0 || mapY >= _currMap._g274_height || !Square(_currMap._g271_data[mapX][mapY]).get(k0x0010_ThingListPresent)) + if (mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight || !Square(_g271_currMapData[mapX][mapY]).get(k0x0010_ThingListPresent)) return -1; int16 y = 0; - uint16 index = _currMap._g270_colCumulativeSquareFirstThingCount[mapX]; - byte* square = _currMap._g271_data[mapX]; + uint16 index = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; + byte* square = _g271_currMapData[mapX]; while (y++ != mapY) if (Square(*square++).get(k0x0010_ThingListPresent)) index++; @@ -811,7 +811,7 @@ Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) { int16 index = getSquareFirstThingIndex(mapX, mapY); if (index == -1) return Thing::_endOfList; - return _dunData._g283_squareFirstThings[index]; + return _g283_squareFirstThings[index]; } @@ -880,7 +880,7 @@ T0172010_ClosedFakeWall: } thing = getNextThing(thing); } - if (squareIsFakeWall && (_currMap._g306_partyPosX != mapX) && (_currMap._g307_partyPosY != mapY)) { + if (squareIsFakeWall && (_g306_partyMapX != mapX) && (_g307_partyMapY != mapY)) { aspectArray[k1_FirstGroupOrObjectAspect] = Thing::_endOfList.toUint16(); return; } @@ -906,7 +906,7 @@ T0172010_ClosedFakeWall: square = Square(footPrintsAllowed ? 8 : 0); // intentional fallthrough case k1_CorridorElemType: - aspectArray[k4_FloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(k0x0008_CorridorRandOrnAllowed), _currMap._g269_map->_randFloorOrnCount, mapX, mapY, 30); + aspectArray[k4_FloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(k0x0008_CorridorRandOrnAllowed), _g269_currMap->_randFloorOrnCount, mapX, mapY, 30); T0172029_Teleporter: footPrintsAllowed = true; T0172030_Pit: @@ -949,7 +949,7 @@ T0172049_Footprints: void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, int16 mapX, int16 mapY, bool isFakeWall) { - int16 ornCount = _currMap._g269_map->_randWallOrnCount; + int16 ornCount = _g269_currMap->_randWallOrnCount; turnDirRight(dir); aspectArray[k2_RightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); @@ -958,7 +958,7 @@ void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowe turnDirRight(dir); aspectArray[k4_LeftWallOrnOrdAspect] = getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - if (isFakeWall || mapX < 0 || mapX >= _currMap._g273_width || mapY < 0 || mapY >= _currMap._g274_height) { + if (isFakeWall || mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight) { for (uint16 i = k2_RightWallOrnOrdAspect; i <= k4_LeftWallOrnOrdAspect; ++i) { if (isWallOrnAnAlcove(_vm->ordinalToIndex(aspectArray[i]))) aspectArray[i] = 0; @@ -968,8 +968,8 @@ void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowe int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) { int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1) - + (3000 + (_currMap._g272_index << 6) + _currMap._g273_width + _currMap._g274_height) * 11 - + _g278_fileHeader._ornamentRandomSeed) >> 2) % modulo; + + (3000 + (_g272_currMapIndex << 6) + _g273_currMapWidth + _g274_currMapHeight) * 11 + + _g278_dungeonFileHeader._ornamentRandomSeed) >> 2) % modulo; if (allowed && index < count) return _vm->indexToOrdinal(index); return 0; @@ -985,7 +985,7 @@ bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) { } uint16 *DungeonMan::getThingData(Thing thing) { - return _dunData._g284_thingsData[thing.getType()][thing.getIndex()]; + return _g284_thingData[thing.getType()][thing.getIndex()]; } uint16* DungeonMan::getSquareFirstThingData(int16 mapX, int16 mapY) { @@ -1099,7 +1099,7 @@ char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { char sepChar; - TextString textString(_dunData._g284_thingsData[k2_TextstringType][thing.getIndex()]); + TextString textString(_g284_thingData[k2_TextstringType][thing.getIndex()]); if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) { type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible); if (type == k1_TextTypeMessage) { @@ -1112,7 +1112,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { } uint16 codeCounter = 0; int16 escChar = 0; - uint16 *codeWord = _dunData._g260_textData + textString.getWordOffset(); + uint16 *codeWord = _g260_dungeonTextData + textString.getWordOffset(); uint16 code = 0, codes = 0; char *escReplString = nullptr; for (;;) { /*infinite loop*/ @@ -1260,27 +1260,27 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map *rawObjPtr = Thing::_endOfList.toUint16(); if (mapX >= 0) { - Square *squarePtr = (Square*)&_currMap._g271_data[mapX][mapY]; + Square *squarePtr = (Square*)&_g271_currMapData[mapX][mapY]; if (squarePtr->get(k0x0010_ThingListPresent)) { thingInList = getSquareFirstThing(mapX, mapY); } else { squarePtr->set(k0x0010_ThingListPresent); - uint16 *cumulativeCount = &_currMap._g270_colCumulativeSquareFirstThingCount[mapX + 1]; - uint16 column = _dunData._g282_columCount - (_dunData._g281_mapsFirstColumnIndex[_currMap._g272_index] + mapX) - 1; + uint16 *cumulativeCount = &_g270_currMapColCumulativeSquareFirstThingCount[mapX + 1]; + uint16 column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1; while (column--) { (*cumulativeCount++)++; } uint16 mapYStep = 0; squarePtr -= mapY; - uint16 squareFirstThingIndex = _currMap._g270_colCumulativeSquareFirstThingCount[mapX]; + uint16 squareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; while (mapYStep++ != mapY) { if (squarePtr->get(k0x0010_ThingListPresent)) { squareFirstThingIndex++; } squarePtr++; } - Thing* thingPtr = &_dunData._g283_squareFirstThings[squareFirstThingIndex]; - memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_g278_fileHeader._squareFirstThingCount - squareFirstThingIndex - 1)); + Thing* thingPtr = &_g283_squareFirstThings[squareFirstThingIndex]; + memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_g278_dungeonFileHeader._squareFirstThingCount - squareFirstThingIndex - 1)); *thingPtr = thingToLink; return; } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index d6ebdc09e9..628422c22d 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -556,7 +556,7 @@ public: SquareType getType() { return (SquareType)(_data >> 5); } // @ M34_SQUARE_TYPE void setType(SquareType type) { _data = (_data & 0x1F) | type << 5; } byte toByte() { return _data; } // I don't like 'em casts -}; +}; // wrapper for bytes which are used as squares struct DungeonFileHeader { uint16 _dungeonId; // @ G0526_ui_DungeonID @@ -592,39 +592,7 @@ struct Map { uint8 _doorSet0, _doorSet1; }; // @ MAP -struct DungeonData { - // I have no idea the heck is this - uint16 *_g281_mapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex - uint16 _g282_columCount; // @ G0282_ui_DungeonColumnCount - - // I have no idea the heck is this - uint16 *_g280_columnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount - Thing *_g283_squareFirstThings; // @ G0283_pT_SquareFirstThings - uint16 *_g260_textData; // @ G0260_pui_DungeonTextData - - uint16 **_g284_thingsData[16]; // @ G0284_apuc_ThingData - - byte ***_g279_mapData; // @ G0279_pppuc_DungeonMapData -}; // @ AGGREGATE -struct CurrMapData { - direction _g308_partyDir; // @ G0308_i_PartyDirection - int16 _g306_partyPosX; // @ G0306_i_PartyMapX - int16 _g307_partyPosY; // @ G0307_i_PartyMapY - uint8 _g309_currPartyMapIndex; // @ G0309_i_PartyMapIndex - - uint8 _g272_index; // @ G0272_i_CurrentMapIndex - byte **_g271_data; // @ G0271_ppuc_CurrentMapData - Map *_g269_map; // @ G0269_ps_CurrentMap - uint16 _g273_width; // @ G0273_i_CurrentMapWidth - uint16 _g274_height; // @ G0274_i_CurrentMapHeight - uint16 *_g270_colCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount -}; // @ AGGREGATE - -struct Messages { - bool _g298_newGame; // @ G0298_B_NewGame - bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested -}; // @ AGGREGATE class DungeonMan { DMEngine *_vm; @@ -674,14 +642,33 @@ public: uint32 _rawDunFileDataSize; // @ probably NONE byte *_rawDunFileData; // @ ??? - DungeonFileHeader _g278_fileHeader; // @ G0278_ps_DungeonHeader + DungeonFileHeader _g278_dungeonFileHeader; // @ G0278_ps_DungeonHeader - DungeonData _dunData; // @ NONE - CurrMapData _currMap; // @ NONE - Map *_g277_maps; // @ G0277_ps_DungeonMaps + + uint16 *_g281_dungeonMapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex + uint16 _g282_dungeonColumCount; // @ G0282_ui_DungeonColumnCount + uint16 *_g280_dungeonColumnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount + Thing *_g283_squareFirstThings; // @ G0283_pT_SquareFirstThings + uint16 *_g260_dungeonTextData; // @ G0260_pui_DungeonTextData + uint16 **_g284_thingData[16]; // @ G0284_apuc_ThingData + byte ***_g279_dungeonMapData; // @ G0279_pppuc_DungeonMapData + + + direction _g308_partyDir; // @ G0308_i_PartyDirection + int16 _g306_partyMapX; // @ G0306_i_PartyMapX + int16 _g307_partyMapY; // @ G0307_i_PartyMapY + uint8 _g309_partyMapIndex; // @ G0309_i_PartyMapIndex + uint8 _g272_currMapIndex; // @ G0272_i_CurrentMapIndex + byte **_g271_currMapData; // @ G0271_ppuc_CurrentMapData + Map *_g269_currMap; // @ G0269_ps_CurrentMap + uint16 _g273_currMapWidth; // @ G0273_i_CurrentMapWidth + uint16 _g274_currMapHeight; // @ G0274_i_CurrentMapHeight + uint16 *_g270_currMapColCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount + + + Map *_g277_dungeonMaps; // @ G0277_ps_DungeonMaps // does not have to be freed - byte *_g276_rawMapData; // @ G0276_puc_DungeonRawMapData - Messages _messages; // @ NONE; + byte *_g276_dungeonRawMapData; // @ G0276_puc_DungeonRawMapData int16 _g265_currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex Box _g291_dungeonViewClickableBoxes[6]; // G0291_aauc_DungeonViewClickableBoxes diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 6d59727e2b..2e6f473eea 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -305,7 +305,6 @@ void EventManager::setMousePos(Common::Point pos) { void EventManager::processInput() { DungeonMan &dungeonMan = *_vm->_dungeonMan; - CurrMapData &currMap = dungeonMan._currMap; Common::Event event; while (_vm->_system->getEventManager()->pollEvent(event)) { @@ -317,22 +316,22 @@ void EventManager::processInput() { switch (event.kbd.keycode) { case Common::KEYCODE_w: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; case Common::KEYCODE_a: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, -1, currMap._g306_partyPosX, currMap._g307_partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; case Common::KEYCODE_s: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, -1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; case Common::KEYCODE_d: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, 1, currMap._g306_partyPosX, currMap._g307_partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; case Common::KEYCODE_q: - turnDirLeft(currMap._g308_partyDir); + turnDirLeft(dungeonMan._g308_partyDir); break; case Common::KEYCODE_e: - turnDirRight(currMap._g308_partyDir); + turnDirRight(dungeonMan._g308_partyDir); break; case Common::KEYCODE_UP: if (_dummyMapIndex < 13) @@ -440,7 +439,7 @@ void EventManager::commandTurnParty(CommandType cmdType) { // MISSING CODE: process sensors // DUMMY CODE: should call F0284_CHAMPION_SetPartyDirection instead - direction &partyDir = _vm->_dungeonMan->_currMap._g308_partyDir; + direction &partyDir = _vm->_dungeonMan->_g308_partyDir; (cmdType == k1_CommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir); // MISSING CODE: process sensors @@ -453,20 +452,19 @@ void EventManager::commandMoveParty(CommandType cmdType) { // DUMMY CODE: DungeonMan &dungeonMan = *_vm->_dungeonMan; - CurrMapData &currMap = dungeonMan._currMap; switch (cmdType) { case k3_CommandMoveForward: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; case k6_CommandMoveLeft: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, -1, currMap._g306_partyPosX, currMap._g307_partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; case k5_CommandMoveBackward: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, -1, 0, currMap._g306_partyPosX, currMap._g307_partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; case k4_CommandMoveRight: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap._g308_partyDir, 0, 1, currMap._g306_partyPosX, currMap._g307_partyPosY); + dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; default: break; @@ -496,7 +494,7 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) { } cm._g411_leaderIndex = champIndex; Champion *champion = &cm._champions[cm._g411_leaderIndex]; - champion->_dir = _vm->_dungeonMan->_currMap._g308_partyDir; + champion->_dir = _vm->_dungeonMan->_g308_partyDir; cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._414_leaderHandObject); if (_vm->indexToOrdinal(champIndex) != cm._g299_candidateChampionOrdinal) { champion->setAttributeFlag(k0x0400_ChampionAttributeIcon, true); @@ -507,26 +505,24 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) { void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() { DungeonMan &dunMan = *_vm->_dungeonMan; - CurrMapData &currMap = dunMan._currMap; - int16 mapX = currMap._g306_partyPosX + _vm->_dirIntoStepCountEast[currMap._g308_partyDir]; - int16 mapY = currMap._g307_partyPosY + _vm->_dirIntoStepCountNorth[currMap._g308_partyDir]; - if ((mapX >= 0) && (mapX < currMap._g273_width) && (mapY >= 0) && (mapY < currMap._g274_height)) { - _vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(currMap._g308_partyDir)); + int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir]; + int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir]; + if ((mapX >= 0) && (mapX < dunMan._g273_currMapWidth) && (mapY >= 0) && (mapY < dunMan._g274_currMapHeight)) { + _vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(dunMan._g308_partyDir)); } } void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY) { DungeonMan &dunMan = *_vm->_dungeonMan; ChampionMan &champMan = *_vm->_championMan; - CurrMapData &currMap = _vm->_dungeonMan->_currMap; if (dunMan._g285_squareAheadElement == k17_ElementTypeDoorFront) { if (champMan._g411_leaderIndex == kM1_ChampionNone) return; if (champMan._g415_leaderEmptyHanded) { - int16 mapX = currMap._g306_partyPosX + _vm->_dirIntoStepCountEast[currMap._g308_partyDir]; - int16 mapY = currMap._g307_partyPosY + _vm->_dirIntoStepCountNorth[currMap._g308_partyDir]; + int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir]; + int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir]; if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() && dunMan._g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { @@ -601,7 +597,6 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane ChampionMan &champMan = *_vm->_championMan; InventoryMan &invMan = *_vm->_inventoryMan; DisplayMan &dispMan = *_vm->_displayMan; - CurrMapData &currMap = _vm->_dungeonMan->_currMap; DungeonMan &dunMan = *_vm->_dungeonMan; uint16 championIndex = champMan._g305_partyChampionCount - 1; @@ -620,15 +615,15 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane box._x2 = box._x1 + 66 + 1; dispMan._g578_useByteBoxCoordinates = false; dispMan.clearScreenBox(k0_ColorBlack, box); - dispMan.clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._g308_partyDir) * 2]); + dispMan.clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2]); warning("F0457_START_DrawEnabledMenus_CPSF"); warning("F0078_MOUSE_ShowPointer"); return; } champMan._g299_candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone); - int16 mapX = currMap._g306_partyPosX + _vm->_dirIntoStepCountEast[currMap._g308_partyDir]; - int16 mapY = currMap._g307_partyPosY + _vm->_dirIntoStepCountNorth[currMap._g308_partyDir]; + int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir]; + int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir]; for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) { Thing thing = champ->getSlot((ChampionSlot)slotIndex); diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 62bf070579..516c1d65bb 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1155,7 +1155,7 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); memcpy(_g74_tmpBitmap, _wallSetBitMaps[kG705_DoorFrameLeft_D3L], 32 * 44); warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally"); - if (((Door*)_vm->_dungeonMan->_dunData._g284_thingsData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { + if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton"); } warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor"); @@ -1519,13 +1519,13 @@ void DisplayMan::loadWallSet(WallSet set) { void DisplayMan::loadCurrentMapGraphics() { - loadFloorSet(_vm->_dungeonMan->_currMap._g269_map->_floorSet); - loadWallSet(_vm->_dungeonMan->_currMap._g269_map->_wallSet); + loadFloorSet(_vm->_dungeonMan->_g269_currMap->_floorSet); + loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet); // the original loads some flipped walls here, I moved it to loadWallSet { - int16 val = _vm->_dungeonMan->_currMap._g269_map->_wallSet * k18_StairsGraphicCount + k90_FirstStairs; + int16 val = _vm->_dungeonMan->_g269_currMap->_wallSet * k18_StairsGraphicCount + k90_FirstStairs; _g675_stairsNativeBitmapIndex_Up_Front_D3L = val++; _g676_stairsNativeBitmapIndex_Up_Front_D3C = val++; _g677_stairsNativeBitmapIndex_Up_Front_D2L = val++; @@ -1556,7 +1556,7 @@ void DisplayMan::loadCurrentMapGraphics() { uint16 alcoveCount = 0; uint16 fountainCount = 0; - Map &currMap = *_vm->_dungeonMan->_currMap._g269_map; + Map &currMap = *_vm->_dungeonMan->_g269_currMap; _g266_currMapViAltarIndex = -1; diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 2891da3ec5..2cc2646a1a 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -43,7 +43,7 @@ GroupMan::~GroupMan() { } void GroupMan::initActiveGroups() { - if (_vm->_dungeonMan->_messages._g298_newGame) + if (_vm->_g298_newGame) _g376_maxActiveGroupCount = 60; if (_g375_activeGroups) delete[] _g375_activeGroups; @@ -55,7 +55,7 @@ void GroupMan::initActiveGroups() { uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) { byte cells; cells = group->_cells; - if (mapIndex == _vm->_dungeonMan->_currMap._g309_currPartyMapIndex) + if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) cells = _g375_activeGroups[cells]._cells; return cells; } @@ -63,14 +63,14 @@ uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) { byte gGroupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_GroupDirections uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) { - if (mapIndex == _vm->_dungeonMan->_currMap._g309_currPartyMapIndex) + if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) return _g375_activeGroups[group->getActiveGroupIndex()]._directions; return gGroupDirections[group->getDir()]; } int16 GroupMan::getCreatureOrdinalInCell(Group* group, uint16 cell) { - uint16 currMapIndex = _vm->_dungeonMan->_currMap._g272_index; + uint16 currMapIndex = _vm->_dungeonMan->_g272_currMapIndex; byte groupCells = getGroupCells(group, currMapIndex); if (groupCells == k255_CreatureTypeSingleCenteredCreature) return _vm->indexToOrdinal(0); diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index aabe88f032..a0cd569c37 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -39,7 +39,7 @@ LoadsaveMan::LoadsaveMan(DMEngine *vm) : _vm(vm) {} LoadgameResponse LoadsaveMan::loadgame() { - bool newGame = _vm->_dungeonMan->_messages._g298_newGame; + bool newGame = _vm->_g298_newGame; ChampionMan &cm = *_vm->_championMan; if (newGame) { diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 9c3b2284bc..499ae9d697 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -145,7 +145,7 @@ IconIndice ObjectMan::getIconIndex(Thing thing) { uint16 *rawType = _vm->_dungeonMan->getThingData(thing); switch (iconIndex) { case k0_IconIndiceJunkCompassNorth: - iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_currMap._g308_partyDir); + iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_g308_partyDir); break; case k4_IconIndiceWeaponTorchUnlit: { Weapon weapon(rawType); diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index d9e7806b35..9803032a5c 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -44,7 +44,7 @@ Timeline::~Timeline() { void Timeline::initTimeline() { _g370_events = new TimelineEvent[_g369_eventMaxCount]; _g371_timeline = new uint16[_g369_eventMaxCount]; - if (_vm->_dungeonMan->_messages._g298_newGame) { + if (_vm->_g298_newGame) { for (int16 i = 0; i < _g369_eventMaxCount; ++i) _g370_events->_type = k0_TMEventTypeNone; _g372_eventCount = 0; -- cgit v1.2.3 From 683230207ccf7c0b3659b082a1dd68a621788621 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 2 Jul 2016 17:46:05 +0200 Subject: DM: Refactor DisplayMan::_walsetBitmaps --- engines/dm/TODOs/todo.txt | 3 + engines/dm/dm.cpp | 6 +- engines/dm/dm.h | 3 +- engines/dm/dungeonman.h | 3 +- engines/dm/gfx.cpp | 291 +++++++++++++++++++++++++++++----------------- engines/dm/gfx.h | 49 +++++++- 6 files changed, 241 insertions(+), 114 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index ca4bc3fbb1..72d6057d35 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -22,4 +22,7 @@ Todo: Missing functions: Add missing F0163_DUNGEON_LinkThingToList in MovesensMan::sensorIsTriggeredByClickOnWall (I don't think it's safe yet) + +Refactoring + Add constructor to CreatureInfo \ No newline at end of file diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index a32f059f7b..bc4d1c9c3e 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -143,9 +143,10 @@ DMEngine::~DMEngine() { void DMEngine::initializeGame() { _displayMan->loadGraphics(); + _displayMan->initializeGraphicData(); // DUMMY CODE: next line _displayMan->loadPalette(g19_PalCredits); - + _eventMan->initMouse(); while (_loadsaveMan->loadgame() != k1_LoadgameSuccess) { @@ -156,6 +157,9 @@ void DMEngine::initializeGame() { _displayMan->loadWallSet(k0_WallSetStone); _objectMan->loadObjectNames(); + // There was some memory wizardy for the Amiga platform, I skipped that part + _displayMan->f461_allocateFlippedWallBitmaps(); + startGame(); warning("MISSING CODE: F0267_MOVE_GetMoveResult_CPSCE (if newGame)"); _eventMan->showMouse(true); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index f627fcc406..361ff9e423 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -133,7 +133,8 @@ public: enum { // engine debug channels - kDMDebugExample = 1 << 0 + kDMDebugExample = 1 << 0, + kDMDebugUselessCode = 1 << 1 }; class DMEngine : public Engine { diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 628422c22d..3b752bdebc 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -181,7 +181,8 @@ enum SquareAspectIndice { -struct CreatureInfo { +class CreatureInfo { +public: byte _creatureAspectIndex; byte _attackSoundOrdinal; uint16 _attributes; /* Bits 15-14 Unreferenced */ diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 516c1d65bb..95c5cf25e8 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -198,39 +198,6 @@ Frame g163_FrameWalls[12] = { // @ G0163_as_Graphic558_Frame_Walls }; /* D0R */ -// these denote the corresponding global in DisplayMan::_wallsetbitmaps -enum WallSetIndices { - kG709_DoorFrameFront = 0, // @ G0709_puc_Bitmap_WallSet_DoorFrameFront - kG708_DoorFrameLeft_D1C = 1, // @ G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C - kG707_DoorFameLeft_D2C = 2, // @ G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C - kG706_DoorFrameLeft_D3C = 3, // @ G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C - kG705_DoorFrameLeft_D3L = 4, // @ G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L - kG704_DoorFrameTop_D1LCR = 5, // @ G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR - kG703_DoorFrameTop_D2LCR = 6, // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR - kG702_Wall_D0R = 7, // @ G0702_puc_Bitmap_WallSet_Wall_D0R - kG701_Wall_D0L = 8, // @ G0701_puc_Bitmap_WallSet_Wall_D0L - kG700_Wall_D1LCR = 9, // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR - kG699_Wall_D2LCR = 10, // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR - kG698_Wall_D3LCR = 11, // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR - kG697_Wall_D3L2 = 12, // @ G0697_puc_Bitmap_WallSet_Wall_D3L2 - - kG696_Wall_D3R2 = 13, // @ G0696_puc_Bitmap_WallSet_Wall_D3R2 - kG710_DoorFrameRight_D1C = 14, // @ G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C - - kG94_Wall_D0R_Flipped = 15, // @ G0094_puc_Bitmap_WallD0R_Flipped - kG93_Wall_D0L_Flipped = 16, // @ G0093_puc_Bitmap_WallD0L_Flipped - kG92_Wall_D1LCR_Flipped = 17, // @ G0092_puc_Bitmap_WallD1LCR_Flipped - kG91_Wall_D2LCR_Flipped = 18, // @ G0091_puc_Bitmap_WallD2LCR_Flipped - kG90_Wall_D3LCR_Flipped = 19, // @ G0090_puc_Bitmap_WallD3LCR_Flipped - - kG99_Wall_D0R_Native = 20, // @ G0099_puc_Bitmap_WallD0R_Native - kG98_Wall_D0L_Native = 21, // @ G0098_puc_Bitmap_WallD0L_Native - kG97_Wall_D1LCR_Native = 22, // @ G0097_puc_Bitmap_WallD1LCR_Native - kG96_Wall_D2LCR_Native = 23, // @ G0096_puc_Bitmap_WallD2LCR_Native - kG95_Wall_D3LCR_Native = 24 // @ G0095_puc_Bitmap_WallD3LCR_Native -}; - - byte g196_DoorOrnCoordIndices[12] = { // @ G0196_auc_Graphic558_DoorOrnamentCoordinateSetIndices 0, /* Door Ornament #00 Square Grid */ 1, /* Door Ornament #01 Iron Bars */ @@ -634,8 +601,8 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _packedBitmaps = nullptr; _bitmaps = nullptr; _g74_tmpBitmap = nullptr; - _g84_floorBitmap = nullptr; - _g85_ceilingBitmap = nullptr; + _g84_bitmapFloor = nullptr; + _g85_bitmapCeiling = nullptr; _g264_currMapAllowedCreatureTypes = nullptr; _g639_derivedBitmapByteCount = nullptr; _g638_derivedBitmaps = nullptr; @@ -644,8 +611,6 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _g289_championPortraitOrdinal = 0; _g266_currMapViAltarIndex = 0; - for (int i = 0; i < 25; i++) - _wallSetBitMaps[i] = nullptr; for (int i = 0; i < 4; i++) _g75_palChangesProjectile[i] = nullptr; @@ -676,6 +641,39 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _g290_inscriptionThing = Thing::_none; _g578_useByteBoxCoordinates = false; + + _g85_bitmapCeiling = nullptr; + _g84_bitmapFloor = nullptr; + _g697_bitmapWallSet_Wall_D3L2 = nullptr; + _g696_bitmapWallSet_Wall_D3R2 = nullptr; + _g698_bitmapWallSet_Wall_D3LCR = nullptr; + _g699_bitmapWallSet_Wall_D2LCR = nullptr; + _g700_bitmapWallSet_Wall_D1LCR = nullptr; + _g701_bitmapWallSet_Wall_D0L = nullptr; + _g702_bitmapWallSet_Wall_D0R = nullptr; + _g703_bitmapWallSet_DoorFrameTop_D2LCR = nullptr; + _g704_bitmapWallSet_DoorFrameTop_D1LCR = nullptr; + _g705_bitmapWallSet_DoorFrameLeft_D3L = nullptr; + _g706_bitmapWallSet_DoorFrameLeft_D3C = nullptr; + _g707_bitmapWallSet_DoorFrameLeft_D2C = nullptr; + _g708_bitmapWallSet_DoorFrameLeft_D1C = nullptr; + _g710_bitmapWallSet_DoorFrameRight_D1C = nullptr; + _g709_bitmapWallSet_DoorFrameFront = nullptr; + _g296_bitmapViewport = nullptr; + + _g231_currentWallSet = -1; + _g230_currentFloorSet = -1; + + _g90_bitmapWall_D3LCR_Flipped = nullptr; + _g91_bitmapWall_D2LCR_Flipped = nullptr; + _g92_bitmapWall_D1LCR_Flipped = nullptr; + _g93_bitmapWall_D0L_Flipped = nullptr; + _g94_bitmapWall_D0R_Flipped = nullptr; + _g95_bitmapWall_D3LCR_Native = nullptr; + _g96_bitmapWall_D2LCR_Native = nullptr; + _g97_bitmapWall_D1LCR_Native = nullptr; + _g98_bitmapWall_D0L_Native = nullptr; + _g99_bitmapWall_D0R_Native = nullptr; } DisplayMan::~DisplayMan() { @@ -686,10 +684,6 @@ DisplayMan::~DisplayMan() { delete[] _bitmaps[0]; delete[] _bitmaps; } - delete[] _wallSetBitMaps[kG696_Wall_D3R2]; // copy of another bitmap, but flipped - delete[] _wallSetBitMaps[kG710_DoorFrameRight_D1C]; // copy of another bitmap, but flipped - for (uint16 i = kG93_Wall_D0L_Flipped; i <= kG90_Wall_D3LCR_Flipped; ++i) - delete[] _wallSetBitMaps[i]; delete[] _g639_derivedBitmapByteCount; if (_g638_derivedBitmaps) { @@ -697,13 +691,37 @@ DisplayMan::~DisplayMan() { delete[] _g638_derivedBitmaps; delete[] _g638_derivedBitmaps; } + + delete[] _g85_bitmapCeiling; + delete[] _g84_bitmapFloor; + delete[] _g697_bitmapWallSet_Wall_D3L2; + delete[] _g696_bitmapWallSet_Wall_D3R2; + delete[] _g698_bitmapWallSet_Wall_D3LCR; + delete[] _g699_bitmapWallSet_Wall_D2LCR; + delete[] _g700_bitmapWallSet_Wall_D1LCR; + delete[] _g701_bitmapWallSet_Wall_D0L; + delete[] _g702_bitmapWallSet_Wall_D0R; + delete[] _g703_bitmapWallSet_DoorFrameTop_D2LCR; + delete[] _g704_bitmapWallSet_DoorFrameTop_D1LCR; + delete[] _g705_bitmapWallSet_DoorFrameLeft_D3L; + delete[] _g706_bitmapWallSet_DoorFrameLeft_D3C; + delete[] _g707_bitmapWallSet_DoorFrameLeft_D2C; + delete[] _g708_bitmapWallSet_DoorFrameLeft_D1C; + delete[] _g710_bitmapWallSet_DoorFrameRight_D1C; + delete[] _g709_bitmapWallSet_DoorFrameFront; + delete[] _g296_bitmapViewport; + + delete[] _g90_bitmapWall_D3LCR_Flipped; + delete[] _g91_bitmapWall_D2LCR_Flipped; + delete[] _g92_bitmapWall_D1LCR_Flipped; + delete[] _g93_bitmapWall_D0L_Flipped; + delete[] _g94_bitmapWall_D0R_Flipped; } void DisplayMan::setUpScreens(uint16 width, uint16 height) { _screenWidth = width; _screenHeight = height; delete[] _g74_tmpBitmap; - _g74_tmpBitmap = new byte[_screenWidth * _screenHeight]; delete[] _vgaBuffer; _vgaBuffer = new byte[_screenWidth * _screenHeight]; clearScreen(k0_ColorBlack); @@ -712,7 +730,6 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) { void DisplayMan::loadGraphics() { Common::File f; f.open("graphics.dat"); - _grapItemCount = f.readUint16BE(); delete[] _packedItemPos; _packedItemPos = new uint32[_grapItemCount + 1]; @@ -728,13 +745,31 @@ void DisplayMan::loadGraphics() { _packedBitmaps[i] = f.readByte(); f.close(); - unpackGraphics(); +} - loadFloorSet(k0_FloorSetStone); - loadWallSet(k0_WallSetStone); - - +void DisplayMan::initializeGraphicData() { + _g85_bitmapCeiling = new byte[224 * 29]; + _g84_bitmapFloor = new byte[224 * 70]; + _g697_bitmapWallSet_Wall_D3L2 = new byte[16 * 49]; + _g696_bitmapWallSet_Wall_D3R2 = new byte[16 * 49]; + _g698_bitmapWallSet_Wall_D3LCR = new byte[128 * 51]; + _g699_bitmapWallSet_Wall_D2LCR = new byte[144 * 71]; + _g700_bitmapWallSet_Wall_D1LCR = new byte[256 * 111]; + _g701_bitmapWallSet_Wall_D0L = new byte[32 * 136]; + _g702_bitmapWallSet_Wall_D0R = new byte[32 * 136]; + _g703_bitmapWallSet_DoorFrameTop_D2LCR = new byte[96 * 3]; + _g704_bitmapWallSet_DoorFrameTop_D1LCR = new byte[128 * 4]; + _g705_bitmapWallSet_DoorFrameLeft_D3L = new byte[32 * 43]; + _g706_bitmapWallSet_DoorFrameLeft_D3C = new byte[32 * 44]; + _g707_bitmapWallSet_DoorFrameLeft_D2C = new byte[48 * 65]; + _g708_bitmapWallSet_DoorFrameLeft_D1C = new byte[32 * 94]; + _g710_bitmapWallSet_DoorFrameRight_D1C = new byte[32 * 94]; + _g709_bitmapWallSet_DoorFrameFront = new byte[32 * 123]; + _g296_bitmapViewport = new byte[224 * 136]; + + warning("SKIPPED CODE: G0086_puc_Bitmap_ViewportBlackArea it is useless"); + warning("SKIPPED CODE: G0087_puc_Bitmap_ViewportFloorArea it is useless"); if (!_g639_derivedBitmapByteCount) _g639_derivedBitmapByteCount = new uint16[k730_DerivedBitmapMaximumCount]; @@ -900,6 +935,14 @@ void DisplayMan::loadFNT1intoBitmap(uint16 index, byte* destBitmap) { } } +void DisplayMan::f461_allocateFlippedWallBitmaps() { + _g90_bitmapWall_D3LCR_Flipped = new byte[128 * 51]; + _g91_bitmapWall_D2LCR_Flipped = new byte[144 * 71]; + _g92_bitmapWall_D1LCR_Flipped = new byte[256 * 111]; + _g93_bitmapWall_D0L_Flipped = new byte[32 * 136]; + _g94_bitmapWall_D0R_Flipped = new byte[32 * 136]; +} + void DisplayMan::loadPalette(uint16 *palette) { byte colorPalette[16 * 3]; for (int i = 0; i < 16; ++i) { @@ -1061,6 +1104,11 @@ uint16 DisplayMan::getHeight(uint16 index) { return READ_BE_UINT16(data + 2); } +// Note: has been screened for missing code +void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 pixelWidth, uint16 height) { + memcpy(destBitmap, srcBitmap, pixelWidth * height * sizeof(byte)); + flipBitmapHorizontal(destBitmap, pixelWidth, height); +} void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { if (f._srcWidth) @@ -1087,7 +1135,7 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g121_FrameStairsDownFront_D3L); goto T0116015_redEagle; case k0_WallElemType: - drawWallSetBitmap(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k1_ViewSquare_D3L]); + drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k1_ViewSquare_D3L]); isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT); if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) { order = k0x0000_CellOrder_Alcove; @@ -1101,7 +1149,7 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { case k17_ElementTypeDoorFront: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); - drawWallSetBitmap(_wallSetBitMaps[kG705_DoorFrameLeft_D3L], g164_Frame_DoorFrameLeft_D3L); + drawWallSetBitmap(_g705_bitmapWallSet_DoorFrameLeft_D3L, g164_Frame_DoorFrameLeft_D3L); warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor"); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; goto T0116017_orangeElk; @@ -1139,7 +1187,7 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { } goto T0117016; case k0_ElementTypeWall: - drawWallSetBitmap(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k2_ViewSquare_D3R]); + drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k2_ViewSquare_D3R]); isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT); if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) { order = k0x0000_CellOrder_Alcove; @@ -1153,7 +1201,7 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { case k17_ElementTypeDoorFront: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); - memcpy(_g74_tmpBitmap, _wallSetBitMaps[kG705_DoorFrameLeft_D3L], 32 * 44); + memcpy(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44); warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally"); if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton"); @@ -1190,7 +1238,7 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) { drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, g122_FrameStairsDownFront_D3C); break; case k0_WallElemType: - drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG698_Wall_D3LCR], g163_FrameWalls[k0_ViewSquare_D3C]); + drawWallSetBitmapWithoutTransparency(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k0_ViewSquare_D3C]); if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) { //... missing code } @@ -1210,7 +1258,7 @@ void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) { drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L); break; case k0_WallElemType: - drawWallSetBitmap(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k4_ViewSquare_D2L]); + drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]); isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT); if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) { // ... missing code @@ -1234,7 +1282,7 @@ void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) { drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R); break; case k0_WallElemType: - drawWallSetBitmap(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k5_ViewSquare_D2R]); + drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]); isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT); if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) { // ... missing code @@ -1258,7 +1306,7 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) { drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, g125_FrameStairsDownFront_D2C); break; case k0_WallElemType: - drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG699_Wall_D2LCR], g163_FrameWalls[k3_ViewSquare_D2C]); + drawWallSetBitmapWithoutTransparency(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k3_ViewSquare_D2C]); if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) { // ... missing code } @@ -1278,7 +1326,7 @@ void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) { drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g127_FrameStairsDownFront_D1L); break; case k0_WallElemType: - drawWallSetBitmap(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k7_ViewSquare_D1L]); + drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k7_ViewSquare_D1L]); isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT); break; case k18_StairsSideElemType: @@ -1302,7 +1350,7 @@ void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) { drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g129_FrameStairsDownFront_D1R); break; case k0_WallElemType: - drawWallSetBitmap(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k8_ViewSquare_D1R]); + drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k8_ViewSquare_D1R]); isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT); break; case k18_StairsSideElemType: @@ -1329,7 +1377,7 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) { _vm->_dungeonMan->_g286_isFacingAlcove = false; _vm->_dungeonMan->_g287_isFacingViAltar = false; _vm->_dungeonMan->_g288_isFacingFountain = false; - drawWallSetBitmapWithoutTransparency(_wallSetBitMaps[kG700_Wall_D1LCR], g163_FrameWalls[k6_ViewSquare_D1C]); + drawWallSetBitmapWithoutTransparency(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k6_ViewSquare_D1C]); if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) { // .... code not yet implemneted } @@ -1348,7 +1396,7 @@ void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) { drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, g138_FrameStairsSide_D0L); break; case k0_WallElemType: - drawWallSetBitmap(_wallSetBitMaps[kG701_Wall_D0L], g163_FrameWalls[k10_ViewSquare_D0L]); + drawWallSetBitmap(_g701_bitmapWallSet_Wall_D0L, g163_FrameWalls[k10_ViewSquare_D0L]); break; default: break; @@ -1364,7 +1412,7 @@ void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) { drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R); return; case k0_WallElemType: - drawWallSetBitmap(_wallSetBitMaps[kG702_Wall_D0R], g163_FrameWalls[k11_ViewSquare_D0R]); + drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, g163_FrameWalls[k11_ViewSquare_D0R]); break; default: break; @@ -1392,7 +1440,7 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) { void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { loadPalette(g20_PalEntrance); // TODO: this is a global variable, set from here - bool flippedFloorCeiling = (posX + posY + dir) & 1; + bool flippedFloorCeiling = true; // NOTE: this can hold every bitmap, width and height is "flexible" byte *tmpBitmap = new byte[305 * 111]; @@ -1405,27 +1453,32 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i]._x1 = 255 + 1; } - if (flippedFloorCeiling) { + if (_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1) { uint16 w = gK13_FloorFrame._srcWidth, h = gK13_FloorFrame._srcHeight; - blitToBitmap(_g84_floorBitmap, w, h, tmpBitmap, w); + blitToBitmap(_g84_bitmapFloor, w, h, tmpBitmap, w); flipBitmapHorizontal(tmpBitmap, w, h); drawWallSetBitmap(tmpBitmap, gK13_FloorFrame); - drawWallSetBitmap(_g85_ceilingBitmap, gK12_CeilingFrame); - - for (uint16 i = 0; i <= kG698_Wall_D3LCR - kG702_Wall_D0R; ++i) - _wallSetBitMaps[i + kG702_Wall_D0R] = _wallSetBitMaps[i + kG94_Wall_D0R_Flipped]; + drawWallSetBitmap(_g85_bitmapCeiling, gK12_CeilingFrame); + + if (flippedFloorCeiling) { + _g698_bitmapWallSet_Wall_D3LCR = _g90_bitmapWall_D3LCR_Flipped; + _g699_bitmapWallSet_Wall_D2LCR = _g91_bitmapWall_D2LCR_Flipped; + _g700_bitmapWallSet_Wall_D1LCR = _g92_bitmapWall_D1LCR_Flipped; + _g701_bitmapWallSet_Wall_D0L = _g93_bitmapWall_D0L_Flipped; + _g702_bitmapWallSet_Wall_D0R = _g94_bitmapWall_D0R_Flipped; + } } else { uint16 w = gK12_CeilingFrame._srcWidth, h = gK12_CeilingFrame._srcHeight; - blitToBitmap(_g85_ceilingBitmap, w, h, tmpBitmap, w); + blitToBitmap(_g85_bitmapCeiling, w, h, tmpBitmap, w); flipBitmapHorizontal(tmpBitmap, w, h); drawWallSetBitmap(tmpBitmap, gK12_CeilingFrame); - drawWallSetBitmap(_g84_floorBitmap, gK13_FloorFrame); + drawWallSetBitmap(_g84_bitmapFloor, gK13_FloorFrame); } if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == k0_WallElemType) - drawWallSetBitmap(_wallSetBitMaps[kG697_Wall_D3L2], g711_FrameWall_D3L2); + drawWallSetBitmap(_g697_bitmapWallSet_Wall_D3L2, g711_FrameWall_D3L2); if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == k0_WallElemType) - drawWallSetBitmap(_wallSetBitMaps[kG696_Wall_D3R2], g712_FrameWall_D3R2); + drawWallSetBitmap(_g696_bitmapWallSet_Wall_D3R2, g712_FrameWall_D3R2); int16 tmpPosX = posX, tmpPosY = posY; _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY); @@ -1462,9 +1515,13 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { drawSquareD0R(dir, tmpPosX, tmpPosY); drawSquareD0C(dir, posX, posY); - - for (uint16 i = 0; i <= kG698_Wall_D3LCR - kG702_Wall_D0R; ++i) - _wallSetBitMaps[i + kG702_Wall_D0R] = _wallSetBitMaps[i + kG99_Wall_D0R_Native]; + if (flippedFloorCeiling) { + _g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native; + _g699_bitmapWallSet_Wall_D2LCR = _g96_bitmapWall_D2LCR_Native; + _g700_bitmapWallSet_Wall_D1LCR = _g97_bitmapWall_D1LCR_Native; + _g701_bitmapWallSet_Wall_D0L = _g98_bitmapWall_D0L_Native; + _g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native; + } delete[] tmpBitmap; } @@ -1477,43 +1534,44 @@ void DisplayMan::clearBitmap(byte *bitmap, uint16 width, uint16 height, Color co memset(bitmap, color, sizeof(byte) * width * height); } - +// NOTE: has been screened for missing code void DisplayMan::loadFloorSet(FloorSet set) { - // there are 2 bitmaps per set, first one is at 75 - GraphicIndice indice = (GraphicIndice)(k75_FirstFloorSet + (k2_FloorSetGraphicCount * set)); - _g84_floorBitmap = _bitmaps[indice]; - _g85_ceilingBitmap = _bitmaps[indice + 1]; + if (_g230_currentFloorSet != set) { + _g230_currentFloorSet = set; + int16 index = (set * k2_FloorSetGraphicCount) + k75_FirstFloorSet; + loadIntoBitmap(index, _g84_bitmapFloor); + loadIntoBitmap(index + 1, _g85_bitmapCeiling); + } } - Box g161_BoxWallBitmap_D3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR Box g162_BoxWallBitmap_D2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR +// Note: has been screened for missing code void DisplayMan::loadWallSet(WallSet set) { - uint16 firstIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet; - for (uint16 i = 0; i < k13_WallSetGraphicCount; ++i) { - _wallSetBitMaps[i] = _bitmaps[i + firstIndice]; - } - for (uint16 i = 0; i <= kG698_Wall_D3LCR - kG702_Wall_D0R; ++i) - _wallSetBitMaps[i + kG99_Wall_D0R_Native] = _wallSetBitMaps[i + kG702_Wall_D0R]; - - uint16 srcIndex[7] = {kG708_DoorFrameLeft_D1C, kG697_Wall_D3L2, kG700_Wall_D1LCR, kG701_Wall_D0L, kG702_Wall_D0R, - kG699_Wall_D2LCR, kG698_Wall_D3LCR}; - - uint16 destIndex[7] = {kG710_DoorFrameRight_D1C, kG696_Wall_D3R2, kG92_Wall_D1LCR_Flipped, kG94_Wall_D0R_Flipped, kG93_Wall_D0L_Flipped, - kG91_Wall_D2LCR_Flipped, kG90_Wall_D3LCR_Flipped}; - - // the original loads these flipped walls in loadCurrentMapGraphics - - for (uint16 i = 0; i < 7; ++i) { - uint16 srcGraphicIndice = firstIndice + srcIndex[i]; - uint16 w = getWidth(srcGraphicIndice), h = getHeight(srcGraphicIndice); - delete[] _wallSetBitMaps[destIndex[i]]; - _wallSetBitMaps[destIndex[i]] = new byte[w * h]; - blitToBitmap(_wallSetBitMaps[srcIndex[i]], w, h, _wallSetBitMaps[destIndex[i]], w); - if (srcIndex[i] != kG699_Wall_D2LCR && srcIndex[i] != kG698_Wall_D3LCR) // TODO: implement flipping of these two bitmaps, disabled with if - flipBitmapHorizontal(_wallSetBitMaps[destIndex[i]], w, h); + if ((_g231_currentWallSet != set) || _vm->_g523_restartGameRequest) { + _g231_currentWallSet = set; + { + int16 graphicIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet; + loadIntoBitmap(graphicIndice++, _g709_bitmapWallSet_DoorFrameFront); + loadIntoBitmap(graphicIndice++, _g708_bitmapWallSet_DoorFrameLeft_D1C); + loadIntoBitmap(graphicIndice++, _g707_bitmapWallSet_DoorFrameLeft_D2C); + loadIntoBitmap(graphicIndice++, _g706_bitmapWallSet_DoorFrameLeft_D3C); + loadIntoBitmap(graphicIndice++, _g705_bitmapWallSet_DoorFrameLeft_D3L); + loadIntoBitmap(graphicIndice++, _g704_bitmapWallSet_DoorFrameTop_D1LCR); + loadIntoBitmap(graphicIndice++, _g703_bitmapWallSet_DoorFrameTop_D2LCR); + loadIntoBitmap(graphicIndice++, _g702_bitmapWallSet_Wall_D0R); + loadIntoBitmap(graphicIndice++, _g701_bitmapWallSet_Wall_D0L); + loadIntoBitmap(graphicIndice++, _g700_bitmapWallSet_Wall_D1LCR); + loadIntoBitmap(graphicIndice++, _g699_bitmapWallSet_Wall_D2LCR); + loadIntoBitmap(graphicIndice++, _g698_bitmapWallSet_Wall_D3LCR); + loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2); + } + f99_copyBitmapAndFlipHorizontal(_g708_bitmapWallSet_DoorFrameLeft_D1C, _g710_bitmapWallSet_DoorFrameRight_D1C, + g171_Frame_DoorFrameRight_D1C._srcWidth, g171_Frame_DoorFrameRight_D1C._srcHeight); + f99_copyBitmapAndFlipHorizontal(_g697_bitmapWallSet_Wall_D3L2, _g696_bitmapWallSet_Wall_D3R2, + g712_FrameWall_D3R2._srcWidth, g712_FrameWall_D3R2._srcHeight); } } @@ -1522,7 +1580,28 @@ void DisplayMan::loadCurrentMapGraphics() { loadFloorSet(_vm->_dungeonMan->_g269_currMap->_floorSet); loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet); - // the original loads some flipped walls here, I moved it to loadWallSet + { + _g74_tmpBitmap = new byte[_screenWidth * _screenHeight]; + _g578_useByteBoxCoordinates = true; + + f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap, + g163_FrameWalls[k0_ViewSquare_D3C]._srcWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight); + clearBitmap(_g90_bitmapWall_D3LCR_Flipped, 128, 51, k10_ColorFlesh); + blitToBitmap(_g74_tmpBitmap, 128, 11, 0, _g90_bitmapWall_D3LCR_Flipped, 128, g161_BoxWallBitmap_D3LCR, k255_ColorNoTransparency); + + f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap, + g163_FrameWalls[k3_ViewSquare_D2C]._srcWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight); + clearBitmap(_g91_bitmapWall_D2LCR_Flipped, 144, 71, k10_ColorFlesh); + blitToBitmap(_g74_tmpBitmap, 144, 8, 0, _g91_bitmapWall_D2LCR_Flipped, 144, g162_BoxWallBitmap_D2LCR, k255_ColorNoTransparency); + + f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped, + g163_FrameWalls[k6_ViewSquare_D1C]._srcWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight); + f99_copyBitmapAndFlipHorizontal(_g98_bitmapWall_D0L_Native = _g701_bitmapWallSet_Wall_D0L, _g94_bitmapWall_D0R_Flipped, + g163_FrameWalls[k10_ViewSquare_D0L]._srcWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight); + f99_copyBitmapAndFlipHorizontal(_g99_bitmapWall_D0R_Native = _g702_bitmapWallSet_Wall_D0R, _g93_bitmapWall_D0L_Flipped, + g163_FrameWalls[k10_ViewSquare_D0L]._srcWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight); + } + { int16 val = _vm->_dungeonMan->_g269_currMap->_wallSet * k18_StairsGraphicCount + k90_FirstStairs; @@ -1691,7 +1770,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex if (viewWallIndex == k12_ViewWall_D1C_FRONT) { if (isInscription) { Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C]; - blitToScreen(_wallSetBitMaps[kG700_Wall_D1LCR], D1CFrame._srcWidth, 94, 28, g202_BoxWallPatchBehindInscription._x1, g202_BoxWallPatchBehindInscription._x2, + blitToScreen(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, g202_BoxWallPatchBehindInscription._x1, g202_BoxWallPatchBehindInscription._x2, g202_BoxWallPatchBehindInscription._y1, g202_BoxWallPatchBehindInscription._y2, k255_ColorNoTransparency, g296_DungeonViewport); unsigned char *string = inscriptionString; diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 80902e4e68..039d270398 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -422,12 +422,7 @@ class DisplayMan { byte *_packedBitmaps; byte **_bitmaps; - // pointers 13,14 and [15-19] are owned by this array - byte *_wallSetBitMaps[25]; // @G[0696..0710]_puc_Bitmap_WallSet_... - // pointers are not owned by these fields - byte *_g84_floorBitmap; // @ G0084_puc_Bitmap_Floor - byte *_g85_ceilingBitmap; // @ G0085_puc_Bitmap_Ceiling byte *_g75_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile DisplayMan(const DisplayMan &other); // no implementation on purpose @@ -482,7 +477,43 @@ class DisplayMan { int16 _g690_stairsNativeBitmapIndex_Up_Side_D1L; // @ G0690_i_StairsNativeBitmapIndex_Up_Side_D1L int16 _g691_stairsNativeBitmapIndex_Down_Side_D1L; // @ G0691_i_StairsNativeBitmapIndex_Down_Side_D1L int16 _g692_stairsNativeBitmapIndex_Side_D0L; // @ G0692_i_StairsNativeBitmapIndex_Side_D0L + + + byte *_g84_bitmapFloor; // @ G0084_puc_Bitmap_Floor + byte *_g85_bitmapCeiling; // @ G0085_puc_Bitmap_Ceiling + byte *_g697_bitmapWallSet_Wall_D3L2; // @ G0697_puc_Bitmap_WallSet_Wall_D3L2 + byte *_g696_bitmapWallSet_Wall_D3R2; // @ G0696_puc_Bitmap_WallSet_Wall_D3R2 + byte *_g698_bitmapWallSet_Wall_D3LCR; // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR + byte *_g699_bitmapWallSet_Wall_D2LCR; // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR + byte *_g700_bitmapWallSet_Wall_D1LCR; // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR + byte *_g701_bitmapWallSet_Wall_D0L; // @ G0701_puc_Bitmap_WallSet_Wall_D0L + byte *_g702_bitmapWallSet_Wall_D0R; // @ G0702_puc_Bitmap_WallSet_Wall_D0R + byte *_g703_bitmapWallSet_DoorFrameTop_D2LCR; // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR + byte *_g704_bitmapWallSet_DoorFrameTop_D1LCR; // @ G0704_puc_Bitmap_WallSet_DoorFrameTop_D1LCR + byte *_g705_bitmapWallSet_DoorFrameLeft_D3L; // @ G0705_puc_Bitmap_WallSet_DoorFrameLeft_D3L + byte *_g706_bitmapWallSet_DoorFrameLeft_D3C; // @ G0706_puc_Bitmap_WallSet_DoorFrameLeft_D3C + byte *_g707_bitmapWallSet_DoorFrameLeft_D2C; // @ G0707_puc_Bitmap_WallSet_DoorFrameLeft_D2C + byte *_g708_bitmapWallSet_DoorFrameLeft_D1C; // @ G0708_puc_Bitmap_WallSet_DoorFrameLeft_D1C + byte *_g710_bitmapWallSet_DoorFrameRight_D1C; // @ G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C + byte *_g709_bitmapWallSet_DoorFrameFront; // @ G0709_puc_Bitmap_WallSet_DoorFrameFront + + byte *_g90_bitmapWall_D3LCR_Flipped; // @ G0090_puc_Bitmap_WallD3LCR_Flipped; + byte *_g91_bitmapWall_D2LCR_Flipped; // @ G0091_puc_Bitmap_WallD2LCR_Flipped; + byte *_g92_bitmapWall_D1LCR_Flipped; // @ G0092_puc_Bitmap_WallD1LCR_Flipped; + byte *_g93_bitmapWall_D0L_Flipped; // @ G0093_puc_Bitmap_WallD0L_Flipped; + byte *_g94_bitmapWall_D0R_Flipped; // @ G0094_puc_Bitmap_WallD0R_Flipped; + byte *_g95_bitmapWall_D3LCR_Native; // @ G0095_puc_Bitmap_WallD3LCR_Native; + byte *_g96_bitmapWall_D2LCR_Native; // @ G0096_puc_Bitmap_WallD2LCR_Native; + byte *_g97_bitmapWall_D1LCR_Native; // @ G0097_puc_Bitmap_WallD1LCR_Native; + byte *_g98_bitmapWall_D0L_Native; // @ G0098_puc_Bitmap_WallD0L_Native; + byte *_g99_bitmapWall_D0R_Native; // @ G0099_puc_Bitmap_WallD0R_Native; + + int16 _g231_currentWallSet; // @ G0231_i_CurrentWallSet + int16 _g230_currentFloorSet;// @ G0230_i_CurrentFloorSet + + bool _g76_useFlippedWallAndFootprintsBitmap; // @ G0076_B_UseFlippedWallAndFootprintsBitmaps public: + byte* _g296_bitmapViewport; // @ G0296_puc_Bitmap_Viewport // some methods use this for a stratchpad, don't make assumptions about content between function calls byte *_g74_tmpBitmap; // @ G0074_puc_Bitmap_Temporary @@ -494,14 +525,19 @@ public: void setUpScreens(uint16 width, uint16 height); void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader, F0460_START_InitializeGraphicData + void initializeGraphicData(); // @ F0460_START_InitializeGraphicData void loadCurrentMapGraphics(); // @ F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF void loadPalette(uint16 *palette); + void f461_allocateFlippedWallBitmaps(); // @ F0461_START_AllocateFlippedWallBitmaps /// Gives the width of an IMG0 type item uint16 getWidth(uint16 index); /// Gives the height of an IMG1 type item uint16 getHeight(uint16 index); + + void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); + void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte *destBitmap, uint16 destWidth, uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, @@ -563,6 +599,8 @@ public: Thing _g290_inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing + // This tells blitting functions wther to assume a BYTE_BOX or a WORD_BOX has been passed to them, + // I only use WORD_BOX, so this will probably deem useless bool _g578_useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates bool _g77_doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame @@ -571,6 +609,7 @@ public: + }; } -- cgit v1.2.3 From c5f118079c943de4a1a721b8fd6d0932ea1eee52 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 2 Jul 2016 17:54:47 +0200 Subject: DM: Renaming stuff --- engines/dm/gfx.cpp | 8 ++++---- engines/dm/gfx.h | 5 +++-- engines/dm/menus.cpp | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 95c5cf25e8..a459109eaf 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1444,7 +1444,7 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { // NOTE: this can hold every bitmap, width and height is "flexible" byte *tmpBitmap = new byte[305 * 111]; - clearBitmap(tmpBitmap, 305, 111, k10_ColorFlesh); + f134_fillBitmap(tmpBitmap, 305, 111, k10_ColorFlesh); for (int16 i = 0; i < 6; ++i) _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i].setToZero(); @@ -1530,7 +1530,7 @@ void DisplayMan::clearScreen(Color color) { memset(getCurrentVgaBuffer(), color, sizeof(byte) * _screenWidth * _screenHeight); } -void DisplayMan::clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color) { +void DisplayMan::f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color) { memset(bitmap, color, sizeof(byte) * width * height); } @@ -1586,12 +1586,12 @@ void DisplayMan::loadCurrentMapGraphics() { f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap, g163_FrameWalls[k0_ViewSquare_D3C]._srcWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight); - clearBitmap(_g90_bitmapWall_D3LCR_Flipped, 128, 51, k10_ColorFlesh); + f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, 128, 51, k10_ColorFlesh); blitToBitmap(_g74_tmpBitmap, 128, 11, 0, _g90_bitmapWall_D3LCR_Flipped, 128, g161_BoxWallBitmap_D3LCR, k255_ColorNoTransparency); f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap, g163_FrameWalls[k3_ViewSquare_D2C]._srcWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight); - clearBitmap(_g91_bitmapWall_D2LCR_Flipped, 144, 71, k10_ColorFlesh); + f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, 144, 71, k10_ColorFlesh); blitToBitmap(_g74_tmpBitmap, 144, 8, 0, _g91_bitmapWall_D2LCR_Flipped, 144, g162_BoxWallBitmap_D2LCR, k255_ColorNoTransparency); f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped, diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 039d270398..2a30c53978 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -565,11 +565,12 @@ public: void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); byte *getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap - void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color); + void f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color); // @ F0134_VIDEO_FillBitmap void clearScreen(Color color); - void clearScreenBox(Color color, Box &box, Viewport &viewport = gDefultViewPort); // @ D24_FillScreenBox + void clearScreenBox(Color color, Box &box, Viewport &viewport = gDefultViewPort); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); + byte* getBitmap(uint16 index); Common::MemoryReadStream getCompressedData(uint16 index); uint32 getCompressedDataSize(uint16 index); diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index ee27ee0f6b..890c8c09dd 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -101,7 +101,7 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) { } else if (g237_ObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) { iconIndex = _vm->_objectMan->getIconIndex(thing); } else { - dm.clearBitmap(bitmapIcon, 16, 16, k4_ColorCyan); + dm.f134_fillBitmap(bitmapIcon, 16, 16, k4_ColorCyan); goto T0386006; } _vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon); -- cgit v1.2.3 From 8c06b0afd0c4ca9fa8f147a40ccd7210250f5a88 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 2 Jul 2016 19:24:13 +0200 Subject: DM: Add F0097_DUNGEONVIEW_DrawViewport --- engines/dm/dm.cpp | 8 ++++++- engines/dm/dm.h | 4 +++- engines/dm/gfx.cpp | 69 +++++++++++++++++++++++++++++++++++++++++++++-------- engines/dm/gfx.h | 28 ++++++++++++++++++---- engines/dm/text.cpp | 4 ++-- 5 files changed, 95 insertions(+), 18 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index bc4d1c9c3e..ec455c44f0 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -166,8 +166,14 @@ void DMEngine::initializeGame() { warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); } + void DMEngine::f448_initMemoryManager() + { + warning("STUB FUNCTION"); + for (uint16 i = 0; i < 16; ++i) + _displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i]; + } -void DMEngine::startGame() { + void DMEngine::startGame() { _g331_pressingEye = false; _g332_stopPressingEye = false; _g333_pressingMouth = false; diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 361ff9e423..d439cfadae 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -134,13 +134,15 @@ public: enum { // engine debug channels kDMDebugExample = 1 << 0, - kDMDebugUselessCode = 1 << 1 + kDMDebugUselessCode = 1 << 1, + kDMDebugOftenCalledWarning = 2 << 2 }; class DMEngine : public Engine { void startGame(); // @ F0462_START_StartGame_CPSF void processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF + void f448_initMemoryManager(); // @ F0448_STARTUP1_InitializeMemoryManager_CPSADEF void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF void initArrays(); diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index a459109eaf..25d4c46839 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -578,8 +578,7 @@ byte g222_PalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, Viewport gDefultViewPort(0, 0, 320, 200); -// TODO: I guessed the numbers -Viewport g296_DungeonViewport(0, 33, 224, 126); // @ G0296_puc_Bitmap_Viewport +Viewport g296_DungeonViewport(0, 33, 224, 136); // @ G0296_puc_Bitmap_Viewport byte g17_PalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges @@ -594,7 +593,7 @@ byte g192_AlcoveOrnIndices[k3_AlcoveOrnCount] = { // @ G0192_auc_Graphic558_Alco DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { - _vgaBuffer = nullptr; + _g348_bitmapScreen = nullptr; _bitmaps = nullptr; _grapItemCount = 0; _packedItemPos = nullptr; @@ -674,12 +673,16 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _g97_bitmapWall_D1LCR_Native = nullptr; _g98_bitmapWall_D0L_Native = nullptr; _g99_bitmapWall_D0R_Native = nullptr; + + _g322_paletteSwitchingEnabled = false; + warning("DUMMY CODE: setting _g304_dungeonViewPaletteIndex"); + _g304_dungeonViewPaletteIndex = 0; } DisplayMan::~DisplayMan() { delete[] _packedItemPos; delete[] _packedBitmaps; - delete[] _vgaBuffer; + delete[] _g348_bitmapScreen; if (_bitmaps) { delete[] _bitmaps[0]; delete[] _bitmaps; @@ -722,8 +725,8 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) { _screenWidth = width; _screenHeight = height; delete[] _g74_tmpBitmap; - delete[] _vgaBuffer; - _vgaBuffer = new byte[_screenWidth * _screenHeight]; + delete[] _g348_bitmapScreen; + _g348_bitmapScreen = new byte[_screenWidth * _screenHeight]; clearScreen(k0_ColorBlack); } @@ -943,6 +946,20 @@ void DisplayMan::f461_allocateFlippedWallBitmaps() { _g94_bitmapWall_D0R_Flipped = new byte[32 * 136]; } +void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* topAndBottomScreen) { + if (middleScreenPalette && topAndBottomScreen) + debugC(kDMDebugOftenCalledWarning, "MISSING CODE: F0508_AMIGA_BuildPaletteChangeCopperList"); + + f566_viewportBlitToScreen(); +} + +void DisplayMan::f566_viewportBlitToScreen() { + warning("MISSING FUNCTIONALITY: using correct colorpalette"); + Box box(0, 33, 223, 135); + + blitToBitmap(_g296_bitmapViewport, k112_byteWidthViewport * 2, 0, 0, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); +} + void DisplayMan::loadPalette(uint16 *palette) { byte colorPalette[16 * 3]; for (int i = 0; i < 16; ++i) { @@ -1033,7 +1050,7 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight void DisplayMan::blitBoxFilledWithMaskedBitmapToScreen(byte* src, byte* mask, byte* tmp, Box& box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport& viewport) { - blitBoxFilledWithMaskedBitmap(src, _vgaBuffer, mask, tmp, box, lastUnitIndex, firstUnitIndex, _screenWidth, transparent, xPos, yPos, _screenHeight, height2, viewport); + blitBoxFilledWithMaskedBitmap(src, _g348_bitmapScreen, mask, tmp, box, lastUnitIndex, firstUnitIndex, _screenWidth, transparent, xPos, yPos, _screenHeight, height2, viewport); } void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) { @@ -1086,12 +1103,42 @@ byte* DisplayMan::getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int void DisplayMan::updateScreen() { - _vm->_system->copyRectToScreen(_vgaBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight); + _vm->_system->copyRectToScreen(_g348_bitmapScreen, _screenWidth, 0, 0, _screenWidth, _screenHeight); _vm->_system->updateScreen(); } +void DisplayMan::f97_drawViewport(int16 palSwitchingRequestedState) { + static uint16 *gK10_dungeonViewCurrentPalette; // @ K0010_pui_DungeonViewCurrentPalette + + // ignored code F0510_AMIGA_WaitBottomOfViewPort + if (palSwitchingRequestedState == k2_viewportAsBeforeSleepOrFreezeGame) + palSwitchingRequestedState = _g322_paletteSwitchingEnabled ? 1 : 0; + + if (_g342_refreshDungeonViewPaleteRequested) { + gK10_dungeonViewCurrentPalette = g21_PalDungeonView[_g304_dungeonViewPaletteIndex]; + _g342_refreshDungeonViewPaleteRequested = false; + if (palSwitchingRequestedState == k0_viewportNotDungeonView) { + _g322_paletteSwitchingEnabled = true; + } else { + _g322_paletteSwitchingEnabled = false; + } + } + + if (palSwitchingRequestedState != (_g322_paletteSwitchingEnabled ? 1 : 0)) { + if (palSwitchingRequestedState) { + f565_viewportSetPalette(gK10_dungeonViewCurrentPalette, _g347_paletteTopAndBottomScreen); + _g322_paletteSwitchingEnabled = true; + } else { + f565_viewportSetPalette(_g347_paletteTopAndBottomScreen, _g347_paletteTopAndBottomScreen); + _g322_paletteSwitchingEnabled = false; + } + } else { + f565_viewportSetPalette(nullptr, nullptr); + } +} + byte *DisplayMan::getCurrentVgaBuffer() { - return _vgaBuffer; + return _g348_bitmapScreen; } uint16 DisplayMan::getWidth(uint16 index) { @@ -1685,6 +1732,8 @@ void DisplayMan::loadCurrentMapGraphics() { if (replColorOrdinal) applyCreatureReplColors(10, _vm->ordinalToIndex(replColorOrdinal)); } + + _g342_refreshDungeonViewPaleteRequested = true; } void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor) { @@ -2965,7 +3014,7 @@ byte* DisplayMan::getDerivedBitmap(int16 derivedBitmapIndex) { void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) { uint16 width = box._x2 - box._x1; for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y) - memset(_vgaBuffer + y * _screenWidth + box._x1 + viewport._posX, color, sizeof(byte) * width); + memset(_g348_bitmapScreen + y * _screenWidth + box._x1 + viewport._posX, color, sizeof(byte) * width); } void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 2a30c53978..5efa58aaa2 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -408,13 +408,21 @@ extern Viewport g296_DungeonViewport; #define k15_DoorOrnDestroyedMask 15 // @ C15_DOOR_ORNAMENT_DESTROYED_MASK #define k16_DoorOrnThivesEyeMask 16 // @ C16_DOOR_ORNAMENT_THIEVES_EYE_MASK +#define k0_viewportNotDungeonView 0 // @ C0_VIEWPORT_NOT_DUNGEON_VIEW +#define k1_viewportDungeonView 1 // @ C1_VIEWPORT_DUNGEON_VIEW +#define k2_viewportAsBeforeSleepOrFreezeGame 2 // @ C2_VIEWPORT_AS_BEFORE_SLEEP_OR_FREEZE_GAME + + +#define k112_byteWidthViewport 112 // @ C112_BYTE_WIDTH_VIEWPORT +#define k136_heightViewport 136 // @ C136_HEIGHT_VIEWPORT + +#define k160_byteWidthScreen 160 // @ C160_BYTE_WIDTH_SCREEN +#define k200_heightScreen 200 // @ C200_HEIGHT_SCREEN + class DisplayMan { friend class DM::TextMan; DMEngine *_vm; - uint16 _screenWidth; - uint16 _screenHeight; - byte *_vgaBuffer; /// Related to graphics.dat file uint16 _grapItemCount; // @ G0632_ui_GraphicCount @@ -434,6 +442,9 @@ class DisplayMan { void unpackGraphics(); void loadFNT1intoBitmap(uint16 index, byte *destBitmap); + void f565_viewportSetPalette(uint16 * middleScreenPalette, uint16 * topAndBottomScreen); // @ F0565_VIEWPORT_SetPalette + void f566_viewportBlitToScreen(); // @ F0566_VIEWPORT_BlitToScreen + void drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally void drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap @@ -513,9 +524,17 @@ class DisplayMan { bool _g76_useFlippedWallAndFootprintsBitmap; // @ G0076_B_UseFlippedWallAndFootprintsBitmaps public: + uint16 _screenWidth; + uint16 _screenHeight; + byte *_g348_bitmapScreen; // @ G0348_pl_Bitmap_Screen byte* _g296_bitmapViewport; // @ G0296_puc_Bitmap_Viewport + // some methods use this for a stratchpad, don't make assumptions about content between function calls byte *_g74_tmpBitmap; // @ G0074_puc_Bitmap_Temporary + bool _g322_paletteSwitchingEnabled; // @ G0322_B_PaletteSwitchingEnabled + bool _g342_refreshDungeonViewPaleteRequested; // @ G0342_B_RefreshDungeonViewPaletteRequested + int16 _g304_dungeonViewPaletteIndex; // @ G0304_i_DungeonViewPaletteIndex + uint16 _g347_paletteTopAndBottomScreen[16]; // @ G0347_aui_Palette_TopAndBottomScreen explicit DisplayMan(DMEngine *dmEngine); ~DisplayMan(); @@ -561,7 +580,7 @@ public: int16 firstUnitIndex, int16 destPixelWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = g296_DungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap - void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); + void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); byte *getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap @@ -570,6 +589,7 @@ public: void clearScreenBox(Color color, Box &box, Viewport &viewport = gDefultViewPort); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); + void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport byte* getBitmap(uint16 index); Common::MemoryReadStream getCompressedData(uint16 index); diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index f526faad88..67ac123a72 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -66,7 +66,7 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 } void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text, Viewport &viewport) { - printTextToBitmap(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport); + printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport); } void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) { @@ -82,7 +82,7 @@ void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, in } void TextMan::printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor, const char* text, int16 strLenght, Viewport& viewport) { - printWithTrailingSpaces(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY, + printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, strLenght, _vm->_displayMan->_screenHeight, viewport); } -- cgit v1.2.3 From 883370eb7d0dfdfbc1ef15ed9f0458cdc1423368 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 2 Jul 2016 20:12:10 +0200 Subject: DM: Remove several blitting overloads --- engines/dm/champion.cpp | 2 +- engines/dm/gfx.cpp | 67 ++++++++++++++++++++---------------------------- engines/dm/gfx.h | 20 +++++---------- engines/dm/inventory.cpp | 4 +-- engines/dm/menus.cpp | 4 +-- engines/dm/objectman.cpp | 3 ++- engines/dm/objectman.h | 2 +- engines/dm/text.cpp | 5 +++- 8 files changed, 46 insertions(+), 61 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 5a85434aa3..a708251a62 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -462,7 +462,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { { // limit destBox scope Box &destBox = gBoxChampionPortrait; dispMan.blitToBitmap(dispMan.getBitmap(k26_ChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), - champ->_portrait, 32, destBox._x1, destBox._x2, destBox._y1, destBox._y2, k255_ColorNoTransparency); + champ->_portrait, 32, destBox, k255_ColorNoTransparency); } champ->_actionIndex = k255_ChampionActionNone; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 25d4c46839..d41bf4900a 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1019,34 +1019,41 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { } } -void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, - byte *destBitmap, uint16 destWidth, - uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - Color transparent, Viewport &destViewport) { - for (uint16 y = 0; y < destToY - destFromY; ++y) - for (uint16 x = 0; x < destToX - destFromX; ++x) { + +void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent, Viewport& viewport) { + for (uint16 y = 0; y < box._y2 - box._y1; ++y) + for (uint16 x = 0; x < box._x2 - box._x1; ++x) { byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x]; if (srcPixel != transparent) - destBitmap[destWidth * (y + destFromY + destViewport._posY) + destFromX + x + destViewport._posX] = srcPixel; + destBitmap[destWidth * (y + box._y1 + viewport._posY) + box._x1 + x + viewport._posX] = srcPixel; } + } -void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent, Viewport& viewport) { - blitToBitmap(srcBitmap, srcWidth, srcX, srcY, destBitmap, destWidth, box._x1, box._x2, box._y1, box._y2, transparent, viewport); +void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX, uint16 destY) { + for (uint16 y = 0; y < srcHeight; ++y) + memcpy(destBitmap + destWidth*(y + destY) + destX, srcBitmap + y * srcWidth, sizeof(byte)* srcWidth); +} + +void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) { + uint16 width = box._x2 - box._x1; + for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y) + memset(_g348_bitmapScreen + y * _screenWidth + box._x1 + viewport._posX, color, sizeof(byte) * width); } void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, - uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, + Box &box, Color transparent, Viewport &viewport) { - blitToBitmap(srcBitmap, srcWidth, srcX, srcY, - getCurrentVgaBuffer(), _screenWidth, destFromX, destToX, destFromY, destToY, transparent, viewport); + blitToBitmap(srcBitmap, srcWidth, srcX, srcY, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, transparent, viewport); } -void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX, uint16 destY) { - for (uint16 y = 0; y < srcHeight; ++y) - memcpy(destBitmap + destWidth*(y + destY) + destX, srcBitmap + y * srcWidth, sizeof(byte)* srcWidth); +void DisplayMan::blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box, + int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, + int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport) { + warning("STUB FUNCTION: does nothing at all"); } + void DisplayMan::blitBoxFilledWithMaskedBitmapToScreen(byte* src, byte* mask, byte* tmp, Box& box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport& viewport) { @@ -1819,8 +1826,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex if (viewWallIndex == k12_ViewWall_D1C_FRONT) { if (isInscription) { Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C]; - blitToScreen(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, g202_BoxWallPatchBehindInscription._x1, g202_BoxWallPatchBehindInscription._x2, - g202_BoxWallPatchBehindInscription._y1, g202_BoxWallPatchBehindInscription._y2, k255_ColorNoTransparency, g296_DungeonViewport); + blitToScreen(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, g202_BoxWallPatchBehindInscription, k255_ColorNoTransparency, g296_DungeonViewport); unsigned char *string = inscriptionString; bitmapRed = _bitmaps[k120_InscriptionFontIndice]; @@ -1923,12 +1929,12 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1]; } } - blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, coordinateSetA[0], coordinateSetA[1], coordinateSetA[2], coordinateSetA[3], k10_ColorFlesh, g296_DungeonViewport); + blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, *(Box*)coordinateSetA, k10_ColorFlesh, g296_DungeonViewport); if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { Box &box = g109_BoxChampionPortraitOnWall; - blitToScreen(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29, box._x1, box._x2, box._y1, box._y2, - k1_ColorDarkGary, g296_DungeonViewport); + blitToScreen(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29, + box, k1_ColorDarkGary, g296_DungeonViewport); } return isAlcove; } @@ -2250,8 +2256,8 @@ void DisplayMan::cthulhu(Thing thingParam, direction directionParam, int16 mapXp bool drawProjectileAsObject; bool sqaureHasProjectile; - uint16 currentViewCellToDraw; - bool projectileFlipVertical; + uint16 currentViewCellToDraw = 0; + bool projectileFlipVertical = false; bool projectileAspectTypeHasBackGraphicAndRotation; bool flipVertical; Explosion* explosion; @@ -3011,22 +3017,5 @@ byte* DisplayMan::getDerivedBitmap(int16 derivedBitmapIndex) { return _g638_derivedBitmaps[derivedBitmapIndex]; } -void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) { - uint16 width = box._x2 - box._x1; - for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y) - memset(_g348_bitmapScreen + y * _screenWidth + box._x1 + viewport._posX, color, sizeof(byte) * width); -} - -void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, - Box &box, - Color transparent, Viewport &viewport) { - blitToScreen(srcBitmap, srcWidth, srcX, srcY, box._x1, box._x2, box._y1, box._y2, transparent, viewport); -} - -void DisplayMan::blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box, - int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, - int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport) { - warning("STUB FUNCTION: does nothing at all"); -} } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 5efa58aaa2..60f6cdb630 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -438,7 +438,6 @@ class DisplayMan { byte *getCurrentVgaBuffer(); // the original function has two position parameters, but they are always set to zero - void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap void unpackGraphics(); void loadFNT1intoBitmap(uint16 index, byte *destBitmap); @@ -542,6 +541,7 @@ public: void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet + void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap void setUpScreens(uint16 width, uint16 height); void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader, F0460_START_InitializeGraphicData void initializeGraphicData(); // @ F0460_START_InitializeGraphicData @@ -557,28 +557,22 @@ public: void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); - void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, - byte *destBitmap, uint16 destWidth, - uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort); + void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort); - void blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight, - byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0); - void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, - uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, - Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort); - void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, - Box &box, - Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort); void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDefultViewPort); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap + void blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight, + byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges void blitBoxFilledWithMaskedBitmapToScreen(byte *src, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = g296_DungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap + void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, + Box &box, + Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort); void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 1d7bd95b80..04554691ba 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -94,9 +94,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { } champion = &cm._champions[championIndex]; - int16 w = dm.getWidth(k17_InventoryGraphicIndice); - int16 h = dm.getHeight(k17_InventoryGraphicIndice); - dm.blitToScreen(dm.getBitmap(k17_InventoryGraphicIndice), w, 0, 0, 0, w, 0, h, k255_ColorNoTransparency, g296_DungeonViewport); + dm.loadIntoBitmap(k17_InventoryGraphicIndice, dm._g296_bitmapViewport); if (cm._g299_candidateChampionOrdinal) { dm.clearScreenBox(k12_ColorDarkestGray, g41_BoxFloppyZzzCross, g296_DungeonViewport); } diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 890c8c09dd..b2ad003739 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -64,7 +64,7 @@ void MenuMan::drawMovementArrows() { Box &dest = g2_BoxMovementArrows; uint16 w = disp.getWidth(k13_MovementArrowsIndice); - disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, k255_ColorNoTransparency); + disp.blitToScreen(arrowsBitmap, w, 0, 0, dest, k255_ColorNoTransparency); } void MenuMan::clearActingChampion() { ChampionMan &cm = *_vm->_championMan; @@ -113,7 +113,7 @@ T0386006: box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that box2._y1 = 95; box2._y2 = 110 + 1; - dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2); + dm.blitToScreen(bitmapIcon, 16, 0, 0, box2); if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 499ae9d697..40dc4f2066 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -195,7 +195,8 @@ void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { byte *srcBitmap = _vm->_displayMan->getBitmap(k42_ObjectIcons_000_TO_031 + i); iconIndex -= g26_IconGraphicFirstIndex[i]; _vm->_displayMan->_g578_useByteBoxCoordinates = true; - _vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, 0, 16, 0, 16, k255_ColorNoTransparency); + Box box(0, 0, 15, 15); + _vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, box, k255_ColorNoTransparency); } void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index f0d2bedf07..e4ce2cf019 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -60,7 +60,7 @@ public: IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex - void extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // F0036_OBJECT_ExtractIconFromBitmap + void extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // @ F0036_OBJECT_ExtractIconFromBitmap void drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox void drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName IconIndice getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index 67ac123a72..c313b1f29e 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -59,8 +59,11 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 if (nextY + k6_LetterHeight >= (viewport._posY + viewport._height)) break; uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code + + Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth, nextY, nextY + k6_LetterHeight); _vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth, - (nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight, k255_ColorNoTransparency, viewport); + box, k255_ColorNoTransparency, viewport); + nextX += k5_LetterWidth + 1; } } -- cgit v1.2.3 From ce1c52bceb661fafdd828bb89bdd34563a38124f Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 2 Jul 2016 23:10:05 +0200 Subject: DM: Remove blitToScreen overloads --- engines/dm/champion.cpp | 37 +++++++++++++++++---------- engines/dm/dm.cpp | 7 ++++-- engines/dm/dm.h | 3 +++ engines/dm/gfx.cpp | 65 +++++++++++++++++++++--------------------------- engines/dm/gfx.h | 24 +++--------------- engines/dm/inventory.cpp | 37 ++++++++++++++++----------- engines/dm/menus.cpp | 28 ++++++++++----------- engines/dm/objectman.cpp | 12 +++++---- engines/dm/text.cpp | 25 ++++++++----------- engines/dm/text.h | 8 +++--- 10 files changed, 122 insertions(+), 124 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index a708251a62..62fff7f7b3 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -751,7 +751,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { if (_g407_party._shieldDefense > 0) nativeBitmapIndices[AL_0_borderCount++] = k37_BorderPartyShieldIndice; while (AL_0_borderCount--) { - dispMan.blitToScreen(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, box, k10_ColorFlesh); + dispMan.blitToBitmap(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, + dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k10_ColorFlesh); } if (isInventoryChamp) { invMan.drawStatusBoxPortrait(champIndex); @@ -760,8 +761,9 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { champAttributes |= (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand); } } else { - dispMan.blitToScreen(dispMan.getBitmap(k8_StatusBoxDeadChampion), 80, 0, 0, box, k255_ColorNoTransparency); - _vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, champ->_name); + dispMan.blitToBitmap(dispMan.getBitmap(k8_StatusBoxDeadChampion), 80, 0, 0, + dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); + _vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, champ->_name); menuMan.drawActionIcon(champIndex); goto T0292042_green; } @@ -788,7 +790,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { box._x1 = champStatusBoxX; box._x2 = box._x1 + 42 + 1; dispMan.clearScreenBox(k1_ColorDarkGary, box); - _vm->_textMan->printTextToScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, k1_ColorDarkGary, champ->_name); + _vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, k1_ColorDarkGary, champ->_name); } } @@ -802,7 +804,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { } else { AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; } - dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxMouth, k12_ColorDarkestGray, g296_DungeonViewport); + dispMan.blitToBitmap(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, + dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, gBoxMouth, k12_ColorDarkestGray); AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; for (int16 AL_0_statisticIndex = k1_ChampionStatStrength; AL_0_statisticIndex <= k6_ChampionStatAntifire; AL_0_statisticIndex++) { if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent) @@ -811,7 +814,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { break; } } - dispMan.blitToScreen(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, gBoxEye, k12_ColorDarkestGray, g296_DungeonViewport); + dispMan.blitToBitmap(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, + dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, gBoxEye, k12_ColorDarkestGray); champAttributes |= k0x4000_ChampionAttributeViewport; } } @@ -854,8 +858,8 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) { dispMan.clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]); - dispMan.blitToScreen(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, - g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray); + dispMan.blitToBitmap(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, + dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray); } } @@ -881,7 +885,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { } if (champAttributes & k0x4000_ChampionAttributeViewport) { - warning("MISSGIN CODE: F0097_DUNGEONVIEW_DrawViewport"); + dispMan.f97_drawViewport(k0_viewportNotDungeonView); } @@ -975,8 +979,13 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { if (nativeBitmapIndex != -1) { _vm->_displayMan->_g578_useByteBoxCoordinates = false; - _vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0, - box, k12_ColorDarkestGray, isInventoryChamp ? g296_DungeonViewport : gDefultViewPort); + if (isInventoryChamp) { + _vm->_displayMan->blitToBitmap(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0, + _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, box, k12_ColorDarkestGray); + } else { + _vm->_displayMan->blitToBitmap(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0, + _vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, box, k12_ColorDarkestGray); + } } _vm->_objectMan->drawIconInSlotBox(slotBoxIndex, iconIndex); @@ -998,8 +1007,9 @@ void ChampionMan::renameChampion(Champion* champ) { box._x1 = 3; box._x2 = box._x1 + 167; - dispMan.clearScreenBox(k12_ColorDarkestGray, box, g296_DungeonViewport); - dispMan.blitToScreen(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, g32_BoxPanel, k4_ColorCyan, g296_DungeonViewport); + dispMan.f135_fillBoxBitmap(dispMan._g296_bitmapViewport, box, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport); + dispMan.blitToBitmap(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, + dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k4_ColorCyan); textMan.printToViewport(177, 58, k13_ColorLightestGray, "_______"); textMan.printToViewport(105, 76, k13_ColorLightestGray, "___________________"); Common::Point clickPos; @@ -1009,6 +1019,7 @@ void ChampionMan::renameChampion(Champion* champ) { if (_vm->_eventMan->hasPendingClick(clickPos, k1_LeftMouseButton) && okButtonBox.isPointInside(clickPos)) { return; } + dispMan.f97_drawViewport(k0_viewportNotDungeonView); dispMan.updateScreen(); } } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index ec455c44f0..f7e9e8fbbd 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -263,11 +263,14 @@ void DMEngine::gameloop() { if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { Box box(0, 224, 0, 126); - _displayMan->clearScreenBox(k0_ColorBlack, box, g296_DungeonViewport); // dummy code + _displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport * 2, k136_heightViewport); // dummy code _displayMan->drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); } - // DUMMY CODE: next line + + // DUMMY CODE: next 2 lines _menuMan->drawMovementArrows(); + _displayMan->f97_drawViewport(k1_viewportDungeonView); + _displayMan->updateScreen(); _system->delayMillis(10); } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index d439cfadae..7837ac4716 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -96,6 +96,9 @@ enum Cell { k3_CellSouthWest = 3 // @ C03_CELL_SOUTHWEST }; +#define kM1_mapIndexNone -1 // @ CM1_MAP_INDEX_NONE +#define k255_mapIndexEntrance 255 // @ C255_MAP_INDEX_ENTRANCE + class Thing { uint16 _data; public: diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index d41bf4900a..f430222d30 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -577,8 +577,6 @@ byte g222_PalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, -Viewport gDefultViewPort(0, 0, 320, 200); -Viewport g296_DungeonViewport(0, 33, 224, 136); // @ G0296_puc_Bitmap_Viewport byte g17_PalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges @@ -955,7 +953,7 @@ void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* to void DisplayMan::f566_viewportBlitToScreen() { warning("MISSING FUNCTIONALITY: using correct colorpalette"); - Box box(0, 33, 223, 135); + Box box(0, 223, 33, 33 + 135); blitToBitmap(_g296_bitmapViewport, k112_byteWidthViewport * 2, 0, 0, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); } @@ -1020,12 +1018,12 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { } -void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent, Viewport& viewport) { +void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent) { for (uint16 y = 0; y < box._y2 - box._y1; ++y) for (uint16 x = 0; x < box._x2 - box._x1; ++x) { byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x]; if (srcPixel != transparent) - destBitmap[destWidth * (y + box._y1 + viewport._posY) + box._x1 + x + viewport._posX] = srcPixel; + destBitmap[destWidth * (y + box._y1) + box._x1 + x] = srcPixel; } } @@ -1035,30 +1033,24 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight memcpy(destBitmap + destWidth*(y + destY) + destX, srcBitmap + y * srcWidth, sizeof(byte)* srcWidth); } -void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) { +void DisplayMan::clearScreenBox(Color color, Box &box) { uint16 width = box._x2 - box._x1; - for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y) - memset(_g348_bitmapScreen + y * _screenWidth + box._x1 + viewport._posX, color, sizeof(byte) * width); + for (int16 y = box._y1; y < box._y2; ++y) + memset(_g348_bitmapScreen + y * _screenWidth + box._x1, color, sizeof(byte) * width); } -void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, - Box &box, - Color transparent, Viewport &viewport) { - blitToBitmap(srcBitmap, srcWidth, srcX, srcY, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, transparent, viewport); +void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int16 pixelWidth, int16 height) { + for (int16 y = box._y1; y < box._y2; ++y) + memset(destBitmap + y * pixelWidth + box._x1, color, sizeof(byte) * (box._x2 - box._x1)); } void DisplayMan::blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, - int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport) { + int16 xPos, int16 yPos, int16 destHeight, int16 height2) { warning("STUB FUNCTION: does nothing at all"); } -void DisplayMan::blitBoxFilledWithMaskedBitmapToScreen(byte* src, byte* mask, byte* tmp, Box& box, - int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, - int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport& viewport) { - blitBoxFilledWithMaskedBitmap(src, _g348_bitmapScreen, mask, tmp, box, lastUnitIndex, firstUnitIndex, _screenWidth, transparent, xPos, yPos, _screenHeight, height2, viewport); -} void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) { for (uint16 y = 0; y < height; ++y) { @@ -1166,12 +1158,12 @@ void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitm void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { if (f._srcWidth) - blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k255_ColorNoTransparency, g296_DungeonViewport); + blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k255_ColorNoTransparency); } void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) { if (f._srcWidth) - blitToScreen(bitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, g296_DungeonViewport); + blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh); } @@ -1578,6 +1570,7 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { } delete[] tmpBitmap; + f97_drawViewport((_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0); } void DisplayMan::clearScreen(Color color) { @@ -1752,16 +1745,15 @@ void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor } void DisplayMan::drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) { - if (f._srcWidth) { - blitToScreen(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, g296_DungeonViewport); - } + if (f._srcWidth) + blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh); } void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) { if (f._srcWidth) { blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcHeight, _g74_tmpBitmap, f._srcWidth); flipBitmapHorizontal(_g74_tmpBitmap, f._srcWidth, f._srcHeight); - blitToScreen(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, f._box, k10_ColorFlesh, g296_DungeonViewport); + blitToBitmap(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh); } } @@ -1826,7 +1818,8 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex if (viewWallIndex == k12_ViewWall_D1C_FRONT) { if (isInscription) { Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C]; - blitToScreen(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, g202_BoxWallPatchBehindInscription, k255_ColorNoTransparency, g296_DungeonViewport); + blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, _g296_bitmapViewport, k112_byteWidthViewport * 2, + g202_BoxWallPatchBehindInscription, k255_ColorNoTransparency); unsigned char *string = inscriptionString; bitmapRed = _bitmaps[k120_InscriptionFontIndice]; @@ -1840,7 +1833,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7; frame._box._y1 = (frame._box._y2 = g203_InscriptionLineY[textLineIndex++]) - 7; while (characterCount--) { - blitToScreen(bitmapRed, 288, (*string++) * 8, 0, frame._box, k10_ColorFlesh, g296_DungeonViewport); + blitToBitmap(bitmapRed, 288, (*string++) * 8, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, frame._box, k10_ColorFlesh); frame._box._x1 += 8; frame._box._x2 += 8; } @@ -1929,12 +1922,12 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1]; } } - blitToScreen(bitmapGreen, coordinateSetA[4], var_X, 0, *(Box*)coordinateSetA, k10_ColorFlesh, g296_DungeonViewport); + blitToBitmap(bitmapGreen, coordinateSetA[4], var_X, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, *(Box*)coordinateSetA, k10_ColorFlesh); if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { Box &box = g109_BoxChampionPortraitOnWall; - blitToScreen(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29, - box, k1_ColorDarkGary, g296_DungeonViewport); + blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29, + _g296_bitmapViewport, k112_byteWidthViewport * 2, box, k1_ColorDarkGary); } return isAlcove; } @@ -2441,7 +2434,7 @@ T0115015_DrawProjectileAsObject: AL_6_bitmapRedBanana = bitmapGreenAnt; dunMan._g292_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */ } - blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, g296_DungeonViewport); + blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh); if (drawProjectileAsObject) goto T0115171_BackFromT0115015_DrawProjectileAsObject; @@ -2692,7 +2685,7 @@ T0115077_DrawSecondHalfSquareCreature: AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1); } warning("SUPER WARNINIG: we might nee noralized with on byteWidth"); - blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, boxByteGreen, (Color)transparentColor, g296_DungeonViewport); + blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, (Color)transparentColor); T0115126_CreatureNotVisible: if (twoHalfSquareCreaturesFrontView) { @@ -2827,7 +2820,7 @@ the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */ AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1)); } - blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, g296_DungeonViewport); + blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh); } else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */ useAlcoveObjectImage = false; projectileCoordinates[0] = projectilePosX; @@ -2914,9 +2907,9 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _g74_tmpBitmap, 48, 32, g212_PalChangeSmoke); AL_6_bitmapRedBanana = _g74_tmpBitmap; } - blitBoxFilledWithMaskedBitmapToScreen(AL_6_bitmapRedBanana, nullptr, getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C, - _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64), - 224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93); + blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C, + _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64), + 224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } else { @@ -2979,7 +2972,7 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP if (flipVertical) { flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } - blitToScreen(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, boxByteGreen, k10_ColorFlesh, g296_DungeonViewport); + blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh); } } } while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList); diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 60f6cdb630..7166908b83 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -321,14 +321,6 @@ public: }; // @ FIELD_ASPECT -class Viewport { -public: - uint16 _posX, _posY; - uint16 _width, _height; - Viewport() {} - Viewport(uint16 posX, uint16 posY, uint16 width, uint16 height) - :_posX(posX), _posY(posY), _width(width), _height(height) {} -}; class CreatureAspect { public: @@ -398,9 +390,6 @@ public: byte _D3ReplacementColor; }; // @ CREATURE_REPLACEMENT_COLOR_SET -extern Viewport gDefultViewPort; -extern Viewport g296_DungeonViewport; - #define k0_DoorButton 0 // @ C0_DOOR_BUTTON #define k0_WallOrnInscription 0 // @ C0_WALL_ORNAMENT_INSCRIPTION @@ -559,20 +548,14 @@ public: void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, - byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort); + byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency); void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0); void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, - int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = gDefultViewPort); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap + int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap void blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight, byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges - void blitBoxFilledWithMaskedBitmapToScreen(byte *src, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, - int16 firstUnitIndex, int16 destPixelWidth, Color transparent, - int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = g296_DungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap - void blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, - Box &box, - Color transparent = k255_ColorNoTransparency, Viewport &viewport = gDefultViewPort); void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); @@ -580,7 +563,8 @@ public: void f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color); // @ F0134_VIDEO_FillBitmap void clearScreen(Color color); - void clearScreenBox(Color color, Box &box, Viewport &viewport = gDefultViewPort); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox + void clearScreenBox(Color color, Box &box); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox + void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 pixelWidth, int16 height); void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 04554691ba..8118356bd0 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -96,7 +96,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { champion = &cm._champions[championIndex]; dm.loadIntoBitmap(k17_InventoryGraphicIndice, dm._g296_bitmapViewport); if (cm._g299_candidateChampionOrdinal) { - dm.clearScreenBox(k12_ColorDarkestGray, g41_BoxFloppyZzzCross, g296_DungeonViewport); + dm.f135_fillBoxBitmap(dm._g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport); } _vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "HEALTH"); _vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "STAMINA"); @@ -128,7 +128,8 @@ void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) { box._y2 = 28 + 1; box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7; box._x2 = box._x1 + 31 + 1; - dispMan.blitToScreen(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0, box, k255_ColorNoTransparency); + dispMan.blitToBitmap(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0, + dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); } void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) { @@ -161,11 +162,15 @@ void InventoryMan::drawPanelFoodWaterPoisoned() { Champion &champ = _vm->_championMan->_champions[_g432_inventoryChampionOrdinal]; closeChest(); DisplayMan &dispMan = *_vm->_displayMan; - dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed); - dispMan.blitToScreen(dispMan.getBitmap(k30_FoodLabelIndice), 48, 0, 0, g35_BoxFood, k12_ColorDarkestGray); - dispMan.blitToScreen(dispMan.getBitmap(k31_WaterLabelIndice), 48, 0, 0, g36_BoxWater, k12_ColorDarkestGray); + dispMan.blitToBitmap(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, + dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g32_BoxPanel, k8_ColorRed); + dispMan.blitToBitmap(dispMan.getBitmap(k30_FoodLabelIndice), 48, 0, 0, + dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g35_BoxFood, k12_ColorDarkestGray); + dispMan.blitToBitmap(dispMan.getBitmap(k31_WaterLabelIndice), 48, 0, 0, + dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g36_BoxWater, k12_ColorDarkestGray); if (champ._poisonEventCount) { - dispMan.blitToScreen(dispMan.getBitmap(k32_PoisionedLabelIndice), 96, 0, 0, g37_BoxPoisoned, k12_ColorDarkestGray); + dispMan.blitToBitmap(dispMan.getBitmap(k32_PoisionedLabelIndice), 96, 0, 0, + dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g37_BoxPoisoned, k12_ColorDarkestGray); } drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown); drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue); @@ -173,7 +178,8 @@ void InventoryMan::drawPanelFoodWaterPoisoned() { void InventoryMan::drawPanelResurrectReincarnate() { _g424_panelContent = k5_PanelContentResurrectReincarnate; - _vm->_displayMan->blitToScreen(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, g32_BoxPanel, k6_ColorDarkGreen, g296_DungeonViewport); + _vm->_displayMan->blitToBitmap(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, + _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k6_ColorDarkGreen); } void InventoryMan::drawPanel() { @@ -256,7 +262,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) { charRed++; } *charRed = '\0'; - dispMan.blitToScreen(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed, g296_DungeonViewport); + dispMan.blitToBitmap(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k8_ColorRed); int16 lineCount = 1; charRed++; char *charGreen = charRed; // first char of the second line @@ -308,7 +314,7 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is if (!isPressingEye) { objMan.drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen); } - dispMan.blitToScreen(dispMan.getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed); + dispMan.blitToBitmap(dispMan.getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g32_BoxPanel, k8_ColorRed); int16 chestSlotIndex = 0; Thing thing = chest->getSlot(); @@ -334,7 +340,8 @@ void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yP box._x2 = (box._x1 = xPos) + 15 + 1; box._y2 = (box._y1 = yPos) + 15 + 1; _vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap); - _vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, k255_ColorNoTransparency, g296_DungeonViewport); + _vm->_displayMan->blitToBitmap(iconBitmap, 16, 0, 0, _vm->_displayMan->_g296_bitmapViewport, + k112_byteWidthViewport * 2, box, k255_ColorNoTransparency); } void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) { @@ -408,8 +415,8 @@ Box g33_BoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOr void InventoryMan::drawPanelArrowOrEye(bool pressingEye) { DisplayMan &dispMan = *_vm->_displayMan; - dispMan.blitToScreen(dispMan.getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice), - 16, 0, 0, g33_BoxArrowOrEye, k8_ColorRed, g296_DungeonViewport); + dispMan.blitToBitmap(dispMan.getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice), + 16, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g33_BoxArrowOrEye, k8_ColorRed); } @@ -441,8 +448,10 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye); } else { IconIndice iconIndex = objMan.getIconIndex(thingToDraw); - dispMan.blitToScreen(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, g32_BoxPanel, k8_ColorRed, g296_DungeonViewport); - dispMan.blitToScreen(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, g34_BoxObjectDescCircle, k12_ColorDarkestGray, g296_DungeonViewport); + dispMan.blitToBitmap(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, + dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k8_ColorRed); + dispMan.blitToBitmap(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, + dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g34_BoxObjectDescCircle, k12_ColorDarkestGray); char *descString = nullptr; char str[40]; diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index b2ad003739..a512a90d07 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -64,7 +64,7 @@ void MenuMan::drawMovementArrows() { Box &dest = g2_BoxMovementArrows; uint16 w = disp.getWidth(k13_MovementArrowsIndice); - disp.blitToScreen(arrowsBitmap, w, 0, 0, dest, k255_ColorNoTransparency); + disp.blitToBitmap(arrowsBitmap, w, 0, 0, disp._g348_bitmapScreen, k160_byteWidthScreen * 2, dest, k255_ColorNoTransparency); } void MenuMan::clearActingChampion() { ChampionMan &cm = *_vm->_championMan; @@ -113,7 +113,7 @@ T0386006: box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that box2._y1 = 95; box2._y2 = 110 + 1; - dm.blitToScreen(bitmapIcon, 16, 0, 0, box2); + dm.blitToBitmap(bitmapIcon, 16, 0, 0, dm._g348_bitmapScreen, k160_byteWidthScreen * 2, box2); if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } @@ -208,13 +208,13 @@ void MenuMan::drawActionArea() { box = g500_BoxActionArea2ActionMenu; if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone) box = g501_BoxActionArea1ActionMenu; - dispMan.blitToScreen(dispMan.getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, box, k255_ColorNoTransparency); - textMan.printWithTrailingSpacesToScreen(235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name, - k7_ChampionNameMaximumLength); + dispMan.blitToBitmap(dispMan.getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); + textMan.printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name, + k7_ChampionNameMaximumLength, k200_heightScreen); for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) { - textMan.printWithTrailingSpacesToScreen(241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack, + textMan.printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack, getActionName(_g713_actionList._actionIndices[actionListIndex]), - k12_ActionNameMaximumLength); + k12_ActionNameMaximumLength, k200_heightScreen); } } warning("MISSING CODE: F0078_MOUSE_ShowPointer"); @@ -253,7 +253,7 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) { switch (champIndex) { case k0_ChampionFirst: warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); - textMan.printTextToScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ._name); + textMan.f53_printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ._name); if (champCount) { if (champCurrHealth[1]) { warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); @@ -277,7 +277,7 @@ labelChamp3: warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); } warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); - textMan.printTextToScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ._name); + textMan.f53_printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ._name); goto labelChamp2; case k2_ChampionThird: if (champCurrHealth[0]) { @@ -287,7 +287,7 @@ labelChamp3: warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); } warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); - textMan.printTextToScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ._name); + textMan.f53_printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ._name); goto labelChamp3; case k3_ChampionFourth: if (champCurrHealth[0]) { @@ -300,7 +300,7 @@ labelChamp3: warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); } warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); - textMan.printTextToScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ._name); + textMan.f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ._name); break; } warning("MISSING CODE: F0078_MOUSE_ShowPointer"); @@ -345,7 +345,7 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) { return; if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) { warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan.blitToScreen(dispMan.getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, g0_BoxSpellArea); + dispMan.blitToBitmap(dispMan.getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g0_BoxSpellArea); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } if (champIndex == kM1_ChampionNone) { @@ -361,9 +361,9 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) { buildSpellAreaLine(k2_SpellAreaAvailableSymbols); warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); drawSpellAreaControls((ChampionIndex)champIndex); - dispMan.blitToScreen(_gK72_bitmapSpellAreaLine, 96, 0, 0, gK75_BoxSpellAreaLine2); + dispMan.blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK75_BoxSpellAreaLine2); buildSpellAreaLine(k3_SpellAreaChampionSymbols); - dispMan.blitToScreen(_gK72_bitmapSpellAreaLine, 96, 0, 0, gK76_BoxSpellAreaLine3); + dispMan.blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK76_BoxSpellAreaLine3); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } } diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 40dc4f2066..2ce67ace6a 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -224,11 +224,12 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { _vm->_displayMan->_g578_useByteBoxCoordinates = false; if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) { - _vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, - box, k255_ColorNoTransparency, g296_DungeonViewport); + _vm->_displayMan->blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, + _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, box, k255_ColorNoTransparency); + } else { - _vm->_displayMan->blitToScreen(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, - box, k255_ColorNoTransparency, gDefultViewPort); + _vm->_displayMan->blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, + _vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); } } @@ -246,7 +247,8 @@ void ObjectMan::drawLeaderObjectName(Thing thing) { } else { objName = _g352_objectNames[iconIndex]; } - _vm->_textMan->printWithTrailingSpacesToScreen(233, 37, k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength); + _vm->_textMan->printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, 233, 37, + k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength, k200_heightScreen); } IconIndice ObjectMan::getIconIndexInSlotBox(uint16 slotBoxIndex) { diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index c313b1f29e..ebda26850d 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -36,7 +36,7 @@ TextMan::TextMan(DMEngine* vm) : _vm(vm) {} #define k6_LetterHeight 6 void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, - Color textColor, Color bgColor, const char* text, uint16 destHeight, Viewport &viewport) { + Color textColor, Color bgColor, const char* text, uint16 destHeight) { destX -= 1; // fixes missalignment, to be checked destY -= 4; // fixes missalignment, to be checked @@ -52,41 +52,36 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 srcBitmap = tmp; for (const char *begin = text, *end = text + textLength; begin != end; ++begin) { - if (nextX + k5_LetterWidth + 1 >= (viewport._posX + viewport._width) || (*begin == '\n')) { + if (nextX + k5_LetterWidth + 1 >= destPixelWidth || (*begin == '\n')) { nextX = destX; nextY += k6_LetterHeight + 1; } - if (nextY + k6_LetterHeight >= (viewport._posY + viewport._height)) + if (nextY + k6_LetterHeight >= destHeight) break; uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code - Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth, nextY, nextY + k6_LetterHeight); + Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1); _vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth, - box, k255_ColorNoTransparency, viewport); + box, k255_ColorNoTransparency); nextX += k5_LetterWidth + 1; } } -void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text, Viewport &viewport) { - printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport); +void TextMan::f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text) { + printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight); } void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) { - printTextToScreen(posX, posY, textColor, bgColor, text, g296_DungeonViewport); + printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, posX, posY, textColor, bgColor, text, k200_heightScreen); } void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, - Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight, Viewport& viewport) { + Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) { Common::String str = text; for (int16 i = str.size(); i < requiredTextLength; ++i) str += ' '; - printTextToBitmap(destBitmap, destPixelWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight, viewport); -} - -void TextMan::printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor, const char* text, int16 strLenght, Viewport& viewport) { - printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, - textColor, bgColor, text, strLenght, _vm->_displayMan->_screenHeight, viewport); + printTextToBitmap(destBitmap, destPixelWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight); } } diff --git a/engines/dm/text.h b/engines/dm/text.h index 48c2d6e7f9..c71f196658 100644 --- a/engines/dm/text.h +++ b/engines/dm/text.h @@ -38,13 +38,11 @@ class TextMan { public: explicit TextMan(DMEngine *vm); void printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, - Color textColor, Color bgColor, const char *text, uint16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0040_TEXT_Print - void printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, Viewport &viewport = gDefultViewPort); // @ F0053_TEXT_PrintToLogicalScreen + Color textColor, Color bgColor, const char *text, uint16 destHeight); // @ F0040_TEXT_Print + void f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text); // @ F0053_TEXT_PrintToLogicalScreen void printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport void printWithTrailingSpaces(byte *destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor, - const char *text, int16 strLenght, int16 destHeight, Viewport &viewport = gDefultViewPort); // @ F0041_TEXT_PrintWithTrailingSpaces - void printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor, - const char *text, int16 strLenght, Viewport &viewport = gDefultViewPort); // @ F0041_TEXT_PrintWithTrailingSpaces + const char *text, int16 strLenght, int16 destHeight); // @ F0041_TEXT_PrintWithTrailingSpaces }; } -- cgit v1.2.3 From 31b10d6d0d416658ef12416fb134e85adec7ac56 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 2 Jul 2016 23:50:17 +0200 Subject: DM: Remove blitToBitmap overload --- engines/dm/gfx.cpp | 57 +++++++++++++++++++----------------------------------- engines/dm/gfx.h | 1 - 2 files changed, 20 insertions(+), 38 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index f430222d30..18deb969cd 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1028,11 +1028,6 @@ void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uin } -void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX, uint16 destY) { - for (uint16 y = 0; y < srcHeight; ++y) - memcpy(destBitmap + destWidth*(y + destY) + destX, srcBitmap + y * srcWidth, sizeof(byte)* srcWidth); -} - void DisplayMan::clearScreenBox(Color color, Box &box) { uint16 width = box._x2 - box._x1; for (int16 y = box._y1; y < box._y2; ++y) @@ -1067,9 +1062,9 @@ void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) { byte *tmp = new byte[width]; for (uint16 y = 0; y < height / 2; ++y) { - memcpy(tmp, bitmap + y * width, width); - memcpy(bitmap + y * width, bitmap + (height - 1 - y) * width, width); - memcpy(bitmap + (height - 1 - y) * width, tmp, width); + memmove(tmp, bitmap + y * width, width); + memmove(bitmap + y * width, bitmap + (height - 1 - y) * width, width); + memmove(bitmap + (height - 1 - y) * width, tmp, width); } delete[] tmp; @@ -1152,7 +1147,7 @@ uint16 DisplayMan::getHeight(uint16 index) { // Note: has been screened for missing code void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 pixelWidth, uint16 height) { - memcpy(destBitmap, srcBitmap, pixelWidth * height * sizeof(byte)); + memmove(destBitmap, srcBitmap, pixelWidth * height * sizeof(byte)); flipBitmapHorizontal(destBitmap, pixelWidth, height); } @@ -1247,7 +1242,7 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { case k17_ElementTypeDoorFront: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); - memcpy(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44); + memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44); warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally"); if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton"); @@ -1488,9 +1483,6 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { // TODO: this is a global variable, set from here bool flippedFloorCeiling = true; - // NOTE: this can hold every bitmap, width and height is "flexible" - byte *tmpBitmap = new byte[305 * 111]; - f134_fillBitmap(tmpBitmap, 305, 111, k10_ColorFlesh); for (int16 i = 0; i < 6; ++i) _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i].setToZero(); @@ -1500,11 +1492,9 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { } if (_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1) { - uint16 w = gK13_FloorFrame._srcWidth, h = gK13_FloorFrame._srcHeight; - blitToBitmap(_g84_bitmapFloor, w, h, tmpBitmap, w); - flipBitmapHorizontal(tmpBitmap, w, h); - drawWallSetBitmap(tmpBitmap, gK13_FloorFrame); drawWallSetBitmap(_g85_bitmapCeiling, gK12_CeilingFrame); + f99_copyBitmapAndFlipHorizontal(_g84_bitmapFloor, _g74_tmpBitmap, k112_byteWidthViewport * 2, 70); + drawWallSetBitmap(_g74_tmpBitmap, gK13_FloorFrame); if (flippedFloorCeiling) { _g698_bitmapWallSet_Wall_D3LCR = _g90_bitmapWall_D3LCR_Flipped; @@ -1514,10 +1504,8 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { _g702_bitmapWallSet_Wall_D0R = _g94_bitmapWall_D0R_Flipped; } } else { - uint16 w = gK12_CeilingFrame._srcWidth, h = gK12_CeilingFrame._srcHeight; - blitToBitmap(_g85_bitmapCeiling, w, h, tmpBitmap, w); - flipBitmapHorizontal(tmpBitmap, w, h); - drawWallSetBitmap(tmpBitmap, gK12_CeilingFrame); + f99_copyBitmapAndFlipHorizontal(_g85_bitmapCeiling, _g74_tmpBitmap, k112_byteWidthViewport * 2, 29); + drawWallSetBitmap(_g74_tmpBitmap, gK12_CeilingFrame); drawWallSetBitmap(_g84_bitmapFloor, gK13_FloorFrame); } @@ -1569,7 +1557,6 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { _g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native; } - delete[] tmpBitmap; f97_drawViewport((_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0); } @@ -1751,8 +1738,7 @@ void DisplayMan::drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) { void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) { if (f._srcWidth) { - blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcHeight, _g74_tmpBitmap, f._srcWidth); - flipBitmapHorizontal(_g74_tmpBitmap, f._srcWidth, f._srcHeight); + f99_copyBitmapAndFlipHorizontal(getBitmap(nativeIndex), _g74_tmpBitmap, f._srcWidth, f._srcHeight); blitToBitmap(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh); } } @@ -1859,8 +1845,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex } bitmapGreen = _bitmaps[nativeBitmapIndex]; if (viewWallIndex == k11_ViewWall_D1R_LEFT) { - blitToBitmap(bitmapGreen, coordinateSetA[4], coordinateSetA[5], _g74_tmpBitmap, coordinateSetA[4]); - flipBitmapHorizontal(_g74_tmpBitmap, coordinateSetA[4], coordinateSetA[5]); + f99_copyBitmapAndFlipHorizontal(bitmapGreen, _g74_tmpBitmap, coordinateSetA[4], coordinateSetA[5]); bitmapGreen = _g74_tmpBitmap; } var_X = 0; @@ -1888,9 +1873,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex bitmapGreen = _bitmaps[nativeBitmapIndex]; var_X = pixelWidth; if (flipHorizontal) { - if (bitmapGreen != _g74_tmpBitmap) - blitToBitmap(bitmapGreen, coordSetB[4], coordSetB[5], _g74_tmpBitmap, coordSetB[4]); - flipBitmapHorizontal(_g74_tmpBitmap, coordSetB[4], coordSetB[5]); + f99_copyBitmapAndFlipHorizontal(bitmapGreen, _g74_tmpBitmap, coordSetB[4], coordSetB[5]); bitmapGreen = _g74_tmpBitmap; var_X = 15 - (var_X & 0xF); } else if (viewWallIndex == k7_ViewWall_D2L_FRONT) { @@ -1975,7 +1958,7 @@ void DisplayMan::drawField(FieldAspect* fieldAspect, Box& box) { bitmapMask = nullptr; } else { bitmapMask = dispMan._g74_tmpBitmap; - memcpy(bitmapMask, dispMan.getBitmap(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)), + memmove(bitmapMask, dispMan.getBitmap(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)), fieldAspect->_height * fieldAspect->_pixelWidth * sizeof(bitmapMask[0])); if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) { dispMan.flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height); @@ -2345,7 +2328,7 @@ T0115015_DrawProjectileAsObject: byteWidth = objectAspect->_width; heightRedEagle = objectAspect->_height; if (flipHorizontal) { - memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); + memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; } @@ -2590,7 +2573,7 @@ T0115077_DrawSecondHalfSquareCreature: if (useCreatureSideBitmap) { AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); if (creatureDirectionDelta == 1) { - memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); + memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; } @@ -2598,7 +2581,7 @@ T0115077_DrawSecondHalfSquareCreature: if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) { AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) { - memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); + memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; } @@ -2609,7 +2592,7 @@ T0115077_DrawSecondHalfSquareCreature: bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex); if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) { AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); - memcpy(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * heightRedEagle * sizeof(byte)); + memmove(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * heightRedEagle * sizeof(byte)); flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); @@ -2652,7 +2635,7 @@ T0115077_DrawSecondHalfSquareCreature: AL_4_normalizdByteWidth = byteWidth; warning("SUPER WARNING: we might need getNormalizedByteWidthM77"); if (!useFlippedHorizontallyCreatureFrontImage) { - memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte)); + memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte)); AL_6_bitmapRedBanana = _g74_tmpBitmap; } flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); @@ -2794,7 +2777,7 @@ continue; warning("might need noralized bytewidth"); AL_4_normalizdByteWidth = byteWidth; if (AL_6_bitmapRedBanana != _g74_tmpBitmap) { - memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte)); + memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte)); AL_6_bitmapRedBanana = _g74_tmpBitmap; } if (flipVertical) { @@ -2963,7 +2946,7 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP warning("might need M77_NORMALIZED_BYTE_WIDTH"); byteWidth = byteWidth; if (flipHorizontal || flipVertical) { - memcpy(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle); + memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; } if (flipHorizontal) { diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 7166908b83..df48bec0ea 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -550,7 +550,6 @@ public: void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency); - void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight, byte *destBitmap, uint16 destWidth, uint16 destX = 0, uint16 destY = 0); void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap -- cgit v1.2.3 From d69236e67430ffe1e5ac07abc2015f6bbf36d580 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:47:44 +0200 Subject: DM: Rename functions --- engines/dm/champion.cpp | 258 ++++++++++----------- engines/dm/champion.h | 50 ++--- engines/dm/dm.cpp | 50 ++--- engines/dm/dm.h | 12 +- engines/dm/dungeonman.cpp | 134 +++++------ engines/dm/dungeonman.h | 50 ++--- engines/dm/eventman.cpp | 136 +++++------ engines/dm/eventman.h | 24 +- engines/dm/gfx.cpp | 558 +++++++++++++++++++++++----------------------- engines/dm/gfx.h | 90 ++++---- engines/dm/group.cpp | 24 +- engines/dm/group.h | 10 +- engines/dm/inventory.cpp | 178 +++++++-------- engines/dm/inventory.h | 32 +-- engines/dm/loadsave.cpp | 12 +- engines/dm/loadsave.h | 2 +- engines/dm/menus.cpp | 104 ++++----- engines/dm/menus.h | 20 +- engines/dm/movesens.cpp | 24 +- engines/dm/movesens.h | 2 +- engines/dm/objectman.cpp | 36 +-- engines/dm/objectman.h | 12 +- engines/dm/text.cpp | 16 +- engines/dm/text.h | 6 +- engines/dm/timeline.cpp | 2 +- engines/dm/timeline.h | 2 +- 26 files changed, 922 insertions(+), 922 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 62fff7f7b3..7986650644 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -93,22 +93,22 @@ Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_Champi ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { _g411_leaderIndex = kM1_ChampionNone; - _303_partyDead = false; + _g303_partyDead = false; _g300_partyIsSleeping = false; _g413_leaderHandObjectIconIndex = kM1_IconIndiceNone; _g415_leaderEmptyHanded = true; _g514_magicCasterChampionIndex = kM1_ChampionNone; } -uint16 ChampionMan::getChampionPortraitX(uint16 index) { +uint16 ChampionMan::M27_getChampionPortraitX(uint16 index) { return ((index) & 0x7) << 5; } -uint16 ChampionMan::getChampionPortraitY(uint16 index) { +uint16 ChampionMan::M28_getChampionPortraitY(uint16 index) { return ((index) >> 3) * 29; } -int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) { +int16 ChampionMan::f279_getDecodedValue(char *string, uint16 characterCount) { int val = 0; for (uint16 i = 0; i < characterCount; ++i) { val = (val << 4) + (string[i] - 'A'); @@ -116,19 +116,19 @@ int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) { return val; } -void ChampionMan::drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) { - Common::String tmp = getStringFromInteger(currVal, true, 3).c_str(); - _vm->_textMan->printToViewport(55, posY, k13_ColorLightestGray, tmp.c_str()); - _vm->_textMan->printToViewport(73, posY, k13_ColorLightestGray, "/"); - tmp = getStringFromInteger(maxVal, true, 3); - _vm->_textMan->printToViewport(79, posY, k13_ColorLightestGray, tmp.c_str()); +void ChampionMan::f289_drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) { + Common::String tmp = f288_getStringFromInteger(currVal, true, 3).c_str(); + _vm->_textMan->f52_printToViewport(55, posY, k13_ColorLightestGray, tmp.c_str()); + _vm->_textMan->f52_printToViewport(73, posY, k13_ColorLightestGray, "/"); + tmp = f288_getStringFromInteger(maxVal, true, 3); + _vm->_textMan->f52_printToViewport(79, posY, k13_ColorLightestGray, tmp.c_str()); } -uint16 ChampionMan::handSlotIndex(uint16 slotBoxIndex) { +uint16 ChampionMan::M70_handSlotIndex(uint16 slotBoxIndex) { return slotBoxIndex & 0x1; } -Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) { +Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) { using namespace Common; String valToStr = String::format("%d", val); String result; @@ -138,15 +138,15 @@ Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint1 return result += valToStr; } -void ChampionMan::applyModifiersToStatistics(Champion* champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing) { +void ChampionMan::f299_pplyModifiersToStatistics(Champion* champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing) { int16 statIndex; int16 modifier = 0; ThingType thingType = thing.getType(); if (((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType)) && (slotIndex >= k0_ChampionSlotReadyHand) && (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) { - Weapon *weapon = (Weapon*)_vm->_dungeonMan->getThingData(thing); - Armour *armour = (Armour*)_vm->_dungeonMan->getThingData(thing); + Weapon *weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(thing); + Armour *armour = (Armour*)_vm->_dungeonMan->f156_getThingData(thing); if (((thingType == k5_WeaponThingType) && weapon->getCursed()) || ((thingType == k6_ArmourThingType) && armour->getCursed())) { statIndex = k0_ChampionStatLuck; @@ -273,20 +273,20 @@ T0299044_ApplyModifier: } -bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) { +bool ChampionMan::f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) { ObjectMan &objMan = *_vm->_objectMan; - IconIndice currIconIndex = objMan.getIconIndexInSlotBox(slotBoxIndex); + IconIndice currIconIndex = objMan.f39_getIconIndexInSlotBox(slotBoxIndex); if (((currIconIndex < k32_IconIndiceWeaponDagger) && (currIconIndex >= k0_IconIndiceJunkCompassNorth)) || ((currIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (currIconIndex <= k163_IconIndicePotionWaterFlask)) || (currIconIndex == k195_IconIndicePotionEmptyFlask)) { - IconIndice newIconIndex = objMan.getIconIndex(thing); + IconIndice newIconIndex = objMan.f33_getIconIndex(thing); if (newIconIndex != currIconIndex) { if ((slotBoxIndex < k8_SlotBoxInventoryFirstSlot) && !_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) { _g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); } - objMan.drawIconInSlotBox(slotBoxIndex, newIconIndex); + objMan.f38_drawIconInSlotBox(slotBoxIndex, newIconIndex); return true; } } @@ -294,7 +294,7 @@ bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) return false; } -void ChampionMan::drawChangedObjectIcons() { +void ChampionMan::f296_drawChangedObjectIcons() { InventoryMan &invMan = *_vm->_inventoryMan; ObjectMan &objMan = *_vm->_objectMan; MenuMan &menuMan = *_vm->_menuMan; @@ -309,52 +309,52 @@ void ChampionMan::drawChangedObjectIcons() { if (((leaderHandObjIconIndex < k32_IconIndiceWeaponDagger) && (leaderHandObjIconIndex >= k0_IconIndiceJunkCompassNorth)) // < instead of <= is correct || ((leaderHandObjIconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= k163_IconIndicePotionWaterFlask)) || (leaderHandObjIconIndex == k195_IconIndicePotionEmptyFlask)) { - IconIndice iconIndex = objMan.getIconIndex(_414_leaderHandObject); + IconIndice iconIndex = objMan.f33_getIconIndex(_g414_leaderHandObject); if (iconIndex != leaderHandObjIconIndex) { _g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - objMan.extractIconFromBitmap(iconIndex, objMan._g412_objectIconForMousePointer); + objMan.f36_extractIconFromBitmap(iconIndex, objMan._g412_objectIconForMousePointer); warning("MISSING CODE: F0068_MOUSE_SetPointerToObject"); _g413_leaderHandObjectIconIndex = iconIndex; - objMan.drawLeaderObjectName(_414_leaderHandObject); + objMan.f34_drawLeaderObjectName(_g414_leaderHandObject); } } for (uint16 slotBoxIndex = 0; slotBoxIndex < (_g305_partyChampionCount * 2); ++slotBoxIndex) { int16 champIndex = slotBoxIndex >> 1; - if (invChampOrdinal == _vm->indexToOrdinal(champIndex)) + if (invChampOrdinal == _vm->M0_indexToOrdinal(champIndex)) continue; - if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)handSlotIndex(slotBoxIndex))) - && (handSlotIndex(slotBoxIndex) == k1_ChampionSlotActionHand)) { + if (f295_hasObjectIconInSlotBoxChanged(slotBoxIndex, _gK71_champions[champIndex].getSlot((ChampionSlot)M70_handSlotIndex(slotBoxIndex))) + && (M70_handSlotIndex(slotBoxIndex) == k1_ChampionSlotActionHand)) { - menuMan.drawActionIcon((ChampionIndex)champIndex); + menuMan.f386_drawActionIcon((ChampionIndex)champIndex); } } if (invChampOrdinal) { - Champion *champ = &_champions[_vm->ordinalToIndex(invChampOrdinal)]; + Champion *champ = &_gK71_champions[_vm->M1_ordinalToIndex(invChampOrdinal)]; Thing *thing = &champ->getSlot(k0_ChampionSlotReadyHand); uint16 drawViewport = 0; for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++, thing++) { - uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + k8_SlotBoxInventoryFirstSlot, *thing) ? 1 : 0; + uint16 objIconChanged = f295_hasObjectIconInSlotBoxChanged(slotIndex + k8_SlotBoxInventoryFirstSlot, *thing) ? 1 : 0; drawViewport |= objIconChanged; if (objIconChanged && (slotIndex == k1_ChampionSlotActionHand)) { - menuMan.drawActionIcon((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal)); + menuMan.f386_drawActionIcon((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal)); } } if (invMan._g424_panelContent = k4_PanelContentChest) { thing = invMan._g425_chestSlots; for (int16 slotIndex = 0; slotIndex < 8; ++slotIndex, thing++) { - drawViewport |= (hasObjectIconInSlotBoxChanged(slotIndex + k38_SlotBoxChestFirstSlot, *thing) ? 1 : 0); + drawViewport |= (f295_hasObjectIconInSlotBoxChanged(slotIndex + k38_SlotBoxChestFirstSlot, *thing) ? 1 : 0); } } if (drawViewport) { champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true); - drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal)); + f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal)); } } @@ -362,7 +362,7 @@ void ChampionMan::drawChangedObjectIcons() { warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } -void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) { +void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) { InventoryMan &invMan = *_vm->_inventoryMan; DungeonMan &dunMan = *_vm->_dungeonMan; ObjectMan &objMan = *_vm->_objectMan; @@ -371,7 +371,7 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio if (thing == Thing::_none) return; - Champion *champ = &_champions[champIndex]; + Champion *champ = &_gK71_champions[champIndex]; if (slotIndex >= k30_ChampionSlotChest_1) { invMan._g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = thing; @@ -379,30 +379,30 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio champ->setSlot(slotIndex, thing); } - champ->_load += dunMan.getObjectWeight(thing); + champ->_load += dunMan.f140_getObjectWeight(thing); champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true); - IconIndice iconIndex = objMan.getIconIndex(thing); - bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal); - applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing); - uint16 *rawObjPtr = dunMan.getThingData(thing); + IconIndice iconIndex = objMan.f33_getIconIndex(thing); + bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal); + f299_pplyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing); + uint16 *rawObjPtr = dunMan.f156_getThingData(thing); if (slotIndex < k2_ChampionSlotHead) { if (slotIndex == k1_ChampionSlotActionHand) { champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true); - if (_g506_actingChampionOrdinal == _vm->indexToOrdinal(champIndex)) - menuMan.clearActingChampion(); + if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)) + menuMan.f388_clearActingChampion(); if ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)) { ((Scroll*)rawObjPtr)->setClosed(false); - drawChangedObjectIcons(); + f296_drawChangedObjectIcons(); } } if (iconIndex = k4_IconIndiceWeaponTorchUnlit) { ((Weapon*)rawObjPtr)->setLit(true); warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette"); - drawChangedObjectIcons(); + f296_drawChangedObjectIcons(); } else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) && ((iconIndex == k144_IconIndiceContainerChestClosed) || ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)))) { champ->setAttributeFlag(k0x0800_ChampionAttributePanel, true); @@ -422,33 +422,33 @@ void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, Champio } - drawSlot(champIndex, slotIndex); + f291_drawSlot(champIndex, slotIndex); if (isInventoryChampion) champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true); } -ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) { +ChampionIndex ChampionMan::f285_getIndexInCell(ViewCell cell) { for (uint16 i = 0; i < _g305_partyChampionCount; ++i) { - if ((_champions[i]._cell == cell) && _champions[i]._currHealth) + if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth) return (ChampionIndex)i; } return kM1_ChampionNone; } -void ChampionMan::resetDataToStartGame() { +void ChampionMan::f278_resetDataToStartGame() { if (!_vm->_g298_newGame) { warning("MISSING CODE: stuff for resetting for loaded games"); assert(false); } - _414_leaderHandObject = Thing::_none; + _g414_leaderHandObject = Thing::_none; _g413_leaderHandObjectIconIndex = kM1_IconIndiceNone; _g415_leaderEmptyHanded = true; } -void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { +void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) { DisplayMan &dispMan = *_vm->_displayMan; DungeonMan &dunMan = *_vm->_dungeonMan; @@ -456,12 +456,12 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { return; uint16 prevChampCount = _g305_partyChampionCount; - Champion *champ = &_champions[prevChampCount]; + Champion *champ = &_gK71_champions[prevChampCount]; champ->resetToZero(); dispMan._g578_useByteBoxCoordinates = true; { // limit destBox scope Box &destBox = gBoxChampionPortrait; - dispMan.blitToBitmap(dispMan.getBitmap(k26_ChampionPortraitsIndice), 256, getChampionPortraitX(championPortraitIndex), getChampionPortraitY(championPortraitIndex), + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k26_ChampionPortraitsIndice), 256, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), champ->_portrait, 32, destBox, k255_ColorNoTransparency); } @@ -470,7 +470,7 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { champ->_hideDamageReceivedIndex = -1; champ->_dir = dunMan._g308_partyDir; ViewCell AL_0_viewCell = k0_ViewCellFronLeft; - while (getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3)) != kM1_ChampionNone) + while (f285_getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3)) != kM1_ChampionNone) AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3); champ->clearAttributes(k0x0400_ChampionAttributeIcon); @@ -481,13 +481,13 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) { champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none); } - Thing thing = dunMan.getSquareFirstThing(dunMan._g306_partyMapX, dunMan._g307_partyMapY); + Thing thing = dunMan.f161_getSquareFirstThing(dunMan._g306_partyMapX, dunMan._g307_partyMapY); while (thing.getType() != k2_TextstringType) { - thing = dunMan.getNextThing(thing); + thing = dunMan.f159_getNextThing(thing); } char decodedChampionText[77]; char* character_Green = decodedChampionText; - dunMan.decodeText(character_Green, thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible)); + dunMan.f168_decodeText(character_Green, thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible)); int16 AL_0_characterIndex = 0; uint16 AL_2_character; while ((AL_2_character = *character_Green++) != '\n') { @@ -511,18 +511,18 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { champ->setAttributeFlag(k0x0010_ChampionAttributeMale, true); } character_Green++; - champ->_currHealth = champ->_maxHealth = getDecodedValue(character_Green, 4); + champ->_currHealth = champ->_maxHealth = f279_getDecodedValue(character_Green, 4); character_Green += 4; - champ->_currStamina = champ->_maxStamina = getDecodedValue(character_Green, 4); + champ->_currStamina = champ->_maxStamina = f279_getDecodedValue(character_Green, 4); character_Green += 4; - champ->_currMana = champ->_maxMana = getDecodedValue(character_Green, 4); + champ->_currMana = champ->_maxMana = f279_getDecodedValue(character_Green, 4); character_Green += 4; character_Green++; int16 AL_0_statisticIndex; for (AL_0_statisticIndex = k0_ChampionStatLuck; AL_0_statisticIndex <= k6_ChampionStatAntifire; ++AL_0_statisticIndex) { champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k2_ChampionStatMinimum, 30); - uint16 currMaxVal = getDecodedValue(character_Green, 2); + uint16 currMaxVal = f279_getDecodedValue(character_Green, 2); champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent, currMaxVal); champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum, currMaxVal); character_Green += 2; @@ -550,11 +550,11 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { _g299_candidateChampionOrdinal = prevChampCount + 1; if (++_g305_partyChampionCount == 1) { - _vm->_eventMan->commandSetLeader(k0_ChampionFirst); + _vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst); _vm->_menuMan->_g508_refreshActionArea = true; } else { - _vm->_menuMan->clearActingChampion(); - _vm->_menuMan->drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1)); + _vm->_menuMan->f388_clearActingChampion(); + _vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1)); } int16 mapX = _vm->_dungeonMan->_g306_partyMapX; @@ -563,13 +563,13 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) { uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._g308_partyDir)); mapX += _vm->_dirIntoStepCountEast[dunMan._g308_partyDir]; mapY += _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir]; - thing = dunMan.getSquareFirstThing(mapX, mapY); + thing = dunMan.f161_getSquareFirstThing(mapX, mapY); AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1; uint16 slotIndex_Green; while (thing != Thing::_endOfList) { ThingType AL_2_thingType = thing.getType(); if ((AL_2_thingType > k3_SensorThingType) && (thing.getCell() == championObjectsCell)) { - int16 objectAllowedSlots = g237_ObjectInfo[dunMan.getObjectInfoIndex(thing)].getAllowedSlots(); + int16 objectAllowedSlots = g237_ObjectInfo[dunMan.f141_getObjectInfoIndex(thing)].getAllowedSlots(); switch (AL_2_thingType) { case k6_ArmourThingType: for (slotIndex_Green = k2_ChampionSlotHead; slotIndex_Green <= k5_ChampionSlotFeet; slotIndex_Green++) { @@ -616,18 +616,18 @@ T0280048: if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_none) { goto T0280046; } - addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green); + f301_addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green); } - thing = dunMan.getNextThing(thing); + thing = dunMan.f159_getNextThing(thing); } - _vm->_inventoryMan->toggleInventory((ChampionIndex)prevChampCount); - _vm->_menuMan->drawDisabledMenu(); + _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)prevChampCount); + _vm->_menuMan->f456_drawDisabledMenu(); } -void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { +void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) { - Champion *curChampion = &_champions[champIndex]; + Champion *curChampion = &_gK71_champions[champIndex]; int16 barGraphIndex = 0; int16 barGraphHeightArray[3]; @@ -676,12 +676,12 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { if (barGraphHeight < 25) { box._y1 = 2; box._y1 = 27 - barGraphHeight + 1; - _vm->_displayMan->clearScreenBox(g46_ChampionColor[champIndex], box); + _vm->_displayMan->D24_clearScreenBox(g46_ChampionColor[champIndex], box); } if (barGraphHeight) { box._y1 = 27 - barGraphHeight; box._y2 = 26 + 1; - _vm->_displayMan->clearScreenBox(g46_ChampionColor[champIndex], box); + _vm->_displayMan->D24_clearScreenBox(g46_ChampionColor[champIndex], box); } box._x1 += 7; box._x2 += 7; @@ -690,7 +690,7 @@ void ChampionMan::drawChampionBarGraphs(ChampionIndex champIndex) { } -uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) { +uint16 ChampionMan::f306_getStaminaAdjustedValue(Champion *champ, int16 val) { int16 currStamina = champ->_currStamina; int16 halfMaxStamina = champ->_maxStamina / 2; if (currStamina < halfMaxStamina) { @@ -701,14 +701,14 @@ uint16 ChampionMan::getStaminaAdjustedValue(Champion *champ, int16 val) { return val; } -uint16 ChampionMan::getMaximumLoad(Champion *champ) { +uint16 ChampionMan::f309_getMaximumLoad(Champion *champ) { uint16 maximumLoad = champ->getStatistic(k1_ChampionStatStrength, k1_ChampionStatCurrent) * 8 + 100; - maximumLoad = getStaminaAdjustedValue(champ, maximumLoad); + maximumLoad = f306_getStaminaAdjustedValue(champ, maximumLoad); int16 wounds = champ->getWounds(); if (wounds) { maximumLoad -= maximumLoad >> (champ->getWoundsFlag(k0x0010_ChampionWoundLegs) ? 2 : 3); } - if (_vm->_objectMan->getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots) { + if (_vm->_objectMan->f33_getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots) { maximumLoad += maximumLoad * 16; } maximumLoad += 9; @@ -716,7 +716,7 @@ uint16 ChampionMan::getMaximumLoad(Champion *champ) { return maximumLoad; } -void ChampionMan::drawChampionState(ChampionIndex champIndex) { +void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { InventoryMan &invMan = *_vm->_inventoryMan; DisplayMan &dispMan = *_vm->_displayMan; MenuMan &menuMan = *_vm->_menuMan; @@ -724,14 +724,14 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { Box box; int16 champStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing; - Champion *champ = &_champions[champIndex]; + Champion *champ = &_gK71_champions[champIndex]; uint16 champAttributes = champ->getAttributes(); if (!((champAttributes) & (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand))) { return; } - bool isInventoryChamp = (_vm->indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal); + bool isInventoryChamp = (_vm->M0_indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal); dispMan._g578_useByteBoxCoordinates = false; if (champAttributes & k0x1000_ChampionAttributeStatusBox) { box._y1 = 0; @@ -739,7 +739,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { box._x1 = champStatusBoxX; box._x2 = box._x1 + 66 + 1; if (champ->_currHealth) { - dispMan.clearScreenBox(k12_ColorDarkestGray, box); + dispMan.D24_clearScreenBox(k12_ColorDarkestGray, box); int16 nativeBitmapIndices[3]; for (int16 i = 0; i < 3; ++i) nativeBitmapIndices[i] = 0; @@ -751,20 +751,20 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { if (_g407_party._shieldDefense > 0) nativeBitmapIndices[AL_0_borderCount++] = k37_BorderPartyShieldIndice; while (AL_0_borderCount--) { - dispMan.blitToBitmap(dispMan.getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k10_ColorFlesh); } if (isInventoryChamp) { - invMan.drawStatusBoxPortrait(champIndex); + invMan.f354_drawStatusBoxPortrait(champIndex); champAttributes |= k0x0100_ChampionAttributeStatistics; } else { champAttributes |= (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand); } } else { - dispMan.blitToBitmap(dispMan.getBitmap(k8_StatusBoxDeadChampion), 80, 0, 0, + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k8_StatusBoxDeadChampion), 80, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); _vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, champ->_name); - menuMan.drawActionIcon(champIndex); + menuMan.f386_drawActionIcon(champIndex); goto T0292042_green; } } @@ -776,35 +776,35 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { Color AL_0_colorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; // unused because of missing functions if (isInventoryChamp) { char *champName = champ->_name; - _vm->_textMan->printToViewport(3, 7, AL_0_colorIndex, champName); + _vm->_textMan->f52_printToViewport(3, 7, AL_0_colorIndex, champName); int16 champTitleX = 6 * strlen(champName) + 3; char champTitleFirstChar = champ->_title[0]; if ((champTitleFirstChar != ',') && (champTitleFirstChar != ';') && (champTitleFirstChar != '-')) { champTitleX += 6; } - _vm->_textMan->printToViewport(champTitleX, 7, AL_0_colorIndex, champ->_title); + _vm->_textMan->f52_printToViewport(champTitleX, 7, AL_0_colorIndex, champ->_title); champAttributes |= k0x4000_ChampionAttributeViewport; } else { box._y1 = 0; box._y2 = 6 + 1; box._x1 = champStatusBoxX; box._x2 = box._x1 + 42 + 1; - dispMan.clearScreenBox(k1_ColorDarkGary, box); + dispMan.D24_clearScreenBox(k1_ColorDarkGary, box); _vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, k1_ColorDarkGary, champ->_name); } } if (champAttributes & k0x0100_ChampionAttributeStatistics) { - drawChampionBarGraphs(champIndex); + f287_drawChampionBarGraphs(champIndex); if (isInventoryChamp) { - drawHealthStaminaManaValues(champ); + f290_drawHealthStaminaManaValues(champ); int16 AL_2_nativeBitmapIndex; if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) { AL_2_nativeBitmapIndex = k34_SlotBoxWoundedIndice; } else { AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; } - dispMan.blitToBitmap(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, gBoxMouth, k12_ColorDarkestGray); AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; for (int16 AL_0_statisticIndex = k1_ChampionStatStrength; AL_0_statisticIndex <= k6_ChampionStatAntifire; AL_0_statisticIndex++) { @@ -814,7 +814,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { break; } } - dispMan.blitToBitmap(dispMan.getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, gBoxEye, k12_ColorDarkestGray); champAttributes |= k0x4000_ChampionAttributeViewport; } @@ -822,7 +822,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { if (champAttributes & k0x2000_ChampionAttributeWounds) { for (int16 AL_0_slotIndex = isInventoryChamp ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL_0_slotIndex >= k0_ChampionSlotReadyHand; AL_0_slotIndex--) { - drawSlot(champIndex, (ChampionSlot)AL_0_slotIndex); + f291_drawSlot(champIndex, (ChampionSlot)AL_0_slotIndex); } if (isInventoryChamp) { champAttributes |= k0x4000_ChampionAttributeViewport; @@ -831,7 +831,7 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { if ((champAttributes & k0x0200_ChampionAttributeLoad) && isInventoryChamp) { Color loadColor; - int16 champMaxLoad = getMaximumLoad(champ); + int16 champMaxLoad = f309_getMaximumLoad(champ); if (champ->_load > champMaxLoad) { loadColor = k8_ColorRed; } else if (((int32)champ->_load) * 8 > ((int32)champMaxLoad) * 5) { @@ -839,46 +839,46 @@ void ChampionMan::drawChampionState(ChampionIndex champIndex) { } else { loadColor = k13_ColorLightestGray; } - _vm->_textMan->printToViewport(104, 132, loadColor, "LOAD "); + _vm->_textMan->f52_printToViewport(104, 132, loadColor, "LOAD "); int16 loadTmp = champ->_load / 10; - Common::String str = getStringFromInteger(loadTmp, true, 3); + Common::String str = f288_getStringFromInteger(loadTmp, true, 3); str += '.'; loadTmp = champ->_load - (loadTmp * 10); - str += getStringFromInteger(loadTmp, false, 1); + str += f288_getStringFromInteger(loadTmp, false, 1); str += '/'; - loadTmp = (getMaximumLoad(champ) + 5) / 10; + loadTmp = (f309_getMaximumLoad(champ) + 5) / 10; str += "KG"; - _vm->_textMan->printToViewport(148, 132, loadColor, str.c_str()); + _vm->_textMan->f52_printToViewport(148, 132, loadColor, str.c_str()); champAttributes |= k0x4000_ChampionAttributeViewport; } { // block so goto won't skip AL_0_championIconIndex initialization - int16 AL_0_championIconIndex = championIconIndex(champ->_cell, _vm->_dungeonMan->_g308_partyDir); + int16 AL_0_championIconIndex = M26_championIconIndex(champ->_cell, _vm->_dungeonMan->_g308_partyDir); - if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->indexToOrdinal(AL_0_championIconIndex))) { - dispMan.clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]); - dispMan.blitToBitmap(dispMan.getBitmap(k28_ChampionIcons), 80, championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, + if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL_0_championIconIndex))) { + dispMan.D24_clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k28_ChampionIcons), 80, M26_championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray); } } if ((champAttributes & k0x0800_ChampionAttributePanel) && isInventoryChamp) { if (_vm->_g333_pressingMouth) { - invMan.drawPanelFoodWaterPoisoned(); + invMan.f345_drawPanelFoodWaterPoisoned(); } else if (_vm->_g331_pressingEye) { if (_g415_leaderEmptyHanded) { warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics"); } } else { - invMan.drawPanel(); + invMan.f347_drawPanel(); } champAttributes |= k0x4000_ChampionAttributeViewport; } if (champAttributes & k0x8000_ChampionAttributeActionHand) { - drawSlot(champIndex, k1_ChampionSlotActionHand); - menuMan.drawActionIcon(champIndex); + f291_drawSlot(champIndex, k1_ChampionSlotActionHand); + menuMan.f386_drawActionIcon(champIndex); if (isInventoryChamp) { champAttributes |= k0x4000_ChampionAttributeViewport; } @@ -896,24 +896,24 @@ T0292042_green: warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } -uint16 ChampionMan::championIconIndex(int16 val, direction dir) { +uint16 ChampionMan::M26_championIconIndex(int16 val, direction dir) { return ((val + 4 - dir) & 0x3); } -void ChampionMan::drawHealthStaminaManaValues(Champion* champ) { - drawHealthOrStaminaOrManaValue(116, champ->_currHealth, champ->_maxHealth); - drawHealthOrStaminaOrManaValue(124, champ->_currStamina, champ->_maxStamina); - drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana); +void ChampionMan::f290_drawHealthStaminaManaValues(Champion* champ) { + f289_drawHealthOrStaminaOrManaValue(116, champ->_currHealth, champ->_maxHealth); + f289_drawHealthOrStaminaOrManaValue(124, champ->_currStamina, champ->_maxStamina); + f289_drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana); } -void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { +void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) { int16 nativeBitmapIndex = -1; - Champion *champ = &_champions[champIndex]; - bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)); + Champion *champ = &_gK71_champions[champIndex]; + bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)); uint16 slotBoxIndex; if (!isInventoryChamp) { /* If drawing a slot for a champion other than the champion whose inventory is open */ - if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->indexToOrdinal(champIndex))) { + if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))) { return; } slotBoxIndex = (champIndex << 1) + slotIndex; @@ -959,7 +959,7 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { } } else { warning("BUG0_35"); - iconIndex = _vm->_objectMan->getIconIndex(thing); // BUG0_35 + iconIndex = _vm->_objectMan->f33_getIconIndex(thing); // BUG0_35 if (isInventoryChamp && (slotIndex == k1_ChampionSlotActionHand) && ((iconIndex == k144_IconIndiceContainerChestClosed) || (iconIndex == k30_IconIndiceScrollOpen))) { warning("BUG2_00"); iconIndex++; @@ -973,29 +973,29 @@ void ChampionMan::drawSlot(uint16 champIndex, ChampionSlot slotIndex) { } } - if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->indexToOrdinal(champIndex) == _g506_actingChampionOrdinal)) { + if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->M0_indexToOrdinal(champIndex) == _g506_actingChampionOrdinal)) { nativeBitmapIndex = k35_SlotBoxActingHandIndice; } if (nativeBitmapIndex != -1) { _vm->_displayMan->_g578_useByteBoxCoordinates = false; if (isInventoryChamp) { - _vm->_displayMan->blitToBitmap(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0, + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), 32, 0, 0, _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, box, k12_ColorDarkestGray); } else { - _vm->_displayMan->blitToBitmap(_vm->_displayMan->getBitmap(nativeBitmapIndex), 32, 0, 0, + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), 32, 0, 0, _vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, box, k12_ColorDarkestGray); } } - _vm->_objectMan->drawIconInSlotBox(slotBoxIndex, iconIndex); + _vm->_objectMan->f38_drawIconInSlotBox(slotBoxIndex, iconIndex); if (!isInventoryChamp) { warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } } -void ChampionMan::renameChampion(Champion* champ) { +void ChampionMan::f281_renameChampion(Champion* champ) { warning("STUB METHOD: Champion::renameChampion, F0281_CHAMPION_Rename"); DisplayMan &dispMan = *_vm->_displayMan; @@ -1008,15 +1008,15 @@ void ChampionMan::renameChampion(Champion* champ) { box._x2 = box._x1 + 167; dispMan.f135_fillBoxBitmap(dispMan._g296_bitmapViewport, box, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport); - dispMan.blitToBitmap(dispMan.getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k4_ColorCyan); - textMan.printToViewport(177, 58, k13_ColorLightestGray, "_______"); - textMan.printToViewport(105, 76, k13_ColorLightestGray, "___________________"); + textMan.f52_printToViewport(177, 58, k13_ColorLightestGray, "_______"); + textMan.f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________"); Common::Point clickPos; static Box okButtonBox(197, 215, 147, 155); // inclusive boundaries, constructor adds +1 for (;;) { _vm->_eventMan->processInput(); - if (_vm->_eventMan->hasPendingClick(clickPos, k1_LeftMouseButton) && okButtonBox.isPointInside(clickPos)) { + if (_vm->_eventMan->f360_hasPendingClick(clickPos, k1_LeftMouseButton) && okButtonBox.isPointInside(clickPos)) { return; } dispMan.f97_drawViewport(k0_viewportNotDungeonView); @@ -1024,14 +1024,14 @@ void ChampionMan::renameChampion(Champion* champ) { } } -uint16 ChampionMan::getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex) { +uint16 ChampionMan::f303_getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex) { if (_g300_partyIsSleeping) return 1; bool ignoreTempExp = skillIndex & k0x8000_IgnoreTemporaryExperience; bool ignoreObjModifiers = skillIndex & k0x4000_IgnoreObjectModifiers; skillIndex = (ChampionSkill)(skillIndex & ~(ignoreTempExp | ignoreObjModifiers)); - Champion *champ = &_champions[champIndex]; + Champion *champ = &_gK71_champions[champIndex]; Skill *skill = &champ->getSkill(skillIndex); int32 experience = skill->_experience; @@ -1054,14 +1054,14 @@ uint16 ChampionMan::getSkillLevel(ChampionIndex champIndex, ChampionSkill skillI } if (!ignoreObjModifiers) { - IconIndice actionHandIconIndex = _vm->_objectMan->getIconIndex(champ->getSlot(k1_ChampionSlotActionHand)); + IconIndice actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->getSlot(k1_ChampionSlotActionHand)); if (actionHandIconIndex == k27_IconIndiceWeaponTheFirestaff) { skillLevel++; } else if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete) { skillLevel += 2; } - IconIndice neckIconIndice = _vm->_objectMan->getIconIndex(champ->getSlot(k10_ChampionSlotNeck)); + IconIndice neckIconIndice = _vm->_objectMan->f33_getIconIndex(champ->getSlot(k10_ChampionSlotNeck)); switch (skillIndex) { case k3_ChampionSkillWizard: if (neckIconIndice == k124_IconIndiceJunkPendantFeral) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index cd6694669b..1b7a4ff548 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -426,18 +426,18 @@ public: class ChampionMan { DMEngine *_vm; - uint16 getChampionPortraitX(uint16 index); // @ M27_PORTRAIT_X - uint16 getChampionPortraitY(uint16 index); // @ M28_PORTRAIT_Y + uint16 M27_getChampionPortraitX(uint16 index); // @ M27_PORTRAIT_X + uint16 M28_getChampionPortraitY(uint16 index); // @ M28_PORTRAIT_Y - ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell - int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue - void drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue - uint16 handSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX + ChampionIndex f285_getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell + int16 f279_getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue + void f289_drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue + uint16 M70_handSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX public: - Champion _champions[4]; + Champion _gK71_champions[4]; // @ K0071_as_Champions uint16 _g305_partyChampionCount; // @ G0305_ui_PartyChampionCount - bool _303_partyDead; // @ G0303_B_PartyDead - Thing _414_leaderHandObject; // @ G0414_T_LeaderHandObject + bool _g303_partyDead; // @ G0303_B_PartyDead + Thing _g414_leaderHandObject; // @ G0414_T_LeaderHandObject ChampionIndex _g411_leaderIndex; // @ G0411_i_LeaderIndex uint16 _g299_candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal bool _g300_partyIsSleeping; // @ G0300_B_PartyIsSleeping @@ -449,23 +449,23 @@ public: bool _g420_mousePointerHiddenToDrawChangedObjIconOnScreen; // @ G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen explicit ChampionMan(DMEngine *vm); - void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame - void addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty - void drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs - uint16 getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue - uint16 getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad - void drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState - uint16 championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX - void drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues - void drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot - void renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename - uint16 getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel - Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger - void applyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex, + void f278_resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame + void f280_addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty + void f287_drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs + uint16 f306_getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue + uint16 f309_getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad + void f292_drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState + uint16 M26_championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX + void f290_drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues + void f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot + void f281_renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename + uint16 f303_getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel + Common::String f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger + void f299_pplyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics - bool hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged - void drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons - void addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot + bool f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged + void f296_drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons + void f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot }; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index f7e9e8fbbd..c5ff2f2287 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -141,26 +141,26 @@ DMEngine::~DMEngine() { DebugMan.clearAllDebugChannels(); } -void DMEngine::initializeGame() { - _displayMan->loadGraphics(); - _displayMan->initializeGraphicData(); +void DMEngine::f463_initializeGame() { + _displayMan->f479_loadGraphics(); + _displayMan->f460_initializeGraphicData(); // DUMMY CODE: next line _displayMan->loadPalette(g19_PalCredits); _eventMan->initMouse(); - while (_loadsaveMan->loadgame() != k1_LoadgameSuccess) { + while (_loadsaveMan->f435_loadgame() != k1_LoadgameSuccess) { warning("TODO: F0441_STARTEND_ProcessEntrance"); } - _displayMan->loadFloorSet(k0_FloorSetStone); - _displayMan->loadWallSet(k0_WallSetStone); + _displayMan->f94_loadFloorSet(k0_FloorSetStone); + _displayMan->f95_loadWallSet(k0_WallSetStone); _objectMan->loadObjectNames(); // There was some memory wizardy for the Amiga platform, I skipped that part _displayMan->f461_allocateFlippedWallBitmaps(); - startGame(); + f462_startGame(); warning("MISSING CODE: F0267_MOVE_GetMoveResult_CPSCE (if newGame)"); _eventMan->showMouse(true); warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); @@ -173,7 +173,7 @@ void DMEngine::initializeGame() { _displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i]; } - void DMEngine::startGame() { + void DMEngine::f462_startGame() { _g331_pressingEye = false; _g332_stopPressingEye = false; _g333_pressingMouth = false; @@ -181,15 +181,15 @@ void DMEngine::initializeGame() { _g340_highlightBoxInversionRequested = false; _eventMan->_g341_highlightBoxEnabled = false; _championMan->_g300_partyIsSleeping = false; - _championMan->_g506_actingChampionOrdinal = indexToOrdinal(kM1_ChampionNone); + _championMan->_g506_actingChampionOrdinal = M0_indexToOrdinal(kM1_ChampionNone); _menuMan->_g509_actionAreaContainsIcons = true; - _eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = indexToOrdinal(kM1_ChampionNone); + _eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = M0_indexToOrdinal(kM1_ChampionNone); _eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface; _eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement; warning("MISSING CODE: set primary/secondary keyboard input"); - processNewPartyMap(_dungeonMan->_g309_partyMapIndex); + f3_processNewPartyMap(_dungeonMan->_g309_partyMapIndex); if (!_g298_newGame) { warning("TODO: loading game"); @@ -199,15 +199,15 @@ void DMEngine::initializeGame() { } warning("TODO: build copper"); - _menuMan->drawMovementArrows(); - _championMan->resetDataToStartGame(); + _menuMan->f395_drawMovementArrows(); + _championMan->f278_resetDataToStartGame(); _g301_gameTimeTicking = true; } -void DMEngine::processNewPartyMap(uint16 mapIndex) { +void DMEngine::f3_processNewPartyMap(uint16 mapIndex) { warning("MISSING CODE: F0194_GROUP_RemoveAllActiveGroups"); - _dungeonMan->setCurrentMapAndPartyMap(mapIndex); - _displayMan->loadCurrentMapGraphics(); + _dungeonMan->f174_setCurrentMapAndPartyMap(mapIndex); + _displayMan->f96_loadCurrentMapGraphics(); warning("MISSING CODE: F0195_GROUP_AddAllActiveGroups"); warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette"); } @@ -232,16 +232,16 @@ Common::Error DMEngine::run() { _timeline = new Timeline(this); _displayMan->setUpScreens(320, 200); - initializeGame(); // @ F0463_START_InitializeGame_CPSADEF + f463_initializeGame(); // @ F0463_START_InitializeGame_CPSADEF while (true) { - gameloop(); + f2_gameloop(); warning("TODO: F0444_STARTEND_Endgame(G0303_B_PartyDead);"); } return Common::kNoError; } -void DMEngine::gameloop() { +void DMEngine::f2_gameloop() { warning("DUMMY CODE SETTING PARTY POS AND DIRECTION"); _dungeonMan->_g306_partyMapX = 10; _dungeonMan->_g307_partyMapY = 4; @@ -254,21 +254,21 @@ void DMEngine::gameloop() { while (true) { _g321_stopWaitingForPlayerInput = false; - _menuMan->refreshActionAreaAndSetChampDirMaxDamageReceived(); + _menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived(); //do { _eventMan->processInput(); - _eventMan->processCommandQueue(); + _eventMan->f380_processCommandQueue(); //} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking); if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { Box box(0, 224, 0, 126); _displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport * 2, k136_heightViewport); // dummy code - _displayMan->drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); + _displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); } // DUMMY CODE: next 2 lines - _menuMan->drawMovementArrows(); + _menuMan->f395_drawMovementArrows(); _displayMan->f97_drawViewport(k1_viewportDungeonView); _displayMan->updateScreen(); @@ -276,11 +276,11 @@ void DMEngine::gameloop() { } } -int16 DMEngine::ordinalToIndex(int16 val) { +int16 DMEngine::M1_ordinalToIndex(int16 val) { return val - 1; } -int16 DMEngine::indexToOrdinal(int16 val) { +int16 DMEngine::M0_indexToOrdinal(int16 val) { return val + 1; } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 7837ac4716..6ceedf9e33 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -142,19 +142,19 @@ enum { }; class DMEngine : public Engine { - void startGame(); // @ F0462_START_StartGame_CPSF - void processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE - void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF + void f462_startGame(); // @ F0462_START_StartGame_CPSF + void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE + void f463_initializeGame(); // @ F0463_START_InitializeGame_CPSADEF void f448_initMemoryManager(); // @ F0448_STARTUP1_InitializeMemoryManager_CPSADEF - void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF + void f2_gameloop(); // @ F0002_MAIN_GameLoop_CPSDF void initArrays(); public: explicit DMEngine(OSystem *syst); ~DMEngine(); - int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX - int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL + int16 M1_ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX + int16 M0_indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL virtual Common::Error run(); // @ main private: diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index d75e92b124..2a037a70d0 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -360,7 +360,7 @@ CreatureInfo g243_CreatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic5 {25, 0, 0x38AA, 0x0000, 12, 22, 255, 180, 210, 0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}, {26, 0, 0x38AA, 0x0000, 12, 22, 255, 180, 210, 0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}}; -void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) { +void DungeonMan::f150_mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) { posX += _vm->_dirIntoStepCountEast[dir] * stepsForward; posY += _vm->_dirIntoStepCountNorth[dir] * stepsForward; turnDirRight(dir); @@ -438,7 +438,7 @@ DungeonMan::~DungeonMan() { } } -void DungeonMan::decompressDungeonFile() { +void DungeonMan::f455_decompressDungeonFile() { Common::File f; f.open("Dungeon.dat"); if (f.readUint16BE() == 0x8104) { @@ -550,9 +550,9 @@ const Thing Thing::_explRebirthStep1(0xFFE4); // @ C0xFFE4_THING_EXPLOSION_REBIR const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIRTH_STEP2 const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY -void DungeonMan::loadDungeonFile() { +void DungeonMan::f434_loadDungeonFile() { if (_vm->_g298_newGame) - decompressDungeonFile(); + f455_decompressDungeonFile(); Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO); @@ -728,7 +728,7 @@ void DungeonMan::loadDungeonFile() { } } -void DungeonMan::setCurrentMap(uint16 mapIndex) { +void DungeonMan::f173_setCurrentMap(uint16 mapIndex) { _g272_currMapIndex = mapIndex; _g271_currMapData = _g279_dungeonMapData[mapIndex]; _g269_currMap = _g277_dungeonMaps + mapIndex; @@ -738,8 +738,8 @@ void DungeonMan::setCurrentMap(uint16 mapIndex) { = &_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]]; } -void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) { - setCurrentMap(mapIndex); +void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) { + f173_setCurrentMap(mapIndex); byte *metaMapData = _g271_currMapData[_g273_currMapWidth - 1] + _g274_currMapHeight; _vm->_displayMan->_g264_currMapAllowedCreatureTypes = metaMapData; @@ -758,7 +758,7 @@ void DungeonMan::setCurrentMapAndPartyMap(uint16 mapIndex) { } -Square DungeonMan::getSquare(int16 mapX, int16 mapY) { +Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) { bool isInXBounds = (mapX >= 0) && (mapX < _g273_currMapWidth); bool isInYBounds = (mapY >= 0) && (mapY < _g274_currMapHeight); @@ -788,12 +788,12 @@ Square DungeonMan::getSquare(int16 mapX, int16 mapY) { return Square(k0_WallElemType); } -Square DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { - mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY); - return getSquare(posX, posY); +Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { + f150_mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY); + return f151_getSquare(posX, posY); } -int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) { +int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) { if (mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight || !Square(_g271_currMapData[mapX][mapY]).get(k0x0010_ThingListPresent)) return -1; @@ -807,8 +807,8 @@ int16 DungeonMan::getSquareFirstThingIndex(int16 mapX, int16 mapY) { return index; } -Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) { - int16 index = getSquareFirstThingIndex(mapX, mapY); +Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) { + int16 index = f160_getSquareFirstThingIndex(mapX, mapY); if (index == -1) return Thing::_endOfList; return _g283_squareFirstThings[index]; @@ -816,14 +816,14 @@ Thing DungeonMan::getSquareFirstThing(int16 mapX, int16 mapY) { // TODO: get rid of the GOTOs -void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) { // complete, except where marked +void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) { // complete, except where marked _vm->_displayMan->_g289_championPortraitOrdinal = 0; // BUG0_75, possible fix for (uint16 i = 0; i < 5; ++i) aspectArray[i] = 0; - Thing thing = getSquareFirstThing(mapX, mapY); - Square square = getSquare(mapX, mapY); + Thing thing = f161_getSquareFirstThing(mapX, mapY); + Square square = f151_getSquare(mapX, mapY); aspectArray[k0_ElemAspect] = square.getType(); @@ -860,25 +860,25 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, } T0172010_ClosedFakeWall: - setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall); + f171_setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall); while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) { int16 sideIndex = (thing.getCell() - dir) & 3; if (sideIndex) { if (thing.getType() == k2_TextstringType) { - if (TextString(getThingData(thing)).isVisible()) { + if (TextString(f156_getThingData(thing)).isVisible()) { aspectArray[sideIndex + 1] = _g265_currMapInscriptionWallOrnIndex + 1; _vm->_displayMan->_g290_inscriptionThing = thing; // BUG0_76 } } else { - Sensor sensor(getThingData(thing)); + Sensor sensor(f156_getThingData(thing)); aspectArray[sideIndex + 1] = sensor.getOrnOrdinal(); if (sensor.getType() == k127_SensorWallChampionPortrait) { - _vm->_displayMan->_g289_championPortraitOrdinal = _vm->indexToOrdinal(sensor.getData()); + _vm->_displayMan->_g289_championPortraitOrdinal = _vm->M0_indexToOrdinal(sensor.getData()); } } } - thing = getNextThing(thing); + thing = f159_getNextThing(thing); } if (squareIsFakeWall && (_g306_partyMapX != mapX) && (_g307_partyMapY != mapY)) { aspectArray[k1_FirstGroupOrObjectAspect] = Thing::_endOfList.toUint16(); @@ -906,14 +906,14 @@ T0172010_ClosedFakeWall: square = Square(footPrintsAllowed ? 8 : 0); // intentional fallthrough case k1_CorridorElemType: - aspectArray[k4_FloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(k0x0008_CorridorRandOrnAllowed), _g269_currMap->_randFloorOrnCount, mapX, mapY, 30); + aspectArray[k4_FloorOrnOrdAspect] = f170_getRandomOrnOrdinal(square.get(k0x0008_CorridorRandOrnAllowed), _g269_currMap->_randFloorOrnCount, mapX, mapY, 30); T0172029_Teleporter: footPrintsAllowed = true; T0172030_Pit: while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) { if (thing.getType() == k3_SensorThingType) - aspectArray[k4_FloorOrnOrdAspect] = Sensor(getThingData(thing)).getOrnOrdinal(); - thing = getNextThing(thing); + aspectArray[k4_FloorOrnOrdAspect] = Sensor(f156_getThingData(thing)).getOrnOrdinal(); + thing = f159_getNextThing(thing); } goto T0172049_Footprints; case k5_TeleporterElemType: @@ -930,12 +930,12 @@ T0172030_Pit: } else { aspectArray[k0_ElemAspect] = k17_DoorFrontElemType; aspectArray[k2_DoorStateAspect] = square.getDoorState(); - aspectArray[k3_DoorThingIndexAspect] = getSquareFirstThing(mapX, mapY).getIndex(); + aspectArray[k3_DoorThingIndexAspect] = f161_getSquareFirstThing(mapX, mapY).getIndex(); } footPrintsAllowed = true; T0172046_Stairs: while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) - thing = getNextThing(thing); + thing = f159_getNextThing(thing); T0172049_Footprints: unsigned char scentOrdinal; // see next line comment if (footPrintsAllowed) // TODO: I skipped some party query code, must come back later and complete @@ -947,36 +947,36 @@ T0172049_Footprints: aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16(); } -void DungeonMan::setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, +void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, int16 mapX, int16 mapY, bool isFakeWall) { int16 ornCount = _g269_currMap->_randWallOrnCount; turnDirRight(dir); - aspectArray[k2_RightWallOrnOrdAspect] = getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); + aspectArray[k2_RightWallOrnOrdAspect] = f170_getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); turnDirRight(dir); - aspectArray[k3_FrontWallOrnOrdAspect] = getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); + aspectArray[k3_FrontWallOrnOrdAspect] = f170_getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); turnDirRight(dir); - aspectArray[k4_LeftWallOrnOrdAspect] = getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); + aspectArray[k4_LeftWallOrnOrdAspect] = f170_getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); if (isFakeWall || mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight) { for (uint16 i = k2_RightWallOrnOrdAspect; i <= k4_LeftWallOrnOrdAspect; ++i) { - if (isWallOrnAnAlcove(_vm->ordinalToIndex(aspectArray[i]))) + if (f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[i]))) aspectArray[i] = 0; } } } -int16 DungeonMan::getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) { +int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) { int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1) + (3000 + (_g272_currMapIndex << 6) + _g273_currMapWidth + _g274_currMapHeight) * 11 + _g278_dungeonFileHeader._ornamentRandomSeed) >> 2) % modulo; if (allowed && index < count) - return _vm->indexToOrdinal(index); + return _vm->M0_indexToOrdinal(index); return 0; } -bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) { +bool DungeonMan::f149_isWallOrnAnAlcove(int16 wallOrnIndex) { if (wallOrnIndex >= 0) for (uint16 i = 0; i < k3_AlcoveOrnCount; ++i) if (_vm->_displayMan->_g267_currMapAlcoveOrnIndices[i] == wallOrnIndex) @@ -984,16 +984,16 @@ bool DungeonMan::isWallOrnAnAlcove(int16 wallOrnIndex) { return false; } -uint16 *DungeonMan::getThingData(Thing thing) { +uint16 *DungeonMan::f156_getThingData(Thing thing) { return _g284_thingData[thing.getType()][thing.getIndex()]; } -uint16* DungeonMan::getSquareFirstThingData(int16 mapX, int16 mapY) { - return getThingData(getSquareFirstThing(mapX, mapY)); +uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) { + return f156_getThingData(f161_getSquareFirstThing(mapX, mapY)); } -Thing DungeonMan::getNextThing(Thing thing) { - return getThingData(thing)[0]; // :) +Thing DungeonMan::f159_getNextThing(Thing thing) { + return Thing(f156_getThingData(thing)[0]); // :) } char g255_MessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings @@ -1097,7 +1097,7 @@ char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_ {0, 0, 0, 0, 0, 0, 0, 0}}; -void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { +void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) { char sepChar; TextString textString(_g284_thingData[k2_TextstringType][thing.getIndex()]); if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) { @@ -1165,7 +1165,7 @@ void DungeonMan::decodeText(char *destString, Thing thing, TextType type) { } -uint16 DungeonMan::getObjectWeight(Thing thing) { +uint16 DungeonMan::f140_getObjectWeight(Thing thing) { static const uint16 g241_junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo // COMPASS - WATERSKIN - JEWEL SYMAL - ILLUMULET - ASHES 1, 3, 2, 2, 4, @@ -1195,11 +1195,11 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { return 0; switch (thing.getType()) { case k5_WeaponThingType: - return g238_WeaponInfo[Weapon(getThingData(thing)).getType()]._weight; + return g238_WeaponInfo[Weapon(f156_getThingData(thing)).getType()]._weight; case k6_ArmourThingType: - return g239_ArmourInfo[Armour(getThingData(thing)).getType()]._weight; + return g239_ArmourInfo[Armour(f156_getThingData(thing)).getType()]._weight; case k10_JunkThingType: { - Junk junk(getThingData(thing)); + Junk junk(f156_getThingData(thing)); uint16 weight = g241_junkInfo[junk.getType()]; if (junk.getType() == k1_JunkTypeWaterskin) weight += junk.getChargeCount() * 2; @@ -1207,16 +1207,16 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { } case k9_ContainerThingType: { uint16 weight = 50; - Container container(getThingData(thing)); + Container container(f156_getThingData(thing)); Thing slotThing = container.getSlot(); while (slotThing != Thing::_endOfList) { - weight += getObjectWeight(slotThing); - slotThing = getNextThing(slotThing); + weight += f140_getObjectWeight(slotThing); + slotThing = f159_getNextThing(slotThing); } return weight; } case k8_PotionThingType: - if (Junk(getThingData(thing)).getType() == k20_PotionTypeEmptyFlask) { + if (Junk(f156_getThingData(thing)).getType() == k20_PotionTypeEmptyFlask) { return 1; } else { return 3; @@ -1232,8 +1232,8 @@ uint16 DungeonMan::getObjectWeight(Thing thing) { } -int16 DungeonMan::getObjectInfoIndex(Thing thing) { - uint16 *rawType = getThingData(thing); +int16 DungeonMan::f141_getObjectInfoIndex(Thing thing) { + uint16 *rawType = f156_getThingData(thing); switch (thing.getType()) { case k7_ScrollThingType: return k0_ObjectInfoIndexFirstScroll; @@ -1252,17 +1252,17 @@ int16 DungeonMan::getObjectInfoIndex(Thing thing) { } } -void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) { +void DungeonMan::f163_linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) { if (thingToLink == Thing::_endOfList) return; - uint16 *rawObjPtr = getThingData(thingToLink); + uint16 *rawObjPtr = f156_getThingData(thingToLink); *rawObjPtr = Thing::_endOfList.toUint16(); if (mapX >= 0) { Square *squarePtr = (Square*)&_g271_currMapData[mapX][mapY]; if (squarePtr->get(k0x0010_ThingListPresent)) { - thingInList = getSquareFirstThing(mapX, mapY); + thingInList = f161_getSquareFirstThing(mapX, mapY); } else { squarePtr->set(k0x0010_ThingListPresent); uint16 *cumulativeCount = &_g270_currMapColCumulativeSquareFirstThingCount[mapX + 1]; @@ -1286,43 +1286,43 @@ void DungeonMan::linkThingToList(Thing thingToLink, Thing thingInList, int16 map } } - Thing thing = getNextThing(thingInList); + Thing thing = f159_getNextThing(thingInList); while (thing != Thing::_endOfList) { - thing = getNextThing(thing); + thing = f159_getNextThing(thing); thingInList = thing; } - rawObjPtr = getThingData(thingInList); + rawObjPtr = f156_getThingData(thingInList); *rawObjPtr = thingToLink.toUint16(); } -WeaponInfo* DungeonMan::getWeaponInfo(Thing thing) { - Weapon* weapon = (Weapon*)getThingData(thing); +WeaponInfo* DungeonMan::f158_getWeaponInfo(Thing thing) { + Weapon* weapon = (Weapon*)f156_getThingData(thing); return &g238_WeaponInfo[weapon->getType()]; } -int16 DungeonMan::getProjectileAspect(Thing thing) { +int16 DungeonMan::f142_getProjectileAspect(Thing thing) { ThingType thingType; int16 projAspOrd; WeaponInfo *weaponInfo; if ((thingType = thing.getType()) == k15_ExplosionThingType) { if (thing == Thing::_explFireBall) - return -_vm->indexToOrdinal(k10_ProjectileAspectExplosionFireBall); + return -_vm->M0_indexToOrdinal(k10_ProjectileAspectExplosionFireBall); if (thing == Thing::_explSlime) - return -_vm->indexToOrdinal(k12_ProjectileAspectExplosionSlime); + return -_vm->M0_indexToOrdinal(k12_ProjectileAspectExplosionSlime); if (thing == Thing::_explLightningBolt) - return -_vm->indexToOrdinal(k3_ProjectileAspectExplosionLightningBolt); + return -_vm->M0_indexToOrdinal(k3_ProjectileAspectExplosionLightningBolt); if ((thing == Thing::_explPoisonBolt) || (thing == Thing::_explPoisonCloud)) - return -_vm->indexToOrdinal(k13_ProjectileAspectExplosionPoisonBoltCloud); + return -_vm->M0_indexToOrdinal(k13_ProjectileAspectExplosionPoisonBoltCloud); - return -_vm->indexToOrdinal(k11_ProjectileAspectExplosionDefault); + return -_vm->M0_indexToOrdinal(k11_ProjectileAspectExplosionDefault); } else if (thingType == k5_WeaponThingType) { - weaponInfo = getWeaponInfo(thing); + weaponInfo = f158_getWeaponInfo(thing); if (projAspOrd = weaponInfo->getProjectileAspectOrdinal()) return -projAspOrd; } - return g237_ObjectInfo[getObjectInfoIndex(thing)]._objectAspectIndex; + return g237_ObjectInfo[f141_getObjectInfoIndex(thing)]._objectAspectIndex; } } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 3b752bdebc..331c3c9e17 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -601,45 +601,45 @@ class DungeonMan { DungeonMan(const DungeonMan &other); // no implementation on purpose void operator=(const DungeonMan &rhs); // no implementation on purpose - Square getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare - Square getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare + Square f151_getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare + Square f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare - void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon + void f455_decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon - int16 getSquareFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex + int16 f160_getSquareFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex - int16 getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal - void setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, + int16 f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal + void f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals - void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap + void f173_setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap public: explicit DungeonMan(DMEngine *dmEngine); ~DungeonMan(); - Thing getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing - Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing) - uint16 *getThingData(Thing thing); // @ unsigned char* F0156_DUNGEON_GetThingData(register THING P0276_T_Thing) - uint16 *getSquareFirstThingData(int16 mapX, int16 mapY); // @ F0157_DUNGEON_GetSquareFirstThingData + Thing f161_getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing + Thing f159_getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing) + uint16 *f156_getThingData(Thing thing); // @ F0156_DUNGEON_GetThingData + uint16 *f157_getSquareFirstThingData(int16 mapX, int16 mapY); // @ F0157_DUNGEON_GetSquareFirstThingData // TODO: this does stuff other than load the file! - void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC - void setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap + void f434_loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC + void f174_setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap - bool isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove - void mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement - SquareType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { - return Square(getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType(); + bool f149_isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove + void f150_mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement + SquareType f153_getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { + return Square(f152_getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType(); } // @ F0153_DUNGEON_GetRelativeSquareType - void setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect - void decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText - - uint16 getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight - int16 getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex - void linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList - WeaponInfo *getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo - int16 getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect + void f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect + void f168_decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText + + uint16 f140_getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight + int16 f141_getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex + void f163_linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList + WeaponInfo *f158_getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo + int16 f142_getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect uint32 _rawDunFileDataSize; // @ probably NONE byte *_rawDunFileData; // @ ??? diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 2e6f473eea..226b616c50 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -316,16 +316,16 @@ void EventManager::processInput() { switch (event.kbd.keycode) { case Common::KEYCODE_w: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); + dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; case Common::KEYCODE_a: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); + dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; case Common::KEYCODE_s: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); + dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; case Common::KEYCODE_d: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); + dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; case Common::KEYCODE_q: turnDirLeft(dungeonMan._g308_partyDir); @@ -335,11 +335,11 @@ void EventManager::processInput() { break; case Common::KEYCODE_UP: if (_dummyMapIndex < 13) - dungeonMan.setCurrentMapAndPartyMap(++_dummyMapIndex); + dungeonMan.f174_setCurrentMapAndPartyMap(++_dummyMapIndex); break; case Common::KEYCODE_DOWN: if (_dummyMapIndex > 0) - dungeonMan.setCurrentMapAndPartyMap(--_dummyMapIndex); + dungeonMan.f174_setCurrentMapAndPartyMap(--_dummyMapIndex); break; default: break; @@ -359,19 +359,19 @@ void EventManager::processInput() { } } -void EventManager::processPendingClick() { +void EventManager::f360_processPendingClick() { if (_g436_pendingClickPresent) { _g436_pendingClickPresent = false; - processClick(_g437_pendingClickPos, _g439_pendingClickButton); + f359_processClick(_g437_pendingClickPos, _g439_pendingClickButton); } } -void EventManager::processClick(Common::Point mousePos, MouseButton button) { +void EventManager::f359_processClick(Common::Point mousePos, MouseButton button) { CommandType commandType; - commandType = getCommandTypeFromMouseInput(_g441_primaryMouseInput, mousePos, button); + commandType = f358_getCommandTypeFromMouseInput(_g441_primaryMouseInput, mousePos, button); if (commandType == k0_CommandNone) - commandType = getCommandTypeFromMouseInput(_g442_secondaryMouseInput, mousePos, button); + commandType = f358_getCommandTypeFromMouseInput(_g442_secondaryMouseInput, mousePos, button); if (commandType != k0_CommandNone) _commandQueue.push(Command(mousePos, commandType)); @@ -379,7 +379,7 @@ void EventManager::processClick(Common::Point mousePos, MouseButton button) { _g435_isCommandQueueLocked = false; } -CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button) { +CommandType EventManager::f358_getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button) { if (!input) return k0_CommandNone; CommandType commandType = k0_CommandNone; @@ -393,11 +393,11 @@ CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common } -void EventManager::processCommandQueue() { +void EventManager::f380_processCommandQueue() { _g435_isCommandQueueLocked = true; if (_commandQueue.empty()) { _g435_isCommandQueueLocked = false; - processPendingClick(); + f360_processPendingClick(); return; } @@ -407,29 +407,29 @@ void EventManager::processCommandQueue() { int16 commandY = cmd._pos.y; _g435_isCommandQueueLocked = false; - processPendingClick(); + f360_processPendingClick(); if ((cmd._type == k2_CommandTurnRight) || (cmd._type == k1_CommandTurnLeft)) { - commandTurnParty(cmd._type); + f365_commandTurnParty(cmd._type); return; } if ((cmd._type >= k3_CommandMoveForward) && (cmd._type <= k6_CommandMoveLeft)) { - commandMoveParty(cmd._type); + f366_commandMoveParty(cmd._type); return; } if (cmd._type == k80_CommandClickInDungeonView) { - commandProcessType80ClickInDungeonView(commandX, commandY); + f377_commandProcessType80ClickInDungeonView(commandX, commandY); } if (cmd._type == k81_CommandClickInPanel) { - commandProcess81ClickInPanel(commandX, commandY); + f378_commandProcess81ClickInPanel(commandX, commandY); } // MISSING CODE: the rest of the function } -void EventManager::commandTurnParty(CommandType cmdType) { +void EventManager::f365_commandTurnParty(CommandType cmdType) { _vm->_g321_stopWaitingForPlayerInput = true; // MISSING CODE: highlight turn left/right buttons @@ -445,7 +445,7 @@ void EventManager::commandTurnParty(CommandType cmdType) { // MISSING CODE: process sensors } -void EventManager::commandMoveParty(CommandType cmdType) { +void EventManager::f366_commandMoveParty(CommandType cmdType) { _vm->_g321_stopWaitingForPlayerInput = true; // MISSING CODE: Lots of code @@ -455,16 +455,16 @@ void EventManager::commandMoveParty(CommandType cmdType) { switch (cmdType) { case k3_CommandMoveForward: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); + dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; case k6_CommandMoveLeft: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); + dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; case k5_CommandMoveBackward: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); + dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; case k4_CommandMoveRight: - dungeonMan.mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); + dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); break; default: break; @@ -473,46 +473,46 @@ void EventManager::commandMoveParty(CommandType cmdType) { // MISSING CODE: Lots of code } -void EventManager::commandSetLeader(ChampionIndex champIndex) { +void EventManager::f368_commandSetLeader(ChampionIndex champIndex) { ChampionMan &cm = *_vm->_championMan; ChampionIndex leaderIndex; - if ((cm._g411_leaderIndex == champIndex) || ((champIndex != kM1_ChampionNone) && !cm._champions[champIndex]._currHealth)) + if ((cm._g411_leaderIndex == champIndex) || ((champIndex != kM1_ChampionNone) && !cm._gK71_champions[champIndex]._currHealth)) return; if (cm._g411_leaderIndex != kM1_ChampionNone) { leaderIndex = cm._g411_leaderIndex; - cm._champions[leaderIndex].setAttributeFlag(k0x0200_ChampionAttributeLoad, true); - cm._champions[leaderIndex].setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true); - cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._414_leaderHandObject); + cm._gK71_champions[leaderIndex].setAttributeFlag(k0x0200_ChampionAttributeLoad, true); + cm._gK71_champions[leaderIndex].setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true); + cm._gK71_champions[leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(cm._g414_leaderHandObject); cm._g411_leaderIndex = kM1_ChampionNone; - cm.drawChampionState(leaderIndex); + cm.f292_drawChampionState(leaderIndex); } if (champIndex == kM1_ChampionNone) { cm._g411_leaderIndex = kM1_ChampionNone; return; } cm._g411_leaderIndex = champIndex; - Champion *champion = &cm._champions[cm._g411_leaderIndex]; + Champion *champion = &cm._gK71_champions[cm._g411_leaderIndex]; champion->_dir = _vm->_dungeonMan->_g308_partyDir; - cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._414_leaderHandObject); - if (_vm->indexToOrdinal(champIndex) != cm._g299_candidateChampionOrdinal) { + cm._gK71_champions[champIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(cm._g414_leaderHandObject); + if (_vm->M0_indexToOrdinal(champIndex) != cm._g299_candidateChampionOrdinal) { champion->setAttributeFlag(k0x0400_ChampionAttributeIcon, true); champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true); - cm.drawChampionState(champIndex); + cm.f292_drawChampionState(champIndex); } } -void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() { +void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() { DungeonMan &dunMan = *_vm->_dungeonMan; int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir]; int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir]; if ((mapX >= 0) && (mapX < dunMan._g273_currMapWidth) && (mapY >= 0) && (mapY < dunMan._g274_currMapHeight)) { - _vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(dunMan._g308_partyDir)); + _vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->f275_sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(dunMan._g308_partyDir)); } } -void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY) { +void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16 posY) { DungeonMan &dunMan = *_vm->_dungeonMan; ChampionMan &champMan = *_vm->_championMan; @@ -524,7 +524,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir]; int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir]; - if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() && + if (Door(dunMan.f157_getSquareFirstThingData(mapX, mapY)).hasButton() && dunMan._g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { _vm->_g321_stopWaitingForPlayerInput = true; warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); @@ -541,7 +541,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY if (dunMan._g291_dungeonViewClickableBoxes[viewCell].isPointInside(Common::Point(posX, posY - 33))) { if (viewCell == k5_ViewCellDoorButtonOrWallOrn) { if (!dunMan._g286_isFacingAlcove) { - commandProcessType80ClickInDungeonViewTouchFrontWall(); + f372_commandProcessType80ClickInDungeonViewTouchFrontWall(); } } else { warning("MISSING CODE: F0373_COMMAND_ProcessType80_ClickInDungeonView_GrabLeaderHandObject"); @@ -550,8 +550,8 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY } } } else { - Thing thing = champMan._414_leaderHandObject; - uint16 *rawThingPointer = dunMan.getThingData(thing); + Thing thing = champMan._g414_leaderHandObject; + uint16 *rawThingPointer = dunMan.f156_getThingData(thing); if (dunMan._g285_squareAheadElement == k0_ElementTypeWall) { for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k1_ViewCellFrontRight; ++viewCell) { if (g462_BoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) { @@ -565,8 +565,8 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject"); } else { if (dunMan._g288_isFacingFountain) { - uint16 iconIndex = _vm->_objectMan->getIconIndex(thing); - int16 weight = dunMan.getObjectWeight(thing); + uint16 iconIndex = _vm->_objectMan->f33_getIconIndex(thing); + int16 weight = dunMan.f140_getObjectWeight(thing); if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) { ((Junk*)rawThingPointer)->setChargeCount(3); } else if (iconIndex == k195_IconIndicePotionEmptyFlask) { @@ -574,11 +574,11 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY } else { goto T0377019; } - champMan.drawChangedObjectIcons(); - champMan._champions[champMan._g411_leaderIndex]._load += dunMan.getObjectWeight(thing) - weight; + champMan.f296_drawChangedObjectIcons(); + champMan._gK71_champions[champMan._g411_leaderIndex]._load += dunMan.f140_getObjectWeight(thing) - weight; } T0377019: - commandProcessType80ClickInDungeonViewTouchFrontWall(); + f372_commandProcessType80ClickInDungeonViewTouchFrontWall(); } } } else { @@ -593,19 +593,19 @@ T0377019: } } -void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType) { +void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType) { ChampionMan &champMan = *_vm->_championMan; InventoryMan &invMan = *_vm->_inventoryMan; DisplayMan &dispMan = *_vm->_displayMan; DungeonMan &dunMan = *_vm->_dungeonMan; uint16 championIndex = champMan._g305_partyChampionCount - 1; - Champion *champ = &champMan._champions[championIndex]; + Champion *champ = &champMan._gK71_champions[championIndex]; if (commandType == k162_CommandClickInPanelCancel) { - invMan.toggleInventory(k4_ChampionCloseInventory); - champMan._g299_candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone); + invMan.f355_toggleInventory(k4_ChampionCloseInventory); + champMan._g299_candidateChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone); if (champMan._g305_partyChampionCount == 1) { - commandSetLeader(kM1_ChampionNone); + f368_commandSetLeader(kM1_ChampionNone); } champMan._g305_partyChampionCount--; Box box; @@ -614,14 +614,14 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane box._x1 = championIndex * k69_ChampionStatusBoxSpacing; box._x2 = box._x1 + 66 + 1; dispMan._g578_useByteBoxCoordinates = false; - dispMan.clearScreenBox(k0_ColorBlack, box); - dispMan.clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2]); + dispMan.D24_clearScreenBox(k0_ColorBlack, box); + dispMan.D24_clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.M26_championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2]); warning("F0457_START_DrawEnabledMenus_CPSF"); warning("F0078_MOUSE_ShowPointer"); return; } - champMan._g299_candidateChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone); + champMan._g299_candidateChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone); int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir]; int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir]; @@ -631,17 +631,17 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList"); } } - Thing thing = dunMan.getSquareFirstThing(mapX, mapY); + Thing thing = dunMan.f161_getSquareFirstThing(mapX, mapY); for (;;) { // infinite if (thing.getType() == k3_SensorThingType) { - ((Sensor*)dunMan.getThingData(thing))->setTypeDisabled(); + ((Sensor*)dunMan.f156_getThingData(thing))->setTypeDisabled(); break; } - thing = dunMan.getNextThing(thing); + thing = dunMan.f159_getNextThing(thing); } if (commandType == k161_CommandClickInPanelReincarnate) { - champMan.renameChampion(champ); + champMan.f281_renameChampion(champ); champ->resetSkillsToZero(); for (uint16 i = 0; i < 12; i++) { @@ -653,10 +653,10 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane if (champMan._g305_partyChampionCount == 1) { warning("MISSING CODE: setting time, G0362_l_LastPartyMovementTime , G0313_ul_GameTime"); - commandSetLeader(k0_ChampionFirst); - _vm->_menuMan->setMagicCasterAndDrawSpellArea(k0_ChampionFirst); + f368_commandSetLeader(k0_ChampionFirst); + _vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(k0_ChampionFirst); } else { - _vm->_menuMan->drawSpellAreaControls(champMan._g514_magicCasterChampionIndex); + _vm->_menuMan->f393_drawSpellAreaControls(champMan._g514_magicCasterChampionIndex); } warning("MISSING CODE: F0051_TEXT_MESSAGEAREA_PrintLineFeed"); @@ -664,12 +664,12 @@ void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePane warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage"); warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage"); - invMan.toggleInventory(k4_ChampionCloseInventory); + invMan.f355_toggleInventory(k4_ChampionCloseInventory); warning("MISSING CODE: F0457_START_DrawEnabledMenus_CPSF"); warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal"); } -void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) { +void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) { ChampionMan &champMan = *_vm->_championMan; InventoryMan &invMan = *_vm->_inventoryMan; @@ -678,23 +678,23 @@ void EventManager::commandProcess81ClickInPanel(int16 x, int16 y) { case k4_PanelContentChest: if (champMan._g411_leaderIndex == kM1_ChampionNone) // if no leader return; - commandType = getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton); + commandType = f358_getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton); if (commandType != k0_CommandNone) warning("MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox"); break; case k5_PanelContentResurrectReincarnate: if (!champMan._g415_leaderEmptyHanded) break; - commandType = getCommandTypeFromMouseInput(g457_MouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), k1_LeftMouseButton); + commandType = f358_getCommandTypeFromMouseInput(g457_MouseInput_PanelResurrectReincarnateCancel, Common::Point(x, y), k1_LeftMouseButton); if (commandType != k0_CommandNone) - commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType); + f282_commandProcessCommands160To162ClickInResurrectReincarnatePanel(commandType); break; default: break; } } -bool EventManager::hasPendingClick(Common::Point& point, MouseButton button) { +bool EventManager::f360_hasPendingClick(Common::Point& point, MouseButton button) { if (_g439_pendingClickButton && button == _g439_pendingClickButton) point = _g437_pendingClickPos; diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index 35f8bd6dc3..51f176185a 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -225,8 +225,8 @@ class EventManager { bool _g435_isCommandQueueLocked; // @ G0435_B_CommandQueueLocked Common::Queue _commandQueue; - void commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty - void commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty + void f365_commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty + void f366_commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty public: explicit EventManager(DMEngine *vm); @@ -242,18 +242,18 @@ public: void setMousePos(Common::Point pos); void processInput(); // acknowledges mouse and keyboard input - void processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick - void processClick(Common::Point mousePos, MouseButton button); // @ F0359_COMMAND_ProcessClick_CPSC - CommandType getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC - void processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC + void f360_processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick + void f359_processClick(Common::Point mousePos, MouseButton button); // @ F0359_COMMAND_ProcessClick_CPSC + CommandType f358_getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC + void f380_processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC - void commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader - void commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall - void commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView - void commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel - void commandProcess81ClickInPanel(int16 x, int16 y); // @ F0378_COMMAND_ProcessType81_ClickInPanel + void f368_commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader + void f372_commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall + void f377_commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView + void f282_commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel + void f378_commandProcess81ClickInPanel(int16 x, int16 y); // @ F0378_COMMAND_ProcessType81_ClickInPanel - bool hasPendingClick(Common::Point &point, MouseButton button); + bool f360_hasPendingClick(Common::Point &point, MouseButton button); // @ F0360_COMMAND_ProcessPendingClick }; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 18deb969cd..a21d8213e1 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -728,7 +728,7 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) { clearScreen(k0_ColorBlack); } -void DisplayMan::loadGraphics() { +void DisplayMan::f479_loadGraphics() { Common::File f; f.open("graphics.dat"); _grapItemCount = f.readUint16BE(); @@ -749,7 +749,7 @@ void DisplayMan::loadGraphics() { unpackGraphics(); } -void DisplayMan::initializeGraphicData() { +void DisplayMan::f460_initializeGraphicData() { _g85_bitmapCeiling = new byte[224 * 29]; _g84_bitmapFloor = new byte[224 * 70]; _g697_bitmapWallSet_Wall_D3L2 = new byte[16 * 49]; @@ -801,8 +801,8 @@ void DisplayMan::initializeGraphicData() { for (int16 objectAspectIndex = 0; objectAspectIndex < k85_ObjAspectCount; ++objectAspectIndex, ++objectAspect) { derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex; - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k16_Scale_D3); - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k20_Scale_D2); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k16_Scale_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k20_Scale_D2); if (getFlag(objectAspect->_graphicInfo, k0x0001_ObjectFlipOnRightMask)) { _g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2]; @@ -825,7 +825,7 @@ void DisplayMan::initializeGraphicData() { derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + projectileAspect->_firstDerivedBitmapRelativeIndex; for (int16 projectileScaleIndex = 0; projectileScaleIndex < 6; projectileScaleIndex++) { - int16 bitmapPixelCount = getScaledBitmapPixelCount(projectileAspect->_width, projectileAspect->_height, g215_ProjectileScales[projectileScaleIndex]); + int16 bitmapPixelCount = f459_getScaledBitmapPixelCount(projectileAspect->_width, projectileAspect->_height, g215_ProjectileScales[projectileScaleIndex]); _g639_derivedBitmapByteCount[derivedBitmapIndex] = bitmapPixelCount; if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k3_ProjectileAspectHasNone) { @@ -847,7 +847,7 @@ void DisplayMan::initializeGraphicData() { ExplosionAspect *expAsp = g211_ExplosionAspects; for (uint16 expAspIndex = 0; expAspIndex < k4_ExplosionAspectCount; ++expAspIndex, expAsp++) { for (int16 scale = 4; scale < 32; scale += 2) - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(expAsp->_pixelWidth, expAsp->_height, scale); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(expAsp->_pixelWidth, expAsp->_height, scale); if (expAspIndex == k3_ExplosionAspectSmoke) { _g639_derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_pixelWidth * expAsp->_height; @@ -863,14 +863,14 @@ void DisplayMan::initializeGraphicData() { creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex; int16 creatureFrontBitmapD3PixelCount; - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3); int16 creatureFrontBitmapD2PixelCount; - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2); if (getFlag(creatureGraphicInfo, k0x0008_CreatureInfoGraphicMaskSide)) { - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k16_Scale_D3); - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k20_Scale_D2); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k16_Scale_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k20_Scale_D2); } if (getFlag(creatureGraphicInfo, k0x0010_CreatureInfoGraphicMaskBack)) { @@ -879,16 +879,16 @@ void DisplayMan::initializeGraphicData() { } if (getFlag(creatureGraphicInfo, k0x0020_CreatureInfoGraphicMaskAttack)) { - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k16_Scale_D3); - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k20_Scale_D2); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k16_Scale_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k20_Scale_D2); } int16 additionalFronGraphicCount; if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, k0x0003_CreatureInfoGraphicMaskAdditional)) { do { _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront; - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3); - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2); } while (--additionalFronGraphicCount); } } @@ -908,15 +908,15 @@ void DisplayMan::unpackGraphics() { } _bitmaps = new byte*[575]; // largest graphic indice (i think) _bitmaps[0] = new byte[unpackedBitmapsSize]; - loadIntoBitmap(0, _bitmaps[0]); + f466_loadIntoBitmap(0, _bitmaps[0]); for (uint16 i = 1; i <= 20; ++i) { _bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1); - loadIntoBitmap(i, _bitmaps[i]); + f466_loadIntoBitmap(i, _bitmaps[i]); } _bitmaps[22] = _bitmaps[20] + getWidth(20) * getHeight(20); for (uint16 i = 23; i <= 532; ++i) { _bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1); - loadIntoBitmap(i, _bitmaps[i]); + f466_loadIntoBitmap(i, _bitmaps[i]); } _bitmaps[k557_FontGraphicIndice] = _bitmaps[532] + getWidth(532) * getHeight(532); loadFNT1intoBitmap(k557_FontGraphicIndice, _bitmaps[k557_FontGraphicIndice]); @@ -955,7 +955,7 @@ void DisplayMan::f566_viewportBlitToScreen() { warning("MISSING FUNCTIONALITY: using correct colorpalette"); Box box(0, 223, 33, 33 + 135); - blitToBitmap(_g296_bitmapViewport, k112_byteWidthViewport * 2, 0, 0, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); + f132_blitToBitmap(_g296_bitmapViewport, k112_byteWidthViewport * 2, 0, 0, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); } void DisplayMan::loadPalette(uint16 *palette) { @@ -969,7 +969,7 @@ void DisplayMan::loadPalette(uint16 *palette) { } -void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { +void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) { uint8 *data = _packedBitmaps + _packedItemPos[index]; uint16 width = READ_BE_UINT16(data); uint16 height = READ_BE_UINT16(data + 2); @@ -1018,7 +1018,7 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) { } -void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent) { +void DisplayMan::f132_blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent) { for (uint16 y = 0; y < box._y2 - box._y1; ++y) for (uint16 x = 0; x < box._x2 - box._x1; ++x) { byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x]; @@ -1028,7 +1028,7 @@ void DisplayMan::blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uin } -void DisplayMan::clearScreenBox(Color color, Box &box) { +void DisplayMan::D24_clearScreenBox(Color color, Box &box) { uint16 width = box._x2 - box._x1; for (int16 y = box._y1; y < box._y2; ++y) memset(_g348_bitmapScreen + y * _screenWidth + box._x1, color, sizeof(byte) * width); @@ -1039,7 +1039,7 @@ void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int memset(destBitmap + y * pixelWidth + box._x1, color, sizeof(byte) * (box._x2 - box._x1)); } -void DisplayMan::blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box, +void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2) { warning("STUB FUNCTION: does nothing at all"); @@ -1047,7 +1047,7 @@ void DisplayMan::blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask -void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) { +void DisplayMan::f103_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) { for (uint16 y = 0; y < height; ++y) { for (uint16 x = 0; x < width / 2; ++x) { byte tmp; @@ -1070,22 +1070,22 @@ void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) { delete[] tmp; } -byte* DisplayMan::getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnPixelWidth, int16& returnHeight) { +byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnPixelWidth, int16& returnHeight) { ExplosionAspect *explAsp = &g211_ExplosionAspects[explosionAspIndex]; if (scale > 32) scale = 32; - int16 pixelWidth = getScaledDimension(explAsp->_pixelWidth, scale); - int16 height = getScaledDimension(explAsp->_height, scale); + int16 pixelWidth = M78_getScaledDimension(explAsp->_pixelWidth, scale); + int16 height = M78_getScaledDimension(explAsp->_height, scale); byte *bitmap; int16 derBitmapIndex = (explosionAspIndex * 14) + scale / 2 + k438_DerivedBitmapFirstExplosion - 2; if ((scale == 32) && (explosionAspIndex != k3_ExplosionAspectSmoke)) { - bitmap = getBitmap(explosionAspIndex + k348_FirstExplosionGraphicIndice); - } else if (isDerivedBitmapInCache(derBitmapIndex)) { - bitmap = getDerivedBitmap(derBitmapIndex); + bitmap = f489_getBitmap(explosionAspIndex + k348_FirstExplosionGraphicIndice); + } else if (f491_isDerivedBitmapInCache(derBitmapIndex)) { + bitmap = f492_getDerivedBitmap(derBitmapIndex); } else { - byte *nativeBitmap = getBitmap(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice); - bitmap = getDerivedBitmap(derBitmapIndex); - blitToBitmapShrinkWithPalChange(nativeBitmap, explAsp->_pixelWidth, explAsp->_height, bitmap, pixelWidth, height, + byte *nativeBitmap = f489_getBitmap(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice); + bitmap = f492_getDerivedBitmap(derBitmapIndex); + f129_blitToBitmapShrinkWithPalChange(nativeBitmap, explAsp->_pixelWidth, explAsp->_height, bitmap, pixelWidth, height, (explosionAspIndex == k3_ExplosionAspectSmoke) ? g212_PalChangeSmoke : g17_PalChangesNoChanges); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } @@ -1148,37 +1148,37 @@ uint16 DisplayMan::getHeight(uint16 index) { // Note: has been screened for missing code void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 pixelWidth, uint16 height) { memmove(destBitmap, srcBitmap, pixelWidth * height * sizeof(byte)); - flipBitmapHorizontal(destBitmap, pixelWidth, height); + f103_flipBitmapHorizontal(destBitmap, pixelWidth, height); } -void DisplayMan::drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { +void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { if (f._srcWidth) - blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k255_ColorNoTransparency); + f132_blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k255_ColorNoTransparency); } -void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) { +void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) { if (f._srcWidth) - blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh); + f132_blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh); } // NOTE: has been screened for missing code -void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { +void DisplayMan::f116_drawSquareD3L(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; int16 order; - _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[k0_ElemAspect]) { case k19_StairsFrontElemType: if (squareAspect[k2_StairsUpAspect]) - drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g110_FrameStairsUpFront_D3L); + f104_drawFloorPitOrStairsBitmap(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g110_FrameStairsUpFront_D3L); else - drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g121_FrameStairsDownFront_D3L); + f104_drawFloorPitOrStairsBitmap(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g121_FrameStairsDownFront_D3L); goto T0116015_redEagle; case k0_WallElemType: - drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k1_ViewSquare_D3L]); - isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT); - if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) { + f100_drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k1_ViewSquare_D3L]); + f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k0_ViewWall_D3L_RIGHT); + if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k2_ViewWall_D3L_FRONT)) { order = k0x0000_CellOrder_Alcove; goto T0116017_orangeElk; } @@ -1189,14 +1189,14 @@ void DisplayMan::drawSquareD3L(direction dir, int16 posX, int16 posY) { goto T0116016_blueToad; case k17_ElementTypeDoorFront: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); - cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); - drawWallSetBitmap(_g705_bitmapWallSet_DoorFrameLeft_D3L, g164_Frame_DoorFrameLeft_D3L); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); + f100_drawWallSetBitmap(_g705_bitmapWallSet_DoorFrameLeft_D3L, g164_Frame_DoorFrameLeft_D3L); warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor"); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; goto T0116017_orangeElk; case k2_ElementTypePit: if (!squareAspect[k2_PitInvisibleAspect]) { - drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, g140_FrameFloorPit_D3L); + f104_drawFloorPitOrStairsBitmap(k49_FloorPit_D3L_GraphicIndice, g140_FrameFloorPit_D3L); } case k5_ElementTypeTeleporter: case k1_ElementTypeCorridor: @@ -1205,32 +1205,32 @@ T0116015_redEagle: T0116016_blueToad: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); T0116017_orangeElk: - cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order); } if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { - drawField(&g188_FieldAspects[k1_ViewSquare_D3L], g163_FrameWalls[k1_ViewSquare_D3L]._box); + f113_drawField(&g188_FieldAspects[k1_ViewSquare_D3L], g163_FrameWalls[k1_ViewSquare_D3L]._box); } } // NOTE: has been screened for missing code -void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { +void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) { int16 order; uint16 squareAspect[5]; - _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[k0_ElemAspect]) { case k19_ElementTypeStaisFront: if (squareAspect[k2_StairsUpAspect]) { - drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g112_FrameStairsUpFront_D3R); + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g675_stairsNativeBitmapIndex_Up_Front_D3L, g112_FrameStairsUpFront_D3R); } else { - drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g123_FrameStairsDownFront_D3R); + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g682_stairsNativeBitmapIndex_Down_Front_D3L, g123_FrameStairsDownFront_D3R); } goto T0117016; case k0_ElementTypeWall: - drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k2_ViewSquare_D3R]); - isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT); - if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) { + f100_drawWallSetBitmap(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k2_ViewSquare_D3R]); + f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k1_ViewWall_D3R_LEFT); + if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k4_ViewWall_D3R_FRONT)) { order = k0x0000_CellOrder_Alcove; goto T0117018; } @@ -1241,7 +1241,7 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { goto T0117017; case k17_ElementTypeDoorFront: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); - cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44); warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally"); if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { @@ -1252,7 +1252,7 @@ void DisplayMan::drawSquareD3R(direction dir, int16 posX, int16 posY) { goto T0117018; case k2_ElementTypePit: if (!squareAspect[k2_PitInvisibleAspect]) { - drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, g142_FrameFloorPit_D3R); + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(k49_FloorPit_D3L_GraphicIndice, g142_FrameFloorPit_D3R); } case k5_ElementTypeTeleporter: case k1_ElementTypeCorridor: @@ -1261,26 +1261,26 @@ T0117016: T0117017: warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); T0117018: - cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order); } if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { - drawField(&g188_FieldAspects[k2_ViewSquare_D3R], g163_FrameWalls[k2_ViewSquare_D3R]._box); + f113_drawField(&g188_FieldAspects[k2_ViewSquare_D3R], g163_FrameWalls[k2_ViewSquare_D3R]._box); } } -void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) { +void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; - _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { case k19_StairsFrontElemType: if (squareAspect[k2_StairsUpAspect]) - drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, g111_FrameStairsUpFront_D3C); + f104_drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, g111_FrameStairsUpFront_D3C); else - drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, g122_FrameStairsDownFront_D3C); + f104_drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, g122_FrameStairsDownFront_D3C); break; case k0_WallElemType: - drawWallSetBitmapWithoutTransparency(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k0_ViewSquare_D3C]); - if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) { + f101_drawWallSetBitmapWithoutTransparency(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k0_ViewSquare_D3C]); + if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) { //... missing code } break; @@ -1288,67 +1288,67 @@ void DisplayMan::drawSquareD3C(direction dir, int16 posX, int16 posY) { break; } } -void DisplayMan::drawSquareD2L(direction dir, int16 posX, int16 posY) { +void DisplayMan::f119_drawSquareD2L(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; - _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { case k19_StairsFrontElemType: if (squareAspect[k2_StairsUpAspect]) - drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L); + f104_drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L); else - drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L); + f104_drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L); break; case k0_WallElemType: - drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]); - isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT); - if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) { + f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]); + f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT); + if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) { // ... missing code } break; case k18_StairsSideElemType: - drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L); + f104_drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L); break; default: break; } } -void DisplayMan::drawSquareD2R(direction dir, int16 posX, int16 posY) { +void DisplayMan::f120_drawSquareD2R(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; - _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { case k19_StairsFrontElemType: if (squareAspect[k2_StairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R); + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R); else - drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R); + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R); break; case k0_WallElemType: - drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]); - isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT); - if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) { + f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]); + f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT); + if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) { // ... missing code } break; case k18_StairsSideElemType: - drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R); + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R); break; default: break; } } -void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) { +void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; - _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { case k19_StairsFrontElemType: if (squareAspect[k2_StairsUpAspect]) - drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, g114_FrameStairsUpFront_D2C); + f104_drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, g114_FrameStairsUpFront_D2C); else - drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, g125_FrameStairsDownFront_D2C); + f104_drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, g125_FrameStairsDownFront_D2C); break; case k0_WallElemType: - drawWallSetBitmapWithoutTransparency(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k3_ViewSquare_D2C]); - if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) { + f101_drawWallSetBitmapWithoutTransparency(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k3_ViewSquare_D2C]); + if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) { // ... missing code } break; @@ -1356,70 +1356,70 @@ void DisplayMan::drawSquareD2C(direction dir, int16 posX, int16 posY) { break; } } -void DisplayMan::drawSquareD1L(direction dir, int16 posX, int16 posY) { +void DisplayMan::f122_drawSquareD1L(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; - _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { case k19_StairsFrontElemType: if (squareAspect[k2_StairsUpAspect]) - drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g116_FrameStairsUpFront_D1L); + f104_drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g116_FrameStairsUpFront_D1L); else - drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g127_FrameStairsDownFront_D1L); + f104_drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g127_FrameStairsDownFront_D1L); break; case k0_WallElemType: - drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k7_ViewSquare_D1L]); - isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT); + f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k7_ViewSquare_D1L]); + f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT); break; case k18_StairsSideElemType: if (squareAspect[k2_StairsUpAspect]) - drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g134_FrameStairsUpSide_D1L); + f104_drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g134_FrameStairsUpSide_D1L); else - drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g136_FrameStairsDownSide_D1L); + f104_drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g136_FrameStairsDownSide_D1L); break; default: break; } } -void DisplayMan::drawSquareD1R(direction dir, int16 posX, int16 posY) { +void DisplayMan::f123_drawSquareD1R(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; - _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { case k19_StairsFrontElemType: if (squareAspect[k2_StairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g118_FrameStairsUpFront_D1R); + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g118_FrameStairsUpFront_D1R); else - drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g129_FrameStairsDownFront_D1R); + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g129_FrameStairsDownFront_D1R); break; case k0_WallElemType: - drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k8_ViewSquare_D1R]); - isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT); + f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k8_ViewSquare_D1R]); + f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT); break; case k18_StairsSideElemType: if (squareAspect[k2_StairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g135_FrameStairsUpSide_D1R); + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g135_FrameStairsUpSide_D1R); else - drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g137_FrameStairsDownSide_D1R); + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g137_FrameStairsDownSide_D1R); break; default: break; } } -void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) { +void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; - _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { case k19_StairsFrontElemType: if (squareAspect[k2_StairsUpAspect]) - drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, g117_FrameStairsUpFront_D1C); + f104_drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, g117_FrameStairsUpFront_D1C); else - drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, g128_FrameStairsDownFront_D1C); + f104_drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, g128_FrameStairsDownFront_D1C); break; case k0_WallElemType: _vm->_dungeonMan->_g286_isFacingAlcove = false; _vm->_dungeonMan->_g287_isFacingViAltar = false; _vm->_dungeonMan->_g288_isFacingFountain = false; - drawWallSetBitmapWithoutTransparency(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k6_ViewSquare_D1C]); - if (isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) { + f101_drawWallSetBitmapWithoutTransparency(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k6_ViewSquare_D1C]); + if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) { // .... code not yet implemneted } break; @@ -1428,49 +1428,49 @@ void DisplayMan::drawSquareD1C(direction dir, int16 posX, int16 posY) { } } -void DisplayMan::drawSquareD0L(direction dir, int16 posX, int16 posY) { +void DisplayMan::f125_drawSquareD0L(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; - _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { case k18_StairsSideElemType: if (squareAspect[k2_StairsUpAspect]) - drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, g138_FrameStairsSide_D0L); + f104_drawFloorPitOrStairsBitmap(_g692_stairsNativeBitmapIndex_Side_D0L, g138_FrameStairsSide_D0L); break; case k0_WallElemType: - drawWallSetBitmap(_g701_bitmapWallSet_Wall_D0L, g163_FrameWalls[k10_ViewSquare_D0L]); + f100_drawWallSetBitmap(_g701_bitmapWallSet_Wall_D0L, g163_FrameWalls[k10_ViewSquare_D0L]); break; default: break; } } -void DisplayMan::drawSquareD0R(direction dir, int16 posX, int16 posY) { +void DisplayMan::f126_drawSquareD0R(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; - _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { case k18_StairsSideElemType: if (squareAspect[k2_StairsUpAspect]) - drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R); + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R); return; case k0_WallElemType: - drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, g163_FrameWalls[k11_ViewSquare_D0R]); + f100_drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, g163_FrameWalls[k11_ViewSquare_D0R]); break; default: break; } } -void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) { +void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; - _vm->_dungeonMan->setSquareAspect(squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { case k19_StairsFrontElemType: if (squareAspect[k2_StairsUpAspect]) { - drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g119_FrameStairsUpFront_D0L); - drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g120_FrameStairsUpFront_D0R); + f104_drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g119_FrameStairsUpFront_D0L); + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g120_FrameStairsUpFront_D0R); } else { - drawFloorPitOrStairsBitmap(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g130_FrameStairsDownFront_D0L); - drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g131_FrameStairsDownFront_D0R); + f104_drawFloorPitOrStairsBitmap(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g130_FrameStairsDownFront_D0L); + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g131_FrameStairsDownFront_D0R); } break; default: @@ -1478,7 +1478,7 @@ void DisplayMan::drawSquareD0C(direction dir, int16 posX, int16 posY) { } } -void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { +void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) { loadPalette(g20_PalEntrance); // TODO: this is a global variable, set from here bool flippedFloorCeiling = true; @@ -1492,9 +1492,9 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { } if (_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1) { - drawWallSetBitmap(_g85_bitmapCeiling, gK12_CeilingFrame); + f100_drawWallSetBitmap(_g85_bitmapCeiling, gK12_CeilingFrame); f99_copyBitmapAndFlipHorizontal(_g84_bitmapFloor, _g74_tmpBitmap, k112_byteWidthViewport * 2, 70); - drawWallSetBitmap(_g74_tmpBitmap, gK13_FloorFrame); + f100_drawWallSetBitmap(_g74_tmpBitmap, gK13_FloorFrame); if (flippedFloorCeiling) { _g698_bitmapWallSet_Wall_D3LCR = _g90_bitmapWall_D3LCR_Flipped; @@ -1505,49 +1505,49 @@ void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { } } else { f99_copyBitmapAndFlipHorizontal(_g85_bitmapCeiling, _g74_tmpBitmap, k112_byteWidthViewport * 2, 29); - drawWallSetBitmap(_g74_tmpBitmap, gK12_CeilingFrame); - drawWallSetBitmap(_g84_bitmapFloor, gK13_FloorFrame); + f100_drawWallSetBitmap(_g74_tmpBitmap, gK12_CeilingFrame); + f100_drawWallSetBitmap(_g84_bitmapFloor, gK13_FloorFrame); } - if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == k0_WallElemType) - drawWallSetBitmap(_g697_bitmapWallSet_Wall_D3L2, g711_FrameWall_D3L2); - if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == k0_WallElemType) - drawWallSetBitmap(_g696_bitmapWallSet_Wall_D3R2, g712_FrameWall_D3R2); + if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, -2, posX, posY) == k0_WallElemType) + f100_drawWallSetBitmap(_g697_bitmapWallSet_Wall_D3L2, g711_FrameWall_D3L2); + if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, 2, posX, posY) == k0_WallElemType) + f100_drawWallSetBitmap(_g696_bitmapWallSet_Wall_D3R2, g712_FrameWall_D3R2); int16 tmpPosX = posX, tmpPosY = posY; - _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY); - drawSquareD3L(dir, tmpPosX, tmpPosY); + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY); + f116_drawSquareD3L(dir, tmpPosX, tmpPosY); tmpPosX = posX, tmpPosY = posY; - _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, 1, tmpPosX, tmpPosY); - drawSquareD3R(dir, tmpPosX, tmpPosY); + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, 1, tmpPosX, tmpPosY); + f117_drawSquareD3R(dir, tmpPosX, tmpPosY); tmpPosX = posX, tmpPosY = posY; - _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 3, 0, tmpPosX, tmpPosY); - drawSquareD3C(dir, tmpPosX, tmpPosY); + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, 0, tmpPosX, tmpPosY); + f118_drawSquareD3C(dir, tmpPosX, tmpPosY); tmpPosX = posX, tmpPosY = posY; - _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, -1, tmpPosX, tmpPosY); - drawSquareD2L(dir, tmpPosX, tmpPosY); + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, -1, tmpPosX, tmpPosY); + f119_drawSquareD2L(dir, tmpPosX, tmpPosY); tmpPosX = posX, tmpPosY = posY; - _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, 1, tmpPosX, tmpPosY); - drawSquareD2R(dir, tmpPosX, tmpPosY); + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, 1, tmpPosX, tmpPosY); + f120_drawSquareD2R(dir, tmpPosX, tmpPosY); tmpPosX = posX, tmpPosY = posY; - _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 2, 0, tmpPosX, tmpPosY); - drawSquareD2C(dir, tmpPosX, tmpPosY); + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, 0, tmpPosX, tmpPosY); + f121_drawSquareD2C(dir, tmpPosX, tmpPosY); tmpPosX = posX, tmpPosY = posY; - _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, -1, tmpPosX, tmpPosY); - drawSquareD1L(dir, tmpPosX, tmpPosY); + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, -1, tmpPosX, tmpPosY); + f122_drawSquareD1L(dir, tmpPosX, tmpPosY); tmpPosX = posX, tmpPosY = posY; - _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, 1, tmpPosX, tmpPosY); - drawSquareD1R(dir, tmpPosX, tmpPosY); + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, 1, tmpPosX, tmpPosY); + f123_drawSquareD1R(dir, tmpPosX, tmpPosY); tmpPosX = posX, tmpPosY = posY; - _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 1, 0, tmpPosX, tmpPosY); - drawSquareD1C(dir, tmpPosX, tmpPosY); + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, 0, tmpPosX, tmpPosY); + f124_drawSquareD1C(dir, tmpPosX, tmpPosY); tmpPosX = posX, tmpPosY = posY; - _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 0, -1, tmpPosX, tmpPosY); - drawSquareD0L(dir, tmpPosX, tmpPosY); + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 0, -1, tmpPosX, tmpPosY); + f125_drawSquareD0L(dir, tmpPosX, tmpPosY); tmpPosX = posX, tmpPosY = posY; - _vm->_dungeonMan->mapCoordsAfterRelMovement(dir, 0, 1, tmpPosX, tmpPosY); - drawSquareD0R(dir, tmpPosX, tmpPosY); - drawSquareD0C(dir, posX, posY); + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 0, 1, tmpPosX, tmpPosY); + f126_drawSquareD0R(dir, tmpPosX, tmpPosY); + f127_drawSquareD0C(dir, posX, posY); if (flippedFloorCeiling) { _g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native; @@ -1569,12 +1569,12 @@ void DisplayMan::f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Colo } // NOTE: has been screened for missing code -void DisplayMan::loadFloorSet(FloorSet set) { +void DisplayMan::f94_loadFloorSet(FloorSet set) { if (_g230_currentFloorSet != set) { _g230_currentFloorSet = set; int16 index = (set * k2_FloorSetGraphicCount) + k75_FirstFloorSet; - loadIntoBitmap(index, _g84_bitmapFloor); - loadIntoBitmap(index + 1, _g85_bitmapCeiling); + f466_loadIntoBitmap(index, _g84_bitmapFloor); + f466_loadIntoBitmap(index + 1, _g85_bitmapCeiling); } } @@ -1582,25 +1582,25 @@ Box g161_BoxWallBitmap_D3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_W Box g162_BoxWallBitmap_D2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR // Note: has been screened for missing code -void DisplayMan::loadWallSet(WallSet set) { +void DisplayMan::f95_loadWallSet(WallSet set) { if ((_g231_currentWallSet != set) || _vm->_g523_restartGameRequest) { _g231_currentWallSet = set; { int16 graphicIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet; - loadIntoBitmap(graphicIndice++, _g709_bitmapWallSet_DoorFrameFront); - loadIntoBitmap(graphicIndice++, _g708_bitmapWallSet_DoorFrameLeft_D1C); - loadIntoBitmap(graphicIndice++, _g707_bitmapWallSet_DoorFrameLeft_D2C); - loadIntoBitmap(graphicIndice++, _g706_bitmapWallSet_DoorFrameLeft_D3C); - loadIntoBitmap(graphicIndice++, _g705_bitmapWallSet_DoorFrameLeft_D3L); - loadIntoBitmap(graphicIndice++, _g704_bitmapWallSet_DoorFrameTop_D1LCR); - loadIntoBitmap(graphicIndice++, _g703_bitmapWallSet_DoorFrameTop_D2LCR); - loadIntoBitmap(graphicIndice++, _g702_bitmapWallSet_Wall_D0R); - loadIntoBitmap(graphicIndice++, _g701_bitmapWallSet_Wall_D0L); - loadIntoBitmap(graphicIndice++, _g700_bitmapWallSet_Wall_D1LCR); - loadIntoBitmap(graphicIndice++, _g699_bitmapWallSet_Wall_D2LCR); - loadIntoBitmap(graphicIndice++, _g698_bitmapWallSet_Wall_D3LCR); - loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2); + f466_loadIntoBitmap(graphicIndice++, _g709_bitmapWallSet_DoorFrameFront); + f466_loadIntoBitmap(graphicIndice++, _g708_bitmapWallSet_DoorFrameLeft_D1C); + f466_loadIntoBitmap(graphicIndice++, _g707_bitmapWallSet_DoorFrameLeft_D2C); + f466_loadIntoBitmap(graphicIndice++, _g706_bitmapWallSet_DoorFrameLeft_D3C); + f466_loadIntoBitmap(graphicIndice++, _g705_bitmapWallSet_DoorFrameLeft_D3L); + f466_loadIntoBitmap(graphicIndice++, _g704_bitmapWallSet_DoorFrameTop_D1LCR); + f466_loadIntoBitmap(graphicIndice++, _g703_bitmapWallSet_DoorFrameTop_D2LCR); + f466_loadIntoBitmap(graphicIndice++, _g702_bitmapWallSet_Wall_D0R); + f466_loadIntoBitmap(graphicIndice++, _g701_bitmapWallSet_Wall_D0L); + f466_loadIntoBitmap(graphicIndice++, _g700_bitmapWallSet_Wall_D1LCR); + f466_loadIntoBitmap(graphicIndice++, _g699_bitmapWallSet_Wall_D2LCR); + f466_loadIntoBitmap(graphicIndice++, _g698_bitmapWallSet_Wall_D3LCR); + f466_loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2); } f99_copyBitmapAndFlipHorizontal(_g708_bitmapWallSet_DoorFrameLeft_D1C, _g710_bitmapWallSet_DoorFrameRight_D1C, g171_Frame_DoorFrameRight_D1C._srcWidth, g171_Frame_DoorFrameRight_D1C._srcHeight); @@ -1610,9 +1610,9 @@ void DisplayMan::loadWallSet(WallSet set) { } -void DisplayMan::loadCurrentMapGraphics() { - loadFloorSet(_vm->_dungeonMan->_g269_currMap->_floorSet); - loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet); +void DisplayMan::f96_loadCurrentMapGraphics() { + f94_loadFloorSet(_vm->_dungeonMan->_g269_currMap->_floorSet); + f95_loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet); { _g74_tmpBitmap = new byte[_screenWidth * _screenHeight]; @@ -1621,12 +1621,12 @@ void DisplayMan::loadCurrentMapGraphics() { f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap, g163_FrameWalls[k0_ViewSquare_D3C]._srcWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight); f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, 128, 51, k10_ColorFlesh); - blitToBitmap(_g74_tmpBitmap, 128, 11, 0, _g90_bitmapWall_D3LCR_Flipped, 128, g161_BoxWallBitmap_D3LCR, k255_ColorNoTransparency); + f132_blitToBitmap(_g74_tmpBitmap, 128, 11, 0, _g90_bitmapWall_D3LCR_Flipped, 128, g161_BoxWallBitmap_D3LCR, k255_ColorNoTransparency); f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap, g163_FrameWalls[k3_ViewSquare_D2C]._srcWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight); f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, 144, 71, k10_ColorFlesh); - blitToBitmap(_g74_tmpBitmap, 144, 8, 0, _g91_bitmapWall_D2LCR_Flipped, 144, g162_BoxWallBitmap_D2LCR, k255_ColorNoTransparency); + f132_blitToBitmap(_g74_tmpBitmap, 144, 8, 0, _g91_bitmapWall_D2LCR_Flipped, 144, g162_BoxWallBitmap_D2LCR, k255_ColorNoTransparency); f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped, g163_FrameWalls[k6_ViewSquare_D1C]._srcWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight); @@ -1707,23 +1707,23 @@ void DisplayMan::loadCurrentMapGraphics() { _g103_currMapDoorOrnInfo[i][k1_CoordinateSet] = g196_DoorOrnCoordIndices[ornIndice]; } - applyCreatureReplColors(9, 8); - applyCreatureReplColors(10, 12); + f93_applyCreatureReplColors(9, 8); + f93_applyCreatureReplColors(10, 12); for (uint16 creatureType = 0; creatureType < currMap._creatureTypeCount; ++creatureType) { CreatureAspect &aspect = g219_CreatureAspects[_g264_currMapAllowedCreatureTypes[creatureType]]; uint16 replColorOrdinal = aspect.getReplColour9(); if (replColorOrdinal) - applyCreatureReplColors(9, _vm->ordinalToIndex(replColorOrdinal)); + f93_applyCreatureReplColors(9, _vm->M1_ordinalToIndex(replColorOrdinal)); replColorOrdinal = aspect.getReplColour10(); if (replColorOrdinal) - applyCreatureReplColors(10, _vm->ordinalToIndex(replColorOrdinal)); + f93_applyCreatureReplColors(10, _vm->M1_ordinalToIndex(replColorOrdinal)); } _g342_refreshDungeonViewPaleteRequested = true; } -void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor) { +void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementColor) { for (int16 i = 0; i < 6; ++i) g21_PalDungeonView[i][replacedColor] = g220_CreatureReplColorSets[replacementColor]._RGBColor[i]; @@ -1731,15 +1731,15 @@ void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor g221_PalChangesCreature_D3[replacedColor] = g220_CreatureReplColorSets[replacementColor]._D3ReplacementColor; } -void DisplayMan::drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) { +void DisplayMan::f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) { if (f._srcWidth) - blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh); + f132_blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh); } -void DisplayMan::drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) { +void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) { if (f._srcWidth) { - f99_copyBitmapAndFlipHorizontal(getBitmap(nativeIndex), _g74_tmpBitmap, f._srcWidth, f._srcHeight); - blitToBitmap(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh); + f99_copyBitmapAndFlipHorizontal(f489_getBitmap(nativeIndex), _g74_tmpBitmap, f._srcWidth, f._srcHeight); + f132_blitToBitmap(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh); } } @@ -1777,7 +1777,7 @@ byte g204_UnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_Unreadabl Box g109_BoxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall -bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) { +bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) { byte *bitmapGreen; byte *bitmapRed; int16 coordinateSetOffset; @@ -1794,17 +1794,17 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex int16 nativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k0_NativeBitmapIndex]; uint16 *coordinateSetA = g205_WallOrnCoordSets[_g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]][viewWallIndex]; - isAlcove = _vm->_dungeonMan->isWallOrnAnAlcove(wallOrnIndex); + isAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(wallOrnIndex); isInscription = (wallOrnIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex); if (isInscription) { - _vm->_dungeonMan->decodeText((char*)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription); + _vm->_dungeonMan->f168_decodeText((char*)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription); } if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) { if (viewWallIndex == k12_ViewWall_D1C_FRONT) { if (isInscription) { Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C]; - blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, _g296_bitmapViewport, k112_byteWidthViewport * 2, + f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, _g296_bitmapViewport, k112_byteWidthViewport * 2, g202_BoxWallPatchBehindInscription, k255_ColorNoTransparency); unsigned char *string = inscriptionString; @@ -1819,7 +1819,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7; frame._box._y1 = (frame._box._y2 = g203_InscriptionLineY[textLineIndex++]) - 7; while (characterCount--) { - blitToBitmap(bitmapRed, 288, (*string++) * 8, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, frame._box, k10_ColorFlesh); + f132_blitToBitmap(bitmapRed, 288, (*string++) * 8, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, frame._box, k10_ColorFlesh); frame._box._x1 += 8; frame._box._x2 += 8; } @@ -1868,7 +1868,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex } } int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0]; - blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], coordSetB[4] << 1, coordSetB[5], _g74_tmpBitmap, pixelWidth + 1, coordinateSetA[5], + f129_blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], coordSetB[4] << 1, coordSetB[5], _g74_tmpBitmap, pixelWidth + 1, coordinateSetA[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2); bitmapGreen = _bitmaps[nativeBitmapIndex]; var_X = pixelWidth; @@ -1905,11 +1905,11 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1]; } } - blitToBitmap(bitmapGreen, coordinateSetA[4], var_X, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, *(Box*)coordinateSetA, k10_ColorFlesh); + f132_blitToBitmap(bitmapGreen, coordinateSetA[4], var_X, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, *(Box*)coordinateSetA, k10_ColorFlesh); if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { Box &box = g109_BoxChampionPortraitOnWall; - blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29, + f132_blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29, _g296_bitmapViewport, k112_byteWidthViewport * 2, box, k1_ColorDarkGary); } return isAlcove; @@ -1918,7 +1918,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex } -void DisplayMan::blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHeight, byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange) { +void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHeight, byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange) { double rateW = srcWidth / destWidth; double rateH = srcHeight / destHeight; @@ -1933,7 +1933,7 @@ void DisplayMan::blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth } -byte* DisplayMan::getBitmap(uint16 index) { +byte* DisplayMan::f489_getBitmap(uint16 index) { return _bitmaps[index]; } @@ -1950,7 +1950,7 @@ uint32 DisplayMan::getCompressedDataSize(uint16 index) { #define kMaskFieldAspectIndex 0x007F // @ MASK0x007F_MASK_INDEX #define kMaskFieldAspectNoMask 255 // @ C255_NO_MASK -void DisplayMan::drawField(FieldAspect* fieldAspect, Box& box) { +void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) { DisplayMan &dispMan = *_vm->_displayMan; byte *bitmapMask; @@ -1958,24 +1958,24 @@ void DisplayMan::drawField(FieldAspect* fieldAspect, Box& box) { bitmapMask = nullptr; } else { bitmapMask = dispMan._g74_tmpBitmap; - memmove(bitmapMask, dispMan.getBitmap(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)), + memmove(bitmapMask, dispMan.f489_getBitmap(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)), fieldAspect->_height * fieldAspect->_pixelWidth * sizeof(bitmapMask[0])); if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) { - dispMan.flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height); + dispMan.f103_flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height); } } - byte *bitmap = dispMan.getBitmap(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex); + byte *bitmap = dispMan.f489_getBitmap(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex); warning("MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap"); warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock"); } -int16 DisplayMan::getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale) { - return getScaledDimension(pixelWidth, scale) * getScaledDimension(pixelHeight, scale); +int16 DisplayMan::f459_getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale) { + return M78_getScaledDimension(pixelWidth, scale) * M78_getScaledDimension(pixelHeight, scale); } -int16 DisplayMan::getScaledDimension(int16 dimension, int16 scale) { +int16 DisplayMan::M78_getScaledDimension(int16 dimension, int16 scale) { return (dimension * scale + scale / 2) / 32; } @@ -2135,7 +2135,7 @@ int16 g225_CenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_Cen #define k0x0080_BlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK -void DisplayMan::cthulhu(Thing thingParam, direction directionParam, int16 mapXpos, +void DisplayMan::f115_cthulhu(Thing thingParam, direction directionParam, int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) { DungeonMan &dunMan = *_vm->_dungeonMan; @@ -2276,7 +2276,7 @@ creatures are drawn in the right order and so that Fluxcages are not drawn twice cellYellowBear = returnOppositeDir(directionParam); /* Alcove is on the opposite direction of the viewing direction */ objectShiftIndex = 2; } else { - AL_2_viewCell = _vm->ordinalToIndex((int16)remainingViewCellOrdinalsToProcess & 0x000F); /* View cell is the index of coordinates to draw object */ + AL_2_viewCell = _vm->M1_ordinalToIndex((int16)remainingViewCellOrdinalsToProcess & 0x000F); /* View cell is the index of coordinates to draw object */ currentViewCellToDraw = AL_2_viewCell; remainingViewCellOrdinalsToProcess >>= 4; /* Proceed to the next cell ordinal */ cellCounter++; @@ -2304,7 +2304,7 @@ creatures are drawn in the right order and so that Fluxcages are not drawn twice /* Square where objects are visible and object is located on cell being processed */ if ((viewSquareIndex >= k0_ViewSquare_D3C) && (viewSquareIndex <= k9_ViewSquare_D0C) && (thingParam.getCell() == cellYellowBear)) { - objectAspect = &(g209_ObjectAspects[g237_ObjectInfo[dunMan.getObjectInfoIndex(thingParam)]._objectAspectIndex]); + objectAspect = &(g209_ObjectAspects[g237_ObjectInfo[dunMan.f141_getObjectInfoIndex(thingParam)]._objectAspectIndex]); AL_4_nativeBitmapIndex = k360_FirstObjectGraphicIndice + objectAspect->_firstNativeBitmapRelativeIndex; if (useAlcoveObjectImage = (drawAlcoveObjects && getFlag(objectAspect->_graphicInfo, k0x0010_ObjectAlcoveMask) && !viewLane)) { AL_4_nativeBitmapIndex++; @@ -2324,12 +2324,12 @@ T0115015_DrawProjectileAsObject: /* If object is in the center lane (only D0C or D1C with condition above) and is not a projectile */ drawingGrabbableObject = (!viewLane && !drawProjectileAsObject); AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front; - AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */ + AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */ byteWidth = objectAspect->_width; heightRedEagle = objectAspect->_height; if (flipHorizontal) { memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); - flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); + f103_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; } } else { @@ -2338,13 +2338,13 @@ T0115015_DrawProjectileAsObject: if ((viewSquareIndex >= k6_ViewSquare_D1C) || ((viewSquareIndex >= k3_ViewSquare_D2C) && (AL_2_viewCell >= k2_ViewCellBackRight))) { derivedBitmapIndex++; AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front; - byteWidth = getScaledDimension(objectAspect->_width, k20_Scale_D2); - heightRedEagle = getScaledDimension(objectAspect->_height, k20_Scale_D2); + byteWidth = M78_getScaledDimension(objectAspect->_width, k20_Scale_D2); + heightRedEagle = M78_getScaledDimension(objectAspect->_height, k20_Scale_D2); paletteChanges = g214_PalChangesFloorOrn_D2; } else { AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front; - byteWidth = getScaledDimension(objectAspect->_width, k16_Scale_D3); - heightRedEagle = getScaledDimension(objectAspect->_height, k16_Scale_D3); + byteWidth = M78_getScaledDimension(objectAspect->_width, k16_Scale_D3); + heightRedEagle = M78_getScaledDimension(objectAspect->_height, k16_Scale_D3); paletteChanges = g213_PalChangesFloorOrn_D3; } if (flipHorizontal) { @@ -2354,14 +2354,14 @@ T0115015_DrawProjectileAsObject: derivedBitmapIndex += 4; } - if (isDerivedBitmapInCache(derivedBitmapIndex)) { - AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); + if (f491_isDerivedBitmapInCache(derivedBitmapIndex)) { + AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); } else { - bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex); - blitToBitmapShrinkWithPalChange(bitmapGreenAnt, objectAspect->_width, objectAspect->_height, AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex), + bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex); + f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, objectAspect->_width, objectAspect->_height, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), byteWidth, heightRedEagle, paletteChanges); if (flipHorizontal) { - flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); + f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } @@ -2417,12 +2417,12 @@ T0115015_DrawProjectileAsObject: AL_6_bitmapRedBanana = bitmapGreenAnt; dunMan._g292_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */ } - blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh); + f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh); if (drawProjectileAsObject) goto T0115171_BackFromT0115015_DrawProjectileAsObject; } - } while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList); + } while ((thingParam = dunMan.f159_getNextThing(thingParam)) != Thing::_endOfList); if (AL_2_viewCell == k4_ViewCellAlcove) break; /* End of processing when drawing objects in an alcove */ if (viewSquareIndex < k0_ViewSquare_D3C) @@ -2436,7 +2436,7 @@ T0115015_DrawProjectileAsObject: if ((groupThing == Thing::_none) || drawCreaturesCompleted) goto T0115129_DrawProjectiles; /* Skip code to draw creatures */ if (group == nullptr) { /* If all creature data and info has not already been gathered */ - group = (Group*)dunMan.getThingData(groupThing); + group = (Group*)dunMan.f156_getThingData(groupThing); activeGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]; creatureInfo = &g243_CreatureInfo[group->_type]; creatureAspectStruct = &g219_CreatureAspects[creatureInfo->_creatureAspectIndex]; @@ -2444,7 +2444,7 @@ T0115015_DrawProjectileAsObject: creatureGraphicInfoGreen = creatureInfo->_graphicInfo; } objectAspect = (ObjectAspect*)creatureAspectStruct; - if (AL_0_creatureIndexRed = _vm->_groupMan->getCreatureOrdinalInCell(group, cellYellowBear)) { /* If there is a creature on the cell being processed */ + if (AL_0_creatureIndexRed = _vm->_groupMan->f176_getCreatureOrdinalInCell(group, cellYellowBear)) { /* If there is a creature on the cell being processed */ AL_0_creatureIndexRed--; /* Convert ordinal to index */ creatureIndexGreen = AL_0_creatureIndexRed; } else if (creatureSize == k1_MaskCreatureSizeHalf) { @@ -2454,7 +2454,7 @@ T0115015_DrawProjectileAsObject: goto T0115129_DrawProjectiles; /* No creature to draw at cell, skip to projectiles */ } - creatureDirectionDelta = (directionParam - _vm->_groupMan->getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed)) % 3; + creatureDirectionDelta = (directionParam - _vm->_groupMan->M50_getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed)) % 3; twoHalfSquareCreaturesFrontView = false; if ((AL_4_groupCells = activeGroup->_cells) == k255_CreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */ if (remainingViewCellOrdinalsToProcess || (doorFrontViewDrawingPass == 1)) @@ -2487,7 +2487,7 @@ T0115015_DrawProjectileAsObject: creatureIndexGreen = 0; } twoHalfSquareCreaturesFrontView = group->getCount(); - if (((AL_4_groupCells = _vm->_groupMan->getCreatureValue(AL_4_groupCells, AL_0_creatureIndexRed)) == directionParam) + if (((AL_4_groupCells = _vm->_groupMan->M50_getCreatureValue(AL_4_groupCells, AL_0_creatureIndexRed)) == directionParam) || (AL_4_groupCells == returnPrevVal(directionParam))) { AL_2_viewCell = k0_HalfSizedViewCell_LeftColumn; } else { @@ -2571,29 +2571,29 @@ T0115077_DrawSecondHalfSquareCreature: AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front; transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour(); if (useCreatureSideBitmap) { - AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); + AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex); if (creatureDirectionDelta == 1) { memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); - flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); + f103_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; } } else { if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) { - AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); + AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex); if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) { memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); - flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); + f103_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; } } else { /* Use first additional derived graphic: front D1 */ - if (isDerivedBitmapInCache(derivedBitmapIndex)) { /* If derived graphic is already in memory */ - AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); + if (f491_isDerivedBitmapInCache(derivedBitmapIndex)) { /* If derived graphic is already in memory */ + AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); } else { - bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex); + bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex); if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) { - AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); + AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); memmove(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * heightRedEagle * sizeof(byte)); - flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); + f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } @@ -2616,15 +2616,15 @@ T0115077_DrawSecondHalfSquareCreature: paletteChanges = g221_PalChangesCreature_D3; scale = k16_Scale_D3; } - byteWidth = getScaledDimension(sourceByteWidth, scale); - heightRedEagle = getScaledDimension(sourceHeight, scale); + byteWidth = M78_getScaledDimension(sourceByteWidth, scale); + heightRedEagle = M78_getScaledDimension(sourceHeight, scale); transparentColor = paletteChanges[((CreatureAspect*)objectAspect)->getTranspColour()] / 10; - if (derivedBitmapInCache = isDerivedBitmapInCache(derivedBitmapIndex)) { - AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); + if (derivedBitmapInCache = f491_isDerivedBitmapInCache(derivedBitmapIndex)) { + AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); } else { - bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex); - AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); - blitToBitmapShrinkWithPalChange(bitmapGreenAnt, sourceByteWidth, sourceHeight, AL_6_bitmapRedBanana, byteWidth, heightRedEagle, paletteChanges); + bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex); + AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); + f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, sourceByteWidth, sourceHeight, AL_6_bitmapRedBanana, byteWidth, heightRedEagle, paletteChanges); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */ @@ -2633,12 +2633,12 @@ T0115077_DrawSecondHalfSquareCreature: (useFlippedHorizontallyCreatureFrontImage && getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack))) { /* If the graphic should be flipped */ if (!useFlippedHorizontallyCreatureFrontImage || !derivedBitmapInCache) { AL_4_normalizdByteWidth = byteWidth; - warning("SUPER WARNING: we might need getNormalizedByteWidthM77"); + warning("SUPER WARNING: we might need M77_getNormalizedByteWidth"); if (!useFlippedHorizontallyCreatureFrontImage) { memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte)); AL_6_bitmapRedBanana = _g74_tmpBitmap; } - flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); + f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); } creaturePaddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; } else { @@ -2646,11 +2646,11 @@ T0115077_DrawSecondHalfSquareCreature: } } AL_4_yPos = coordinateSet[1]; - AL_4_yPos += g223_ShiftSets[AL_8_shiftSetIndex][getVerticalOffsetM23(creatureAspectInt)]; + AL_4_yPos += g223_ShiftSets[AL_8_shiftSetIndex][M23_getVerticalOffsetM23(creatureAspectInt)]; boxByteGreen._y2 = MIN(AL_4_yPos, (int16)135) + 1; boxByteGreen._y1 = MIN(0, AL_4_yPos - (heightRedEagle - 1)); AL_4_xPos = coordinateSet[0]; - AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][getHorizontalOffsetM22(creatureAspectInt)]; + AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][M22_getHorizontalOffsetM22(creatureAspectInt)]; if (viewLane == k1_ViewLaneLeft) { AL_4_xPos -= 100; } else { @@ -2668,7 +2668,7 @@ T0115077_DrawSecondHalfSquareCreature: AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1); } warning("SUPER WARNINIG: we might nee noralized with on byteWidth"); - blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, (Color)transparentColor); + f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, (Color)transparentColor); T0115126_CreatureNotVisible: if (twoHalfSquareCreaturesFrontView) { @@ -2692,9 +2692,9 @@ continue; do { if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) { - projectile = (Projectile*)dunMan.getThingData(thingParam); - if ((AL_4_projectileAspect = dunMan.getProjectileAspect(projectile->_object)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */ - objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)]; + projectile = (Projectile*)dunMan.f156_getThingData(thingParam); + if ((AL_4_projectileAspect = dunMan.f142_getProjectileAspect(projectile->_object)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */ + objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)]; AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice; projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask); if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) @@ -2708,8 +2708,8 @@ continue; if (!doNotScaleWithKineticEnergy) { scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8; } - byteWidth = getScaledDimension(((ProjectileAspect*)objectAspect)->_width, scale); - heightRedEagle = getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale); + byteWidth = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_width, scale); + heightRedEagle = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale); } if (projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == k0_ProjectileAspectHasBackGraphicRotation)) { projectileFlipVertical = ((mapXpos + mapYpos) & 0x0001); @@ -2751,22 +2751,22 @@ continue; AL_4_nativeBitmapIndex += projectileBitmapIndexData; paddingPixelCount = 0; if (!scale) { - AL_6_bitmapRedBanana = getBitmap(AL_4_nativeBitmapIndex); + AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex); } else { if (flipHorizontal) { paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; } derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6); - if (doNotScaleWithKineticEnergy && isDerivedBitmapInCache(derivedBitmapIndex) + AL_8_projectileScaleIndex) { - AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); + if (doNotScaleWithKineticEnergy && f491_isDerivedBitmapInCache(derivedBitmapIndex) + AL_8_projectileScaleIndex) { + AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); } else { - bitmapGreenAnt = getBitmap(AL_4_nativeBitmapIndex); + bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex); if (doNotScaleWithKineticEnergy) { - AL_6_bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex); + AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); } else { AL_6_bitmapRedBanana = _g74_tmpBitmap; } - blitToBitmapShrinkWithPalChange(bitmapGreenAnt, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, + f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, AL_6_bitmapRedBanana, byteWidth, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]); if (doNotScaleWithKineticEnergy) { warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap"); @@ -2784,7 +2784,7 @@ continue; flipBitmapVertical(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); } if (flipHorizontal) { - flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); + f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); } } boxByteGreen._y2 = (heightRedEagle >> 1) + 47 + 1; @@ -2803,7 +2803,7 @@ the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */ AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1)); } - blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh); + f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh); } else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */ useAlcoveObjectImage = false; projectileCoordinates[0] = projectilePosX; @@ -2817,7 +2817,7 @@ screen. To fix this bug, "+ paddingPixelCount" must be added to the second param } } T0115171_BackFromT0115015_DrawProjectileAsObject:; - } while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList); + } while ((thingParam = dunMan.f159_getNextThing(thingParam)) != Thing::_endOfList); } while (remainingViewCellOrdinalsToProcess); @@ -2832,7 +2832,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; do { if (thingParam.getType() == k15_ExplosionThingType) { AL_2_cellPurpleMan = thingParam.getCell(); - explosion = (Explosion*)dunMan.getThingData(thingParam); + explosion = (Explosion*)dunMan.f156_getThingData(thingParam); if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= k100_ExplosionType_RebirthStep1)) && ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion) || (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion) @@ -2850,13 +2850,13 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke; } else { if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) { - objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->ordinalToIndex(-dunMan.getProjectileAspect(Thing::_explLightningBolt))]; - AL_6_bitmapRedBanana = getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1)); + objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-dunMan.f142_getProjectileAspect(Thing::_explLightningBolt))]; + AL_6_bitmapRedBanana = f489_getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1)); explosionCoordinates = g228_RebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3]; - byteWidth = getScaledDimension((((ProjectileAspect*)objectAspect)->_width), explosionCoordinates[2]); - heightRedEagle = getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]); + byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_width), explosionCoordinates[2]); + heightRedEagle = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]); if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) { - blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, + f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, _g74_tmpBitmap, byteWidth, heightRedEagle, g17_PalChangesNoChanges); AL_6_bitmapRedBanana = _g74_tmpBitmap; @@ -2885,12 +2885,12 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; } } warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache"); - AL_6_bitmapRedBanana = getBitmap(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice); + AL_6_bitmapRedBanana = f489_getBitmap(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice); if (smoke) { - blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _g74_tmpBitmap, 48, 32, g212_PalChangeSmoke); + f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _g74_tmpBitmap, 48, 32, g212_PalChangeSmoke); AL_6_bitmapRedBanana = _g74_tmpBitmap; } - blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C, + f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C, _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64), 224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); @@ -2912,7 +2912,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; } explosionScale = MAX(4, (MAX(48, explosion->getAttack() + 1) * g216_ExplosionBaseScales[explosionScaleIndex]) >> 8) & (int16)0xFFFE; } - AL_6_bitmapRedBanana = getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle); + AL_6_bitmapRedBanana = f114_getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle); T0115200_DrawExplosion: flipVertical = _vm->_rnd->getRandomNumber(2); paddingPixelCount = 0; @@ -2950,37 +2950,37 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP AL_6_bitmapRedBanana = _g74_tmpBitmap; } if (flipHorizontal) { - flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); + f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } if (flipVertical) { flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } - blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh); + f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh); } } - } while ((thingParam = dunMan.getNextThing(thingParam)) != Thing::_endOfList); + } while ((thingParam = dunMan.f159_getNextThing(thingParam)) != Thing::_endOfList); /* Fluxcage is an explosion displayed as a field (like teleporters), above all other graphics */ if ((fluxcageExplosion != 0) && (doorFrontViewDrawingPass != 1) && !_g77_doNotDrawFluxcagesDuringEndgame) { AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */ fieldAspect = g188_FieldAspects[viewSquareIndex]; (fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */ - drawField(&fieldAspect, *(Box*)&g163_FrameWalls[viewSquareIndex]); + f113_drawField(&fieldAspect, *(Box*)&g163_FrameWalls[viewSquareIndex]); } } -uint16 DisplayMan::getNormalizedByteWidthM77(uint16 byteWidth) { +uint16 DisplayMan::M77_getNormalizedByteWidth(uint16 byteWidth) { return (byteWidth + 7) & 0xFFF8; } -uint16 DisplayMan::getVerticalOffsetM23(uint16 val) { +uint16 DisplayMan::M23_getVerticalOffsetM23(uint16 val) { return (val >> 3) & 0x7; } -uint16 DisplayMan::getHorizontalOffsetM22(uint16 val) { +uint16 DisplayMan::M22_getHorizontalOffsetM22(uint16 val) { return (val & 0x7); } -bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) { +bool DisplayMan::f491_isDerivedBitmapInCache(int16 derivedBitmapIndex) { if (_g638_derivedBitmaps[derivedBitmapIndex] == nullptr) { // * 2, because the original uses 4 bits instead of 8 bits to store a pixel _g638_derivedBitmaps[derivedBitmapIndex] = new byte[_g639_derivedBitmapByteCount[derivedBitmapIndex] * 2]; @@ -2989,7 +2989,7 @@ bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) { return true; } -byte* DisplayMan::getDerivedBitmap(int16 derivedBitmapIndex) { +byte* DisplayMan::f492_getDerivedBitmap(int16 derivedBitmapIndex) { return _g638_derivedBitmaps[derivedBitmapIndex]; } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index df48bec0ea..a0a61ba78f 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -433,27 +433,27 @@ class DisplayMan { void f565_viewportSetPalette(uint16 * middleScreenPalette, uint16 * topAndBottomScreen); // @ F0565_VIEWPORT_SetPalette void f566_viewportBlitToScreen(); // @ F0566_VIEWPORT_BlitToScreen - void drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally - void drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap - void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap - void drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency - void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L - void drawSquareD3R(direction dir, int16 posX, int16 posY); // @ F0117_DUNGEONVIEW_DrawSquareD3R - void drawSquareD3C(direction dir, int16 posX, int16 posY); // @ F0118_DUNGEONVIEW_DrawSquareD3C_CPSF - void drawSquareD2L(direction dir, int16 posX, int16 posY); // @ F0119_DUNGEONVIEW_DrawSquareD2L - void drawSquareD2R(direction dir, int16 posX, int16 posY); // @ F0120_DUNGEONVIEW_DrawSquareD2R_CPSF - void drawSquareD2C(direction dir, int16 posX, int16 posY); // @ F0121_DUNGEONVIEW_DrawSquareD2C - void drawSquareD1L(direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1L - void drawSquareD1R(direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1R - void drawSquareD1C(direction dir, int16 posX, int16 posY); // @ F0124_DUNGEONVIEW_DrawSquareD1C - void drawSquareD0L(direction dir, int16 posX, int16 posY); // @ F0125_DUNGEONVIEW_DrawSquareD0L - void drawSquareD0R(direction dir, int16 posX, int16 posY); // @ F0126_DUNGEONVIEW_DrawSquareD0R - void drawSquareD0C(direction dir, int16 posX, int16 posY); // @ F0127_DUNGEONVIEW_DrawSquareD0C - - - void applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors - - bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF + void f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally + void f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap + void f100_drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap + void f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency + void f116_drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L + void f117_drawSquareD3R(direction dir, int16 posX, int16 posY); // @ F0117_DUNGEONVIEW_DrawSquareD3R + void f118_drawSquareD3C(direction dir, int16 posX, int16 posY); // @ F0118_DUNGEONVIEW_DrawSquareD3C_CPSF + void f119_drawSquareD2L(direction dir, int16 posX, int16 posY); // @ F0119_DUNGEONVIEW_DrawSquareD2L + void f120_drawSquareD2R(direction dir, int16 posX, int16 posY); // @ F0120_DUNGEONVIEW_DrawSquareD2R_CPSF + void f121_drawSquareD2C(direction dir, int16 posX, int16 posY); // @ F0121_DUNGEONVIEW_DrawSquareD2C + void f122_drawSquareD1L(direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1L + void f123_drawSquareD1R(direction dir, int16 posX, int16 posY); // @ F0123_DUNGEONVIEW_DrawSquareD1R + void f124_drawSquareD1C(direction dir, int16 posX, int16 posY); // @ F0124_DUNGEONVIEW_DrawSquareD1C + void f125_drawSquareD0L(direction dir, int16 posX, int16 posY); // @ F0125_DUNGEONVIEW_DrawSquareD0L + void f126_drawSquareD0R(direction dir, int16 posX, int16 posY); // @ F0126_DUNGEONVIEW_DrawSquareD0R + void f127_drawSquareD0C(direction dir, int16 posX, int16 posY); // @ F0127_DUNGEONVIEW_DrawSquareD0C + + + void f93_applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors + + bool f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF uint16 *_g639_derivedBitmapByteCount; // @ G0639_pui_DerivedBitmapByteCount byte **_g638_derivedBitmaps; // @ G0638_pui_DerivedBitmapBlockIndices @@ -527,14 +527,14 @@ public: explicit DisplayMan(DMEngine *dmEngine); ~DisplayMan(); - void loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet - void loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet + void f95_loadWallSet(WallSet set); // @ F0095_DUNGEONVIEW_LoadWallSet + void f94_loadFloorSet(FloorSet set); // @ F0094_DUNGEONVIEW_LoadFloorSet - void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap + void f466_loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap void setUpScreens(uint16 width, uint16 height); - void loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader, F0460_START_InitializeGraphicData - void initializeGraphicData(); // @ F0460_START_InitializeGraphicData - void loadCurrentMapGraphics(); // @ F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF + void f479_loadGraphics(); // @ F0479_MEMORY_ReadGraphicsDatHeader + void f460_initializeGraphicData(); // @ F0460_START_InitializeGraphicData + void f96_loadCurrentMapGraphics(); // @ F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF void loadPalette(uint16 *palette); void f461_allocateFlippedWallBitmaps(); // @ F0461_START_AllocateFlippedWallBitmaps @@ -547,40 +547,40 @@ public: void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); - void blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, - byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency); + void f132_blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, + byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency); // @ F0132_VIDEO_Blit - void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, + void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap - void blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight, + void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight, byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges - void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally + void f103_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); - byte *getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap + byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap void f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color); // @ F0134_VIDEO_FillBitmap void clearScreen(Color color); - void clearScreenBox(Color color, Box &box); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox + void D24_clearScreenBox(Color color, Box &box); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 pixelWidth, int16 height); - void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF + void f128_drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport - byte* getBitmap(uint16 index); + byte* f489_getBitmap(uint16 index); // @ F0489_MEMORY_GetNativeBitmapOrGraphic Common::MemoryReadStream getCompressedData(uint16 index); uint32 getCompressedDataSize(uint16 index); - void drawField(FieldAspect *fieldAspect, Box &box); // @ F0113_DUNGEONVIEW_DrawField + void f113_drawField(FieldAspect *fieldAspect, Box &box); // @ F0113_DUNGEONVIEW_DrawField - int16 getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount - int16 getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION - void cthulhu(Thing thingParam, direction directionParam, + int16 f459_getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount + int16 M78_getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION + void f115_cthulhu(Thing thingParam, direction directionParam, int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF - uint16 getNormalizedByteWidthM77(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH - uint16 getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET - uint16 getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET + uint16 M77_getNormalizedByteWidth(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH + uint16 M23_getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET + uint16 M22_getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET int16 _g289_championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal int16 _g267_currMapAlcoveOrnIndices[k3_AlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices @@ -602,8 +602,8 @@ public: bool _g578_useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates bool _g77_doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame - bool isDerivedBitmapInCache(int16 derivedBitmapIndex); // @ F0491_CACHE_IsDerivedBitmapInCache - byte *getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap + bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @ F0491_CACHE_IsDerivedBitmapInCache + byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 2cc2646a1a..3fa8c4a3b1 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -42,7 +42,7 @@ GroupMan::~GroupMan() { delete[] _g375_activeGroups; } -void GroupMan::initActiveGroups() { +void GroupMan::f196_initActiveGroups() { if (_vm->_g298_newGame) _g376_maxActiveGroupCount = 60; if (_g375_activeGroups) @@ -52,7 +52,7 @@ void GroupMan::initActiveGroups() { _g375_activeGroups[i]._groupThingIndex = -1; } -uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) { +uint16 GroupMan::f145_getGroupCells(Group* group, int16 mapIndex) { byte cells; cells = group->_cells; if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) @@ -62,39 +62,39 @@ uint16 GroupMan::getGroupCells(Group* group, int16 mapIndex) { byte gGroupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_GroupDirections -uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) { +uint16 GroupMan::f147_getGroupDirections(Group* group, int16 mapIndex) { if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) return _g375_activeGroups[group->getActiveGroupIndex()]._directions; return gGroupDirections[group->getDir()]; } -int16 GroupMan::getCreatureOrdinalInCell(Group* group, uint16 cell) { +int16 GroupMan::f176_getCreatureOrdinalInCell(Group* group, uint16 cell) { uint16 currMapIndex = _vm->_dungeonMan->_g272_currMapIndex; - byte groupCells = getGroupCells(group, currMapIndex); + byte groupCells = f145_getGroupCells(group, currMapIndex); if (groupCells == k255_CreatureTypeSingleCenteredCreature) - return _vm->indexToOrdinal(0); + return _vm->M0_indexToOrdinal(0); byte creatureIndex = group->getCount(); if (getFlag(g243_CreatureInfo[group->_type]._attributes, k0x0003_MaskCreatureInfo_size) == k1_MaskCreatureSizeHalf) { - if ((getGroupDirections(group, currMapIndex) & 1) == (cell & 1)) + if ((f147_getGroupDirections(group, currMapIndex) & 1) == (cell & 1)) cell = returnPrevVal(cell); do { - byte creatureCell = getCreatureValue(groupCells, creatureIndex); + byte creatureCell = M50_getCreatureValue(groupCells, creatureIndex); if (creatureCell == cell || creatureCell == returnNextVal(cell)) - return _vm->indexToOrdinal(creatureIndex); + return _vm->M0_indexToOrdinal(creatureIndex); } while (creatureIndex--); } else { do { - if (getCreatureValue(groupCells, creatureIndex) == cell) - return _vm->indexToOrdinal(creatureIndex); + if (M50_getCreatureValue(groupCells, creatureIndex) == cell) + return _vm->M0_indexToOrdinal(creatureIndex); } while (creatureIndex--); } return 0; } -uint16 GroupMan::getCreatureValue(uint16 groupVal, uint16 creatureIndex) { +uint16 GroupMan::M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex) { return (groupVal >> (creatureIndex << 1)) & 0x3; } } diff --git a/engines/dm/group.h b/engines/dm/group.h index af7a4eb622..76cb8b2649 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -137,11 +137,11 @@ public: ActiveGroup *_g375_activeGroups; // @ G0375_ps_ActiveGroups GroupMan(DMEngine *vm); ~GroupMan(); - void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups - uint16 getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells - uint16 getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections - int16 getCreatureOrdinalInCell(Group *group, uint16 cell); // @ F0176_GROUP_GetCreatureOrdinalInCell - uint16 getCreatureValue(uint16 groupVal, uint16 creatureIndex); // @ M50_CREATURE_VALUE + void f196_initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups + uint16 f145_getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells + uint16 f147_getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections + int16 f176_getCreatureOrdinalInCell(Group *group, uint16 cell); // @ F0176_GROUP_GetCreatureOrdinalInCell + uint16 M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex); // @ M50_CREATURE_VALUE }; diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 8118356bd0..1d1eb5e8c9 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -50,36 +50,36 @@ InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) { _g426_openChest = Thing::_none; } -void InventoryMan::toggleInventory(ChampionIndex championIndex) { +void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) { ChampionMan &cm = *_vm->_championMan; EventManager &em = *_vm->_eventMan; DisplayMan &dm = *_vm->_displayMan; - if ((championIndex != k4_ChampionCloseInventory) && !cm._champions[championIndex]._currHealth) + if ((championIndex != k4_ChampionCloseInventory) && !cm._gK71_champions[championIndex]._currHealth) return; if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) return; _vm->_g321_stopWaitingForPlayerInput = true; int16 invChampOrdinal = _g432_inventoryChampionOrdinal; // copy, as the original will be edited - if (_vm->indexToOrdinal(championIndex) == invChampOrdinal) { + if (_vm->M0_indexToOrdinal(championIndex) == invChampOrdinal) { championIndex = k4_ChampionCloseInventory; } Champion *champion; if (invChampOrdinal) { - _g432_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone); - closeChest(); - champion = &cm._champions[_vm->ordinalToIndex(invChampOrdinal)]; + _g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone); + f334_closeChest(); + champion = &cm._gK71_champions[_vm->M1_ordinalToIndex(invChampOrdinal)]; if (champion->_currHealth && !cm._g299_candidateChampionOrdinal) { champion->setAttributeFlag(k0x1000_ChampionAttributeStatusBox, true); - cm.drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal)); + cm.f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal)); } if (cm._g300_partyIsSleeping) { return; } if (championIndex == k4_ChampionCloseInventory) { em._g326_refreshMousePointerInMainLoop = true; - _vm->_menuMan->drawMovementArrows(); + _vm->_menuMan->f395_drawMovementArrows(); em._g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement; warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput"); warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); @@ -88,22 +88,22 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { } dm._g578_useByteBoxCoordinates = false; - _g432_inventoryChampionOrdinal = _vm->indexToOrdinal(championIndex); + _g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(championIndex); if (!invChampOrdinal) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } - champion = &cm._champions[championIndex]; - dm.loadIntoBitmap(k17_InventoryGraphicIndice, dm._g296_bitmapViewport); + champion = &cm._gK71_champions[championIndex]; + dm.f466_loadIntoBitmap(k17_InventoryGraphicIndice, dm._g296_bitmapViewport); if (cm._g299_candidateChampionOrdinal) { dm.f135_fillBoxBitmap(dm._g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport); } - _vm->_textMan->printToViewport(5, 116, k13_ColorLightestGray, "HEALTH"); - _vm->_textMan->printToViewport(5, 124, k13_ColorLightestGray, "STAMINA"); - _vm->_textMan->printToViewport(5, 132, k13_ColorLightestGray, "MANA"); + _vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "HEALTH"); + _vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "STAMINA"); + _vm->_textMan->f52_printToViewport(5, 132, k13_ColorLightestGray, "MANA"); for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) { - _vm->_championMan->drawSlot(championIndex, (ChampionSlot)slotIndex); + _vm->_championMan->f291_drawSlot(championIndex, (ChampionSlot)slotIndex); } champion->setAttributeFlag(k0x4000_ChampionAttributeViewport, true); @@ -113,14 +113,14 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) { champion->setAttributeFlag(k0x0100_ChampionAttributeStatistics, true); champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true); - cm.drawChampionState(championIndex); + cm.f292_drawChampionState(championIndex); em._g598_mousePointerBitmapUpdated = true; em._g442_secondaryMouseInput = g449_SecondaryMouseInput_ChampionInventory; warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput"); warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); } -void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) { +void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) { DisplayMan &dispMan = *_vm->_displayMan; dispMan._g578_useByteBoxCoordinates = false; Box box; @@ -128,21 +128,21 @@ void InventoryMan::drawStatusBoxPortrait(ChampionIndex championIndex) { box._y2 = 28 + 1; box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7; box._x2 = box._x1 + 31 + 1; - dispMan.blitToBitmap(_vm->_championMan->_champions[championIndex]._portrait, 32, 0, 0, + dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, 32, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); } -void InventoryMan::drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) { +void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) { Box box; box._x1 = x; box._x2 = box._x1 + pixelWidth + 1; box._y1 = y; box._y2 = box._y1 + 6 + 1; _vm->_displayMan->_g578_useByteBoxCoordinates = false; - _vm->_displayMan->clearScreenBox(color, box); + _vm->_displayMan->D24_clearScreenBox(color, box); } -void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) { +void InventoryMan::f344_drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) { if (amount < -512) { color = k8_ColorRed; } else if (amount < 0) { @@ -154,45 +154,45 @@ void InventoryMan::drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) { pixelWidth = 3071; } pixelWidth /= 32; - drawPanelHorizontalBar(115, y + 2, pixelWidth, k0_ColorBlack); - drawPanelHorizontalBar(113, y, pixelWidth, color); + f343_drawPanelHorizontalBar(115, y + 2, pixelWidth, k0_ColorBlack); + f343_drawPanelHorizontalBar(113, y, pixelWidth, color); } -void InventoryMan::drawPanelFoodWaterPoisoned() { - Champion &champ = _vm->_championMan->_champions[_g432_inventoryChampionOrdinal]; - closeChest(); +void InventoryMan::f345_drawPanelFoodWaterPoisoned() { + Champion &champ = _vm->_championMan->_gK71_champions[_g432_inventoryChampionOrdinal]; + f334_closeChest(); DisplayMan &dispMan = *_vm->_displayMan; - dispMan.blitToBitmap(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), 144, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g32_BoxPanel, k8_ColorRed); - dispMan.blitToBitmap(dispMan.getBitmap(k30_FoodLabelIndice), 48, 0, 0, + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k30_FoodLabelIndice), 48, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g35_BoxFood, k12_ColorDarkestGray); - dispMan.blitToBitmap(dispMan.getBitmap(k31_WaterLabelIndice), 48, 0, 0, + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k31_WaterLabelIndice), 48, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g36_BoxWater, k12_ColorDarkestGray); if (champ._poisonEventCount) { - dispMan.blitToBitmap(dispMan.getBitmap(k32_PoisionedLabelIndice), 96, 0, 0, + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k32_PoisionedLabelIndice), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g37_BoxPoisoned, k12_ColorDarkestGray); } - drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown); - drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue); + f344_drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown); + f344_drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue); } -void InventoryMan::drawPanelResurrectReincarnate() { +void InventoryMan::f346_drawPanelResurrectReincarnate() { _g424_panelContent = k5_PanelContentResurrectReincarnate; - _vm->_displayMan->blitToBitmap(_vm->_displayMan->getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k6_ColorDarkGreen); } -void InventoryMan::drawPanel() { +void InventoryMan::f347_drawPanel() { warning("possible reintroduction of BUG0_48"); - closeChest(); // possibility of BUG0_48 + f334_closeChest(); // possibility of BUG0_48 ChampionMan &cm = *_vm->_championMan; if (cm._g299_candidateChampionOrdinal) { - drawPanelResurrectReincarnate(); + f346_drawPanelResurrectReincarnate(); return; } - Thing thing = cm._champions[_vm->ordinalToIndex(_g432_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand); + Thing thing = cm._gK71_champions[_vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand); _g424_panelContent = k0_PanelContentFoodWaterPoisoned; switch (thing.getType()) { @@ -207,19 +207,19 @@ void InventoryMan::drawPanel() { break; } if (thing == Thing::_none) { - drawPanelFoodWaterPoisoned(); + f345_drawPanelFoodWaterPoisoned(); } else { - drawPanelObject(thing, false); + f342_drawPanelObject(thing, false); } } -void InventoryMan::closeChest() { +void InventoryMan::f334_closeChest() { DungeonMan &dunMan = *_vm->_dungeonMan; bool processFirstChestSlot = true; if (_g426_openChest == Thing::_none) return; - Container *container = (Container*)dunMan.getThingData(_g426_openChest); + Container *container = (Container*)dunMan.f156_getThingData(_g426_openChest); _g426_openChest = Thing::_none; container->getSlot() = Thing::_endOfList; Thing prevThing; @@ -230,17 +230,17 @@ void InventoryMan::closeChest() { if (processFirstChestSlot) { processFirstChestSlot = false; - *dunMan.getThingData(thing) = Thing::_endOfList.toUint16(); + *dunMan.f156_getThingData(thing) = Thing::_endOfList.toUint16(); container->getSlot() = prevThing = thing; } else { - dunMan.linkThingToList(thing, prevThing, kM1_MapXNotOnASquare, 0); + dunMan.f163_linkThingToList(thing, prevThing, kM1_MapXNotOnASquare, 0); prevThing = thing; } } } } -void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) { +void InventoryMan::f340_drawPanelScrollTextLine(int16 yPos, char* text) { warning("CHANGE5_03_IMPROVEMENT"); for (char* iter = text; *iter != '\0'; ++iter) { if ((*iter >= 'A') && (*iter <= 'Z')) { @@ -249,20 +249,20 @@ void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) { *iter -= 96; } } - _vm->_textMan->printToViewport(162 - (6 * strlen(text) / 2), yPos, k0_ColorBlack, text, k15_ColorWhite); + _vm->_textMan->f52_printToViewport(162 - (6 * strlen(text) / 2), yPos, k0_ColorBlack, text, k15_ColorWhite); } -void InventoryMan::drawPanelScroll(Scroll* scroll) { +void InventoryMan::f341_drawPanelScroll(Scroll* scroll) { DisplayMan &dispMan = *_vm->_displayMan; char stringFirstLine[300]; - _vm->_dungeonMan->decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible)); + _vm->_dungeonMan->f168_decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible)); char *charRed = stringFirstLine; while (*charRed && (*charRed != '\n')) { charRed++; } *charRed = '\0'; - dispMan.blitToBitmap(dispMan.getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k8_ColorRed); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k8_ColorRed); int16 lineCount = 1; charRed++; char *charGreen = charRed; // first char of the second line @@ -283,7 +283,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) { lineCount--; } int16 yPos = 92 - (7 * lineCount) / 2; // center the text vertically - drawPanelScrollTextLine(yPos, stringFirstLine); + f340_drawPanelScrollTextLine(yPos, stringFirstLine); charGreen = charRed; while (*charGreen) { yPos += 7; @@ -294,12 +294,12 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) { charRed[1] = '\0'; } *charRed++ = '\0'; - drawPanelScrollTextLine(yPos, charGreen); + f340_drawPanelScrollTextLine(yPos, charGreen); charGreen = charRed; } } -void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool isPressingEye) { +void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bool isPressingEye) { DisplayMan &dispMan = *_vm->_displayMan; ObjectMan &objMan = *_vm->_objectMan; @@ -308,13 +308,13 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is warning("CHANGE8_09_FIX"); if (_g426_openChest != Thing::_none) - closeChest(); // CHANGE8_09_FIX + f334_closeChest(); // CHANGE8_09_FIX _g426_openChest = thingToOpen; if (!isPressingEye) { - objMan.drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen); + objMan.f38_drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen); } - dispMan.blitToBitmap(dispMan.getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g32_BoxPanel, k8_ColorRed); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g32_BoxPanel, k8_ColorRed); int16 chestSlotIndex = 0; Thing thing = chest->getSlot(); @@ -324,27 +324,27 @@ void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool is if (++thingCount > 8) break; // CHANGE8_08_FIX, make sure that no more than the first 8 objects in a chest are drawn - objMan.drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, objMan.getIconIndex(thing)); + objMan.f38_drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, objMan.f33_getIconIndex(thing)); _g425_chestSlots[chestSlotIndex++] = thing; - thing = _vm->_dungeonMan->getNextThing(thing); + thing = _vm->_dungeonMan->f159_getNextThing(thing); } while (chestSlotIndex < 8) { - objMan.drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, kM1_IconIndiceNone); + objMan.f38_drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, kM1_IconIndiceNone); _g425_chestSlots[chestSlotIndex++] = Thing::_none; } } -void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos) { +void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos) { static byte iconBitmap[16 * 16]; Box box; box._x2 = (box._x1 = xPos) + 15 + 1; box._y2 = (box._y1 = yPos) + 15 + 1; - _vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap); - _vm->_displayMan->blitToBitmap(iconBitmap, 16, 0, 0, _vm->_displayMan->_g296_bitmapViewport, + _vm->_objectMan->f36_extractIconFromBitmap(iconIndex, iconBitmap); + _vm->_displayMan->f132_blitToBitmap(iconBitmap, 16, 0, 0, _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, box, k255_ColorNoTransparency); } -void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) { +void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) { uint16 identicalBitCount = 0; int16 attribMask = 1; for (uint16 stringIndex = 0; stringIndex < 16; stringIndex++, attribMask <<= 1) { @@ -375,7 +375,7 @@ void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 a strcat(destString, suffixString); } -void InventoryMan::drawPanelObjectDescriptionString(char* descString) { +void InventoryMan::f335_drawPanelObjectDescriptionString(char* descString) { if (descString[0] == '\f') { // form feed descString++; _g421_objDescTextXpos = 108; @@ -399,7 +399,7 @@ void InventoryMan::drawPanelObjectDescriptionString(char* descString) { severalLines = true; } - _vm->_textMan->printToViewport(_g421_objDescTextXpos, _g422_objDescTextYpos, k13_ColorLightestGray, stringLine); + _vm->_textMan->f52_printToViewport(_g421_objDescTextXpos, _g422_objDescTextYpos, k13_ColorLightestGray, stringLine); _g422_objDescTextYpos += 7; if (severalLines) { severalLines = false; @@ -413,9 +413,9 @@ void InventoryMan::drawPanelObjectDescriptionString(char* descString) { Box g33_BoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye -void InventoryMan::drawPanelArrowOrEye(bool pressingEye) { +void InventoryMan::f339_drawPanelArrowOrEye(bool pressingEye) { DisplayMan &dispMan = *_vm->_displayMan; - dispMan.blitToBitmap(dispMan.getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice), + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice), 16, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g33_BoxArrowOrEye, k8_ColorRed); } @@ -427,7 +427,7 @@ Box g34_BoxObjectDescCircle = Box(105, 136, 53, 79); // @ G0034_s_Graphic562_Box #define k0x0004_DescriptionMaskBroken 0x0004 // @ MASK0x0004_DESCRIPTION_BROKEN #define k0x0008_DescriptionMaskCursed 0x0008 // @ MASK0x0008_DESCRIPTION_CURSED -void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { +void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) { DungeonMan &dunMan = *_vm->_dungeonMan; ObjectMan &objMan = *_vm->_objectMan; DisplayMan &dispMan = *_vm->_displayMan; @@ -436,34 +436,34 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) { warning("BUG0_48 The contents of a chest are reorganized when an object with a statistic modifier is placed or removed on a champion"); - closeChest(); + f334_closeChest(); } - uint16 *rawThingPtr = dunMan.getThingData(thingToDraw); - drawPanelObjectDescriptionString("\f"); // form feed + uint16 *rawThingPtr = dunMan.f156_getThingData(thingToDraw); + f335_drawPanelObjectDescriptionString("\f"); // form feed ThingType thingType = thingToDraw.getType(); if (thingType == k7_ScrollThingType) { - drawPanelScroll((Scroll*)rawThingPtr); + f341_drawPanelScroll((Scroll*)rawThingPtr); } else if (thingType == k9_ContainerThingType) { - openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye); + f333_openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye); } else { - IconIndice iconIndex = objMan.getIconIndex(thingToDraw); - dispMan.blitToBitmap(dispMan.getBitmap(k20_PanelEmptyIndice), 144, 0, 0, + IconIndice iconIndex = objMan.f33_getIconIndex(thingToDraw); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), 144, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k8_ColorRed); - dispMan.blitToBitmap(dispMan.getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g34_BoxObjectDescCircle, k12_ColorDarkestGray); char *descString = nullptr; char str[40]; if (iconIndex == k147_IconIndiceJunkChampionBones) { - strcpy(str, champMan._champions[((Junk*)rawThingPtr)->getChargeCount()]._name); // TODO: localization + strcpy(str, champMan._gK71_champions[((Junk*)rawThingPtr)->getChargeCount()]._name); // TODO: localization strcat(str, " "); // TODO: localization strcat(str, objMan._g352_objectNames[iconIndex]); // TODO: localization descString = str; } else if ((thingType == k8_PotionThingType) && (iconIndex != k163_IconIndicePotionWaterFlask) - && (champMan.getSkillLevel((ChampionIndex)_vm->ordinalToIndex(_g432_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) { + && (champMan.f303_getSkillLevel((ChampionIndex)_vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) { str[0] = '_' + ((Potion*)rawThingPtr)->getPower() / 40; str[1] = ' '; str[2] = '\0'; @@ -473,8 +473,8 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { descString = objMan._g352_objectNames[iconIndex]; } - textMan.printToViewport(134, 68, k13_ColorLightestGray, descString); - drawIconToViewport(iconIndex, 111, 59); + textMan.f52_printToViewport(134, 68, k13_ColorLightestGray, descString); + f332_drawIconToViewport(iconIndex, 111, 59); char *attribString[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"}; // TODO: localization @@ -490,7 +490,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit) && (weapon->getChargeCount() == 0)) { - drawPanelObjectDescriptionString("(BURNT OUT)"); // TODO: localization + f335_drawPanelObjectDescriptionString("(BURNT OUT)"); // TODO: localization } break; } @@ -524,13 +524,13 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { descString = "(FULL)"; // TODO: localization break; } - drawPanelObjectDescriptionString(descString); + f335_drawPanelObjectDescriptionString(descString); } else if ((iconIndex >= k0_IconIndiceJunkCompassNorth) && (iconIndex <= k3_IconIndiceJunkCompassWest)) { potentialAttribMask = 0; strcpy(str, "PARTY FACING "); // TODO: localization static char* directionName[4] = {"NORTH", "EAST", "SOUTH", "WEST"}; // G0430_apc_DirectionNames // TODO: localization strcat(str, directionName[iconIndex]); - drawPanelObjectDescriptionString(str); + f335_drawPanelObjectDescriptionString(str); } else { potentialAttribMask = k0x0001_DescriptionMaskConsumable; actualAttribMask = g237_ObjectInfo[k127_ObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots(); @@ -540,25 +540,25 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) { } // end of switch if (potentialAttribMask) { - buildObjectAttributeString(potentialAttribMask, actualAttribMask, attribString, str, "(", ")"); - drawPanelObjectDescriptionString(str); + f336_buildObjectAttributeString(potentialAttribMask, actualAttribMask, attribString, str, "(", ")"); + f335_drawPanelObjectDescriptionString(str); } strcpy(str, "WEIGHS "); // TODO: localization - uint16 weight = dunMan.getObjectWeight(thingToDraw); - strcat(str, champMan.getStringFromInteger(weight / 10, false, 3).c_str()); + uint16 weight = dunMan.f140_getObjectWeight(thingToDraw); + strcat(str, champMan.f288_getStringFromInteger(weight / 10, false, 3).c_str()); strcat(str, "."); // TODO: localization weight -= (weight / 10) * 10; - strcat(str, champMan.getStringFromInteger(weight, false, 1).c_str()); + strcat(str, champMan.f288_getStringFromInteger(weight, false, 1).c_str()); strcat(str, " KG."); // TODO: localization - drawPanelObjectDescriptionString(str); + f335_drawPanelObjectDescriptionString(str); } - drawPanelArrowOrEye(pressingEye); + f339_drawPanelArrowOrEye(pressingEye); } } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 82865f5cc5..df429af70b 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -61,23 +61,23 @@ public: int16 _g421_objDescTextXpos; // @ G0421_i_ObjectDescriptionTextX int16 _g422_objDescTextYpos; // @ G0422_i_ObjectDescriptionTextY - void toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE - void drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait - void drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar - void drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color); // @ F0344_INVENTORY_DrawPanel_FoodOrWaterBar - void drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned - void drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate - void drawPanel(); // @ F0347_INVENTORY_DrawPanel - void closeChest(); // @ F0334_INVENTORY_CloseChest - void drawPanelScrollTextLine(int16 yPos, char *text); // @ F0340_INVENTORY_DrawPanel_ScrollTextLine - void drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll - void openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye); // @ F0333_INVENTORY_OpenAndDrawChest - void drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos); // @ F0332_INVENTORY_DrawIconToViewport - void buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char ** attribStrings, + void f355_toggleInventory(ChampionIndex championIndex); // @ F0355_INVENTORY_Toggle_CPSE + void f354_drawStatusBoxPortrait(ChampionIndex championIndex); // @ F0354_INVENTORY_DrawStatusBoxPortrait + void f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color); // @ F0343_INVENTORY_DrawPanel_HorizontalBar + void f344_drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color); // @ F0344_INVENTORY_DrawPanel_FoodOrWaterBar + void f345_drawPanelFoodWaterPoisoned(); // @ F0345_INVENTORY_DrawPanel_FoodWaterPoisoned + void f346_drawPanelResurrectReincarnate(); // @ F0346_INVENTORY_DrawPanel_ResurrectReincarnate + void f347_drawPanel(); // @ F0347_INVENTORY_DrawPanel + void f334_closeChest(); // @ F0334_INVENTORY_CloseChest + void f340_drawPanelScrollTextLine(int16 yPos, char *text); // @ F0340_INVENTORY_DrawPanel_ScrollTextLine + void f341_drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll + void f333_openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye); // @ F0333_INVENTORY_OpenAndDrawChest + void f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos); // @ F0332_INVENTORY_DrawIconToViewport + void f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char ** attribStrings, char *destString, char *prefixString, char *suffixString); // @ F0336_INVENTORY_DrawPanel_BuildObjectAttributesString - void drawPanelObjectDescriptionString(char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString - void drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye - void drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object + void f335_drawPanelObjectDescriptionString(char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString + void f339_drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye + void f342_drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object }; diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index a0cd569c37..81a914c040 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -38,30 +38,30 @@ namespace DM { LoadsaveMan::LoadsaveMan(DMEngine *vm) : _vm(vm) {} -LoadgameResponse LoadsaveMan::loadgame() { +LoadgameResponse LoadsaveMan::f435_loadgame() { bool newGame = _vm->_g298_newGame; ChampionMan &cm = *_vm->_championMan; if (newGame) { _vm->_g524_restartGameAllowed = false; cm._g305_partyChampionCount = 0; - cm._414_leaderHandObject = Thing::_none; + cm._g414_leaderHandObject = Thing::_none; _vm->_g525_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536); } else { assert(false); // MISSING CODE: load game } - _vm->_dungeonMan->loadDungeonFile(); + _vm->_dungeonMan->f434_loadDungeonFile(); if (newGame) { - _vm->_timeline->initTimeline(); - _vm->_groupMan->initActiveGroups(); + _vm->_timeline->f233_initTimeline(); + _vm->_groupMan->f196_initActiveGroups(); } else { assert(false); // MISSING CODE: load game } - cm._303_partyDead = false; + cm._g303_partyDead = false; return k1_LoadgameSuccess; } diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h index 0ee7118582..c45b111ac9 100644 --- a/engines/dm/loadsave.h +++ b/engines/dm/loadsave.h @@ -42,7 +42,7 @@ class LoadsaveMan { public: explicit LoadsaveMan(DMEngine *vm); - LoadgameResponse loadgame(); // @ F0435_STARTEND_LoadGame_CPSF + LoadgameResponse f435_loadgame(); // @ F0435_STARTEND_LoadGame_CPSF }; } diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index a512a90d07..1d93895e09 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -58,30 +58,30 @@ MenuMan::~MenuMan() { delete[] _gK72_bitmapSpellAreaLine; } -void MenuMan::drawMovementArrows() { +void MenuMan::f395_drawMovementArrows() { DisplayMan &disp = *_vm->_displayMan; - byte *arrowsBitmap = disp.getBitmap(k13_MovementArrowsIndice); + byte *arrowsBitmap = disp.f489_getBitmap(k13_MovementArrowsIndice); Box &dest = g2_BoxMovementArrows; uint16 w = disp.getWidth(k13_MovementArrowsIndice); - disp.blitToBitmap(arrowsBitmap, w, 0, 0, disp._g348_bitmapScreen, k160_byteWidthScreen * 2, dest, k255_ColorNoTransparency); + disp.f132_blitToBitmap(arrowsBitmap, w, 0, 0, disp._g348_bitmapScreen, k160_byteWidthScreen * 2, dest, k255_ColorNoTransparency); } -void MenuMan::clearActingChampion() { +void MenuMan::f388_clearActingChampion() { ChampionMan &cm = *_vm->_championMan; if (cm._g506_actingChampionOrdinal) { cm._g506_actingChampionOrdinal--; - cm._champions[cm._g506_actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true); - cm.drawChampionState((ChampionIndex)cm._g506_actingChampionOrdinal); - cm._g506_actingChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone); + cm._gK71_champions[cm._g506_actingChampionOrdinal].setAttributeFlag(k0x8000_ChampionAttributeActionHand, true); + cm.f292_drawChampionState((ChampionIndex)cm._g506_actingChampionOrdinal); + cm._g506_actingChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone); _g508_refreshActionArea = true; } } -void MenuMan::drawActionIcon(ChampionIndex championIndex) { +void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) { if (!_g509_actionAreaContainsIcons) return; DisplayMan &dm = *_vm->_displayMan; - Champion &champion = _vm->_championMan->_champions[championIndex]; + Champion &champion = _vm->_championMan->_gK71_champions[championIndex]; Box box; box._x1 = championIndex * 22 + 233; @@ -90,7 +90,7 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) { box._y2 = 120 + 1; dm._g578_useByteBoxCoordinates = false; if (!champion._currHealth) { - dm.clearScreenBox(k0_ColorBlack, box); + dm.D24_clearScreenBox(k0_ColorBlack, box); return; } byte *bitmapIcon = dm._g74_tmpBitmap; @@ -98,34 +98,34 @@ void MenuMan::drawActionIcon(ChampionIndex championIndex) { IconIndice iconIndex; if (thing == Thing::_none) { iconIndex = k201_IconIndiceActionEmptyHand; - } else if (g237_ObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) { - iconIndex = _vm->_objectMan->getIconIndex(thing); + } else if (g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thing)]._actionSetIndex) { + iconIndex = _vm->_objectMan->f33_getIconIndex(thing); } else { dm.f134_fillBitmap(bitmapIcon, 16, 16, k4_ColorCyan); goto T0386006; } - _vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon); - dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, g498_PalChangesActionAreaObjectIcon); + _vm->_objectMan->f36_extractIconFromBitmap(iconIndex, bitmapIcon); + dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, g498_PalChangesActionAreaObjectIcon); T0386006: - dm.clearScreenBox(k4_ColorCyan, box); + dm.D24_clearScreenBox(k4_ColorCyan, box); Box box2; box2._x1 = box._x1 + 2; box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that box2._y1 = 95; box2._y2 = 110 + 1; - dm.blitToBitmap(bitmapIcon, 16, 0, 0, dm._g348_bitmapScreen, k160_byteWidthScreen * 2, box2); + dm.f132_blitToBitmap(bitmapIcon, 16, 0, 0, dm._g348_bitmapScreen, k160_byteWidthScreen * 2, box2); if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } } -void MenuMan::drawDisabledMenu() { +void MenuMan::f456_drawDisabledMenu() { if (!_vm->_championMan->_g300_partyIsSleeping) { warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); _vm->_displayMan->_g578_useByteBoxCoordinates = false; if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) { if (_vm->_inventoryMan->_g424_panelContent == k4_PanelContentChest) { - _vm->_inventoryMan->closeChest(); + _vm->_inventoryMan->f334_closeChest(); } } else { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); @@ -136,7 +136,7 @@ void MenuMan::drawDisabledMenu() { } } -void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() { +void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() { ChampionMan &champMan = *_vm->_championMan; if (!champMan._g305_partyChampionCount) @@ -145,24 +145,24 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() { Champion *champ = nullptr; if (champMan._g300_partyIsSleeping || champMan._g299_candidateChampionOrdinal) { if (champMan._g506_actingChampionOrdinal) { - clearActingChampion(); + f388_clearActingChampion(); return; } if (!champMan._g299_candidateChampionOrdinal) return; } else { - champ = champMan._champions; + champ = champMan._gK71_champions; int16 champIndex = k0_ChampionFirst; do { if ((champIndex != champMan._g411_leaderIndex) - && (_vm->indexToOrdinal(champIndex) != champMan._g506_actingChampionOrdinal) + && (_vm->M0_indexToOrdinal(champIndex) != champMan._g506_actingChampionOrdinal) && (champ->_maximumDamageReceived) && (champ->_dir != champ->_directionMaximumDamageReceived)) { champ->_dir = (direction)champ->_directionMaximumDamageReceived; champ->setAttributeFlag(k0x0400_ChampionAttributeIcon, true); - champMan.drawChampionState((ChampionIndex)champIndex); + champMan.f292_drawChampionState((ChampionIndex)champIndex); } champ->_maximumDamageReceived = 0; champ++; @@ -177,12 +177,12 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() { _g513_actionDamage = 0; } else { _g509_actionAreaContainsIcons = true; - drawActionArea(); + f387_drawActionArea(); } } else { _g509_actionAreaContainsIcons = false; champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true); - champMan.drawChampionState((ChampionIndex)_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal)); + champMan.f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)); warning("MISSING CODE: F0387_MENUS_DrawActionArea"); } } @@ -191,29 +191,29 @@ void MenuMan::refreshActionAreaAndSetChampDirMaxDamageReceived() { #define k7_ChampionNameMaximumLength 7 // @ C007_CHAMPION_NAME_MAXIMUM_LENGTH #define k12_ActionNameMaximumLength 12 // @ C012_ACTION_NAME_MAXIMUM_LENGTH -void MenuMan::drawActionArea() { +void MenuMan::f387_drawActionArea() { DisplayMan &dispMan = *_vm->_displayMan; ChampionMan &champMan = *_vm->_championMan; TextMan &textMan = *_vm->_textMan; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); dispMan._g578_useByteBoxCoordinates = false; - dispMan.clearScreenBox(k0_ColorBlack, g1_BoxActionArea); + dispMan.D24_clearScreenBox(k0_ColorBlack, g1_BoxActionArea); if (_g509_actionAreaContainsIcons) { for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._g305_partyChampionCount; ++champIndex) - drawActionIcon((ChampionIndex)champIndex); + f386_drawActionIcon((ChampionIndex)champIndex); } else if (champMan._g506_actingChampionOrdinal) { Box box = g499_BoxActionArea3ActionMenu; if (_g713_actionList._actionIndices[2] == k255_ChampionActionNone) box = g500_BoxActionArea2ActionMenu; if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone) box = g501_BoxActionArea1ActionMenu; - dispMan.blitToBitmap(dispMan.getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); - textMan.printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 235, 83, k0_ColorBlack, k4_ColorCyan, champMan._champions[_vm->ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name, + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); + textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 235, 83, k0_ColorBlack, k4_ColorCyan, champMan._gK71_champions[_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name, k7_ChampionNameMaximumLength, k200_heightScreen); for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) { - textMan.printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack, - getActionName(_g713_actionList._actionIndices[actionListIndex]), + textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack, + f384_getActionName(_g713_actionList._actionIndices[actionListIndex]), k12_ActionNameMaximumLength, k200_heightScreen); } } @@ -231,24 +231,24 @@ const char *g490_ChampionActionNames[44] = { // @ G0490_ac_Graphic560_ActionName "FLUXCAGE", "HEAL", "CALM", "LIGHT", "WINDOW", "SPIT", "BRANDISH", "THROW", "FUSE"}; -const char* MenuMan::getActionName(ChampionAction actionIndex) { +const char* MenuMan::f384_getActionName(ChampionAction actionIndex) { return (actionIndex == k255_ChampionActionNone) ? "" : g490_ChampionActionNames[actionIndex]; } Box g504_BoxSpellAreaControls = Box(233, 319, 42, 49); // @ G0504_s_Graphic560_Box_SpellAreaControls -void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) { +void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) { ChampionMan &champMan = *_vm->_championMan; DisplayMan &dispMan = *_vm->_displayMan; TextMan &textMan = *_vm->_textMan; - Champion &champ = champMan._champions[champIndex]; + Champion &champ = champMan._gK71_champions[champIndex]; int16 champCurrHealth[4]; for (uint16 i = 0; i < 4; ++i) - champCurrHealth[i] = champMan._champions[i]._currHealth; + champCurrHealth[i] = champMan._gK71_champions[i]._currHealth; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan.clearScreenBox(k0_ColorBlack, g504_BoxSpellAreaControls); + dispMan.D24_clearScreenBox(k0_ColorBlack, g504_BoxSpellAreaControls); int16 champCount = champMan._g305_partyChampionCount; switch (champIndex) { case k0_ChampionFirst: @@ -309,61 +309,61 @@ labelChamp3: #define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS #define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS -void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) { +void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) { DisplayMan &dispMan = *_vm->_displayMan; - Champion &champ = _vm->_championMan->_champions[_vm->_championMan->_g514_magicCasterChampionIndex]; + Champion &champ = _vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex]; if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) { dispMan._g578_useByteBoxCoordinates = false; - dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 12, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 12, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency); int16 x = 1; byte c = 96 + (6 * champ._symbolStep); char spellSymbolString[2] = {'\0', '\0'}; for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) { spellSymbolString[0] = c++; - _vm->_textMan->printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12); + _vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12); } } else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) { dispMan._g578_useByteBoxCoordinates = false; - dispMan.blitToBitmap(dispMan.getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 24, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 24, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency); char spellSymbolString[2] = {'\0', '\0'}; int16 x = 8; for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) { if ((spellSymbolString[0] = champ._symbols[symbolIndex]) == '\0') break; - _vm->_textMan->printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12); + _vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12); } } } -void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) { +void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) { ChampionMan &champMan = *_vm->_championMan; DisplayMan &dispMan = *_vm->_displayMan; if ((champIndex == champMan._g514_magicCasterChampionIndex) - || ((champIndex != kM1_ChampionNone) && !champMan._champions[champIndex]._currHealth)) + || ((champIndex != kM1_ChampionNone) && !champMan._gK71_champions[champIndex]._currHealth)) return; if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) { warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan.blitToBitmap(dispMan.getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g0_BoxSpellArea); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g0_BoxSpellArea); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } if (champIndex == kM1_ChampionNone) { champMan._g514_magicCasterChampionIndex = kM1_ChampionNone; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); dispMan._g578_useByteBoxCoordinates = false; - dispMan.clearScreenBox(k0_ColorBlack, g0_BoxSpellArea); + dispMan.D24_clearScreenBox(k0_ColorBlack, g0_BoxSpellArea); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); return; } champMan._g514_magicCasterChampionIndex = (ChampionIndex)champIndex; - buildSpellAreaLine(k2_SpellAreaAvailableSymbols); + f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols); warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - drawSpellAreaControls((ChampionIndex)champIndex); - dispMan.blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK75_BoxSpellAreaLine2); - buildSpellAreaLine(k3_SpellAreaChampionSymbols); - dispMan.blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK76_BoxSpellAreaLine3); + f393_drawSpellAreaControls((ChampionIndex)champIndex); + dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK75_BoxSpellAreaLine2); + f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols); + dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK76_BoxSpellAreaLine3); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } } diff --git a/engines/dm/menus.h b/engines/dm/menus.h index 30bf01c542..ef5f86d153 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -60,17 +60,17 @@ public: ActionList _g713_actionList; // @ G0713_s_ActionList byte *_gK72_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine - void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion - void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon + void f388_clearActingChampion(); // @ F0388_MENUS_ClearActingChampion + void f386_drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon - void drawMovementArrows(); // @ F0395_MENUS_DrawMovementArrows - void drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus - void refreshActionAreaAndSetChampDirMaxDamageReceived(); // @ F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived - void drawActionArea(); // @ F0387_MENUS_DrawActionArea - const char* getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName - void drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls - void buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine - void setMagicCasterAndDrawSpellArea(int16 champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea + void f395_drawMovementArrows(); // @ F0395_MENUS_DrawMovementArrows + void f456_drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus + void f390_refreshActionAreaAndSetChampDirMaxDamageReceived(); // @ F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived + void f387_drawActionArea(); // @ F0387_MENUS_DrawActionArea + const char* f384_getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName + void f393_drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls + void f392_buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine + void f394_setMagicCasterAndDrawSpellArea(int16 champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea }; } diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 5d37884557..9fab510ecf 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -37,21 +37,21 @@ namespace DM { MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {} -bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam) { +bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam) { ChampionMan &champMan = *_vm->_championMan; DungeonMan &dunMan = *_vm->_dungeonMan; ObjectMan &objMan = *_vm->_objectMan; bool atLeastOneSensorWasTriggered = false; - Thing leaderHandObject = champMan._414_leaderHandObject; + Thing leaderHandObject = champMan._g414_leaderHandObject; int16 sensorCountToProcessPerCell[4]; uint16 cell; for (cell = k0_CellNorthWest; cell < k3_CellSouthWest; ++cell) { sensorCountToProcessPerCell[cell] = 0; } Thing squareFirstThing; - Thing thingBeingProcessed = squareFirstThing = dunMan.getSquareFirstThing(mapX, mapY); + Thing thingBeingProcessed = squareFirstThing = dunMan.f161_getSquareFirstThing(mapX, mapY); ThingType thingType; while (thingBeingProcessed != Thing::_endOfList) { thingType = thingBeingProcessed.getType(); @@ -60,7 +60,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 } else if (thingType >= k4_GroupThingType) { break; } - thingBeingProcessed = dunMan.getNextThing(thingBeingProcessed); + thingBeingProcessed = dunMan.f159_getNextThing(thingBeingProcessed); } Thing lastProcessedThing = thingBeingProcessed = squareFirstThing; @@ -69,7 +69,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 if (thingType == k3_SensorThingType) { cell = thingBeingProcessed.getCell(); sensorCountToProcessPerCell[cell]--; - Sensor *sensor = (Sensor*)dunMan.getThingData(thingBeingProcessed); // IF YOU CHECK ME, I'LL CALL THE COPS! + Sensor *sensor = (Sensor*)dunMan.f156_getThingData(thingBeingProcessed); // IF YOU CHECK ME, I'LL CALL THE COPS! SensorType sensorType = sensor->getType(); if (sensorType == k0_SensorDisabled) goto T0275058_ProceedToNextThing; @@ -96,11 +96,11 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 goto T0275058_ProceedToNextThing; case k3_SensorWallOrnClickWithSpecObj: case k4_SensorWallOrnClickWithSpecObjRemoved: - doNotTriggerSensor = ((sensorData == objMan.getObjectType(leaderHandObject)) == sensor->getRevertEffectA()); + doNotTriggerSensor = ((sensorData == objMan.f32_getObjectType(leaderHandObject)) == sensor->getRevertEffectA()); if (!doNotTriggerSensor && (sensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) { if (lastProcessedThing == thingBeingProcessed) break; - ((Sensor*)dunMan.getThingData(lastProcessedThing))->setNextThing(sensor->getNextThing()); + ((Sensor*)dunMan.f156_getThingData(lastProcessedThing))->setNextThing(sensor->getNextThing()); sensor->setNextThing(Thing::_none); thingBeingProcessed = lastProcessedThing; } @@ -137,8 +137,8 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 case k16_SensorWallObjExchanger: { if (sensorCountToProcessPerCell[cell]) goto T0275058_ProceedToNextThing; - Thing thingOnSquare = dunMan.getSquareFirstThing(mapX, mapY); - if ((objMan.getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_none)) + Thing thingOnSquare = dunMan.f161_getSquareFirstThing(mapX, mapY); + if ((objMan.f32_getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_none)) goto T0275058_ProceedToNextThing; warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList"); warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand"); @@ -148,7 +148,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 break; } case k127_SensorWallChampionPortrait: - champMan.addCandidateChampionToParty(sensorData); + champMan.f280_addCandidateChampionToParty(sensorData); goto T0275058_ProceedToNextThing; default: goto T0275058_ProceedToNextThing; @@ -169,7 +169,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 (sensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (sensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) { - *((Thing*)dunMan.getThingData(leaderHandObject)) = Thing::_none; + *((Thing*)dunMan.f156_getThingData(leaderHandObject)) = Thing::_none; warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand"); leaderHandObject = Thing::_none; } else { @@ -186,7 +186,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 break; T0275058_ProceedToNextThing: lastProcessedThing = thingBeingProcessed; - thingBeingProcessed = dunMan.getNextThing(thingBeingProcessed); + thingBeingProcessed = dunMan.f159_getNextThing(thingBeingProcessed); } warning("MISSING CODE: F0271_SENSOR_ProcessRotationEffect"); return atLeastOneSensorWasTriggered; diff --git a/engines/dm/movesens.h b/engines/dm/movesens.h index b73f727f8b..6a8a53ac96 100644 --- a/engines/dm/movesens.h +++ b/engines/dm/movesens.h @@ -37,7 +37,7 @@ class MovesensMan { DMEngine *_vm; public: explicit MovesensMan(DMEngine *vm); - bool sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam); // @ F0275_SENSOR_IsTriggeredByClickOnWall + bool f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam); // @ F0275_SENSOR_IsTriggeredByClickOnWall }; } diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 2ce67ace6a..251401f069 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -121,11 +121,11 @@ void ObjectMan::loadObjectNames() { } } -IconIndice ObjectMan::getObjectType(Thing thing) { +IconIndice ObjectMan::f32_getObjectType(Thing thing) { if (thing == Thing::_none) return kM1_IconIndiceNone; - int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing); + int16 objectInfoIndex = _vm->_dungeonMan->f141_getObjectInfoIndex(thing); if (objectInfoIndex != -1) { objectInfoIndex = g237_ObjectInfo[objectInfoIndex]._type; } @@ -134,15 +134,15 @@ IconIndice ObjectMan::getObjectType(Thing thing) { byte g29_ChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType -IconIndice ObjectMan::getIconIndex(Thing thing) { - IconIndice iconIndex = getObjectType(thing); +IconIndice ObjectMan::f33_getIconIndex(Thing thing) { + IconIndice iconIndex = f32_getObjectType(thing); if ((iconIndex != kM1_IconIndiceNone) && (((iconIndex < k32_IconIndiceWeaponDagger) && (iconIndex >= k0_IconIndiceJunkCompassNorth)) || // < instead of <= is no error ((iconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (iconIndex <= k163_IconIndicePotionWaterFlask)) || (iconIndex == k195_IconIndicePotionEmptyFlask)) ) { - uint16 *rawType = _vm->_dungeonMan->getThingData(thing); + uint16 *rawType = _vm->_dungeonMan->f156_getThingData(thing); switch (iconIndex) { case k0_IconIndiceJunkCompassNorth: iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_g308_partyDir); @@ -184,7 +184,7 @@ IconIndice ObjectMan::getIconIndex(Thing thing) { return iconIndex; } -void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { +void ObjectMan::f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { int16 i; for (i = 0; i < 7; ++i) { if (g26_IconGraphicFirstIndex[i] > iconIndex) @@ -192,14 +192,14 @@ void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { } --i; - byte *srcBitmap = _vm->_displayMan->getBitmap(k42_ObjectIcons_000_TO_031 + i); + byte *srcBitmap = _vm->_displayMan->f489_getBitmap(k42_ObjectIcons_000_TO_031 + i); iconIndex -= g26_IconGraphicFirstIndex[i]; _vm->_displayMan->_g578_useByteBoxCoordinates = true; Box box(0, 0, 15, 15); - _vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, box, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, box, k255_ColorNoTransparency); } -void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { +void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { SlotBox *slotBox = &_g30_slotBoxes[slotBoxIndex]; slotBox->_iconIndex = iconIndex; // yes, this modifies the global array if (slotBox->_iconIndex == kM1_IconIndiceNone) { @@ -219,39 +219,39 @@ void ObjectMan::drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { } } iconGraphicIndex--; - byte *iconsBitmap = _vm->_displayMan->getBitmap(iconGraphicIndex + k42_ObjectIcons_000_TO_031); + byte *iconsBitmap = _vm->_displayMan->f489_getBitmap(iconGraphicIndex + k42_ObjectIcons_000_TO_031); iconIndex -= g26_IconGraphicFirstIndex[iconGraphicIndex]; _vm->_displayMan->_g578_useByteBoxCoordinates = false; if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) { - _vm->_displayMan->blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, + _vm->_displayMan->f132_blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, box, k255_ColorNoTransparency); } else { - _vm->_displayMan->blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, + _vm->_displayMan->f132_blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, _vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); } } #define k14_ObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH -void ObjectMan::drawLeaderObjectName(Thing thing) { - IconIndice iconIndex = getIconIndex(thing); +void ObjectMan::f34_drawLeaderObjectName(Thing thing) { + IconIndice iconIndex = f33_getIconIndex(thing); char *objName; char objectNameBuffer[16]; if (iconIndex == k147_IconIndiceJunkChampionBones) { - Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing); - strcpy(objectNameBuffer, _vm->_championMan->_champions[junk->getChargeCount()]._name); + Junk *junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing); + strcpy(objectNameBuffer, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name); strcat(objectNameBuffer, _g352_objectNames[iconIndex]); objName = objectNameBuffer; } else { objName = _g352_objectNames[iconIndex]; } - _vm->_textMan->printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, 233, 37, + _vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, 233, 37, k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength, k200_heightScreen); } -IconIndice ObjectMan::getIconIndexInSlotBox(uint16 slotBoxIndex) { +IconIndice ObjectMan::f39_getIconIndexInSlotBox(uint16 slotBoxIndex) { return (IconIndice)_g30_slotBoxes[slotBoxIndex]._iconIndex; } } diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index e4ce2cf019..b01957da8a 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -58,12 +58,12 @@ public: char *_g352_objectNames[k199_ObjectNameCount]; // @ G0352_apc_ObjectNames byte *_g412_objectIconForMousePointer; // @ G0412_puc_Bitmap_ObjectIconForMousePointer - IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType - IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex - void extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // @ F0036_OBJECT_ExtractIconFromBitmap - void drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox - void drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName - IconIndice getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox + IconIndice f32_getObjectType(Thing thing); // @ F0032_OBJECT_GetType + IconIndice f33_getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex + void f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap); // @ F0036_OBJECT_ExtractIconFromBitmap + void f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox + void f34_drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName + IconIndice f39_getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox }; diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index ebda26850d..a97060e914 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -35,7 +35,7 @@ TextMan::TextMan(DMEngine* vm) : _vm(vm) {} #define k5_LetterWidth 5 #define k6_LetterHeight 6 -void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, +void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text, uint16 destHeight) { destX -= 1; // fixes missalignment, to be checked destY -= 4; // fixes missalignment, to be checked @@ -43,7 +43,7 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 uint16 textLength = strlen(text); uint16 nextX = destX; uint16 nextY = destY; - byte *srcBitmap = _vm->_displayMan->getBitmap(k557_FontGraphicIndice); + byte *srcBitmap = _vm->_displayMan->f489_getBitmap(k557_FontGraphicIndice); byte *tmp = _vm->_displayMan->_g74_tmpBitmap; for (uint16 i = 0; i < (k5_LetterWidth + 1) * k6_LetterHeight * 128; ++i) { @@ -61,7 +61,7 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1); - _vm->_displayMan->blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth, + _vm->_displayMan->f132_blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth, box, k255_ColorNoTransparency); nextX += k5_LetterWidth + 1; @@ -69,19 +69,19 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 } void TextMan::f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text) { - printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight); + f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight); } -void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) { - printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, posX, posY, textColor, bgColor, text, k200_heightScreen); +void TextMan::f52_printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) { + f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, posX, posY, textColor, bgColor, text, k200_heightScreen); } -void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, +void TextMan::f41_printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) { Common::String str = text; for (int16 i = str.size(); i < requiredTextLength; ++i) str += ' '; - printTextToBitmap(destBitmap, destPixelWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight); + f40_printTextToBitmap(destBitmap, destPixelWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight); } } diff --git a/engines/dm/text.h b/engines/dm/text.h index c71f196658..adfc42635b 100644 --- a/engines/dm/text.h +++ b/engines/dm/text.h @@ -37,11 +37,11 @@ class TextMan { DMEngine *_vm; public: explicit TextMan(DMEngine *vm); - void printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, + void f40_printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, uint16 destHeight); // @ F0040_TEXT_Print void f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text); // @ F0053_TEXT_PrintToLogicalScreen - void printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport - void printWithTrailingSpaces(byte *destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor, + void f52_printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport + void f41_printWithTrailingSpaces(byte *destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor, const char *text, int16 strLenght, int16 destHeight); // @ F0041_TEXT_PrintWithTrailingSpaces }; diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 9803032a5c..4b5cfd411d 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -41,7 +41,7 @@ Timeline::~Timeline() { delete[] _g371_timeline; } -void Timeline::initTimeline() { +void Timeline::f233_initTimeline() { _g370_events = new TimelineEvent[_g369_eventMaxCount]; _g371_timeline = new uint16[_g369_eventMaxCount]; if (_vm->_g298_newGame) { diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index 47d339eb33..c2e06bcd9c 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -153,7 +153,7 @@ public: Timeline(DMEngine *vm); ~Timeline(); - void initTimeline(); // @ F0233_TIMELINE_Initialize + void f233_initTimeline(); // @ F0233_TIMELINE_Initialize }; -- cgit v1.2.3 From ec0b26ce795c9f5d7ecb12a642f444183b52348e Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 3 Jul 2016 01:06:54 +0200 Subject: DM: Reorder blitting method parameters --- engines/dm/champion.cpp | 37 ++++++++++++++++--------------------- engines/dm/gfx.cpp | 39 +++++++++++++++++++-------------------- engines/dm/gfx.h | 4 ++-- engines/dm/inventory.cpp | 36 +++++++++++++----------------------- engines/dm/menus.cpp | 22 +++++++++++----------- engines/dm/objectman.cpp | 10 ++++------ engines/dm/text.cpp | 3 +-- 7 files changed, 66 insertions(+), 85 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 7986650644..8cac2c732a 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -48,7 +48,7 @@ Color g46_ChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; int16 g39_LightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100}; uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks - /* 30 for champion inventory, 8 for chest */ + /* 30 for champion inventory, 8 for chest */ 0xFFFF, /* Ready Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ 0xFFFF, /* Action Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ 0x0002, /* Head Head */ @@ -414,10 +414,10 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch ((Junk*)rawObjPtr)->setChargeCount(1); _g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2]; warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette"); - iconIndex = (IconIndice) (iconIndex + 1); + iconIndex = (IconIndice)(iconIndex + 1); } else if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) { ((Junk*)rawObjPtr)->setChargeCount(1); - iconIndex = (IconIndice) (iconIndex + 1); + iconIndex = (IconIndice)(iconIndex + 1); } } @@ -461,8 +461,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) dispMan._g578_useByteBoxCoordinates = true; { // limit destBox scope Box &destBox = gBoxChampionPortrait; - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k26_ChampionPortraitsIndice), 256, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), - champ->_portrait, 32, destBox, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k26_ChampionPortraitsIndice), champ->_portrait, destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 256, 32, k255_ColorNoTransparency); } champ->_actionIndex = k255_ChampionActionNone; @@ -751,8 +750,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { if (_g407_party._shieldDefense > 0) nativeBitmapIndices[AL_0_borderCount++] = k37_BorderPartyShieldIndice; while (AL_0_borderCount--) { - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(nativeBitmapIndices[AL_0_borderCount]), 80, 0, 0, - dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k10_ColorFlesh); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(nativeBitmapIndices[AL_0_borderCount]), dispMan._g348_bitmapScreen, box, 0, 0, 80, k160_byteWidthScreen * 2, k10_ColorFlesh); } if (isInventoryChamp) { invMan.f354_drawStatusBoxPortrait(champIndex); @@ -761,8 +759,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { champAttributes |= (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand); } } else { - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k8_StatusBoxDeadChampion), 80, 0, 0, - dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k8_StatusBoxDeadChampion), dispMan._g348_bitmapScreen, box, 0, 0, 80, k160_byteWidthScreen * 2, k255_ColorNoTransparency); _vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, champ->_name); menuMan.f386_drawActionIcon(champIndex); goto T0292042_green; @@ -804,8 +801,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { } else { AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; } - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, - dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, gBoxMouth, k12_ColorDarkestGray); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport, gBoxMouth, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray); AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; for (int16 AL_0_statisticIndex = k1_ChampionStatStrength; AL_0_statisticIndex <= k6_ChampionStatAntifire; AL_0_statisticIndex++) { if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent) @@ -814,8 +810,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { break; } } - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), 32, 0, 0, - dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, gBoxEye, k12_ColorDarkestGray); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport, gBoxEye, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray); champAttributes |= k0x4000_ChampionAttributeViewport; } } @@ -858,8 +853,11 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL_0_championIconIndex))) { dispMan.D24_clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]); - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k28_ChampionIcons), 80, M26_championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, - dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g54_BoxChampionIcons[AL_0_championIconIndex], k12_ColorDarkestGray); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k28_ChampionIcons), + dispMan._g348_bitmapScreen, + g54_BoxChampionIcons[AL_0_championIconIndex << 2], + M26_championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, + 40 * 2, k160_byteWidthScreen * 2, k12_ColorDarkestGray); } } @@ -980,11 +978,9 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) { if (nativeBitmapIndex != -1) { _vm->_displayMan->_g578_useByteBoxCoordinates = false; if (isInventoryChamp) { - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), 32, 0, 0, - _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, box, k12_ColorDarkestGray); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray); } else { - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), 32, 0, 0, - _vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, box, k12_ColorDarkestGray); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), _vm->_displayMan->_g348_bitmapScreen, box, 0, 0, 32, k160_byteWidthScreen * 2, k12_ColorDarkestGray); } } @@ -1008,8 +1004,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) { box._x2 = box._x1 + 167; dispMan.f135_fillBoxBitmap(dispMan._g296_bitmapViewport, box, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport); - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k27_PanelRenameChampionIndice), 144, 0, 0, - dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k4_ColorCyan); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k27_PanelRenameChampionIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k4_ColorCyan); textMan.f52_printToViewport(177, 58, k13_ColorLightestGray, "_______"); textMan.f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________"); Common::Point clickPos; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index a21d8213e1..a91d6ee7a8 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -955,7 +955,7 @@ void DisplayMan::f566_viewportBlitToScreen() { warning("MISSING FUNCTIONALITY: using correct colorpalette"); Box box(0, 223, 33, 33 + 135); - f132_blitToBitmap(_g296_bitmapViewport, k112_byteWidthViewport * 2, 0, 0, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); + f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport * 2, k160_byteWidthScreen * 2, k255_ColorNoTransparency); } void DisplayMan::loadPalette(uint16 *palette) { @@ -1017,15 +1017,14 @@ void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) { } } - -void DisplayMan::f132_blitToBitmap(byte* srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, byte* destBitmap, uint16 destWidth, Box& box, Color transparent) { +void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth, + uint16 destWidth, Color transparent) { for (uint16 y = 0; y < box._y2 - box._y1; ++y) for (uint16 x = 0; x < box._x2 - box._x1; ++x) { byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x]; if (srcPixel != transparent) destBitmap[destWidth * (y + box._y1) + box._x1 + x] = srcPixel; } - } void DisplayMan::D24_clearScreenBox(Color color, Box &box) { @@ -1153,12 +1152,12 @@ void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitm void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { if (f._srcWidth) - f132_blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k255_ColorNoTransparency); + f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k255_ColorNoTransparency); } void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) { if (f._srcWidth) - f132_blitToBitmap(bitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh); + f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k10_ColorFlesh); } @@ -1621,12 +1620,12 @@ void DisplayMan::f96_loadCurrentMapGraphics() { f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap, g163_FrameWalls[k0_ViewSquare_D3C]._srcWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight); f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, 128, 51, k10_ColorFlesh); - f132_blitToBitmap(_g74_tmpBitmap, 128, 11, 0, _g90_bitmapWall_D3LCR_Flipped, 128, g161_BoxWallBitmap_D3LCR, k255_ColorNoTransparency); + f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, g161_BoxWallBitmap_D3LCR, 11, 0, 128, 128, k255_ColorNoTransparency); f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap, g163_FrameWalls[k3_ViewSquare_D2C]._srcWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight); f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, 144, 71, k10_ColorFlesh); - f132_blitToBitmap(_g74_tmpBitmap, 144, 8, 0, _g91_bitmapWall_D2LCR_Flipped, 144, g162_BoxWallBitmap_D2LCR, k255_ColorNoTransparency); + f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, g162_BoxWallBitmap_D2LCR, 8, 0, 144, 144, k255_ColorNoTransparency); f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped, g163_FrameWalls[k6_ViewSquare_D1C]._srcWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight); @@ -1733,13 +1732,13 @@ void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementC void DisplayMan::f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) { if (f._srcWidth) - f132_blitToBitmap(_bitmaps[nativeIndex], f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh); + f132_blitToBitmap(_bitmaps[nativeIndex], _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k10_ColorFlesh); } void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) { if (f._srcWidth) { f99_copyBitmapAndFlipHorizontal(f489_getBitmap(nativeIndex), _g74_tmpBitmap, f._srcWidth, f._srcHeight); - f132_blitToBitmap(_g74_tmpBitmap, f._srcWidth, f._srcX, f._srcY, _g296_bitmapViewport, k112_byteWidthViewport * 2, f._box, k10_ColorFlesh); + f132_blitToBitmap(_g74_tmpBitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k10_ColorFlesh); } } @@ -1804,8 +1803,8 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall if (viewWallIndex == k12_ViewWall_D1C_FRONT) { if (isInscription) { Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C]; - f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, D1CFrame._srcWidth, 94, 28, _g296_bitmapViewport, k112_byteWidthViewport * 2, - g202_BoxWallPatchBehindInscription, k255_ColorNoTransparency); + f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, g202_BoxWallPatchBehindInscription, 94, 28, + D1CFrame._srcWidth, k112_byteWidthViewport * 2, k255_ColorNoTransparency); unsigned char *string = inscriptionString; bitmapRed = _bitmaps[k120_InscriptionFontIndice]; @@ -1819,7 +1818,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7; frame._box._y1 = (frame._box._y2 = g203_InscriptionLineY[textLineIndex++]) - 7; while (characterCount--) { - f132_blitToBitmap(bitmapRed, 288, (*string++) * 8, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, frame._box, k10_ColorFlesh); + f132_blitToBitmap(bitmapRed, _g296_bitmapViewport, frame._box, (*string++) * 8, 0, 288, k112_byteWidthViewport * 2, k10_ColorFlesh); frame._box._x1 += 8; frame._box._x2 += 8; } @@ -1905,12 +1904,12 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1]; } } - f132_blitToBitmap(bitmapGreen, coordinateSetA[4], var_X, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, *(Box*)coordinateSetA, k10_ColorFlesh); + f132_blitToBitmap(bitmapGreen, _g296_bitmapViewport, *(Box*)coordinateSetA, var_X, 0, coordinateSetA[4], k112_byteWidthViewport * 2, k10_ColorFlesh); if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { Box &box = g109_BoxChampionPortraitOnWall; - f132_blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], 256, (_g289_championPortraitOrdinal & 0x7) << 5, (_g289_championPortraitOrdinal >> 3) * 29, - _g296_bitmapViewport, k112_byteWidthViewport * 2, box, k1_ColorDarkGary); + f132_blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], _g296_bitmapViewport, box, (_g289_championPortraitOrdinal & 0x7) << 5, + (_g289_championPortraitOrdinal >> 3) * 29, 256, k112_byteWidthViewport * 2, k1_ColorDarkGary); } return isAlcove; } @@ -2417,7 +2416,7 @@ T0115015_DrawProjectileAsObject: AL_6_bitmapRedBanana = bitmapGreenAnt; dunMan._g292_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */ } - f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh); + f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport * 2, k10_ColorFlesh); if (drawProjectileAsObject) goto T0115171_BackFromT0115015_DrawProjectileAsObject; @@ -2668,7 +2667,7 @@ T0115077_DrawSecondHalfSquareCreature: AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1); } warning("SUPER WARNINIG: we might nee noralized with on byteWidth"); - f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_0_creaturePosX, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, (Color)transparentColor); + f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_0_creaturePosX, 0, byteWidth, k112_byteWidthViewport * 2, (Color)transparentColor); T0115126_CreatureNotVisible: if (twoHalfSquareCreaturesFrontView) { @@ -2803,7 +2802,7 @@ the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */ AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1)); } - f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh); + f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport * 2, k10_ColorFlesh); } else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */ useAlcoveObjectImage = false; projectileCoordinates[0] = projectilePosX; @@ -2955,7 +2954,7 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP if (flipVertical) { flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } - f132_blitToBitmap(AL_6_bitmapRedBanana, byteWidth, AL_4_xPos, 0, _g296_bitmapViewport, k112_byteWidthViewport * 2, boxByteGreen, k10_ColorFlesh); + f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport * 2, k10_ColorFlesh); } } } while ((thingParam = dunMan.f159_getNextThing(thingParam)) != Thing::_endOfList); diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index a0a61ba78f..1305322e72 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -547,8 +547,8 @@ public: void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); - void f132_blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, - byte *destBitmap, uint16 destWidth, Box &box, Color transparent = k255_ColorNoTransparency); // @ F0132_VIDEO_Blit + void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth, + uint16 destWidth, Color transparent = k255_ColorNoTransparency); // @ F0132_VIDEO_Blit void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 1d1eb5e8c9..9718a57be2 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -128,8 +128,7 @@ void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) { box._y2 = 28 + 1; box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7; box._x2 = box._x1 + 31 + 1; - dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, 32, 0, 0, - dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, dispMan._g348_bitmapScreen, box, 0, 0, 32, k160_byteWidthScreen * 2, k255_ColorNoTransparency); } void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) { @@ -162,15 +161,11 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() { Champion &champ = _vm->_championMan->_gK71_champions[_g432_inventoryChampionOrdinal]; f334_closeChest(); DisplayMan &dispMan = *_vm->_displayMan; - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), 144, 0, 0, - dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g32_BoxPanel, k8_ColorRed); - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k30_FoodLabelIndice), 48, 0, 0, - dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g35_BoxFood, k12_ColorDarkestGray); - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k31_WaterLabelIndice), 48, 0, 0, - dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g36_BoxWater, k12_ColorDarkestGray); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 144, k160_byteWidthScreen * 2, k8_ColorRed); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k30_FoodLabelIndice), dispMan._g348_bitmapScreen, g35_BoxFood, 0, 0, 48, k160_byteWidthScreen * 2, k12_ColorDarkestGray); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k31_WaterLabelIndice), dispMan._g348_bitmapScreen, g36_BoxWater, 0, 0, 48, k160_byteWidthScreen * 2, k12_ColorDarkestGray); if (champ._poisonEventCount) { - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k32_PoisionedLabelIndice), 96, 0, 0, - dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g37_BoxPoisoned, k12_ColorDarkestGray); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k32_PoisionedLabelIndice), dispMan._g348_bitmapScreen, g37_BoxPoisoned, 0, 0, 96, k160_byteWidthScreen * 2, k12_ColorDarkestGray); } f344_drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown); f344_drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue); @@ -178,8 +173,7 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() { void InventoryMan::f346_drawPanelResurrectReincarnate() { _g424_panelContent = k5_PanelContentResurrectReincarnate; - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(k40_PanelResurectReincaranteIndice), 144, 0, 0, - _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k6_ColorDarkGreen); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(k40_PanelResurectReincaranteIndice), _vm->_displayMan->_g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k6_ColorDarkGreen); } void InventoryMan::f347_drawPanel() { @@ -262,7 +256,7 @@ void InventoryMan::f341_drawPanelScroll(Scroll* scroll) { charRed++; } *charRed = '\0'; - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k23_PanelOpenScrollIndice), 144, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k8_ColorRed); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k23_PanelOpenScrollIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k8_ColorRed); int16 lineCount = 1; charRed++; char *charGreen = charRed; // first char of the second line @@ -314,7 +308,7 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo if (!isPressingEye) { objMan.f38_drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen); } - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k25_PanelOpenChestIndice), 144, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g32_BoxPanel, k8_ColorRed); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k25_PanelOpenChestIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 144, k160_byteWidthScreen * 2, k8_ColorRed); int16 chestSlotIndex = 0; Thing thing = chest->getSlot(); @@ -340,8 +334,7 @@ void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int box._x2 = (box._x1 = xPos) + 15 + 1; box._y2 = (box._y1 = yPos) + 15 + 1; _vm->_objectMan->f36_extractIconFromBitmap(iconIndex, iconBitmap); - _vm->_displayMan->f132_blitToBitmap(iconBitmap, 16, 0, 0, _vm->_displayMan->_g296_bitmapViewport, - k112_byteWidthViewport * 2, box, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(iconBitmap, _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport * 2, k255_ColorNoTransparency); } void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) { @@ -415,8 +408,7 @@ Box g33_BoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOr void InventoryMan::f339_drawPanelArrowOrEye(bool pressingEye) { DisplayMan &dispMan = *_vm->_displayMan; - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice), - 16, 0, 0, dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g33_BoxArrowOrEye, k8_ColorRed); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice), dispMan._g296_bitmapViewport, g33_BoxArrowOrEye, 0, 0, 16, k112_byteWidthViewport * 2, k8_ColorRed); } @@ -448,10 +440,8 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) { f333_openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye); } else { IconIndice iconIndex = objMan.f33_getIconIndex(thingToDraw); - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), 144, 0, 0, - dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g32_BoxPanel, k8_ColorRed); - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k29_ObjectDescCircleIndice), 32, 0, 0, - dispMan._g296_bitmapViewport, k112_byteWidthViewport * 2, g34_BoxObjectDescCircle, k12_ColorDarkestGray); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k8_ColorRed); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k29_ObjectDescCircleIndice), dispMan._g296_bitmapViewport, g34_BoxObjectDescCircle, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray); char *descString = nullptr; char str[40]; @@ -552,7 +542,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) { strcat(str, "."); // TODO: localization weight -= (weight / 10) * 10; - strcat(str, champMan.f288_getStringFromInteger(weight, false, 1).c_str()); + strcat(str, champMan.f288_getStringFromInteger(weight, false, 1).c_str()); strcat(str, " KG."); // TODO: localization diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 1d93895e09..ee023e7522 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -64,7 +64,7 @@ void MenuMan::f395_drawMovementArrows() { Box &dest = g2_BoxMovementArrows; uint16 w = disp.getWidth(k13_MovementArrowsIndice); - disp.f132_blitToBitmap(arrowsBitmap, w, 0, 0, disp._g348_bitmapScreen, k160_byteWidthScreen * 2, dest, k255_ColorNoTransparency); + disp.f132_blitToBitmap(arrowsBitmap, disp._g348_bitmapScreen, dest, 0, 0, w, k160_byteWidthScreen * 2, k255_ColorNoTransparency); } void MenuMan::f388_clearActingChampion() { ChampionMan &cm = *_vm->_championMan; @@ -113,7 +113,7 @@ T0386006: box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that box2._y1 = 95; box2._y2 = 110 + 1; - dm.f132_blitToBitmap(bitmapIcon, 16, 0, 0, dm._g348_bitmapScreen, k160_byteWidthScreen * 2, box2); + dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 16, k160_byteWidthScreen * 2, k255_ColorNoTransparency); if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } @@ -208,13 +208,13 @@ void MenuMan::f387_drawActionArea() { box = g500_BoxActionArea2ActionMenu; if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone) box = g501_BoxActionArea1ActionMenu; - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k10_MenuActionAreaIndice), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k10_MenuActionAreaIndice), dispMan._g348_bitmapScreen, box, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency); textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 235, 83, k0_ColorBlack, k4_ColorCyan, champMan._gK71_champions[_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name, - k7_ChampionNameMaximumLength, k200_heightScreen); + k7_ChampionNameMaximumLength, k200_heightScreen); for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) { textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack, - f384_getActionName(_g713_actionList._actionIndices[actionListIndex]), - k12_ActionNameMaximumLength, k200_heightScreen); + f384_getActionName(_g713_actionList._actionIndices[actionListIndex]), + k12_ActionNameMaximumLength, k200_heightScreen); } } warning("MISSING CODE: F0078_MOUSE_ShowPointer"); @@ -315,7 +315,7 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) { Champion &champ = _vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex]; if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) { dispMan._g578_useByteBoxCoordinates = false; - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 12, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 12, 96, 96, k255_ColorNoTransparency); int16 x = 1; byte c = 96 + (6 * champ._symbolStep); char spellSymbolString[2] = {'\0', '\0'}; @@ -325,7 +325,7 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) { } } else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) { dispMan._g578_useByteBoxCoordinates = false; - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), 96, 0, 24, _gK72_bitmapSpellAreaLine, 96, gK74_BoxSpellAreaLine, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 24, 96, 96, k255_ColorNoTransparency); char spellSymbolString[2] = {'\0', '\0'}; int16 x = 8; for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) { @@ -345,7 +345,7 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) { return; if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) { warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k9_MenuSpellAreaBackground), 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, g0_BoxSpellArea); + dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k9_MenuSpellAreaBackground), dispMan._g348_bitmapScreen, g0_BoxSpellArea, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } if (champIndex == kM1_ChampionNone) { @@ -361,9 +361,9 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) { f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols); warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); f393_drawSpellAreaControls((ChampionIndex)champIndex); - dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK75_BoxSpellAreaLine2); + dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK75_BoxSpellAreaLine2, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency); f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols); - dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, 96, 0, 0, dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, gK76_BoxSpellAreaLine3); + dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } } diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 251401f069..2daf3e12bb 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -196,7 +196,7 @@ void ObjectMan::f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { iconIndex -= g26_IconGraphicFirstIndex[i]; _vm->_displayMan->_g578_useByteBoxCoordinates = true; Box box(0, 0, 15, 15); - _vm->_displayMan->f132_blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, box, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 256, 16, k255_ColorNoTransparency); } void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { @@ -224,12 +224,10 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { _vm->_displayMan->_g578_useByteBoxCoordinates = false; if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) { - _vm->_displayMan->f132_blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, - _vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, box, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g296_bitmapViewport, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 256, k112_byteWidthViewport * 2, k255_ColorNoTransparency); } else { - _vm->_displayMan->f132_blitToBitmap(iconsBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, - _vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g348_bitmapScreen, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 256, k160_byteWidthScreen * 2, k255_ColorNoTransparency); } } @@ -248,7 +246,7 @@ void ObjectMan::f34_drawLeaderObjectName(Thing thing) { objName = _g352_objectNames[iconIndex]; } _vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, 233, 37, - k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength, k200_heightScreen); + k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength, k200_heightScreen); } IconIndice ObjectMan::f39_getIconIndexInSlotBox(uint16 slotBoxIndex) { diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index a97060e914..b29584e3bd 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -61,8 +61,7 @@ void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uin uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1); - _vm->_displayMan->f132_blitToBitmap(srcBitmap, 6 * 128, (nextX == destX) ? (srcX + 1) : srcX, 0, destBitmap, destPixelWidth, - box, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128, destPixelWidth, k255_ColorNoTransparency); nextX += k5_LetterWidth + 1; } -- cgit v1.2.3 From c756d1755670ed26c0171b6207279e4c321293be Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 3 Jul 2016 01:15:10 +0200 Subject: DM: Reorder DisplayMan::D24_clearScrenBox parameters --- engines/dm/champion.cpp | 10 +++++----- engines/dm/eventman.cpp | 4 ++-- engines/dm/gfx.cpp | 6 +++--- engines/dm/gfx.h | 6 +++--- engines/dm/inventory.cpp | 2 +- engines/dm/menus.cpp | 10 +++++----- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 8cac2c732a..125bdde4ea 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -675,12 +675,12 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) { if (barGraphHeight < 25) { box._y1 = 2; box._y1 = 27 - barGraphHeight + 1; - _vm->_displayMan->D24_clearScreenBox(g46_ChampionColor[champIndex], box); + _vm->_displayMan->D24_fillScreenBox(box, g46_ChampionColor[champIndex]); } if (barGraphHeight) { box._y1 = 27 - barGraphHeight; box._y2 = 26 + 1; - _vm->_displayMan->D24_clearScreenBox(g46_ChampionColor[champIndex], box); + _vm->_displayMan->D24_fillScreenBox(box, g46_ChampionColor[champIndex]); } box._x1 += 7; box._x2 += 7; @@ -738,7 +738,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { box._x1 = champStatusBoxX; box._x2 = box._x1 + 66 + 1; if (champ->_currHealth) { - dispMan.D24_clearScreenBox(k12_ColorDarkestGray, box); + dispMan.D24_fillScreenBox(box, k12_ColorDarkestGray); int16 nativeBitmapIndices[3]; for (int16 i = 0; i < 3; ++i) nativeBitmapIndices[i] = 0; @@ -786,7 +786,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { box._y2 = 6 + 1; box._x1 = champStatusBoxX; box._x2 = box._x1 + 42 + 1; - dispMan.D24_clearScreenBox(k1_ColorDarkGary, box); + dispMan.D24_fillScreenBox(box, k1_ColorDarkGary); _vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, k1_ColorDarkGary, champ->_name); } } @@ -852,7 +852,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { int16 AL_0_championIconIndex = M26_championIconIndex(champ->_cell, _vm->_dungeonMan->_g308_partyDir); if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL_0_championIconIndex))) { - dispMan.D24_clearScreenBox(g46_ChampionColor[champIndex], g54_BoxChampionIcons[AL_0_championIconIndex]); + dispMan.D24_fillScreenBox(g54_BoxChampionIcons[AL_0_championIconIndex], g46_ChampionColor[champIndex]); dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k28_ChampionIcons), dispMan._g348_bitmapScreen, g54_BoxChampionIcons[AL_0_championIconIndex << 2], diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 226b616c50..a4d1b6d640 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -614,8 +614,8 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat box._x1 = championIndex * k69_ChampionStatusBoxSpacing; box._x2 = box._x1 + 66 + 1; dispMan._g578_useByteBoxCoordinates = false; - dispMan.D24_clearScreenBox(k0_ColorBlack, box); - dispMan.D24_clearScreenBox(k0_ColorBlack, g54_BoxChampionIcons[champMan.M26_championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2]); + dispMan.D24_fillScreenBox(box, k0_ColorBlack); + dispMan.D24_fillScreenBox(g54_BoxChampionIcons[champMan.M26_championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2], k0_ColorBlack); warning("F0457_START_DrawEnabledMenus_CPSF"); warning("F0078_MOUSE_ShowPointer"); return; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index a91d6ee7a8..79669a11a4 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -725,7 +725,7 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) { delete[] _g74_tmpBitmap; delete[] _g348_bitmapScreen; _g348_bitmapScreen = new byte[_screenWidth * _screenHeight]; - clearScreen(k0_ColorBlack); + fillScreen(k0_ColorBlack); } void DisplayMan::f479_loadGraphics() { @@ -1027,7 +1027,7 @@ void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, } } -void DisplayMan::D24_clearScreenBox(Color color, Box &box) { +void DisplayMan::D24_fillScreenBox(Box &box, Color color) { uint16 width = box._x2 - box._x1; for (int16 y = box._y1; y < box._y2; ++y) memset(_g348_bitmapScreen + y * _screenWidth + box._x1, color, sizeof(byte) * width); @@ -1559,7 +1559,7 @@ void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) { f97_drawViewport((_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0); } -void DisplayMan::clearScreen(Color color) { +void DisplayMan::fillScreen(Color color) { memset(getCurrentVgaBuffer(), color, sizeof(byte) * _screenWidth * _screenHeight); } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 1305322e72..72f9fa6cff 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -561,9 +561,9 @@ public: byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap void f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color); // @ F0134_VIDEO_FillBitmap - void clearScreen(Color color); - void D24_clearScreenBox(Color color, Box &box); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox - void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 pixelWidth, int16 height); + void fillScreen(Color color); + void D24_fillScreenBox(Box &box, Color color); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox + void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 pixelWidth, int16 height); // @ F0135_VIDEO_FillBox void f128_drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 9718a57be2..527fea3da3 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -138,7 +138,7 @@ void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidt box._y1 = y; box._y2 = box._y1 + 6 + 1; _vm->_displayMan->_g578_useByteBoxCoordinates = false; - _vm->_displayMan->D24_clearScreenBox(color, box); + _vm->_displayMan->D24_fillScreenBox(box, color); } void InventoryMan::f344_drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) { diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index ee023e7522..38b974bb79 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -90,7 +90,7 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) { box._y2 = 120 + 1; dm._g578_useByteBoxCoordinates = false; if (!champion._currHealth) { - dm.D24_clearScreenBox(k0_ColorBlack, box); + dm.D24_fillScreenBox(box, k0_ColorBlack); return; } byte *bitmapIcon = dm._g74_tmpBitmap; @@ -107,7 +107,7 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) { _vm->_objectMan->f36_extractIconFromBitmap(iconIndex, bitmapIcon); dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, g498_PalChangesActionAreaObjectIcon); T0386006: - dm.D24_clearScreenBox(k4_ColorCyan, box); + dm.D24_fillScreenBox(box, k4_ColorCyan); Box box2; box2._x1 = box._x1 + 2; box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that @@ -198,7 +198,7 @@ void MenuMan::f387_drawActionArea() { warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); dispMan._g578_useByteBoxCoordinates = false; - dispMan.D24_clearScreenBox(k0_ColorBlack, g1_BoxActionArea); + dispMan.D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack); if (_g509_actionAreaContainsIcons) { for (uint16 champIndex = k0_ChampionFirst; champIndex < champMan._g305_partyChampionCount; ++champIndex) f386_drawActionIcon((ChampionIndex)champIndex); @@ -248,7 +248,7 @@ void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) { for (uint16 i = 0; i < 4; ++i) champCurrHealth[i] = champMan._gK71_champions[i]._currHealth; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan.D24_clearScreenBox(k0_ColorBlack, g504_BoxSpellAreaControls); + dispMan.D24_fillScreenBox(g504_BoxSpellAreaControls, k0_ColorBlack); int16 champCount = champMan._g305_partyChampionCount; switch (champIndex) { case k0_ChampionFirst: @@ -352,7 +352,7 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) { champMan._g514_magicCasterChampionIndex = kM1_ChampionNone; warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); dispMan._g578_useByteBoxCoordinates = false; - dispMan.D24_clearScreenBox(k0_ColorBlack, g0_BoxSpellArea); + dispMan.D24_fillScreenBox(g0_BoxSpellArea, k0_ColorBlack); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); return; } -- cgit v1.2.3 From f01a03e91865a4cec1119bb83a5682d8f5f25553 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 3 Jul 2016 02:19:22 +0200 Subject: DM: Add default parameters to DipslayMan::f132_blitToBitmap --- engines/dm/gfx.cpp | 4 +++- engines/dm/gfx.h | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 79669a11a4..a9c555e857 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1018,7 +1018,9 @@ void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) { } void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth, - uint16 destWidth, Color transparent) { + uint16 destWidth, Color transparent, int16 srcHeight, int16 destHight) { + // Note: if you want to use srcHeight and destHight parameters, remove the defaults values and + // and complete the function calls at the callsites, otherwise their value can be the default -1 for (uint16 y = 0; y < box._y2 - box._y1; ++y) for (uint16 x = 0; x < box._x2 - box._x1; ++x) { byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x]; diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 72f9fa6cff..1515229d7d 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -547,8 +547,11 @@ public: void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); + /* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which + does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters + match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/ void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth, - uint16 destWidth, Color transparent = k255_ColorNoTransparency); // @ F0132_VIDEO_Blit + uint16 destWidth, Color transparent = k255_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, -- cgit v1.2.3 From bd06132072852e7695015cad4373c31893b04934 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 3 Jul 2016 03:07:38 +0200 Subject: DM: Box objects are not expected to conatain inclusive boundaries, blitting and other methods adapted --- engines/dm/champion.cpp | 24 ++++++++++++------------ engines/dm/dm.cpp | 2 +- engines/dm/eventman.cpp | 4 ++-- engines/dm/gfx.cpp | 45 +++++++++++++++++++++++---------------------- engines/dm/gfx.h | 14 +++++++++----- engines/dm/inventory.cpp | 12 ++++++------ engines/dm/menus.cpp | 8 ++++---- engines/dm/objectman.cpp | 4 ++-- 8 files changed, 59 insertions(+), 54 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 125bdde4ea..44d783f4ff 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -666,20 +666,20 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) { Box box; box._x1 = champIndex * k69_ChampionStatusBoxSpacing + 46; - box._x2 = box._x1 + 3 + 1; + box._x2 = box._x1 + 3; box._y1 = 2; - box._y2 = 26 + 1; + box._y2 = 26; for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) { int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex]; if (barGraphHeight < 25) { box._y1 = 2; - box._y1 = 27 - barGraphHeight + 1; + box._y1 = 27 - barGraphHeight; _vm->_displayMan->D24_fillScreenBox(box, g46_ChampionColor[champIndex]); } if (barGraphHeight) { box._y1 = 27 - barGraphHeight; - box._y2 = 26 + 1; + box._y2 = 26; _vm->_displayMan->D24_fillScreenBox(box, g46_ChampionColor[champIndex]); } box._x1 += 7; @@ -734,9 +734,9 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { dispMan._g578_useByteBoxCoordinates = false; if (champAttributes & k0x1000_ChampionAttributeStatusBox) { box._y1 = 0; - box._y2 = 28 + 1; + box._y2 = 28; box._x1 = champStatusBoxX; - box._x2 = box._x1 + 66 + 1; + box._x2 = box._x1 + 66; if (champ->_currHealth) { dispMan.D24_fillScreenBox(box, k12_ColorDarkestGray); int16 nativeBitmapIndices[3]; @@ -783,9 +783,9 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { champAttributes |= k0x4000_ChampionAttributeViewport; } else { box._y1 = 0; - box._y2 = 6 + 1; + box._y2 = 6; box._x1 = champStatusBoxX; - box._x2 = box._x1 + 42 + 1; + box._x2 = box._x1 + 42; dispMan.D24_fillScreenBox(box, k1_ColorDarkGary); _vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, k1_ColorDarkGary, champ->_name); } @@ -930,8 +930,8 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) { Box box; box._x1 = slotBox->_x - 1; box._y1 = slotBox->_y - 1; - box._x2 = box._x1 + 17 + 1; - box._y2 = box._y1 + 17 + 1; + box._x2 = box._x1 + 17; + box._y2 = box._y1 + 17; if (!isInventoryChamp) { @@ -999,7 +999,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) { Box box; box._y1 = 3; - box._y2 = 8 + 1; + box._y2 = 8; box._x1 = 3; box._x2 = box._x1 + 167; @@ -1008,7 +1008,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) { textMan.f52_printToViewport(177, 58, k13_ColorLightestGray, "_______"); textMan.f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________"); Common::Point clickPos; - static Box okButtonBox(197, 215, 147, 155); // inclusive boundaries, constructor adds +1 + static Box okButtonBox(197, 215, 147, 155); for (;;) { _vm->_eventMan->processInput(); if (_vm->_eventMan->f360_hasPendingClick(clickPos, k1_LeftMouseButton) && okButtonBox.isPointInside(clickPos)) { diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index c5ff2f2287..7a3ce4089e 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -262,7 +262,7 @@ void DMEngine::f2_gameloop() { //} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking); if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { - Box box(0, 224, 0, 126); + Box box(0, 223, 0, 135); _displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport * 2, k136_heightViewport); // dummy code _displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index a4d1b6d640..490449d61c 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -610,9 +610,9 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat champMan._g305_partyChampionCount--; Box box; box._y1 = 0; - box._y2 = 28 + 1; + box._y2 = 28; box._x1 = championIndex * k69_ChampionStatusBoxSpacing; - box._x2 = box._x1 + 66 + 1; + box._x2 = box._x1 + 66; dispMan._g578_useByteBoxCoordinates = false; dispMan.D24_fillScreenBox(box, k0_ColorBlack); dispMan.D24_fillScreenBox(g54_BoxChampionIcons[champMan.M26_championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2], k0_ColorBlack); diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index a9c555e857..d4229bdd91 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -120,7 +120,7 @@ FieldAspect g188_FieldAspects[12] = { // @ G0188_as_Graphic558_FieldAspects FieldAspect(0, 63, 0x0A, 0x83, 16, 136, 0, 64), /* D0L */ FieldAspect(0, 63, 0x0A, 0x03, 16, 136, 0, 64)}; /* D0R */ -Box g2_BoxMovementArrows = Box(224, 319, 124, 168); +Box g2_BoxMovementArrows = Box(224, 319, 124, 168); // @ G0002_s_Graphic562_Box_MovementArrows byte g212_PalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke @@ -1021,8 +1021,8 @@ void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 destWidth, Color transparent, int16 srcHeight, int16 destHight) { // Note: if you want to use srcHeight and destHight parameters, remove the defaults values and // and complete the function calls at the callsites, otherwise their value can be the default -1 - for (uint16 y = 0; y < box._y2 - box._y1; ++y) - for (uint16 x = 0; x < box._x2 - box._x1; ++x) { + for (uint16 y = 0; y < box._y2 + 1 - box._y1; ++y) // + 1 for inclusive boundaries + for (uint16 x = 0; x < box._x2 + 1 - box._x1; ++x) { // + 1 for inclusive boundaries byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x]; if (srcPixel != transparent) destBitmap[destWidth * (y + box._y1) + box._x1 + x] = srcPixel; @@ -1030,19 +1030,20 @@ void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, } void DisplayMan::D24_fillScreenBox(Box &box, Color color) { - uint16 width = box._x2 - box._x1; - for (int16 y = box._y1; y < box._y2; ++y) + uint16 width = box._x2 + 1 - box._x1; // + 1 for inclusive boundaries + for (int16 y = box._y1; y < box._y2 + 1; ++y) // + 1 for inclusive boundaries memset(_g348_bitmapScreen + y * _screenWidth + box._x1, color, sizeof(byte) * width); } void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int16 pixelWidth, int16 height) { - for (int16 y = box._y1; y < box._y2; ++y) - memset(destBitmap + y * pixelWidth + box._x1, color, sizeof(byte) * (box._x2 - box._x1)); + for (int16 y = box._y1; y < box._y2 + 1; ++y) // + 1 for inclusive boundaries + memset(destBitmap + y * pixelWidth + box._x1, color, sizeof(byte) * (box._x2 - box._x1 + 1)); // + 1 for inclusive boundaries } void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2) { + // make sure to take care of inclusive boundaries warning("STUB FUNCTION: does nothing at all"); } @@ -2368,7 +2369,7 @@ T0115015_DrawProjectileAsObject: } } AL_4_xPos = coordinateSet[0]; - boxByteGreen._y2 = coordinateSet[1] + 1; + boxByteGreen._y2 = coordinateSet[1]; if (!drawProjectileAsObject) { /* If drawing an object that is not a projectile */ AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][g217_ObjectPileShiftSetIndices[objectShiftIndex][0]]; boxByteGreen._y2 += g223_ShiftSets[AL_8_shiftSetIndex][g217_ObjectPileShiftSetIndices[objectShiftIndex][1]]; @@ -2381,12 +2382,12 @@ T0115015_DrawProjectileAsObject: objectShiftIndex &= 0x000F; } } - boxByteGreen._y1 = boxByteGreen._y2 - (heightRedEagle - 1) - 1; - if (boxByteGreen._y2 > 136) { - boxByteGreen._y2 = 136; + boxByteGreen._y1 = boxByteGreen._y2 - (heightRedEagle - 1); + if (boxByteGreen._y2 > 135) { + boxByteGreen._y2 = 135; } - boxByteGreen._x2 = MIN(224, AL_4_xPos + byteWidth); - if (boxByteGreen._x1 = MAX(0, AL_4_xPos - byteWidth + 1)) { + boxByteGreen._x2 = MIN(223, AL_4_xPos + byteWidth); + if (boxByteGreen._x1 = MAX(0, AL_4_xPos - byteWidth)) { if (flipHorizontal) { AL_4_xPos = paddingPixelCount; } else { @@ -2402,7 +2403,7 @@ T0115015_DrawProjectileAsObject: if (AL_6_boxPtrRed->_x1 == 255) { /* If the grabbable object is the first */ *AL_6_boxPtrRed = boxByteGreen; - if ((heightGreenGoat = AL_6_boxPtrRed->_y2 - AL_6_boxPtrRed->_y1) < 15) { /* If the box is too small then enlarge it a little */ + if ((heightGreenGoat = AL_6_boxPtrRed->_y2 - AL_6_boxPtrRed->_y1) < 14) { /* If the box is too small then enlarge it a little */ heightGreenGoat = heightGreenGoat >> 1; AL_6_boxPtrRed->_y1 += heightGreenGoat - 7; if (heightGreenGoat < 4) { @@ -2648,7 +2649,7 @@ T0115077_DrawSecondHalfSquareCreature: } AL_4_yPos = coordinateSet[1]; AL_4_yPos += g223_ShiftSets[AL_8_shiftSetIndex][M23_getVerticalOffsetM23(creatureAspectInt)]; - boxByteGreen._y2 = MIN(AL_4_yPos, (int16)135) + 1; + boxByteGreen._y2 = MIN(AL_4_yPos, (int16)135); boxByteGreen._y1 = MIN(0, AL_4_yPos - (heightRedEagle - 1)); AL_4_xPos = coordinateSet[0]; AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][M22_getHorizontalOffsetM22(creatureAspectInt)]; @@ -2659,7 +2660,7 @@ T0115077_DrawSecondHalfSquareCreature: AL_4_xPos += 100; } } - if (boxByteGreen._x2 = 1 + MIN(MAX(0, AL_4_xPos + byteWidth), 223) <= 1) + if (!(boxByteGreen._x2 = MIN(MAX(0, AL_4_xPos + byteWidth), 223))) goto T0115126_CreatureNotVisible; if (boxByteGreen._x1 = MIN(MAX(0, AL_4_xPos - byteWidth + 1), 223)) { if (boxByteGreen._x1 == 223) @@ -2788,9 +2789,9 @@ continue; f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); } } - boxByteGreen._y2 = (heightRedEagle >> 1) + 47 + 1; + boxByteGreen._y2 = (heightRedEagle >> 1) + 47; boxByteGreen._y1 = 47 - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001); - boxByteGreen._x2 = MIN(223, projectilePosX + byteWidth) + 1; + boxByteGreen._x2 = MIN(223, projectilePosX + byteWidth); if (boxByteGreen._x1 = MAX(0, projectilePosX - byteWidth + 1)) { if (flipHorizontal) { AL_4_xPos = paddingPixelCount; @@ -2920,14 +2921,14 @@ T0115200_DrawExplosion: if (flipHorizontal = _vm->_rnd->getRandomNumber(2)) { paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; /* Number of unused pixels in the units on the right of the bitmap */ } - boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1)) + 1; + boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1)); AL_4_yPos = MAX(0, explosionCoordinates[1] - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001)); if (AL_4_yPos >= 136) continue; boxByteGreen._y1 = AL_4_yPos; if ((AL_4_xPos = MIN(223, explosionCoordinates[0] + byteWidth)) < 0) continue; - boxByteGreen._x2 = AL_4_xPos + 1; + boxByteGreen._x2 = AL_4_xPos; AL_4_xPos = explosionCoordinates[0]; if (boxByteGreen._x1 = MIN(MAX(0, AL_4_xPos - byteWidth + 1), 223)) { AL_4_xPos = paddingPixelCount; @@ -2942,7 +2943,7 @@ and may cause an incorrect bitmap to be drawn */ only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */ } - if (boxByteGreen._x2 - 1 <= boxByteGreen._x1) + if (boxByteGreen._x2 <= boxByteGreen._x1) continue; warning("might need M77_NORMALIZED_BYTE_WIDTH"); byteWidth = byteWidth; @@ -2965,7 +2966,7 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP AL_1_viewSquareExplosionIndex -= 3; /* Convert square index for explosions back to square index */ fieldAspect = g188_FieldAspects[viewSquareIndex]; (fieldAspect._nativeBitmapRelativeIndex)++; /* NativeBitmapRelativeIndex is now the index of the Fluxcage field graphic */ - f113_drawField(&fieldAspect, *(Box*)&g163_FrameWalls[viewSquareIndex]); + f113_drawField(&fieldAspect, g163_FrameWalls[viewSquareIndex]._box); } } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 1515229d7d..6bfb504326 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -230,6 +230,8 @@ extern uint16 g19_PalCredits[16]; // @ G0019_aui_Graphic562_Palette_Credits extern uint16 g20_PalEntrance[16]; // @ G0020_aui_Graphic562_Palette_Entrance extern uint16 g21_PalDungeonView[6][16]; // @ G0021_aaui_Graphic562_Palette_DungeonView + +// in all cases, where a function takes a Box, it expects it to contain inclusive boundaries class Box { public: uint16 _x1; @@ -237,15 +239,15 @@ public: uint16 _y1; uint16 _y2; - Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2) : _x1(x1), _x2(x2 + 1), _y1(y1), _y2(y2 + 1) {} + Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2) : _x1(x1), _x2(x2), _y1(y1), _y2(y2) {} Box() {} bool isPointInside(Common::Point point) { - return (_x1 <= point.x) && (point.x < _x2) && (_y1 <= point.y) && (point.y < _y2); + return (_x1 <= point.x) && (point.x <= _x2) && (_y1 <= point.y) && (point.y <= _y2); // <= because incluseive boundaries } void setToZero() { _x1 = _x2 = _y1 = _y2 = 0; } }; // @ BOX_BYTE, BOX_WORD -extern Box g2_BoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows +extern Box g2_BoxMovementArrows; // @ G0002_s_Graphic562_Box_MovementArrows class Frame { public: @@ -550,22 +552,24 @@ public: /* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/ + /* Expects inclusive boundaries in box */ void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth, uint16 destWidth, Color transparent = k255_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit - +/* Expects inclusive boundaries in box */ void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight, byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges - void f103_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap void f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color); // @ F0134_VIDEO_FillBitmap void fillScreen(Color color); + /* Expects inclusive boundaries in box */ void D24_fillScreenBox(Box &box, Color color); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox +/* Expects inclusive boundaries in box */ void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 pixelWidth, int16 height); // @ F0135_VIDEO_FillBox void f128_drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 527fea3da3..77242c1e58 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -125,18 +125,18 @@ void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) { dispMan._g578_useByteBoxCoordinates = false; Box box; box._y1 = 0; - box._y2 = 28 + 1; + box._y2 = 28; box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7; - box._x2 = box._x1 + 31 + 1; + box._x2 = box._x1 + 31; dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, dispMan._g348_bitmapScreen, box, 0, 0, 32, k160_byteWidthScreen * 2, k255_ColorNoTransparency); } void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) { Box box; box._x1 = x; - box._x2 = box._x1 + pixelWidth + 1; + box._x2 = box._x1 + pixelWidth; box._y1 = y; - box._y2 = box._y1 + 6 + 1; + box._y2 = box._y1 + 6; _vm->_displayMan->_g578_useByteBoxCoordinates = false; _vm->_displayMan->D24_fillScreenBox(box, color); } @@ -331,8 +331,8 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos) { static byte iconBitmap[16 * 16]; Box box; - box._x2 = (box._x1 = xPos) + 15 + 1; - box._y2 = (box._y1 = yPos) + 15 + 1; + box._x2 = (box._x1 = xPos) + 15; + box._y2 = (box._y1 = yPos) + 15; _vm->_objectMan->f36_extractIconFromBitmap(iconIndex, iconBitmap); _vm->_displayMan->f132_blitToBitmap(iconBitmap, _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport * 2, k255_ColorNoTransparency); } diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 38b974bb79..196fab740f 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -85,9 +85,9 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) { Box box; box._x1 = championIndex * 22 + 233; - box._x2 = box._x1 + 19 + 1; + box._x2 = box._x1 + 19; box._y1 = 86; - box._y2 = 120 + 1; + box._y2 = 120; dm._g578_useByteBoxCoordinates = false; if (!champion._currHealth) { dm.D24_fillScreenBox(box, k0_ColorBlack); @@ -110,9 +110,9 @@ T0386006: dm.D24_fillScreenBox(box, k4_ColorCyan); Box box2; box2._x1 = box._x1 + 2; - box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that + box2._x2 = box._x2 - 2; box2._y1 = 95; - box2._y2 = 110 + 1; + box2._y2 = 110; dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 16, k160_byteWidthScreen * 2, k255_ColorNoTransparency); if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 2daf3e12bb..1d8b7800bb 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -209,8 +209,8 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { Box box; box._x1 = slotBox->_x; box._y1 = slotBox->_y; - box._x2 = box._x1 + 15 + 1; - box._y2 = box._y1 + 15 + 1; + box._x2 = box._x1 + 15; + box._y2 = box._y1 + 15; uint16 iconGraphicIndex; for (iconGraphicIndex = 0; iconGraphicIndex < 7; ++iconGraphicIndex) { -- cgit v1.2.3 From d7b0413be646e774d9b251bba30b34440fa50289 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 3 Jul 2016 14:49:04 +0200 Subject: DM: Reorder blitshrink parameters --- engines/dm/gfx.cpp | 23 ++++++++++++----------- engines/dm/gfx.h | 4 ++-- engines/dm/menus.cpp | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index d4229bdd91..33c9c6deb9 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1087,7 +1087,7 @@ byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale } else { byte *nativeBitmap = f489_getBitmap(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice); bitmap = f492_getDerivedBitmap(derBitmapIndex); - f129_blitToBitmapShrinkWithPalChange(nativeBitmap, explAsp->_pixelWidth, explAsp->_height, bitmap, pixelWidth, height, + f129_blitToBitmapShrinkWithPalChange(nativeBitmap, bitmap, explAsp->_pixelWidth, explAsp->_height, pixelWidth, height, (explosionAspIndex == k3_ExplosionAspectSmoke) ? g212_PalChangeSmoke : g17_PalChangesNoChanges); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } @@ -1870,7 +1870,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall } } int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0]; - f129_blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], coordSetB[4] << 1, coordSetB[5], _g74_tmpBitmap, pixelWidth + 1, coordinateSetA[5], + f129_blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], _g74_tmpBitmap, coordSetB[4] << 1, coordSetB[5],pixelWidth + 1, coordinateSetA[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2); bitmapGreen = _bitmaps[nativeBitmapIndex]; var_X = pixelWidth; @@ -1920,7 +1920,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall } -void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHeight, byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange) { +void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap, int16 srcWidth, int16 srcHeight, int16 destWidth, int16 destHeight, byte *palChange) { double rateW = srcWidth / destWidth; double rateH = srcHeight / destHeight; @@ -2360,8 +2360,9 @@ T0115015_DrawProjectileAsObject: AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); } else { bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex); - f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, objectAspect->_width, objectAspect->_height, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), - byteWidth, heightRedEagle, paletteChanges); + f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), + objectAspect->_width, objectAspect->_height, + byteWidth, heightRedEagle, paletteChanges); if (flipHorizontal) { f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } @@ -2626,7 +2627,7 @@ T0115077_DrawSecondHalfSquareCreature: } else { bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex); AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); - f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, sourceByteWidth, sourceHeight, AL_6_bitmapRedBanana, byteWidth, heightRedEagle, paletteChanges); + f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, sourceByteWidth, sourceHeight, byteWidth, heightRedEagle, paletteChanges); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */ @@ -2768,8 +2769,8 @@ continue; } else { AL_6_bitmapRedBanana = _g74_tmpBitmap; } - f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, - AL_6_bitmapRedBanana, byteWidth, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]); + f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, + byteWidth, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]); if (doNotScaleWithKineticEnergy) { warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap"); } @@ -2858,8 +2859,8 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_width), explosionCoordinates[2]); heightRedEagle = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]); if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) { - f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, - ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, _g74_tmpBitmap, + f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, + ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, byteWidth, heightRedEagle, g17_PalChangesNoChanges); AL_6_bitmapRedBanana = _g74_tmpBitmap; } @@ -2889,7 +2890,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache"); AL_6_bitmapRedBanana = f489_getBitmap(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice); if (smoke) { - f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, 48, 32, _g74_tmpBitmap, 48, 32, g212_PalChangeSmoke); + f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, 48, 32, 48, 32, g212_PalChangeSmoke); AL_6_bitmapRedBanana = _g74_tmpBitmap; } f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C, diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 6bfb504326..92b14d186a 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -559,8 +559,8 @@ public: void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap - void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth, int16 srcHight, - byte *destBitmap, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges + void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap, + int16 srcWidth, int16 srcHight, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges void f103_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 196fab740f..4f5b985f5c 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -105,7 +105,7 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) { goto T0386006; } _vm->_objectMan->f36_extractIconFromBitmap(iconIndex, bitmapIcon); - dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, g498_PalChangesActionAreaObjectIcon); + dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, bitmapIcon, 16, 16, 16, 16, g498_PalChangesActionAreaObjectIcon); T0386006: dm.D24_fillScreenBox(box, k4_ColorCyan); Box box2; -- cgit v1.2.3 From cb345ff614f431b7442aba590fd5d59a88dc1e4a Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 3 Jul 2016 14:58:05 +0200 Subject: DM: Reorder fillBitmap parameters --- engines/dm/gfx.cpp | 54 ++++++++++++++++++++++++++-------------------------- engines/dm/gfx.h | 4 ++-- engines/dm/menus.cpp | 6 +++--- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 33c9c6deb9..2bfcb6c213 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1018,9 +1018,9 @@ void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) { } void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth, - uint16 destWidth, Color transparent, int16 srcHeight, int16 destHight) { - // Note: if you want to use srcHeight and destHight parameters, remove the defaults values and - // and complete the function calls at the callsites, otherwise their value can be the default -1 + uint16 destWidth, Color transparent, int16 srcHeight, int16 destHight) { + // Note: if you want to use srcHeight and destHight parameters, remove the defaults values and + // and complete the function calls at the callsites, otherwise their value can be the default -1 for (uint16 y = 0; y < box._y2 + 1 - box._y1; ++y) // + 1 for inclusive boundaries for (uint16 x = 0; x < box._x2 + 1 - box._x1; ++x) { // + 1 for inclusive boundaries byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x]; @@ -1041,15 +1041,15 @@ void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int } void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box, - int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, - int16 xPos, int16 yPos, int16 destHeight, int16 height2) { - // make sure to take care of inclusive boundaries + int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, + int16 xPos, int16 yPos, int16 destHeight, int16 height2) { + // make sure to take care of inclusive boundaries warning("STUB FUNCTION: does nothing at all"); } -void DisplayMan::f103_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) { +void DisplayMan::f130_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) { for (uint16 y = 0; y < height; ++y) { for (uint16 x = 0; x < width / 2; ++x) { byte tmp; @@ -1150,7 +1150,7 @@ uint16 DisplayMan::getHeight(uint16 index) { // Note: has been screened for missing code void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 pixelWidth, uint16 height) { memmove(destBitmap, srcBitmap, pixelWidth * height * sizeof(byte)); - f103_flipBitmapHorizontal(destBitmap, pixelWidth, height); + f130_flipBitmapHorizontal(destBitmap, pixelWidth, height); } void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { @@ -1566,7 +1566,7 @@ void DisplayMan::fillScreen(Color color) { memset(getCurrentVgaBuffer(), color, sizeof(byte) * _screenWidth * _screenHeight); } -void DisplayMan::f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color) { +void DisplayMan::f134_fillBitmap(byte *bitmap, Color color, uint16 width, uint16 height) { memset(bitmap, color, sizeof(byte) * width * height); } @@ -1622,12 +1622,12 @@ void DisplayMan::f96_loadCurrentMapGraphics() { f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap, g163_FrameWalls[k0_ViewSquare_D3C]._srcWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight); - f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, 128, 51, k10_ColorFlesh); + f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 128, 51); f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, g161_BoxWallBitmap_D3LCR, 11, 0, 128, 128, k255_ColorNoTransparency); f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap, g163_FrameWalls[k3_ViewSquare_D2C]._srcWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight); - f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, 144, 71, k10_ColorFlesh); + f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 144, 71); f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, g162_BoxWallBitmap_D2LCR, 8, 0, 144, 144, k255_ColorNoTransparency); f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped, @@ -1870,7 +1870,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall } } int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0]; - f129_blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], _g74_tmpBitmap, coordSetB[4] << 1, coordSetB[5],pixelWidth + 1, coordinateSetA[5], + f129_blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], _g74_tmpBitmap, coordSetB[4] << 1, coordSetB[5], pixelWidth + 1, coordinateSetA[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2); bitmapGreen = _bitmaps[nativeBitmapIndex]; var_X = pixelWidth; @@ -1961,9 +1961,9 @@ void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) { } else { bitmapMask = dispMan._g74_tmpBitmap; memmove(bitmapMask, dispMan.f489_getBitmap(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)), - fieldAspect->_height * fieldAspect->_pixelWidth * sizeof(bitmapMask[0])); + fieldAspect->_height * fieldAspect->_pixelWidth * sizeof(bitmapMask[0])); if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) { - dispMan.f103_flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height); + dispMan.f130_flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height); } } @@ -2138,7 +2138,7 @@ int16 g225_CenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_Cen #define k0x0080_BlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK void DisplayMan::f115_cthulhu(Thing thingParam, direction directionParam, int16 mapXpos, - int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) { + int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) { DungeonMan &dunMan = *_vm->_dungeonMan; @@ -2331,7 +2331,7 @@ T0115015_DrawProjectileAsObject: heightRedEagle = objectAspect->_height; if (flipHorizontal) { memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); - f103_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); + f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; } } else { @@ -2364,7 +2364,7 @@ T0115015_DrawProjectileAsObject: objectAspect->_width, objectAspect->_height, byteWidth, heightRedEagle, paletteChanges); if (flipHorizontal) { - f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); + f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } @@ -2577,7 +2577,7 @@ T0115077_DrawSecondHalfSquareCreature: AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex); if (creatureDirectionDelta == 1) { memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); - f103_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); + f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; } } else { @@ -2585,7 +2585,7 @@ T0115077_DrawSecondHalfSquareCreature: AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex); if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) { memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); - f103_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); + f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; } } else { /* Use first additional derived graphic: front D1 */ @@ -2596,7 +2596,7 @@ T0115077_DrawSecondHalfSquareCreature: if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) { AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); memmove(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * heightRedEagle * sizeof(byte)); - f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); + f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } @@ -2641,7 +2641,7 @@ T0115077_DrawSecondHalfSquareCreature: memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte)); AL_6_bitmapRedBanana = _g74_tmpBitmap; } - f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); + f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); } creaturePaddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; } else { @@ -2770,7 +2770,7 @@ continue; AL_6_bitmapRedBanana = _g74_tmpBitmap; } f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, - byteWidth, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]); + byteWidth, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]); if (doNotScaleWithKineticEnergy) { warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap"); } @@ -2787,7 +2787,7 @@ continue; flipBitmapVertical(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); } if (flipHorizontal) { - f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); + f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); } } boxByteGreen._y2 = (heightRedEagle >> 1) + 47; @@ -2861,7 +2861,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) { f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, - byteWidth, heightRedEagle, g17_PalChangesNoChanges); + byteWidth, heightRedEagle, g17_PalChangesNoChanges); AL_6_bitmapRedBanana = _g74_tmpBitmap; } goto T0115200_DrawExplosion; @@ -2894,8 +2894,8 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; AL_6_bitmapRedBanana = _g74_tmpBitmap; } f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C, - _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64), - 224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93); + _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64), + 224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } else { @@ -2953,7 +2953,7 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP AL_6_bitmapRedBanana = _g74_tmpBitmap; } if (flipHorizontal) { - f103_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); + f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } if (flipVertical) { flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 92b14d186a..282dfc2f3d 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -561,11 +561,11 @@ public: int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap, int16 srcWidth, int16 srcHight, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges - void f103_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally + void f130_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0130_VIDEO_FlipHorizontal void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap - void f134_fillBitmap(byte *bitmap, uint16 width, uint16 height, Color color); // @ F0134_VIDEO_FillBitmap + void f134_fillBitmap(byte *bitmap, Color color, uint16 width, uint16 height); // @ F0134_VIDEO_FillBitmap void fillScreen(Color color); /* Expects inclusive boundaries in box */ void D24_fillScreenBox(Box &box, Color color); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 4f5b985f5c..63ca90c8fd 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -101,16 +101,16 @@ void MenuMan::f386_drawActionIcon(ChampionIndex championIndex) { } else if (g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(thing)]._actionSetIndex) { iconIndex = _vm->_objectMan->f33_getIconIndex(thing); } else { - dm.f134_fillBitmap(bitmapIcon, 16, 16, k4_ColorCyan); + dm.f134_fillBitmap(bitmapIcon, k4_ColorCyan, 16, 16); goto T0386006; } _vm->_objectMan->f36_extractIconFromBitmap(iconIndex, bitmapIcon); - dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, bitmapIcon, 16, 16, 16, 16, g498_PalChangesActionAreaObjectIcon); + dm.f129_blitToBitmapShrinkWithPalChange(bitmapIcon, bitmapIcon, 16, 16, 16, 16, g498_PalChangesActionAreaObjectIcon); T0386006: dm.D24_fillScreenBox(box, k4_ColorCyan); Box box2; box2._x1 = box._x1 + 2; - box2._x2 = box._x2 - 2; + box2._x2 = box._x2 - 2; box2._y1 = 95; box2._y2 = 110; dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 16, k160_byteWidthScreen * 2, k255_ColorNoTransparency); -- cgit v1.2.3 From 816319c65912a0274b1203dd9f8051b75706cbc0 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sun, 3 Jul 2016 21:12:47 +0200 Subject: DM: Revert to using byteWidths where the original does so as well --- engines/dm/champion.cpp | 34 ++-- engines/dm/champion.h | 2 +- engines/dm/dm.cpp | 2 +- engines/dm/eventman.h | 2 +- engines/dm/gfx.cpp | 493 ++++++++++++++++++++++++----------------------- engines/dm/gfx.h | 56 +++--- engines/dm/inventory.cpp | 30 +-- engines/dm/menus.cpp | 33 ++-- engines/dm/objectman.cpp | 12 +- engines/dm/text.cpp | 16 +- engines/dm/text.h | 4 +- 11 files changed, 354 insertions(+), 330 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 44d783f4ff..333243c969 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -138,7 +138,7 @@ Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding, return result += valToStr; } -void ChampionMan::f299_pplyModifiersToStatistics(Champion* champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing) { +void ChampionMan::f299_applyModifiersToStatistics(Champion* champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing) { int16 statIndex; int16 modifier = 0; ThingType thingType = thing.getType(); @@ -383,7 +383,7 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch champ->setAttributeFlag(k0x0200_ChampionAttributeLoad, true); IconIndice iconIndex = objMan.f33_getIconIndex(thing); bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal); - f299_pplyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing); + f299_applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing); uint16 *rawObjPtr = dunMan.f156_getThingData(thing); if (slotIndex < k2_ChampionSlotHead) { @@ -461,7 +461,8 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) dispMan._g578_useByteBoxCoordinates = true; { // limit destBox scope Box &destBox = gBoxChampionPortrait; - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k26_ChampionPortraitsIndice), champ->_portrait, destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 256, 32, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), champ->_portrait, + destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 128, 16, k255_ColorNoTransparency); } champ->_actionIndex = k255_ChampionActionNone; @@ -750,7 +751,8 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { if (_g407_party._shieldDefense > 0) nativeBitmapIndices[AL_0_borderCount++] = k37_BorderPartyShieldIndice; while (AL_0_borderCount--) { - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(nativeBitmapIndices[AL_0_borderCount]), dispMan._g348_bitmapScreen, box, 0, 0, 80, k160_byteWidthScreen * 2, k10_ColorFlesh); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(nativeBitmapIndices[AL_0_borderCount]), + dispMan._g348_bitmapScreen, box, 0, 0, 40, k160_byteWidthScreen, k10_ColorFlesh); } if (isInventoryChamp) { invMan.f354_drawStatusBoxPortrait(champIndex); @@ -759,7 +761,8 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { champAttributes |= (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand); } } else { - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k8_StatusBoxDeadChampion), dispMan._g348_bitmapScreen, box, 0, 0, 80, k160_byteWidthScreen * 2, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), dispMan._g348_bitmapScreen, + box, 0, 0, 40, k160_byteWidthScreen, k255_ColorNoTransparency); _vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, champ->_name); menuMan.f386_drawActionIcon(champIndex); goto T0292042_green; @@ -801,7 +804,8 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { } else { AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; } - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport, gBoxMouth, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport, + gBoxMouth, 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray); AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; for (int16 AL_0_statisticIndex = k1_ChampionStatStrength; AL_0_statisticIndex <= k6_ChampionStatAntifire; AL_0_statisticIndex++) { if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent) @@ -810,7 +814,8 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { break; } } - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport, gBoxEye, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport, gBoxEye, + 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray); champAttributes |= k0x4000_ChampionAttributeViewport; } } @@ -853,11 +858,11 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL_0_championIconIndex))) { dispMan.D24_fillScreenBox(g54_BoxChampionIcons[AL_0_championIconIndex], g46_ChampionColor[champIndex]); - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k28_ChampionIcons), + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k28_ChampionIcons), dispMan._g348_bitmapScreen, g54_BoxChampionIcons[AL_0_championIconIndex << 2], M26_championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, - 40 * 2, k160_byteWidthScreen * 2, k12_ColorDarkestGray); + 40, k160_byteWidthScreen, k12_ColorDarkestGray); } } @@ -978,9 +983,11 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) { if (nativeBitmapIndex != -1) { _vm->_displayMan->_g578_useByteBoxCoordinates = false; if (isInventoryChamp) { - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), + _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray); } else { - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(nativeBitmapIndex), _vm->_displayMan->_g348_bitmapScreen, box, 0, 0, 32, k160_byteWidthScreen * 2, k12_ColorDarkestGray); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), + _vm->_displayMan->_g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen, k12_ColorDarkestGray); } } @@ -1003,8 +1010,9 @@ void ChampionMan::f281_renameChampion(Champion* champ) { box._x1 = 3; box._x2 = box._x1 + 167; - dispMan.f135_fillBoxBitmap(dispMan._g296_bitmapViewport, box, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport); - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k27_PanelRenameChampionIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k4_ColorCyan); + dispMan.f135_fillBoxBitmap(dispMan._g296_bitmapViewport, box, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, + 0, 0, 72, k112_byteWidthViewport, k4_ColorCyan); textMan.f52_printToViewport(177, 58, k13_ColorLightestGray, "_______"); textMan.f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________"); Common::Point clickPos; diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 1b7a4ff548..cabf06fbfb 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -461,7 +461,7 @@ public: void f281_renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename uint16 f303_getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel Common::String f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger - void f299_pplyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex, + void f299_applyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics bool f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged void f296_drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 7a3ce4089e..ae7852d649 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -263,7 +263,7 @@ void DMEngine::f2_gameloop() { if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { Box box(0, 223, 0, 135); - _displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport * 2, k136_heightViewport); // dummy code + _displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // dummy code _displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); } diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index 51f176185a..c156eedd94 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -243,7 +243,7 @@ public: void setMousePos(Common::Point pos); void processInput(); // acknowledges mouse and keyboard input void f360_processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick - void f359_processClick(Common::Point mousePos, MouseButton button); // @ F0359_COMMAND_ProcessClick_CPSC + void f359_processClick(Common::Point mousePos, MouseButton button); // @ F0359_COMMAND_ProcessClick_CPSC CommandType f358_getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC void f380_processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 2bfcb6c213..4aa9ea2b2a 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -224,111 +224,111 @@ byte g195_FloorOrnCoordSetIndices[9] = { // @ G0195_auc_Graphic558_FloorOrnament 0}; /* Floor Ornament 08 Puddle */ uint16 g205_WallOrnCoordSets[8][13][6] = { // @ G0205_aaauc_Graphic558_WallOrnamentCoordinateSets - /* { X1, X2, Y1, Y2, PixelWidth, Height } */ - {{80, 83, 41, 45, 8 * 2, 5}, /* D3L */ - {140, 143, 41, 45, 8 * 2, 5}, /* D3R */ - {16, 29, 39, 50, 8 * 2, 12}, /* D3L */ - {107, 120, 39, 50, 8 * 2, 12}, /* D3C */ - {187, 200, 39, 50, 8 * 2, 12}, /* D3R */ - {67, 77, 40, 49, 8 * 2, 10}, /* D2L */ - {146, 156, 40, 49, 8 * 2, 10}, /* D2R */ - {0, 17, 38, 55, 16 * 2, 18}, /* D2L */ - {102, 123, 38, 55, 16 * 2, 18}, /* D2C */ - {206, 223, 38, 55, 16 * 2, 18}, /* D2R */ - {48, 63, 38, 56, 8 * 2, 19}, /* D1L */ - {160, 175, 38, 56, 8 * 2, 19}, /* D1R */ - {96, 127, 36, 63, 16 * 2, 28}}, /* D1C */ - {{74, 82, 41, 60, 8 * 2, 20}, /* D3L */ - {141, 149, 41, 60, 8 * 2, 20}, /* D3R */ - {1, 47, 37, 63, 24 * 2, 27}, /* D3L */ - {88, 134, 37, 63, 24 * 2, 27}, /* D3C */ - {171, 217, 37, 63, 24 * 2, 27}, /* D3R */ - {61, 76, 38, 67, 8 * 2, 30}, /* D2L */ - {147, 162, 38, 67, 8 * 2, 30}, /* D2R */ - {0, 43, 37, 73, 32 * 2, 37}, /* D2L */ - {80, 143, 37, 73, 32 * 2, 37}, /* D2C */ - {180, 223, 37, 73, 32 * 2, 37}, /* D2R */ - {32, 63, 36, 83, 16 * 2, 48}, /* D1L */ - {160, 191, 36, 83, 16 * 2, 48}, /* D1R */ - {64, 159, 36, 91, 48 * 2, 56}}, /* D1C */ - {{80, 83, 66, 70, 8 * 2, 5}, /* D3L */ - {140, 143, 66, 70, 8 * 2, 5}, /* D3R */ - {16, 29, 64, 75, 8 * 2, 12}, /* D3L */ - {106, 119, 64, 75, 8 * 2, 12}, /* D3C */ - {187, 200, 64, 75, 8 * 2, 12}, /* D3R */ - {67, 77, 74, 83, 8 * 2, 10}, /* D2L */ - {146, 156, 74, 83, 8 * 2, 10}, /* D2R */ - {0, 17, 73, 90, 16 * 2, 18}, /* D2L */ - {100, 121, 73, 90, 16 * 2, 18}, /* D2C */ - {206, 223, 73, 90, 16 * 2, 18}, /* D2R */ - {48, 63, 84, 102, 8 * 2, 19}, /* D1L */ - {160, 175, 84, 102, 8 * 2, 19}, /* D1R */ - {96, 127, 92, 119, 16 * 2, 28}}, /* D1C */ - {{80, 83, 49, 53, 8 * 2, 5}, /* D3L */ - {140, 143, 49, 53, 8 * 2, 5}, /* D3R */ - {16, 29, 50, 61, 8 * 2, 12}, /* D3L */ - {106, 119, 50, 61, 8 * 2, 12}, /* D3C */ - {187, 200, 50, 61, 8 * 2, 12}, /* D3R */ - {67, 77, 53, 62, 8 * 2, 10}, /* D2L */ - {146, 156, 53, 62, 8 * 2, 10}, /* D2R */ - {0, 17, 55, 72, 16 * 2, 18}, /* D2L */ - {100, 121, 55, 72, 16 * 2, 18}, /* D2C */ - {206, 223, 55, 72, 16 * 2, 18}, /* D2R */ - {48, 63, 57, 75, 8 * 2, 19}, /* D1L */ - {160, 175, 57, 75, 8 * 2, 19}, /* D1R */ - {96, 127, 64, 91, 16 * 2, 28}}, /* D1C */ - {{75, 90, 40, 44, 8 * 2, 5}, /* D3L */ - {133, 148, 40, 44, 8 * 2, 5}, /* D3R */ - {1, 48, 44, 49, 24 * 2, 6}, /* D3L */ - {88, 135, 44, 49, 24 * 2, 6}, /* D3C */ - {171, 218, 44, 49, 24 * 2, 6}, /* D3R */ - {60, 77, 40, 46, 16 * 2, 7}, /* D2L */ - {146, 163, 40, 46, 16 * 2, 7}, /* D2R */ - {0, 35, 43, 50, 32 * 2, 8}, /* D2L */ - {80, 143, 43, 50, 32 * 2, 8}, /* D2C */ - {184, 223, 43, 50, 32 * 2, 8}, /* D2R */ - {32, 63, 41, 52, 16 * 2, 12}, /* D1L */ - {160, 191, 41, 52, 16 * 2, 12}, /* D1R */ - {64, 159, 41, 52, 48 * 2, 12}}, /* D1C */ - {{78, 85, 36, 51, 8 * 2, 16}, /* D3L */ - {138, 145, 36, 51, 8 * 2, 16}, /* D3R */ - {10, 41, 34, 53, 16 * 2, 20}, /* D3L */ - {98, 129, 34, 53, 16 * 2, 20}, /* D3C */ - {179, 210, 34, 53, 16 * 2, 20}, /* D3R */ - {66, 75, 34, 56, 8 * 2, 23}, /* D2L */ - {148, 157, 34, 56, 8 * 2, 23}, /* D2R */ - {0, 26, 33, 61, 24 * 2, 29}, /* D2L */ - {91, 133, 33, 61, 24 * 2, 29}, /* D2C */ - {194, 223, 33, 61, 24 * 2, 29}, /* D2R */ - {41, 56, 31, 65, 8 * 2, 35}, /* D1L */ - {167, 182, 31, 65, 8 * 2, 35}, /* D1R */ - {80, 143, 29, 71, 32 * 2, 43}}, /* D1C */ - {{75, 82, 25, 75, 8 * 2, 51}, /* D3L */ - {142, 149, 25, 75, 8 * 2, 51}, /* D3R */ - {12, 60, 25, 75, 32 * 2, 51}, /* D3L */ - {88, 136, 25, 75, 32 * 2, 51}, /* D3C */ - {163, 211, 25, 75, 32 * 2, 51}, /* D3R */ - {64, 73, 20, 90, 8 * 2, 71}, /* D2L */ - {150, 159, 20, 90, 8 * 2, 71}, /* D2R */ - {0, 38, 20, 90, 32 * 2, 71}, /* D2L */ - {82, 142, 20, 90, 32 * 2, 71}, /* D2C */ - {184, 223, 20, 90, 32 * 2, 71}, /* D2R */ - {41, 56, 9, 119, 8 * 2, 111}, /* D1L */ - {169, 184, 9, 119, 8 * 2, 111}, /* D1R */ - {64, 159, 9, 119, 48 * 2, 111}}, /* D1C */ - {{74, 85, 25, 75, 8 * 2, 51}, /* D3L */ - {137, 149, 25, 75, 8 * 2, 51}, /* D3R */ - {0, 75, 25, 75, 40 * 2, 51}, /* D3L Atari ST: { 0, 83, 25, 75, 48*2, 51 } */ - {74, 149, 25, 75, 40 * 2, 51}, /* D3C Atari ST: { 74, 149, 25, 75, 48*2, 51 } */ - {148, 223, 25, 75, 40 * 2, 51}, /* D3R Atari ST: { 139, 223, 25, 75, 48*2, 51 } */ - {60, 77, 20, 90, 16 * 2, 71}, /* D2L */ - {146, 163, 20, 90, 16 * 2, 71}, /* D2R */ - {0, 74, 20, 90, 56 * 2, 71}, /* D2L */ - {60, 163, 20, 90, 56 * 2, 71}, /* D2C */ - {149, 223, 20, 90, 56 * 2, 71}, /* D2R */ - {32, 63, 9, 119, 16 * 2, 111}, /* D1L */ - {160, 191, 9, 119, 16 * 2, 111}, /* D1R */ - {32, 191, 9, 119, 80 * 2, 111}}}; /* D1C */ + /* { X1, X2, Y1, Y2, PixelWidth, Height } */ + {{80, 83, 41, 45, 8, 5}, /* D3L */ + {140, 143, 41, 45, 8, 5}, /* D3R */ + {16, 29, 39, 50, 8, 12}, /* D3L */ + {107, 120, 39, 50, 8, 12}, /* D3C */ + {187, 200, 39, 50, 8, 12}, /* D3R */ + {67, 77, 40, 49, 8, 10}, /* D2L */ + {146, 156, 40, 49, 8, 10}, /* D2R */ + {0, 17, 38, 55, 16, 18}, /* D2L */ + {102, 123, 38, 55, 16, 18}, /* D2C */ + {206, 223, 38, 55, 16, 18}, /* D2R */ + {48, 63, 38, 56, 8, 19}, /* D1L */ + {160, 175, 38, 56, 8, 19}, /* D1R */ + {96, 127, 36, 63, 16, 28}}, /* D1C */ + {{74, 82, 41, 60, 8, 20}, /* D3L */ + {141, 149, 41, 60, 8, 20}, /* D3R */ + {1, 47, 37, 63, 24, 27}, /* D3L */ + {88, 134, 37, 63, 24, 27}, /* D3C */ + {171, 217, 37, 63, 24, 27}, /* D3R */ + {61, 76, 38, 67, 8, 30}, /* D2L */ + {147, 162, 38, 67, 8, 30}, /* D2R */ + {0, 43, 37, 73, 32, 37}, /* D2L */ + {80, 143, 37, 73, 32, 37}, /* D2C */ + {180, 223, 37, 73, 32, 37}, /* D2R */ + {32, 63, 36, 83, 16, 48}, /* D1L */ + {160, 191, 36, 83, 16, 48}, /* D1R */ + {64, 159, 36, 91, 48, 56}}, /* D1C */ + {{80, 83, 66, 70, 8, 5}, /* D3L */ + {140, 143, 66, 70, 8, 5}, /* D3R */ + {16, 29, 64, 75, 8, 12}, /* D3L */ + {106, 119, 64, 75, 8, 12}, /* D3C */ + {187, 200, 64, 75, 8, 12}, /* D3R */ + {67, 77, 74, 83, 8, 10}, /* D2L */ + {146, 156, 74, 83, 8, 10}, /* D2R */ + {0, 17, 73, 90, 16, 18}, /* D2L */ + {100, 121, 73, 90, 16, 18}, /* D2C */ + {206, 223, 73, 90, 16, 18}, /* D2R */ + {48, 63, 84, 102, 8, 19}, /* D1L */ + {160, 175, 84, 102, 8, 19}, /* D1R */ + {96, 127, 92, 119, 16, 28}}, /* D1C */ + {{80, 83, 49, 53, 8, 5}, /* D3L */ + {140, 143, 49, 53, 8, 5}, /* D3R */ + {16, 29, 50, 61, 8, 12}, /* D3L */ + {106, 119, 50, 61, 8, 12}, /* D3C */ + {187, 200, 50, 61, 8, 12}, /* D3R */ + {67, 77, 53, 62, 8, 10}, /* D2L */ + {146, 156, 53, 62, 8, 10}, /* D2R */ + {0, 17, 55, 72, 16, 18}, /* D2L */ + {100, 121, 55, 72, 16, 18}, /* D2C */ + {206, 223, 55, 72, 16, 18}, /* D2R */ + {48, 63, 57, 75, 8, 19}, /* D1L */ + {160, 175, 57, 75, 8, 19}, /* D1R */ + {96, 127, 64, 91, 16, 28}}, /* D1C */ + {{75, 90, 40, 44, 8, 5}, /* D3L */ + {133, 148, 40, 44, 8, 5}, /* D3R */ + {1, 48, 44, 49, 24, 6}, /* D3L */ + {88, 135, 44, 49, 24, 6}, /* D3C */ + {171, 218, 44, 49, 24, 6}, /* D3R */ + {60, 77, 40, 46, 16, 7}, /* D2L */ + {146, 163, 40, 46, 16, 7}, /* D2R */ + {0, 35, 43, 50, 32, 8}, /* D2L */ + {80, 143, 43, 50, 32, 8}, /* D2C */ + {184, 223, 43, 50, 32, 8}, /* D2R */ + {32, 63, 41, 52, 16, 12}, /* D1L */ + {160, 191, 41, 52, 16, 12}, /* D1R */ + {64, 159, 41, 52, 48, 12}}, /* D1C */ + {{78, 85, 36, 51, 8, 16}, /* D3L */ + {138, 145, 36, 51, 8, 16}, /* D3R */ + {10, 41, 34, 53, 16, 20}, /* D3L */ + {98, 129, 34, 53, 16, 20}, /* D3C */ + {179, 210, 34, 53, 16, 20}, /* D3R */ + {66, 75, 34, 56, 8, 23}, /* D2L */ + {148, 157, 34, 56, 8, 23}, /* D2R */ + {0, 26, 33, 61, 24, 29}, /* D2L */ + {91, 133, 33, 61, 24, 29}, /* D2C */ + {194, 223, 33, 61, 24, 29}, /* D2R */ + {41, 56, 31, 65, 8, 35}, /* D1L */ + {167, 182, 31, 65, 8, 35}, /* D1R */ + {80, 143, 29, 71, 32, 43}}, /* D1C */ + {{75, 82, 25, 75, 8, 51}, /* D3L */ + {142, 149, 25, 75, 8, 51}, /* D3R */ + {12, 60, 25, 75, 32, 51}, /* D3L */ + {88, 136, 25, 75, 32, 51}, /* D3C */ + {163, 211, 25, 75, 32, 51}, /* D3R */ + {64, 73, 20, 90, 8, 71}, /* D2L */ + {150, 159, 20, 90, 8, 71}, /* D2R */ + {0, 38, 20, 90, 32, 71}, /* D2L */ + {82, 142, 20, 90, 32, 71}, /* D2C */ + {184, 223, 20, 90, 32, 71}, /* D2R */ + {41, 56, 9, 119, 8, 111}, /* D1L */ + {169, 184, 9, 119, 8, 111}, /* D1R */ + {64, 159, 9, 119, 48, 111}}, /* D1C */ + {{74, 85, 25, 75, 8, 51}, /* D3L */ + {137, 149, 25, 75, 8, 51}, /* D3R */ + {0, 75, 25, 75, 40, 51}, /* D3L Atari ST: { 0, 83, 25, 75, 48*2, 51 } */ + {74, 149, 25, 75, 40, 51}, /* D3C Atari ST: { 74, 149, 25, 75, 48*2, 51 } */ + {148, 223, 25, 75, 40, 51}, /* D3R Atari ST: { 139, 223, 25, 75, 48*2, 51 } */ + {60, 77, 20, 90, 16, 71}, /* D2L */ + {146, 163, 20, 90, 16, 71}, /* D2R */ + {0, 74, 20, 90, 56, 71}, /* D2L */ + {60, 163, 20, 90, 56, 71}, /* D2C */ + {149, 223, 20, 90, 56, 71}, /* D2R */ + {32, 63, 9, 119, 16, 111}, /* D1L */ + {160, 191, 9, 119, 16, 111}, /* D1R */ + {32, 191, 9, 119, 80, 111}}}; /* D1C */ byte g194_WallOrnCoordSetIndices[60] = { // @ G0194_auc_Graphic558_WallOrnamentCoordinateSetIndices 1, /* Wall Ornament 00 Unreadable Inscription */ @@ -531,7 +531,6 @@ ProjectileAspect g210_ProjectileAspect[k14_ProjectileAspectCount] = { // @ G0210 ProjectileAspect(31, 156, 16, 24, 0x0103) /* Explosion Poison Bolt Poison Cloud */ }; -// TODO: this is ONLY for the Amiga version, name will have to be refactored /* Identical to the palette at the end of the swoosh palette animation */ uint16 gK57_PalSwoosh[16] = {0x000, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0x000, 0xFFF, 0xAAA, 0xFFF, 0xAAA, 0x444, 0xFF0, 0xFF0}; // @ K0057_aui_Palette_Swoosh @@ -780,17 +779,17 @@ void DisplayMan::f460_initializeGraphicData() { _g638_derivedBitmaps[i] = nullptr; } - _g639_derivedBitmapByteCount[k0_DerivedBitmapViewport] = 224 * 136; - _g639_derivedBitmapByteCount[k1_DerivedBitmapThievesEyeVisibleArea] = 96 * 95; - _g639_derivedBitmapByteCount[k2_DerivedBitmapDamageToCreatureMedium] = 64 * 37; - _g639_derivedBitmapByteCount[k3_DerivedBitmapDamageToCreatureSmall] = 48 * 37; + _g639_derivedBitmapByteCount[k0_DerivedBitmapViewport] = 112 * 136; + _g639_derivedBitmapByteCount[k1_DerivedBitmapThievesEyeVisibleArea] = 48 * 95; + _g639_derivedBitmapByteCount[k2_DerivedBitmapDamageToCreatureMedium] = 32 * 37; + _g639_derivedBitmapByteCount[k3_DerivedBitmapDamageToCreatureSmall] = 24 * 37; for (int16 doorOrnamentIndex = k15_DoorOrnDestroyedMask; doorOrnamentIndex <= k16_DoorOrnThivesEyeMask; doorOrnamentIndex++) { _g103_currMapDoorOrnInfo[doorOrnamentIndex][k0_NativeBitmapIndex] = doorOrnamentIndex + (k301_DoorMaskDestroyedIndice - k15_DoorOrnDestroyedMask); _g103_currMapDoorOrnInfo[doorOrnamentIndex][k1_CoordinateSet] = 1; - _g639_derivedBitmapByteCount[doorOrnamentIndex * 2 + k68_DerivedBitmapFirstDoorOrnament_D3] = 48 * 41; - _g639_derivedBitmapByteCount[doorOrnamentIndex * 2 + k69_DerivedBitmapFirstDoorOrnament_D2] = 64 * 61; + _g639_derivedBitmapByteCount[doorOrnamentIndex * 2 + k68_DerivedBitmapFirstDoorOrnament_D3] = 24 * 41; + _g639_derivedBitmapByteCount[doorOrnamentIndex * 2 + k69_DerivedBitmapFirstDoorOrnament_D2] = 32 * 61; } _g102_currMapFloorOrnInfo[k15_FloorOrnFootprints][k0_NativeBitmapIndex] = k241_FloorOrn_15_D3L_footprints; @@ -801,8 +800,8 @@ void DisplayMan::f460_initializeGraphicData() { for (int16 objectAspectIndex = 0; objectAspectIndex < k85_ObjAspectCount; ++objectAspectIndex, ++objectAspect) { derivedBitmapIndex = k104_DerivedBitmapFirstObject + objectAspect->_firstDerivedBitmapRelativeIndex; - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k16_Scale_D3); - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(objectAspect->_width, objectAspect->_height, k20_Scale_D2); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(objectAspect->_byteWidth, objectAspect->_height, k16_Scale_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(objectAspect->_byteWidth, objectAspect->_height, k20_Scale_D2); if (getFlag(objectAspect->_graphicInfo, k0x0001_ObjectFlipOnRightMask)) { _g639_derivedBitmapByteCount[derivedBitmapIndex] = _g639_derivedBitmapByteCount[derivedBitmapIndex - 2]; @@ -825,14 +824,14 @@ void DisplayMan::f460_initializeGraphicData() { derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + projectileAspect->_firstDerivedBitmapRelativeIndex; for (int16 projectileScaleIndex = 0; projectileScaleIndex < 6; projectileScaleIndex++) { - int16 bitmapPixelCount = f459_getScaledBitmapPixelCount(projectileAspect->_width, projectileAspect->_height, g215_ProjectileScales[projectileScaleIndex]); - _g639_derivedBitmapByteCount[derivedBitmapIndex] = bitmapPixelCount; + int16 bitmapByteCount = f459_getScaledBitmapByteCount(projectileAspect->_byteWidth, projectileAspect->_height, g215_ProjectileScales[projectileScaleIndex]); + _g639_derivedBitmapByteCount[derivedBitmapIndex] = bitmapByteCount; if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k3_ProjectileAspectHasNone) { - _g639_derivedBitmapByteCount[derivedBitmapIndex + 6] = bitmapPixelCount; + _g639_derivedBitmapByteCount[derivedBitmapIndex + 6] = bitmapByteCount; if (getFlag(projectileAspect->_graphicInfo, k0x0003_ProjectileAspectTypeMask) != k2_ProjectileAspectHasRotation) { - _g639_derivedBitmapByteCount[derivedBitmapIndex + 12] = bitmapPixelCount; + _g639_derivedBitmapByteCount[derivedBitmapIndex + 12] = bitmapByteCount; } } } @@ -847,10 +846,10 @@ void DisplayMan::f460_initializeGraphicData() { ExplosionAspect *expAsp = g211_ExplosionAspects; for (uint16 expAspIndex = 0; expAspIndex < k4_ExplosionAspectCount; ++expAspIndex, expAsp++) { for (int16 scale = 4; scale < 32; scale += 2) - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(expAsp->_pixelWidth, expAsp->_height, scale); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(expAsp->_byteWidth, expAsp->_height, scale); if (expAspIndex == k3_ExplosionAspectSmoke) { - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_pixelWidth * expAsp->_height; + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = expAsp->_byteWidth * expAsp->_height; } } @@ -863,14 +862,16 @@ void DisplayMan::f460_initializeGraphicData() { creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex; int16 creatureFrontBitmapD3PixelCount; - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount + = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3); int16 creatureFrontBitmapD2PixelCount; - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount + = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2); if (getFlag(creatureGraphicInfo, k0x0008_CreatureInfoGraphicMaskSide)) { - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k16_Scale_D3); - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k20_Scale_D2); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k16_Scale_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, k20_Scale_D2); } if (getFlag(creatureGraphicInfo, k0x0010_CreatureInfoGraphicMaskBack)) { @@ -879,16 +880,16 @@ void DisplayMan::f460_initializeGraphicData() { } if (getFlag(creatureGraphicInfo, k0x0020_CreatureInfoGraphicMaskAttack)) { - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k16_Scale_D3); - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k20_Scale_D2); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k16_Scale_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, k20_Scale_D2); } int16 additionalFronGraphicCount; if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, k0x0003_CreatureInfoGraphicMaskAdditional)) { do { _g639_derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront; - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3); - _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k16_Scale_D3); + _g639_derivedBitmapByteCount[derivedBitmapIndex++] = f459_getScaledBitmapByteCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, k20_Scale_D2); } while (--additionalFronGraphicCount); } } @@ -897,9 +898,9 @@ void DisplayMan::f460_initializeGraphicData() { void DisplayMan::unpackGraphics() { uint32 unpackedBitmapsSize = 0; for (uint16 i = 0; i <= 20; ++i) - unpackedBitmapsSize += getWidth(i) * getHeight(i); + unpackedBitmapsSize += getPixelWidth(i) * getPixelHeight(i); for (uint16 i = 22; i <= 532; ++i) - unpackedBitmapsSize += getWidth(i) * getHeight(i); + unpackedBitmapsSize += getPixelWidth(i) * getPixelHeight(i); unpackedBitmapsSize += (5 + 1) * 6 * 128; // 5 x 6 characters, 128 of them, +1 for convenience padding // graphics items go from 0-20 and 22-532 inclusive, _unpackedItemPos 21 and 22 are there for indexing convenience if (_bitmaps) { @@ -910,15 +911,15 @@ void DisplayMan::unpackGraphics() { _bitmaps[0] = new byte[unpackedBitmapsSize]; f466_loadIntoBitmap(0, _bitmaps[0]); for (uint16 i = 1; i <= 20; ++i) { - _bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1); + _bitmaps[i] = _bitmaps[i - 1] + getPixelWidth(i - 1) * getPixelHeight(i - 1); f466_loadIntoBitmap(i, _bitmaps[i]); } - _bitmaps[22] = _bitmaps[20] + getWidth(20) * getHeight(20); + _bitmaps[22] = _bitmaps[20] + getPixelWidth(20) * getPixelHeight(20); for (uint16 i = 23; i <= 532; ++i) { - _bitmaps[i] = _bitmaps[i - 1] + getWidth(i - 1) * getHeight(i - 1); + _bitmaps[i] = _bitmaps[i - 1] + getPixelWidth(i - 1) * getPixelHeight(i - 1); f466_loadIntoBitmap(i, _bitmaps[i]); } - _bitmaps[k557_FontGraphicIndice] = _bitmaps[532] + getWidth(532) * getHeight(532); + _bitmaps[k557_FontGraphicIndice] = _bitmaps[532] + getPixelWidth(532) * getPixelHeight(532); loadFNT1intoBitmap(k557_FontGraphicIndice, _bitmaps[k557_FontGraphicIndice]); } @@ -955,7 +956,7 @@ void DisplayMan::f566_viewportBlitToScreen() { warning("MISSING FUNCTIONALITY: using correct colorpalette"); Box box(0, 223, 33, 33 + 135); - f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport * 2, k160_byteWidthScreen * 2, k255_ColorNoTransparency); + f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport, k160_byteWidthScreen, k255_ColorNoTransparency); } void DisplayMan::loadPalette(uint16 *palette) { @@ -1017,10 +1018,12 @@ void DisplayMan::f466_loadIntoBitmap(uint16 index, byte *destBitmap) { } } -void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth, - uint16 destWidth, Color transparent, int16 srcHeight, int16 destHight) { +void DisplayMan::f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth, + uint16 destByteWidth, Color transparent, int16 srcHeight, int16 destHight) { // Note: if you want to use srcHeight and destHight parameters, remove the defaults values and // and complete the function calls at the callsites, otherwise their value can be the default -1 + uint16 srcWidth = srcByteWidth * 2; + uint16 destWidth = destByteWidth * 2; for (uint16 y = 0; y < box._y2 + 1 - box._y1; ++y) // + 1 for inclusive boundaries for (uint16 x = 0; x < box._x2 + 1 - box._x1; ++x) { // + 1 for inclusive boundaries byte srcPixel = srcBitmap[srcWidth * (y + srcY) + srcX + x]; @@ -1035,13 +1038,13 @@ void DisplayMan::D24_fillScreenBox(Box &box, Color color) { memset(_g348_bitmapScreen + y * _screenWidth + box._x1, color, sizeof(byte) * width); } -void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int16 pixelWidth, int16 height) { +void DisplayMan::f135_fillBoxBitmap(byte* destBitmap, Box &box, Color color, int16 byteWidth, int16 height) { for (int16 y = box._y1; y < box._y2 + 1; ++y) // + 1 for inclusive boundaries - memset(destBitmap + y * pixelWidth + box._x1, color, sizeof(byte) * (box._x2 - box._x1 + 1)); // + 1 for inclusive boundaries + memset(destBitmap + y * byteWidth * 2 + box._x1, color, sizeof(byte) * (box._x2 - box._x1 + 1)); // + 1 for inclusive boundaries } void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* mask, byte* tmp, Box& box, - int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, + int16 lastUnitIndex, int16 firstUnitIndex, int16 destByteWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2) { // make sure to take care of inclusive boundaries warning("STUB FUNCTION: does nothing at all"); @@ -1049,7 +1052,8 @@ void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* -void DisplayMan::f130_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) { +void DisplayMan::f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height) { + uint16 width = byteWidth * 2; for (uint16 y = 0; y < height; ++y) { for (uint16 x = 0; x < width / 2; ++x) { byte tmp; @@ -1060,7 +1064,8 @@ void DisplayMan::f130_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 he } } -void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) { +void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 byteWidth, uint16 height) { + uint16 width = byteWidth * 2; byte *tmp = new byte[width]; for (uint16 y = 0; y < height / 2; ++y) { @@ -1072,27 +1077,27 @@ void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 width, uint16 height) { delete[] tmp; } -byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnPixelWidth, int16& returnHeight) { +byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16& returnByteWidth, int16& returnHeight) { ExplosionAspect *explAsp = &g211_ExplosionAspects[explosionAspIndex]; if (scale > 32) scale = 32; - int16 pixelWidth = M78_getScaledDimension(explAsp->_pixelWidth, scale); + int16 pixelWidth = M78_getScaledDimension(explAsp->_byteWidth, scale); int16 height = M78_getScaledDimension(explAsp->_height, scale); byte *bitmap; int16 derBitmapIndex = (explosionAspIndex * 14) + scale / 2 + k438_DerivedBitmapFirstExplosion - 2; if ((scale == 32) && (explosionAspIndex != k3_ExplosionAspectSmoke)) { - bitmap = f489_getBitmap(explosionAspIndex + k348_FirstExplosionGraphicIndice); + bitmap = f489_getNativeBitmapOrGraphic(explosionAspIndex + k348_FirstExplosionGraphicIndice); } else if (f491_isDerivedBitmapInCache(derBitmapIndex)) { bitmap = f492_getDerivedBitmap(derBitmapIndex); } else { - byte *nativeBitmap = f489_getBitmap(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice); + byte *nativeBitmap = f489_getNativeBitmapOrGraphic(MIN(explosionAspIndex, (uint16)k2_ExplosionAspectPoison) + k348_FirstExplosionGraphicIndice); bitmap = f492_getDerivedBitmap(derBitmapIndex); - f129_blitToBitmapShrinkWithPalChange(nativeBitmap, bitmap, explAsp->_pixelWidth, explAsp->_height, pixelWidth, height, + f129_blitToBitmapShrinkWithPalChange(nativeBitmap, bitmap, explAsp->_byteWidth, explAsp->_height, pixelWidth * 2, height, (explosionAspIndex == k3_ExplosionAspectSmoke) ? g212_PalChangeSmoke : g17_PalChangesNoChanges); - warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); + f493_addDerivedBitmap(derBitmapIndex); } - returnPixelWidth = pixelWidth; + returnByteWidth = pixelWidth; returnHeight = height; return bitmap; } @@ -1137,30 +1142,30 @@ byte *DisplayMan::getCurrentVgaBuffer() { return _g348_bitmapScreen; } -uint16 DisplayMan::getWidth(uint16 index) { +uint16 DisplayMan::getPixelWidth(uint16 index) { byte *data = _packedBitmaps + _packedItemPos[index]; return READ_BE_UINT16(data); } -uint16 DisplayMan::getHeight(uint16 index) { +uint16 DisplayMan::getPixelHeight(uint16 index) { uint8 *data = _packedBitmaps + _packedItemPos[index]; return READ_BE_UINT16(data + 2); } // Note: has been screened for missing code -void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 pixelWidth, uint16 height) { - memmove(destBitmap, srcBitmap, pixelWidth * height * sizeof(byte)); - f130_flipBitmapHorizontal(destBitmap, pixelWidth, height); +void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 byteWidth, uint16 height) { + memmove(destBitmap, srcBitmap, byteWidth * 2 * height * sizeof(byte)); + f130_flipBitmapHorizontal(destBitmap, byteWidth, height); } void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { - if (f._srcWidth) - f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k255_ColorNoTransparency); + if (f._srcByteWidth) + f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency); } void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) { - if (f._srcWidth) - f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k10_ColorFlesh); + if (f._srcByteWidth) + f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh); } @@ -1495,7 +1500,7 @@ void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) { if (_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1) { f100_drawWallSetBitmap(_g85_bitmapCeiling, gK12_CeilingFrame); - f99_copyBitmapAndFlipHorizontal(_g84_bitmapFloor, _g74_tmpBitmap, k112_byteWidthViewport * 2, 70); + f99_copyBitmapAndFlipHorizontal(_g84_bitmapFloor, _g74_tmpBitmap, k112_byteWidthViewport, 70); f100_drawWallSetBitmap(_g74_tmpBitmap, gK13_FloorFrame); if (flippedFloorCeiling) { @@ -1506,7 +1511,7 @@ void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) { _g702_bitmapWallSet_Wall_D0R = _g94_bitmapWall_D0R_Flipped; } } else { - f99_copyBitmapAndFlipHorizontal(_g85_bitmapCeiling, _g74_tmpBitmap, k112_byteWidthViewport * 2, 29); + f99_copyBitmapAndFlipHorizontal(_g85_bitmapCeiling, _g74_tmpBitmap, k112_byteWidthViewport, 29); f100_drawWallSetBitmap(_g74_tmpBitmap, gK12_CeilingFrame); f100_drawWallSetBitmap(_g84_bitmapFloor, gK13_FloorFrame); } @@ -1566,7 +1571,8 @@ void DisplayMan::fillScreen(Color color) { memset(getCurrentVgaBuffer(), color, sizeof(byte) * _screenWidth * _screenHeight); } -void DisplayMan::f134_fillBitmap(byte *bitmap, Color color, uint16 width, uint16 height) { +void DisplayMan::f134_fillBitmap(byte *bitmap, Color color, uint16 byteWidth, uint16 height) { + uint16 width = byteWidth * 2; memset(bitmap, color, sizeof(byte) * width * height); } @@ -1605,9 +1611,9 @@ void DisplayMan::f95_loadWallSet(WallSet set) { f466_loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2); } f99_copyBitmapAndFlipHorizontal(_g708_bitmapWallSet_DoorFrameLeft_D1C, _g710_bitmapWallSet_DoorFrameRight_D1C, - g171_Frame_DoorFrameRight_D1C._srcWidth, g171_Frame_DoorFrameRight_D1C._srcHeight); + g171_Frame_DoorFrameRight_D1C._srcByteWidth, g171_Frame_DoorFrameRight_D1C._srcHeight); f99_copyBitmapAndFlipHorizontal(_g697_bitmapWallSet_Wall_D3L2, _g696_bitmapWallSet_Wall_D3R2, - g712_FrameWall_D3R2._srcWidth, g712_FrameWall_D3R2._srcHeight); + g712_FrameWall_D3R2._srcByteWidth, g712_FrameWall_D3R2._srcHeight); } } @@ -1621,21 +1627,21 @@ void DisplayMan::f96_loadCurrentMapGraphics() { _g578_useByteBoxCoordinates = true; f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap, - g163_FrameWalls[k0_ViewSquare_D3C]._srcWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight); - f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 128, 51); - f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, g161_BoxWallBitmap_D3LCR, 11, 0, 128, 128, k255_ColorNoTransparency); + g163_FrameWalls[k0_ViewSquare_D3C]._srcByteWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight); + f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 64, 51); + f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, g161_BoxWallBitmap_D3LCR, 11, 0, 64, 64, k255_ColorNoTransparency); f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap, - g163_FrameWalls[k3_ViewSquare_D2C]._srcWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight); - f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 144, 71); - f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, g162_BoxWallBitmap_D2LCR, 8, 0, 144, 144, k255_ColorNoTransparency); + g163_FrameWalls[k3_ViewSquare_D2C]._srcByteWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight); + f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 72, 71); + f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, g162_BoxWallBitmap_D2LCR, 8, 0, 72, 72, k255_ColorNoTransparency); f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped, - g163_FrameWalls[k6_ViewSquare_D1C]._srcWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight); + g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight); f99_copyBitmapAndFlipHorizontal(_g98_bitmapWall_D0L_Native = _g701_bitmapWallSet_Wall_D0L, _g94_bitmapWall_D0R_Flipped, - g163_FrameWalls[k10_ViewSquare_D0L]._srcWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight); + g163_FrameWalls[k10_ViewSquare_D0L]._srcByteWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight); f99_copyBitmapAndFlipHorizontal(_g99_bitmapWall_D0R_Native = _g702_bitmapWallSet_Wall_D0R, _g93_bitmapWall_D0L_Flipped, - g163_FrameWalls[k10_ViewSquare_D0L]._srcWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight); + g163_FrameWalls[k10_ViewSquare_D0L]._srcByteWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight); } @@ -1734,14 +1740,14 @@ void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementC } void DisplayMan::f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) { - if (f._srcWidth) - f132_blitToBitmap(_bitmaps[nativeIndex], _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k10_ColorFlesh); + if (f._srcByteWidth) + f132_blitToBitmap(_bitmaps[nativeIndex], _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh); } void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) { - if (f._srcWidth) { - f99_copyBitmapAndFlipHorizontal(f489_getBitmap(nativeIndex), _g74_tmpBitmap, f._srcWidth, f._srcHeight); - f132_blitToBitmap(_g74_tmpBitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcWidth, k112_byteWidthViewport * 2, k10_ColorFlesh); + if (f._srcByteWidth) { + f99_copyBitmapAndFlipHorizontal(f489_getNativeBitmapOrGraphic(nativeIndex), _g74_tmpBitmap, f._srcByteWidth, f._srcHeight); + f132_blitToBitmap(_g74_tmpBitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh); } } @@ -1807,7 +1813,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall if (isInscription) { Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C]; f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, g202_BoxWallPatchBehindInscription, 94, 28, - D1CFrame._srcWidth, k112_byteWidthViewport * 2, k255_ColorNoTransparency); + D1CFrame._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency); unsigned char *string = inscriptionString; bitmapRed = _bitmaps[k120_InscriptionFontIndice]; @@ -1821,7 +1827,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7; frame._box._y1 = (frame._box._y2 = g203_InscriptionLineY[textLineIndex++]) - 7; while (characterCount--) { - f132_blitToBitmap(bitmapRed, _g296_bitmapViewport, frame._box, (*string++) * 8, 0, 288, k112_byteWidthViewport * 2, k10_ColorFlesh); + f132_blitToBitmap(bitmapRed, _g296_bitmapViewport, frame._box, (*string++) * 8, 0, 144, k112_byteWidthViewport, k10_ColorFlesh); frame._box._x1 += 8; frame._box._x2 += 8; } @@ -1899,7 +1905,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall frame._box._x2 = coordinateSetA[1]; frame._box._y1 = coordinateSetA[2]; frame._box._y2 = coordinateSetA[3]; - frame._srcWidth = coordinateSetA[4]; + frame._srcByteWidth = coordinateSetA[4]; frame._srcHeight = coordinateSetA[5]; coordinateSetA = (uint16*)&frame._box; @@ -1907,12 +1913,12 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1]; } } - f132_blitToBitmap(bitmapGreen, _g296_bitmapViewport, *(Box*)coordinateSetA, var_X, 0, coordinateSetA[4], k112_byteWidthViewport * 2, k10_ColorFlesh); + f132_blitToBitmap(bitmapGreen, _g296_bitmapViewport, *(Box*)coordinateSetA, var_X, 0, coordinateSetA[4], k112_byteWidthViewport, k10_ColorFlesh); if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { Box &box = g109_BoxChampionPortraitOnWall; f132_blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], _g296_bitmapViewport, box, (_g289_championPortraitOrdinal & 0x7) << 5, - (_g289_championPortraitOrdinal >> 3) * 29, 256, k112_byteWidthViewport * 2, k1_ColorDarkGary); + (_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary); } return isAlcove; } @@ -1920,22 +1926,22 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall } -void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap, int16 srcWidth, int16 srcHeight, int16 destWidth, int16 destHeight, byte *palChange) { - double rateW = srcWidth / destWidth; +void DisplayMan::f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap, int16 srcPixelWidth, int16 srcHeight, int16 destPixelWidth, int16 destHeight, byte *palChange) { + double rateW = srcPixelWidth / destPixelWidth; double rateH = srcHeight / destHeight; for (uint16 y = 0; y < destHeight; ++y) { - for (uint16 x = 0; x < destWidth; ++x) { + for (uint16 x = 0; x < destPixelWidth; ++x) { if (palChange) - destBitmap[y * destWidth + x] = palChange[srcBitmap[(int)(y * rateH * srcWidth) + (int)(x * rateW)]]; + destBitmap[y * destPixelWidth + x] = palChange[srcBitmap[(int)(y * rateH * srcPixelWidth) + (int)(x * rateW)]]; else - destBitmap[y * destWidth + x] = srcBitmap[(int)(y * rateH * srcWidth) + (int)(x * rateW)]; + destBitmap[y * destPixelWidth + x] = srcBitmap[(int)(y * rateH * srcPixelWidth) + (int)(x * rateW)]; } } } -byte* DisplayMan::f489_getBitmap(uint16 index) { +byte* DisplayMan::f489_getNativeBitmapOrGraphic(uint16 index) { return _bitmaps[index]; } @@ -1960,21 +1966,21 @@ void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) { bitmapMask = nullptr; } else { bitmapMask = dispMan._g74_tmpBitmap; - memmove(bitmapMask, dispMan.f489_getBitmap(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)), - fieldAspect->_height * fieldAspect->_pixelWidth * sizeof(bitmapMask[0])); + memmove(bitmapMask, dispMan.f489_getNativeBitmapOrGraphic(k69_FieldMask_D3R_GraphicIndice + getFlag(fieldAspect->_mask, kMaskFieldAspectIndex)), + fieldAspect->_height * fieldAspect->_byteWidth * 2 * sizeof(bitmapMask[0])); if (getFlag(fieldAspect->_mask, kMaskFieldAspectFlipMask)) { - dispMan.f130_flipBitmapHorizontal(bitmapMask, fieldAspect->_pixelWidth, fieldAspect->_height); + dispMan.f130_flipBitmapHorizontal(bitmapMask, fieldAspect->_byteWidth, fieldAspect->_height); } } - byte *bitmap = dispMan.f489_getBitmap(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex); + byte *bitmap = dispMan.f489_getNativeBitmapOrGraphic(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex); warning("MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap"); warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock"); } -int16 DisplayMan::f459_getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale) { - return M78_getScaledDimension(pixelWidth, scale) * M78_getScaledDimension(pixelHeight, scale); +int16 DisplayMan::f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale) { + return M77_getNormalizedByteWidth(M78_getScaledDimension(byteWidth, scale)) * M78_getScaledDimension(height, scale); } int16 DisplayMan::M78_getScaledDimension(int16 dimension, int16 scale) { @@ -2326,11 +2332,11 @@ T0115015_DrawProjectileAsObject: /* If object is in the center lane (only D0C or D1C with condition above) and is not a projectile */ drawingGrabbableObject = (!viewLane && !drawProjectileAsObject); AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front; - AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */ - byteWidth = objectAspect->_width; + AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); /* Use base graphic, no resizing */ + byteWidth = objectAspect->_byteWidth; heightRedEagle = objectAspect->_height; if (flipHorizontal) { - memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); + memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * 2 * heightRedEagle * sizeof(byte)); f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; } @@ -2340,18 +2346,18 @@ T0115015_DrawProjectileAsObject: if ((viewSquareIndex >= k6_ViewSquare_D1C) || ((viewSquareIndex >= k3_ViewSquare_D2C) && (AL_2_viewCell >= k2_ViewCellBackRight))) { derivedBitmapIndex++; AL_8_shiftSetIndex = k1_ShiftSet_D1BackD2Front; - byteWidth = M78_getScaledDimension(objectAspect->_width, k20_Scale_D2); + byteWidth = M78_getScaledDimension(objectAspect->_byteWidth, k20_Scale_D2); heightRedEagle = M78_getScaledDimension(objectAspect->_height, k20_Scale_D2); paletteChanges = g214_PalChangesFloorOrn_D2; } else { AL_8_shiftSetIndex = k2_ShiftSet_D2BackD3Front; - byteWidth = M78_getScaledDimension(objectAspect->_width, k16_Scale_D3); + byteWidth = M78_getScaledDimension(objectAspect->_byteWidth, k16_Scale_D3); heightRedEagle = M78_getScaledDimension(objectAspect->_height, k16_Scale_D3); paletteChanges = g213_PalChangesFloorOrn_D3; } if (flipHorizontal) { derivedBitmapIndex += 2; - paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; + paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1; } else if (useAlcoveObjectImage) { derivedBitmapIndex += 4; } @@ -2359,12 +2365,12 @@ T0115015_DrawProjectileAsObject: if (f491_isDerivedBitmapInCache(derivedBitmapIndex)) { AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); } else { - bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex); + bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex), - objectAspect->_width, objectAspect->_height, - byteWidth, heightRedEagle, paletteChanges); + objectAspect->_byteWidth * 2, objectAspect->_height, + byteWidth * 2, heightRedEagle, paletteChanges); if (flipHorizontal) { - f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); + f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, M77_getNormalizedByteWidth(byteWidth), heightRedEagle); } warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } @@ -2413,14 +2419,14 @@ T0115015_DrawProjectileAsObject: } } else { /* If there are several grabbable objects then enlarge the box so it includes all objects */ AL_6_boxPtrRed->_x1 = MIN(AL_6_boxPtrRed->_x1, boxByteGreen._x1); - AL_6_boxPtrRed->_x2 = MIN(AL_6_boxPtrRed->_x2, boxByteGreen._x2); + AL_6_boxPtrRed->_x2 = MAX(AL_6_boxPtrRed->_x2, boxByteGreen._x2); AL_6_boxPtrRed->_y1 = MIN(AL_6_boxPtrRed->_y1, boxByteGreen._y1); - AL_6_boxPtrRed->_y2 = MIN(AL_6_boxPtrRed->_y2, boxByteGreen._y2); + AL_6_boxPtrRed->_y2 = MAX(AL_6_boxPtrRed->_y2, boxByteGreen._y2); } AL_6_bitmapRedBanana = bitmapGreenAnt; dunMan._g292_pileTopObject[AL_2_viewCell] = thingParam; /* The object is at the top of the pile */ } - f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport * 2, k10_ColorFlesh); + f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh); if (drawProjectileAsObject) goto T0115171_BackFromT0115015_DrawProjectileAsObject; @@ -2574,17 +2580,17 @@ T0115077_DrawSecondHalfSquareCreature: AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front; transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour(); if (useCreatureSideBitmap) { - AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex); + AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); if (creatureDirectionDelta == 1) { - memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); + memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * 2 * heightRedEagle * sizeof(byte)); f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; } } else { if (useCreatureBackBitmap || !useFlippedHorizontallyCreatureFrontImage) { - AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex); + AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); if (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) { - memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle * sizeof(byte)); + memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * 2 * heightRedEagle * sizeof(byte)); f130_flipBitmapHorizontal(_g74_tmpBitmap, byteWidth, heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; } @@ -2592,10 +2598,10 @@ T0115077_DrawSecondHalfSquareCreature: if (f491_isDerivedBitmapInCache(derivedBitmapIndex)) { /* If derived graphic is already in memory */ AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); } else { - bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex); + bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); if (getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) { AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); - memmove(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * heightRedEagle * sizeof(byte)); + memmove(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * 2 * heightRedEagle * sizeof(byte)); f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); @@ -2625,9 +2631,9 @@ T0115077_DrawSecondHalfSquareCreature: if (derivedBitmapInCache = f491_isDerivedBitmapInCache(derivedBitmapIndex)) { AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); } else { - bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex); + bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); - f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, sourceByteWidth, sourceHeight, byteWidth, heightRedEagle, paletteChanges); + f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, sourceByteWidth * 2, sourceHeight, byteWidth * 2, heightRedEagle, paletteChanges); warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */ @@ -2635,15 +2641,14 @@ T0115077_DrawSecondHalfSquareCreature: (useCreatureSpecialD2FrontBitmap && getFlag(AL_0_creatureGraphicInfoRed, k0x0100_CreatureInfoGraphicMaskSpecialD2FrontIsFlipped)) || (useFlippedHorizontallyCreatureFrontImage && getFlag(AL_0_creatureGraphicInfoRed, k0x0004_CreatureInfoGraphicMaskFlipNonAttack))) { /* If the graphic should be flipped */ if (!useFlippedHorizontallyCreatureFrontImage || !derivedBitmapInCache) { - AL_4_normalizdByteWidth = byteWidth; - warning("SUPER WARNING: we might need M77_getNormalizedByteWidth"); + AL_4_normalizdByteWidth = M77_getNormalizedByteWidth(byteWidth); if (!useFlippedHorizontallyCreatureFrontImage) { - memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte)); + memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * 2 * heightRedEagle * sizeof(byte)); AL_6_bitmapRedBanana = _g74_tmpBitmap; } f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); } - creaturePaddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; + creaturePaddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1; } else { creaturePaddingPixelCount = 0; } @@ -2651,7 +2656,7 @@ T0115077_DrawSecondHalfSquareCreature: AL_4_yPos = coordinateSet[1]; AL_4_yPos += g223_ShiftSets[AL_8_shiftSetIndex][M23_getVerticalOffsetM23(creatureAspectInt)]; boxByteGreen._y2 = MIN(AL_4_yPos, (int16)135); - boxByteGreen._y1 = MIN(0, AL_4_yPos - (heightRedEagle - 1)); + boxByteGreen._y1 = MAX(0, AL_4_yPos - (heightRedEagle - 1)); AL_4_xPos = coordinateSet[0]; AL_4_xPos += g223_ShiftSets[AL_8_shiftSetIndex][M22_getHorizontalOffsetM22(creatureAspectInt)]; if (viewLane == k1_ViewLaneLeft) { @@ -2670,8 +2675,7 @@ T0115077_DrawSecondHalfSquareCreature: } else { AL_0_creaturePosX = creaturePaddingPixelCount + (byteWidth - AL_4_xPos - 1); } - warning("SUPER WARNINIG: we might nee noralized with on byteWidth"); - f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_0_creaturePosX, 0, byteWidth, k112_byteWidthViewport * 2, (Color)transparentColor); + f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_0_creaturePosX, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, (Color)transparentColor); T0115126_CreatureNotVisible: if (twoHalfSquareCreaturesFrontView) { @@ -2703,7 +2707,7 @@ continue; if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == k9_ViewSquare_D0C)) { scale = 0; /* Use native bitmap without resizing */ - byteWidth = ((ProjectileAspect*)objectAspect)->_width; + byteWidth = ((ProjectileAspect*)objectAspect)->_byteWidth; heightRedEagle = ((ProjectileAspect*)objectAspect)->_height; } else { AL_8_projectileScaleIndex = ((viewSquareIndex / 3) << 1) + (AL_2_viewCell >> 1); @@ -2711,7 +2715,7 @@ continue; if (!doNotScaleWithKineticEnergy) { scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8; } - byteWidth = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_width, scale); + byteWidth = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_byteWidth, scale); heightRedEagle = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale); } if (projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == k0_ProjectileAspectHasBackGraphicRotation)) { @@ -2754,33 +2758,32 @@ continue; AL_4_nativeBitmapIndex += projectileBitmapIndexData; paddingPixelCount = 0; if (!scale) { - AL_6_bitmapRedBanana = f489_getBitmap(AL_4_nativeBitmapIndex); + AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); } else { if (flipHorizontal) { - paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; + paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1; } derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6); if (doNotScaleWithKineticEnergy && f491_isDerivedBitmapInCache(derivedBitmapIndex) + AL_8_projectileScaleIndex) { AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); } else { - bitmapGreenAnt = f489_getBitmap(AL_4_nativeBitmapIndex); + bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); if (doNotScaleWithKineticEnergy) { AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); } else { AL_6_bitmapRedBanana = _g74_tmpBitmap; } - f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, - byteWidth, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]); + f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_byteWidth * 2, ((ProjectileAspect*)objectAspect)->_height, + byteWidth * 2, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]); if (doNotScaleWithKineticEnergy) { warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap"); } } } if (flipHorizontal || flipVertical) { - warning("might need noralized bytewidth"); - AL_4_normalizdByteWidth = byteWidth; + AL_4_normalizdByteWidth = M77_getNormalizedByteWidth(byteWidth); if (AL_6_bitmapRedBanana != _g74_tmpBitmap) { - memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * heightRedEagle * sizeof(byte)); + memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, AL_4_normalizdByteWidth * 2 * heightRedEagle * sizeof(byte)); AL_6_bitmapRedBanana = _g74_tmpBitmap; } if (flipVertical) { @@ -2806,7 +2809,7 @@ the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) then a wrong part screen. To fix this bug, "+ paddingPixelCount" must be added to the second parameter of this function call */ AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - projectilePosX - 1)); } - f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport * 2, k10_ColorFlesh); + f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, M77_getNormalizedByteWidth(byteWidth), k112_byteWidthViewport, k10_ColorFlesh); } else { /* Positive value: projectile aspect is the index of a OBJECT_ASPECT */ useAlcoveObjectImage = false; projectileCoordinates[0] = projectilePosX; @@ -2854,14 +2857,14 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; } else { if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) { objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-dunMan.f142_getProjectileAspect(Thing::_explLightningBolt))]; - AL_6_bitmapRedBanana = f489_getBitmap(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1)); + AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1)); explosionCoordinates = g228_RebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3]; - byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_width), explosionCoordinates[2]); + byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]); heightRedEagle = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]); if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) { f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, - ((ProjectileAspect*)objectAspect)->_width, ((ProjectileAspect*)objectAspect)->_height, - byteWidth, heightRedEagle, g17_PalChangesNoChanges); + ((ProjectileAspect*)objectAspect)->_byteWidth * 2, ((ProjectileAspect*)objectAspect)->_height, + byteWidth * 2, heightRedEagle, g17_PalChangesNoChanges); AL_6_bitmapRedBanana = _g74_tmpBitmap; } goto T0115200_DrawExplosion; @@ -2888,7 +2891,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; } } warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache"); - AL_6_bitmapRedBanana = f489_getBitmap(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice); + AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice); if (smoke) { f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, 48, 32, 48, 32, g212_PalChangeSmoke); AL_6_bitmapRedBanana = _g74_tmpBitmap; @@ -2920,7 +2923,7 @@ T0115200_DrawExplosion: flipVertical = _vm->_rnd->getRandomNumber(2); paddingPixelCount = 0; if (flipHorizontal = _vm->_rnd->getRandomNumber(2)) { - paddingPixelCount = (7 - ((byteWidth / 2 - 1) & 0x0007)) << 1; /* Number of unused pixels in the units on the right of the bitmap */ + paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1; /* Number of unused pixels in the units on the right of the bitmap */ } boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1)); AL_4_yPos = MAX(0, explosionCoordinates[1] - (heightRedEagle >> 1) + !(heightRedEagle & 0x0001)); @@ -2938,7 +2941,7 @@ T0115200_DrawExplosion: left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is not flipped horizontally (flipHorizontal = C0_FALSE) then the variable paddingPixelCount is not set before being used here. Its previous value (defined while drawing something else) is used and may cause an incorrect bitmap to be drawn */ - AL_4_xPos = MIN(paddingPixelCount, (int16)(byteWidth / 2 - AL_4_xPos - 1)); + AL_4_xPos = MAX(paddingPixelCount, (int16)(byteWidth - AL_4_xPos - 1)); /* BUG0_06 Graphical glitch when drawing projectiles or explosions. If a projectile or explosion bitmap is cropped because it is only partly visible on the left side of the viewport (boxByteGreen.X1 = 0) and the bitmap is flipped horizontally (flipHorizontal = C1_TRUE) @@ -2946,10 +2949,9 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP } if (boxByteGreen._x2 <= boxByteGreen._x1) continue; - warning("might need M77_NORMALIZED_BYTE_WIDTH"); - byteWidth = byteWidth; + byteWidth = M77_getNormalizedByteWidth(byteWidth); if (flipHorizontal || flipVertical) { - memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * heightRedEagle); + memmove(_g74_tmpBitmap, AL_6_bitmapRedBanana, byteWidth * 2 * heightRedEagle); AL_6_bitmapRedBanana = _g74_tmpBitmap; } if (flipHorizontal) { @@ -2958,7 +2960,7 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP if (flipVertical) { flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } - f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport * 2, k10_ColorFlesh); + f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport, k10_ColorFlesh); } } } while ((thingParam = dunMan.f159_getNextThing(thingParam)) != Thing::_endOfList); @@ -2996,5 +2998,8 @@ byte* DisplayMan::f492_getDerivedBitmap(int16 derivedBitmapIndex) { return _g638_derivedBitmaps[derivedBitmapIndex]; } +void DisplayMan::f493_addDerivedBitmap(int16 derivedBitmapIndex) { + warning("f493_addDerivedBitmap DOES NOTHING"); +} } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 282dfc2f3d..50a6d5e267 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -111,10 +111,10 @@ namespace DM { class ExplosionAspect { public: - uint16 _pixelWidth; + uint16 _byteWidth; uint16 _height; - ExplosionAspect(uint16 byteWidth, uint16 height) :_pixelWidth(byteWidth * 2), _height(height) {} + ExplosionAspect(uint16 byteWidth, uint16 height) :_byteWidth(byteWidth), _height(height) {} }; // @ EXPLOSION_ASPECT extern ExplosionAspect g211_ExplosionAspects[k4_ExplosionAspectCount]; // @ G0211_as_Graphic558_ExplosionAspects @@ -252,14 +252,14 @@ extern Box g2_BoxMovementArrows; // @ G0002_s_Graphic562_Box_MovementArrows class Frame { public: Box _box; - uint16 _srcWidth, _srcHeight; + uint16 _srcByteWidth, _srcHeight; uint16 _srcX, _srcY; Frame() {} Frame(uint16 destFromX, uint16 destToX, uint16 destFromY, uint16 destToY, uint16 srcWidth, uint16 srcHeight, uint16 srcX, uint16 srcY) : _box(destFromX, destToX, destFromY, destToY), - _srcWidth(srcWidth * 2), _srcHeight(srcHeight), _srcX(srcX), _srcY(srcY) {} + _srcByteWidth(srcWidth), _srcHeight(srcHeight), _srcX(srcX), _srcY(srcY) {} }; enum WallSet { @@ -312,13 +312,13 @@ public: uint16 _baseStartUnitIndex; /* Index of the unit (16 pixels = 8 bytes) in bitmap where blit will start from. A random value of 0 or 1 is added to this base index */ uint16 _transparentColor; /* Bit 7: Do not use mask if set, Bits 6-0: Transparent color index. 0xFF = no transparency */ byte _mask; /* Bit 7: Flip, Bits 6-0: Mask index. 0xFF = no mask */ - uint16 _pixelWidth; + uint16 _byteWidth; uint16 _height; uint16 _xPos; uint16 _bitplaneWordCount; FieldAspect(uint16 native, uint16 base, uint16 transparent, byte mask, uint16 byteWidth, uint16 height, uint16 xPos, uint16 bitplane) : _nativeBitmapRelativeIndex(native), _baseStartUnitIndex(base), _transparentColor(transparent), _mask(mask), - _pixelWidth(byteWidth * 2), _height(height), _xPos(xPos), _bitplaneWordCount(bitplane) {} + _byteWidth(byteWidth), _height(height), _xPos(xPos), _bitplaneWordCount(bitplane) {} FieldAspect() {} }; // @ FIELD_ASPECT @@ -342,11 +342,11 @@ public: CreatureAspect(uint16 uint161, uint16 uint162, byte byte0, byte byte1, byte byte2, byte byte3, byte byte4, byte byte5, byte byte6, byte byte7) : _firstNativeBitmapRelativeIndex(uint161), _firstDerivedBitmapIndex(uint162), - _byteWidthFront(byte0 * 2), + _byteWidthFront(byte0), _heightFront(byte1), - _byteWidthSide(byte2 * 2), + _byteWidthSide(byte2), _heightSide(byte3), - _byteWidthAttack(byte4 * 2), + _byteWidthAttack(byte4), _heightAttack(byte5), _coordinateSet_TransparentColor(byte6), _replacementColorSetIndices(byte7) {} @@ -355,34 +355,32 @@ public: byte getTranspColour() { return _coordinateSet_TransparentColor & 0xF; } // @ M72_TRANSPARENT_COLOR byte getReplColour10() { return (_replacementColorSetIndices >> 4) & 0xF; } // @ M74_COLOR_10_REPLACEMENT_COLOR_SET byte getReplColour9() { return _replacementColorSetIndices & 0xF; } // @ M73_COLOR_09_REPLACEMENT_COLOR_SET - - }; // @ CREATURE_ASPECT class ObjectAspect { public: byte _firstNativeBitmapRelativeIndex; byte _firstDerivedBitmapRelativeIndex; - byte _width; + byte _byteWidth; byte _height; byte _graphicInfo; /* Bits 7-5 and 3-1 Unreferenced */ byte _coordinateSet; ObjectAspect(byte firstN, byte firstD, byte byteWidth, byte h, byte grap, byte coord) : _firstNativeBitmapRelativeIndex(firstN), _firstDerivedBitmapRelativeIndex(firstD), - _width(byteWidth * 2), _height(h), _graphicInfo(grap), _coordinateSet(coord) {} + _byteWidth(byteWidth), _height(h), _graphicInfo(grap), _coordinateSet(coord) {} }; // @ OBJECT_ASPECT class ProjectileAspect { public: byte _firstNativeBitmapRelativeIndex; byte _firstDerivedBitmapRelativeIndex; - byte _width; + byte _byteWidth; byte _height; uint16 _graphicInfo; /* Bits 15-9, 7-5 and 3-2 Unreferenced */ ProjectileAspect(byte firstN, byte firstD, byte byteWidth, byte h, uint16 grap) : _firstNativeBitmapRelativeIndex(firstN), _firstDerivedBitmapRelativeIndex(firstD), - _width(byteWidth * 2), _height(h), _graphicInfo(grap) {} + _byteWidth(byteWidth), _height(h), _graphicInfo(grap) {} }; // @ PROJECTIL_ASPECT class CreatureReplColorSet { @@ -541,9 +539,9 @@ public: void f461_allocateFlippedWallBitmaps(); // @ F0461_START_AllocateFlippedWallBitmaps /// Gives the width of an IMG0 type item - uint16 getWidth(uint16 index); + uint16 getPixelWidth(uint16 index); /// Gives the height of an IMG1 type item - uint16 getHeight(uint16 index); + uint16 getPixelHeight(uint16 index); void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); @@ -553,34 +551,35 @@ public: does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/ /* Expects inclusive boundaries in box */ - void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcWidth, - uint16 destWidth, Color transparent = k255_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit + void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth, + uint16 destByteWidth, Color transparent = k255_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit /* Expects inclusive boundaries in box */ void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, - int16 firstUnitIndex, int16 destPixelWidth, Color transparent, + int16 firstUnitIndex, int16 destByteWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap + // this function takes pixel widths void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap, - int16 srcWidth, int16 srcHight, int16 destWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges - void f130_flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0130_VIDEO_FlipHorizontal - void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); - byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap + int16 srcPixelWidth, int16 srcHight, int16 destPixelWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges + void f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height); // @ F0130_VIDEO_FlipHorizontal + void flipBitmapVertical(byte *bitmap, uint16 byteWidth, uint16 height); + byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnByteWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap - void f134_fillBitmap(byte *bitmap, Color color, uint16 width, uint16 height); // @ F0134_VIDEO_FillBitmap + void f134_fillBitmap(byte *bitmap, Color color, uint16 byteWidth, uint16 height); // @ F0134_VIDEO_FillBitmap void fillScreen(Color color); /* Expects inclusive boundaries in box */ void D24_fillScreenBox(Box &box, Color color); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox /* Expects inclusive boundaries in box */ - void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 pixelWidth, int16 height); // @ F0135_VIDEO_FillBox + void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 byteWidth, int16 height); // @ F0135_VIDEO_FillBox void f128_drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport - byte* f489_getBitmap(uint16 index); // @ F0489_MEMORY_GetNativeBitmapOrGraphic + byte* f489_getNativeBitmapOrGraphic(uint16 index); // @ F0489_MEMORY_GetNativeBitmapOrGraphic Common::MemoryReadStream getCompressedData(uint16 index); uint32 getCompressedDataSize(uint16 index); void f113_drawField(FieldAspect *fieldAspect, Box &box); // @ F0113_DUNGEONVIEW_DrawField - int16 f459_getScaledBitmapPixelCount(int16 pixelWidth, int16 pixelHeight, int16 scale); // @ F0459_START_GetScaledBitmapByteCount + int16 f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale); // @ F0459_START_GetScaledBitmapByteCount int16 M78_getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION void f115_cthulhu(Thing thingParam, direction directionParam, int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, @@ -611,6 +610,7 @@ public: bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @ F0491_CACHE_IsDerivedBitmapInCache byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap + void f493_addDerivedBitmap(int16 derivedBitmapIndex); // @ F0493_CACHE_AddDerivedBitmap diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 77242c1e58..1583c6f994 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -96,7 +96,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) { champion = &cm._gK71_champions[championIndex]; dm.f466_loadIntoBitmap(k17_InventoryGraphicIndice, dm._g296_bitmapViewport); if (cm._g299_candidateChampionOrdinal) { - dm.f135_fillBoxBitmap(dm._g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport); + dm.f135_fillBoxBitmap(dm._g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport); } _vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "HEALTH"); _vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "STAMINA"); @@ -128,7 +128,7 @@ void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) { box._y2 = 28; box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7; box._x2 = box._x1 + 31; - dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, dispMan._g348_bitmapScreen, box, 0, 0, 32, k160_byteWidthScreen * 2, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, dispMan._g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen, k255_ColorNoTransparency); } void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) { @@ -161,11 +161,11 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() { Champion &champ = _vm->_championMan->_gK71_champions[_g432_inventoryChampionOrdinal]; f334_closeChest(); DisplayMan &dispMan = *_vm->_displayMan; - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 144, k160_byteWidthScreen * 2, k8_ColorRed); - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k30_FoodLabelIndice), dispMan._g348_bitmapScreen, g35_BoxFood, 0, 0, 48, k160_byteWidthScreen * 2, k12_ColorDarkestGray); - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k31_WaterLabelIndice), dispMan._g348_bitmapScreen, g36_BoxWater, 0, 0, 48, k160_byteWidthScreen * 2, k12_ColorDarkestGray); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 72, k160_byteWidthScreen, k8_ColorRed); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k30_FoodLabelIndice), dispMan._g348_bitmapScreen, g35_BoxFood, 0, 0, 24, k160_byteWidthScreen, k12_ColorDarkestGray); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k31_WaterLabelIndice), dispMan._g348_bitmapScreen, g36_BoxWater, 0, 0, 24, k160_byteWidthScreen, k12_ColorDarkestGray); if (champ._poisonEventCount) { - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k32_PoisionedLabelIndice), dispMan._g348_bitmapScreen, g37_BoxPoisoned, 0, 0, 96, k160_byteWidthScreen * 2, k12_ColorDarkestGray); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k32_PoisionedLabelIndice), dispMan._g348_bitmapScreen, g37_BoxPoisoned, 0, 0, 48, k160_byteWidthScreen, k12_ColorDarkestGray); } f344_drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown); f344_drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue); @@ -173,7 +173,8 @@ void InventoryMan::f345_drawPanelFoodWaterPoisoned() { void InventoryMan::f346_drawPanelResurrectReincarnate() { _g424_panelContent = k5_PanelContentResurrectReincarnate; - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(k40_PanelResurectReincaranteIndice), _vm->_displayMan->_g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k6_ColorDarkGreen); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k40_PanelResurectReincaranteIndice), + _vm->_displayMan->_g296_bitmapViewport, g32_BoxPanel, 0, 0, 72, k112_byteWidthViewport, k6_ColorDarkGreen); } void InventoryMan::f347_drawPanel() { @@ -256,7 +257,7 @@ void InventoryMan::f341_drawPanelScroll(Scroll* scroll) { charRed++; } *charRed = '\0'; - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k23_PanelOpenScrollIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k8_ColorRed); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k23_PanelOpenScrollIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 72, k112_byteWidthViewport, k8_ColorRed); int16 lineCount = 1; charRed++; char *charGreen = charRed; // first char of the second line @@ -308,7 +309,7 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo if (!isPressingEye) { objMan.f38_drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen); } - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k25_PanelOpenChestIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 144, k160_byteWidthScreen * 2, k8_ColorRed); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k25_PanelOpenChestIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 72, k160_byteWidthScreen, k8_ColorRed); int16 chestSlotIndex = 0; Thing thing = chest->getSlot(); @@ -334,7 +335,7 @@ void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int box._x2 = (box._x1 = xPos) + 15; box._y2 = (box._y1 = yPos) + 15; _vm->_objectMan->f36_extractIconFromBitmap(iconIndex, iconBitmap); - _vm->_displayMan->f132_blitToBitmap(iconBitmap, _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport * 2, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(iconBitmap, _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 8, k112_byteWidthViewport, k255_ColorNoTransparency); } void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) { @@ -408,7 +409,8 @@ Box g33_BoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOr void InventoryMan::f339_drawPanelArrowOrEye(bool pressingEye) { DisplayMan &dispMan = *_vm->_displayMan; - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice), dispMan._g296_bitmapViewport, g33_BoxArrowOrEye, 0, 0, 16, k112_byteWidthViewport * 2, k8_ColorRed); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice), + dispMan._g296_bitmapViewport, g33_BoxArrowOrEye, 0, 0, 8, k112_byteWidthViewport, k8_ColorRed); } @@ -440,8 +442,10 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) { f333_openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye); } else { IconIndice iconIndex = objMan.f33_getIconIndex(thingToDraw); - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k8_ColorRed); - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k29_ObjectDescCircleIndice), dispMan._g296_bitmapViewport, g34_BoxObjectDescCircle, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), dispMan._g296_bitmapViewport, + g32_BoxPanel, 0, 0, 72, k112_byteWidthViewport, k8_ColorRed); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k29_ObjectDescCircleIndice), dispMan._g296_bitmapViewport, + g34_BoxObjectDescCircle, 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray); char *descString = nullptr; char str[40]; diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 63ca90c8fd..376b629d28 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -60,11 +60,11 @@ MenuMan::~MenuMan() { void MenuMan::f395_drawMovementArrows() { DisplayMan &disp = *_vm->_displayMan; - byte *arrowsBitmap = disp.f489_getBitmap(k13_MovementArrowsIndice); + byte *arrowsBitmap = disp.f489_getNativeBitmapOrGraphic(k13_MovementArrowsIndice); Box &dest = g2_BoxMovementArrows; - uint16 w = disp.getWidth(k13_MovementArrowsIndice); + uint16 byteWidth = disp.getPixelWidth(k13_MovementArrowsIndice) / 2; - disp.f132_blitToBitmap(arrowsBitmap, disp._g348_bitmapScreen, dest, 0, 0, w, k160_byteWidthScreen * 2, k255_ColorNoTransparency); + disp.f132_blitToBitmap(arrowsBitmap, disp._g348_bitmapScreen, dest, 0, 0, byteWidth, k160_byteWidthScreen, k255_ColorNoTransparency); } void MenuMan::f388_clearActingChampion() { ChampionMan &cm = *_vm->_championMan; @@ -113,7 +113,7 @@ T0386006: box2._x2 = box._x2 - 2; box2._y1 = 95; box2._y2 = 110; - dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 16, k160_byteWidthScreen * 2, k255_ColorNoTransparency); + dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 8, k160_byteWidthScreen, k255_ColorNoTransparency); if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } @@ -208,11 +208,13 @@ void MenuMan::f387_drawActionArea() { box = g500_BoxActionArea2ActionMenu; if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone) box = g501_BoxActionArea1ActionMenu; - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k10_MenuActionAreaIndice), dispMan._g348_bitmapScreen, box, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency); - textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 235, 83, k0_ColorBlack, k4_ColorCyan, champMan._gK71_champions[_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name, + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k10_MenuActionAreaIndice), dispMan._g348_bitmapScreen, + box, 0, 0, 48, k160_byteWidthScreen, k255_ColorNoTransparency); + textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen, + 235, 83, k0_ColorBlack, k4_ColorCyan, champMan._gK71_champions[_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name, k7_ChampionNameMaximumLength, k200_heightScreen); for (uint16 actionListIndex = 0; actionListIndex < 3; actionListIndex++) { - textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen * 2, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack, + textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen, 241, 93 + actionListIndex * 12, k4_ColorCyan, k0_ColorBlack, f384_getActionName(_g713_actionList._actionIndices[actionListIndex]), k12_ActionNameMaximumLength, k200_heightScreen); } @@ -315,23 +317,25 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) { Champion &champ = _vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex]; if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) { dispMan._g578_useByteBoxCoordinates = false; - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 12, 96, 96, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine, + gK74_BoxSpellAreaLine, 0, 12, 48, 48, k255_ColorNoTransparency); int16 x = 1; byte c = 96 + (6 * champ._symbolStep); char spellSymbolString[2] = {'\0', '\0'}; for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) { spellSymbolString[0] = c++; - _vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12); + _vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 14, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12); } } else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) { dispMan._g578_useByteBoxCoordinates = false; - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine, gK74_BoxSpellAreaLine, 0, 24, 96, 96, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine, + gK74_BoxSpellAreaLine, 0, 24, 48, 48, k255_ColorNoTransparency); char spellSymbolString[2] = {'\0', '\0'}; int16 x = 8; for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) { if ((spellSymbolString[0] = champ._symbols[symbolIndex]) == '\0') break; - _vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 96, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12); + _vm->_textMan->f40_printTextToBitmap(_gK72_bitmapSpellAreaLine, 48, x += 9, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12); } } } @@ -345,7 +349,8 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) { return; if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) { warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k9_MenuSpellAreaBackground), dispMan._g348_bitmapScreen, g0_BoxSpellArea, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), dispMan._g348_bitmapScreen, g0_BoxSpellArea, 0, 0, + 48, k160_byteWidthScreen, k255_ColorNoTransparency); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } if (champIndex == kM1_ChampionNone) { @@ -361,9 +366,9 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) { f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols); warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); f393_drawSpellAreaControls((ChampionIndex)champIndex); - dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK75_BoxSpellAreaLine2, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK75_BoxSpellAreaLine2, 0, 0, 48, k160_byteWidthScreen, k255_ColorNoTransparency); f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols); - dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 96, k160_byteWidthScreen * 2, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 48, k160_byteWidthScreen, k255_ColorNoTransparency); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } } diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 1d8b7800bb..ff7ff4dd9d 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -192,11 +192,11 @@ void ObjectMan::f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { } --i; - byte *srcBitmap = _vm->_displayMan->f489_getBitmap(k42_ObjectIcons_000_TO_031 + i); + byte *srcBitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k42_ObjectIcons_000_TO_031 + i); iconIndex -= g26_IconGraphicFirstIndex[i]; _vm->_displayMan->_g578_useByteBoxCoordinates = true; Box box(0, 0, 15, 15); - _vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 256, 16, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, k255_ColorNoTransparency); } void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { @@ -219,15 +219,15 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { } } iconGraphicIndex--; - byte *iconsBitmap = _vm->_displayMan->f489_getBitmap(iconGraphicIndex + k42_ObjectIcons_000_TO_031); + byte *iconsBitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(iconGraphicIndex + k42_ObjectIcons_000_TO_031); iconIndex -= g26_IconGraphicFirstIndex[iconGraphicIndex]; _vm->_displayMan->_g578_useByteBoxCoordinates = false; if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) { - _vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g296_bitmapViewport, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 256, k112_byteWidthViewport * 2, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g296_bitmapViewport, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k112_byteWidthViewport, k255_ColorNoTransparency); } else { - _vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g348_bitmapScreen, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 256, k160_byteWidthScreen * 2, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g348_bitmapScreen, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k160_byteWidthScreen, k255_ColorNoTransparency); } } @@ -245,7 +245,7 @@ void ObjectMan::f34_drawLeaderObjectName(Thing thing) { } else { objName = _g352_objectNames[iconIndex]; } - _vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen * 2, 233, 37, + _vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, 233, 37, k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength, k200_heightScreen); } diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index b29584e3bd..5426dd0f61 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -35,15 +35,17 @@ TextMan::TextMan(DMEngine* vm) : _vm(vm) {} #define k5_LetterWidth 5 #define k6_LetterHeight 6 -void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, +void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text, uint16 destHeight) { destX -= 1; // fixes missalignment, to be checked destY -= 4; // fixes missalignment, to be checked + uint16 destPixelWidth = destByteWidth * 2; + uint16 textLength = strlen(text); uint16 nextX = destX; uint16 nextY = destY; - byte *srcBitmap = _vm->_displayMan->f489_getBitmap(k557_FontGraphicIndice); + byte *srcBitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k557_FontGraphicIndice); byte *tmp = _vm->_displayMan->_g74_tmpBitmap; for (uint16 i = 0; i < (k5_LetterWidth + 1) * k6_LetterHeight * 128; ++i) { @@ -61,26 +63,26 @@ void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uin uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1); - _vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128, destPixelWidth, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128 / 2, destByteWidth, k255_ColorNoTransparency); nextX += k5_LetterWidth + 1; } } void TextMan::f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text) { - f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight); + f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth / 2, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight); } void TextMan::f52_printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) { - f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport * 2, posX, posY, textColor, bgColor, text, k200_heightScreen); + f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, posX, posY, textColor, bgColor, text, k200_heightScreen); } -void TextMan::f41_printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, +void TextMan::f41_printWithTrailingSpaces(byte* destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor, Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) { Common::String str = text; for (int16 i = str.size(); i < requiredTextLength; ++i) str += ' '; - f40_printTextToBitmap(destBitmap, destPixelWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight); + f40_printTextToBitmap(destBitmap, destByteWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight); } } diff --git a/engines/dm/text.h b/engines/dm/text.h index adfc42635b..31344e21d9 100644 --- a/engines/dm/text.h +++ b/engines/dm/text.h @@ -37,11 +37,11 @@ class TextMan { DMEngine *_vm; public: explicit TextMan(DMEngine *vm); - void f40_printTextToBitmap(byte *destBitmap, uint16 destPixelWidth, uint16 destX, uint16 destY, + void f40_printTextToBitmap(byte *destBitmap, uint16 destByteWidth, uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, uint16 destHeight); // @ F0040_TEXT_Print void f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text); // @ F0053_TEXT_PrintToLogicalScreen void f52_printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport - void f41_printWithTrailingSpaces(byte *destBitmap, int16 destPixelWidth, int16 destX, int16 destY, Color textColor, Color bgColor, + void f41_printWithTrailingSpaces(byte *destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor, Color bgColor, const char *text, int16 strLenght, int16 destHeight); // @ F0041_TEXT_PrintWithTrailingSpaces }; -- cgit v1.2.3 From 01ed61e06642b506ba2c471002a410bbbb659167 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 4 Jul 2016 01:49:58 +0200 Subject: DM: Fix some comments --- engines/dm/TODOs/todo.txt | 5 ++++- engines/dm/dm.h | 6 +++--- engines/dm/gfx.h | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 72d6057d35..5ef225f869 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -25,4 +25,7 @@ Todo: Refactoring Add constructor to CreatureInfo - \ No newline at end of file + +Forgot to add number to name: + gBoxChampionPortrait, gBoxEye, gBoxMouth, gSlotMasks + \ No newline at end of file diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 6ceedf9e33..0fc2bd3743 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -178,7 +178,7 @@ public: bool _g298_newGame; // @ G0298_B_NewGame bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested - bool _g321_stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput + bool _g321_stopWaitingForPlayerInput; // @ G0321_B_StopWaitingForPlayerInput bool _g301_gameTimeTicking; // @ G0301_B_GameTimeTicking bool _g524_restartGameAllowed; // @ G0524_B_RestartGameAllowed uint32 _g525_gameId; // @ G0525_l_GameID, probably useless here @@ -189,8 +189,8 @@ public: bool _g340_highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested // TODO: refactor direction into a class - int8 _dirIntoStepCountEast[4]; - int8 _dirIntoStepCountNorth[4]; + int8 _dirIntoStepCountEast[4]; // @ G0233_ai_Graphic559_DirectionToStepEastCount + int8 _dirIntoStepCountNorth[4]; // @ G0234_ai_Graphic559_DirectionToStepNorthCount }; class Console : public GUI::Debugger { diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 50a6d5e267..785899b681 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -544,7 +544,7 @@ public: uint16 getPixelHeight(uint16 index); - void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); + void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); // @ F0099_DUNGEONVIEW_CopyBitmapAndFlipHorizontal /* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which -- cgit v1.2.3 From 94c878143e75e872ba8c82b31a5564c9b4e6437c Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 4 Jul 2016 14:22:17 +0200 Subject: DM: Add F0108_DUNGEONVIEW_DrawFloorOrnament --- engines/dm/dm.cpp | 27 +++++++++-------- engines/dm/dm.h | 7 +++-- engines/dm/gfx.cpp | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++--- engines/dm/gfx.h | 11 +++++++ 4 files changed, 112 insertions(+), 19 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index ae7852d649..7de740d3a9 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -72,12 +72,16 @@ uint16 getFlag(uint16 val, uint16 mask) { return val & mask; } -void setFlag(uint16 &val, uint16 mask) { - val |= mask; +uint16 setFlag(uint16 &val, uint16 mask) { + return val |= mask; } -void clearFlag(uint16 &val, uint16 mask) { - val &= ~mask; +uint16 clearFlag(uint16 &val, uint16 mask) { + return val &= ~mask; +} + +uint16 toggleFlag(uint16& val, uint16 mask) { + return val ^= mask; } DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { @@ -146,7 +150,7 @@ void DMEngine::f463_initializeGame() { _displayMan->f460_initializeGraphicData(); // DUMMY CODE: next line _displayMan->loadPalette(g19_PalCredits); - + _eventMan->initMouse(); while (_loadsaveMan->f435_loadgame() != k1_LoadgameSuccess) { @@ -166,14 +170,13 @@ void DMEngine::f463_initializeGame() { warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); } - void DMEngine::f448_initMemoryManager() - { - warning("STUB FUNCTION"); - for (uint16 i = 0; i < 16; ++i) - _displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i]; - } +void DMEngine::f448_initMemoryManager() { + warning("STUB FUNCTION"); + for (uint16 i = 0; i < 16; ++i) + _displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i]; +} - void DMEngine::f462_startGame() { +void DMEngine::f462_startGame() { _g331_pressingEye = false; _g332_stopPressingEye = false; _g333_pressingMouth = false; diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 0fc2bd3743..207416c18f 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -65,9 +65,10 @@ uint16 returnNextVal(uint16 val); // @ M17_NEXT bool isOrientedWestEast(direction dir); // @ M16_IS_ORIENTED_WEST_EAST -uint16 getFlag(uint16 val, uint16 mask); -void setFlag(uint16 &val, uint16 mask); -void clearFlag(uint16 &val, uint16 mask); +uint16 getFlag(uint16 val, uint16 mask); // @ M07_GET +uint16 setFlag(uint16 &val, uint16 mask); // @ M08_SET +uint16 clearFlag(uint16 &val, uint16 mask); // @ M09_CLEAR +uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE enum ThingType { diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 4aa9ea2b2a..45a636830a 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1158,6 +1158,82 @@ void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitm f130_flipBitmapHorizontal(destBitmap, byteWidth, height); } +void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex) { +#define AP0118_ui_FloorOrnamentIndex floorOrnOrdinal + int16 nativeBitmapIndex; + bool drawFootprints; + byte* bitmap; + uint16* coordSets; + + + static byte g191_floorOrnNativeBitmapndexInc[9] = { // @ G0191_auc_Graphic558_FloorOrnamentNativeBitmapIndexIncrements + 0, /* D3L */ + 1, /* D3C */ + 0, /* D3R */ + 2, /* D2L */ + 3, /* D2C */ + 2, /* D2R */ + 4, /* D1L */ + 5, /* D1C */ + 4}; /* D1R */ + + static uint16 g206_floorOrnCoordSets[3][9][6] = { // @ G0206_aaauc_Graphic558_FloorOrnamentCoordinateSets + /* { X1, X2, Y1, Y2, ByteWidth, Height } */ + {{32, 79, 66, 71, 24, 6}, /* D3L */ + {96, 127, 66, 71, 16, 6}, /* D3C */ + {144, 191, 66, 71, 24, 6}, /* D3R */ + {0, 63, 77, 87, 32, 11}, /* D2L */ + {80, 143, 77, 87, 32, 11}, /* D2C */ + {160, 223, 77, 87, 32, 11}, /* D2R */ + {0, 31, 92, 116, 16, 25}, /* D1L */ + {80, 143, 92, 116, 32, 25}, /* D1C */ + {192, 223, 92, 116, 16, 25}}, /* D1R */ + {{0, 95, 66, 74, 48, 9}, /* D3L */ + {64, 159, 66, 74, 48, 9}, /* D3C */ + {128, 223, 66, 74, 48, 9}, /* D3R */ + {0, 79, 75, 89, 40, 15}, /* D2L */ + {56, 167, 75, 89, 56, 15}, /* D2C */ + {144, 223, 75, 89, 40, 15}, /* D2R */ + {0, 63, 90, 118, 32, 29}, /* D1L */ + {32, 191, 90, 118, 80, 29}, /* D1C */ + {160, 223, 90, 118, 32, 29}}, /* D1R */ + {{42, 57, 68, 72, 8, 5}, /* D3L */ + {104, 119, 68, 72, 8, 5}, /* D3C */ + {166, 181, 68, 72, 8, 5}, /* D3R */ + {9, 40, 80, 85, 16, 6}, /* D2L */ + {96, 127, 80, 85, 16, 6}, /* D2C */ + {183, 214, 80, 85, 16, 6}, /* D2R */ + {0, 15, 97, 108, 8, 12}, /* D1L */ + {96, 127, 97, 108, 16, 12}, /* D1C */ + {208, 223, 97, 108, 8, 12}}}; /* D1R */ + + if (floorOrnOrdinal) { + if (drawFootprints = getFlag(floorOrnOrdinal, k0x8000_FootprintsAspect)) { + if (!clearFlag(floorOrnOrdinal, k0x8000_FootprintsAspect)) + goto T0108005; + } + floorOrnOrdinal--; + nativeBitmapIndex = _vm->_displayMan->_g102_currMapFloorOrnInfo[AP0118_ui_FloorOrnamentIndex][k0_NativeBitmapIndex] + + g191_floorOrnNativeBitmapndexInc[viewFloorIndex]; + coordSets = g206_floorOrnCoordSets[_vm->_displayMan->_g102_currMapFloorOrnInfo[AP0118_ui_FloorOrnamentIndex][k1_CoordinateSet]][viewFloorIndex]; + if ((viewFloorIndex == k8_viewFloor_D1R) || (viewFloorIndex == k5_viewFloor_D2R) + || (viewFloorIndex == k2_viewFloor_D3R) + || ((AP0118_ui_FloorOrnamentIndex == k15_FloorOrnFootprints) && _vm->_displayMan->_g76_useFlippedWallAndFootprintsBitmap && + ((viewFloorIndex == k7_viewFloor_D1C) || (viewFloorIndex == k4_viewFloor_D2C) || (viewFloorIndex == k1_viewFloor_D3C)))) { + _vm->_displayMan->f99_copyBitmapAndFlipHorizontal(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), + bitmap = _vm->_displayMan->_g74_tmpBitmap, coordSets[4], coordSets[5]); + } else { + bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + } + _vm->_displayMan->f132_blitToBitmap(bitmap, _vm->_displayMan->_g296_bitmapViewport, + *(Box*)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport); +T0108005: + if (drawFootprints) { + f108_drawFloorOrnament(_vm->M0_indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex); + } + } +} + void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { if (f._srcByteWidth) f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency); @@ -1195,7 +1271,7 @@ void DisplayMan::f116_drawSquareD3L(direction dir, int16 posX, int16 posY) { order = k0x0321_CellOrder_BackLeft_BackRight_FrontRight; goto T0116016_blueToad; case k17_ElementTypeDoorFront: - warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L); f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); f100_drawWallSetBitmap(_g705_bitmapWallSet_DoorFrameLeft_D3L, g164_Frame_DoorFrameLeft_D3L); warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor"); @@ -1210,7 +1286,8 @@ void DisplayMan::f116_drawSquareD3L(direction dir, int16 posX, int16 posY) { T0116015_redEagle: order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight; T0116016_blueToad: - warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); +/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L); T0116017_orangeElk: f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order); } @@ -1247,7 +1324,7 @@ void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) { order = k0x0412_CellOrder_BackRight_BackLeft_FrontLeft; goto T0117017; case k17_ElementTypeDoorFront: - warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R); f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44); warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally"); @@ -1266,7 +1343,8 @@ void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) { T0117016: order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft; T0117017: - warning("MISSING CODE: F0108_DUNGEONVIEW_DrawFloorOrnament"); + /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R); T0117018: f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, order); } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 785899b681..5b75676c75 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -36,6 +36,16 @@ namespace DM { +#define k0_viewFloor_D3L 0 // @ C0_VIEW_FLOOR_D3L +#define k1_viewFloor_D3C 1 // @ C1_VIEW_FLOOR_D3C +#define k2_viewFloor_D3R 2 // @ C2_VIEW_FLOOR_D3R +#define k3_viewFloor_D2L 3 // @ C3_VIEW_FLOOR_D2L +#define k4_viewFloor_D2C 4 // @ C4_VIEW_FLOOR_D2C +#define k5_viewFloor_D2R 5 // @ C5_VIEW_FLOOR_D2R +#define k6_viewFloor_D1L 6 // @ C6_VIEW_FLOOR_D1L +#define k7_viewFloor_D1C 7 // @ C7_VIEW_FLOOR_D1C +#define k8_viewFloor_D1R 8 // @ C8_VIEW_FLOOR_D1R + #define k2_FloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT #define k13_WallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT #define k18_StairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT @@ -545,6 +555,7 @@ public: void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); // @ F0099_DUNGEONVIEW_CopyBitmapAndFlipHorizontal + void f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex); // @ F0108_DUNGEONVIEW_DrawFloorOrnament /* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which -- cgit v1.2.3 From 7fef7b83127f532781fec64eea3229d56c080902 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 4 Jul 2016 17:14:32 +0200 Subject: DM: Add paritial drawing of doors --- engines/dm/dm.cpp | 4 + engines/dm/dm.h | 1 + engines/dm/dungeonman.cpp | 13 ++- engines/dm/dungeonman.h | 11 +- engines/dm/gfx.cpp | 264 +++++++++++++++++++++++++++++++++++++++++++--- engines/dm/gfx.h | 48 ++++++++- 6 files changed, 324 insertions(+), 17 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 7de740d3a9..7fa1eea7b9 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -84,6 +84,10 @@ uint16 toggleFlag(uint16& val, uint16 mask) { return val ^= mask; } +uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height) { + return pixelWidth / 2 * height; +} + DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { // Do not load data files // Do not initialize graphics here diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 207416c18f..8133fd231f 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -69,6 +69,7 @@ uint16 getFlag(uint16 val, uint16 mask); // @ M07_GET uint16 setFlag(uint16 &val, uint16 mask); // @ M08_SET uint16 clearFlag(uint16 &val, uint16 mask); // @ M09_CLEAR uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE +uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height); // @ M75_BITMAP_BYTE_COUNT enum ThingType { diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 2a037a70d0..0cecd049e7 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -384,7 +384,7 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL _g306_partyMapX = 0; _g307_partyMapY = 0; _g309_partyMapIndex = 0; - _g272_currMapIndex = 0; + _g272_currMapIndex = kM1_mapIndexNone; _g273_currMapWidth = 0; _g274_currMapHeight = 0; @@ -729,11 +729,22 @@ void DungeonMan::f434_loadDungeonFile() { } void DungeonMan::f173_setCurrentMap(uint16 mapIndex) { + static DoorInfo g254_doorInfo[4] = { // @ G0254_as_Graphic559_DoorInfo + /* { Attributes, Defense } */ + DoorInfo(3, 110), /* Door type 0 Portcullis */ + DoorInfo(0, 42), /* Door type 1 Wooden door */ + DoorInfo(0, 230), /* Door type 2 Iron door */ + DoorInfo(5, 255)}; /* Door type 3 Ra door */ + + if (_g272_currMapIndex == mapIndex) + return; _g272_currMapIndex = mapIndex; _g271_currMapData = _g279_dungeonMapData[mapIndex]; _g269_currMap = _g277_dungeonMaps + mapIndex; _g273_currMapWidth = _g277_dungeonMaps[mapIndex]._width + 1; _g274_currMapHeight = _g277_dungeonMaps[mapIndex]._height + 1; + _g275_currMapDoorInfo[0] = g254_doorInfo[_g269_currMap->_doorSet0]; + _g275_currMapDoorInfo[1] = g254_doorInfo[_g269_currMap->_doorSet1]; _g270_currMapColCumulativeSquareFirstThingCount = &_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]]; } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 331c3c9e17..d2a82ac8f2 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -594,6 +594,14 @@ struct Map { }; // @ MAP +class DoorInfo { +public: + byte _attributes; + byte _defense; + DoorInfo(byte b1, byte b2): _attributes(b1), _defense(b2){} + DoorInfo() {} +}; // @ DOOR_INFO + class DungeonMan { DMEngine *_vm; @@ -659,7 +667,7 @@ public: int16 _g306_partyMapX; // @ G0306_i_PartyMapX int16 _g307_partyMapY; // @ G0307_i_PartyMapY uint8 _g309_partyMapIndex; // @ G0309_i_PartyMapIndex - uint8 _g272_currMapIndex; // @ G0272_i_CurrentMapIndex + int16 _g272_currMapIndex; // @ G0272_i_CurrentMapIndex byte **_g271_currMapData; // @ G0271_ppuc_CurrentMapData Map *_g269_currMap; // @ G0269_ps_CurrentMap uint16 _g273_currMapWidth; // @ G0273_i_CurrentMapWidth @@ -678,6 +686,7 @@ public: bool _g288_isFacingFountain; // @ G0288_B_FacingFountain ElementType _g285_squareAheadElement; // @ G0285_i_SquareAheadElement Thing _g292_pileTopObject[5]; // @ G0292_aT_PileTopObject + DoorInfo _g275_currMapDoorInfo[2]; // @ G0275_as_CurrentMapDoorInfo }; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 45a636830a..2a9a90dc7a 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -35,10 +35,136 @@ #include "dungeonman.h" #include "group.h" #include "timeline.h" +#include "champion.h" namespace DM { +DoorFrames g179_doorFrame_D3L = { // @ G0179_s_Graphic558_Frames_Door_D3L + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(24, 71, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ + Frame(24, 71, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ + Frame(24, 71, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ + Frame(24, 71, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ + Frame(24, 29, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ + Frame(24, 35, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ + Frame(24, 41, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ + Frame(66, 71, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ + Frame(60, 71, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ + Frame(54, 71, 28, 67, 24, 41, 24, 0)}; /* Right Horizontal Closed three fourth */ +DoorFrames g180_doorFrame_D3C = { // @ G0180_s_Graphic558_Frames_Door_D3C + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(88, 135, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ + Frame(88, 135, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ + Frame(88, 135, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ + Frame(88, 135, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ + Frame(88, 93, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ + Frame(88, 99, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ + Frame(88, 105, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ + Frame(130, 135, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ + Frame(124, 135, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ + Frame(118, 135, 28, 67, 24, 41, 24, 0)}; /* Right Horizontal Closed three fourth */ +DoorFrames g181_doorFrame_D3R = { // @ G0181_s_Graphic558_Frames_Door_D3R + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(150, 197, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ + Frame(150, 197, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ + Frame(150, 197, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ + Frame(150, 197, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ + Frame(150, 153, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ + Frame(150, 161, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ + Frame(150, 167, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ + Frame(192, 197, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ + Frame(186, 197, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ + Frame(180, 197, 28, 67, 24, 41, 24, 0)}; /* Right Horizontal Closed three fourth */ +DoorFrames g182_doorFrame_D2L = { // @ G0182_s_Graphic558_Frames_Door_D2L + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(0, 63, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ + Frame(0, 63, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ + Frame(0, 63, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ + Frame(0, 63, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ + Frame(0, 7, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ + Frame(0, 15, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ + Frame(0, 23, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ + Frame(56, 63, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ + Frame(48, 63, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ + Frame(40, 63, 24, 82, 32, 61, 32, 0)}; /* Right Horizontal Closed three fourth */ +DoorFrames g183_doorFrame_D2C = { // @ G0183_s_Graphic558_Frames_Door_D2C + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(80, 143, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ + Frame(80, 143, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ + Frame(80, 143, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ + Frame(80, 143, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ + Frame(80, 87, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ + Frame(80, 95, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ + Frame(80, 103, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ + Frame(136, 143, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ + Frame(128, 143, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ + Frame(120, 143, 24, 82, 32, 61, 32, 0)}; /* Right Horizontal Closed three fourth */ +DoorFrames g184_doorFrame_D2R = { // @ G0184_s_Graphic558_Frames_Door_D2R + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(160, 223, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ + Frame(160, 223, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ + Frame(160, 223, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ + Frame(160, 223, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ + Frame(160, 167, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ + Frame(160, 175, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ + Frame(160, 183, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ + Frame(216, 223, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ + Frame(208, 223, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ + Frame(200, 223, 24, 82, 32, 61, 32, 0)}; /* Right Horizontal Closed three fourth */ +DoorFrames g185_doorFrame_D1L = { // @ G0185_s_Graphic558_Frames_Door_D1L + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(0, 31, 17, 102, 48, 88, 64, 0), /* Closed Or Destroyed */ + Frame(0, 31, 17, 38, 48, 88, 64, 66), /* Vertical Closed one fourth */ + Frame(0, 31, 17, 60, 48, 88, 64, 44), /* Vertical Closed half */ + Frame(0, 31, 17, 82, 48, 88, 64, 22), /* Vertical Closed three fourth */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed one fourth */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed half */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed three fourth */ + Frame(20, 31, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */ + Frame(8, 31, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */ + Frame(0, 31, 17, 102, 48, 88, 52, 0)}; /* Right Horizontal Closed three fourth */ +DoorFrames g186_doorFrame_D1C = { // @ G0186_s_Graphic558_Frames_Door_D1C + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(64, 159, 17, 102, 48, 88, 0, 0), /* Closed Or Destroyed */ + Frame(64, 159, 17, 38, 48, 88, 0, 66), /* Vertical Closed one fourth */ + Frame(64, 159, 17, 60, 48, 88, 0, 44), /* Vertical Closed half */ + Frame(64, 159, 17, 82, 48, 88, 0, 22), /* Vertical Closed three fourth */ + Frame(64, 75, 17, 102, 48, 88, 36, 0), /* Left Horizontal Closed one fourth */ + Frame(64, 87, 17, 102, 48, 88, 24, 0), /* Left Horizontal Closed half */ + Frame(64, 99, 17, 102, 48, 88, 12, 0), /* Left Horizontal Closed three fourth */ + Frame(148, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */ + Frame(136, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */ + Frame(124, 159, 17, 102, 48, 88, 48, 0)}; /* Right Horizontal Closed three fourth */ +DoorFrames g187_doorFrame_D1R = { // @ G0187_s_Graphic558_Frames_Door_D1R + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(192, 223, 17, 102, 48, 88, 0, 0), /* Closed Or Destroyed */ + Frame(192, 223, 17, 38, 48, 88, 0, 66), /* Vertical Closed one fourth */ + Frame(192, 223, 17, 60, 48, 88, 0, 44), /* Vertical Closed half */ + Frame(192, 223, 17, 82, 48, 88, 0, 22), /* Vertical Closed three fourth */ + Frame(192, 203, 17, 102, 48, 88, 36, 0), /* Left Horizontal Closed one fourth */ + Frame(192, 215, 17, 102, 48, 88, 24, 0), /* Left Horizontal Closed half */ + Frame(192, 223, 17, 102, 48, 88, 12, 0), /* Left Horizontal Closed three fourth */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Right Horizontal Closed one fourth */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Right Horizontal Closed half */ + Frame(0, 0, 0, 0, 0, 0, 0, 0)}; /* Right Horizontal Closed three fourth */ + +uint16 g207_doorOrnCoordSets[4][3][6] = { // @ G0207_aaauc_Graphic558_DoorOrnamentCoordinateSets + /* { X1, X2, Y1, Y2, ByteWidth, Height } */ + {{17, 31, 8, 17, 8, 10}, /* D3LCR */ + {22, 42, 11, 23, 16, 13}, /* D2LCR */ + {32, 63, 13, 31, 16, 19}}, /* D1LCR */ + {{0, 47, 0, 40, 24, 41}, /* D3LCR */ + {0, 63, 0, 60, 32, 61}, /* D2LCR */ + {0, 95, 0, 87, 48, 88}}, /* D1LCR */ + {{17, 31, 15, 24, 8, 10}, /* D3LCR */ + {22, 42, 22, 34, 16, 13}, /* D2LCR */ + {32, 63, 31, 49, 16, 19}}, /* D1LCR */ + {{23, 35, 31, 39, 8, 9}, /* D3LCR */ + {30, 48, 41, 52, 16, 12}, /* D2LCR */ + {44, 75, 61, 79, 16, 19}}}; /* D1LCR */ + + Frame g164_Frame_DoorFrameLeft_D3L = Frame(0, 31, 28, 70, 16, 43, 0, 0); // @ G0164_s_Graphic558_Frame_DoorFrameLeft_D3L Frame g165_Frame_DoorFrameRight_D3R = Frame(192, 223, 28, 70, 16, 43, 0, 0); // @ G0165_s_Graphic558_Frame_DoorFrameRight_D3R Frame g166_Frame_DoorFrameLeft_D3C = Frame(64, 95, 27, 70, 16, 44, 0, 0); // @ G0166_s_Graphic558_Frame_DoorFrameLeft_D3C @@ -945,6 +1071,14 @@ void DisplayMan::f461_allocateFlippedWallBitmaps() { _g94_bitmapWall_D0R_Flipped = new byte[32 * 136]; } +void DisplayMan::f102_drawDoorBitmap(Frame* frame) { + if (frame->_srcByteWidth) { + f132_blitToBitmap(_vm->_displayMan->_g74_tmpBitmap, + _vm->_displayMan->_g296_bitmapViewport, + frame->_box, frame->_srcX, frame->_srcY, frame->_srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, frame->_srcHeight, k136_heightViewport); + } +} + void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* topAndBottomScreen) { if (middleScreenPalette && topAndBottomScreen) debugC(kDMDebugOftenCalledWarning, "MISSING CODE: F0508_AMIGA_BuildPaletteChangeCopperList"); @@ -1064,7 +1198,7 @@ void DisplayMan::f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint1 } } -void DisplayMan::flipBitmapVertical(byte *bitmap, uint16 byteWidth, uint16 height) { +void DisplayMan::f131_flipVertical(byte *bitmap, uint16 byteWidth, uint16 height) { uint16 width = byteWidth * 2; byte *tmp = new byte[width]; @@ -1159,7 +1293,7 @@ void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitm } void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex) { -#define AP0118_ui_FloorOrnamentIndex floorOrnOrdinal + uint16 floorOrnIndex; int16 nativeBitmapIndex; bool drawFootprints; byte* bitmap; @@ -1213,12 +1347,13 @@ void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloor goto T0108005; } floorOrnOrdinal--; - nativeBitmapIndex = _vm->_displayMan->_g102_currMapFloorOrnInfo[AP0118_ui_FloorOrnamentIndex][k0_NativeBitmapIndex] + floorOrnIndex = floorOrnOrdinal; + nativeBitmapIndex = _vm->_displayMan->_g102_currMapFloorOrnInfo[floorOrnIndex][k0_NativeBitmapIndex] + g191_floorOrnNativeBitmapndexInc[viewFloorIndex]; - coordSets = g206_floorOrnCoordSets[_vm->_displayMan->_g102_currMapFloorOrnInfo[AP0118_ui_FloorOrnamentIndex][k1_CoordinateSet]][viewFloorIndex]; + coordSets = g206_floorOrnCoordSets[_vm->_displayMan->_g102_currMapFloorOrnInfo[floorOrnIndex][k1_CoordinateSet]][viewFloorIndex]; if ((viewFloorIndex == k8_viewFloor_D1R) || (viewFloorIndex == k5_viewFloor_D2R) || (viewFloorIndex == k2_viewFloor_D3R) - || ((AP0118_ui_FloorOrnamentIndex == k15_FloorOrnFootprints) && _vm->_displayMan->_g76_useFlippedWallAndFootprintsBitmap && + || ((floorOrnIndex == k15_FloorOrnFootprints) && _vm->_displayMan->_g76_useFlippedWallAndFootprintsBitmap && ((viewFloorIndex == k7_viewFloor_D1C) || (viewFloorIndex == k4_viewFloor_D2C) || (viewFloorIndex == k1_viewFloor_D3C)))) { _vm->_displayMan->f99_copyBitmapAndFlipHorizontal(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), bitmap = _vm->_displayMan->_g74_tmpBitmap, coordSets[4], coordSets[5]); @@ -1226,7 +1361,7 @@ void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloor bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex); } _vm->_displayMan->f132_blitToBitmap(bitmap, _vm->_displayMan->_g296_bitmapViewport, - *(Box*)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport); + *(Box*)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport); T0108005: if (drawFootprints) { f108_drawFloorOrnament(_vm->M0_indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex); @@ -1234,6 +1369,96 @@ T0108005: } } +void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* doorNativeBitmapIndices, int16 byteCount, int16 viewDoorOrnIndex, DoorFrames* doorFrames) { + uint16 doorType; + DoorFrames* doorFramesTemp; + Door* door; + + + doorFramesTemp = doorFrames; + if (doorState != k0_doorState_OPEN) { + door = (Door*)(_vm->_dungeonMan->_g284_thingData[k0_DoorThingType]) + doorThingIndex; + memmove(_g74_tmpBitmap, f489_getNativeBitmapOrGraphic(doorNativeBitmapIndices[doorType = door->getType()]), byteCount * 2); + f109_drawDoorOrnament(door->getOrnOrdinal(), viewDoorOrnIndex); + if (getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[doorType]._attributes, k0x0004_MaskDoorInfo_Animated)) { + if (_vm->_rnd->getRandomNumber(1)) { + _vm->_displayMan->f130_flipBitmapHorizontal(_vm->_displayMan->_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight); + } + if (_vm->_rnd->getRandomNumber(1)) { + f131_flipVertical(_vm->_displayMan->_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight); + } + } + if ((doorFramesTemp == &g186_doorFrame_D1C) && _vm->_championMan->_g407_party._event73Count_ThievesEye) { + f109_drawDoorOrnament(_vm->M0_indexToOrdinal(k16_DoorOrnThivesEyeMask), k2_ViewDoorOrnament_D1LCR); + } + if (doorState == k4_doorState_CLOSED) { + f102_drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed); + } else { + if (doorState == k5_doorState_DESTROYED) { + f109_drawDoorOrnament(_vm->M0_indexToOrdinal(k15_DoorOrnDestroyedMask), viewDoorOrnIndex); + f102_drawDoorBitmap(&doorFramesTemp->_closedOrDestroyed); + } else { + doorState--; + if (door->opensVertically()) { + f102_drawDoorBitmap(&doorFramesTemp->_vertical[doorState]); + } else { + f102_drawDoorBitmap(&doorFramesTemp->_leftHorizontal[doorState]); + f102_drawDoorBitmap(&doorFramesTemp->_rightHorizontal[doorState]); + } + } + } + } +} + +void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIndex) { + static byte g200_palChangesDoorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 0, 130}; // @ G0200_auc_Graphic558_PaletteChanges_DoorOrnament_D3 + static byte g201PalChangesDoorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0201_auc_Graphic558_PaletteChanges_DoorOrnament_D2 + + +#define height doorOrnOrdinal +#define byteWidth viewDoorOrnIndex + int16 nativeBitmapIndex; + int16 coordSetGreenToad; + uint16* coordSetOrangeElk; + byte* L0107_puc_Multiple; +#define bitmap L0107_puc_Multiple + byte* bitmapNative; + + + if (doorOrnOrdinal) { + doorOrnOrdinal--; + nativeBitmapIndex = _vm->_displayMan->_g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex]; + coordSetOrangeElk = g207_doorOrnCoordSets[coordSetGreenToad = _vm->_displayMan->_g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]][viewDoorOrnIndex]; + if (viewDoorOrnIndex == k2_ViewDoorOrnament_D1LCR) { + bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + byteWidth = 48; + height = 88; + } else { + if (!_vm->_displayMan->f491_isDerivedBitmapInCache(doorOrnOrdinal = k68_DerivedBitmapFirstDoorOrnament_D3 + (doorOrnOrdinal * 2) + viewDoorOrnIndex)) { + uint16 *coordSetRedEagle = g207_doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR]; + bitmapNative = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmapNative, + f492_getDerivedBitmap(doorOrnOrdinal), + coordSetRedEagle[4] << 1, coordSetRedEagle[5], + coordSetOrangeElk[2] - coordSetOrangeElk[0] + 1, + coordSetOrangeElk[5], + (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2); + _vm->_displayMan->f493_addDerivedBitmap(doorOrnOrdinal); + } + bitmap = _vm->_displayMan->f492_getDerivedBitmap(doorOrnOrdinal); + if (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) { + byteWidth = 24; + height = 41; + } else { + byteWidth = 32; + height = 61; + } + } + _vm->_displayMan->f132_blitToBitmap(bitmap, _vm->_displayMan->_g74_tmpBitmap, + *(Box*)coordSetOrangeElk, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height); + } +} + void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { if (f._srcByteWidth) f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency); @@ -1274,7 +1499,8 @@ void DisplayMan::f116_drawSquareD3L(direction dir, int16 posX, int16 posY) { f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L); f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); f100_drawWallSetBitmap(_g705_bitmapWallSet_DoorFrameLeft_D3L, g164_Frame_DoorFrameLeft_D3L); - warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor"); + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], + _g693_doorNativeBitmapIndex_Front_D3LCR, M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &g179_doorFrame_D3L); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; goto T0116017_orangeElk; case k2_ElementTypePit: @@ -1287,7 +1513,7 @@ T0116015_redEagle: order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight; T0116016_blueToad: /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ - f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L); + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k0_viewFloor_D3L); T0116017_orangeElk: f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, order); } @@ -1331,8 +1557,9 @@ void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) { if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton"); } - warning("MISSING CODE: F0111_DUNGEONVIEW_DrawDoor"); - order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft; + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], + squareAspect[k2_DoorStateAspect], _g693_doorNativeBitmapIndex_Front_D3LCR, + M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &g181_doorFrame_D3R); goto T0117018; case k2_ElementTypePit: if (!squareAspect[k2_PitInvisibleAspect]) { @@ -1750,8 +1977,17 @@ void DisplayMan::f96_loadCurrentMapGraphics() { for (int16 i = 0; i < k1_FountainOrnCount; ++i) _g268_currMapFountainOrnIndices[i] = -1; - - + { + uint16 doorSets[2]; + doorSets[0] = _vm->_dungeonMan->_g269_currMap->_doorSet0; + doorSets[1] = _vm->_dungeonMan->_g269_currMap->_doorSet1; + for (uint16 doorSet = 0; doorSet <= 1; doorSet++) { + int16 counter = k108_FirstDoorSet + (doorSets[doorSet] * k3_DoorSetGraphicsCount); + _g693_doorNativeBitmapIndex_Front_D3LCR[doorSet] = counter++; + _g694_doorNativeBitmapIndex_Front_D2LCR[doorSet] = counter++; + _g695_doorNativeBitmapIndex_Front_D1LCR[doorSet] = counter++; + } + } uint16 alcoveCount = 0; uint16 fountainCount = 0; @@ -2865,7 +3101,7 @@ continue; AL_6_bitmapRedBanana = _g74_tmpBitmap; } if (flipVertical) { - flipBitmapVertical(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); + f131_flipVertical(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); } if (flipHorizontal) { f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, AL_4_normalizdByteWidth, heightRedEagle); @@ -3036,7 +3272,7 @@ then a wrong part of the bitmap is drawn on screen. To fix this bug, "+ paddingP f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } if (flipVertical) { - flipBitmapVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); + f131_flipVertical(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } f132_blitToBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, boxByteGreen, AL_4_xPos, 0, byteWidth, k112_byteWidthViewport, k10_ColorFlesh); } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 5b75676c75..1db59901e4 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -46,6 +46,22 @@ namespace DM { #define k7_viewFloor_D1C 7 // @ C7_VIEW_FLOOR_D1C #define k8_viewFloor_D1R 8 // @ C8_VIEW_FLOOR_D1R +#define k0_doorState_OPEN 0 // @ C0_DOOR_STATE_OPEN +#define k1_doorState_FOURTH 1 // @ C1_DOOR_STATE_CLOSED_ONE_FOURTH +#define k2_doorState_HALF 2 // @ k2_DoorStateAspect_CLOSED_HALF +#define k3_doorState_FOURTH 3 // @ C3_DOOR_STATE_CLOSED_THREE_FOURTH +#define k4_doorState_CLOSED 4 // @ C4_DOOR_STATE_CLOSED +#define k5_doorState_DESTROYED 5 // @ C5_DOOR_STATE_DESTROYED + +#define k0_ViewDoorOrnament_D3LCR 0 // @ C0_VIEW_DOOR_ORNAMENT_D3LCR +#define k1_ViewDoorOrnament_D2LCR 1 // @ C1_VIEW_DOOR_ORNAMENT_D2LCR +#define k2_ViewDoorOrnament_D1LCR 2 // @ C2_VIEW_DOOR_ORNAMENT_D1LCR + +#define k0x0001_MaskDoorInfo_CraturesCanSeeThrough 0x0001 // @ MASK0x0001_CREATURES_CAN_SEE_THROUGH +#define k0x0002_MaskDoorInfo_ProjectilesCanPassThrough 0x0002 // @ MASK0x0002_PROJECTILES_CAN_PASS_THROUGH +#define k0x0004_MaskDoorInfo_Animated 0x0004 // @ MASK0x0004_ANIMATED + + #define k2_FloorSetGraphicCount 2 // @ C002_FLOOR_SET_GRAPHIC_COUNT #define k13_WallSetGraphicCount 13 // @ C013_WALL_SET_GRAPHIC_COUNT #define k18_StairsGraphicCount 18 // @ C018_STAIRS_GRAPHIC_COUNT @@ -418,6 +434,28 @@ public: #define k160_byteWidthScreen 160 // @ C160_BYTE_WIDTH_SCREEN #define k200_heightScreen 200 // @ C200_HEIGHT_SCREEN +class DoorFrames { +public: + Frame _closedOrDestroyed; + Frame _vertical[3]; + Frame _leftHorizontal[3]; + Frame _rightHorizontal[3]; + DoorFrames(Frame f1, Frame f2_1, Frame f2_2, Frame f2_3, + Frame f3_1, Frame f3_2, Frame f3_3, + Frame f4_1, Frame f4_2, Frame f4_3) { + _closedOrDestroyed = f1; + _vertical[0] = f2_1; + _vertical[1] = f2_2; + _vertical[2] = f2_3; + _leftHorizontal[0] = f3_1; + _leftHorizontal[1] = f3_2; + _leftHorizontal[2] = f3_3; + _rightHorizontal[0] = f4_1; + _rightHorizontal[1] = f4_2; + _rightHorizontal[2] = f4_3; + } +}; // @ DOOR_FRAMES + class DisplayMan { friend class DM::TextMan; @@ -521,6 +559,10 @@ class DisplayMan { int16 _g230_currentFloorSet;// @ G0230_i_CurrentFloorSet bool _g76_useFlippedWallAndFootprintsBitmap; // @ G0076_B_UseFlippedWallAndFootprintsBitmaps + + int16 _g693_doorNativeBitmapIndex_Front_D3LCR[2]; // @ G0693_ai_DoorNativeBitmapIndex_Front_D3LCR + int16 _g694_doorNativeBitmapIndex_Front_D2LCR[2]; // @ G0694_ai_DoorNativeBitmapIndex_Front_D2LCR + int16 _g695_doorNativeBitmapIndex_Front_D1LCR[2]; // @ G0695_ai_DoorNativeBitmapIndex_Front_D1LCR public: uint16 _screenWidth; uint16 _screenHeight; @@ -547,6 +589,7 @@ public: void f96_loadCurrentMapGraphics(); // @ F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF void loadPalette(uint16 *palette); void f461_allocateFlippedWallBitmaps(); // @ F0461_START_AllocateFlippedWallBitmaps + void f102_drawDoorBitmap(Frame *frame);// @ F0102_DUNGEONVIEW_DrawDoorBitmap /// Gives the width of an IMG0 type item uint16 getPixelWidth(uint16 index); @@ -556,6 +599,9 @@ public: void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); // @ F0099_DUNGEONVIEW_CopyBitmapAndFlipHorizontal void f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex); // @ F0108_DUNGEONVIEW_DrawFloorOrnament + void f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16 *doorNativeBitmapIndices, int16 byteCount, + int16 viewDoorOrnIndex, DoorFrames *doorFrames); // @ F0111_DUNGEONVIEW_DrawDoor + void f109_drawDoorOrnament(int16 doorOrnOdinal, int16 viewDoorOrnIndex); // @ F0109_DUNGEONVIEW_DrawDoorOrnament /* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which @@ -572,7 +618,7 @@ public: void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap, int16 srcPixelWidth, int16 srcHight, int16 destPixelWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges void f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height); // @ F0130_VIDEO_FlipHorizontal - void flipBitmapVertical(byte *bitmap, uint16 byteWidth, uint16 height); + void f131_flipVertical(byte *bitmap, uint16 byteWidth, uint16 height); byte *f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnByteWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap void f134_fillBitmap(byte *bitmap, Color color, uint16 byteWidth, uint16 height); // @ F0134_VIDEO_FillBitmap -- cgit v1.2.3 From 411ad40ca43b900e3bdb9804ca39b10b25d6fa4b Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 4 Jul 2016 20:54:17 +0200 Subject: DM: Add missing code to several display functions --- engines/dm/champion.cpp | 22 ++ engines/dm/champion.h | 4 + engines/dm/dm.cpp | 4 + engines/dm/dm.h | 1 + engines/dm/dungeonman.cpp | 217 +++++++----- engines/dm/dungeonman.h | 1 + engines/dm/gfx.cpp | 875 ++++++++++++++++++++++++++++++++-------------- engines/dm/gfx.h | 23 ++ 8 files changed, 804 insertions(+), 343 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 333243c969..b35e0d8f5a 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -427,6 +427,28 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true); } +int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) { + uint16 searchedScentRedEagle; + int16 scentIndex; + Scent* scent; + Scent searchedScent; + + + if (scentIndex = _g407_party._scentCount) { + searchedScent.setMapX(mapX); + searchedScent.setMapY(mapY); + searchedScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); + searchedScentRedEagle = searchedScent.toUint16(); + scent = &_g407_party._scents[scentIndex--]; + do { + if ((*(--scent)).toUint16() == searchedScentRedEagle) { + return _vm->M0_indexToOrdinal(scentIndex); + } + } while (scentIndex--); + } + return 0; +} + ChampionIndex ChampionMan::f285_getIndexInCell(ViewCell cell) { for (uint16 i = 0; i < _g305_partyChampionCount; ++i) { if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index cabf06fbfb..43e976e543 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -55,6 +55,8 @@ public: void setMapX(uint16 val) { _scent = (_scent & ~0x1F) & (val & 0x1F); } void setMapY(uint16 val) { _scent = (_scent & ~(0x1F << 5)) & (val & 0x1F); } void setMapIndex(uint16 val) { _scent = (_scent & ~(0x1F << 10)) & (val & 0x3F); } + + uint16 toUint16() { return _scent; } }; // @ SCENT class Party { @@ -466,6 +468,8 @@ public: bool f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged void f296_drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons void f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot + int16 f315_getScentOrdinal(int16 mapX, int16 mapY); // @ F0315_CHAMPION_GetScentOrdinal + }; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 7fa1eea7b9..d824cf349a 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -88,6 +88,10 @@ uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height) { return pixelWidth / 2 * height; } +uint16 M21_normalizeModulo4(uint16 val) { + return val & 3; +} + DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { // Do not load data files // Do not initialize graphics here diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 8133fd231f..c4fe3c5ce1 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -70,6 +70,7 @@ uint16 setFlag(uint16 &val, uint16 mask); // @ M08_SET uint16 clearFlag(uint16 &val, uint16 mask); // @ M09_CLEAR uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height); // @ M75_BITMAP_BYTE_COUNT +uint16 M21_normalizeModulo4(uint16 val); // @ M21_NORMALIZE enum ThingType { diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 0cecd049e7..fa0e72c4ba 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -30,6 +30,7 @@ #include "dungeonman.h" #include "timeline.h" +#include "champion.h" @@ -512,7 +513,7 @@ byte g236_AdditionalThingCounts[16] = { // @ G0236_auc_Graphic559_AdditionalThin 0, /* Unused */ 60, /* Projectile */ 50 /* Explosion */ -}; +}; // this is the number of uint16s the data has to be stored, not the length of the data in dungeon.dat! byte g235_ThingDataWordCount[16] = { // @ G0235_auc_Graphic559_ThingDataByteCount @@ -532,7 +533,7 @@ byte g235_ThingDataWordCount[16] = { // @ G0235_auc_Graphic559_ThingDataByteCoun 0, /* Unused */ 5, /* Projectile */ 2 /* Explosion */ -}; +}; const Thing Thing::_none(0); // @ C0xFFFF_THING_NONE const Thing Thing::_endOfList(0xFFFE); // @ C0xFFFE_THING_ENDOFLIST @@ -826,140 +827,154 @@ Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) { } -// TODO: get rid of the GOTOs +// TODO: produce more GOTOs void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) { // complete, except where marked - _vm->_displayMan->_g289_championPortraitOrdinal = 0; // BUG0_75, possible fix +#define thingType dir + byte L0307_uc_Multiple; +#define square L0307_uc_Multiple +#define footprintsAllowed L0307_uc_Multiple +#define scentOrdinal L0307_uc_Multiple + Sensor* sensor; + bool leftRandWallOrnAllowed; + int16 L0310_i_Multiple; +#define frontRandWallOrnAllowed L0310_i_Multiple +#define sideIndex L0310_i_Multiple + bool rightRandWallOrnAllowed; + int16 thingTypeRedEagle; + bool squreIsFakeWall; + Thing thing; + for (uint16 i = 0; i < 5; ++i) aspectArray[i] = 0; - Thing thing = f161_getSquareFirstThing(mapX, mapY); - Square square = f151_getSquare(mapX, mapY); - - aspectArray[k0_ElemAspect] = square.getType(); - - bool leftOrnAllowed = false; - bool rightOrnAllowed = false; - bool frontOrnAllowed = false; - bool squareIsFakeWall = false; - bool footPrintsAllowed = false; - switch (square.getType()) { - case k0_WallElemType: + thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY); + square = _vm->_dungeonMan->f151_getSquare(mapX, mapY).toByte(); + switch (aspectArray[k0_ElemAspect] = Square(square).getType()) { + case k0_ElementTypeWall: switch (dir) { case kDirNorth: - leftOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed); - frontOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed); - rightOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed); + leftRandWallOrnAllowed = getFlag(square, k0x0004_WallEastRandOrnAllowed); + frontRandWallOrnAllowed = getFlag(square, k0x0002_WallSouthRandOrnAllowed); + rightRandWallOrnAllowed = getFlag(square, k0x0001_WallWestRandOrnAllowed); break; case kDirEast: - leftOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed); - frontOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed); - rightOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed); + leftRandWallOrnAllowed = getFlag(square, k0x0002_WallSouthRandOrnAllowed); + frontRandWallOrnAllowed = getFlag(square, k0x0001_WallWestRandOrnAllowed); + rightRandWallOrnAllowed = getFlag(square, k0x0008_WallNorthRandOrnAllowed); break; case kDirSouth: - leftOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed); - frontOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed); - rightOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed); + leftRandWallOrnAllowed = getFlag(square, k0x0001_WallWestRandOrnAllowed); + frontRandWallOrnAllowed = getFlag(square, k0x0008_WallNorthRandOrnAllowed); + rightRandWallOrnAllowed = getFlag(square, k0x0004_WallEastRandOrnAllowed); break; case kDirWest: - leftOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed); - frontOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed); - rightOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed); - break; - default: - break; + leftRandWallOrnAllowed = getFlag(square, k0x0008_WallNorthRandOrnAllowed); + frontRandWallOrnAllowed = getFlag(square, k0x0004_WallEastRandOrnAllowed); + rightRandWallOrnAllowed = getFlag(square, k0x0002_WallSouthRandOrnAllowed); } - + /* BUG0_75 Multiple champion portraits are drawn (one at a time) then the game crashes. This variable is only + reset to 0 when at least one square in the dungeon view is a wall. If the party is in front of a wall with a + champion portrait and the next time the dungeon view is drawn there is no wall square in the view and the + square in front of the party is a fake wall with a random ornament then the same champion portrait will be + drawn again because the variable was not reset to 0. Each time _vm->_displayMan->f107_isDrawnWallOrnAnAlcove + draws the portrait, _vm->_displayMan->_g289_championPortraitOrdinal is decremented so that the portait is + different each time the dungeon view is drawn until the game crashes */ + _vm->_displayMan->_g289_championPortraitOrdinal = 0; + squreIsFakeWall = false; T0172010_ClosedFakeWall: - f171_setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall); - - while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) { - int16 sideIndex = (thing.getCell() - dir) & 3; - if (sideIndex) { - if (thing.getType() == k2_TextstringType) { - if (TextString(f156_getThingData(thing)).isVisible()) { - aspectArray[sideIndex + 1] = _g265_currMapInscriptionWallOrnIndex + 1; - _vm->_displayMan->_g290_inscriptionThing = thing; // BUG0_76 + _vm->_dungeonMan->f171_setSquareAspectOrnOrdinals(aspectArray, + leftRandWallOrnAllowed, frontRandWallOrnAllowed, rightRandWallOrnAllowed, dir, mapX, mapY, squreIsFakeWall); + while ((thing != Thing::_endOfList) && ((thingTypeRedEagle = thing.getType()) <= k3_SensorThingType)) { + if (sideIndex = M21_normalizeModulo4(thing.getCell() - dir)) { /* Invisible on the back wall if 0 */ + sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(thing); + if (thingTypeRedEagle == k2_TextstringType) { + if (((TextString*)sensor)->isVisible()) { + aspectArray[sideIndex + 1] = _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex + 1; +/* BUG0_76 The same text is drawn on multiple sides of a wall square. The engine stores only a +single text to draw on a wall in a global variable. Even if different texts are placed on +differents sides of the wall, the same text is drawn on each affected side */ + _vm->_displayMan->_g290_inscriptionThing = thing; } } else { - Sensor sensor(f156_getThingData(thing)); - aspectArray[sideIndex + 1] = sensor.getOrnOrdinal(); - if (sensor.getType() == k127_SensorWallChampionPortrait) { - _vm->_displayMan->_g289_championPortraitOrdinal = _vm->M0_indexToOrdinal(sensor.getData()); + aspectArray[sideIndex + 1] = sensor->getOrnOrdinal(); + if (sensor->getType() == k127_SensorWallChampionPortrait) { + _vm->_displayMan->_g289_championPortraitOrdinal = _vm->M0_indexToOrdinal(sensor->getData()); } } } - thing = f159_getNextThing(thing); + thing = _vm->_dungeonMan->f159_getNextThing(thing); } - if (squareIsFakeWall && (_g306_partyMapX != mapX) && (_g307_partyMapY != mapY)) { + if (squreIsFakeWall && (_vm->_dungeonMan->_g306_partyMapX != mapX) && (_vm->_dungeonMan->_g307_partyMapY != mapY)) { aspectArray[k1_FirstGroupOrObjectAspect] = Thing::_endOfList.toUint16(); return; } break; - case k2_PitElemType: - if (square.get(k0x0008_PitOpen)) { - aspectArray[k2_PitInvisibleAspect] = square.get(k0x0004_PitInvisible); - footPrintsAllowed = square.toByte() & 1; + case k2_ElementTypePit: + if (getFlag(square, k0x0008_PitOpen)) { + aspectArray[k2_PitInvisibleAspect] = getFlag(square, k0x0004_PitInvisible); + footprintsAllowed &= 0x0001; } else { aspectArray[k0_ElemAspect] = k1_CorridorElemType; - footPrintsAllowed = true; + footprintsAllowed = true; } goto T0172030_Pit; - case k6_FakeWallElemType: - if (!square.get(k0x0004_FakeWallOpen)) { - aspectArray[k0_ElemAspect] = k0_WallElemType; - leftOrnAllowed = rightOrnAllowed = frontOrnAllowed = square.get(k0x0008_FakeWallRandOrnOrFootPAllowed); - squareIsFakeWall = true; + case k6_ElementTypeFakeWall: + if (!getFlag(square, k0x0004_FakeWallOpen)) { + aspectArray[k0_ElemAspect] = k0_ElementTypeWall; + leftRandWallOrnAllowed = rightRandWallOrnAllowed = frontRandWallOrnAllowed = getFlag(square, k0x0008_FakeWallRandOrnOrFootPAllowed); + squreIsFakeWall = true; goto T0172010_ClosedFakeWall; } - aspectArray[k0_WallElemType] = k1_CorridorElemType; - footPrintsAllowed = square.get(k0x0008_FakeWallRandOrnOrFootPAllowed); - square = Square(footPrintsAllowed ? 8 : 0); - // intentional fallthrough + aspectArray[k0_ElemAspect] = k1_CorridorElemType; + footprintsAllowed = getFlag(square, k0x0008_FakeWallRandOrnOrFootPAllowed) ? 8 : 0; case k1_CorridorElemType: - aspectArray[k4_FloorOrnOrdAspect] = f170_getRandomOrnOrdinal(square.get(k0x0008_CorridorRandOrnAllowed), _g269_currMap->_randFloorOrnCount, mapX, mapY, 30); + aspectArray[k4_FloorOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(getFlag(square, k0x0008_CorridorRandOrnAllowed), + _vm->_dungeonMan->_g269_currMap->_randFloorOrnCount, mapX, mapY, 30); T0172029_Teleporter: - footPrintsAllowed = true; + footprintsAllowed = true; T0172030_Pit: - while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) { - if (thing.getType() == k3_SensorThingType) - aspectArray[k4_FloorOrnOrdAspect] = Sensor(f156_getThingData(thing)).getOrnOrdinal(); - thing = f159_getNextThing(thing); + while ((thing != Thing::_endOfList) && ((thingType = (direction)thing.getType()) <= k3_SensorThingType)) { + if (thingType == k3_SensorThingType) { + sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(thing); + aspectArray[k4_FloorOrnOrdAspect] = sensor->getOrnOrdinal(); + } + thing = _vm->_dungeonMan->f159_getNextThing(thing); } goto T0172049_Footprints; - case k5_TeleporterElemType: - aspectArray[k2_TeleporterVisibleAspect] = square.get(k0x0008_TeleporterOpen) && square.get(k0x0004_TeleporterVisible); + case k5_ElementTypeTeleporter: + aspectArray[k2_TeleporterVisibleAspect] = getFlag(square, k0x0008_TeleporterOpen) && getFlag(square, k0x0004_TeleporterVisible); goto T0172029_Teleporter; - case k3_StairsElemType: - aspectArray[k0_ElemAspect] = ((square.get(k0x0008_StairsNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) ? k18_StairsSideElemType : k19_StairsFrontElemType; - aspectArray[k2_StairsUpAspect] = square.get(k0x0004_StairsUp); - footPrintsAllowed = false; + case k3_ElementTypeStairs: + aspectArray[k0_ElemAspect] = ((getFlag(square, k0x0008_StairsNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront; + aspectArray[k2_StairsUpAspect] = getFlag(square, k0x0004_StairsUp); + footprintsAllowed = false; goto T0172046_Stairs; case k4_DoorElemType: - if ((square.get(k0x0008_DoorNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) { + if ((getFlag(square, k0x0008_DoorNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) { aspectArray[k0_ElemAspect] = k16_DoorSideElemType; } else { aspectArray[k0_ElemAspect] = k17_DoorFrontElemType; - aspectArray[k2_DoorStateAspect] = square.getDoorState(); - aspectArray[k3_DoorThingIndexAspect] = f161_getSquareFirstThing(mapX, mapY).getIndex(); + aspectArray[k2_DoorStateAspect] = Square(square).getDoorState(); + aspectArray[k3_DoorThingIndexAspect] = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY).getIndex(); } - footPrintsAllowed = true; + footprintsAllowed = true; T0172046_Stairs: - while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) - thing = f159_getNextThing(thing); + while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) { + thing = _vm->_dungeonMan->f159_getNextThing(thing); + } T0172049_Footprints: - unsigned char scentOrdinal; // see next line comment - if (footPrintsAllowed) // TODO: I skipped some party query code, must come back later and complete - aspectArray[k4_FloorOrnOrdAspect] &= k0x8000_FootprintsAspect; - break; - default: - break; + if (footprintsAllowed && (scentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapX, mapY)) + && (--scentOrdinal >= _vm->_championMan->_g407_party._firstScentIndex) + && (scentOrdinal < _vm->_championMan->_g407_party._lastScentIndex)) { + setFlag(aspectArray[k4_FloorOrnOrdAspect], k0x8000_FootprintsAspect); + } } aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16(); } void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, - int16 mapX, int16 mapY, bool isFakeWall) { + int16 mapX, int16 mapY, bool isFakeWall) { int16 ornCount = _g269_currMap->_randWallOrnCount; turnDirRight(dir); @@ -1336,4 +1351,34 @@ int16 DungeonMan::f142_getProjectileAspect(Thing thing) { return g237_ObjectInfo[f141_getObjectInfoIndex(thing)]._objectAspectIndex; } +int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16* mapX, int16* mapY) { + int16 newMapX; + int16 newMapY; + int16 newLevel; + int16 offset; + Map* map; + int16 targetMapIndex; + + + if (_vm->_dungeonMan->_g309_partyMapIndex == k255_mapIndexEntrance) { + return kM1_mapIndexNone; + } + map = _vm->_dungeonMan->_g277_dungeonMaps + mapIndex; + newMapX = map->_offsetMapX + *mapX; + newMapY = map->_offsetMapY + *mapY; + newLevel = map->_level + levelDelta; + map = _vm->_dungeonMan->_g277_dungeonMaps; + for (targetMapIndex = 0; targetMapIndex < _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount; targetMapIndex++) { + if ((map->_level == newLevel) + && (newMapX >= (offset = map->_offsetMapX)) + && (newMapX <= (offset + map->_width)) + && (newMapY >= (offset = map->_offsetMapY)) && (newMapY <= (offset + map->_height))) { + *mapY = newMapY - offset; + *mapX = newMapX - map->_offsetMapX; + return targetMapIndex; + } + map++; + } + return kM1_mapIndexNone; +} } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index d2a82ac8f2..a32edcf3a4 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -648,6 +648,7 @@ public: void f163_linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList WeaponInfo *f158_getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo int16 f142_getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect + int16 f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16 *mapX, int16 *mapY); // @ F0154_DUNGEON_GetLocationAfterLevelChange uint32 _rawDunFileDataSize; // @ probably NONE byte *_rawDunFileData; // @ ??? diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 2a9a90dc7a..460e7b54a9 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -40,6 +40,19 @@ namespace DM { +Box g106_BoxThievesEye_ViewPortVisibleArea(64, 159, 19, 113); // @ G0106_s_Graphic558_Box_ThievesEye_ViewportVisibleArea +byte g198_PalChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3 +byte g199_PalChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2 + +byte g197_doorButtonCoordSet[1] = {0}; // @ G0197_auc_Graphic558_DoorButtonCoordinateSet + +uint16 g208_doorButtonCoordSets[1][4][6] = { // @ G0208_aaauc_Graphic558_DoorButtonCoordinateSets + /* X1, X2, Y1, Y2, ByteWidth, Height */ + {{199, 204, 41, 44, 8, 4}, /* D3R */ + {136, 141, 41, 44, 8, 4}, /* D3C */ + {144, 155, 42, 47, 8, 6}, /* D2C */ + {160, 175, 44, 52, 8, 9}}}; /* D1C */ + DoorFrames g179_doorFrame_D3L = { // @ G0179_s_Graphic558_Frames_Door_D3L /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ Frame(24, 71, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ @@ -1073,12 +1086,57 @@ void DisplayMan::f461_allocateFlippedWallBitmaps() { void DisplayMan::f102_drawDoorBitmap(Frame* frame) { if (frame->_srcByteWidth) { - f132_blitToBitmap(_vm->_displayMan->_g74_tmpBitmap, - _vm->_displayMan->_g296_bitmapViewport, + f132_blitToBitmap(_g74_tmpBitmap, + _g296_bitmapViewport, frame->_box, frame->_srcX, frame->_srcY, frame->_srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, frame->_srcHeight, k136_heightViewport); } } +void DisplayMan::f103_drawDoorFrameBitmapFlippedHorizontally(byte* bitmap, Frame* frame) { + if (frame->_srcByteWidth) { + f130_flipBitmapHorizontal(bitmap, frame->_srcByteWidth, frame->_srcHeight); + f132_blitToBitmap(bitmap, _g296_bitmapViewport, frame->_box, frame->_srcX, frame->_srcY, + frame->_srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, frame->_srcHeight, k136_heightViewport); + } +} + +void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButtonIndex) { + int16 nativeBitmapIndex; + int coordSet; + uint16* coordSetRedEagle; + byte* bitmap; + byte* bitmapNative; + + if (doorButtonOrdinal) { + doorButtonOrdinal--; + nativeBitmapIndex = doorButtonOrdinal + k315_firstDoorButton_GraphicIndice; + coordSetRedEagle = g208_doorButtonCoordSets[coordSet = g197_doorButtonCoordSet[doorButtonOrdinal]][viewDoorButtonIndex]; + if (viewDoorButtonIndex == k3_viewDoorButton_D1C) { + bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordSetRedEagle[0]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordSetRedEagle[1]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordSetRedEagle[2]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordSetRedEagle[3]; + } else { + if (!f491_isDerivedBitmapInCache(doorButtonOrdinal = k102_DerivedBitmapFirstDoorButton + (doorButtonOrdinal * 2) + ((!viewDoorButtonIndex) ? 0 : viewDoorButtonIndex - 1))) { + uint16* coordSetBlueGoat = g208_doorButtonCoordSets[coordSet][k3_viewDoorButton_D1C]; + bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + f129_blitToBitmapShrinkWithPalChange(bitmapNative, f492_getDerivedBitmap(doorButtonOrdinal), + coordSetBlueGoat[4] << 1, coordSetBlueGoat[5], + coordSetRedEagle[1] - coordSetRedEagle[0] + 1, + coordSetRedEagle[5], + (viewDoorButtonIndex == k2_viewDoorButton_D2C) ? g199_PalChangesDoorButtonAndWallOrn_D2 : g198_PalChangesDoorButtonAndWallOrn_D3); + + f493_addDerivedBitmap(doorButtonOrdinal); + } + bitmap = f492_getDerivedBitmap(doorButtonOrdinal); + } + f132_blitToBitmap(bitmap, _g296_bitmapViewport, *(Box*)coordSetRedEagle, 0, 0, + coordSetRedEagle[4], k112_byteWidthViewport, k10_ColorFlesh, coordSetRedEagle[5], k136_heightViewport); + } +} + void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* topAndBottomScreen) { if (middleScreenPalette && topAndBottomScreen) debugC(kDMDebugOftenCalledWarning, "MISSING CODE: F0508_AMIGA_BuildPaletteChangeCopperList"); @@ -1348,20 +1406,20 @@ void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloor } floorOrnOrdinal--; floorOrnIndex = floorOrnOrdinal; - nativeBitmapIndex = _vm->_displayMan->_g102_currMapFloorOrnInfo[floorOrnIndex][k0_NativeBitmapIndex] + nativeBitmapIndex = _g102_currMapFloorOrnInfo[floorOrnIndex][k0_NativeBitmapIndex] + g191_floorOrnNativeBitmapndexInc[viewFloorIndex]; - coordSets = g206_floorOrnCoordSets[_vm->_displayMan->_g102_currMapFloorOrnInfo[floorOrnIndex][k1_CoordinateSet]][viewFloorIndex]; + coordSets = g206_floorOrnCoordSets[_g102_currMapFloorOrnInfo[floorOrnIndex][k1_CoordinateSet]][viewFloorIndex]; if ((viewFloorIndex == k8_viewFloor_D1R) || (viewFloorIndex == k5_viewFloor_D2R) || (viewFloorIndex == k2_viewFloor_D3R) - || ((floorOrnIndex == k15_FloorOrnFootprints) && _vm->_displayMan->_g76_useFlippedWallAndFootprintsBitmap && + || ((floorOrnIndex == k15_FloorOrnFootprints) && _g76_useFlippedWallAndFootprintsBitmap && ((viewFloorIndex == k7_viewFloor_D1C) || (viewFloorIndex == k4_viewFloor_D2C) || (viewFloorIndex == k1_viewFloor_D3C)))) { - _vm->_displayMan->f99_copyBitmapAndFlipHorizontal(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), - bitmap = _vm->_displayMan->_g74_tmpBitmap, coordSets[4], coordSets[5]); + f99_copyBitmapAndFlipHorizontal(f489_getNativeBitmapOrGraphic(nativeBitmapIndex), + bitmap = _g74_tmpBitmap, coordSets[4], coordSets[5]); } else { - bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); } - _vm->_displayMan->f132_blitToBitmap(bitmap, _vm->_displayMan->_g296_bitmapViewport, - *(Box*)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport); + f132_blitToBitmap(bitmap, _g296_bitmapViewport, + *(Box*)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport); T0108005: if (drawFootprints) { f108_drawFloorOrnament(_vm->M0_indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex); @@ -1382,10 +1440,10 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d f109_drawDoorOrnament(door->getOrnOrdinal(), viewDoorOrnIndex); if (getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[doorType]._attributes, k0x0004_MaskDoorInfo_Animated)) { if (_vm->_rnd->getRandomNumber(1)) { - _vm->_displayMan->f130_flipBitmapHorizontal(_vm->_displayMan->_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight); + f130_flipBitmapHorizontal(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight); } if (_vm->_rnd->getRandomNumber(1)) { - f131_flipVertical(_vm->_displayMan->_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight); + f131_flipVertical(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight); } } if ((doorFramesTemp == &g186_doorFrame_D1C) && _vm->_championMan->_g407_party._event73Count_ThievesEye) { @@ -1427,25 +1485,25 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn if (doorOrnOrdinal) { doorOrnOrdinal--; - nativeBitmapIndex = _vm->_displayMan->_g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex]; - coordSetOrangeElk = g207_doorOrnCoordSets[coordSetGreenToad = _vm->_displayMan->_g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]][viewDoorOrnIndex]; + nativeBitmapIndex = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex]; + coordSetOrangeElk = g207_doorOrnCoordSets[coordSetGreenToad = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]][viewDoorOrnIndex]; if (viewDoorOrnIndex == k2_ViewDoorOrnament_D1LCR) { - bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); byteWidth = 48; height = 88; } else { - if (!_vm->_displayMan->f491_isDerivedBitmapInCache(doorOrnOrdinal = k68_DerivedBitmapFirstDoorOrnament_D3 + (doorOrnOrdinal * 2) + viewDoorOrnIndex)) { + if (!f491_isDerivedBitmapInCache(doorOrnOrdinal = k68_DerivedBitmapFirstDoorOrnament_D3 + (doorOrnOrdinal * 2) + viewDoorOrnIndex)) { uint16 *coordSetRedEagle = g207_doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR]; - bitmapNative = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex); - _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmapNative, - f492_getDerivedBitmap(doorOrnOrdinal), - coordSetRedEagle[4] << 1, coordSetRedEagle[5], - coordSetOrangeElk[2] - coordSetOrangeElk[0] + 1, - coordSetOrangeElk[5], - (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2); - _vm->_displayMan->f493_addDerivedBitmap(doorOrnOrdinal); + bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + f129_blitToBitmapShrinkWithPalChange(bitmapNative, + f492_getDerivedBitmap(doorOrnOrdinal), + coordSetRedEagle[4] << 1, coordSetRedEagle[5], + coordSetOrangeElk[2] - coordSetOrangeElk[0] + 1, + coordSetOrangeElk[5], + (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2); + f493_addDerivedBitmap(doorOrnOrdinal); } - bitmap = _vm->_displayMan->f492_getDerivedBitmap(doorOrnOrdinal); + bitmap = f492_getDerivedBitmap(doorOrnOrdinal); if (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) { byteWidth = 24; height = 41; @@ -1454,8 +1512,25 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn height = 61; } } - _vm->_displayMan->f132_blitToBitmap(bitmap, _vm->_displayMan->_g74_tmpBitmap, - *(Box*)coordSetOrangeElk, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height); + f132_blitToBitmap(bitmap, _g74_tmpBitmap, + *(Box*)coordSetOrangeElk, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height); + } +} + +void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame* frame, int16 mapX, int16 mapY, bool flipHorizontal) { + int16 L0117_i_Multiple; +#define AL0117_i_MapIndex L0117_i_Multiple +#define AL0117_i_Square L0117_i_Multiple + + + if (((AL0117_i_MapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g272_currMapIndex, -1, &mapX, &mapY)) >= 0) && + (Square(AL0117_i_Square = _vm->_dungeonMan->_g279_dungeonMapData[AL0117_i_MapIndex][mapX][mapY]).getType() == k2_ElementTypePit) && + getFlag(AL0117_i_Square, k0x0008_PitOpen)) { + if (flipHorizontal) { + _vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(nativeBitmapIndex, *frame); + } else { + _vm->_displayMan->f104_drawFloorPitOrStairsBitmap(nativeBitmapIndex, *frame); + } } } @@ -1553,9 +1628,9 @@ void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) { f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R); f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44); - warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally"); + f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g165_Frame_DoorFrameRight_D3R); if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { - warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton"); + f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k0_viewDoorButton_D3R); } f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], _g693_doorNativeBitmapIndex_Front_D3LCR, @@ -1581,162 +1656,393 @@ T0117018: } void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: - if (squareAspect[k2_StairsUpAspect]) + int16 order; + int16 squareAspect[5]; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { f104_drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, g111_FrameStairsUpFront_D3C); - else + } else { f104_drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, g122_FrameStairsDownFront_D3C); - break; - case k0_WallElemType: + } + goto T0118027; + case k0_ElementTypeWall: f101_drawWallSetBitmapWithoutTransparency(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k0_ViewSquare_D3C]); if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) { - //... missing code + order = k0x0000_CellOrder_Alcove; + goto T0118028; } - break; - default: - break; + return; + case k17_DoorFrontElemType: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); + f100_drawWallSetBitmap(_g706_bitmapWallSet_DoorFrameLeft_D3C, g166_Frame_DoorFrameLeft_D3C); + memmove(_g74_tmpBitmap, _g706_bitmapWallSet_DoorFrameLeft_D3C, 32 * 44); + f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g167_Frame_DoorFrameRight_D3C); + if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { + f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k1_ViewDoorOrnament_D2LCR); + } + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], + _g693_doorNativeBitmapIndex_Front_D3LCR, M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &g180_doorFrame_D3C); + order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; + goto T0118028; + case k2_ElementTypePit: + if (!squareAspect[k2_PitInvisibleAspect]) { + f104_drawFloorPitOrStairsBitmap(k50_FloorPit_D3C_GraphicIndice, g141_FrameFloorPit_D3C); + } + case k5_ElementTypeTeleporter: + case k1_CorridorElemType: +T0118027: + order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight; + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ +T0118028: + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, order); + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + f113_drawField(&g188_FieldAspects[k0_ViewSquare_D3C], g163_FrameWalls[k0_ViewSquare_D3C]._box); } } void DisplayMan::f119_drawSquareD2L(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: - if (squareAspect[k2_StairsUpAspect]) - f104_drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L); - else - f104_drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L); - break; - case k0_WallElemType: - f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]); - f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT); - if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) { - // ... missing code + int16 order; + int16 squareAspect[5]; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { + _vm->_displayMan->f104_drawFloorPitOrStairsBitmap(_vm->_displayMan->_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L); + } else { + _vm->_displayMan->f104_drawFloorPitOrStairsBitmap(_vm->_displayMan->_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L); } - break; - case k18_StairsSideElemType: - f104_drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L); - break; - default: - break; + goto T0119018; + case k0_ElementTypeWall: + _vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]); + _vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT); + if (_vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) { + order = k0x0000_CellOrder_Alcove; + goto T0119020; + } + return; + case k18_ElementTypeStairsSide: + _vm->_displayMan->f104_drawFloorPitOrStairsBitmap(_vm->_displayMan->_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L); + case k16_DoorSideElemType: + order = k0x0342_CellOrder_BackRight_FrontLeft_FrontRight; + goto T0119019; + case k17_DoorFrontElemType: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); + _vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); + _vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g703_bitmapWallSet_DoorFrameTop_D2LCR, g173_Frame_DoorFrameTop_D2L); + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], _g694_doorNativeBitmapIndex_Front_D2LCR, + M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g182_doorFrame_D2L); + order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; + goto T0119020; + case k2_ElementTypePit: + _vm->_displayMan->f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, + g143_FrameFloorPit_D2L); + case k5_ElementTypeTeleporter: + case k1_CorridorElemType: +T0119018: + order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight; +T0119019: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ +T0119020: + f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &g152_FrameFloorPit_D2L, posX, posY, false); + _vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, order); + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + _vm->_displayMan->f113_drawField(&g188_FieldAspects[k4_ViewSquare_D2L], g163_FrameWalls[k4_ViewSquare_D2L]._box); } } void DisplayMan::f120_drawSquareD2R(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: - if (squareAspect[k2_StairsUpAspect]) - f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R); - else - f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R); - break; - case k0_WallElemType: - f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]); - f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT); - if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) { - // ... missing code + int16 order; + int16 squareAspect[5]; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { + _vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_vm->_displayMan->_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R); + } else { + _vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_vm->_displayMan->_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R); } - break; - case k18_StairsSideElemType: - f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R); - break; - default: - break; + goto T0120027; + case k0_ElementTypeWall: + _vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]); + _vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT); + if (_vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) { + order = k0x0000_CellOrder_Alcove; + goto T0120029; + } + return; + case k18_ElementTypeStairsSide: + _vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_vm->_displayMan->_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R); + case k16_DoorSideElemType: + order = k0x0431_CellOrder_BackLeft_FrontRight_FrontLeft; + goto T0120028; + case k17_DoorFrontElemType: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_ViewSquare_D2R); + _vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); + _vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g703_bitmapWallSet_DoorFrameTop_D2LCR, g175_Frame_DoorFrameTop_D2R); + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], + _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g184_doorFrame_D2R); + order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft; + goto T0120029; + case k2_ElementTypePit: + _vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] + ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, g145_FrameFloorPit_D2R); + case k5_ElementTypeTeleporter: + case k1_CorridorElemType: +T0120027: + order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft; +T0120028: +/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_viewFloor_D2R); + f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &g154_FrameFloorPit_D2R, posX, posY, true); +T0120029: + _vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, order); + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + _vm->_displayMan->f113_drawField(&g188_FieldAspects[k5_ViewSquare_D2R], g163_FrameWalls[k5_ViewSquare_D2R]._box); } } void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: - if (squareAspect[k2_StairsUpAspect]) + int16 order; + int16 squareAspect[5]; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { f104_drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, g114_FrameStairsUpFront_D2C); - else + } else { f104_drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, g125_FrameStairsDownFront_D2C); - break; - case k0_WallElemType: + } + goto T0121015; + case k0_ElementTypeWall: f101_drawWallSetBitmapWithoutTransparency(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k3_ViewSquare_D2C]); if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) { - // ... missing code + order = k0x0000_CellOrder_Alcove; + goto T0121016; } - break; - default: - break; + return; + case k17_DoorFrontElemType: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); + f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, g174_Frame_DoorFrameTop_D2C); + f100_drawWallSetBitmap(_g707_bitmapWallSet_DoorFrameLeft_D2C, g168_Frame_DoorFrameLeft_D2C); + memcpy(_g74_tmpBitmap, _g707_bitmapWallSet_DoorFrameLeft_D2C, 48 * 65); + f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g169_Frame_DoorFrameRight_D2C); + if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { + f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k2_viewDoorButton_D2C); + } + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], + _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g183_doorFrame_D2C); + order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; + goto T0121016; + case k2_ElementTypePit: + f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k58_FloorPit_invisible_D2C_GraphicIndice : k52_FloorPit_D2C_GraphicIndice, g144_FrameFloorPit_D2C); + case k5_ElementTypeTeleporter: + case k1_CorridorElemType: +T0121015: + order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight; + /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C); + f112_drawCeilingPit(k64_ceilingPitD2C_GraphicIndice, &g153_FrameFloorPit_D2C, posX, posY, false); +T0121016: + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, order); + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + f113_drawField(&g188_FieldAspects[k3_ViewSquare_D2C], g163_FrameWalls[k3_ViewSquare_D2C]._box); } } + void DisplayMan::f122_drawSquareD1L(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: - if (squareAspect[k2_StairsUpAspect]) + int16 order; + int16 squareAspect[5]; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { f104_drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g116_FrameStairsUpFront_D1L); - else + } else { f104_drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g127_FrameStairsDownFront_D1L); - break; - case k0_WallElemType: + } + goto T0122019; + case k0_ElementTypeWall: f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k7_ViewSquare_D1L]); f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT); - break; - case k18_StairsSideElemType: - if (squareAspect[k2_StairsUpAspect]) + return; + case k18_ElementTypeStairsSide: + if (squareAspect[k2_StairsUpAspect]) { f104_drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g134_FrameStairsUpSide_D1L); - else + } else { f104_drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g136_FrameStairsDownSide_D1L); - break; - default: - break; + } + case k16_DoorSideElemType: + order = k0x0032_CellOrder_BackRight_FrontRight; + goto T0122020; + case k17_DoorFrontElemType: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, k0x0028_CellOrder_DoorPass1_BackRight); + f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g176_Frame_DoorFrameTop_D1L); + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], + _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &g185_doorFrame_D1L); + order = k0x0039_CellOrder_DoorPass2_FrontRight; + goto T0122021; + case k2_ElementTypePit: + f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice : k53_FloorPit_D1L_GraphicIndice, g146_FrameFloorPit_D1L); + case k5_ElementTypeTeleporter: + case k1_CorridorElemType: +T0122019: + order = k0x0032_CellOrder_BackRight_FrontRight; +T0122020: + /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L); + f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &g155_FrameFloorPit_D1L, posX, posY, false); +T0122021: + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, order); + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + f113_drawField(&g188_FieldAspects[k7_ViewSquare_D1L], g163_FrameWalls[k7_ViewSquare_D1L]._box); } } void DisplayMan::f123_drawSquareD1R(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: - if (squareAspect[k2_StairsUpAspect]) + int16 order; + int16 squareAspect[5]; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g118_FrameStairsUpFront_D1R); - else + } else { f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g129_FrameStairsDownFront_D1R); - break; - case k0_WallElemType: + } + goto T0123019; + case k0_ElementTypeWall: f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k8_ViewSquare_D1R]); f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT); - break; - case k18_StairsSideElemType: - if (squareAspect[k2_StairsUpAspect]) + return; + case k18_ElementTypeStairsSide: + if (squareAspect[k2_StairsUpAspect]) { f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g135_FrameStairsUpSide_D1R); - else + } else { f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g137_FrameStairsDownSide_D1R); - break; - default: - break; + } + case k16_DoorSideElemType: + order = k0x0041_CellOrder_BackLeft_FrontLeft; + goto T0123020; + case k17_DoorFrontElemType: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, k0x0018_CellOrder_DoorPass1_BackLeft); + f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g178_Frame_DoorFrameTop_D1R); + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], + _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &g187_doorFrame_D1R); + order = k0x0049_CellOrder_DoorPass2_FrontLeft; + goto T0123021; + case k2_ElementTypePit: + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice + : k53_FloorPit_D1L_GraphicIndice, g148_FrameFloorPit_D1R); + case k5_ElementTypeTeleporter: + case k1_CorridorElemType: +T0123019: + order = k0x0041_CellOrder_BackLeft_FrontLeft; +T0123020: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ + f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &g157_FrameFloorPit_D1R, posX, posY, true); +T0123021: + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, order); + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + f113_drawField(&g188_FieldAspects[k8_ViewSquare_D1R], g163_FrameWalls[k8_ViewSquare_D1R]._box); } } void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: - if (squareAspect[k2_StairsUpAspect]) + static Box g107_BoxThievesEyeVisibleArea(0, 95, 0, 94); // @ G0107_s_Graphic558_Box_ThievesEye_VisibleArea + int16 order; + int16 squareAspect[5]; + byte* bitmap; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + switch (_vm->_dungeonMan->_g285_squareAheadElement = (ElementType)squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { f104_drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, g117_FrameStairsUpFront_D1C); - else + } else { f104_drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, g128_FrameStairsDownFront_D1C); - break; - case k0_WallElemType: + } + goto T0124017; + case k0_ElementTypeWall: _vm->_dungeonMan->_g286_isFacingAlcove = false; _vm->_dungeonMan->_g287_isFacingViAltar = false; _vm->_dungeonMan->_g288_isFacingFountain = false; + if (_vm->_championMan->_g407_party._event73Count_ThievesEye) { + f491_isDerivedBitmapInCache(k1_DerivedBitmapThievesEyeVisibleArea); + f132_blitToBitmap(_g296_bitmapViewport, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea), + g107_BoxThievesEyeVisibleArea, + g106_BoxThievesEye_ViewPortVisibleArea._x1, + g106_BoxThievesEye_ViewPortVisibleArea._y1, + k112_byteWidthViewport, 48, k255_ColorNoTransparency, 136, 95); + bitmap = f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice); + /* BUG0_74 Creatures are drawn with wrong colors when viewed through a wall with the 'Thieve's Eye' spell. The 'hole in wall' + graphic is applied to the visible area with transparency on color 10. However the visible area may contain creature graphics + that use color 9. When the bitmap is drawn below with transparency on color 9 then the creature graphic is alterated: pixels + using color 9 are transparent and the background wall is visible through the creature graphic (grey/white pixels). + To fix this bug, the 'hole in wall' graphic should be applied to the wall graphic first (in a temporary buffer) and + then the wall with the hole should be drawn over the visible area */ + f132_blitToBitmap(bitmap, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea), + g107_BoxThievesEyeVisibleArea, + 0, 0, 48, 48, k10_ColorFlesh, 95, 95); + } f101_drawWallSetBitmapWithoutTransparency(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k6_ViewSquare_D1C]); if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) { - // .... code not yet implemneted + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0000_CellOrder_Alcove); } - break; - default: - break; + if (_vm->_championMan->_g407_party._event73Count_ThievesEye) { + f132_blitToBitmap(f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea), + _g296_bitmapViewport, g106_BoxThievesEye_ViewPortVisibleArea, 0, 0, + 48, k112_byteWidthViewport, k9_ColorGold, 95, k136_heightViewport); /* BUG0_74 */ + f493_addDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea); + warning("MISSING CODE: F0480_CACHE_ReleaseBlock"); + } + return; + case k17_DoorFrontElemType: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); + f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g177_Frame_DoorFrameTop_D1C); + f100_drawWallSetBitmap(_g708_bitmapWallSet_DoorFrameLeft_D1C, g170_Frame_DoorFrameLeft_D1C); + f100_drawWallSetBitmap(_g710_bitmapWallSet_DoorFrameRight_D1C, g171_Frame_DoorFrameRight_D1C); + if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { + f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C); + } + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], + _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &g186_doorFrame_D1C); + order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; + goto T0124018; + case k2_ElementTypePit: + f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k60_floorPitInvisibleD1C_GraphicIndice : k54_FloorPit_D1C_GraphicIndice, g147_FrameFloorPit_D1C); + case k5_ElementTypeTeleporter: + case k1_CorridorElemType: +T0124017: + order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight; +/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C); + f112_drawCeilingPit(k66_ceilingPitD1C_GraphicIndice, &g156_FrameFloorPit_D1C, posX, posY, false); +T0124018: + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, order); + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + f113_drawField(&g188_FieldAspects[k6_ViewSquare_D1C], g163_FrameWalls[k6_ViewSquare_D1C]._box); } } @@ -1757,26 +2063,51 @@ void DisplayMan::f125_drawSquareD0L(direction dir, int16 posX, int16 posY) { } void DisplayMan::f126_drawSquareD0R(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k18_StairsSideElemType: - if (squareAspect[k2_StairsUpAspect]) - f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R); + int16 squareAspect[5]; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k18_ElementTypeStairsSide: + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R); return; - case k0_WallElemType: - f100_drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, g163_FrameWalls[k11_ViewSquare_D0R]); - break; - default: + case k2_ElementTypePit: + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] ? k61_floorPitInvisibleD0L_GraphicIndice + : k55_FloorPit_D0L_GraphicIndice, g151_FrameFloorPit_D0R); + case k1_CorridorElemType: + case k16_DoorSideElemType: + case k5_ElementTypeTeleporter: + f112_drawCeilingPit(k67_ceilingPitD0L_grahicIndice, &g160_FrameFloorPit_D0R, posX, posY, true); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k11_ViewSquare_D0R, k0x0001_CellOrder_BackLeft); break; + case k0_ElementTypeWall: + f100_drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, g163_FrameWalls[k11_ViewSquare_D0R]); + return; + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + f113_drawField(&g188_FieldAspects[k11_ViewSquare_D0R], g163_FrameWalls[k11_ViewSquare_D0R]._box); } } void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: + static Box g108_BoxThievesEyeHoleInDoorFrame(0, 31, 19, 113); // @ G0108_s_Graphic558_Box_ThievesEye_HoleInDoorFrame + + int16 squareAspect[5]; + + _vm->_dungeonMan->f172_setSquareAspect((uint16*) squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k16_DoorSideElemType: + if (_vm->_championMan->_g407_party._event73Count_ThievesEye) { + memmove(_g74_tmpBitmap, _g709_bitmapWallSet_DoorFrameFront, 32 * 123); + f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice), + _g74_tmpBitmap, g108_BoxThievesEyeHoleInDoorFrame, g172_Frame_DoorFrame_D0C._box._x1 - g106_BoxThievesEye_ViewPortVisibleArea._x1, + 0, 48, 16, k9_ColorGold, 95, 123); + f100_drawWallSetBitmap(_g74_tmpBitmap, g172_Frame_DoorFrame_D0C); + } else { + f100_drawWallSetBitmap(_g709_bitmapWallSet_DoorFrameFront, g172_Frame_DoorFrame_D0C); + } + break; + case k19_ElementTypeStaisFront: if (squareAspect[k2_StairsUpAspect]) { f104_drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g119_FrameStairsUpFront_D0L); f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g120_FrameStairsUpFront_D0R); @@ -1785,8 +2116,13 @@ void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) { f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g131_FrameStairsDownFront_D0R); } break; - default: - break; + case k2_ElementTypePit: + f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k62_flootPitInvisibleD0C_graphicIndice : k56_FloorPit_D0C_GraphicIndice, g150_FrameFloorPit_D0C); + } + f112_drawCeilingPit(k68_ceilingPitD0C_graphicIndice, &g159_FrameFloorPit_D0C, posX, posY, false); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k9_ViewSquare_D0C, k0x0021_CellOrder_BackLeft_BackRight); + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + f113_drawField(&g188_FieldAspects[k9_ViewSquare_D0C], g163_FrameWalls[k9_ViewSquare_D0C]._box); } } @@ -2086,8 +2422,6 @@ byte g190_WallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_W 4, /* D1L Right */ 4}; /* D1R Left */ -byte g198_PalChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3 -byte g199_PalChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2 byte g204_UnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2 /* { Y for 1 line, Y for 2 lines, Y for 3 lines } */ @@ -2100,141 +2434,168 @@ byte g204_UnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_Unreadabl Box g109_BoxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) { - byte *bitmapGreen; - byte *bitmapRed; - int16 coordinateSetOffset; - bool flipHorizontal; - bool isInscription; - bool isAlcove; - Frame frame; - unsigned char inscriptionString[70]; +#define AP0116_i_CharacterCount wallOrnOrd +#define AP0116_i_WallOrnamentIndex wallOrnOrd + int16 L0088_i_Multiple; +#define AL0088_i_NativeBitmapIndex L0088_i_Multiple +#define AL0088_i_UnreadableTextLineCount L0088_i_Multiple + int16 L0089_i_Multiple; +#define AL0089_i_WallOrnamentCoordinateSetIndex L0089_i_Multiple +#define AL0089_i_FountainOrnamentIndex L0089_i_Multiple +#define AL0089_i_PixelWidth L0089_i_Multiple +#define AL0089_i_X L0089_i_Multiple + + uint16 *AL0090_puc_CoordinateSet = nullptr; + + byte* L0091_puc_Multiple; +#define AL0091_puc_Character L0091_puc_Multiple +#define AL0091_puc_Bitmap L0091_puc_Multiple + byte* L0092_puc_Bitmap; + int16 L0093_i_CoordinateSetOffset; + bool L0094_B_FlipHorizontal; + bool L0095_B_IsInscription; + bool L0096_B_IsAlcove; + int16 L0097_i_TextLineIndex; + uint16 tmp[6]; + byte L0099_auc_InscriptionString[70]; if (wallOrnOrd) { - int16 var_X; - int16 wallOrnIndex = wallOrnOrd - 1; - int16 nativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k0_NativeBitmapIndex]; + wallOrnOrd--; + AL0088_i_NativeBitmapIndex = _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k0_NativeBitmapIndex]; - uint16 *coordinateSetA = g205_WallOrnCoordSets[_g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]][viewWallIndex]; - isAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(wallOrnIndex); - isInscription = (wallOrnIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex); - if (isInscription) { - _vm->_dungeonMan->f168_decodeText((char*)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription); - } + AL0090_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex = + _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k1_CoordinateSet]][viewWallIndex]; + L0096_B_IsAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(AP0116_i_WallOrnamentIndex); + if (L0095_B_IsInscription = (AP0116_i_WallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex)) { + _vm->_dungeonMan->f168_decodeText((char *)L0099_auc_InscriptionString, _g290_inscriptionThing, k0_TextTypeInscription); + } if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) { if (viewWallIndex == k12_ViewWall_D1C_FRONT) { - if (isInscription) { - Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C]; - f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, g202_BoxWallPatchBehindInscription, 94, 28, - D1CFrame._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency); - - unsigned char *string = inscriptionString; - bitmapRed = _bitmaps[k120_InscriptionFontIndice]; - int16 textLineIndex = 0; + if (L0095_B_IsInscription) { + f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR,_g296_bitmapViewport, + g202_BoxWallPatchBehindInscription, 94, 28, + g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, + k112_byteWidthViewport, k255_ColorNoTransparency, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport); + byte *AL0090_puc_String = L0099_auc_InscriptionString; + L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont); + L0097_i_TextLineIndex = 0; do { - int16 characterCount = 0; - unsigned char *character = string; - while (*character++ < 0x80) { - characterCount++; + AP0116_i_CharacterCount = 0; + AL0091_puc_Character = AL0090_puc_String; + while (*AL0091_puc_Character++ < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */ + AP0116_i_CharacterCount++; } - frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7; - frame._box._y1 = (frame._box._y2 = g203_InscriptionLineY[textLineIndex++]) - 7; - while (characterCount--) { - f132_blitToBitmap(bitmapRed, _g296_bitmapViewport, frame._box, (*string++) * 8, 0, 144, k112_byteWidthViewport, k10_ColorFlesh); - frame._box._x1 += 8; - frame._box._x2 += 8; + Frame L0098_s_Frame; + L0098_s_Frame._box._x2 = (L0098_s_Frame._box._x1 = 112 - (AP0116_i_CharacterCount << 2)) + 7; + L0098_s_Frame._box._y1 = (L0098_s_Frame._box._y2 = g203_InscriptionLineY[L0097_i_TextLineIndex++]) - 7; + while (AP0116_i_CharacterCount--) { + f132_blitToBitmap(L0092_puc_Bitmap, _g296_bitmapViewport, L0098_s_Frame._box, + *AL0090_puc_String++ << 3, 0, 144, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport); + L0098_s_Frame._box._x1 += 8; + L0098_s_Frame._box._x2 += 8; } - } while (*string++ != 0x81); - return isAlcove; + } while (*AL0090_puc_String++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */ + goto T0107031; } - nativeBitmapIndex++; - - _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordinateSetA[0]; - _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordinateSetA[1]; - _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordinateSetA[2]; - _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordinateSetA[3]; - - _vm->_dungeonMan->_g286_isFacingAlcove = isAlcove; - _vm->_dungeonMan->_g287_isFacingViAltar = (wallOrnIndex == _g266_currMapViAltarIndex); + AL0088_i_NativeBitmapIndex++; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = AL0090_puc_CoordinateSet[0]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = AL0090_puc_CoordinateSet[1]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = AL0090_puc_CoordinateSet[2]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = AL0090_puc_CoordinateSet[3]; + + _vm->_dungeonMan->_g286_isFacingAlcove = L0096_B_IsAlcove; + _vm->_dungeonMan->_g287_isFacingViAltar = + (AP0116_i_WallOrnamentIndex == _g266_currMapViAltarIndex); _vm->_dungeonMan->_g288_isFacingFountain = false; - for (int16 fountainOrnIndex = 0; fountainOrnIndex < k1_FountainOrnCount; ++fountainOrnIndex) { - if (_g268_currMapFountainOrnIndices[fountainOrnIndex] == wallOrnIndex) { + for (AL0089_i_FountainOrnamentIndex = 0; AL0089_i_FountainOrnamentIndex < k1_FountainOrnCount; AL0089_i_FountainOrnamentIndex++) { + if (_g268_currMapFountainOrnIndices[AL0089_i_FountainOrnamentIndex] == AP0116_i_WallOrnamentIndex) { _vm->_dungeonMan->_g288_isFacingFountain = true; break; } } } - bitmapGreen = _bitmaps[nativeBitmapIndex]; + AL0091_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex); if (viewWallIndex == k11_ViewWall_D1R_LEFT) { - f99_copyBitmapAndFlipHorizontal(bitmapGreen, _g74_tmpBitmap, coordinateSetA[4], coordinateSetA[5]); - bitmapGreen = _g74_tmpBitmap; + f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]); + AL0091_puc_Bitmap = _g74_tmpBitmap; } - var_X = 0; + AL0089_i_X = 0; } else { - coordinateSetOffset = 0; - uint16 *coordSetB; - int16 wallOrnCoordSetIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]; - flipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT); - if (flipHorizontal) { - coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k11_ViewWall_D1R_LEFT]; - } else if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) { - coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k10_ViewWall_D1L_RIGHT]; + uint16 *AL0091_puc_CoordinateSet; + L0093_i_CoordinateSetOffset = 0; + if (L0094_B_FlipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT)) { + AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k11_ViewWall_D1R_LEFT]; } else { - nativeBitmapIndex++; - coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k12_ViewWall_D1C_FRONT]; - if (viewWallIndex == k7_ViewWall_D2L_FRONT) { - coordinateSetOffset = 6; - } else if (viewWallIndex == k9_ViewWall_D2R_FRONT) { - coordinateSetOffset = -6; + if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) { + AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k10_ViewWall_D1L_RIGHT]; + } else { + AL0088_i_NativeBitmapIndex++; + AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k12_ViewWall_D1C_FRONT]; + if (viewWallIndex == k7_ViewWall_D2L_FRONT) { + L0093_i_CoordinateSetOffset = 6; + } else { + if (viewWallIndex == k9_ViewWall_D2R_FRONT) { + L0093_i_CoordinateSetOffset = -6; + } + } } } - int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0]; - f129_blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], _g74_tmpBitmap, coordSetB[4] << 1, coordSetB[5], pixelWidth + 1, coordinateSetA[5], - (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2); - bitmapGreen = _bitmaps[nativeBitmapIndex]; - var_X = pixelWidth; - if (flipHorizontal) { - f99_copyBitmapAndFlipHorizontal(bitmapGreen, _g74_tmpBitmap, coordSetB[4], coordSetB[5]); - bitmapGreen = _g74_tmpBitmap; - var_X = 15 - (var_X & 0xF); - } else if (viewWallIndex == k7_ViewWall_D2L_FRONT) { - var_X -= coordinateSetA[1] - coordinateSetA[0]; + AL0089_i_PixelWidth = (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[1] - (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[0]; + if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + + (AP0116_i_WallOrnamentIndex << 2) + g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex])) { + L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex); + f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex), + AL0091_puc_CoordinateSet[4] << 1, + AL0091_puc_CoordinateSet[5], AL0089_i_PixelWidth + 1, + AL0090_puc_CoordinateSet[5], + (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2); + f493_addDerivedBitmap(AP0116_i_WallOrnamentIndex); + } + AL0091_puc_Bitmap = f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex); + if (L0094_B_FlipHorizontal) { + f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]); + AL0091_puc_Bitmap = _g74_tmpBitmap; + AL0089_i_X = 15 - (AL0089_i_X & 0x000F); } else { - var_X = 0; + if (viewWallIndex == k7_ViewWall_D2L_FRONT) { + AL0089_i_X -= AL0090_puc_CoordinateSet[1] - AL0090_puc_CoordinateSet[0]; + } else { + AL0089_i_X = 0; + } } } - if (isInscription) { - unsigned char *string = inscriptionString; - int16 unreadableTextLineCount = 0; + if (L0095_B_IsInscription) { + byte *AL0090_puc_String = L0099_auc_InscriptionString; + AL0088_i_UnreadableTextLineCount = 0; do { - while (*string < 0x80) { - string++; + while (*AL0090_puc_String < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */ + AL0090_puc_String++; } - unreadableTextLineCount++; - } while (*string++ != 0x81); - - if (unreadableTextLineCount < 4) { - frame._box._x1 = coordinateSetA[0]; - frame._box._x2 = coordinateSetA[1]; - frame._box._y1 = coordinateSetA[2]; - frame._box._y2 = coordinateSetA[3]; - frame._srcByteWidth = coordinateSetA[4]; - frame._srcHeight = coordinateSetA[5]; - - coordinateSetA = (uint16*)&frame._box; - - coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1]; + AL0088_i_UnreadableTextLineCount++; + } while (*AL0090_puc_String++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */ + if (AL0088_i_UnreadableTextLineCount < 4) { + for (uint16 i = 0; i < 6; ++i) + tmp[i] = AL0090_puc_CoordinateSet[i]; + AL0090_puc_CoordinateSet = tmp; + AL0090_puc_CoordinateSet[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + AL0088_i_UnreadableTextLineCount - 1]; } } - f132_blitToBitmap(bitmapGreen, _g296_bitmapViewport, *(Box*)coordinateSetA, var_X, 0, coordinateSetA[4], k112_byteWidthViewport, k10_ColorFlesh); - - if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { - Box &box = g109_BoxChampionPortraitOnWall; - f132_blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], _g296_bitmapViewport, box, (_g289_championPortraitOrdinal & 0x7) << 5, - (_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary); + f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport, + *(Box*)AL0090_puc_CoordinateSet, AL0089_i_X, 0, + AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport); +/* BUG0_05 A champion portrait sensor on a wall square is visible on all sides of the wall. +If there is another sensor with a wall ornament on one side of the wall then the champion portrait is drawn over that wall ornament */ + if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { +/* A portrait is 32x29 pixels */ + f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), + _g296_bitmapViewport, g109_BoxChampionPortraitOnWall, + (_g289_championPortraitOrdinal & 0x0007) << 5, + (_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); } - return isAlcove; +T0107031: + return L0096_B_IsAlcove; } return false; } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 1db59901e4..cfe271052d 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -57,6 +57,11 @@ namespace DM { #define k1_ViewDoorOrnament_D2LCR 1 // @ C1_VIEW_DOOR_ORNAMENT_D2LCR #define k2_ViewDoorOrnament_D1LCR 2 // @ C2_VIEW_DOOR_ORNAMENT_D1LCR +#define k0_viewDoorButton_D3R 0 // @ C0_VIEW_DOOR_BUTTON_D3R +#define k1_viewDoorButton_D3C 1 // @ C1_VIEW_DOOR_BUTTON_D3C +#define k2_viewDoorButton_D2C 2 // @ C2_VIEW_DOOR_BUTTON_D2C +#define k3_viewDoorButton_D1C 3 // @ C3_VIEW_DOOR_BUTTON_D1C + #define k0x0001_MaskDoorInfo_CraturesCanSeeThrough 0x0001 // @ MASK0x0001_CREATURES_CAN_SEE_THROUGH #define k0x0002_MaskDoorInfo_ProjectilesCanPassThrough 0x0002 // @ MASK0x0002_PROJECTILES_CAN_PASS_THROUGH #define k0x0004_MaskDoorInfo_Animated 0x0004 // @ MASK0x0004_ANIMATED @@ -222,6 +227,7 @@ enum GraphicIndice { k38_BorderPartyFireshieldIndice = 38, // @ C038_GRAPHIC_BORDER_PARTY_FIRESHIELD k39_BorderPartySpellshieldIndice = 39, // @ C039_GRAPHIC_BORDER_PARTY_SPELLSHIELD k40_PanelResurectReincaranteIndice = 40, // @ C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE + k41_holeInWall_GraphicIndice = 41, // @ C041_GRAPHIC_HOLE_IN_WALL k42_ObjectIcons_000_TO_031 = 42, // @ C042_GRAPHIC_OBJECT_ICONS_000_TO_031 k43_ObjectIcons_032_TO_063 = 43, // @ C043_GRAPHIC_OBJECT_ICONS_032_TO_063 k44_ObjectIcons_064_TO_095 = 44, // @ C044_GRAPHIC_OBJECT_ICONS_064_TO_095 @@ -237,11 +243,24 @@ enum GraphicIndice { k54_FloorPit_D1C_GraphicIndice = 54, // @ C054_GRAPHIC_FLOOR_PIT_D1C k55_FloorPit_D0L_GraphicIndice = 55, // @ C055_GRAPHIC_FLOOR_PIT_D0L k56_FloorPit_D0C_GraphicIndice = 56, // @ C056_GRAPHIC_FLOOR_PIT_D0C + k57_FloorPir_Invisible_D2L_GraphicIndice = 57, // @ C057_GRAPHIC_FLOOR_PIT_INVISIBLE_D2L + k58_FloorPit_invisible_D2C_GraphicIndice = 58, // @ C058_GRAPHIC_FLOOR_PIT_INVISIBLE_D2C + k59_floorPit_invisible_D1L_GraphicIndice = 59, // @ C059_GRAPHIC_FLOOR_PIT_INVISIBLE_D1L + k60_floorPitInvisibleD1C_GraphicIndice = 60, // @ C060_GRAPHIC_FLOOR_PIT_INVISIBLE_D1C + k61_floorPitInvisibleD0L_GraphicIndice = 61, // @ C061_GRAPHIC_FLOOR_PIT_INVISIBLE_D0L + k62_flootPitInvisibleD0C_graphicIndice = 62, // @ C062_GRAPHIC_FLOOR_PIT_INVISIBLE_D0C + k63_ceilingPit_D2L_GraphicIndice = 63, // @ C063_GRAPHIC_CEILING_PIT_D2L + k64_ceilingPitD2C_GraphicIndice = 64, // @ C064_GRAPHIC_CEILING_PIT_D2C + k65_ceilingPitD1L_GraphicIndice = 65, // @ C065_GRAPHIC_CEILING_PIT_D1L + k66_ceilingPitD1C_GraphicIndice = 66, // @ C066_GRAPHIC_CEILING_PIT_D1C + k67_ceilingPitD0L_grahicIndice = 67, // @ C067_GRAPHIC_CEILING_PIT_D0L + k68_ceilingPitD0C_graphicIndice = 68, // @ C068_GRAPHIC_CEILING_PIT_D0C k69_FieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R k73_FieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER k120_InscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT k241_FloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS k301_DoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED + k315_firstDoorButton_GraphicIndice = 315, // @ C315_GRAPHIC_FIRST_DOOR_BUTTON k316_FirstProjectileGraphicIndice = 316, // @ C316_GRAPHIC_FIRST_PROJECTILE k348_FirstExplosionGraphicIndice = 348, // @ C348_GRAPHIC_FIRST_EXPLOSION k351_FirstExplosionPatternGraphicIndice = 351, // @ C351_GRAPHIC_FIRST_EXPLOSION_PATTERN @@ -590,6 +609,8 @@ public: void loadPalette(uint16 *palette); void f461_allocateFlippedWallBitmaps(); // @ F0461_START_AllocateFlippedWallBitmaps void f102_drawDoorBitmap(Frame *frame);// @ F0102_DUNGEONVIEW_DrawDoorBitmap + void f103_drawDoorFrameBitmapFlippedHorizontally(byte *bitmap, Frame *frame); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally + void f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButtonIndex); // @ F0110_DUNGEONVIEW_DrawDoorButton /// Gives the width of an IMG0 type item uint16 getPixelWidth(uint16 index); @@ -602,6 +623,8 @@ public: void f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16 *doorNativeBitmapIndices, int16 byteCount, int16 viewDoorOrnIndex, DoorFrames *doorFrames); // @ F0111_DUNGEONVIEW_DrawDoor void f109_drawDoorOrnament(int16 doorOrnOdinal, int16 viewDoorOrnIndex); // @ F0109_DUNGEONVIEW_DrawDoorOrnament + void f112_drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int16 mapX, int16 mapY, bool flipHorizontal); // @ F0112_DUNGEONVIEW_DrawCeilingPit + /* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which -- cgit v1.2.3 From c95b23317ce179fe168a20f39a132b4cd9ec4f32 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 7 Jul 2016 00:46:51 +0200 Subject: DM: Add some missing code --- engines/dm/TODOs/todo.txt | 7 +- engines/dm/champion.cpp | 737 +++++++++++++++++++- engines/dm/champion.h | 60 +- engines/dm/dm.cpp | 63 +- engines/dm/dm.h | 117 ++-- engines/dm/dmglobals.cpp | 11 + engines/dm/dungeonman.cpp | 342 +++++++++- engines/dm/dungeonman.h | 110 ++- engines/dm/eventman.cpp | 470 ++++++++++--- engines/dm/eventman.h | 34 +- engines/dm/gfx.cpp | 134 ++-- engines/dm/gfx.h | 25 + engines/dm/group.cpp | 1639 ++++++++++++++++++++++++++++++++++++++++++++- engines/dm/group.h | 103 ++- engines/dm/inventory.cpp | 92 ++- engines/dm/inventory.h | 1 + engines/dm/menus.cpp | 30 + engines/dm/menus.h | 1 + engines/dm/module.mk | 1 + engines/dm/movesens.cpp | 1094 +++++++++++++++++++++++++++--- engines/dm/movesens.h | 33 +- engines/dm/objectman.cpp | 6 + engines/dm/objectman.h | 1 + engines/dm/projexpl.cpp | 418 ++++++++++++ engines/dm/projexpl.h | 101 +++ engines/dm/text.cpp | 82 ++- engines/dm/text.h | 11 + engines/dm/timeline.cpp | 153 +++++ engines/dm/timeline.h | 6 + 29 files changed, 5509 insertions(+), 373 deletions(-) create mode 100644 engines/dm/projexpl.cpp create mode 100644 engines/dm/projexpl.h diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 5ef225f869..183889e994 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -7,7 +7,7 @@ Bugs: Command gui is broken Logic: Game crashes when reincaranting a fourth champion and trying to copy his portrait - +e Todo: @@ -18,7 +18,7 @@ Todo: Attend to sev's notes on github Double check enums with hex literals, I think I screwed the regex when processing them Double check strcat, strstr usages, I might have messed them up in many places - I forgot to add a bunch of warning for show/hide mouse pointer + I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions Missing functions: Add missing F0163_DUNGEON_LinkThingToList in MovesensMan::sensorIsTriggeredByClickOnWall (I don't think it's safe yet) @@ -26,6 +26,3 @@ Todo: Refactoring Add constructor to CreatureInfo -Forgot to add number to name: - gBoxChampionPortrait, gBoxEye, gBoxMouth, gSlotMasks - \ No newline at end of file diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b35e0d8f5a..5c1f5466a7 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -32,10 +32,15 @@ #include "inventory.h" #include "objectman.h" #include "text.h" +#include "timeline.h" +#include "projexpl.h" +#include "group.h" namespace DM { +const char *g417_baseSkillName[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"}; + Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye Box g54_BoxChampionIcons[4] = { @@ -98,6 +103,81 @@ ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { _g413_leaderHandObjectIconIndex = kM1_IconIndiceNone; _g415_leaderEmptyHanded = true; _g514_magicCasterChampionIndex = kM1_ChampionNone; + for (uint16 i = 0; i < 4; ++i) { + _g409_championPendingDamage[i] = 0; + _g410_championPendingWounds[i] = 0; + } + +} + +bool ChampionMan::f329_isLeaderHandObjectThrown(int16 side) { + if (_g411_leaderIndex == kM1_ChampionNone) { + return false; + } + return f328_isObjectThrown(_g411_leaderIndex, kM1_ChampionSlotLeaderHand, side); +} + +bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side) { + int16 L0993_i_KineticEnergy; + int16 L0994_i_Multiple; +#define AL0994_i_Experience L0994_i_Multiple +#define AL0994_i_Attack L0994_i_Multiple + int16 L0995_i_Multiple; +#define AL0995_i_WeaponKineticEnergy L0995_i_Multiple +#define AL0995_i_SkillLevel L0995_i_Multiple +#define AL0995_i_StepEnergy L0995_i_Multiple + Thing L0996_T_Thing; + Champion* L0997_ps_Champion = nullptr; + WeaponInfo* L0998_ps_WeaponInfo; + Thing L0999_T_ActionHandThing; + bool L1000_B_ThrowingLeaderHandObject; + + + L1000_B_ThrowingLeaderHandObject = false; + if (slotIndex < 0) { /* Throw object in leader hand, which is temporarily placed in action hand */ + if (_g415_leaderEmptyHanded) { + return false; + } + L0996_T_Thing = f298_getObjectRemovedFromLeaderHand(); + L0997_ps_Champion = &_gK71_champions[champIndex]; + L0999_T_ActionHandThing = L0997_ps_Champion->getSlot(k1_ChampionSlotActionHand); + L0997_ps_Champion->setSlot(k1_ChampionSlotActionHand, L0996_T_Thing); + slotIndex = k1_ChampionSlotActionHand; + L1000_B_ThrowingLeaderHandObject = true; + } + L0993_i_KineticEnergy = f312_getStrength(champIndex, slotIndex); + if (L1000_B_ThrowingLeaderHandObject) { + L0997_ps_Champion->setSlot((ChampionSlot)slotIndex, L0999_T_ActionHandThing); + } else { + if ((L0996_T_Thing = f300_getObjectRemovedFromSlot(champIndex, slotIndex)) == Thing::_none) { + return false; + } + } + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + f325_decrementStamine(champIndex, f305_getThrowingStaminaCost(L0996_T_Thing)); + f330_disableAction(champIndex, 4); + AL0994_i_Experience = 8; + AL0995_i_WeaponKineticEnergy = 1; + if (L0996_T_Thing.getType() == k5_WeaponThingType) { + AL0994_i_Experience += 4; + L0998_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0996_T_Thing); + if (L0998_ps_WeaponInfo->_class <= k12_WeaponClassPoisinDart) { + AL0994_i_Experience += (AL0995_i_WeaponKineticEnergy = L0998_ps_WeaponInfo->_kineticEnergy) >> 2; + } + } + f304_addSkillExperience(champIndex, k10_ChampionSkillThrow, AL0994_i_Experience); + L0993_i_KineticEnergy += AL0995_i_WeaponKineticEnergy; + AL0995_i_SkillLevel = f303_getSkillLevel((ChampionIndex)champIndex, k10_ChampionSkillThrow); + L0993_i_KineticEnergy += _vm->_rnd->getRandomNumber(16) + (L0993_i_KineticEnergy >> 1) + AL0995_i_SkillLevel; + AL0994_i_Attack = f26_getBoundedValue((uint16)40, (uint16)((AL0995_i_SkillLevel << 3) + _vm->_rnd->getRandomNumber(31)), (uint16)200); + AL0995_i_StepEnergy = MAX(5, 11 - AL0995_i_SkillLevel); + _vm->_projexpl->f212_projectileCreate(L0996_T_Thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, + M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side), + _vm->_dungeonMan->_g308_partyDir, L0993_i_KineticEnergy, AL0994_i_Attack, AL0995_i_StepEnergy); + _vm->_g311_projectileDisableMovementTicks = 4; + _vm->_g312_lastProjectileDisabledMovementDirection = _vm->_dungeonMan->_g308_partyDir; + f292_drawChampionState((ChampionIndex)champIndex); + return true; } uint16 ChampionMan::M27_getChampionPortraitX(uint16 index) { @@ -138,7 +218,7 @@ Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding, return result += valToStr; } -void ChampionMan::f299_applyModifiersToStatistics(Champion* champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing) { +void ChampionMan::f299_applyModifiersToStatistics(Champion* champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) { int16 statIndex; int16 modifier = 0; ThingType thingType = thing.getType(); @@ -266,7 +346,6 @@ T0299044_ApplyModifier: } else if (statIndex < k6_ChampionStatAntifire + 1) { for (uint16 statValIndex = k0_ChampionStatMaximum; statValIndex <= k2_ChampionStatMinimum; ++statValIndex) { champ->getStatistic((ChampionStatisticType)statIndex, (ChampionStatisticValue)statValIndex) += modifier; - warning("BUG0_38"); } } } @@ -284,7 +363,7 @@ bool ChampionMan::f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing t if (newIconIndex != currIconIndex) { if ((slotBoxIndex < k8_SlotBoxInventoryFirstSlot) && !_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) { _g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true; - warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + _vm->_eventMan->f77_hideMouse(); } objMan.f38_drawIconInSlotBox(slotBoxIndex, newIconIndex); return true; @@ -312,9 +391,9 @@ void ChampionMan::f296_drawChangedObjectIcons() { IconIndice iconIndex = objMan.f33_getIconIndex(_g414_leaderHandObject); if (iconIndex != leaderHandObjIconIndex) { _g420_mousePointerHiddenToDrawChangedObjIconOnScreen = true; - warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + _vm->_eventMan->f77_hideMouse(); objMan.f36_extractIconFromBitmap(iconIndex, objMan._g412_objectIconForMousePointer); - warning("MISSING CODE: F0068_MOUSE_SetPointerToObject"); + _vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer); _g413_leaderHandObjectIconIndex = iconIndex; objMan.f34_drawLeaderObjectName(_g414_leaderHandObject); } @@ -359,7 +438,7 @@ void ChampionMan::f296_drawChangedObjectIcons() { } if (_g420_mousePointerHiddenToDrawChangedObjIconOnScreen) - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + _vm->_eventMan->f78_showMouse(); } void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) { @@ -401,7 +480,7 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch if (iconIndex = k4_IconIndiceWeaponTorchUnlit) { ((Weapon*)rawObjPtr)->setLit(true); - warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette"); + _vm->_inventoryMan->f337_setDungeonViewPalette(); f296_drawChangedObjectIcons(); } else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) && ((iconIndex == k144_IconIndiceContainerChestClosed) || ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)))) { @@ -413,7 +492,7 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch if ((iconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (iconIndex <= k13_IconIndiceJunkIllumuletEquipped)) { ((Junk*)rawObjPtr)->setChargeCount(1); _g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2]; - warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette"); + _vm->_inventoryMan->f337_setDungeonViewPalette(); iconIndex = (IconIndice)(iconIndex + 1); } else if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) { ((Junk*)rawObjPtr)->setChargeCount(1); @@ -449,7 +528,627 @@ int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) { return 0; } -ChampionIndex ChampionMan::f285_getIndexInCell(ViewCell cell) { +Thing ChampionMan::f298_getObjectRemovedFromLeaderHand() { + Thing L0890_T_LeaderHandObject; + + + _g415_leaderEmptyHanded = true; + if ((L0890_T_LeaderHandObject = _g414_leaderHandObject) != Thing::_none) { + _g414_leaderHandObject = Thing::_none; + _g413_leaderHandObjectIconIndex = kM1_IconIndiceNone; + _vm->_eventMan->f78_showMouse(); + _vm->_objectMan->f35_clearLeaderObjectName(); + _vm->_eventMan->f69_setMousePointer(); + _vm->_eventMan->f77_hideMouse(); + if (_g411_leaderIndex != kM1_ChampionNone) { + _gK71_champions[_g411_leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(L0890_T_LeaderHandObject); + setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad); + f292_drawChampionState(_g411_leaderIndex); + } + } + return L0890_T_LeaderHandObject; +} + +uint16 ChampionMan::f312_getStrength(int16 champIndex, int16 slotIndex) { + int16 L0935_i_Strength; + uint16 L0936_ui_Multiple; +#define AL0936_ui_ObjectWeight L0936_ui_Multiple +#define AL0936_ui_SkillLevel L0936_ui_Multiple + uint16 L0937_ui_Multiple; +#define AL0937_ui_OneSixteenthMaximumLoad L0937_ui_Multiple +#define AL0937_ui_Class L0937_ui_Multiple + Thing L0938_T_Thing; + Champion* L0939_ps_Champion; + WeaponInfo* L0940_ps_WeaponInfo; + int16 L0941_i_LoadThreshold; + + + L0939_ps_Champion = &_gK71_champions[champIndex]; + L0935_i_Strength = _vm->_rnd->getRandomNumber(15) + L0939_ps_Champion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent]; + L0938_T_Thing = L0939_ps_Champion->_slots[slotIndex]; + if ((AL0936_ui_ObjectWeight = _vm->_dungeonMan->f140_getObjectWeight(L0938_T_Thing)) <= (AL0937_ui_OneSixteenthMaximumLoad = f309_getMaximumLoad(L0939_ps_Champion) >> 4)) { + L0935_i_Strength += AL0936_ui_ObjectWeight - 12; + } else { + if (AL0936_ui_ObjectWeight <= (L0941_i_LoadThreshold = AL0937_ui_OneSixteenthMaximumLoad + ((AL0937_ui_OneSixteenthMaximumLoad - 12) >> 1))) { + L0935_i_Strength += (AL0936_ui_ObjectWeight - AL0937_ui_OneSixteenthMaximumLoad) >> 1; + } else { + L0935_i_Strength -= (AL0936_ui_ObjectWeight - L0941_i_LoadThreshold) << 1; + } + } + if (L0938_T_Thing.getType() == k5_WeaponThingType) { + L0940_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0938_T_Thing); + L0935_i_Strength += L0940_ps_WeaponInfo->_strength; + AL0936_ui_SkillLevel = 0; + AL0937_ui_Class = L0940_ps_WeaponInfo->_class; + if ((AL0937_ui_Class == k0_WeaponClassSwingWeapon) || (AL0937_ui_Class == k2_WeaponClassDaggerAndAxes)) { + AL0936_ui_SkillLevel = f303_getSkillLevel(champIndex, k4_ChampionSkillSwing); + } + if ((AL0937_ui_Class != k0_WeaponClassSwingWeapon) && (AL0937_ui_Class < k16_WeaponClassFirstBow)) { + AL0936_ui_SkillLevel += f303_getSkillLevel(champIndex, k10_ChampionSkillThrow); + } + if ((AL0937_ui_Class >= k16_WeaponClassFirstBow) && (AL0937_ui_Class < k112_WeaponClassFirstMagicWeapon)) { + AL0936_ui_SkillLevel += f303_getSkillLevel(champIndex, k11_ChampionSkillShoot); + } + L0935_i_Strength += AL0936_ui_SkillLevel << 1; + } + L0935_i_Strength = f306_getStaminaAdjustedValue(L0939_ps_Champion, L0935_i_Strength); + if (getFlag(L0939_ps_Champion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? k0x0001_ChampionWoundReadHand : k0x0002_ChampionWoundActionHand)) { + L0935_i_Strength >>= 1; + } + MAX(1, 2); + return f26_getBoundedValue(0, L0935_i_Strength >> 1, 100); +} + +Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) { + Thing L0894_T_Thing; + int16 L0895_i_IconIndex; + Champion* L0896_ps_Champion; + Weapon* L0897_ps_Weapon; + bool L0898_B_IsInventoryChampion; + + + L0896_ps_Champion = &_gK71_champions[champIndex]; + if (slotIndex >= k30_ChampionSlotChest_1) { + L0894_T_Thing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1]; + _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = Thing::_none; + } else { + L0894_T_Thing = L0896_ps_Champion->_slots[slotIndex]; + L0896_ps_Champion->_slots[slotIndex] = Thing::_none; + } + if (L0894_T_Thing == Thing::_none) { + return Thing::_none; + } + L0898_B_IsInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal); + L0895_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0894_T_Thing); + f299_applyModifiersToStatistics(L0896_ps_Champion, slotIndex, L0895_i_IconIndex, -1, L0894_T_Thing); /* Remove objet modifiers */ + L0897_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0894_T_Thing); + if (slotIndex == k10_ChampionSlotNeck) { + if ((L0895_i_IconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (L0895_i_IconIndex <= k13_IconIndiceJunkIllumuletEquipped)) { + ((Junk*)L0897_ps_Weapon)->setChargeCount(0); + _g407_party._magicalLightAmount -= g39_LightPowerToLightAmount[2]; + _vm->_inventoryMan->f337_setDungeonViewPalette(); + } else { + if ((L0895_i_IconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (L0895_i_IconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) { + ((Junk*)L0897_ps_Weapon)->setChargeCount(0); + } + } + } + f291_drawSlot(champIndex, slotIndex); + if (L0898_B_IsInventoryChampion) { + setFlag(L0896_ps_Champion->_attributes, k0x4000_ChampionAttributeViewport); + } + if (slotIndex < k2_ChampionSlotHead) { + if (slotIndex == k1_ChampionSlotActionHand) { + setFlag(L0896_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand); + if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)) { + _vm->_menuMan->f388_clearActingChampion(); + } + if ((L0895_i_IconIndex >= k30_IconIndiceScrollOpen) && (L0895_i_IconIndex <= k31_IconIndiceScrollClosed)) { + ((Scroll*)L0897_ps_Weapon)->setClosed(true); + f296_drawChangedObjectIcons(); + } + } + if ((L0895_i_IconIndex >= k4_IconIndiceWeaponTorchUnlit) && (L0895_i_IconIndex <= k7_IconIndiceWeaponTorchLit)) { + L0897_ps_Weapon->setLit(false); + _vm->_inventoryMan->f337_setDungeonViewPalette(); + f296_drawChangedObjectIcons(); + } + if (L0898_B_IsInventoryChampion && (slotIndex == k1_ChampionSlotActionHand)) { + if (L0895_i_IconIndex == k144_IconIndiceContainerChestClosed) { + _vm->_inventoryMan->f334_closeChest(); + goto T0300011; + } + if ((L0895_i_IconIndex >= k30_IconIndiceScrollOpen) && (L0895_i_IconIndex <= k31_IconIndiceScrollClosed)) { +T0300011: + setFlag(L0896_ps_Champion->_attributes, k0x0800_ChampionAttributePanel); + } + } + } + L0896_ps_Champion->_load -= _vm->_dungeonMan->f140_getObjectWeight(L0894_T_Thing); + setFlag(L0896_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad); + return L0894_T_Thing; +} + +void ChampionMan::f325_decrementStamine(int16 championIndex, int16 decrement) { + int16 L0988_i_Stamina; + Champion* L0989_ps_Champion; + + + if (championIndex == kM1_ChampionNone) { + return; + } + L0989_ps_Champion = &_gK71_champions[championIndex]; + if ((L0988_i_Stamina = (L0989_ps_Champion->_currStamina -= decrement)) <= 0) { + L0989_ps_Champion->_currStamina = 0; + f321_addPendingDamageAndWounds_getDamage(championIndex, (-L0988_i_Stamina) >> 1, k0x0000_ChampionWoundNone, k0_attackType_NORMAL); + } else { + if (L0988_i_Stamina > L0989_ps_Champion->_maxStamina) { + L0989_ps_Champion->_currStamina = L0989_ps_Champion->_maxStamina; + } + } + setFlag(L0989_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics); +} + +int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, uint16 attackType) { + int16 L0976_i_Multiple; +#define AL0976_i_WoundIndex L0976_i_Multiple +#define AL0976_i_WisdomFactor L0976_i_Multiple +#define AL0976_i_AdjustedAttack L0976_i_Multiple + uint16 L0977_ui_Defense; + uint16 L0978_ui_WoundCount; + Champion* L0979_ps_Champion; + + if (attack <= 0) + return 0; + + L0979_ps_Champion = &_gK71_champions[champIndex]; + if (!L0979_ps_Champion->_currHealth) { +T0321004: + return 0; + } + if (attackType != k0_attackType_NORMAL) { + for (L0978_ui_WoundCount = 0, AL0976_i_WoundIndex = k0_ChampionSlotReadyHand, L0977_ui_Defense = 0; AL0976_i_WoundIndex <= k5_ChampionSlotFeet; AL0976_i_WoundIndex++) { + if (allowedWounds & (1 << AL0976_i_WoundIndex)) { + L0978_ui_WoundCount++; + L0977_ui_Defense += f313_getWoundDefense(champIndex, AL0976_i_WoundIndex | ((attackType == k4_attackType_SHARP) ? k0x8000_maskUseSharpDefense : k0x0000_maskDoNotUseSharpDefense)); + } + } + if (L0978_ui_WoundCount) { + L0977_ui_Defense /= L0978_ui_WoundCount; + } + switch (attackType) { + case k6_attackType_PSYCHIC: + if ((AL0976_i_WisdomFactor = 115 - L0979_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent]) <= 0) { + attack = 0; + } else { + attack = _vm->f30_getScaledProduct(attack, 6, AL0976_i_WisdomFactor); + } + goto T0321024; + case k5_attackType_MAGIC: + attack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k5_ChampionStatAntimagic, attack); + attack -= _g407_party._spellShieldDefense; + goto T0321024; + case k1_attackType_FIRE: + attack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k6_ChampionStatAntifire, attack); + attack -= _g407_party._fireShieldDefense; + break; + case k2_attackType_SELF: + L0977_ui_Defense >>= 1; + case k3_attackType_BLUNT: + case k4_attackType_SHARP: + case k7_attackType_LIGHTNING: + ; + } + if (attack <= 0) + goto T0321004; + attack = _vm->f30_getScaledProduct(attack, 6, 130 - L0977_ui_Defense); + /* BUG0_44 A champion may take much more damage than expected after a Black Flame attack or an impact + with a Fireball projectile. If the party has a fire shield defense value higher than the fire attack value then the resulting intermediary + attack value is negative and damage should be 0. However, the negative value is still used for further computations and the result may be a very + high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE and if attack is negative before calling F0030_MAIN_GetScaledProduct */ +T0321024: + if (attack <= 0) + goto T0321004; + if (attack > (AL0976_i_AdjustedAttack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k4_ChampionStatVitality, _vm->_rnd->getRandomNumber(127) + 10))) { /* BUG0_45 This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the probability of being wounded. However if it was fixed, the behavior would be the opposite of what it should: the higher the vitality of a champion, the lower the result of F0307_CHAMPION_GetStatisticAdjustedAttack and the more likely the champion could get wounded (because of more iterations in the loop below) */ + do { + setFlag(*(uint16*)&_g410_championPendingWounds[champIndex], (1 << _vm->_rnd->getRandomNumber(7)) & allowedWounds); + } while ((attack > (AL0976_i_AdjustedAttack <<= 1)) && AL0976_i_AdjustedAttack); + } + if (_g300_partyIsSleeping) { + f314_wakeUp(); + } + } + _g409_championPendingDamage[champIndex] += attack; + return attack; +} + +int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) { + static byte g50_woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor + + int16 L0942_i_Multiple; +#define AL0942_i_SlotIndex L0942_i_Multiple +#define AL0942_i_WoundDefense L0942_i_Multiple + uint16 L0943_ui_ArmourShieldDefense; + bool L0944_B_UseSharpDefense; + Thing L0945_T_Thing; + Champion* L0946_ps_Champion; + ArmourInfo* L0947_ps_ArmourInfo; + + + L0946_ps_Champion = &_gK71_champions[champIndex]; + if (L0944_B_UseSharpDefense = getFlag(woundIndex, k0x8000_maskUseSharpDefense)) { + clearFlag(woundIndex, k0x8000_maskUseSharpDefense); + } + for (L0943_ui_ArmourShieldDefense = 0, AL0942_i_SlotIndex = k0_ChampionSlotReadyHand; AL0942_i_SlotIndex <= k1_ChampionSlotActionHand; AL0942_i_SlotIndex++) { + if ((L0945_T_Thing = L0946_ps_Champion->_slots[AL0942_i_SlotIndex]).getType() == k6_ArmourThingType) { + L0947_ps_ArmourInfo = (ArmourInfo*)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing); + L0947_ps_ArmourInfo = &g239_ArmourInfo[((Armour*)L0947_ps_ArmourInfo)->getType()]; + if (getFlag(L0947_ps_ArmourInfo->_attributes, k0x0080_ArmourAttributeIsAShield)) { + L0943_ui_ArmourShieldDefense += ((f312_getStrength(champIndex, AL0942_i_SlotIndex) + _vm->_dungeonMan->f143_getArmourDefense(L0947_ps_ArmourInfo, L0944_B_UseSharpDefense)) * g50_woundDefenseFactor[woundIndex]) >> ((AL0942_i_SlotIndex == woundIndex) ? 4 : 5); + } + } + } + AL0942_i_WoundDefense = _vm->getRandomNumber((L0946_ps_Champion->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] >> 3) + 1); + if (L0944_B_UseSharpDefense) { + AL0942_i_WoundDefense >>= 1; + } + AL0942_i_WoundDefense += L0946_ps_Champion->_actionDefense + L0946_ps_Champion->_shieldDefense + _g407_party._shieldDefense + L0943_ui_ArmourShieldDefense; + if ((woundIndex > k1_ChampionSlotActionHand) && ((L0945_T_Thing = L0946_ps_Champion->_slots[woundIndex]).getType() == k6_ArmourThingType)) { + L0947_ps_ArmourInfo = (ArmourInfo*)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing); + AL0942_i_WoundDefense += _vm->_dungeonMan->f143_getArmourDefense(&g239_ArmourInfo[((Armour*)L0947_ps_ArmourInfo)->getType()], L0944_B_UseSharpDefense); + } + if (getFlag(L0946_ps_Champion->_wounds, 1 << woundIndex)) { + AL0942_i_WoundDefense -= 8 + _vm->getRandomNumber(4); + } + if (_g300_partyIsSleeping) { + AL0942_i_WoundDefense >>= 1; + } + return f26_getBoundedValue(0, AL0942_i_WoundDefense >> 1, 100); +} + +uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion* champ, uint16 statIndex, uint16 attack) { + int16 L0927_i_Factor; + + if ((L0927_i_Factor = 170 - champ->_statistics[statIndex][k1_ChampionStatCurrent]) < 16) { /* BUG0_41 The Antifire and Antimagic statistics are completely ignored. The Vitality statistic is ignored against poison and to determine the probability of being wounded. Vitality is still used normally to compute the defense against wounds and the speed of health regeneration. A bug in the Megamax C compiler produces wrong machine code for this statement. It always returns 0 for the current statistic value so that L0927_i_Factor = 170 in all cases */ + return attack >> 3; + } + return _vm->f30_getScaledProduct(attack, 7, L0927_i_Factor); +} + +void ChampionMan::f314_wakeUp() { + _vm->_g321_stopWaitingForPlayerInput = true; + _g300_partyIsSleeping = false; + _vm->waitMs(10); + _vm->_displayMan->f98_drawFloorAndCeiling(); + _vm->_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface; + _vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement; + warning("MISSING CODE: set G0443_ps_PrimaryKeyboardInput"); + warning("MISSING CODE: G0444_ps_SecondaryKeyboardInput"); + _vm->_eventMan->f357_discardAllInput(); + _vm->_menuMan->f457_drawEnabledMenus(); +} + +int16 ChampionMan::f305_getThrowingStaminaCost(Thing thing) { + int16 L0923_i_Weight; + int16 L0924_i_StaminaCost; + + + L0924_i_StaminaCost = f26_getBoundedValue((int16)1, L0923_i_Weight = _vm->_dungeonMan->f140_getObjectWeight(thing) >> 1, (int16)10); + while ((L0923_i_Weight -= 10) > 0) { + L0924_i_StaminaCost += L0923_i_Weight >> 1; + } + return L0924_i_StaminaCost; +} + +void ChampionMan::f330_disableAction(uint16 champIndex, uint16 ticks) { + int32 L1001_l_UpdatedEnableActionEventTime; + int32 L1002_l_CurrentEnableActionEventTime; + int16 L1003_i_EventIndex; + Champion* L1004_ps_Champion; + TimelineEvent L1005_s_Event; + + + L1004_ps_Champion = &_gK71_champions[champIndex]; + L1001_l_UpdatedEnableActionEventTime = _vm->_g313_gameTime + ticks; + L1005_s_Event._type = k11_TMEventTypeEnableChampionAction; + L1005_s_Event._priority = champIndex; + L1005_s_Event._B._slotOrdinal = 0; + if ((L1003_i_EventIndex = L1004_ps_Champion->_enableActionEventIndex) >= 0) { + L1002_l_CurrentEnableActionEventTime = M30_time(_vm->_timeline->_g370_events[L1003_i_EventIndex]._mapTime); + if (L1001_l_UpdatedEnableActionEventTime >= L1002_l_CurrentEnableActionEventTime) { + L1001_l_UpdatedEnableActionEventTime += (L1002_l_CurrentEnableActionEventTime - _vm->_g313_gameTime) >> 1; + } else { + L1001_l_UpdatedEnableActionEventTime = L1002_l_CurrentEnableActionEventTime + (ticks >> 1); + } + _vm->_timeline->f237_deleteEvent(L1003_i_EventIndex); + } else { + setFlag(L1004_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x0008_ChampionAttributeDisableAction); + f292_drawChampionState((ChampionIndex)champIndex); + } + M33_setMapAndTime(L1005_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, L1001_l_UpdatedEnableActionEventTime); + L1004_ps_Champion->_enableActionEventIndex = _vm->_timeline->f238_addEventGetEventIndex(&L1005_s_Event); +} + +void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) { +#define AP0638_ui_SkillLevelAfter exp +#define AP0638_ui_ChampionColor exp + uint16 L0915_ui_Multiple; +#define AL0915_ui_MapDifficulty L0915_ui_Multiple +#define AL0915_ui_SkillLevelBefore L0915_ui_Multiple +#define AL0915_ui_VitalityAmount L0915_ui_Multiple +#define AL0915_ui_StaminaAmount L0915_ui_Multiple + uint16 L0916_ui_BaseSkillIndex; + Skill* L0918_ps_Skill; + Champion* L0919_ps_Champion; + int16 L0920_i_MinorStatisticIncrease; + int16 L0921_i_MajorStatisticIncrease; + int16 L0922_i_BaseSkillLevel; + + + warning("potaneitally dangerous cast of uint32 below"); + if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && ((uint32)_vm->_projexpl->_g361_lastCreatureAttackTime < (_vm->_g313_gameTime - 150))) { + exp >>= 1; + } + if (exp) { + if (AL0915_ui_MapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty) { + exp *= AL0915_ui_MapDifficulty; + } + L0919_ps_Champion = &_gK71_champions[champIndex]; + if (skillIndex >= k4_ChampionSkillSwing) { + L0916_ui_BaseSkillIndex = (skillIndex - k4_ChampionSkillSwing) >> 2; + } else { + L0916_ui_BaseSkillIndex = skillIndex; + } + AL0915_ui_SkillLevelBefore = f303_getSkillLevel(champIndex, L0916_ui_BaseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience)); + warning("potentially dangerous cast of uint32 below"); + if ((skillIndex >= k4_ChampionSkillSwing) && ((uint32)_vm->_projexpl->_g361_lastCreatureAttackTime > (_vm->_g313_gameTime - 25))) { + exp <<= 1; + } + L0918_ps_Skill = &L0919_ps_Champion->_skills[skillIndex]; + L0918_ps_Skill->_experience += exp; + if (L0918_ps_Skill->_temporaryExperience < 32000) { + L0918_ps_Skill->_temporaryExperience += f26_getBoundedValue(1, exp >> 3, 100); + } + L0918_ps_Skill = &L0919_ps_Champion->_skills[L0916_ui_BaseSkillIndex]; + if (skillIndex >= k4_ChampionSkillSwing) { + L0918_ps_Skill->_experience += exp; + } + AP0638_ui_SkillLevelAfter = f303_getSkillLevel(champIndex, L0916_ui_BaseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience)); + if (AP0638_ui_SkillLevelAfter > AL0915_ui_SkillLevelBefore) { + L0922_i_BaseSkillLevel = AP0638_ui_SkillLevelAfter; + L0920_i_MinorStatisticIncrease = _vm->getRandomNumber(2); + L0921_i_MajorStatisticIncrease = 1 + _vm->getRandomNumber(2); + AL0915_ui_VitalityAmount = _vm->getRandomNumber(2); /* For Priest skill, the amount is 0 or 1 for all skill levels */ + if (L0916_ui_BaseSkillIndex != k2_ChampionSkillPriest) { + AL0915_ui_VitalityAmount &= AP0638_ui_SkillLevelAfter; /* For non Priest skills the amount is 0 for even skill levels. The amount is 0 or 1 for odd skill levels */ + } + L0919_ps_Champion->_statistics[k4_ChampionStatVitality][k0_ChampionStatMaximum] += AL0915_ui_VitalityAmount; + AL0915_ui_StaminaAmount = L0919_ps_Champion->_maxStamina; + L0919_ps_Champion->_statistics[k6_ChampionStatAntifire][k0_ChampionStatMaximum] += _vm->getRandomNumber(2) & ~AP0638_ui_SkillLevelAfter; /* The amount is 0 for odd skill levels. The amount is 0 or 1 for even skill levels */ + switch (L0916_ui_BaseSkillIndex) { + case k0_ChampionSkillFighter: + AL0915_ui_StaminaAmount >>= 4; + AP0638_ui_SkillLevelAfter *= 3; + L0919_ps_Champion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += L0921_i_MajorStatisticIncrease; + L0919_ps_Champion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += L0920_i_MinorStatisticIncrease; + break; + case k1_ChampionSkillNinja: + AL0915_ui_StaminaAmount /= 21; + AP0638_ui_SkillLevelAfter <<= 1; + L0919_ps_Champion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += L0920_i_MinorStatisticIncrease; + L0919_ps_Champion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += L0921_i_MajorStatisticIncrease; + break; + case k3_ChampionSkillWizard: + AL0915_ui_StaminaAmount >>= 5; + L0919_ps_Champion->_maxMana += AP0638_ui_SkillLevelAfter + (AP0638_ui_SkillLevelAfter >> 1); + L0919_ps_Champion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += L0921_i_MajorStatisticIncrease; + goto T0304016; + case k2_ChampionSkillPriest: + AL0915_ui_StaminaAmount /= 25; + L0919_ps_Champion->_maxMana += AP0638_ui_SkillLevelAfter; + AP0638_ui_SkillLevelAfter += (AP0638_ui_SkillLevelAfter + 1) >> 1; + L0919_ps_Champion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += L0920_i_MinorStatisticIncrease; +T0304016: + if ((L0919_ps_Champion->_maxMana += MIN(_vm->getRandomNumber(4), (uint16)(L0922_i_BaseSkillLevel - 1))) > 900) { + L0919_ps_Champion->_maxMana = 900; + } + L0919_ps_Champion->_statistics[k5_ChampionStatAntimagic][k0_ChampionStatMaximum] += _vm->getRandomNumber(3); + } + if ((L0919_ps_Champion->_maxHealth += AP0638_ui_SkillLevelAfter + _vm->getRandomNumber((AP0638_ui_SkillLevelAfter >> 1) + 1)) > 999) { + L0919_ps_Champion->_maxHealth = 999; + } + if ((L0919_ps_Champion->_maxStamina += AL0915_ui_StaminaAmount + _vm->getRandomNumber((AL0915_ui_StaminaAmount >> 1) + 1)) > 9999) { + L0919_ps_Champion->_maxStamina = 9999; + } + setFlag(L0919_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); + f292_drawChampionState((ChampionIndex)champIndex); + _vm->_textMan->f51_messageAreaPrintLineFeed(); + _vm->_textMan->f47_messageAreaPrintMessage((Color)(AP0638_ui_ChampionColor = g46_ChampionColor[champIndex]), L0919_ps_Champion->_name); + // TODO: localization + _vm->_textMan->f47_messageAreaPrintMessage((Color)AP0638_ui_ChampionColor, " JUST GAINED A "); + _vm->_textMan->f47_messageAreaPrintMessage((Color)AP0638_ui_ChampionColor, g417_baseSkillName[L0916_ui_BaseSkillIndex]); + _vm->_textMan->f47_messageAreaPrintMessage((Color)AP0638_ui_ChampionColor, " LEVEL!"); + } + } +} + +int16 ChampionMan::f324_damageAll_getDamagedChampionCount(uint16 attack, int16 wounds, int16 attackType) { + int16 L0984_i_ChampionIndex; + int16 L0985_i_RandomAttack; + int16 L0986_i_DamagedChampionCount; + + attack -= (L0985_i_RandomAttack = (attack >> 3) + 1); + L0985_i_RandomAttack <<= 1; + for (L0986_i_DamagedChampionCount = 0, L0984_i_ChampionIndex = k0_ChampionFirst; L0984_i_ChampionIndex < _g305_partyChampionCount; L0984_i_ChampionIndex++) { + if (f321_addPendingDamageAndWounds_getDamage(L0984_i_ChampionIndex, MAX(1, attack + _vm->getRandomNumber(L0985_i_RandomAttack)), wounds, attackType)) { /* Actual attack is attack +/- (attack / 8) */ + L0986_i_DamagedChampionCount++; + } + } + return L0986_i_DamagedChampionCount; +} + +int16 ChampionMan::f286_getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) { + uint16 L0838_ui_Counter; + int16 L0839_i_ChampionIndex; + signed char L0840_auc_OrderedCellsToAttack[4]; + + + if (_g305_partyChampionCount && (M38_distance(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)) { + _vm->_groupMan->f229_setOrderedCellsToAttack(L0840_auc_OrderedCellsToAttack, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, mapX, mapY, cell); + for (L0838_ui_Counter = 0; L0838_ui_Counter < 4; L0838_ui_Counter++) { + if ((L0839_i_ChampionIndex = f285_getIndexInCell(L0840_auc_OrderedCellsToAttack[L0838_ui_Counter])) >= 0) { + return L0839_i_ChampionIndex; + } + } + } + return kM1_ChampionNone; +} + +int16 ChampionMan::f311_getDexterity(Champion* champ) { + int16 L0934_i_Dexterity; + + + L0934_i_Dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent]; + L0934_i_Dexterity -= ((int32)(L0934_i_Dexterity >> 1) * (int32)champ->_load) / f309_getMaximumLoad(champ); + if (_g300_partyIsSleeping) { + L0934_i_Dexterity >>= 1; + } + return f26_getBoundedValue(1 + _vm->getRandomNumber(8), L0934_i_Dexterity >> 1, 100 - _vm->getRandomNumber(8)); +} + +bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) { +#define AP0646_ui_IsLucky percentage + register unsigned char* L0928_puc_Statistic; + + + if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage)) { + return true; + } + L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck]; + AP0646_ui_IsLucky = (_vm->getRandomNumber(L0928_puc_Statistic[k1_ChampionStatCurrent]) > percentage); + L0928_puc_Statistic[k1_ChampionStatCurrent] = f26_getBoundedValue((int32)L0928_puc_Statistic[k2_ChampionStatMinimum], (int32)L0928_puc_Statistic[k1_ChampionStatCurrent] + (AP0646_ui_IsLucky ? -2 : 2), (int32)L0928_puc_Statistic[k0_ChampionStatMaximum]); + return AP0646_ui_IsLucky; +} + +void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) { + TimelineEvent L0980_s_Event; + Champion* L0981_ps_Champion; + + + if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _g299_candidateChampionOrdinal)) { + return; + } + L0981_ps_Champion = &_gK71_champions[champIndex]; + f321_addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), k0x0000_ChampionWoundNone, k0_attackType_NORMAL); + setFlag(L0981_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); + if ((_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) && (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) { + setFlag(L0981_ps_Champion->_attributes, k0x0800_ChampionAttributePanel); + } + if (--attack) { + L0981_ps_Champion->_poisonEventCount++; + L0980_s_Event._type = k75_TMEventTypePoisonChampion; + L0980_s_Event._priority = champIndex; + M33_setMapAndTime(L0980_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 36); + L0980_s_Event._B._attack = attack; + _vm->_timeline->f238_addEventGetEventIndex(&L0980_s_Event); + } + f292_drawChampionState((ChampionIndex)champIndex); +} + +void ChampionMan::f284_setPartyDirection(int16 dir) { + int16 L0833_i_ChampionIndex; + int16 L0834_i_Delta; + Champion* L0835_ps_Champion; + + + if (dir == _vm->_dungeonMan->_g308_partyDir) { + return; + } + if ((L0834_i_Delta = dir - _vm->_dungeonMan->_g308_partyDir) < 0) { + L0834_i_Delta += 4; + } + L0835_ps_Champion = _gK71_champions; + for (L0833_i_ChampionIndex = k0_ChampionFirst; L0833_i_ChampionIndex < _g305_partyChampionCount; L0833_i_ChampionIndex++) { + L0835_ps_Champion->_cell = (ViewCell)M21_normalizeModulo4(L0835_ps_Champion->_cell + L0834_i_Delta); + L0835_ps_Champion->_dir = (direction)M21_normalizeModulo4(L0835_ps_Champion->_dir + L0834_i_Delta); + L0835_ps_Champion++; + } + _vm->_dungeonMan->_g308_partyDir = (direction)dir; + f296_drawChangedObjectIcons(); +} + +void ChampionMan::f316_deleteScent(uint16 scentIndex) { + uint16 L0953_ui_Count; + + if (L0953_ui_Count = --_g407_party._scentCount - scentIndex) { + for (uint16 i = 0; i < L0953_ui_Count; ++i) { + _g407_party._scents[scentIndex + i] = _g407_party._scents[scentIndex + i + 1]; + _g407_party._scentStrengths[scentIndex + i] = _g407_party._scentStrengths[scentIndex + i + 1]; + } + } + if (scentIndex < _g407_party._firstScentIndex) { + _g407_party._firstScentIndex--; + } + if (scentIndex < _g407_party._lastScentIndex) { + _g407_party._lastScentIndex--; + } +} + +void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount) { + int16 L0954_i_ScentIndex; + bool L0955_B_Merge; + bool L0956_B_CycleCountDefined; + Scent* L0957_ps_Scent; /* BUG0_00 Useless code */ + Scent L0958_s_Scent; /* BUG0_00 Useless code */ + + + if (L0954_i_ScentIndex = _vm->_championMan->_g407_party._scentCount) { + if (L0955_B_Merge = getFlag(cycleCount, k0x8000_mergeCycles)) { + clearFlag(cycleCount, k0x8000_mergeCycles); + } + L0958_s_Scent.setMapX(mapX); /* BUG0_00 Useless code */ + L0958_s_Scent.setMapY(mapY); /* BUG0_00 Useless code */ + L0958_s_Scent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */ + L0957_ps_Scent = _vm->_championMan->_g407_party._scents; /* BUG0_00 Useless code */ + L0956_B_CycleCountDefined = false; + while (L0954_i_ScentIndex--) { + if (&*L0957_ps_Scent++ == &L0958_s_Scent) { + if (!L0956_B_CycleCountDefined) { + L0956_B_CycleCountDefined = true; + if (L0955_B_Merge) { + cycleCount = MAX((int32)_vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount); + } else { + cycleCount = MIN(80, _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount); + } + } + _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount; + } + } + } +} + +void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) { + if (thing == Thing::_none) { + return; + } + _vm->_championMan->_g415_leaderEmptyHanded = false; + _vm->_objectMan->f36_extractIconFromBitmap(_vm->_championMan->_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_vm->_championMan->_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer); + _vm->_eventMan->f78_showMouse(); + _vm->_objectMan->f34_drawLeaderObjectName(thing); + if (setMousePointer) { + _vm->_g325_setMousePointerToObjectInMainLoop = true; + } else { + _vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer); + } + _vm->_eventMan->f77_hideMouse(); + if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) { + _vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing); + setFlag(_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad); + _vm->_championMan->f292_drawChampionState(_vm->_championMan->_g411_leaderIndex); + } +} + +ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) { for (uint16 i = 0; i < _g305_partyChampionCount; ++i) { if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth) return (ChampionIndex)i; @@ -685,7 +1384,7 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) { } else { barGraphHeightArray[barGraphIndex++] = 0; } - warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + _vm->_eventMan->f78_showMouse(); Box box; box._x1 = champIndex * k69_ChampionStatusBoxSpacing + 46; @@ -708,7 +1407,7 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) { box._x1 += 7; box._x2 += 7; } - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + _vm->_eventMan->f77_hideMouse(); } @@ -918,7 +1617,7 @@ T0292042_green: champ->setAttributeFlag((ChampionAttribute)(k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand), false); - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + _vm->_eventMan->f78_showMouse(); } uint16 ChampionMan::M26_championIconIndex(int16 val, direction dir) { @@ -931,7 +1630,7 @@ void ChampionMan::f290_drawHealthStaminaManaValues(Champion* champ) { f289_drawHealthOrStaminaOrManaValue(132, champ->_currMana, champ->_maxMana); } -void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) { +void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) { int16 nativeBitmapIndex = -1; Champion *champ = &_gK71_champions[champIndex]; bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)); @@ -950,7 +1649,7 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) { if (slotIndex >= k30_ChampionSlotChest_1) { thing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1]; } else { - thing = champ->getSlot(slotIndex); + thing = champ->getSlot((ChampionSlot)slotIndex); } SlotBox *slotBox = &_vm->_objectMan->_g30_slotBoxes[slotBoxIndex]; @@ -962,7 +1661,7 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) { if (!isInventoryChamp) { - warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + _vm->_eventMan->f77_hideMouse(); } int16 iconIndex; @@ -983,10 +1682,8 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) { } } } else { - warning("BUG0_35"); iconIndex = _vm->_objectMan->f33_getIconIndex(thing); // BUG0_35 if (isInventoryChamp && (slotIndex == k1_ChampionSlotActionHand) && ((iconIndex == k144_IconIndiceContainerChestClosed) || (iconIndex == k30_IconIndiceScrollOpen))) { - warning("BUG2_00"); iconIndex++; } // BUG2_00 if (slotIndex <= k5_ChampionSlotFeet) { @@ -1016,7 +1713,7 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex) { _vm->_objectMan->f38_drawIconInSlotBox(slotBoxIndex, iconIndex); if (!isInventoryChamp) { - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + _vm->_eventMan->f78_showMouse(); } } @@ -1049,7 +1746,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) { } } -uint16 ChampionMan::f303_getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex) { +uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, int16 skillIndex) { if (_g300_partyIsSleeping) return 1; @@ -1057,7 +1754,7 @@ uint16 ChampionMan::f303_getSkillLevel(ChampionIndex champIndex, ChampionSkill s bool ignoreObjModifiers = skillIndex & k0x4000_IgnoreObjectModifiers; skillIndex = (ChampionSkill)(skillIndex & ~(ignoreTempExp | ignoreObjModifiers)); Champion *champ = &_gK71_champions[champIndex]; - Skill *skill = &champ->getSkill(skillIndex); + Skill *skill = &champ->getSkill((ChampionSkill)skillIndex); int32 experience = skill->_experience; if (!ignoreTempExp) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 43e976e543..282889d09e 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -328,6 +328,14 @@ enum ChampionAction { k255_ChampionActionNone = 255 // @ C255_ACTION_NONE }; +#define k0_attackType_NORMAL 0 // @ C0_ATTACK_NORMAL +#define k1_attackType_FIRE 1 // @ C1_ATTACK_FIRE +#define k2_attackType_SELF 2 // @ C2_ATTACK_SELF +#define k3_attackType_BLUNT 3 // @ C3_ATTACK_BLUNT +#define k4_attackType_SHARP 4 // @ C4_ATTACK_SHARP +#define k5_attackType_MAGIC 5 // @ C5_ATTACK_MAGIC +#define k6_attackType_PSYCHIC 6 // @ C6_ATTACK_PSYCHIC +#define k7_attackType_LIGHTNING 7 // @ C7_ATTACK_LIGHTNING class Skill { public: @@ -338,12 +346,12 @@ public: }; // @ SKILL class Champion { - Thing _slots[30]; - Skill _skills[20]; +public: uint16 _attributes; - byte _statistics[7][3]; uint16 _wounds; -public: + byte _statistics[7][3]; + Thing _slots[30]; + Skill _skills[20]; char _name[8]; char _title[20]; direction _dir; @@ -425,16 +433,23 @@ public: } }; // @ CHAMPION_INCLUDING_PORTRAIT +#define k0x0000_maskDoNotUseSharpDefense 0x0000 // @ MASK0x0000_DO_NOT_USE_SHARP_DEFENSE +#define k0x8000_maskUseSharpDefense 0x8000 // @ MASK0x8000_USE_SHARP_DEFENSE + +#define k0x8000_mergeCycles 0x8000 // @ MASK0x8000_MERGE_CYCLES +extern const char *g417_baseSkillName[4]; + class ChampionMan { DMEngine *_vm; uint16 M27_getChampionPortraitX(uint16 index); // @ M27_PORTRAIT_X uint16 M28_getChampionPortraitY(uint16 index); // @ M28_PORTRAIT_Y - ChampionIndex f285_getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell int16 f279_getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue void f289_drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue uint16 M70_handSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX + int16 _g410_championPendingWounds[4]; // @ G0410_ai_ChampionPendingWounds + int16 _g409_championPendingDamage[4]; // @ G0409_ai_ChampionPendingDamage public: Champion _gK71_champions[4]; // @ K0071_as_Champions uint16 _g305_partyChampionCount; // @ G0305_ui_PartyChampionCount @@ -451,6 +466,9 @@ public: bool _g420_mousePointerHiddenToDrawChangedObjIconOnScreen; // @ G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen explicit ChampionMan(DMEngine *vm); + ChampionIndex f285_getIndexInCell(int16 cell); // @ F0285_CHAMPION_GetIndexInCell + bool f329_isLeaderHandObjectThrown(int16 side); // @ F0329_CHAMPION_IsLeaderHandObjectThrown + bool f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side); // @ F0328_CHAMPION_IsObjectThrown void f278_resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame void f280_addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty void f287_drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs @@ -459,16 +477,42 @@ public: void f292_drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState uint16 M26_championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX void f290_drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues - void f291_drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot + void f291_drawSlot(uint16 champIndex, int16 slotIndex); // @ F0291_CHAMPION_DrawSlot void f281_renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename - uint16 f303_getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel + uint16 f303_getSkillLevel(int16 champIndex, int16 skillIndex);// @ F0303_CHAMPION_GetSkillLevel Common::String f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger - void f299_applyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex, + void f299_applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics bool f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged void f296_drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons void f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot int16 f315_getScentOrdinal(int16 mapX, int16 mapY); // @ F0315_CHAMPION_GetScentOrdinal + Thing f298_getObjectRemovedFromLeaderHand(); // @ F0298_CHAMPION_GetObjectRemovedFromLeaderHand + uint16 f312_getStrength(int16 champIndex, int16 slotIndex); // @ F0312_CHAMPION_GetStrength + Thing f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex); // @ F0300_CHAMPION_GetObjectRemovedFromSlot + void f325_decrementStamine(int16 championIndex, int16 decrement); // @ F0325_CHAMPION_DecrementStamina + int16 f321_addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, + uint16 attackType); // @ F0321_CHAMPION_AddPendingDamageAndWounds_GetDamage + int16 f313_getWoundDefense(int16 champIndex, uint16 woundIndex); // @ F0313_CHAMPION_GetWoundDefense + uint16 f307_getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack); // @ F0307_CHAMPION_GetStatisticAdjustedAttack + void f314_wakeUp(); // @ F0314_CHAMPION_WakeUp + int16 f305_getThrowingStaminaCost(Thing thing);// @ F0305_CHAMPION_GetThrowingStaminaCost + void f330_disableAction(uint16 champIndex, uint16 ticks); // @ F0330_CHAMPION_DisableAction + void f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp);// @ F0304_CHAMPION_AddSkillExperience + int16 f324_damageAll_getDamagedChampionCount(uint16 attack, int16 wounds, + int16 attackType); // @ F0324_CHAMPION_DamageAll_GetDamagedChampionCount + int16 f286_getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell); // @ F0286_CHAMPION_GetTargetChampionIndex + int16 f311_getDexterity(Champion *champ); // @ F0311_CHAMPION_GetDexterity + bool f308_isLucky(Champion *champ, uint16 percentage); // @ F0308_CHAMPION_IsLucky + void f322_championPoison(int16 championIndex, uint16 attack); // @ F0322_CHAMPION_Poison + void f284_setPartyDirection(int16 dir); // @ F0284_CHAMPION_SetPartyDirection + void f316_deleteScent(uint16 scentIndex); // @ F0316_CHAMPION_DeleteScent + void f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount); // @ F0317_CHAMPION_AddScentStrength + void f297_putObjectInLeaderHand(Thing thing, bool setMousePointer); // @ F0297_CHAMPION_PutObjectInLeaderHand + + + + }; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index d824cf349a..51b33c321d 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -51,6 +51,7 @@ #include "movesens.h" #include "group.h" #include "timeline.h" +#include "projexpl.h" namespace DM { @@ -68,18 +69,11 @@ uint16 returnNextVal(uint16 val) { bool isOrientedWestEast(direction dir) { return dir & 1; } -uint16 getFlag(uint16 val, uint16 mask) { - return val & mask; -} uint16 setFlag(uint16 &val, uint16 mask) { return val |= mask; } -uint16 clearFlag(uint16 &val, uint16 mask) { - return val &= ~mask; -} - uint16 toggleFlag(uint16& val, uint16 mask) { return val ^= mask; } @@ -92,6 +86,26 @@ uint16 M21_normalizeModulo4(uint16 val) { return val & 3; } +int32 M30_time(int32 map_time) { + return map_time & 0x00FFFFFF; +} + +int32 M33_setMapAndTime(int32 &map_time, uint32 map, uint32 time) { + return (map_time) = ((time) | (((long)(map)) << 24)); +} + +uint16 M29_map(int32 map_time) { + return ((uint16)((map_time) >> 24)); +} + +Thing M15_thingWithNewCell(Thing thing, int16 cell) { + return Thing(((thing.toUint16()) & 0x3FFF) | ((cell) << 14)); +} + +int16 M38_distance(int16 mapx1, int16 mapy1, int16 mapx2, int16 mapy2) { + return ABS(mapx1 - mapx2) + ABS(mapy1 - mapy2); +} + DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { // Do not load data files // Do not initialize graphics here @@ -118,6 +132,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _movsens = nullptr; _groupMan = nullptr; _timeline = nullptr; + _projexpl = nullptr; _g321_stopWaitingForPlayerInput = false; _g301_gameTimeTicking = false; _g524_restartGameAllowed = false; @@ -126,6 +141,9 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _g332_stopPressingEye = false; _g334_stopPressingMouth = false; _g340_highlightBoxInversionRequested = false; + _g313_gameTime = 0; + _g302_gameWon = false; + _g327_newPartyMapIndex = kM1_mapIndexNone; debug("DMEngine::DMEngine"); } @@ -148,11 +166,20 @@ DMEngine::~DMEngine() { delete _movsens; delete _groupMan; delete _timeline; + delete _projexpl; // clear debug channels DebugMan.clearAllDebugChannels(); } +void DMEngine::waitMs(uint16 ms) { + _system->delayMillis(ms * 20); +} + +uint16 DMEngine::f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2) { + return ((uint32)val * vale2) >> scale; +} + void DMEngine::f463_initializeGame() { _displayMan->f479_loadGraphics(); _displayMan->f460_initializeGraphicData(); @@ -174,8 +201,8 @@ void DMEngine::f463_initializeGame() { f462_startGame(); warning("MISSING CODE: F0267_MOVE_GetMoveResult_CPSCE (if newGame)"); - _eventMan->showMouse(true); - warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); + _eventMan->f78_showMouse(); + _eventMan->f357_discardAllInput(); } void DMEngine::f448_initMemoryManager() { @@ -220,7 +247,7 @@ void DMEngine::f3_processNewPartyMap(uint16 mapIndex) { _dungeonMan->f174_setCurrentMapAndPartyMap(mapIndex); _displayMan->f96_loadCurrentMapGraphics(); warning("MISSING CODE: F0195_GROUP_AddAllActiveGroups"); - warning("MISSING CODE: F0337_INVENTORY_SetDungeonViewPalette"); + _inventoryMan->f337_setDungeonViewPalette(); } Common::Error DMEngine::run() { @@ -241,6 +268,7 @@ Common::Error DMEngine::run() { _movsens = new MovesensMan(this); _groupMan = new GroupMan(this); _timeline = new Timeline(this); + _projexpl = new ProjExpl(this); _displayMan->setUpScreens(320, 200); f463_initializeGame(); // @ F0463_START_InitializeGame_CPSADEF @@ -257,16 +285,19 @@ void DMEngine::f2_gameloop() { _dungeonMan->_g306_partyMapX = 10; _dungeonMan->_g307_partyMapY = 4; _dungeonMan->_g308_partyDir = kDirNorth; - - warning("DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero"); _inventoryMan->_g432_inventoryChampionOrdinal = 0; warning("DUMMY CODE: clearing screen to black"); // in loop below + while (true) { - _g321_stopWaitingForPlayerInput = false; + _g313_gameTime++; _menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived(); + if (_g311_projectileDisableMovementTicks) + _g311_projectileDisableMovementTicks--; + + _g321_stopWaitingForPlayerInput = false; //do { _eventMan->processInput(); _eventMan->f380_processCommandQueue(); @@ -278,12 +309,8 @@ void DMEngine::f2_gameloop() { _displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); } - // DUMMY CODE: next 2 lines - _menuMan->f395_drawMovementArrows(); - _displayMan->f97_drawViewport(k1_viewportDungeonView); - _displayMan->updateScreen(); - _system->delayMillis(10); + _system->delayMillis(18); } } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index c4fe3c5ce1..9ace815f51 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -48,6 +48,8 @@ class TextMan; class MovesensMan; class GroupMan; class Timeline; +class ProjExpl; + enum direction { @@ -57,50 +59,26 @@ enum direction { kDirWest = 3 }; -void turnDirRight(direction &dir); -void turnDirLeft(direction &dir); -direction returnOppositeDir(direction dir); // @ M18_OPPOSITE -uint16 returnPrevVal(uint16 val); // @ M19_PREVIOUS -uint16 returnNextVal(uint16 val); // @ M17_NEXT -bool isOrientedWestEast(direction dir); // @ M16_IS_ORIENTED_WEST_EAST - - -uint16 getFlag(uint16 val, uint16 mask); // @ M07_GET -uint16 setFlag(uint16 &val, uint16 mask); // @ M08_SET -uint16 clearFlag(uint16 &val, uint16 mask); // @ M09_CLEAR -uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE -uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height); // @ M75_BITMAP_BYTE_COUNT -uint16 M21_normalizeModulo4(uint16 val); // @ M21_NORMALIZE enum ThingType { - kM1_PartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value - k0_DoorThingType = 0, - k1_TeleporterThingType = 1, - k2_TextstringType = 2, - k3_SensorThingType = 3, - k4_GroupThingType = 4, - k5_WeaponThingType = 5, - k6_ArmourThingType = 6, - k7_ScrollThingType = 7, - k8_PotionThingType = 8, - k9_ContainerThingType = 9, - k10_JunkThingType = 10, - k14_ProjectileThingType = 14, - k15_ExplosionThingType = 15, + kM1_PartyThingType = -1, // @ CM1_THING_TYPE_PARTY + k0_DoorThingType = 0, // @ C00_THING_TYPE_DOOR + k1_TeleporterThingType = 1, // @ C01_THING_TYPE_TELEPORTER + k2_TextstringType = 2, // @ C02_THING_TYPE_TEXTSTRING + k3_SensorThingType = 3, // @ C03_THING_TYPE_SENSOR + k4_GroupThingType = 4, // @ C04_THING_TYPE_GROUP + k5_WeaponThingType = 5, // @ C05_THING_TYPE_WEAPON + k6_ArmourThingType = 6, // @ C06_THING_TYPE_ARMOUR + k7_ScrollThingType = 7, // @ C07_THING_TYPE_SCROLL + k8_PotionThingType = 8, // @ C08_THING_TYPE_POTION + k9_ContainerThingType = 9, // @ C09_THING_TYPE_CONTAINER + k10_JunkThingType = 10, // @ C10_THING_TYPE_JUNK + k14_ProjectileThingType = 14, // @ C14_THING_TYPE_PROJECTILE + k15_ExplosionThingType = 15, // @ C15_THING_TYPE_EXPLOSION k16_ThingTypeTotal = 16 // +1 than the last (explosionThingType) }; // @ C[00..15]_THING_TYPE_... -enum Cell { - kM1_CellAny = -1, // @ CM1_CELL_ANY - k0_CellNorthWest = 0, // @ C00_CELL_NORTHWEST - k1_CellNorthEast = 1, // @ C01_CELL_NORTHEAST - k2_CellSouthEast = 2, // @ C02_CELL_SOUTHEAST - k3_CellSouthWest = 3 // @ C03_CELL_SOUTHWEST -}; - -#define kM1_mapIndexNone -1 // @ CM1_MAP_INDEX_NONE -#define k255_mapIndexEntrance 255 // @ C255_MAP_INDEX_ENTRANCE class Thing { uint16 _data; @@ -131,12 +109,52 @@ public: byte getCell() const { return _data >> 14; } ThingType getType() const { return (ThingType)((_data >> 10) & 0xF); } uint16 getIndex() const { return _data & 0x3FF; } + uint16 getTypeAndIndex() { return _data & 0x3FFF; } uint16 toUint16() const { return _data; } // I don't like 'em cast operators bool operator==(const Thing &rhs) const { return _data == rhs._data; } bool operator!=(const Thing &rhs) const { return _data != rhs._data; } }; // @ THING + +void turnDirRight(direction &dir); +void turnDirLeft(direction &dir); +direction returnOppositeDir(direction dir); // @ M18_OPPOSITE +uint16 returnPrevVal(uint16 val); // @ M19_PREVIOUS +uint16 returnNextVal(uint16 val); // @ M17_NEXT +bool isOrientedWestEast(direction dir); // @ M16_IS_ORIENTED_WEST_EAST + + +uint16 setFlag(uint16 &val, uint16 mask); // @ M08_SET + + +#define getFlag(val, mask) ((val) & (mask)) + + +#define clearFlag(val, mask) ((val) &= (~(mask))) // @ M09_CLEAR + +uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE +uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height); // @ M75_BITMAP_BYTE_COUNT +uint16 M21_normalizeModulo4(uint16 val); // @ M21_NORMALIZE +int32 M30_time(int32 map_time); // @ M30_TIME +int32 M33_setMapAndTime(int32 &map_time, uint32 map, uint32 time); // @ M33_SET_MAP_AND_TIME +uint16 M29_map(int32 map_time); // @ M29_MAP +Thing M15_thingWithNewCell(Thing thing, int16 cell); // @ M15_THING_WITH_NEW_CELL +int16 M38_distance(int16 mapx1, int16 mapy1, int16 mapx2, int16 mapy2);// @ M38_DISTANCE + + +enum Cell { + kM1_CellAny = -1, // @ CM1_CELL_ANY + k0_CellNorthWest = 0, // @ C00_CELL_NORTHWEST + k1_CellNorthEast = 1, // @ C01_CELL_NORTHEAST + k2_CellSouthEast = 2, // @ C02_CELL_SOUTHEAST + k3_CellSouthWest = 3 // @ C03_CELL_SOUTHWEST +}; + +#define kM1_mapIndexNone -1 // @ CM1_MAP_INDEX_NONE +#define k255_mapIndexEntrance 255 // @ C255_MAP_INDEX_ENTRANCE + + enum { // engine debug channels kDMDebugExample = 1 << 0, @@ -144,6 +162,17 @@ enum { kDMDebugOftenCalledWarning = 2 << 2 }; + + + +template +inline T f26_getBoundedValue(T min, T val, T max) { + return MIN(MAX(min, val), max); +} // @ F0026_MAIN_GetBoundedValue + +#define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember)) + + class DMEngine : public Engine { void f462_startGame(); // @ F0462_START_StartGame_CPSF void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE @@ -156,8 +185,12 @@ public: explicit DMEngine(OSystem *syst); ~DMEngine(); + void waitMs(uint16 ms); + uint16 f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2); // @ F0030_MAIN_GetScaledProduct + uint16 getRandomNumber(uint32 max) { return _rnd->getRandomNumber(max - 1); } int16 M1_ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX int16 M0_indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL + void f19_displayErrorAndStop(int16 errorIndex); // @ F0019_MAIN_DisplayErrorAndStop virtual Common::Error run(); // @ main private: @@ -176,6 +209,7 @@ public: MovesensMan *_movsens; GroupMan *_groupMan; Timeline *_timeline; + ProjExpl *_projexpl; bool _g298_newGame; // @ G0298_B_NewGame @@ -190,10 +224,17 @@ public: bool _g333_pressingMouth; // @ G0333_B_PressingMouth bool _g334_stopPressingMouth; // @ G0334_B_StopPressingMouth bool _g340_highlightBoxInversionRequested; // @ G0340_B_HighlightBoxInversionRequested + int16 _g311_projectileDisableMovementTicks; // @ G0311_i_ProjectileDisabledMovementTicks + int16 _g312_lastProjectileDisabledMovementDirection; // @ G0312_i_LastProjectileDisabledMovementDirection + bool _g302_gameWon; // @ G0302_B_GameWon + int16 _g327_newPartyMapIndex; // @ G0327_i_NewPartyMapIndex + bool _g325_setMousePointerToObjectInMainLoop; // @ G0325_B_SetMousePointerToObjectInMainLoop // TODO: refactor direction into a class int8 _dirIntoStepCountEast[4]; // @ G0233_ai_Graphic559_DirectionToStepEastCount int8 _dirIntoStepCountNorth[4]; // @ G0234_ai_Graphic559_DirectionToStepNorthCount + uint32 _g313_gameTime; // @ G0313_ul_GameTime + char _g353_stringBuildBuffer[128]; // @ G0353_ac_StringBuildBuffer }; class Console : public GUI::Debugger { diff --git a/engines/dm/dmglobals.cpp b/engines/dm/dmglobals.cpp index c138453c31..044659aa2e 100644 --- a/engines/dm/dmglobals.cpp +++ b/engines/dm/dmglobals.cpp @@ -25,6 +25,7 @@ * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) */ +#include "common/system.h" #include "dm/dm.h" #include "gfx.h" #include "dungeonman.h" @@ -36,6 +37,8 @@ #include "inventory.h" #include "text.h" #include "movesens.h" +#include "string.h" + namespace DM { @@ -52,4 +55,12 @@ void DMEngine::initArrays() { _dirIntoStepCountNorth[2] = 1; // West _dirIntoStepCountNorth[3] = 0; // South } + +void DMEngine::f19_displayErrorAndStop(int16 errorIndex) { + debug("Stuff hit the fun: "); + debug(Common::String::format("%d", errorIndex).c_str()); + Common::Event event; + while (_system->getEventManager()->pollEvent(event) || true) + ; +} } // End of namespace DM diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index fa0e72c4ba..ca7785652b 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -31,7 +31,9 @@ #include "dungeonman.h" #include "timeline.h" #include "champion.h" - +#include "group.h" +#include "movesens.h" +#include "projexpl.h" namespace DM { @@ -835,11 +837,11 @@ void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 #define footprintsAllowed L0307_uc_Multiple #define scentOrdinal L0307_uc_Multiple Sensor* sensor; - bool leftRandWallOrnAllowed; - int16 L0310_i_Multiple; + bool leftRandWallOrnAllowed = false; + int16 L0310_i_Multiple = 0; #define frontRandWallOrnAllowed L0310_i_Multiple #define sideIndex L0310_i_Multiple - bool rightRandWallOrnAllowed; + bool rightRandWallOrnAllowed = false; int16 thingTypeRedEagle; bool squreIsFakeWall; Thing thing; @@ -946,12 +948,12 @@ T0172030_Pit: aspectArray[k2_TeleporterVisibleAspect] = getFlag(square, k0x0008_TeleporterOpen) && getFlag(square, k0x0004_TeleporterVisible); goto T0172029_Teleporter; case k3_ElementTypeStairs: - aspectArray[k0_ElemAspect] = ((getFlag(square, k0x0008_StairsNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront; + aspectArray[k0_ElemAspect] = (((getFlag(square, k0x0008_StairsNorthSouthOrient) >> 3) ? true : false) == isOrientedWestEast(dir)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront; aspectArray[k2_StairsUpAspect] = getFlag(square, k0x0004_StairsUp); footprintsAllowed = false; goto T0172046_Stairs; case k4_DoorElemType: - if ((getFlag(square, k0x0008_DoorNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) { + if (((getFlag(square, k0x0008_DoorNorthSouthOrient) >> 3) ? true : false) == isOrientedWestEast(dir)) { aspectArray[k0_ElemAspect] = k16_DoorSideElemType; } else { aspectArray[k0_ElemAspect] = k17_DoorFrontElemType; @@ -1190,6 +1192,45 @@ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) { *destString = ((type == k0_TextTypeInscription) ? 0x81 : '\0'); } +Thing DungeonMan::f166_getUnusedThing(uint16 thingType) { + int16 L0288_i_ThingIndex; + int16 L0289_i_ThingDataByteCount; + int16 L0290_i_ThingCount; + Thing* L0291_ps_Generic; + Thing L0292_T_Thing; + + + L0290_i_ThingCount = _vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[getFlag(thingType, k0x7FFF_thingType)]; + if (thingType == (k0x8000_championBones | k10_JunkThingType)) { + thingType = k10_JunkThingType; + } else { + if (thingType == k10_JunkThingType) { + L0290_i_ThingCount -= 3; /* Always keep 3 unused JUNK things for the bones of dead champions */ + } + } + L0288_i_ThingIndex = L0290_i_ThingCount; + L0289_i_ThingDataByteCount = g235_ThingDataWordCount[thingType] >> 1; + L0291_ps_Generic = (Thing*)_vm->_dungeonMan->_g284_thingData[thingType]; + for (;;) { /*_Infinite loop_*/ + if (*L0291_ps_Generic == Thing::_none) { /* If thing data is unused */ + L0292_T_Thing = Thing((thingType << 10) | (L0290_i_ThingCount - L0288_i_ThingIndex)); + break; + } + if (--L0288_i_ThingIndex) { /* If there are thing data left to process */ + L0291_ps_Generic += L0289_i_ThingDataByteCount; /* Proceed to the next thing data */ + } else { + if ((L0292_T_Thing = f165_getDiscardTHing(thingType)) == Thing::_none) { + return Thing::_none; + } + L0291_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0292_T_Thing); + break; + } + } + memset(L0291_ps_Generic, 0, L0289_i_ThingDataByteCount * 2); + + *L0291_ps_Generic = Thing::_endOfList; + return L0292_T_Thing; +} uint16 DungeonMan::f140_getObjectWeight(Thing thing) { static const uint16 g241_junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo @@ -1381,4 +1422,293 @@ int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDe } return kM1_mapIndexNone; } + +Thing DungeonMan::f162_getSquareFirstObject(int16 mapX, int16 mapY) { + Thing thing = f161_getSquareFirstThing(mapX, mapY); + while ((thing != Thing::_endOfList) && (thing.getType() < k4_GroupThingType)) { + thing = f159_getNextThing(thing); + } + return thing; +} + +uint16 DungeonMan::f143_getArmourDefense(ArmourInfo* armourInfo, bool useSharpDefense) { + uint16 L0244_ui_Defense; + + L0244_ui_Defense = armourInfo->_defense; + if (useSharpDefense) { + L0244_ui_Defense = _vm->f30_getScaledProduct(L0244_ui_Defense, 3, getFlag(armourInfo->_attributes, k0x0007_ArmourAttributeSharpDefense) + 4); + } + return L0244_ui_Defense; +} + +Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) { + uint16 L0276_ui_MapX; + uint16 L0277_ui_MapY; + Thing L0278_T_Thing; + uint16 L0279_ui_MapIndex; + byte* L0280_puc_Square; + Thing* L0281_pT_SquareFirstThing; + Thing* L0282_ps_Generic; + uint16 L0283_ui_DiscardThingMapIndex; + int L0284_i_CurrentMapIndex; + uint16 L0285_ui_MapWidth; + uint16 L0286_ui_MapHeight; + int L0287_i_ThingType; + static unsigned char G0294_auc_LastDiscardedThingMapIndex[16]; + + + if (thingType == k15_ExplosionThingType) { + return Thing::_none; + } + L0284_i_CurrentMapIndex = _vm->_dungeonMan->_g272_currMapIndex; + if (((L0279_ui_MapIndex = G0294_auc_LastDiscardedThingMapIndex[thingType]) == _vm->_dungeonMan->_g309_partyMapIndex) && (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount)) { + L0279_ui_MapIndex = 0; + } + L0283_ui_DiscardThingMapIndex = L0279_ui_MapIndex; + for (;;) { /*_Infinite loop_*/ + L0285_ui_MapWidth = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._width; + L0286_ui_MapHeight = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._height; + L0280_puc_Square = _vm->_dungeonMan->_g279_dungeonMapData[L0279_ui_MapIndex][0]; + L0281_pT_SquareFirstThing = &_vm->_dungeonMan->_g283_squareFirstThings[_vm->_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[L0279_ui_MapIndex]]]; + for (L0276_ui_MapX = 0; L0276_ui_MapX <= L0285_ui_MapWidth; L0276_ui_MapX++) { + for (L0277_ui_MapY = 0; L0277_ui_MapY <= L0286_ui_MapHeight; L0277_ui_MapY++) { + if (getFlag(*L0280_puc_Square++, k0x0010_ThingListPresent)) { + L0278_T_Thing = *L0281_pT_SquareFirstThing++; + if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && ((L0276_ui_MapX - _vm->_dungeonMan->_g306_partyMapX + 5) <= 10) && ((L0277_ui_MapY - _vm->_dungeonMan->_g307_partyMapY + 5) <= 10)) /* If square is too close to the party */ + goto T0165029; + do { + if ((L0287_i_ThingType = (L0278_T_Thing).getType()) == k3_SensorThingType) { + L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing); + if (((Sensor*)L0282_ps_Generic)->getType()) /* If sensor is not disabled */ + break; + } else { + if (L0287_i_ThingType == thingType) { + L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing); + switch (thingType) { + case k4_GroupThingType: + if (((Group*)L0282_ps_Generic)->getDoNotDiscard()) + continue; + case k14_ProjectileThingType: + _vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex); + if (thingType == k4_GroupThingType) { + _vm->_groupMan->f188_dropGroupPossessions(L0276_ui_MapX, L0277_ui_MapY, L0278_T_Thing, kM1_soundModeDoNotPlaySound); + _vm->_groupMan->f189_delete(L0276_ui_MapX, L0277_ui_MapY); + } else { + _vm->_projexpl->f214_projectileDeleteEvent(L0278_T_Thing); + f164_unlinkThingFromList(L0278_T_Thing, Thing(0), L0276_ui_MapX, L0277_ui_MapY); + _vm->_projexpl->f215_projectileDelete(L0278_T_Thing, 0, L0276_ui_MapX, L0277_ui_MapY); + } + break; + case k6_ArmourThingType: + if (((Armour*)L0282_ps_Generic)->getDoNotDiscard()) + continue; + goto T0165026; + case k5_WeaponThingType: + if (((Weapon*)L0282_ps_Generic)->getDoNotDiscard()) + continue; + goto T0165026; + case k10_JunkThingType: + if (((Junk*)L0282_ps_Generic)->getDoNotDiscard()) + continue; + goto T0165026; + case k8_PotionThingType: + if (((Potion*)L0282_ps_Generic)->getDoNotDiscard()) + continue; +T0165026: + _vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex); + _vm->_movsens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0); + } + _vm->_dungeonMan->f173_setCurrentMap(L0284_i_CurrentMapIndex); + G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex; + return Thing((L0278_T_Thing).getTypeAndIndex()); + } + } + } while ((L0278_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0278_T_Thing)) != Thing::_endOfList); +T0165029: + ; + } + } + } + if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) || (_vm->_dungeonMan->_g278_dungeonFileHeader._mapCount <= 1)) { + G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex; + return Thing::_none; + } + do { + if (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount) { + L0279_ui_MapIndex = 0; + } + } while (L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex); + if (L0279_ui_MapIndex == L0283_ui_DiscardThingMapIndex) { + L0279_ui_MapIndex = _vm->_dungeonMan->_g309_partyMapIndex; + } + } +} + +uint16 DungeonMan::f144_getCreatureAttributes(Thing thing) { + Group* L0245_ps_Group; + + L0245_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing); + return g243_CreatureInfo[L0245_ps_Group->_type]._attributes; +} + +void DungeonMan::f146_setGroupCells(Group* group, uint16 cells, uint16 mapIndex) { + if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) { + _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._cells = cells; + } else { + group->_cells = cells; + } +} + +void DungeonMan::f148_setGroupDirections(Group* group, int16 dir, uint16 mapIndex) { + if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) { + _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (direction)dir; + } else { + group->setDir(M21_normalizeModulo4(dir)); + } +} + +bool DungeonMan::f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) { + int16 L0234_i_Counter; + int16 L0235_i_CreatureType; + byte* L0236_puc_Multiple; +#define AL0236_puc_Group L0236_puc_Multiple +#define AL0236_puc_AllowedCreatureType L0236_puc_Multiple + Map* L0237_ps_Map; + + L0235_i_CreatureType = ((Group*)_vm->_dungeonMan->f156_getThingData(thing))->_type; + L0237_ps_Map = &_vm->_dungeonMan->_g277_dungeonMaps[mapIndex]; + AL0236_puc_AllowedCreatureType = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][L0237_ps_Map->_width] + L0237_ps_Map->_height + 1; + for (L0234_i_Counter = L0237_ps_Map->_creatureTypeCount; L0234_i_Counter > 0; L0234_i_Counter--) { + if (*AL0236_puc_AllowedCreatureType++ == L0235_i_CreatureType) { + return true; + } + } + return false; +} + +void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY) { + uint16 L0271_ui_SquareFirstThingIndex; + uint16 L0272_ui_Multiple; +#define AL0272_ui_SquareFirstThingIndex L0272_ui_Multiple +#define AL0272_ui_Column L0272_ui_Multiple + Thing L0273_T_Thing; + Thing* L0274_ps_Generic = nullptr; + Thing* L0275_pui_Multiple = nullptr; +#define AL0275_pT_Thing L0275_pui_Multiple +#define AL0275_pui_CumulativeFirstThingCount L0275_pui_Multiple + + + if (thingToUnlink == Thing::_endOfList) { + return; + } + + { + uint16 tmp = thingToUnlink.toUint16(); + clearFlag(tmp, 0xC000); + thingToUnlink = Thing(tmp); + } + + if (mapX >= 0) { + L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink); + AL0275_pT_Thing = &_vm->_dungeonMan->_g283_squareFirstThings[L0271_ui_SquareFirstThingIndex = _vm->_dungeonMan->f160_getSquareFirstThingIndex(mapX, mapY)]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. _vm->_dungeonMan->f160_getSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */ + if ((*L0274_ps_Generic == Thing::_endOfList) && (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16())) { /* If the thing to unlink is the last thing on the square */ + clearFlag(_vm->_dungeonMan->_g271_currMapData[mapX][mapY], k0x0010_ThingListPresent); + AL0272_ui_SquareFirstThingIndex = _vm->_dungeonMan->_g278_dungeonFileHeader._squareFirstThingCount - 1; + for (uint16 i = 0; i < AL0272_ui_SquareFirstThingIndex - L0271_ui_SquareFirstThingIndex; ++i) + AL0275_pT_Thing[i] = AL0275_pT_Thing[i + 1]; + + _vm->_dungeonMan->_g283_squareFirstThings[AL0272_ui_SquareFirstThingIndex] = Thing::_none; + AL0275_pui_CumulativeFirstThingCount = (Thing*)_vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount + mapX + 1; + AL0272_ui_Column = _vm->_dungeonMan->_g282_dungeonColumCount - (_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[_vm->_dungeonMan->_g272_currMapIndex] + mapX) - 1; + while (AL0272_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is unlinked */ + (*(uint16*)AL0275_pui_CumulativeFirstThingCount++)--; /* Decrement the cumulative first thing count */ + } + goto T0164011; + } + if (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16()) { + *AL0275_pT_Thing = *L0274_ps_Generic; + goto T0164011; + } + thingInList = *AL0275_pT_Thing; + } + L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList); + while (L0273_T_Thing.getTypeAndIndex() != thingToUnlink.toUint16()) { + if ((L0273_T_Thing == Thing::_endOfList) || (L0273_T_Thing == Thing::_none)) { + goto T0164011; + } + L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList = L0273_T_Thing); + } + L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingInList); + *L0274_ps_Generic = _vm->_dungeonMan->f159_getNextThing(L0273_T_Thing); + L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink); +T0164011: + *L0274_ps_Generic = Thing::_endOfList; +} + +int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) { + int16 L0256_i_SquareType; + bool L0257_B_NorthSouthOrientedStairs; + + + if (L0257_B_NorthSouthOrientedStairs = !getFlag(_vm->_dungeonMan->f151_getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient)) { + mapX = mapX + _vm->_dirIntoStepCountEast[kDirEast]; + mapY = mapY + _vm->_dirIntoStepCountNorth[kDirEast]; + } else { + mapX = mapX + _vm->_dirIntoStepCountEast[kDirNorth]; + mapY = mapY + _vm->_dirIntoStepCountNorth[kDirNorth]; + } + return ((((L0256_i_SquareType = Square(_vm->_dungeonMan->f151_getSquare(mapX, mapY)).getType()) == k0_ElementTypeWall) || (L0256_i_SquareType == k3_ElementTypeStairs)) << 1) + L0257_B_NorthSouthOrientedStairs; + +} + +Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) { + int16 L0293_i_Type; + int16 L0294_i_ThingType; + Thing L0295_T_Thing; + Junk* L0296_ps_Junk; + + + L0294_i_ThingType = k5_WeaponThingType; + if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit)) { + iconIndex = k4_IconIndiceWeaponTorchUnlit; + } + switch (iconIndex) { + case k54_IconIndiceWeaponRock: + L0293_i_Type = k30_WeaponTypeRock; + break; + case k128_IconIndiceJunkBoulder: + L0293_i_Type = k25_JunkTypeBoulder; + L0294_i_ThingType = k10_JunkThingType; + break; + case k51_IconIndiceWeaponArrow: + L0293_i_Type = k27_WeaponTypeArrow; + break; + case k52_IconIndiceWeaponSlayer: + L0293_i_Type = k28_WeaponTypeSlayer; + break; + case k55_IconIndiceWeaponPoisonDart: + L0293_i_Type = k31_WeaponTypePoisonDart; + break; + case k56_IconIndiceWeaponThrowingStar: + L0293_i_Type = k32_WeaponTypeThrowingStar; + break; + case k32_IconIndiceWeaponDagger: + L0293_i_Type = k8_WeaponTypeDagger; + break; + case k4_IconIndiceWeaponTorchUnlit: + L0293_i_Type = k2_WeaponTypeTorch; + break; + default: + return Thing::_none; + } + if ((L0295_T_Thing = f166_getUnusedThing(L0294_i_ThingType)) == Thing::_none) { + return Thing::_none; + } + L0296_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0295_T_Thing); + L0296_ps_Junk->setType(L0293_i_Type); /* Also works for WEAPON in cases other than Boulder */ + if ((iconIndex == k4_IconIndiceWeaponTorchUnlit) && ((Weapon*)L0296_ps_Junk)->isLit()) { /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */ + ((Weapon*)L0296_ps_Junk)->setChargeCount(15); + } + return L0295_T_Thing; +} } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index a32edcf3a4..c591881094 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -107,9 +107,7 @@ class ArmourInfo { public: uint16 _weight; uint16 _defense; -private: uint16 _attributes; -public: ArmourInfo(uint16 weight, uint16 defense, uint16 attributes) :_weight(weight), _defense(defense), _attributes(attributes) {} @@ -178,8 +176,9 @@ enum SquareAspectIndice { }; - +#define k15_immuneToFire 15 // @ C15_IMMUNE_TO_FIRE +#define k15_immuneToPoison 15 // @ C15_IMMUNE_TO_POISON class CreatureInfo { public: @@ -200,6 +199,17 @@ public: uint16 _animationTicks; /* Bits 15-12 Unreferenced */ uint16 _woundProbabilities; /* Contains 4 probabilities to wound a champion's Head (Bits 15-12), Legs (Bits 11-8), Torso (Bits 7-4) and Feet (Bits 3-0) */ byte _attackType; + + uint16 M57_getFearResistance() { return (_properties >> 4) & 0xF; } + uint16 M58_getExperience() { return (_properties >> 8) & 0xF; } + uint16 M59_getWariness() { return (_properties >> 12) & 0xF; } + uint16 M60_getFireResistance() { return (_resistances >> 4) & 0xF; } + uint16 M61_poisonResistance() { return (_resistances >> 8) & 0xF; } + uint16 M51_height() { return (_attributes >> 7) & 0x3; } + + uint16 M54_getSightRange() { return (_ranges) & 0xF; } + uint16 M55_getSmellRange() { return (_ranges >> 8) & 0xF; } + uint16 M56_getAttackRange() { return (_ranges >> 12) & 0xF; } }; // @ CREATURE_INFO @@ -232,13 +242,13 @@ class Teleporter { public: explicit Teleporter(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]), _destMapIndex(rawDat[2]) {} Thing getNextThing() { return _nextThing; } - bool makesSound() { return (_attributes >> 15) & 1; } + bool isAudible() { return (_attributes >> 15) & 1; } TeleporterScope getScope() { return (TeleporterScope)((_attributes >> 13) & 1); } - bool absRotation() { return (_attributes >> 12) & 1; } - direction getRotationDir() { return (direction)((_attributes >> 10) & 1); } - byte getDestY() { return (_attributes >> 5) & 0xF; } - byte getDestX() { return _attributes & 0xF; } - uint16 getDestMapIndex() { return _destMapIndex >> 8; } + bool getAbsoluteRotation() { return (_attributes >> 12) & 1; } + direction getRotation() { return (direction)((_attributes >> 10) & 1); } + byte getTargetMapY() { return (_attributes >> 5) & 0xF; } + byte getTargetMapX() { return _attributes & 0xF; } + uint16 getTargetMapIndex() { return _destMapIndex >> 8; } }; // @ TELEPORTER @@ -311,26 +321,30 @@ public: uint16 getDataMask2() { return (_datAndType >> 11) & 0xF; } // @ M43_MASK2 void setData(int16 dat) { _datAndType = (_datAndType & 0x7F) | (dat << 7); } // @ M41_SET_DATA void setTypeDisabled() { _datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED - uint16 getOrnOrdinal() { return _attributes >> 12; } - bool isLocalAction() { return (_attributes >> 11) & 1; } - uint16 getDelay() { return (_attributes >> 7) & 0xF; } - bool hasSound() { return (_attributes >> 6) & 1; } - bool shouldRevert() { return (_attributes >> 5) & 1; } - SensorActionType getActionType() { return (SensorActionType)((_attributes >> 3) & 3); } - bool isSingleUse() { return (_attributes >> 2) & 1; } - uint16 getRemoteMapY() { return (_action >> 11); } - uint16 getRemoteMapX() { return (_action >> 6) & 0x1F; } - direction getRemoteDir() { return (direction)((_action >> 4) & 3); } - uint16 getLocalAction() { return (_action >> 4); } + + + + bool getOnlyOnce() { return (_attributes >> 2) & 1; } uint16 getEffectA() { return (_attributes >> 3) & 0x3; } bool getRevertEffectA() { return (_attributes >> 5) & 0x1; } bool getAudibleA() { return (_attributes >> 6) & 0x1; } + uint16 getValue() { return (_attributes >> 7) & 0xF; } + bool getLocalEffect() { return (_attributes >> 11) & 1; } + uint16 getOrnOrdinal() { return _attributes >> 12; } + + uint16 getTargetMapY() { return (_action >> 11); } + uint16 getTargetMapX() { return (_action >> 6) & 0x1F; } + direction getTargetCell() { return (direction)((_action >> 4) & 3); } + uint16 M49_localEffect() { return (_action >> 4); } // some macros missing, i got bored }; // @ SENSOR +#define k0x8000_randomDrop 0x8000 // @ MASK0x8000_RANDOM_DROP + + enum WeaponType { k2_WeaponTypeTorch = 2, // @ C02_WEAPON_TORCH k8_WeaponTypeDagger = 8, // @ C08_WEAPON_DAGGER @@ -351,6 +365,7 @@ public: explicit Weapon(uint16 *rawDat) : _nextThing(rawDat[0]), _desc(rawDat[1]) {} WeaponType getType() { return (WeaponType)(_desc & 0x7F); } + void setType(uint16 val) { _desc = (_desc & ~0x7F) | (val & 0x7F); } bool isLit() { return (_desc >> 15) & 1; } void setLit(bool val) { if (val) @@ -359,10 +374,13 @@ public: _desc &= (~(1 << 15)); } uint16 getChargeCount() { return (_desc >> 10) & 0xF; } + void setChargeCount(uint16 val) { _desc = (_desc & ~(0xF << 10)) | ((val & 0xF) << 10); } Thing getNextThing() { return _nextThing; } uint16 getCursed() { return (_desc >> 8) & 1; } + void setCursed(uint16 val) { _desc = (_desc & ~(1 << 8)) | ((val & 1) << 8); } uint16 getPoisoned() { return (_desc >> 9) & 1; } uint16 getBroken() { return (_desc >> 14) & 1; } + uint16 getDoNotDiscard() { return (_desc >> 7) & 1; } }; // @ WEAPON enum ArmourType { @@ -382,6 +400,7 @@ public: Thing getNextThing() { return _nextThing; } uint16 getCursed() { return (_attributes >> 8) & 1; } uint16 getBroken() { return (_attributes >> 13) & 1; } + uint16 getDoNotDiscard() { return (_attributes >> 7) & 1; } }; // @ ARMOUR class Scroll { @@ -420,15 +439,16 @@ enum PotionType { k20_PotionTypeEmptyFlask = 20 // @ C20_POTION_EMPTY_FLASK, }; class Potion { +public: Thing _nextThing; uint16 _attributes; -public: explicit Potion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} PotionType getType() { return (PotionType)((_attributes >> 8) & 0x7F); } void setType(PotionType val) { _attributes = (_attributes & ~(0x7F << 8)) | ((val & 0x7F) << 8); } Thing getNextThing() { return _nextThing; } uint16 getPower() { return _attributes & 0xFF; } + uint16 getDoNotDiscard() { return (_attributes >> 15) & 1; } }; // @ POTION class Container { @@ -463,23 +483,29 @@ public: explicit Junk(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} JunkType getType() { return (JunkType)(_attributes & 0x7F); } + void setType(uint16 val) { _attributes = (_attributes & ~0x7F) | (val & 0x7F); } uint16 getChargeCount() { return (_attributes >> 14) & 0x3; } void setChargeCount(uint16 val) { _attributes = (_attributes & ~(0x3 << 14)) | ((val & 0x3) << 14); } + uint16 getDoNotDiscard() { return (_attributes >> 7) & 1; } Thing getNextThing() { return _nextThing; } }; // @ JUNK +#define kM1_soundModeDoNotPlaySound -1 // @ CM1_MODE_DO_NOT_PLAY_SOUND +#define k0_soundModePlayImmediately 0 // @ C00_MODE_PLAY_IMMEDIATELY +#define k1_soundModePlayIfPrioritized 1 // @ C01_MODE_PLAY_IF_PRIORITIZED +#define k2_soundModePlayOneTickLater 2 // @ C02_MODE_PLAY_ONE_TICK_LATER + class Projectile { public: Thing _nextThing; - Thing _object; - byte _kineticEnergy; - byte _damageEnergy; - uint16 _timerIndex; - explicit Projectile(uint16 *rawDat) : _nextThing(rawDat[0]), _object(rawDat[1]), _kineticEnergy(rawDat[2]), - _damageEnergy(rawDat[3]), _timerIndex(rawDat[4]) {} + Thing _slot; + uint16 _kineticEnergy; + uint16 _attack; + uint16 _eventIndex; + explicit Projectile(uint16 *rawDat) : _nextThing(rawDat[0]), _slot(rawDat[1]), _kineticEnergy(rawDat[2]), + _attack(rawDat[3]), _eventIndex(rawDat[4]) {} - Thing getNextThing() { return _nextThing; } }; // @ PROJECTILE #define k0_ExplosionType_Fireball 0 // @ C000_EXPLOSION_FIREBALL @@ -502,8 +528,11 @@ public: Thing getNextThing() { return _nextThing; } uint16 getType() { return _attributes & 0x7F; } + uint16 setType(uint16 val) { _attributes = (_attributes & ~0x7F) | (val & 0x7F); return (val & 0x7F); } uint16 getAttack() { return (_attributes >> 8) & 0xFF; } - uint16 getCentered() { return (_attributes >> 7) & 0x1; } + void setAttack(uint16 val) { _attributes = (_attributes & ~(0xFF << 8)) | ((val & 0xFF) << 8); } + uint16 getCentered() { return (_attributes >> 7) & 0x1; } + void setCentered(uint16 val) { _attributes = (_attributes & ~(1 << 7)) | ((val & 1) << 7); } }; // @ EXPLOSION @@ -544,6 +573,9 @@ enum SquareType { k19_StairsFrontElemType = 19 // @ C19_ELEMENT_STAIRS_FRONT }; // @ C[-2..19]_ELEMENT_... +#define k0x8000_championBones 0x8000 // @ MASK0x8000_CHAMPION_BONES +#define k0x7FFF_thingType 0x7FFF // @ MASK0x7FFF_THING_TYPE + class Square { byte _data; public: @@ -598,10 +630,11 @@ class DoorInfo { public: byte _attributes; byte _defense; - DoorInfo(byte b1, byte b2): _attributes(b1), _defense(b2){} + DoorInfo(byte b1, byte b2) : _attributes(b1), _defense(b2) {} DoorInfo() {} }; // @ DOOR_INFO +class Group; class DungeonMan { DMEngine *_vm; @@ -618,14 +651,14 @@ class DungeonMan { int16 f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal void f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, - int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals + int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals - void f173_setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap public: explicit DungeonMan(DMEngine *dmEngine); ~DungeonMan(); + void f173_setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap Thing f161_getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing Thing f159_getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing) uint16 *f156_getThingData(Thing thing); // @ F0156_DUNGEON_GetThingData @@ -642,6 +675,8 @@ public: } // @ F0153_DUNGEON_GetRelativeSquareType void f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect void f168_decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText + Thing f166_getUnusedThing(uint16 thingType); // @ F0166_DUNGEON_GetUnusedThing + uint16 f140_getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight int16 f141_getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex @@ -649,6 +684,17 @@ public: WeaponInfo *f158_getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo int16 f142_getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect int16 f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16 *mapX, int16 *mapY); // @ F0154_DUNGEON_GetLocationAfterLevelChange + Thing f162_getSquareFirstObject(int16 mapX, int16 mapY); // @ F0162_DUNGEON_GetSquareFirstObject + uint16 f143_getArmourDefense(ArmourInfo *armourInfo, bool useSharpDefense); // @ F0143_DUNGEON_GetArmourDefense + Thing f165_getDiscardTHing(uint16 thingType); // @ F0165_DUNGEON_GetDiscardedThing + uint16 f144_getCreatureAttributes(Thing thing); // @ F0144_DUNGEON_GetCreatureAttributes + void f146_setGroupCells(Group *group, uint16 cells, uint16 mapIndex); // @ F0146_DUNGEON_SetGroupCells + void f148_setGroupDirections(Group *group, int16 dir, uint16 mapIndex); // @ F0148_DUNGEON_SetGroupDirections + bool f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex); // @ F0139_DUNGEON_IsCreatureAllowedOnMap + void f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY); // @ F0164_DUNGEON_UnlinkThingFromList + int16 f155_getStairsExitDirection(int16 mapX, int16 mapY); // @ F0155_DUNGEON_GetStairsExitDirection + Thing f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex); // @ F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator + uint32 _rawDunFileDataSize; // @ probably NONE byte *_rawDunFileData; // @ ??? diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 490449d61c..0104883e21 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -34,12 +34,53 @@ #include "objectman.h" #include "inventory.h" #include "menus.h" - - +#include "timeline.h" +#include "projexpl.h" +#include "text.h" +#include "group.h" namespace DM { +byte g42_bitmapArrowPointer[576] = { // @ G0042_auc_Graphic562_Bitmap_ArrowPointer + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x7, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x7, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x6, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x8, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x3, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xA, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xC, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; +byte g43_bitmapHanPointer[576] = { // @ G0043_auc_Graphic562_Bitmap_HandPointer + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x3, 0x5, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xA, 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xD, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE, 0xA, 0x8, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x7, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0xC, 0x7, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x6, 0x7, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x7, 0x7, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, + 0x3, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x3, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x1, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0xA, 0xA, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x5, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x1, 0x2, 0xA, 0x8, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x5, 0x4, 0x0, 0x0, 0x0, 0x0, 0xC, 0x8, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x2, 0x8, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, + 0x9, 0x8, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x8, 0x8, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, + 0x2, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x7, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0x8, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, + 0xC, 0xF, 0xF, 0xC, 0x0, 0x0, 0x0, 0x0, 0xE, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, + 0x7, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0xF, 0xE, 0x0, 0x0, 0x0, 0x0, 0x3, 0xF, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x7, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; + Box g462_BoxObjectPiles[4] = { // @ G0462_as_Graphic561_Box_ObjectPiles /* { X1, X2, Y1, Y2 } */ Box(24, 111, 148, 168), /* Front left */ @@ -260,44 +301,179 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) { _dummyMapIndex = 0; _g439_pendingClickButton = k0_NoneMouseButton; + _g615_mousePointerOriginalColorsObject = nullptr; + _g613_mousePointerOriginalColorsChampionIcon = nullptr; + _gK190_mousePointerTempBuffer = nullptr; } +EventManager::~EventManager() { + delete[] _g615_mousePointerOriginalColorsObject; + delete[] _gK190_mousePointerTempBuffer; + delete[] _g613_mousePointerOriginalColorsChampionIcon; +} -// dummy data -static const byte mouseData[] = { - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 7, 1, 0, 0, 0, 0, 0, 0, 0, - 1, 7, 7, 1, 0, 0, 0, 0, 0, 0, - 1, 7, 7, 7, 1, 0, 0, 0, 0, 0, - 1, 7, 7, 7, 7, 1, 0, 0, 0, 0, - 1, 7, 7, 7, 7, 7, 1, 0, 0, 0, - 1, 7, 7, 7, 7, 7, 7, 1, 0, 0, - 1, 7, 7, 7, 7, 7, 7, 7, 1, 0, - 1, 7, 7, 7, 7, 7, 1, 1, 1, 1, - 1, 7, 7, 1, 7, 7, 1, 0, 0, 0, - 1, 7, 1, 0, 1, 7, 7, 1, 0, 0, - 1, 1, 0, 0, 1, 7, 7, 1, 0, 0, - 0, 0, 0, 0, 0, 1, 7, 7, 1, 0, - 0, 0, 0, 0, 0, 1, 7, 7, 1, 0, - 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 -}; -#define MOUSE_WIDTH 10 -#define MOUSE_HEIGHT 15 +void EventManager::initMouse() { + if (!_g615_mousePointerOriginalColorsObject) + _g615_mousePointerOriginalColorsObject = new byte[32 * 18]; + if (!_gK190_mousePointerTempBuffer) + _gK190_mousePointerTempBuffer = new byte[32 * 18]; + if (!_g613_mousePointerOriginalColorsChampionIcon) + _g613_mousePointerOriginalColorsChampionIcon = new byte[32 * 18]; + _gK104_mousePointerType = k0_pointerArrow; + _gK105_previousMousePointerType = k1_pointerHand; -void EventManager::initMouse() { _mousePos = Common::Point(0, 0); - CursorMan.pushCursor(mouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0); + CursorMan.pushCursor(g42_bitmapArrowPointer, 32, 18, 0, 0, 0); CursorMan.showMouse(false); + setMousePos(Common::Point(320 / 2, 200 / 2)); - // TODO: add cursor creatin, set to hidden } -void EventManager::showMouse(bool visibility) { - CursorMan.showMouse(visibility); +void EventManager::f67_setMousePointerToNormal(int16 mousePointer) { + _gK100_preventBuildPointerScreenArea = true; + _g600_useObjectAsMousePointerBitmap = false; + _g601_useHandAsMousePointerBitmap = (mousePointer == k1_pointerHand); + _g598_mousePointerBitmapUpdated = true; + _gK100_preventBuildPointerScreenArea = false; + f73_buildpointerScreenArea(_mousePos.x, _mousePos.y); +} + +void EventManager::f68_setPointerToObject(byte* bitmap) { + static byte gK27_palChangesMousepointerOjbectIconShadow[16] = {120, 120, 120, 120, 120, 120, 120, 120, + 120, 120, 120, 120, 0, 120, 120, 120}; // @ K0027_auc_PaletteChanges_MousePointerObjectIconShadow + static byte g44_palChangesMousePointerIcon[16] = {120, 10, 20, 30, 40, 50, 60, 70, 80, 90, + 100, 110, 0, 130, 140, 150}; // @ G0044_auc_Graphic562_PaletteChanges_MousePointerIcon + static Box g619_BoxMousePointerObjectShadow(2, 17, 2, 17); // @ G0619_s_Box_MousePointer_ObjectShadow + static Box g620_BoxMousePointerObject(0, 15, 0, 15); // @ G0620_s_Box_MousePointer_Object + byte* L0051_puc_Bitmap; + + _gK100_preventBuildPointerScreenArea = true; + _g600_useObjectAsMousePointerBitmap = true; + _g601_useHandAsMousePointerBitmap = false; + _g598_mousePointerBitmapUpdated = true; + _vm->_displayMan->_g578_useByteBoxCoordinates = true; + L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject; + memset(L0051_puc_Bitmap, 0, 32 * 18); + _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, gK27_palChangesMousepointerOjbectIconShadow); + _vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, k255_ColorNoTransparency, 16, 18); + _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, g44_palChangesMousePointerIcon); + _vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18); + _gK100_preventBuildPointerScreenArea = false; + f73_buildpointerScreenArea(_mousePos.x, _mousePos.y); +} + +void EventManager::f71_mouseDropChampionIcon() { + bool L0057_B_UseByteBoxCoordinatesBackup; + uint16 L0058_ui_ChampionIconIndex; + + + _gK100_preventBuildPointerScreenArea = true; + L0058_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap); + _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone); + _vm->_eventMan->_g598_mousePointerBitmapUpdated = true; + L0057_B_UseByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates; + _vm->_displayMan->f21_blitToScreen(_g613_mousePointerOriginalColorsChampionIcon, &g54_BoxChampionIcons[L0058_ui_ChampionIconIndex << 2], 16, k12_ColorDarkestGray, 18); + _vm->_displayMan->_g578_useByteBoxCoordinates = L0057_B_UseByteBoxCoordinatesBackup; + _gK100_preventBuildPointerScreenArea = false; +} + +void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY) { + uint16 L1577_i_ChampionIndex; + int16 L1578_i_XOverChampionStatusBox; + + + if (_gK100_preventBuildPointerScreenArea) + return; + + _gK100_preventBuildPointerScreenArea = true; + if (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) { + if ((mousePosY > 28) || (mousePosX < 274)) { + _gK104_mousePointerType = k4_pointerTypeAutoselect; + f71_mouseDropChampionIcon(); + } else { + _gK104_mousePointerType = k2_pointerTypeChampionIcon; + } + } else { + if (mousePosY >= 169) { + _gK104_mousePointerType = k0_pointerTypeArrow; + } else { + if (mousePosX >= 274) { + _gK104_mousePointerType = k0_pointerTypeArrow; + } else { + if (mousePosY <= 28) { + L1577_i_ChampionIndex = mousePosX / 69; + L1578_i_XOverChampionStatusBox = mousePosX % 69; + if (L1577_i_ChampionIndex >= _vm->_championMan->_g305_partyChampionCount) { + _gK104_mousePointerType = k4_pointerTypeAutoselect; + } else { + if (L1578_i_XOverChampionStatusBox > 42) { + _gK104_mousePointerType = k4_pointerTypeAutoselect; + } else { + L1577_i_ChampionIndex++; + if (L1577_i_ChampionIndex == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) { + _gK104_mousePointerType = k0_pointerTypeArrow; + } else { + if (mousePosY <= 6) { + _gK104_mousePointerType = k0_pointerTypeArrow; + } else { + _gK104_mousePointerType = k4_pointerTypeAutoselect; + } + } + } + } + } else { + if (mousePosX >= 224) { + _gK104_mousePointerType = k0_pointerTypeArrow; + } else { + _gK104_mousePointerType = k4_pointerTypeAutoselect; + } + } + } + } + } + if (_gK104_mousePointerType == k4_pointerTypeAutoselect) { + _gK104_mousePointerType = (_g600_useObjectAsMousePointerBitmap) ? k1_pointerTypeObjectIcon : (_g601_useHandAsMousePointerBitmap) ? k3_pointerTypeHand : k0_pointerTypeArrow; + } + if (_vm->_eventMan->_g598_mousePointerBitmapUpdated || (_gK104_mousePointerType != _gK105_previousMousePointerType)) { + _vm->_eventMan->_g598_mousePointerBitmapUpdated = false; + switch (_gK104_mousePointerType) { + case k0_pointerTypeArrow: + CursorMan.pushCursor(g42_bitmapArrowPointer, 32, 18, 0, 0, 0); + break; + case k1_pointerTypeObjectIcon: + CursorMan.pushCursor(_g615_mousePointerOriginalColorsObject, 32, 18, 0, 0, 0); + break; + case k2_pointerTypeChampionIcon: + CursorMan.pushCursor(_g613_mousePointerOriginalColorsChampionIcon, 32, 18, 0, 0, 0); + break; + case k3_pointerTypeHand: + CursorMan.pushCursor(g43_bitmapHanPointer, 32, 18, 0, 0, 0); + break; + } + } + _gK105_previousMousePointerType = _gK104_mousePointerType; + _gK100_preventBuildPointerScreenArea = false; +} + +void EventManager::f69_setMousePointer() { + if (_vm->_championMan->_g415_leaderEmptyHanded) { + f67_setMousePointerToNormal((_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand); + } else { + f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer); + } +} + +void EventManager::f78_showMouse() { + CursorMan.showMouse(true); +} + +void EventManager::f77_hideMouse() { + CursorMan.showMouse(false); } + void EventManager::setMousePos(Common::Point pos) { _vm->_system->warpMouse(pos.x, pos.y); } @@ -473,6 +649,48 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) { // MISSING CODE: Lots of code } +bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY) { + bool L1149_B_ObjectThrown; + + +#define k0_sideLeft 0 // @ C0_SIDE_LEFT +#define k1_sideRight 1 // @ C0_SIDE_LEFT + + if ((posY < 47) || (posY > 102)) { + return false; + } + if (posX <= 111) { + if (_vm->_dungeonMan->_g285_squareAheadElement == k17_DoorFrontElemType) { + if (posX < 64) { + return false; + } + } else { + if (posX < 32) { + return false; + } + } + // Strangerke: Only poresent in CSB2.1... But it fixes a bug so we keep it + L1149_B_ObjectThrown = _vm->_championMan->f329_isLeaderHandObjectThrown(k0_sideLeft); + } else { + if (_vm->_dungeonMan->_g285_squareAheadElement == k17_DoorFrontElemType) { + if (posX > 163) { + return false; + } + } else { + if (posX > 191) { + return false; + } + } + L1149_B_ObjectThrown = _vm->_championMan->f329_isLeaderHandObjectThrown(k1_sideRight); + } + if (L1149_B_ObjectThrown) { + _vm->_g321_stopWaitingForPlayerInput = true; + } + return L1149_B_ObjectThrown; +} + + + void EventManager::f368_commandSetLeader(ChampionIndex champIndex) { ChampionMan &cm = *_vm->_championMan; ChampionIndex leaderIndex; @@ -513,79 +731,88 @@ void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() { } void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16 posY) { - DungeonMan &dunMan = *_vm->_dungeonMan; - ChampionMan &champMan = *_vm->_championMan; - - if (dunMan._g285_squareAheadElement == k17_ElementTypeDoorFront) { - if (champMan._g411_leaderIndex == kM1_ChampionNone) + uint16 L1150_ui_ViewCell; + Junk* L1151_ps_Junk; + Thing L1152_T_Thing; + uint16 L1153_ui_IconIndex; + uint16 L1154_ui_Weight; + int16 L1155_i_MapX; + int16 L1156_i_MapY; + + if (_vm->_dungeonMan->_g285_squareAheadElement == k17_DoorFrontElemType) { + if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) { return; - - if (champMan._g415_leaderEmptyHanded) { - int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir]; - int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir]; - - if (Door(dunMan.f157_getSquareFirstThingData(mapX, mapY)).hasButton() && - dunMan._g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { + } + L1155_i_MapX = _vm->_dungeonMan->_g306_partyMapX; + L1156_i_MapY = _vm->_dungeonMan->_g307_partyMapY; + L1155_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1156_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir]; + if (_vm->_championMan->_g415_leaderEmptyHanded) { + L1151_ps_Junk = (Junk*)_vm->_dungeonMan->f157_getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY); + if ((((Door*)L1151_ps_Junk)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) { _vm->_g321_stopWaitingForPlayerInput = true; warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); - warning("MISSING CODE: F0268_SENSOR_AddEvent"); + _vm->_movsens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1); + return; + } + } else { + if (f375_processType80_clickDungeonView_isLeaderHandObjThrown(posX, posY)) { return; } - - warning("MISSING CODE: F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown in elseif condition"); } } - - if (champMan._g415_leaderEmptyHanded) { - for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k5_ViewCellDoorButtonOrWallOrn; viewCell++) { - if (dunMan._g291_dungeonViewClickableBoxes[viewCell].isPointInside(Common::Point(posX, posY - 33))) { - if (viewCell == k5_ViewCellDoorButtonOrWallOrn) { - if (!dunMan._g286_isFacingAlcove) { + if (_vm->_championMan->_g415_leaderEmptyHanded) { + for (L1150_ui_ViewCell = k0_ViewCellFronLeft; L1150_ui_ViewCell < k5_ViewCellDoorButtonOrWallOrn + 1; L1150_ui_ViewCell++) { + if (_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[L1150_ui_ViewCell].isPointInside(posX, posY - 33)) { + if (L1150_ui_ViewCell == k5_ViewCellDoorButtonOrWallOrn) { + if (!_vm->_dungeonMan->_g286_isFacingAlcove) { f372_commandProcessType80ClickInDungeonViewTouchFrontWall(); } } else { - warning("MISSING CODE: F0373_COMMAND_ProcessType80_ClickInDungeonView_GrabLeaderHandObject"); + f373_processType80_clickInDungeonView_grabLeaderHandObject(L1150_ui_ViewCell); } return; } } } else { - Thing thing = champMan._g414_leaderHandObject; - uint16 *rawThingPointer = dunMan.f156_getThingData(thing); - if (dunMan._g285_squareAheadElement == k0_ElementTypeWall) { - for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k1_ViewCellFrontRight; ++viewCell) { - if (g462_BoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) { - warning("F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject"); + L1152_T_Thing = _vm->_championMan->_g414_leaderHandObject; + L1151_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1152_T_Thing); + if (_vm->_dungeonMan->_g285_squareAheadElement == k0_ElementTypeWall) { + for (L1150_ui_ViewCell = k0_ViewCellFronLeft; L1150_ui_ViewCell < k1_ViewCellFrontRight + 1; L1150_ui_ViewCell++) { + if (g462_BoxObjectPiles[L1150_ui_ViewCell].isPointInside(posX, posY)) { + f374_processType80_clickInDungeonViewDropLeaderHandObject(L1150_ui_ViewCell); return; } } - - if (dunMan._g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(Common::Point(posX, posY - 33))) { - if (dunMan._g286_isFacingAlcove) { - warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject"); + if (_vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) { + if (_vm->_dungeonMan->_g286_isFacingAlcove) { + f374_processType80_clickInDungeonViewDropLeaderHandObject(k4_ViewCellAlcove); } else { - if (dunMan._g288_isFacingFountain) { - uint16 iconIndex = _vm->_objectMan->f33_getIconIndex(thing); - int16 weight = dunMan.f140_getObjectWeight(thing); - if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) { - ((Junk*)rawThingPointer)->setChargeCount(3); - } else if (iconIndex == k195_IconIndicePotionEmptyFlask) { - ((Potion*)rawThingPointer)->setType(k15_PotionTypeWaterFlask); + if (_vm->_dungeonMan->_g288_isFacingFountain) { + L1153_ui_IconIndex = _vm->_objectMan->f33_getIconIndex(L1152_T_Thing); + L1154_ui_Weight = _vm->_dungeonMan->f140_getObjectWeight(L1152_T_Thing); + if ((L1153_ui_IconIndex >= k8_IconIndiceJunkWater) && (L1153_ui_IconIndex <= k9_IconIndiceJunkWaterSkin)) { + L1151_ps_Junk->setChargeCount(3); /* Full */ } else { - goto T0377019; + if (L1153_ui_IconIndex == k195_IconIndicePotionEmptyFlask) { + ((Potion*)L1151_ps_Junk)->setType(k15_PotionTypeWaterFlask); + } else { + goto T0377019; + } } - champMan.f296_drawChangedObjectIcons(); - champMan._gK71_champions[champMan._g411_leaderIndex]._load += dunMan.f140_getObjectWeight(thing) - weight; + _vm->_championMan->f296_drawChangedObjectIcons(); + _vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(L1152_T_Thing) - L1154_ui_Weight; } T0377019: f372_commandProcessType80ClickInDungeonViewTouchFrontWall(); } } } else { - warning("MISSING CODE: F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown in if branch"); - for (int16 viewCell = k0_ViewCellFronLeft; viewCell <= k3_ViewCellBackLeft; viewCell++) { - if (g462_BoxObjectPiles[viewCell].isPointInside(Common::Point(posX, posY))) { - warning("MISSING CODE: F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject"); + if (f375_processType80_clickDungeonView_isLeaderHandObjThrown(posX, posY)) { + return; + } + for (L1150_ui_ViewCell = k0_ViewCellFronLeft; L1150_ui_ViewCell < k3_ViewCellBackLeft + 1; L1150_ui_ViewCell++) { + if (g462_BoxObjectPiles[L1150_ui_ViewCell].isPointInside(posX, posY)) { + f374_processType80_clickInDungeonViewDropLeaderHandObject(L1150_ui_ViewCell); return; } } @@ -616,8 +843,8 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat dispMan._g578_useByteBoxCoordinates = false; dispMan.D24_fillScreenBox(box, k0_ColorBlack); dispMan.D24_fillScreenBox(g54_BoxChampionIcons[champMan.M26_championIconIndex(champ->_cell, dunMan._g308_partyDir) * 2], k0_ColorBlack); - warning("F0457_START_DrawEnabledMenus_CPSF"); - warning("F0078_MOUSE_ShowPointer"); + _vm->_menuMan->f457_drawEnabledMenus(); + _vm->_eventMan->f78_showMouse(); return; } @@ -628,7 +855,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) { Thing thing = champ->getSlot((ChampionSlot)slotIndex); if (thing != Thing::_none) { - warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList"); + _vm->_dungeonMan->f164_unlinkThingFromList(thing, Thing(0), mapX, mapY); } } Thing thing = dunMan.f161_getSquareFirstThing(mapX, mapY); @@ -652,21 +879,21 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat } if (champMan._g305_partyChampionCount == 1) { - warning("MISSING CODE: setting time, G0362_l_LastPartyMovementTime , G0313_ul_GameTime"); + _vm->_projexpl->_g362_lastPartyMovementTime = _vm->_g313_gameTime; f368_commandSetLeader(k0_ChampionFirst); _vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(k0_ChampionFirst); } else { _vm->_menuMan->f393_drawSpellAreaControls(champMan._g514_magicCasterChampionIndex); } - warning("MISSING CODE: F0051_TEXT_MESSAGEAREA_PrintLineFeed"); - Color champColor = g46_ChampionColor[championIndex]; // unreferenced because of missing code - warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage"); - warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage"); + _vm->_textMan->f51_messageAreaPrintLineFeed(); + Color champColor = g46_ChampionColor[championIndex]; + _vm->_textMan->f47_messageAreaPrintMessage(champColor, champ->_name); + _vm->_textMan->f47_messageAreaPrintMessage(champColor, (commandType == k160_CommandClickInPanelResurrect) ? " RESURRECTED." : " REINCARNATED."); // TODO: localization invMan.f355_toggleInventory(k4_ChampionCloseInventory); - warning("MISSING CODE: F0457_START_DrawEnabledMenus_CPSF"); - warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal"); + _vm->_menuMan->f457_drawEnabledMenus(); + _vm->_eventMan->f67_setMousePointerToNormal((_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) ? k0_pointerArrow : k1_pointerHand); } void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) { @@ -694,6 +921,72 @@ void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) { } } +void EventManager::f373_processType80_clickInDungeonView_grabLeaderHandObject(uint16 viewCell) { + int16 L1137_i_MapX; + int16 L1138_i_MapY; + Thing L1139_T_Thing; + + + if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) { + return; + } + L1137_i_MapX = _vm->_dungeonMan->_g306_partyMapX; + L1138_i_MapY = _vm->_dungeonMan->_g307_partyMapY; + if (viewCell >= k2_ViewCellBackRight) { + L1137_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1138_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir]; + if (((L1139_T_Thing = _vm->_groupMan->f175_groupGetThing(L1137_i_MapX, L1138_i_MapY)) != Thing::_endOfList) && + !_vm->_movsens->f264_isLevitating(L1139_T_Thing) && + _vm->_groupMan->f176_getCreatureOrdinalInCell((Group*)_vm->_dungeonMan->f156_getThingData(L1139_T_Thing), M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir))) { + return; /* It is not possible to grab an object on floor if there is a non levitating creature on its cell */ + } + } + L1139_T_Thing = _vm->_dungeonMan->_g292_pileTopObject[viewCell]; + if (_vm->_objectMan->f33_getIconIndex(L1139_T_Thing) != kM1_IconIndiceNone) { + _vm->_movsens->f267_getMoveResult(L1139_T_Thing, L1137_i_MapX, L1138_i_MapY, kM1_MapXNotOnASquare, 0); + _vm->_championMan->f297_putObjectInLeaderHand(L1139_T_Thing, true); + } + _vm->_g321_stopWaitingForPlayerInput = true; +} + +void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uint16 viewCell) { + int16 L1140_i_MapX; + int16 L1141_i_MapY; + Thing L1142_T_Thing; + Junk* L1143_ps_Junk; + int16 L1144_i_IconIndex; + uint16 L1145_ui_Cell; + bool L1146_B_DroppingIntoAnAlcove; + TimelineEvent L1147_s_Event; + + + if (_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) { + return; + } + L1140_i_MapX = _vm->_dungeonMan->_g306_partyMapX; + L1141_i_MapY = _vm->_dungeonMan->_g307_partyMapY; + if (L1146_B_DroppingIntoAnAlcove = (viewCell == k4_ViewCellAlcove)) { + viewCell = k2_ViewCellBackRight; + } + if (viewCell > k1_ViewCellFrontRight) { + L1140_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1141_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir]; + } + L1145_ui_Cell = M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + viewCell); + L1142_T_Thing = _vm->_championMan->f298_getObjectRemovedFromLeaderHand(); + _vm->_movsens->f267_getMoveResult(M15_thingWithNewCell(L1142_T_Thing, L1145_ui_Cell), kM1_MapXNotOnASquare, 0, L1140_i_MapX, L1141_i_MapY); + if (L1146_B_DroppingIntoAnAlcove && _vm->_dungeonMan->_g287_isFacingViAltar && ((L1144_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L1142_T_Thing)) == k147_IconIndiceJunkChampionBones)) { + L1143_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1142_T_Thing); + M33_setMapAndTime(L1147_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 1); + L1147_s_Event._type = k13_TMEventTypeViAltarRebirth; + L1147_s_Event._priority = L1143_ps_Junk->getChargeCount(); + L1147_s_Event._B._location._mapX = L1140_i_MapX; + L1147_s_Event._B._location._mapY = L1141_i_MapY; + L1147_s_Event._C.A._cell = L1145_ui_Cell; + L1147_s_Event._C.A._effect = k2_SensorEffToggle; + _vm->_timeline->f238_addEventGetEventIndex(&L1147_s_Event); + } + _vm->_g321_stopWaitingForPlayerInput = true; +} + bool EventManager::f360_hasPendingClick(Common::Point& point, MouseButton button) { if (_g439_pendingClickButton && button == _g439_pendingClickButton) point = _g437_pendingClickPos; @@ -701,4 +994,15 @@ bool EventManager::f360_hasPendingClick(Common::Point& point, MouseButton button return _g436_pendingClickPresent; } +void EventManager::f379_drawSleepScreen() { + _vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 224, 136); // TODO: localization +} + +void EventManager::f357_discardAllInput() { + Common::Event event; + while (_vm->_system->getEventManager()->pollEvent(event)) + ; + _commandQueue.clear(); +} + } // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index c156eedd94..d1ded67f35 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -211,6 +211,16 @@ public: class DMEngine; +#define k0_pointerArrow 0 // @ C0_POINTER_ARROW +#define k1_pointerHand 1 // @ C1_POINTER_HAND + +#define k0_pointerTypeArrow 0 // @ C0_POINTER_TYPE_ARROW +#define k1_pointerTypeObjectIcon 1 // @ C1_POINTER_TYPE_OBJECT_ICON +#define k2_pointerTypeChampionIcon 2 // @ C2_POINTER_TYPE_CHAMPION_ICON +#define k3_pointerTypeHand 3 // @ C3_POINTER_TYPE_HAND +#define k4_pointerTypeAutoselect 4 // @ C4_POINTER_TYPE_AUTOSELECT + + class EventManager { DMEngine *_vm; @@ -220,6 +230,14 @@ class EventManager { bool _g436_pendingClickPresent; // G0436_B_PendingClickPresent Common::Point _g437_pendingClickPos; // @ G0437_i_PendingClickX, G0438_i_PendingClickY MouseButton _g439_pendingClickButton; // @ G0439_i_PendingClickButtonsStatus + bool _g600_useObjectAsMousePointerBitmap; // @ G0600_B_UseObjectAsMousePointerBitmap + bool _g601_useHandAsMousePointerBitmap; // @ G0601_B_UseHandAsMousePointerBitmap + bool _gK100_preventBuildPointerScreenArea; // @ K0100_B_PreventBuildPointerScreenArea + byte *_g615_mousePointerOriginalColorsObject; // @ G0615_puc_Bitmap_MousePointerOriginalColorsObject + byte *_g613_mousePointerOriginalColorsChampionIcon; // @ G0613_puc_Bitmap_MousePointerOriginalColorsChampionIcon + byte *_gK190_mousePointerTempBuffer; // @ K0190_puc_Bitmap_MousePointerTemporaryBuffer + int16 _gK104_mousePointerType; // @ K0104_i_MousePointerType + int16 _gK105_previousMousePointerType; // @ K0105_i_PreviousMousePointerType // this doesn't seem to be used anywhere at all bool _g435_isCommandQueueLocked; // @ G0435_B_CommandQueueLocked @@ -227,8 +245,12 @@ class EventManager { void f365_commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty void f366_commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty + bool f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY); // @ F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown + + public: explicit EventManager(DMEngine *vm); + ~EventManager(); MouseInput* _g441_primaryMouseInput;// @ G0441_ps_PrimaryMouseInput MouseInput* _g442_secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput @@ -238,7 +260,13 @@ public: uint16 _g599_useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap void initMouse(); - void showMouse(bool visibility); + void f67_setMousePointerToNormal(int16 mousePointer); // @ F0067_MOUSE_SetPointerToNormal + void f68_setPointerToObject(byte *bitmap); // @ F0068_MOUSE_SetPointerToObject + void f71_mouseDropChampionIcon(); // @ F0071_MOUSE_DropChampionIcon + void f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY); // @ F0073_MOUSE_BuildPointerScreenArea + void f69_setMousePointer(); // @ F0069_MOUSE_SetPointer + void f78_showMouse(); // @ F0077_MOUSE_HidePointer_CPSE + void f77_hideMouse(); // @ F0078_MOUSE_ShowPointer void setMousePos(Common::Point pos); void processInput(); // acknowledges mouse and keyboard input @@ -252,8 +280,12 @@ public: void f377_commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView void f282_commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel void f378_commandProcess81ClickInPanel(int16 x, int16 y); // @ F0378_COMMAND_ProcessType81_ClickInPanel + void f373_processType80_clickInDungeonView_grabLeaderHandObject(uint16 viewCell); // @ F0373_COMMAND_ProcessType80_ClickInDungeonView_GrabLeaderHandObject + void f374_processType80_clickInDungeonViewDropLeaderHandObject(uint16 viewCell); // @ F0374_COMMAND_ProcessType80_ClickInDungeonView_DropLeaderHandObject bool f360_hasPendingClick(Common::Point &point, MouseButton button); // @ F0360_COMMAND_ProcessPendingClick + void f379_drawSleepScreen(); // @ F0379_COMMAND_DrawSleepScreen + void f357_discardAllInput(); // @ F0357_COMMAND_DiscardAllInput }; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 460e7b54a9..05c8f172cd 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -745,6 +745,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _screenWidth = _screenHeight = 0; _g289_championPortraitOrdinal = 0; _g266_currMapViAltarIndex = 0; + _g297_drawFloorAndCeilingRequested = true; for (int i = 0; i < 4; i++) @@ -1534,6 +1535,16 @@ void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame* frame, int1 } } +void DisplayMan::f21_blitToScreen(byte *bitmap, int16* box, int16 byteWidth, Color transparent, int16 height) { + Box actualBox(box[0], box[1], box[2], box[3]); + f21_blitToScreen(bitmap, &actualBox, byteWidth, transparent, height); +} + +void DisplayMan::f21_blitToScreen(byte* bitmap, Box* box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal) { + _g578_useByteBoxCoordinates = false; + f132_blitToBitmap(bitmap, _g348_bitmapScreen, *box, 0, 0, byteWidth, k112_byteWidthViewport, transparent, height, k136_heightViewport); +} + void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { if (f._srcByteWidth) f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency); @@ -1597,7 +1608,6 @@ T0116017_orangeElk: } } -// NOTE: has been screened for missing code void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) { int16 order; uint16 squareAspect[5]; @@ -2010,7 +2020,7 @@ void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) { } if (_vm->_championMan->_g407_party._event73Count_ThievesEye) { f132_blitToBitmap(f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea), - _g296_bitmapViewport, g106_BoxThievesEye_ViewPortVisibleArea, 0, 0, + _g296_bitmapViewport, g106_BoxThievesEye_ViewPortVisibleArea, 0, 0, 48, k112_byteWidthViewport, k9_ColorGold, 95, k136_heightViewport); /* BUG0_74 */ f493_addDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea); warning("MISSING CODE: F0480_CACHE_ReleaseBlock"); @@ -2036,7 +2046,7 @@ void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) { T0124017: order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight; /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ - f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C); + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C); f112_drawCeilingPit(k66_ceilingPitD1C_GraphicIndice, &g156_FrameFloorPit_D1C, posX, posY, false); T0124018: f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, order); @@ -2094,13 +2104,13 @@ void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) { int16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect((uint16*) squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); switch (squareAspect[k0_ElemAspect]) { case k16_DoorSideElemType: if (_vm->_championMan->_g407_party._event73Count_ThievesEye) { memmove(_g74_tmpBitmap, _g709_bitmapWallSet_DoorFrameFront, 32 * 123); f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice), - _g74_tmpBitmap, g108_BoxThievesEyeHoleInDoorFrame, g172_Frame_DoorFrame_D0C._box._x1 - g106_BoxThievesEye_ViewPortVisibleArea._x1, + _g74_tmpBitmap, g108_BoxThievesEyeHoleInDoorFrame, g172_Frame_DoorFrame_D0C._box._x1 - g106_BoxThievesEye_ViewPortVisibleArea._x1, 0, 48, 16, k9_ColorGold, 95, 123); f100_drawWallSetBitmap(_g74_tmpBitmap, g172_Frame_DoorFrame_D0C); } else { @@ -2127,16 +2137,17 @@ void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) { } void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) { - loadPalette(g20_PalEntrance); - // TODO: this is a global variable, set from here - bool flippedFloorCeiling = true; + loadPalette(g20_PalEntrance); // dummy code + if (_g297_drawFloorAndCeilingRequested) + f98_drawFloorAndCeiling(); + _g578_useByteBoxCoordinates = true; for (int16 i = 0; i < 6; ++i) _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i].setToZero(); for (uint16 i = 0; i < 6; ++i) { - _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i]._x1 = 255 + 1; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[i]._x1 = 255; } if (_g76_useFlippedWallAndFootprintsBitmap = (posX + posY + dir) & 1) { @@ -2144,68 +2155,96 @@ void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) { f99_copyBitmapAndFlipHorizontal(_g84_bitmapFloor, _g74_tmpBitmap, k112_byteWidthViewport, 70); f100_drawWallSetBitmap(_g74_tmpBitmap, gK13_FloorFrame); - if (flippedFloorCeiling) { - _g698_bitmapWallSet_Wall_D3LCR = _g90_bitmapWall_D3LCR_Flipped; - _g699_bitmapWallSet_Wall_D2LCR = _g91_bitmapWall_D2LCR_Flipped; - _g700_bitmapWallSet_Wall_D1LCR = _g92_bitmapWall_D1LCR_Flipped; - _g701_bitmapWallSet_Wall_D0L = _g93_bitmapWall_D0L_Flipped; - _g702_bitmapWallSet_Wall_D0R = _g94_bitmapWall_D0R_Flipped; - } + _g698_bitmapWallSet_Wall_D3LCR = _g90_bitmapWall_D3LCR_Flipped; + _g699_bitmapWallSet_Wall_D2LCR = _g91_bitmapWall_D2LCR_Flipped; + _g700_bitmapWallSet_Wall_D1LCR = _g92_bitmapWall_D1LCR_Flipped; + _g701_bitmapWallSet_Wall_D0L = _g93_bitmapWall_D0L_Flipped; + _g702_bitmapWallSet_Wall_D0R = _g94_bitmapWall_D0R_Flipped; } else { f99_copyBitmapAndFlipHorizontal(_g85_bitmapCeiling, _g74_tmpBitmap, k112_byteWidthViewport, 29); f100_drawWallSetBitmap(_g74_tmpBitmap, gK12_CeilingFrame); f100_drawWallSetBitmap(_g84_bitmapFloor, gK13_FloorFrame); } - if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, -2, posX, posY) == k0_WallElemType) + if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, -2, posX, posY) == k0_ElementTypeWall) { f100_drawWallSetBitmap(_g697_bitmapWallSet_Wall_D3L2, g711_FrameWall_D3L2); - if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, 2, posX, posY) == k0_WallElemType) + } + if (_vm->_dungeonMan->f153_getRelSquareType(dir, 3, 2, posX, posY) == k0_ElementTypeWall) { f100_drawWallSetBitmap(_g696_bitmapWallSet_Wall_D3R2, g712_FrameWall_D3R2); + } - int16 tmpPosX = posX, tmpPosY = posY; + int16 tmpPosX = posX; + int16 tmpPosY = posY; + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 4, -1, tmpPosX, tmpPosY); + f115_cthulhu(_vm->_dungeonMan->f162_getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM2_ViewSquare_D4L, k0x0001_CellOrder_BackLeft); + tmpPosX = posX; + tmpPosY = posY; + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 4, 1, tmpPosX, tmpPosY); + f115_cthulhu(_vm->_dungeonMan->f162_getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM1_ViewSquare_D4R, k0x0001_CellOrder_BackLeft); + tmpPosX = posX; + tmpPosY = posY; + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 4, 0, tmpPosX, tmpPosY); + f115_cthulhu(_vm->_dungeonMan->f162_getSquareFirstObject(tmpPosX, tmpPosY), dir, tmpPosX, tmpPosY, kM3_ViewSquare_D4C, k0x0001_CellOrder_BackLeft); + tmpPosX = posX; + tmpPosY = posY; _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, -1, tmpPosX, tmpPosY); f116_drawSquareD3L(dir, tmpPosX, tmpPosY); - tmpPosX = posX, tmpPosY = posY; + tmpPosX = posX; + tmpPosY = posY; _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, 1, tmpPosX, tmpPosY); f117_drawSquareD3R(dir, tmpPosX, tmpPosY); - tmpPosX = posX, tmpPosY = posY; + tmpPosX = posX; + tmpPosY = posY; _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 3, 0, tmpPosX, tmpPosY); f118_drawSquareD3C(dir, tmpPosX, tmpPosY); - tmpPosX = posX, tmpPosY = posY; + tmpPosX = posX; + tmpPosY = posY; _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, -1, tmpPosX, tmpPosY); f119_drawSquareD2L(dir, tmpPosX, tmpPosY); - tmpPosX = posX, tmpPosY = posY; + tmpPosX = posX; + tmpPosY = posY; _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, 1, tmpPosX, tmpPosY); f120_drawSquareD2R(dir, tmpPosX, tmpPosY); - tmpPosX = posX, tmpPosY = posY; + tmpPosX = posX; + tmpPosY = posY; _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 2, 0, tmpPosX, tmpPosY); f121_drawSquareD2C(dir, tmpPosX, tmpPosY); - tmpPosX = posX, tmpPosY = posY; + tmpPosX = posX; + tmpPosY = posY; _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, -1, tmpPosX, tmpPosY); f122_drawSquareD1L(dir, tmpPosX, tmpPosY); - tmpPosX = posX, tmpPosY = posY; + tmpPosX = posX; + tmpPosY = posY; _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, 1, tmpPosX, tmpPosY); f123_drawSquareD1R(dir, tmpPosX, tmpPosY); - tmpPosX = posX, tmpPosY = posY; + tmpPosX = posX; + tmpPosY = posY; _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 1, 0, tmpPosX, tmpPosY); f124_drawSquareD1C(dir, tmpPosX, tmpPosY); - tmpPosX = posX, tmpPosY = posY; + tmpPosX = posX; + tmpPosY = posY; _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 0, -1, tmpPosX, tmpPosY); f125_drawSquareD0L(dir, tmpPosX, tmpPosY); - tmpPosX = posX, tmpPosY = posY; + tmpPosX = posX; + tmpPosY = posY; _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(dir, 0, 1, tmpPosX, tmpPosY); f126_drawSquareD0R(dir, tmpPosX, tmpPosY); f127_drawSquareD0C(dir, posX, posY); - if (flippedFloorCeiling) { - _g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native; - _g699_bitmapWallSet_Wall_D2LCR = _g96_bitmapWall_D2LCR_Native; - _g700_bitmapWallSet_Wall_D1LCR = _g97_bitmapWall_D1LCR_Native; - _g701_bitmapWallSet_Wall_D0L = _g98_bitmapWall_D0L_Native; - _g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native; - } + _g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native; + _g699_bitmapWallSet_Wall_D2LCR = _g96_bitmapWall_D2LCR_Native; + _g700_bitmapWallSet_Wall_D1LCR = _g97_bitmapWall_D1LCR_Native; + _g701_bitmapWallSet_Wall_D0L = _g98_bitmapWall_D0L_Native; + _g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native; f97_drawViewport((_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0); + if (_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) + f98_drawFloorAndCeiling(); +} + +void DisplayMan::f98_drawFloorAndCeiling() { + warning("f98_drawFloorAndCeiling doesn't do anything"); + _g297_drawFloorAndCeilingRequested = false; } void DisplayMan::fillScreen(Color color) { @@ -2378,6 +2417,7 @@ void DisplayMan::f96_loadCurrentMapGraphics() { f93_applyCreatureReplColors(10, _vm->M1_ordinalToIndex(replColorOrdinal)); } + _g297_drawFloorAndCeilingRequested = true; _g342_refreshDungeonViewPaleteRequested = true; } @@ -2464,7 +2504,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall wallOrnOrd--; AL0088_i_NativeBitmapIndex = _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k0_NativeBitmapIndex]; - AL0090_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex = + AL0090_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex = _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k1_CoordinateSet]][viewWallIndex]; L0096_B_IsAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(AP0116_i_WallOrnamentIndex); @@ -2474,7 +2514,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) { if (viewWallIndex == k12_ViewWall_D1C_FRONT) { if (L0095_B_IsInscription) { - f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR,_g296_bitmapViewport, + f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, g202_BoxWallPatchBehindInscription, 94, 28, g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport); @@ -2543,7 +2583,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall } } AL0089_i_PixelWidth = (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[1] - (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[0]; - if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + + if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + (AP0116_i_WallOrnamentIndex << 2) + g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex])) { L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex); f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex), @@ -2583,16 +2623,16 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall } } f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport, - *(Box*)AL0090_puc_CoordinateSet, AL0089_i_X, 0, + *(Box*)AL0090_puc_CoordinateSet, AL0089_i_X, 0, AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport); -/* BUG0_05 A champion portrait sensor on a wall square is visible on all sides of the wall. +/* BUG0_05 A champion portrait sensor on a wall square is visible on all sides of the wall. If there is another sensor with a wall ornament on one side of the wall then the champion portrait is drawn over that wall ornament */ - if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { + if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { /* A portrait is 32x29 pixels */ f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), - _g296_bitmapViewport, g109_BoxChampionPortraitOnWall, + _g296_bitmapViewport, g109_BoxChampionPortraitOnWall, (_g289_championPortraitOrdinal & 0x0007) << 5, - (_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); + (_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); } T0107031: return L0096_B_IsAlcove; @@ -2648,7 +2688,7 @@ void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) { } } - byte *bitmap = dispMan.f489_getNativeBitmapOrGraphic(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex); + // byte *bitmap = dispMan.f489_getNativeBitmapOrGraphic(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex); warning("MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap"); warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock"); @@ -3375,7 +3415,7 @@ continue; do { if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) { projectile = (Projectile*)dunMan.f156_getThingData(thingParam); - if ((AL_4_projectileAspect = dunMan.f142_getProjectileAspect(projectile->_object)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */ + if ((AL_4_projectileAspect = dunMan.f142_getProjectileAspect(projectile->_slot)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */ objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)]; AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice; projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask); @@ -3400,7 +3440,7 @@ continue; projectileBitmapIndexData = 0; flipVertical = flipHorizontal = false; } else { - if (isOrientedWestEast((direction)(projectileDirection = _vm->_timeline->_g370_events[projectile->_timerIndex]._C._projectile.getDir())) + if (isOrientedWestEast((direction)(projectileDirection = _vm->_timeline->_g370_events[projectile->_eventIndex]._C._projectile.getDir())) != isOrientedWestEast(directionParam)) { if (projectileAspectType == k2_ProjectileAspectHasRotation) { projectileBitmapIndexData = 1; diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index cfe271052d..4cdf6139ff 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -286,9 +286,16 @@ public: Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2) : _x1(x1), _x2(x2), _y1(y1), _y2(y2) {} Box() {} + explicit Box(uint16 *ptr) { + _x1 = *ptr++; + _x2 = *ptr++; + _y1 = *ptr++; + _y2 = *ptr++; + } bool isPointInside(Common::Point point) { return (_x1 <= point.x) && (point.x <= _x2) && (_y1 <= point.y) && (point.y <= _y2); // <= because incluseive boundaries } + bool isPointInside(int16 x, int16 y) { return isPointInside(Common::Point(x, y)); } void setToZero() { _x1 = _x2 = _y1 = _y2 = 0; } }; // @ BOX_BYTE, BOX_WORD @@ -453,6 +460,18 @@ public: #define k160_byteWidthScreen 160 // @ C160_BYTE_WIDTH_SCREEN #define k200_heightScreen 200 // @ C200_HEIGHT_SCREEN +#define k8_byteWidth 8 // @ C008_BYTE_WIDTH +#define k16_byteWidth 16 // @ C016_BYTE_WIDTH +#define k24_byteWidth 24 // @ C024_BYTE_WIDTH +#define k32_byteWidth 32 // @ C032_BYTE_WIDTH +#define k40_byteWidth 40 // @ C040_BYTE_WIDTH +#define k48_byteWidth 48 // @ C048_BYTE_WIDTH +#define k64_byteWidth 64 // @ C064_BYTE_WIDTH +#define k72_byteWidth 72 // @ C072_BYTE_WIDTH +#define k128_byteWidth 128 // @ C128_BYTE_WIDTH +#define k144_byteWidth 144 // @ C144_BYTE_WIDTH + + class DoorFrames { public: Frame _closedOrDestroyed; @@ -626,6 +645,9 @@ public: void f112_drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int16 mapX, int16 mapY, bool flipHorizontal); // @ F0112_DUNGEONVIEW_DrawCeilingPit + void f21_blitToScreen(byte* bitmap, int16 *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen + void f21_blitToScreen(byte* bitmap, Box *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen + /* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters @@ -651,6 +673,7 @@ public: /* Expects inclusive boundaries in box */ void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 byteWidth, int16 height); // @ F0135_VIDEO_FillBox void f128_drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF + void f98_drawFloorAndCeiling(); // @ F0098_DUNGEONVIEW_DrawFloorAndCeiling void updateScreen(); void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport @@ -683,6 +706,8 @@ public: Thing _g290_inscriptionThing; // @ G0290_T_DungeonView_InscriptionThing + bool _g297_drawFloorAndCeilingRequested; // @ G0297_B_DrawFloorAndCeilingRequested + // This tells blitting functions wther to assume a BYTE_BOX or a WORD_BOX has been passed to them, // I only use WORD_BOX, so this will probably deem useless bool _g578_useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 3fa8c4a3b1..7f845c6aa1 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -28,14 +28,19 @@ #include "group.h" #include "dungeonman.h" #include "champion.h" - +#include "movesens.h" +#include "projexpl.h" +#include "timeline.h" namespace DM { - +int32 M32_setTime(int32 &map_time, int32 time) { + return map_time = (map_time & 0xFF000000) | time; +} GroupMan::GroupMan(DMEngine* vm) : _vm(vm) { _g375_activeGroups = nullptr; + _g377_currActiveGroupCount = 0; } GroupMan::~GroupMan() { @@ -97,4 +102,1634 @@ int16 GroupMan::f176_getCreatureOrdinalInCell(Group* group, uint16 cell) { uint16 GroupMan::M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex) { return (groupVal >> (creatureIndex << 1)) & 0x3; } + +void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode) { + Thing L0365_T_CurrentThing; + Thing L0366_T_NextThing; + Group* L0367_ps_Group; + uint16 L0368_ui_CreatureType; + int16 L0369_i_CreatureIndex; + uint16 L0370_ui_GroupCells; + bool L0371_B_WeaponDropped; + + + L0367_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(groupThing); + if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[L0368_ui_CreatureType = L0367_ps_Group->_type]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) { + L0369_i_CreatureIndex = L0367_ps_Group->getCount(); + L0370_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(L0367_ps_Group, _vm->_dungeonMan->_g272_currMapIndex); + do { + _vm->_groupMan->f186_dropCreatureFixedPossessions(L0368_ui_CreatureType, mapX, mapY, (L0370_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0370_ui_GroupCells, L0369_i_CreatureIndex), mode); + } while (L0369_i_CreatureIndex--); + } + if ((L0365_T_CurrentThing = L0367_ps_Group->_slot) != Thing::_endOfList) { + L0371_B_WeaponDropped = false; + do { + L0366_T_NextThing = _vm->_dungeonMan->f159_getNextThing(L0365_T_CurrentThing); + L0365_T_CurrentThing = M15_thingWithNewCell(L0365_T_CurrentThing, _vm->getRandomNumber(4)); + if ((L0365_T_CurrentThing).getType() == k5_WeaponThingType) { + L0371_B_WeaponDropped = true; + } + _vm->_movsens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY); + } while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList); + if (mode >= k0_soundModePlayImmediately) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + } +} + +void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell, int16 mode) { + static uint16 g245FixedPossessionCreature_12Skeleton[3] = { // @ G0245_aui_Graphic559_FixedPossessionsCreature12Skeleton + k23_ObjectInfoIndexFirstWeapon + k9_WeaponTypeFalchion, + k69_ObjectInfoIndexFirstArmour + k30_ArmourTypeWoodenShield, 0}; + static uint16 g246FixedPossessionCreature_9StoneGolem[2] = { // @ G0246_aui_Graphic559_FixedPossessionsCreature09StoneGolem + k23_ObjectInfoIndexFirstWeapon + k24_WeaponTypeStoneClub, 0}; + static uint16 g247FixedPossessionCreature_16TrolinAntman[2] = { // @ G0247_aui_Graphic559_FixedPossessionsCreature16Trolin_Antman + k23_ObjectInfoIndexFirstWeapon + k23_WeaponTypeClub, 0}; + static uint16 g248FixedPossessionCreature_18AnimatedArmourDethKnight[7] = { // @ G0248_aui_Graphic559_FixedPossessionsCreature18AnimatedArmour_DethKnight + k69_ObjectInfoIndexFirstArmour + k41_ArmourTypeFootPlate, + k69_ObjectInfoIndexFirstArmour + k40_ArmourTypeLegPlate, + k69_ObjectInfoIndexFirstArmour + k39_ArmourTypeTorsoPlate, + k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword, + k69_ObjectInfoIndexFirstArmour + k38_ArmourTypeArmet, + k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword, 0}; + static uint16 g249FixedPossessionCreature_7rockRockPile[5] = { // @ G0249_aui_Graphic559_FixedPossessionsCreature07Rock_RockPile + k127_ObjectInfoIndexFirstJunk + k25_JunkTypeBoulder, + k127_ObjectInfoIndexFirstJunk + k25_JunkTypeBoulder | k0x8000_randomDrop, + k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop, + k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop, 0}; + static uint16 g250FixedPossessionCreature_4PainRatHellHound[3] = { // @ G0250_aui_Graphic559_FixedPossessionsCreature04PainRat_Hellhound + k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank, + k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank | k0x8000_randomDrop, 0}; + static uint16 g251FixedPossessionCreature_6screamer[3] = { // @ G0251_aui_Graphic559_FixedPossessionsCreature06Screamer + k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice, + k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice | k0x8000_randomDrop, 0}; + static uint16 g252FixedPossessionCreature_15MagnetaWormWorm[4] = { // @ G0252_aui_Graphic559_FixedPossessionsCreature15MagentaWorm_Worm + k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound, + k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop, + k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop, 0}; + static uint16 g253FixedPossessionCreature_24RedDragon[11] = { // @ G0253_aui_Graphic559_FixedPossessionsCreature24RedDragon + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop, 0}; + + uint16 L0356_ui_FixedPossession; + int16 L0357_i_ThingType; + Thing L0358_T_Thing; + uint16* L0359_pui_FixedPossessions; + Weapon* L0360_ps_Weapon; + bool L0361_B_Cursed; + bool L0362_B_WeaponDropped; + + + L0361_B_Cursed = false; + L0362_B_WeaponDropped = false; + switch (creatureType) { + default: + return; + case k12_CreatureTypeSkeleton: + L0359_pui_FixedPossessions = g245FixedPossessionCreature_12Skeleton; + break; + case k9_CreatureTypeStoneGolem: + L0359_pui_FixedPossessions = g246FixedPossessionCreature_9StoneGolem; + break; + case k16_CreatureTypeTrolinAntman: + L0359_pui_FixedPossessions = g247FixedPossessionCreature_16TrolinAntman; + break; + case k18_CreatureTypeAnimatedArmourDethKnight: + L0361_B_Cursed = true; + L0359_pui_FixedPossessions = g248FixedPossessionCreature_18AnimatedArmourDethKnight; + break; + case k7_CreatureTypeRockpile: + L0359_pui_FixedPossessions = g249FixedPossessionCreature_7rockRockPile; + break; + case k4_CreatureTypePainRatHellHound: + L0359_pui_FixedPossessions = g250FixedPossessionCreature_4PainRatHellHound; + break; + case k6_CreatureTypeScreamer: + L0359_pui_FixedPossessions = g251FixedPossessionCreature_6screamer; + break; + case k15_CreatureTypeMagnetaWormWorm: + L0359_pui_FixedPossessions = g252FixedPossessionCreature_15MagnetaWormWorm; + break; + case k24_CreatureTypeRedDragon: + L0359_pui_FixedPossessions = g253FixedPossessionCreature_24RedDragon; + } + while (L0356_ui_FixedPossession = *L0359_pui_FixedPossessions++) { + if (getFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) && _vm->getRandomNumber(2)) + continue; + if (clearFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) >= k127_ObjectInfoIndexFirstJunk) { + L0357_i_ThingType = k10_JunkThingType; + L0356_ui_FixedPossession -= k127_ObjectInfoIndexFirstJunk; + } else { + if (L0356_ui_FixedPossession >= k69_ObjectInfoIndexFirstArmour) { + L0357_i_ThingType = k6_ArmourThingType; + L0356_ui_FixedPossession -= k69_ObjectInfoIndexFirstArmour; + } else { + L0362_B_WeaponDropped = true; + L0357_i_ThingType = k5_WeaponThingType; + L0356_ui_FixedPossession -= k23_ObjectInfoIndexFirstWeapon; + } + } + if ((L0358_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(L0357_i_ThingType)) == Thing::_none) { + continue; + } + L0360_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0358_T_Thing); +/* The same pointer type is used no matter the actual type k5_WeaponThingType, k6_ArmourThingType or k10_JunkThingType */ + L0360_ps_Weapon->setType(L0356_ui_FixedPossession); + L0360_ps_Weapon->setCursed(L0361_B_Cursed); + L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell); + _vm->_movsens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY); + } + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); +} + +int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) { +#define AP0483_i_PrimaryDirection srcMapX + int16 L0556_i_Direction; + + + if (srcMapX == destMapX) { + _vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 1; /* Resulting direction may be 1 or 3 (East or West) */ + if (srcMapY > destMapY) { + return kDirNorth; + } + return kDirSouth; + } + if (srcMapY == destMapY) { + _vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 0; /* Resulting direction may be 0 or 2 (North or South) */ + if (srcMapX > destMapX) { + return kDirWest; + } + return kDirEast; + } + L0556_i_Direction = kDirNorth; + for (;;) { + if (f227_isDestVisibleFromSource(L0556_i_Direction, srcMapX, srcMapY, destMapX, destMapY)) { + if (!f227_isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) { + if ((L0556_i_Direction != kDirNorth) || !f227_isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnPrevVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) { + _vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + L0556_i_Direction); + return L0556_i_Direction; + } + } + if (_vm->getRandomNumber(2)) { + AP0483_i_PrimaryDirection = _vm->_projexpl->_g363_secondaryDirToOrFromParty; + _vm->_projexpl->_g363_secondaryDirToOrFromParty = L0556_i_Direction; + return AP0483_i_PrimaryDirection; + } + return L0556_i_Direction; + } + L0556_i_Direction++; + } +} + +bool GroupMan::f227_isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) { + int L1637_i_Temp; + + switch (dir) { /* If direction is not 'West' then swap variables so that the same test as for west can be applied */ + case kDirSouth: + L1637_i_Temp = srcMapX; + srcMapX = destMapY; + destMapY = L1637_i_Temp; + L1637_i_Temp = destMapX; + destMapX = srcMapY; + srcMapY = L1637_i_Temp; + break; + case kDirEast: + L1637_i_Temp = srcMapX; + srcMapX = destMapX; + destMapX = L1637_i_Temp; + L1637_i_Temp = destMapY; + destMapY = srcMapY; + srcMapY = L1637_i_Temp; + break; + case kDirNorth: + L1637_i_Temp = srcMapX; + srcMapX = srcMapY; + srcMapY = L1637_i_Temp; + L1637_i_Temp = destMapX; + destMapX = destMapY; + destMapY = L1637_i_Temp; + } + return ((srcMapX -= (destMapX - 1)) > 0) && ((((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY) <= srcMapX); +} + +bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack, bool magicAttack, int16 ticks) { + Door* L0573_ps_Door; + byte* L0574_puc_Square; + TimelineEvent L0575_s_Event; + + L0573_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY); + if ((magicAttack && !L0573_ps_Door->isMagicDestructible()) || (!magicAttack && !L0573_ps_Door->isMeleeDestructible())) { + return false; + } + if (attack >= _vm->_dungeonMan->_g275_currMapDoorInfo[L0573_ps_Door->getType()]._defense) { + L0574_puc_Square = &_vm->_dungeonMan->_g271_currMapData[mapX][mapY]; + if (Square(*L0574_puc_Square).getDoorState() == k4_doorState_CLOSED) { + if (ticks) { + M33_setMapAndTime(L0575_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ticks); + L0575_s_Event._type = k2_TMEventTypeDoorDestruction; + L0575_s_Event._priority = 0; + L0575_s_Event._B._location._mapX = mapX; + L0575_s_Event._B._location._mapY = mapY; + _vm->_timeline->f238_addEventGetEventIndex(&L0575_s_Event); + } else { + ((Square*)L0574_puc_Square)->setDoorState(k5_doorState_DESTROYED); + } + return true; + } + } + return false; +} + +Thing GroupMan::f175_groupGetThing(int16 mapX, int16 mapY) { + Thing L0317_T_Thing; + + L0317_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY); + while ((L0317_T_Thing != Thing::_endOfList) && ((L0317_T_Thing).getType() != k4_GroupThingType)) { + L0317_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0317_T_Thing); + } + return L0317_T_Thing; +} + +int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group* group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) { + uint16 L0374_ui_Multiple; +#define AL0374_ui_EventIndex L0374_ui_Multiple +#define AL0374_ui_CreatureIndex L0374_ui_Multiple +#define AL0374_ui_CreatureSize L0374_ui_Multiple +#define AL0374_ui_Attack L0374_ui_Multiple + uint16 L0375_ui_Multiple; +#define AL0375_ui_Outcome L0375_ui_Multiple +#define AL0375_ui_EventType L0375_ui_Multiple +#define AL0375_ui_NextCreatureIndex L0375_ui_Multiple + CreatureInfo* L0376_ps_CreatureInfo; + TimelineEvent* L0377_ps_Event; + ActiveGroup* L0378_ps_ActiveGroup = nullptr; + uint16 L0379_ui_CreatureCount; + uint16 L0380_ui_Multiple = 0; +#define AL0380_ui_CreatureType L0380_ui_Multiple +#define AL0380_ui_FearResistance L0380_ui_Multiple + uint16 L0381_ui_GroupCells; + uint16 L0382_ui_GroupDirections; + bool L0383_B_CurrentMapIsPartyMap; + uint16 L0384_ui_Cell; + + + L0376_ps_CreatureInfo = &g243_CreatureInfo[AL0380_ui_CreatureType = group->_type]; + if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) /* Lord Chaos cannot be damaged */ + goto T0190024; + if (group->_health[creatureIndex] <= damage) { + L0381_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(group, _vm->_dungeonMan->_g272_currMapIndex); + L0384_ui_Cell = (L0381_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0381_ui_GroupCells, creatureIndex); + if (!(L0379_ui_CreatureCount = group->getCount())) { /* If there is a single creature in the group */ + if (notMoving) { + f188_dropGroupPossessions(mapX, mapY, _vm->_groupMan->f175_groupGetThing(mapX, mapY), k2_soundModePlayOneTickLater); + f189_delete(mapX, mapY); + } + AL0375_ui_Outcome = k2_outcomeKilledAllCreaturesInGroup; + } else { /* If there are several creatures in the group */ + L0382_ui_GroupDirections = _vm->_groupMan->f147_getGroupDirections(group, _vm->_dungeonMan->_g272_currMapIndex); + if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) { + if (notMoving) { + f186_dropCreatureFixedPossessions(AL0380_ui_CreatureType, mapX, mapY, L0384_ui_Cell, k2_soundModePlayOneTickLater); + } else { + _g392_dropMovingCreatureFixedPossessionsCell[_g391_dropMovingCreatureFixedPossCellCount++] = L0384_ui_Cell; + } + } + if (L0383_B_CurrentMapIsPartyMap = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) { + L0378_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]; + } + if (group->getBehaviour() == k6_behavior_ATTACK) { + L0377_ps_Event = _vm->_timeline->_g370_events; + for (AL0374_ui_EventIndex = 0; AL0374_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; AL0374_ui_EventIndex++) { + if ((M29_map(L0377_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) && + (L0377_ps_Event->_B._location._mapX == mapX) && + (L0377_ps_Event->_B._location._mapY == mapY) && + ((AL0375_ui_EventType = L0377_ps_Event->_type) > k32_TMEventTypeUpdateAspectGroup) && + (AL0375_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1)) { + if (AL0375_ui_EventType < k37_TMEventTypeUpdateBehaviourGroup) { + AL0375_ui_EventType -= k33_TMEventTypeUpdateAspectCreature_0; /* Get creature index for events 33 to 36 */ + } else { + AL0375_ui_EventType -= k38_TMEventTypeUpdateBehaviour_0; /* Get creature index for events 38 to 41 */ + } + if (AL0375_ui_NextCreatureIndex == creatureIndex) { + _vm->_timeline->f237_deleteEvent(AL0374_ui_EventIndex); + } else { + if (AL0375_ui_NextCreatureIndex > creatureIndex) { + L0377_ps_Event->_type -= 1; + _vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(AL0374_ui_EventIndex)); + } + } + } + L0377_ps_Event++; + } + if (L0383_B_CurrentMapIsPartyMap && ((AL0380_ui_FearResistance = L0376_ps_CreatureInfo->M57_getFearResistance()) != k15_immuneToFear) && ((AL0380_ui_FearResistance += L0379_ui_CreatureCount - 1) < (_vm->getRandomNumber(16)))) { /* Test if the death of a creature frigthens the remaining creatures in the group */ + L0378_ps_ActiveGroup->_delayFleeingFromTarget = _vm->getRandomNumber(100 - (AL0380_ui_FearResistance << 2)) + 20; + group->setBehaviour(k5_behavior_FLEE); + } + } + for (AL0375_ui_NextCreatureIndex = AL0374_ui_CreatureIndex = creatureIndex; AL0374_ui_CreatureIndex < L0379_ui_CreatureCount; AL0374_ui_CreatureIndex++) { + AL0375_ui_NextCreatureIndex++; + group->_health[AL0374_ui_CreatureIndex] = group->_health[AL0375_ui_NextCreatureIndex]; + L0382_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0382_ui_GroupDirections, AL0374_ui_CreatureIndex, _vm->_groupMan->M50_getCreatureValue(L0382_ui_GroupDirections, AL0375_ui_NextCreatureIndex)); + L0381_ui_GroupCells = f178_getGroupValueUpdatedWithCreatureValue(L0381_ui_GroupCells, AL0374_ui_CreatureIndex, _vm->_groupMan->M50_getCreatureValue(L0381_ui_GroupCells, AL0375_ui_NextCreatureIndex)); + if (L0383_B_CurrentMapIsPartyMap) { + L0378_ps_ActiveGroup->_aspect[AL0374_ui_CreatureIndex] = L0378_ps_ActiveGroup->_aspect[AL0375_ui_NextCreatureIndex]; + } + } + L0381_ui_GroupCells &= 0x003F; + _vm->_dungeonMan->f146_setGroupCells(group, L0381_ui_GroupCells, _vm->_dungeonMan->_g272_currMapIndex); + _vm->_dungeonMan->f148_setGroupDirections(group, L0382_ui_GroupDirections, _vm->_dungeonMan->_g272_currMapIndex); + group->setCount(group->getCount() - 1); + AL0375_ui_Outcome = k1_outcomeKilledSomeCreaturesInGroup; + } + if ((AL0374_ui_CreatureSize = getFlag(L0376_ps_CreatureInfo->_attributes, k0x0003_MaskCreatureInfo_size)) == k0_MaskCreatureSizeQuarter) { + AL0374_ui_Attack = 110; + } else { + if (AL0374_ui_CreatureSize == k1_MaskCreatureSizeHalf) { + AL0374_ui_Attack = 190; + } else { + AL0374_ui_Attack = 255; + } + } + _vm->_projexpl->f213_explosionCreate(Thing::_explSmoke, AL0374_ui_Attack, mapX, mapY, L0384_ui_Cell); /* BUG0_66 Smoke is placed on the source map instead of the destination map when a creature dies by falling through a pit. The game has a special case to correctly drop the creature possessions on the destination map but there is no such special case for the smoke. Note that the death must be caused by the damage of the fall (there is no smoke if the creature is removed because its type is not allowed on the destination map). However this bug has no visible consequence because of BUG0_26: the smoke explosion falls in the pit right after being placed in the dungeon and before being drawn on screen so it is only visible on the destination square */ + return AL0375_ui_Outcome; + } + if (damage > 0) { + group->_health[creatureIndex] -= damage; + } +T0190024: + return k0_outcomeKilledNoCreaturesInGroup; +} + +void GroupMan::f189_delete(int16 mapX, int16 mapY) { + Thing L0372_T_GroupThing; + Group* L0373_ps_Group; + + + if ((L0372_T_GroupThing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) { + return; + } + L0373_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0372_T_GroupThing); + for (uint16 i = 0; i < 4; ++i) + L0373_ps_Group->_health[i] = 0; + _vm->_movsens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0); + L0373_ps_Group->_nextThing = Thing::_none; + if (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) { + _vm->_groupMan->_g375_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1; + _g377_currActiveGroupCount--; + } + f181_groupDeleteEvents(mapX, mapY); +} + +void GroupMan::f181_groupDeleteEvents(int16 mapX, int16 mapY) { + int16 L0334_i_EventIndex; + uint16 L0335_ui_EventType; + TimelineEvent* L0336_ps_Event; + + + L0336_ps_Event = _vm->_timeline->_g370_events; + for (L0334_i_EventIndex = 0; L0334_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0334_i_EventIndex++) { + if ((M29_map(L0336_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) && + ((L0335_ui_EventType = L0336_ps_Event->_type) > k29_TMEventTypeGroupReactionDangerOnSquare - 1) && (L0335_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1) && + (L0336_ps_Event->_B._location._mapX == mapX) && (L0336_ps_Event->_B._location._mapY == mapY)) { + _vm->_timeline->f237_deleteEvent(L0334_i_EventIndex); + } + L0336_ps_Event++; + } +} + +uint16 GroupMan::f178_getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatreVal) { + creatreVal &= 0x0003; + creatreVal <<= (creatureIndex <<= 1); + return creatreVal | (groupVal & ~(3 << creatreVal)); +} + +int16 GroupMan::f191_getDamageAllCreaturesOutcome(Group* group, int16 mapX, int16 mapY, int16 attack, bool notMoving) { + uint16 L0385_ui_RandomAttack; + int16 L0386_i_CreatureIndex; + int16 L0387_i_Outcome; + bool L0388_B_KilledSomeCreatures; + bool L0389_B_KilledAllCreatures; + + + L0388_B_KilledSomeCreatures = false; + L0389_B_KilledAllCreatures = true; + _g391_dropMovingCreatureFixedPossCellCount = 0; + if (attack > 0) { + L0386_i_CreatureIndex = group->getCount(); + attack -= (L0385_ui_RandomAttack = (attack >> 3) + 1); + L0385_ui_RandomAttack <<= 1; + do { + L0389_B_KilledAllCreatures = (L0387_i_Outcome = f190_groupGetDamageCreatureOutcome(group, L0386_i_CreatureIndex, mapX, mapY, attack + _vm->getRandomNumber(L0385_ui_RandomAttack), notMoving)) && L0389_B_KilledAllCreatures; + L0388_B_KilledSomeCreatures = L0388_B_KilledSomeCreatures || L0387_i_Outcome; + } while (L0386_i_CreatureIndex--); + if (L0389_B_KilledAllCreatures) { + return k2_outcomeKilledAllCreaturesInGroup; + } + if (L0388_B_KilledSomeCreatures) { + return k1_outcomeKilledSomeCreaturesInGroup; + } + return k0_outcomeKilledNoCreaturesInGroup; + } else { + return k0_outcomeKilledNoCreaturesInGroup; + } +} + +int16 GroupMan::f192_groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack) { + int16 L0390_i_PoisonResistance; + + + if (!poisonAttack || ((L0390_i_PoisonResistance = g243_CreatureInfo[creatreType].M61_poisonResistance()) == k15_immuneToPoison)) { + return 0; + } + return ((poisonAttack + _vm->getRandomNumber(4)) << 3) / ++L0390_i_PoisonResistance; +} + +void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks) { + Group* L0444_ps_Group; + ActiveGroup* L0445_ps_ActiveGroup; + int16 L0446_i_Multiple; +#define AL0446_i_EventType L0446_i_Multiple +#define AL0446_i_Direction L0446_i_Multiple +#define AL0446_i_Ticks L0446_i_Multiple +#define AL0446_i_Distance L0446_i_Multiple +#define AL0446_i_Behavior2Or3 L0446_i_Multiple +#define AL0446_i_CreatureAspectIndex L0446_i_Multiple +#define AL0446_i_Range L0446_i_Multiple +#define AL0446_i_CreatureAttributes L0446_i_Multiple +#define AL0446_i_Cell L0446_i_Multiple +#define AL0446_i_GroupCellsCriteria L0446_i_Multiple + int16 L0447_i_Multiple; +#define AL0447_i_Behavior L0447_i_Multiple +#define AL0447_i_CreatureIndex L0447_i_Multiple +#define AL0447_i_ReferenceDirection L0447_i_Multiple +#define AL0447_i_Ticks L0447_i_Multiple + CreatureInfo L0448_s_CreatureInfo; + Thing L0449_T_GroupThing; + int16 L0450_i_Multiple; +#define AL0450_i_DestinationMapX L0450_i_Multiple +#define AL0450_i_DistanceXToParty L0450_i_Multiple +#define AL0450_i_TargetMapX L0450_i_Multiple + int16 L0451_i_Multiple; +#define AL0451_i_DestinationMapY L0451_i_Multiple +#define AL0451_i_DistanceYToParty L0451_i_Multiple +#define AL0451_i_TargetMapY L0451_i_Multiple + int16 L0452_i_DistanceToVisibleParty = 0; + bool L0453_B_NewGroupDirectionFound; + int16 L0454_i_PrimaryDirectionToOrFromParty; + bool L0455_B_CurrentEventTypeIsNotUpdateBehavior; + bool L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls; + bool L0457_B_MoveToPriorLocation; + bool L0458_B_SetBehavior7_ApproachAfterReaction = false; + int16 L0459_i_CreatureSize; + uint16 L0460_ui_CreatureCount; + int16 L0461_i_MovementTicks; + int16 L0462_i_TicksSinceLastMove; + bool L0463_B_Archenemy; + int32 L0464_l_NextAspectUpdateTime; + TimelineEvent L0465_s_NextEvent; + + + /* If the party is not on the map specified in the event and the event type is not one of 32, 33, 37, 38 then the event is ignored */ + if ((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) && ((AL0446_i_EventType = eventType) != k37_TMEventTypeUpdateBehaviourGroup) && (AL0446_i_EventType != k32_TMEventTypeUpdateAspectGroup) && (AL0446_i_EventType != k38_TMEventTypeUpdateBehaviour_0) && (AL0446_i_EventType != k33_TMEventTypeUpdateAspectCreature_0)) + goto T0209139_Return; + /* If there is no creature at the location specified in the event then the event is ignored */ + if ((L0449_T_GroupThing = _vm->_groupMan->f175_groupGetThing(eventMapX, eventMapY)) == Thing::_endOfList) { + goto T0209139_Return; + } + L0444_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0449_T_GroupThing); + L0448_s_CreatureInfo = g243_CreatureInfo[L0444_ps_Group->_type]; + /* Update the event */ + M33_setMapAndTime(L0465_s_NextEvent._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime); + L0465_s_NextEvent._priority = 255 - L0448_s_CreatureInfo._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */ + L0465_s_NextEvent._B._location._mapX = eventMapX; + L0465_s_NextEvent._B._location._mapY = eventMapY; + /* If the creature is not on the party map then try and move the creature in a random direction and place a new event 37 in the timeline for the next creature movement */ + if (_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) { + if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->getRandomNumber(4), false)) { /* BUG0_67 A group that is not on the party map may wrongly move or not move into a teleporter. Normally, a creature type with Wariness >= 10 (Vexirk, Materializer / Zytaz, Demon, Lord Chaos, Red Dragon / Dragon) would only move into a teleporter if the creature type is allowed on the destination map. However, the variable G0380_T_CurrentGroupThing identifying the group is not set before being used by F0139_DUNGEON_IsCreatureAllowedOnMap called by f202_isMovementPossible so the check to see if the creature type is allowed may operate on another creature type and thus return an incorrect result, causing the creature to teleport while it should not, or not to teleport while it should */ + AL0450_i_DestinationMapX = eventMapX; + AL0451_i_DestinationMapY = eventMapY; + AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction]; + if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY)) + goto T0209139_Return; + L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX; + L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY; + } + L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup; + AL0446_i_Ticks = MAX(ABS(_vm->_dungeonMan->_g272_currMapIndex - _vm->_dungeonMan->_g309_partyMapIndex) << 4, L0448_s_CreatureInfo._movementTicks << 1); + /* BUG0_68 A group moves or acts with a wrong timing. Event is added below but L0465_s_NextEvent.C.Ticks has not been initialized. No consequence while the group is not on the party map. When the party enters the group map the first group event may have a wrong timing */ +T0209005_AddEventAndReturn: + L0465_s_NextEvent._mapTime += AL0446_i_Ticks; + _vm->_timeline->f238_addEventGetEventIndex(&L0465_s_NextEvent); + goto T0209139_Return; + } + /* If the creature is Lord Chaos then ignore the event if the game is won. Initialize data to analyze Fluxcages */ + if (L0463_B_Archenemy = getFlag(L0448_s_CreatureInfo._attributes, k0x2000_MaskCreatureInfo_archenemy)) { + if (_vm->_g302_gameWon) { + goto T0209139_Return; + } + _g386_fluxCageCount = 0; + _g385_fluxCages[0] = 0; + } + L0445_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[L0444_ps_Group->getActiveGroupIndex()]; + if ((L0462_i_TicksSinceLastMove = (unsigned char)_vm->_g313_gameTime - L0445_ps_ActiveGroup->_lastMoveTime) < 0) { + L0462_i_TicksSinceLastMove += 256; + } + if ((L0461_i_MovementTicks = L0448_s_CreatureInfo._movementTicks) == k255_immobile) { + L0461_i_MovementTicks = 100; + } + if (_vm->_championMan->_g407_party._freezeLifeTicks && !L0463_B_Archenemy) { /* If life is frozen and the creature is not Lord Chaos (Lord Chaos is immune to Freeze Life) then reschedule the event later (except for reactions which are ignored when life if frozen) */ + if (eventType < 0) + goto T0209139_Return; + L0465_s_NextEvent._type = eventType; + L0465_s_NextEvent._C._ticks = ticks; + AL0446_i_Ticks = 4; /* Retry in 4 ticks */ + goto T0209005_AddEventAndReturn; + } + /* If the specified event type is a 'reaction' instead of a real event from the timeline then create the corresponding reaction event with a delay: + For event kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, the reaction time is 1 tick + For event kM2_TMEventTypeCreateReactionEvent30HitByProjectile and kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, the reaction time may be 1 tick or slower: slow moving creatures react more slowly. The more recent is the last creature move, the slower the reaction */ + if (eventType < 0) { + L0465_s_NextEvent._type = eventType + k32_TMEventTypeUpdateAspectGroup; + if ((eventType == kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) || ((AL0446_i_Ticks = ((L0461_i_MovementTicks + 2) >> 2) - L0462_i_TicksSinceLastMove) < 1)) { /* AL0446_i_Ticks is the reaction time */ + AL0446_i_Ticks = 1; /* Retry in 1 tick */ + } + goto T0209005_AddEventAndReturn; /* BUG0_68 A group moves or acts with a wrong timing. Event is added but L0465_s_NextEvent.C.Ticks has not been initialized */ + } + AL0447_i_Behavior = L0444_ps_Group->getBehaviour(); + L0460_ui_CreatureCount = L0444_ps_Group->getCount(); + L0459_i_CreatureSize = getFlag(L0448_s_CreatureInfo._attributes, k0x0003_MaskCreatureInfo_size); + AL0450_i_DistanceXToParty = ((AL0446_i_Distance = eventMapX - _vm->_dungeonMan->_g306_partyMapX) < 0) ? -AL0446_i_Distance : AL0446_i_Distance; + AL0451_i_DistanceYToParty = ((AL0446_i_Distance = eventMapY - _vm->_dungeonMan->_g307_partyMapY) < 0) ? -AL0446_i_Distance : AL0446_i_Distance; + _g378_currentGroupMapX = eventMapX; + _g379_currentGroupMapY = eventMapY; + _g380_currGroupThing = L0449_T_GroupThing; + _g384_groupMovementTestedDirections[0] = 0; + _g381_currGroupDistanceToParty = f226_getDistanceBetweenSquares(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); + _g382_currGroupPrimaryDirToParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); + _g383_currGroupSecondaryDirToParty = _vm->_projexpl->_g363_secondaryDirToOrFromParty; + L0464_l_NextAspectUpdateTime = 0; + L0455_B_CurrentEventTypeIsNotUpdateBehavior = true; + if (eventType <= k31_TMEventTypeGroupReactionPartyIsAdjecent) { /* Process Reaction events 29 to 31 */ + switch (eventType = eventType - k32_TMEventTypeUpdateAspectGroup) { + case kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent: /* This event is used when the party bumps into a group or attacks a group physically (not with a spell). It causes the creature behavior to change to attack if it is not already attacking the party or fleeing from target */ + if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) { + f181_groupDeleteEvents(eventMapX, eventMapY); + goto T0209044_SetBehavior6_Attack; + } + L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; + L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; + goto T0209139_Return; + case kM2_TMEventTypeCreateReactionEvent30HitByProjectile: /* This event is used for the reaction of a group after a projectile impacted with one creature in the group (some creatures may have been killed) */ + if ((AL0447_i_Behavior == k6_behavior_ATTACK) || (AL0447_i_Behavior == k5_behavior_FLEE)) /* If the creature is attacking the party or fleeing from the target then there is no reaction */ + goto T0209139_Return; + if ((AL0446_i_Behavior2Or3 = ((AL0447_i_Behavior == k3_behavior_USELESS) || (AL0447_i_Behavior == k2_behavior_USELESS))) || (_vm->getRandomNumber(4))) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances */ + if (!f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { /* If the group cannot see the party then look in a random direction to try and search for the party */ + L0458_B_SetBehavior7_ApproachAfterReaction = L0453_B_NewGroupDirectionFound = false; + goto T0209073_SetDirectionGroup; + } + if (AL0446_i_Behavior2Or3 || (_vm->getRandomNumber(4))) /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances then no reaction */ + goto T0209139_Return; + } /* No 'break': proceed to instruction after the next 'case' below. Reaction is to move in a random direction to try and avoid other projectiles */ + case kM3_TMEventTypeCreateReactionEvent29DangerOnSquare: /* This event is used when some creatures in the group were killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by 3 Fluxcages. It causes the creature to move in a random direction to avoid the danger */ + L0458_B_SetBehavior7_ApproachAfterReaction = (AL0447_i_Behavior == k6_behavior_ATTACK); /* If the creature behavior is 'Attack' and it has to move to avoid danger then it will change its behavior to 'Approach' after the movement */ + L0453_B_NewGroupDirectionFound = false; + goto T0209058_MoveInRandomDirection; + } + } + if (eventType < k37_TMEventTypeUpdateBehaviourGroup) { /* Process Update Aspect events 32 to 36 */ + L0465_s_NextEvent._type = eventType + 5; + if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { + if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) { + if (M38_distance(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, eventMapX, eventMapY) <= 1) + goto T0209044_SetBehavior6_Attack; + if (((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k3_behavior_USELESS)) && (AL0447_i_Behavior != k7_behavior_APPROACH)) /* BUG0_00 Useless code. Behavior cannot be 3 because this value is never used. Moreover, the second condition in the && is redundant (if the value is 0 or 3, it cannot be 7). The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */ + goto T0209054_SetBehavior7_Approach; + } + L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; + L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; + } + if (AL0447_i_Behavior == k6_behavior_ATTACK) { + AL0446_i_CreatureAspectIndex = eventType - k33_TMEventTypeUpdateAspectCreature_0; /* Value -1 for event 32, meaning aspect will be updated for all creatures in the group */ + L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0446_i_CreatureAspectIndex, getFlag(L0445_ps_ActiveGroup->_aspect[AL0446_i_CreatureAspectIndex], k0x0080_MaskActiveGroupIsAttacking)); + goto T0209136; + } + if ((AL0450_i_DistanceXToParty > 3) || (AL0451_i_DistanceYToParty > 3)) { + L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime + ((L0448_s_CreatureInfo._animationTicks >> 4) & 0xF); + goto T0209136; + } + } else { /* Process Update Behavior events 37 to 41 */ + L0455_B_CurrentEventTypeIsNotUpdateBehavior = false; + if (ticks) { + L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime; + } + if (eventType == k37_TMEventTypeUpdateBehaviourGroup) { /* Process event 37, Update Group Behavior */ + if ((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k2_behavior_USELESS) || (AL0447_i_Behavior == k3_behavior_USELESS)) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */ + if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { + if ((L0452_i_DistanceToVisibleParty <= (L0448_s_CreatureInfo.M56_getAttackRange())) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) { /* If the creature is in range for attack and on the same row or column as the party on the map */ +T0209044_SetBehavior6_Attack: + if (eventType == kM2_TMEventTypeCreateReactionEvent30HitByProjectile) { + f181_groupDeleteEvents(eventMapX, eventMapY); + } + L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; + L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; + L0444_ps_Group->setBehaviour(k6_behavior_ATTACK); + AL0446_i_Direction = _g382_currGroupPrimaryDirToParty; + for (AL0447_i_CreatureIndex = L0460_ui_CreatureCount; AL0447_i_CreatureIndex >= 0; AL0447_i_CreatureIndex--) { + if ((_vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) != AL0446_i_Direction) && + ((!AL0447_i_CreatureIndex) || (!_vm->getRandomNumber(2)))) { + f205_setDirection(L0445_ps_ActiveGroup, AL0446_i_Direction, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf)); + M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + _vm->getRandomNumber(4) + 2); /* Random delay represents the time for the creature to turn */ + } else { + M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + 1); + } + if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) { + L0465_s_NextEvent._mapTime += MIN((uint16)((L0448_s_CreatureInfo._attackTicks >> 1) + _vm->getRandomNumber(4)), ticks); + } + L0465_s_NextEvent._type = k38_TMEventTypeUpdateBehaviour_0 + AL0447_i_CreatureIndex; + f208_groupAddEvent(&L0465_s_NextEvent, f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false)); + } + goto T0209139_Return; + } + if (AL0447_i_Behavior != k2_behavior_USELESS) { /* BUG0_00 Useless code. Behavior cannot be 2 because this value is never used */ +T0209054_SetBehavior7_Approach: + L0444_ps_Group->setBehaviour(k7_behavior_APPROACH); + L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; + L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; + L0465_s_NextEvent._mapTime += 1; + goto T0209134_SetEvent37; + } + } else { + if (AL0447_i_Behavior == k0_behavior_WANDER) { + if (L0454_i_PrimaryDirectionToOrFromParty = f201_getSmelledPartyPrimaryDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY)) { + L0454_i_PrimaryDirectionToOrFromParty--; + L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = false; + goto T0209085_SingleSquareMove; + } + L0453_B_NewGroupDirectionFound = false; + if (_vm->getRandomNumber(2)) { +T0209058_MoveInRandomDirection: + AL0446_i_Direction = _vm->getRandomNumber(4); + AL0447_i_ReferenceDirection = AL0446_i_Direction; + L0457_B_MoveToPriorLocation = false; + do { + AL0450_i_DestinationMapX = eventMapX; + AL0451_i_DestinationMapY = eventMapY; + AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction]; + if (((L0445_ps_ActiveGroup->_priorMapX != AL0450_i_DestinationMapX) || + (L0445_ps_ActiveGroup->_priorMapY != AL0451_i_DestinationMapY) || + (L0457_B_MoveToPriorLocation = !_vm->getRandomNumber(4))) /* 1/4 chance of moving back to the square that the creature comes from */ + && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction, false)) { +T0209061_MoveGroup: + if (L0453_B_NewGroupDirectionFound = ((AL0447_i_Ticks = (L0461_i_MovementTicks >> 1) - L0462_i_TicksSinceLastMove) <= 0)) { + if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY)) + goto T0209139_Return; + L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX; + L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY;; + L0445_ps_ActiveGroup->_priorMapX = eventMapX; + L0445_ps_ActiveGroup->_priorMapY = eventMapY; + L0445_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime; + } else { + L0461_i_MovementTicks = AL0447_i_Ticks; + L0462_i_TicksSinceLastMove = -1; + } + break; + } + if (_g390_groupMovementBlockedByParty) { + if ((eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) && + ((L0444_ps_Group->getBehaviour() != k5_behavior_FLEE) || + !f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false) || + _vm->getRandomNumber(2))) + goto T0209044_SetBehavior6_Attack; + L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; + L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; + } + } while ((AL0446_i_Direction = returnNextVal(AL0446_i_Direction)) != AL0447_i_ReferenceDirection); + } + if (!L0453_B_NewGroupDirectionFound && + (L0462_i_TicksSinceLastMove != -1) && + L0463_B_Archenemy && + ((eventType == kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) || !_vm->getRandomNumber(4))) { /* BUG0_15 The game hangs when you close a door on Lord Chaos. A condition is missing in the code to manage creatures and this may create an infinite loop between two parts in the code */ + _vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0454_i_PrimaryDirectionToOrFromParty = _vm->getRandomNumber(4)); + goto T0209089_DoubleSquareMove; /* BUG0_69 Memory corruption when you close a door on Lord Chaos. The local variable (L0454_i_PrimaryDirectionToOrFromParty) containing the direction where Lord Chaos tries to move may be used as an array index without being initialized and cause memory corruption */ + } + if (L0453_B_NewGroupDirectionFound || ((!_vm->getRandomNumber(4) || (L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M55_getSmellRange())) && (eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare))) { +T0209073_SetDirectionGroup: + if (!L0453_B_NewGroupDirectionFound && (L0462_i_TicksSinceLastMove >= 0)) { /* If direction is not found yet then look around in a random direction */ + AL0446_i_Direction = _vm->getRandomNumber(4); + } + f206_groupSetDirGroup(L0445_ps_ActiveGroup, AL0446_i_Direction, L0460_ui_CreatureCount, L0459_i_CreatureSize); + } + /* If event is kM3_TMEventTypeCreateReactionEvent29DangerOnSquare or kM2_TMEventTypeCreateReactionEvent30HitByProjectile */ + if (eventType < kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) { + if (!L0453_B_NewGroupDirectionFound) + goto T0209139_Return; + if (L0458_B_SetBehavior7_ApproachAfterReaction) { + L0444_ps_Group->setBehaviour(k7_behavior_APPROACH); + } + f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY); + } + } + } + } else { + if (AL0447_i_Behavior == k7_behavior_APPROACH) { + if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { + if ((L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M56_getAttackRange()) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) /* If the creature is in range for attack and on the same row or column as the party on the map */ + goto T0209044_SetBehavior6_Attack; +T0209081_RunTowardParty: + L0461_i_MovementTicks++; + L0461_i_MovementTicks = L0461_i_MovementTicks >> 1; /* Running speed is half the movement ticks */ + AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX); + AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY); + } else { +T0209082_WalkTowardTarget: + AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX; + AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY; + /* If the creature reached its target but the party is not there anymore */ + if ((eventMapX == AL0450_i_TargetMapX) && (eventMapY == AL0451_i_TargetMapY)) { + L0453_B_NewGroupDirectionFound = false; + L0444_ps_Group->setBehaviour(k0_behavior_WANDER); + goto T0209073_SetDirectionGroup; + } + } + L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true; +T0209084_SingleSquareMoveTowardParty: + L0454_i_PrimaryDirectionToOrFromParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY); +T0209085_SingleSquareMove: + if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls) || + f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls && _vm->getRandomNumber(2)) || + f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction), false) || + (!_vm->getRandomNumber(4) && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty), false))) { + AL0450_i_DestinationMapX = eventMapX; + AL0451_i_DestinationMapY = eventMapY; + AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction]; + goto T0209061_MoveGroup; + } + if (L0463_B_Archenemy) { +T0209089_DoubleSquareMove: + f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false); /* BUG0_00 Useless code. Returned value is ignored. When Lord Chaos teleports two squares away the ability to move to the first square is ignored which means Lord Chaos can teleport through walls or any other obstacle */ + if (f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty) || + f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty) || + (_g386_fluxCageCount && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction))) || + ((_g386_fluxCageCount >= 2) && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty)))) { + AL0450_i_DestinationMapX = eventMapX; + AL0451_i_DestinationMapY = eventMapY; + AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2; + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + goto T0209061_MoveGroup; + } + } + f206_groupSetDirGroup(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, L0460_ui_CreatureCount, L0459_i_CreatureSize); + } else { + if (AL0447_i_Behavior == k5_behavior_FLEE) { +T0209094_FleeFromTarget: + L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true; + /* If the creature can see the party then update target coordinates */ + if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { + AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX); + AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY); + } else { + if (!(--(L0445_ps_ActiveGroup->_delayFleeingFromTarget))) { /* If the creature is not afraid anymore then stop fleeing from target */ +T0209096_SetBehavior0_Wander: + L0453_B_NewGroupDirectionFound = false; + L0444_ps_Group->setBehaviour(k0_behavior_WANDER); + goto T0209073_SetDirectionGroup; + } + if (_vm->getRandomNumber(2)) { + /* If the creature cannot move and the party is adjacent then stop fleeing */ + if (!f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false)) { + if (M38_distance(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1) + goto T0209096_SetBehavior0_Wander; + } + /* Set creature target to the home square where the creature was located when the party entered the map */ + AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_homeMapX; + AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_homeMapY; + goto T0209084_SingleSquareMoveTowardParty; + } + AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX; + AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY; + } + /* Try and flee from the party (opposite direction) */ + L0454_i_PrimaryDirectionToOrFromParty = returnOppositeDir((direction)f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY)); + _vm->_projexpl->_g363_secondaryDirToOrFromParty = returnOppositeDir((direction)_vm->_projexpl->_g363_secondaryDirToOrFromParty); + L0461_i_MovementTicks -= (L0461_i_MovementTicks >> 2); + goto T0209085_SingleSquareMove; + } + } + } + } else { /* Process events 38 to 41, Update Creature Behavior */ + if (AL0447_i_Behavior == k5_behavior_FLEE) { + if (L0460_ui_CreatureCount) { + f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY); + } + goto T0209094_FleeFromTarget; + } + /* If the creature is attacking, then compute the next aspect update time and the next attack time */ + if (getFlag(L0445_ps_ActiveGroup->_aspect[AL0447_i_CreatureIndex = eventType - k38_TMEventTypeUpdateBehaviour_0], k0x0080_MaskActiveGroupIsAttacking)) { + L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false); + L0465_s_NextEvent._mapTime += ((AL0447_i_Ticks = L0448_s_CreatureInfo._attackTicks) + _vm->getRandomNumber(4) - 1); + if (AL0447_i_Ticks > 15) { + L0465_s_NextEvent._mapTime += _vm->getRandomNumber(8) - 2; + } + } else { /* If the creature is not attacking, then try attacking if possible */ + if (AL0447_i_CreatureIndex > L0460_ui_CreatureCount) { /* Ignore event if it is for a creature that is not in the group */ + goto T0209139_Return; + } + L0454_i_PrimaryDirectionToOrFromParty = _g382_currGroupPrimaryDirToParty; + /* If the party is visible, update the target coordinates */ + if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, AL0447_i_CreatureIndex, eventMapX, eventMapY)) { + L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; + L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; + } + /* If there is a single creature in the group that is not full square sized and 1/4 chance */ + if (!L0460_ui_CreatureCount && (L0459_i_CreatureSize != k2_MaskCreatureSizeFull) && !((AL0446_i_GroupCellsCriteria = _vm->getRandomNumber(65536)) & 0x00C0)) { + if (L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) { + /* If the creature is not already on the center of the square then change its cell */ + if (AL0446_i_GroupCellsCriteria & 0x0038) { /* 7/8 chances of changing cell to the center of the square */ + L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature; + } else { /* 1/8 chance of changing cell to the next or previous cell on the square */ + AL0446_i_GroupCellsCriteria = M21_normalizeModulo4(M21_normalizeModulo4(L0445_ps_ActiveGroup->_cells) + ((AL0446_i_GroupCellsCriteria & 0x0001) ? 1 : -1)); + } + } + /* If 1/8 chance and the creature is not adjacent to the party and is a quarter square sized creature then process projectile impacts and update the creature cell if still alive. When the creature is not in front of the party, it has 7/8 chances of dodging a projectile by moving to another cell or staying in the center of the square */ + if (!(AL0446_i_GroupCellsCriteria & 0x0038) && (L0452_i_DistanceToVisibleParty != 1) && (L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter)) { + if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* This call to F0218_PROJECTILE_GetImpactCount works fine because there is a single creature in the group so L0445_ps_ActiveGroup->Cells contains only one cell index */ + goto T0209139_Return; + L0445_ps_ActiveGroup->_cells = M21_normalizeModulo4(AL0446_i_GroupCellsCriteria); + } + } + /* If the creature can see the party and is looking in the party direction or can attack in all direction */ + if (L0452_i_DistanceToVisibleParty && + (getFlag(L0448_s_CreatureInfo._attributes, k0x0004_MaskCreatureInfo_sideAttack) || + _vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) == L0454_i_PrimaryDirectionToOrFromParty)) { + /* If the creature is in range to attack the party and random test succeeds */ + if ((L0452_i_DistanceToVisibleParty <= (AL0446_i_Range = L0448_s_CreatureInfo.M56_getAttackRange())) && + (!AL0450_i_DistanceXToParty || !AL0451_i_DistanceYToParty) && + (AL0446_i_Range <= (_vm->getRandomNumber(16) + 1))) { + if ((AL0446_i_Range == 1) && + (!getFlag(AL0446_i_CreatureAttributes = L0448_s_CreatureInfo._attributes, k0x0008_MaskCreatureInfo_preferBackRow) || !_vm->getRandomNumber(4) || !getFlag(AL0446_i_CreatureAttributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) && + (L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter) && + (L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) && + ((AL0446_i_Cell = _vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex)) != L0454_i_PrimaryDirectionToOrFromParty) && + (AL0446_i_Cell != returnNextVal(L0454_i_PrimaryDirectionToOrFromParty))) { /* If the creature cannot cast spells (range = 1) and is not on a cell where it can attack the party directly and is a quarter square sized creature not in the center of the square then the creature moves to another cell and attack does not occur immediately */ + if (!L0460_ui_CreatureCount && _vm->getRandomNumber(2)) { + L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature; + } else { + if ((L0454_i_PrimaryDirectionToOrFromParty & 0x0001) == (AL0446_i_Cell & 0x0001)) { + AL0446_i_Cell--; + } else { + AL0446_i_Cell++; + } + if (!_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = M21_normalizeModulo4(AL0446_i_Cell)) || + (_vm->getRandomNumber(2) && !_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */ + if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */ + goto T0209139_Return; + if (_vm->_projexpl->_g364_creatureDamageOutcome != k1_outcomeKilledSomeCreaturesInGroup) { + L0445_ps_ActiveGroup->_cells = f178_getGroupValueUpdatedWithCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex, AL0446_i_Cell); + } + } + } + L0465_s_NextEvent._mapTime += MAX(1, (L0448_s_CreatureInfo._movementTicks >> 1) + _vm->getRandomNumber(2)); /* Time for the creature to change cell */ + L0465_s_NextEvent._type = eventType; + goto T0209135; + } + L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, f207_isCreatureAttacking(L0444_ps_Group, eventMapX, eventMapY, AL0447_i_CreatureIndex)); + L0465_s_NextEvent._mapTime += (L0448_s_CreatureInfo._animationTicks & 0xF) + _vm->getRandomNumber(2); + } else { + L0444_ps_Group->setBehaviour(k7_behavior_APPROACH); + if (L0460_ui_CreatureCount) { + f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY); + } + goto T0209081_RunTowardParty; + } + } else { + /* If the party is visible, update target coordinates */ + if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { + L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; + L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; + f205_setDirection(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf)); + L0465_s_NextEvent._mapTime += 2; + L0464_l_NextAspectUpdateTime = M30_time(L0465_s_NextEvent._mapTime); + } else { /* If the party is not visible, move to the target (last known party location) */ + L0444_ps_Group->setBehaviour(k7_behavior_APPROACH); + if (L0460_ui_CreatureCount) { + f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY); + } + goto T0209082_WalkTowardTarget; + } + } + } + L0465_s_NextEvent._type = eventType; + goto T0209136; + } + L0465_s_NextEvent._mapTime += MAX(1, _vm->getRandomNumber(4) + L0461_i_MovementTicks - 1); +T0209134_SetEvent37: + L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup; + } +T0209135: + if (!L0464_l_NextAspectUpdateTime) { + L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, kM1_wholeCreatureGroup, false); + } +T0209136: + if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) { + L0465_s_NextEvent._mapTime += ticks; + } else { + L0464_l_NextAspectUpdateTime += ticks; + } + f208_groupAddEvent(&L0465_s_NextEvent, L0464_l_NextAspectUpdateTime); +T0209139_Return: + ; +} + +bool GroupMan::f202_isMovementPossible(CreatureInfo* creatureInfo, int16 mapX, int16 mapY, uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls) { + int16 L0428_i_MapX; + int16 L0429_i_MapY; + uint16 L0430_ui_Square = 0; + int16 L0431_i_SquareType = 0; + Teleporter* L0432_ps_Teleporter; + Thing L0433_T_Thing; + + + _g384_groupMovementTestedDirections[dir] = true; + _g388_groupMovementBlockedByGroupThing = Thing::_endOfList; + _g389_groupMovementBlockedByDoor = false; + _g390_groupMovementBlockedByParty = false; + if (creatureInfo->_movementTicks == k255_immobile) { + return false; + } + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement((direction)dir, 1, 0, mapX, mapY); + L0428_i_MapX = mapX; + L0429_i_MapY = mapY; + if (_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = + !(((L0428_i_MapX >= 0) && (L0428_i_MapX < _vm->_dungeonMan->_g273_currMapWidth)) && + ((L0429_i_MapY >= 0) && (L0429_i_MapY < _vm->_dungeonMan->_g274_currMapHeight)) && + ((L0431_i_SquareType = Square(L0430_ui_Square = _vm->_dungeonMan->_g271_currMapData[L0428_i_MapX][L0429_i_MapY]).getType()) != k0_ElementTypeWall) && + (L0431_i_SquareType != k3_ElementTypeStairs) && + ((L0431_i_SquareType != k2_ElementTypePit) || (getFlag(L0430_ui_Square, k0x0001_PitImaginary) && allowMovementOverImaginaryPitsAndFakeWalls) || !getFlag(L0430_ui_Square, k0x0008_PitOpen) || getFlag(creatureInfo->_attributes, k0x0020_MaskCreatureInfo_levitation)) && + ((L0431_i_SquareType != k6_ElementTypeFakeWall) || getFlag(L0430_ui_Square, k0x0004_FakeWallOpen) || (getFlag(L0430_ui_Square, k0x0001_FakeWallImaginary) && allowMovementOverImaginaryPitsAndFakeWalls)))) { + return false; + } + if (getFlag(creatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) { + L0433_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0428_i_MapX, L0429_i_MapY); + while (L0433_T_Thing != Thing::_endOfList) { + if ((L0433_T_Thing).getType() == k15_ExplosionThingType) { + L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(L0433_T_Thing); + if (((Explosion*)L0432_ps_Teleporter)->setType(k50_ExplosionType_Fluxcage)) { + _g385_fluxCages[dir] = true; + _g386_fluxCageCount++; + _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true; + return false; + } + } + L0433_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0433_T_Thing); + } + } + if ((L0431_i_SquareType == k5_ElementTypeTeleporter) && getFlag(L0430_ui_Square, k0x0008_TeleporterOpen) && (creatureInfo->M59_getWariness() >= 10)) { + L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY); + if (getFlag(L0432_ps_Teleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->f139_isCreatureAllowedOnMap(_g380_currGroupThing, L0432_ps_Teleporter->getTargetMapIndex())) { + _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true; + return false; + } + } + if (_g390_groupMovementBlockedByParty = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0428_i_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0429_i_MapY == _vm->_dungeonMan->_g307_partyMapY)) { + return false; + } + if (L0431_i_SquareType == k4_DoorElemType) { + L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY); + if (((Square(L0430_ui_Square).getDoorState()) > (((Door*)L0432_ps_Teleporter)->opensVertically() ? creatureInfo->M51_height() : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) { + _g389_groupMovementBlockedByDoor = true; + return false; + } + } + return (_g388_groupMovementBlockedByGroupThing = _vm->_groupMan->f175_groupGetThing(L0428_i_MapX, L0429_i_MapY)) == Thing::_endOfList; +} + +int16 GroupMan::f226_getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) { + return ((((srcMapX -= destMapX) < 0) ? -srcMapX : srcMapX) + + (((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY)); +} + +int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group* group, int16 creatureIndex, int16 mapX, int16 mapY) { + int16 L0420_i_CreatureDirection; + int16 L0421_i_CreatureViewDirectionCount; /* Count of directions to test in L0425_ai_CreatureViewDirections */ + int16 L0422_i_Multiple; +#define AL0422_i_Counter L0422_i_Multiple +#define AL0422_i_SightRange L0422_i_Multiple + uint16 L0423_ui_GroupDirections; + CreatureInfo* L0424_ps_CreatureInfo; + int16 L0425_ai_CreatureViewDirections[4]; /* List of directions to test */ + + + L0424_ps_CreatureInfo = &g243_CreatureInfo[group->_type]; + if (_vm->_championMan->_g407_party._event71Count_Invisibility && !getFlag(L0424_ps_CreatureInfo->_attributes, k0x0800_MaskCreatureInfo_seeInvisible)) { + return 0; + } + if (getFlag(L0424_ps_CreatureInfo->_attributes, k0x0004_MaskCreatureInfo_sideAttack)) /* If creature can see in all directions */ + goto T0200011; + L0423_ui_GroupDirections = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions; + if (creatureIndex < 0) { /* Negative index means test if each creature in the group can see the party in their respective direction */ + L0421_i_CreatureViewDirectionCount = 0; + for (creatureIndex = group->getCount(); creatureIndex >= 0; creatureIndex--) { + L0420_i_CreatureDirection = M21_normalizeModulo4(L0423_ui_GroupDirections >> (creatureIndex << 1)); + AL0422_i_Counter = L0421_i_CreatureViewDirectionCount; + while (AL0422_i_Counter--) { + if (L0425_ai_CreatureViewDirections[AL0422_i_Counter] == L0420_i_CreatureDirection) /* If the creature looks in the same direction as another one in the group */ + goto T0200006; + } + L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount++] = L0420_i_CreatureDirection; +T0200006: + ; + } + } else { /* Positive index means test only if the specified creature in the group can see the party in its direction */ + L0425_ai_CreatureViewDirections[0] = _vm->_groupMan->M50_getCreatureValue(L0423_ui_GroupDirections, creatureIndex); + L0421_i_CreatureViewDirectionCount = 1; + } + while (L0421_i_CreatureViewDirectionCount--) { + if (f227_isDestVisibleFromSource(L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount], mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY)) { +T0200011: + AL0422_i_SightRange = L0424_ps_CreatureInfo->M54_getSightRange(); + if (!getFlag(L0424_ps_CreatureInfo->_attributes, k0x1000_MaskCreatureInfo_nightVision)) { + AL0422_i_SightRange -= _vm->_displayMan->_g304_dungeonViewPaletteIndex >> 1; + } + if (_g381_currGroupDistanceToParty > MAX((int16)1, AL0422_i_SightRange)) { + return 0; + } + return f199_getDistanceBetweenUnblockedSquares(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f197_isViewPartyBlocked); + } + } + return 0; +} + +int16 GroupMan::f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 srcMapY, + int16 destMapX, int16 destMapY, bool (GroupMan::*isBlocked)(uint16, uint16)) { + int16 L0410_i_XAxisStep; + int16 L0411_i_YAxisStep; + int16 L0412_i_Multiple; +#define AL0412_i_DistanceX L0412_i_Multiple +#define AL0412_i_PathMapX L0412_i_Multiple + int16 L0413_i_Multiple; +#define AL0413_i_DistanceY L0413_i_Multiple +#define AL0413_i_PathMapY L0413_i_Multiple + int16 L0414_i_LargestAxisDistance; + bool L0415_B_DistanceXSmallerThanDistanceY; + int16 L0416_i_ValueA; + int16 L0417_i_ValueB; + bool L0418_B_DistanceXEqualsDistanceY; + int16 L0419_i_ValueC; + + + if (M38_distance(srcMapX, srcMapY, destMapX, destMapY) <= 1) { + return 1; + } + L0415_B_DistanceXSmallerThanDistanceY = (AL0412_i_DistanceX = ((AL0412_i_DistanceX = destMapX - srcMapX) < 0) ? -AL0412_i_DistanceX : AL0412_i_DistanceX) < (AL0413_i_DistanceY = ((AL0413_i_DistanceY = destMapY - srcMapY) < 0) ? -AL0413_i_DistanceY : AL0413_i_DistanceY); + L0418_B_DistanceXEqualsDistanceY = (AL0412_i_DistanceX == AL0413_i_DistanceY); + L0410_i_XAxisStep = (((AL0412_i_PathMapX = destMapX) - srcMapX) > 0) ? -1 : 1; + L0411_i_YAxisStep = (((AL0413_i_PathMapY = destMapY) - srcMapY) > 0) ? -1 : 1; + L0419_i_ValueC = L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY - srcMapY) ? ((AL0412_i_PathMapX - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) + : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX - srcMapX) ? ((AL0413_i_PathMapY - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128); + /* 128 when the creature is on the same row or column as the party */ + do { + if (L0418_B_DistanceXEqualsDistanceY) { + if (((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY) && (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX, AL0413_i_PathMapY + L0411_i_YAxisStep)) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX = AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY = AL0413_i_PathMapY + L0411_i_YAxisStep)) { + return 0; + } + } else { + if ((L0416_i_ValueA = ((L0414_i_LargestAxisDistance = (L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY - srcMapY) ? ((AL0412_i_PathMapX + L0410_i_XAxisStep - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX + L0410_i_XAxisStep - srcMapX) ? ((AL0413_i_PathMapY - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128)) - L0419_i_ValueC) < 0) ? -L0414_i_LargestAxisDistance : L0414_i_LargestAxisDistance) < (L0417_i_ValueB = ((L0414_i_LargestAxisDistance = (L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY + L0411_i_YAxisStep - srcMapY) ? ((AL0412_i_PathMapX - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX - srcMapX) ? ((AL0413_i_PathMapY + L0411_i_YAxisStep - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128)) - L0419_i_ValueC) < 0) ? -L0414_i_LargestAxisDistance : L0414_i_LargestAxisDistance)) { + AL0412_i_PathMapX += L0410_i_XAxisStep; + } else { + AL0413_i_PathMapY += L0411_i_YAxisStep; + } + if ((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX, AL0413_i_PathMapY) && ((L0416_i_ValueA != L0417_i_ValueB) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX = AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY = AL0413_i_PathMapY - L0411_i_YAxisStep))) { + return 0; + } + } + } while (M38_distance(AL0412_i_PathMapX, AL0413_i_PathMapY, srcMapX, srcMapY) > 1); + return f226_getDistanceBetweenSquares(srcMapX, srcMapY, destMapX, destMapY); +} + +bool GroupMan::f197_isViewPartyBlocked(uint16 mapX, uint16 mapY) { + uint16 L0404_ui_Square; + int16 L0405_i_SquareType; + int16 L0406_i_DoorState; + Door* L0407_ps_Door; + + if ((L0405_i_SquareType = Square(L0404_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k4_DoorElemType) { + L0407_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY); + return (((L0406_i_DoorState = Square(L0404_ui_Square).getDoorState()) == k3_doorState_FOURTH) || (L0406_i_DoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[L0407_ps_Door->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough); + } + return (L0405_i_SquareType == k0_ElementTypeWall) || ((L0405_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0404_ui_Square, k0x0004_FakeWallOpen)); +} + +int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup* activeGroup, int16 creatureIndex, bool isAttacking) { + uint16 L0326_ui_Multiple; +#define AL0326_ui_Aspect L0326_ui_Multiple +#define AL0326_ui_AnimationTicks L0326_ui_Multiple + uint16 L0327_ui_CreatureGraphicInfo; + int16 L0328_i_Offset; + Group* L0329_ps_Group; + bool L0330_B_ProcessGroup; + uint16 L0331_ui_CreatureType; + uint16 L1635_ui_SoundIndex; + + L0329_ps_Group = &(((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]); + L0327_ui_CreatureGraphicInfo = g243_CreatureInfo[L0331_ui_CreatureType = L0329_ps_Group->_type]._graphicInfo; + if (L0330_B_ProcessGroup = (creatureIndex < 0)) { /* If the creature index is negative then all creatures in the group are processed */ + creatureIndex = L0329_ps_Group->getCount(); + } + do { + AL0326_ui_Aspect = activeGroup->_aspect[creatureIndex]; + AL0326_ui_Aspect &= k0x0080_MaskActiveGroupIsAttacking | k0x0040_MaskActiveGroupFlipBitmap; + if (L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 12) & 0x3)) { + L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset); + if (_vm->getRandomNumber(2)) { + L0328_i_Offset = (-L0328_i_Offset) & 0x0007; + } + AL0326_ui_Aspect |= L0328_i_Offset; + } + if (L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 14) & 0x3)) { + L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset); + if (_vm->getRandomNumber(2)) { + L0328_i_Offset = (-L0328_i_Offset) & 0x0007; + } + AL0326_ui_Aspect |= (L0328_i_Offset << 3); + } + if (isAttacking) { + if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0200_CreatureInfoGraphicMaskFlipAttack)) { + if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) { + if (_vm->getRandomNumber(2)) { + toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + } else { + if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) { + if (_vm->getRandomNumber(2)) { + setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + } else { + clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + } + } + } + } else { + clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + } + setFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking); + } else { + if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) { + if (L0331_ui_CreatureType == k13_CreatureTypeCouatl) { + if (_vm->getRandomNumber(2)) { + toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + L1635_ui_SoundIndex = _vm->_movsens->f514_getSound(k13_CreatureTypeCouatl); + if (L1635_ui_SoundIndex <= k34_D13_soundCount) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + } + } else { + if (_vm->getRandomNumber(2)) { + setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + } else { + clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + } + } + } else { + clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + } + clearFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking); + } + activeGroup->_aspect[creatureIndex] = AL0326_ui_Aspect; + } while (L0330_B_ProcessGroup && (creatureIndex--)); + AL0326_ui_AnimationTicks = g243_CreatureInfo[L0329_ps_Group->_type]._animationTicks; + return _vm->_g313_gameTime + (isAttacking ? ((AL0326_ui_AnimationTicks >> 8) & 0xF) : ((AL0326_ui_AnimationTicks >> 4) & 0xF)) + _vm->getRandomNumber(2); +} + +void GroupMan::f205_setDirection(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) { + uint16 L0435_ui_GroupDirections; + static long G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; /* These two variables are used to prevent setting direction of half square sized creatures twice at the same game time */ + static ActiveGroup* G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup; + + + warning("potentially dangerous cast to uint32 below"); + if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == (uint32)G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) { + return; + } + if (M21_normalizeModulo4(_vm->_groupMan->M50_getCreatureValue(L0435_ui_GroupDirections = activeGroup->_directions, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */ + L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + dir)); + } else { + L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir); + } + if (twoHalfSquareSizedCreatures) { + L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex ^ 1, dir); /* Set direction of the second half square sized creature */ + G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_g313_gameTime; + G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup = activeGroup; + } + activeGroup->_directions = (direction)L0435_ui_GroupDirections; +} + +void GroupMan::f208_groupAddEvent(TimelineEvent* event, uint32 time) { + warning("potentially dangerous cast to uint32 below"); + if (time < (uint32)M30_time(event->_mapTime)) { + event->_type -= 5; + event->_C._ticks = M30_time(event->_mapTime) - time; + M32_setTime(event->_mapTime, time); + } else { + event->_C._ticks = time - M30_time(event->_mapTime); + } + _vm->_timeline->f238_addEventGetEventIndex(event); +} + +int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo* creatureInfo, int16 mapY, int16 mapX) { + + uint16 L0426_ui_SmellRange; + int16 L0427_i_ScentOrdinal; + + + if (!(L0426_ui_SmellRange = creatureInfo->M55_getSmellRange())) { + return 0; + } + if ((((L0426_ui_SmellRange + 1) >> 1) >= _g381_currGroupDistanceToParty) && f199_getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f198_isSmellPartyBlocked)) { + _vm->_projexpl->_g363_secondaryDirToOrFromParty = _g383_currGroupSecondaryDirToParty; + return _vm->M0_indexToOrdinal(_g382_currGroupPrimaryDirToParty); + } + if ((L0427_i_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapY, mapX)) && ((_vm->_championMan->_g407_party._scentStrengths[_vm->M1_ordinalToIndex(L0427_i_ScentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (L0426_ui_SmellRange << 1)))) { /* If there is a fresh enough party scent on the group square */ + return _vm->M0_indexToOrdinal(f228_getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_g407_party._scents[L0427_i_ScentOrdinal].getMapX(), _vm->_championMan->_g407_party._scents[L0427_i_ScentOrdinal].getMapY())); + } + return 0; +} + +bool GroupMan::f198_isSmellPartyBlocked(uint16 mapX, uint16 mapY) { + uint16 L0408_ui_Square; + int16 L0409_i_SquareType; + + return ((L0409_i_SquareType = Square(L0408_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k0_ElementTypeWall) || ((L0409_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0408_ui_Square, k0x0004_FakeWallOpen)); +} + +int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo* info, int16 mapX, int16 mapY, bool allowMovementOverImaginaryPitsAndFakeWalls) { + int16 L0434_i_Direction; + + + for (L0434_i_Direction = kDirNorth; L0434_i_Direction <= kDirWest; L0434_i_Direction++) { + if ((!_g384_groupMovementTestedDirections[L0434_i_Direction]) && f202_isMovementPossible(info, mapX, mapY, L0434_i_Direction, allowMovementOverImaginaryPitsAndFakeWalls)) { + return _vm->M0_indexToOrdinal(L0434_i_Direction); + } + } + return 0; +} + +void GroupMan::f206_groupSetDirGroup(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, int16 creatureSize) { + bool L0436_B_TwoHalfSquareSizedCreatures; + + + if (L0436_B_TwoHalfSquareSizedCreatures = creatureIndex && (creatureSize == k1_MaskCreatureSizeHalf)) { + creatureIndex--; + } + do { + if (!creatureIndex || _vm->getRandomNumber(2)) { + f205_setDirection(activeGroup, dir, creatureIndex, L0436_B_TwoHalfSquareSizedCreatures); + } + } while (creatureIndex--); +} + +void GroupMan::f182_stopAttacking(ActiveGroup* group, int16 mapX, int16 mapY) { + int16 L0337_i_CreatureIndex; + + for (L0337_i_CreatureIndex = 0; L0337_i_CreatureIndex < 4; clearFlag(group->_aspect[L0337_i_CreatureIndex++], k0x0080_MaskActiveGroupIsAttacking)); + f181_groupDeleteEvents(mapX, mapY); + +} + +bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo* info, int16 mapX, int16 mapY, uint16 dir) { + if (_g385_fluxCages[dir]) { + return false; + } + mapX += _vm->_dirIntoStepCountEast[dir], mapY += _vm->_dirIntoStepCountNorth[dir]; + return f202_isMovementPossible(info, mapX, mapY, dir, false); +} + +bool GroupMan::f207_isCreatureAttacking(Group* group, int16 mapX, int16 mapY, uint16 creatureIndex) { + uint16 L0437_ui_Multiple; +#define AL0437_ui_CreatureType L0437_ui_Multiple +#define AL0437_T_Thing L0437_ui_Multiple + uint16 L0438_ui_PrimaryDirectionToParty; + int16 L0439_i_Multiple; +#define AL0439_i_GroupCells L0439_i_Multiple +#define AL0439_i_TargetCell L0439_i_Multiple +#define AL0439_i_ChampionIndex L0439_i_Multiple + int16 L0440_i_Multiple; +#define AL0440_i_KineticEnergy L0440_i_Multiple +#define AL0440_i_Counter L0440_i_Multiple +#define AL0440_i_Damage L0440_i_Multiple +#define AL0440_i_AttackSoundOrdinal L0440_i_Multiple + CreatureInfo* L0441_ps_CreatureInfo; + Champion* L0442_ps_Champion; + ActiveGroup L0443_s_ActiveGroup; + + + _vm->_projexpl->_g361_lastCreatureAttackTime = _vm->_g313_gameTime; + L0443_s_ActiveGroup = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]; + L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type]; + L0438_ui_PrimaryDirectionToParty = _g382_currGroupPrimaryDirToParty; + if ((AL0439_i_GroupCells = L0443_s_ActiveGroup._cells) == k255_CreatureTypeSingleCenteredCreature) { + AL0439_i_TargetCell = _vm->getRandomNumber(2); + } else { + AL0439_i_TargetCell = ((_vm->_groupMan->M50_getCreatureValue(AL0439_i_GroupCells, creatureIndex) + 5 - L0438_ui_PrimaryDirectionToParty) & 0x0002) >> 1; + } + AL0439_i_TargetCell += L0438_ui_PrimaryDirectionToParty; + AL0439_i_TargetCell &= 0x0003; + if ((L0441_ps_CreatureInfo->M56_getAttackRange() > 1) && ((_g381_currGroupDistanceToParty > 1) || _vm->getRandomNumber(2))) { + switch (AL0437_ui_CreatureType) { + case k14_CreatureTypeVexirk: + case k23_CreatureTypeLordChaos: + if (_vm->getRandomNumber(2)) { + AL0437_T_Thing = Thing::_explFireBall.toUint16(); + } else { + switch (_vm->getRandomNumber(4)) { + case 0: + AL0437_T_Thing = Thing::_explHarmNonMaterial.toUint16(); + break; + case 1: + AL0437_T_Thing = Thing::_explLightningBolt.toUint16(); + break; + case 2: + AL0437_T_Thing = Thing::_explPoisonCloud.toUint16(); + break; + case 3: + AL0437_T_Thing = Thing::_explOpenDoor.toUint16(); + } + } + break; + case k1_CreatureTypeSwampSlimeSlime: + AL0437_T_Thing = Thing::_explSlime.toUint16(); + break; + case k3_CreatureTypeWizardEyeFlyingEye: + if (_vm->getRandomNumber(8)) { + AL0437_T_Thing = Thing::_explLightningBolt.toUint16(); + } else { + AL0437_T_Thing = Thing::_explOpenDoor.toUint16(); + } + break; + case k19_CreatureTypeMaterializerZytaz: + if (_vm->getRandomNumber(2)) { + AL0437_T_Thing = Thing::_explPoisonCloud.toUint16(); + break; + } + case k22_CreatureTypeDemon: + case k24_CreatureTypeRedDragon: + AL0437_T_Thing = Thing::_explFireBall.toUint16(); + } /* BUG0_13 The game may crash when 'Lord Order' or 'Grey Lord' cast spells. This cannot happen with the original dungeons as they do not contain any groups of these types. 'Lord Order' and 'Grey Lord' creatures can cast spells (attack range > 1) but no projectile type is defined for them in the code. If these creatures are present in a dungeon they will cast projectiles containing undefined things because the variable is not initialized */ + AL0440_i_KineticEnergy = (L0441_ps_CreatureInfo->_attack >> 2) + 1; + AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy); + AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy); + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8); + } else { + if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) { + AL0439_i_ChampionIndex = _vm->getRandomNumber(4); + for (AL0440_i_Counter = 0; (AL0440_i_Counter < 4) && !_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex]._currHealth; AL0440_i_Counter++) { + AL0439_i_ChampionIndex = returnNextVal(AL0439_i_ChampionIndex); + } + if (AL0440_i_Counter == 4) { + return false; + } + } else { + if ((AL0439_i_ChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(mapX, mapY, AL0439_i_TargetCell)) < 0) { + return false; + } + } + if (AL0437_ui_CreatureType == k2_CreatureTypeGiggler) { + f193_stealFromChampion(group, AL0439_i_ChampionIndex); + } else { + AL0440_i_Damage = f230_getChampionDamage(group, AL0439_i_ChampionIndex) + 1; + L0442_ps_Champion = &_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex]; + if (AL0440_i_Damage > L0442_ps_Champion->_maximumDamageReceived) { + L0442_ps_Champion->_maximumDamageReceived = AL0440_i_Damage; + L0442_ps_Champion->_directionMaximumDamageReceived = returnOppositeDir((direction)L0438_ui_PrimaryDirectionToParty); + } + } + } + if (AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + return true; +} + +void GroupMan::f229_setOrderedCellsToAttack(signed char* orderedCellsToAttack, int16 targetMapX, int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource) { + static signed char g23_orderedCellsToAttack[8][4] = { // @ G0023_aac_Graphic562_OrderedCellsToAttack + {0, 1, 3, 2}, /* Attack South from position Northwest or Southwest */ + {1, 0, 2, 3}, /* Attack South from position Northeast or Southeast */ + {1, 2, 0, 3}, /* Attack West from position Northwest or Northeast */ + {2, 1, 3, 0}, /* Attack West from position Southeast or Southwest */ + {3, 2, 0, 1}, /* Attack North from position Northwest or Southwest */ + {2, 3, 1, 0}, /* Attack North from position Southeast or Northeast */ + {0, 3, 1, 2}, /* Attack East from position Northwest or Northeast */ + {3, 0, 2, 1}}; /* Attack East from position Southeast or Southwest */ + uint16 L0557_ui_OrderedCellsToAttackIndex; + + + if (!((L0557_ui_OrderedCellsToAttackIndex = f228_getDirsWhereDestIsVisibleFromSource(targetMapX, targetMapY, attackerMapX, attackerMapY) << 1) & 0x0002)) { + cellSource++; + } + L0557_ui_OrderedCellsToAttackIndex += (cellSource >> 1) & 0x0001; + for (uint16 i = 0; i < 4; ++i) + orderedCellsToAttack[i] = g23_orderedCellsToAttack[L0557_ui_OrderedCellsToAttackIndex][i]; +} + +void GroupMan::f193_stealFromChampion(Group* group, uint16 championIndex) { + int16 L0391_i_Percentage; + uint16 L0392_ui_StealFromSlotIndex; + uint16 L0393_ui_Counter; + Thing L0394_T_Thing; + Champion* L0395_ps_Champion; + bool L0396_B_ObjectStolen; + static unsigned char G0394_auc_StealFromSlotIndices[8]; /* Initialized with 0 bytes by C loader */ + + + L0396_B_ObjectStolen = false; + L0391_i_Percentage = 100 - _vm->_championMan->f311_getDexterity(L0395_ps_Champion = &_vm->_championMan->_gK71_champions[championIndex]); + L0393_ui_Counter = _vm->getRandomNumber(8); + while ((L0391_i_Percentage > 0) && !_vm->_championMan->f308_isLucky(L0395_ps_Champion, L0391_i_Percentage)) { + if ((L0392_ui_StealFromSlotIndex = G0394_auc_StealFromSlotIndices[L0393_ui_Counter]) == k13_ChampionSlotBackpackLine_1_1) { + L0392_ui_StealFromSlotIndex += _vm->getRandomNumber(17); /* Select a random slot in the backpack */ + } + if (((L0394_T_Thing = L0395_ps_Champion->_slots[L0392_ui_StealFromSlotIndex]) != Thing::_none)) { + L0396_B_ObjectStolen = true; + L0394_T_Thing = _vm->_championMan->f300_getObjectRemovedFromSlot(championIndex, L0392_ui_StealFromSlotIndex); + if (group->_slot == Thing::_endOfList) { + group->_slot = L0394_T_Thing; /* BUG0_12 An object is cloned and appears at two different locations in the dungeon and/or inventory. The game may crash when interacting with this object. If a Giggler with no possessions steals an object that was previously in a chest and was not the last object in the chest then the objects that followed it are cloned. In the chest, the object is part of a linked list of objects that is not reset when the object is removed from the chest and placed in the inventory (but not in the dungeon), nor when it is stolen and added as the first Giggler possession. If the Giggler already has a possession before stealing the object then this does not create a cloned object. + The following statement is missing: L0394_T_Thing->Next = Thing::_endOfList; + This creates cloned things if L0394_T_Thing->Next is not Thing::_endOfList which is the case when the object comes from a chest in which it was not the last object */ + } else { + _vm->_dungeonMan->f163_linkThingToList(L0394_T_Thing, group->_slot, kM1_MapXNotOnASquare, 0); + } + _vm->_championMan->f292_drawChampionState((ChampionIndex)championIndex); + } + ++L0393_ui_Counter; + L0393_ui_Counter &= 0x0007; + L0391_i_Percentage -= 20; + } + if (!_vm->getRandomNumber(8) || (L0396_B_ObjectStolen && _vm->getRandomNumber(2))) { + _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._delayFleeingFromTarget = _vm->getRandomNumber(64) + 20; + group->setBehaviour(k5_behavior_FLEE); + } +} + +int16 GroupMan::f230_getChampionDamage(Group* group, uint16 champIndex) { + unsigned char g24_woundProbabilityIndexToWoundMask[4] = {32, 16, 8, 4}; // @ G0024_auc_Graphic562_WoundProbabilityIndexToWoundMask + + Champion* L0562_ps_Champion; + int16 L0558_i_Multiple; +#define AL0558_i_Attack L0558_i_Multiple +#define AL0558_i_Damage L0558_i_Multiple + uint16 L0559_ui_Multiple; +#define AL0559_ui_WoundTest L0559_ui_Multiple +#define AL0559_ui_PoisonAttack L0559_ui_Multiple +#define AL0559_ui_CreatureDifficulty L0559_ui_Multiple + uint16 L0560_ui_WoundProbabilities; + uint16 L0561_ui_Multiple; +#define AL0561_ui_WoundProbabilityIndex L0561_ui_Multiple +#define AL0561_ui_AllowedWound L0561_ui_Multiple + int16 L0563_i_DoubledMapDifficulty; + CreatureInfo L0564_s_CreatureInfo; + + + L0562_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + if (champIndex >= _vm->_championMan->_g305_partyChampionCount) { + return 0; + } + if (!L0562_ps_Champion->_currHealth) { + return 0; + } + if (_vm->_championMan->_g300_partyIsSleeping) { + _vm->_championMan->f314_wakeUp(); + } + L0563_i_DoubledMapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty << 1; + L0564_s_CreatureInfo = g243_CreatureInfo[group->_type]; + _vm->_championMan->f304_addSkillExperience(champIndex, k7_ChampionSkillParry, L0564_s_CreatureInfo.M58_getExperience()); + if (_vm->_championMan->_g300_partyIsSleeping || (((_vm->_championMan->f311_getDexterity(L0562_ps_Champion) < (_vm->getRandomNumber(32) + L0564_s_CreatureInfo._dexterity + L0563_i_DoubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->f308_isLucky(L0562_ps_Champion, 60))) { + if ((AL0559_ui_WoundTest = _vm->getRandomNumber(65536)) & 0x0070) { + AL0559_ui_WoundTest &= 0x000F; + L0560_ui_WoundProbabilities = L0564_s_CreatureInfo._woundProbabilities; + for (AL0561_ui_WoundProbabilityIndex = 0; AL0559_ui_WoundTest > (L0560_ui_WoundProbabilities & 0x000F); L0560_ui_WoundProbabilities >>= 4) { + AL0561_ui_WoundProbabilityIndex++; + } + AL0561_ui_AllowedWound = g24_woundProbabilityIndexToWoundMask[AL0561_ui_WoundProbabilityIndex]; + } else { + AL0561_ui_AllowedWound = AL0559_ui_WoundTest & 0x0001; /* 0 (Ready hand) or 1 (action hand) */ + } + if ((AL0558_i_Attack = (_vm->getRandomNumber(16) + L0564_s_CreatureInfo._attack + L0563_i_DoubledMapDifficulty) - (_vm->_championMan->f303_getSkillLevel(champIndex, k7_ChampionSkillParry) << 1)) <= 1) { + if (_vm->getRandomNumber(2)) { + goto T0230014; + } + AL0558_i_Attack = _vm->getRandomNumber(4) + 2; + } + AL0558_i_Attack >>= 1; + AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack) + _vm->getRandomNumber(4); + AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack); + AL0558_i_Attack >>= 2; + AL0558_i_Attack += _vm->getRandomNumber(4) + 1; + if (_vm->getRandomNumber(2)) { + AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1; + } + if (AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType)) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + if ((AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack) && _vm->getRandomNumber(2) && ((AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack)) >= 0)) { + _vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack); + } + return AL0558_i_Damage; + } + } +T0230014: + return 0; +} + +void GroupMan::f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY) { + Group* L0363_ps_Group; + int16 L0364_i_CreatureType; + + + if (_g391_dropMovingCreatureFixedPossCellCount) { + L0363_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing); + L0364_i_CreatureType = L0363_ps_Group->_type; + while (_g391_dropMovingCreatureFixedPossCellCount) { + f186_dropCreatureFixedPossessions(L0364_i_CreatureType, mapX, mapY, _g392_dropMovingCreatureFixedPossessionsCell[--_g391_dropMovingCreatureFixedPossCellCount], k2_soundModePlayOneTickLater); + } + } +} + +void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) { + Group* L0332_ps_Group; + TimelineEvent L0333_s_Event; + + + L0332_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(mapX, mapY)); + if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) { + L0332_ps_Group->setBehaviour(k0_behavior_WANDER); + } + M33_setMapAndTime(L0333_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, (_vm->_g313_gameTime + 1)); + L0333_s_Event._type = k37_TMEventTypeUpdateBehaviourGroup; + L0333_s_Event._priority = 255 - g243_CreatureInfo[L0332_ps_Group->_type]._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */ + L0333_s_Event._C._ticks = 0; + L0333_s_Event._B._location._mapX = mapX; + L0333_s_Event._B._location._mapY = mapY; + _vm->_timeline->f238_addEventGetEventIndex(&L0333_s_Event); +} + +void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) { + uint16 L0339_ui_CreatureIndex; + Group* L0340_ps_Group; + ActiveGroup* L0341_ps_ActiveGroup; + int16 L0344_i_ActiveGroupIndex; + + + L0341_ps_ActiveGroup = _vm->_groupMan->_g375_activeGroups; + L0344_i_ActiveGroupIndex = 0; + while (L0341_ps_ActiveGroup->_groupThingIndex >= 0) { + if (++L0344_i_ActiveGroupIndex >= _vm->_groupMan->_g376_maxActiveGroupCount) { + return; /* BUG0_11 Data corruption in memory. Each group located on the same map as the party has additional associated data but there is only provision for 60 instances (_vm->_groupMan->_g376_maxActiveGroupCount). If there are more groups at the same time then some of them do not get their instance and when the game accesses this information it will corrupt other data in memory (either the instance of another group, parts of the timeline or events). This situation cannot occur in the original Dungeon Master and Chaos Strikes Back dungeons for the following reasons (but it may occur in custom dungeons if they are not designed carefully): there is no map with already more than 60 groups in the original dungeons and none of the following 3 possible ways to move a group into a map can increase the number of instances above the maximum of 60: + - A group generator sensor is triggered: the game never generates a group on the party map if there are less than 5 instances available. This limits the actual number of groups on a map to 55 in most cases. + - A group falls through a pit from the map above (the creature type must be allowed on the target map): a group will never willingly move to an open pit square. It may move to a closed pit square and fall if the pit is then open (either automatically or triggered by the party on the map below). There are no such pits in the original dungeons. + - A group is teleported from another map (the creature type must be allowed on the target map): in the original dungeons, all teleporters whose scope include groups and target another map are either inaccessible to groups or the groups are not allowed on the target map. The only exception is for some Gigglers in the Chaos Strikes Back dungeon but there are not enough to use the 5 reserved instances. + + This code returns immediately if all ACTIVE_GROUP entries are already in use, which avoids an out of bounds access into _vm->_groupMan->_g375_activeGroups below (through L0341_ps_ActiveGroup). However in this case the specified group ends up without an associated ACTIVE_GROUP structure which is assumed everywhere in the code to be present for groups on the same map as the party. If there are more than 60 groups on the party map at any given time then this will corrupt memory (in _vm->_timeline->_g370_events and _vm->_timeline->_g371_timeline allocated in _vm->_timeline->f233_initTimeline before _vm->_groupMan->_g375_activeGroups) because of read and write operations at incorrect memory addresses (the 'Cells' value of the GROUP will be used as an index in _vm->_groupMan->_g375_activeGroups even though that value was not replaced by the index of an ACTIVE_GROUP in this function) */ + } + L0341_ps_ActiveGroup++; + } + _g377_currActiveGroupCount++; + L0340_ps_Group = ((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType()); + L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells; + L0340_ps_Group->getActiveGroupIndex() = L0344_i_ActiveGroupIndex; + L0341_ps_ActiveGroup->_priorMapX = L0341_ps_ActiveGroup->_homeMapX = mapX; + L0341_ps_ActiveGroup->_priorMapY = L0341_ps_ActiveGroup->_homeMapY = mapY; + L0341_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime - 127; + L0339_ui_CreatureIndex = L0340_ps_Group->getCount(); + do { + L0341_ps_ActiveGroup->_directions = (direction)f178_getGroupValueUpdatedWithCreatureValue(L0341_ps_ActiveGroup->_directions, L0339_ui_CreatureIndex, L0340_ps_Group->getDir()); + L0341_ps_ActiveGroup->_aspect[L0339_ui_CreatureIndex] = 0; + } while (L0339_ui_CreatureIndex--); + f179_getCreatureAspectUpdateTime(L0341_ps_ActiveGroup, kM1_wholeCreatureGroup, false); +} + +void GroupMan::f184_removeActiveGroup(uint16 activeGroupIndex) { + ActiveGroup* L0347_ps_ActiveGroup; + Group* L0348_ps_Group; + + + if ((activeGroupIndex > _vm->_groupMan->_g376_maxActiveGroupCount) || (_vm->_groupMan->_g375_activeGroups[activeGroupIndex]._groupThingIndex < 0)) { + return; + } + L0347_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[activeGroupIndex]; + L0348_ps_Group = &((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex]; + _g377_currActiveGroupCount--; + L0348_ps_Group->_cells = L0347_ps_ActiveGroup->_cells; + L0348_ps_Group->setDir(M21_normalizeModulo4(L0347_ps_ActiveGroup->_directions)); + if (L0348_ps_Group->getBehaviour() >= k4_behavior_USELESS) { + L0348_ps_Group->setBehaviour(k0_behavior_WANDER); + } + L0347_ps_ActiveGroup->_groupThingIndex = -1; +} } diff --git a/engines/dm/group.h b/engines/dm/group.h index 76cb8b2649..151594a1d3 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -32,7 +32,10 @@ #include "dm.h" namespace DM { -// this doesn't seem to be used anywhere at all + class TimelineEvent; + class CreatureInfo; + + // this doesn't seem to be used anywhere at all /* Creature types */ enum CreatureType { k0_CreatureTypeGiantScorpionScorpion = 0, // @ C00_CREATURE_GIANT_SCORPION_SCORPION @@ -107,8 +110,8 @@ class Group { public: Thing _nextThing; Thing _slot; - byte _type; - byte _cells; + uint16 _type; + uint16 _cells; uint16 _health[4]; private: uint16 _flags; @@ -121,20 +124,57 @@ public: _health[3] = rawDat[7]; } - byte &getActiveGroupIndex() { return _cells; } + byte &getActiveGroupIndex() { return *(byte*)&_cells; } uint16 getBehaviour() { return _flags & 0xF; } + uint16 setBehaviour(uint16 val) { _flags = (_flags & ~0xF) | (val & 0xF); return (val & 0xF); } uint16 getCount() { return (_flags >> 5) & 0x3; } + void setCount(uint16 val) { _flags = (_flags & ~(0x3 << 5)) | ((val & 0x3) << 5); } direction getDir() { return (direction)((_flags >> 8) & 0x3); } + void setDir(uint16 val) { _flags = (_flags & ~(0x3 << 8)) | ((val & 0x3) << 8); } uint16 getDoNotDiscard() { return (_flags >> 10) & 0x1; } }; // @ GROUP +#define k0_behavior_WANDER 0 // @ C0_BEHAVIOR_WANDER +#define k2_behavior_USELESS 2 // @ C2_BEHAVIOR_USELESS +#define k3_behavior_USELESS 3 // @ C3_BEHAVIOR_USELESS +#define k4_behavior_USELESS 4 // @ C4_BEHAVIOR_USELESS +#define k5_behavior_FLEE 5 // @ C5_BEHAVIOR_FLEE +#define k6_behavior_ATTACK 6 // @ C6_BEHAVIOR_ATTACK +#define k7_behavior_APPROACH 7 // @ C7_BEHAVIOR_APPROACH + +#define k15_immuneToFear 15 // @ C15_IMMUNE_TO_FEAR + +#define k255_immobile 255 // @ C255_IMMOBILE +#define kM1_wholeCreatureGroup -1 // @ CM1_WHOLE_CREATURE_GROUP + +#define k34_D13_soundCount 34 // @ D13_SOUND_COUNT + +int32 M32_setTime(int32 &map_time, int32 time); // @ M32_SET_TIME + class GroupMan { DMEngine *_vm; + byte _g392_dropMovingCreatureFixedPossessionsCell[4]; // @ G0392_auc_DropMovingCreatureFixedPossessionsCells + uint16 _g391_dropMovingCreatureFixedPossCellCount; // @ G0391_ui_DropMovingCreatureFixedPossessionsCellCount + uint16 _g386_fluxCageCount; // @ G0386_ui_FluxCageCount + int16 _g385_fluxCages[4]; // @ G0385_ac_FluxCages + int16 _g378_currentGroupMapX; // @ G0378_i_CurrentGroupMapX + int16 _g379_currentGroupMapY; // @ G0379_i_CurrentGroupMapY + Thing _g380_currGroupThing; // @ G0380_T_CurrentGroupThing + int16 _g384_groupMovementTestedDirections[4]; // @ G0384_auc_GroupMovementTestedDirections + uint16 _g381_currGroupDistanceToParty; // @ G0381_ui_CurrentGroupDistanceToParty + int16 _g382_currGroupPrimaryDirToParty; // @ G0382_i_CurrentGroupPrimaryDirectionToParty + int16 _g383_currGroupSecondaryDirToParty; // @ G0383_i_CurrentGroupSecondaryDirectionToParty + + Thing _g388_groupMovementBlockedByGroupThing; // @ G0388_T_GroupMovementBlockedByGroupThing + bool _g389_groupMovementBlockedByDoor; // @ G0389_B_GroupMovementBlockedByDoor + bool _g390_groupMovementBlockedByParty; // @ G0390_B_GroupMovementBlockedByParty + bool _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter; // @ G0387_B_GroupMovementBlockedByWallStairsPitFakeWallFluxcageTeleporter public: uint16 _g376_maxActiveGroupCount = 60; // @ G0376_ui_MaximumActiveGroupCount ActiveGroup *_g375_activeGroups; // @ G0375_ps_ActiveGroups + uint16 _g377_currActiveGroupCount; // @ G0377_ui_CurrentActiveGroupCount GroupMan(DMEngine *vm); ~GroupMan(); void f196_initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups @@ -142,6 +182,61 @@ public: uint16 f147_getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections int16 f176_getCreatureOrdinalInCell(Group *group, uint16 cell); // @ F0176_GROUP_GetCreatureOrdinalInCell uint16 M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex); // @ M50_CREATURE_VALUE + void f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode); // @ F0188_GROUP_DropGroupPossessions + void f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell, + int16 mode); // @ F0186_GROUP_DropCreatureFixedPossessions + int16 f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, + int16 destMapX, int16 destMapY); // @ F0228_GROUP_GetDirectionsWhereDestinationIsVisibleFromSource + bool f227_isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 srcMapY, int16 destMapX, + int16 destMapY); // @ F0227_GROUP_IsDestinationVisibleFromSource + bool f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack, + bool magicAttack, int16 ticks); // @ F0232_GROUP_IsDoorDestroyedByAttack + Thing f175_groupGetThing(int16 mapX, int16 mapY); // @ F0175_GROUP_GetThing + int16 f190_groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex, + int16 mapX, int16 mapY, int16 damage, bool notMoving); // @ F0190_GROUP_GetDamageCreatureOutcome + void f189_delete(int16 mapX, int16 mapY); // @ F0189_GROUP_Delete + void f181_groupDeleteEvents(int16 mapX, int16 mapY); // @ F0181_GROUP_DeleteEvents + uint16 f178_getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatreVal); // @ F0178_GROUP_GetGroupValueUpdatedWithCreatureValue + int16 f191_getDamageAllCreaturesOutcome(Group *group, int16 mapX, int16 mapY, int16 attack, bool notMoving); // @ F0191_GROUP_GetDamageAllCreaturesOutcome + int16 f192_groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack); // @ F0192_GROUP_GetResistanceAdjustedPoisonAttack + void f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks); // @ F0209_GROUP_ProcessEvents29to41 + bool f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, int16 mapY, + uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls); // @ F0202_GROUP_IsMovementPossible + int16 f226_getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX, + int16 destMapY); // @ F0226_GROUP_GetDistanceBetweenSquares + + int16 f200_groupGetDistanceToVisibleParty(Group *group, int16 creatureIndex, int16 mapX, int16 mapY); // @ F0200_GROUP_GetDistanceToVisibleParty + int16 f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 srcMapY, + int16 destMapX, int16 destMapY, bool (GroupMan::*isBlocked)(uint16, uint16)); // @ F0199_GROUP_GetDistanceBetweenUnblockedSquares + bool f197_isViewPartyBlocked(uint16 mapX, uint16 mapY); // @ F0197_GROUP_IsViewPartyBlocked + int32 f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 creatureIndex, + bool isAttacking); // @ F0179_GROUP_GetCreatureAspectUpdateTime + void f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures); // @ F0205_GROUP_SetDirection + void f208_groupAddEvent(TimelineEvent *event, uint32 time); // @ F0208_GROUP_AddEvent + int16 f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo, int16 mapY, int16 mapX); // @ F0201_GROUP_GetSmelledPartyPrimaryDirectionOrdinal + bool f198_isSmellPartyBlocked(uint16 mapX, uint16 mapY); // @ F0198_GROUP_IsSmellPartyBlocked + int16 f203_getFirstPossibleMovementDirOrdinal(CreatureInfo *info, int16 mapX, int16 mapY, + bool allowMovementOverImaginaryPitsAndFakeWalls); // @ F0203_GROUP_GetFirstPossibleMovementDirectionOrdinal + void f206_groupSetDirGroup(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, + int16 creatureSize); // @ F0206_GROUP_SetDirectionGroup + void f182_stopAttacking(ActiveGroup *group, int16 mapX, int16 mapY);// @ F0182_GROUP_StopAttacking + bool f204_isArchenemyDoubleMovementPossible(CreatureInfo *info, int16 mapX, int16 mapY, uint16 dir); // @ F0204_GROUP_IsArchenemyDoubleMovementPossible + bool f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 creatureIndex); // @ F0207_GROUP_IsCreatureAttacking + void f229_setOrderedCellsToAttack(signed char * orderedCellsToAttack, int16 targetMapX, + int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource); // @ F0229_GROUP_SetOrderedCellsToAttack + void f193_stealFromChampion(Group *group, uint16 championIndex); // @ F0193_GROUP_StealFromChampion + int16 f230_getChampionDamage(Group *group, uint16 champIndex); // @ F0230_GROUP_GetChampionDamage + void f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY); // @ F0187_GROUP_DropMovingCreatureFixedPossessions + void f180_startWanedring(int16 mapX, int16 mapY); // @ F0180_GROUP_StartWandering + void f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY); // @ F0183_GROUP_AddActiveGroup + void f184_removeActiveGroup(uint16 activeGroupIndex); // @ F0184_GROUP_RemoveActiveGroup + + + + + + + }; diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 1583c6f994..b8b0ba8a60 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -82,7 +82,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) { _vm->_menuMan->f395_drawMovementArrows(); em._g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement; warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput"); - warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); + _vm->_eventMan->f357_discardAllInput(); return; } } @@ -117,7 +117,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) { em._g598_mousePointerBitmapUpdated = true; em._g442_secondaryMouseInput = g449_SecondaryMouseInput_ChampionInventory; warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput"); - warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); + _vm->_eventMan->f357_discardAllInput(); } void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) { @@ -555,4 +555,92 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) { f339_drawPanelArrowOrEye(pressingEye); } + +void InventoryMan::f337_setDungeonViewPalette() { + int16 L1036_i_TotalLightAmount; + uint16 L1037_ui_TorchLightAmountMultiplier; + int16 L1038_i_Counter; + uint16 L1039_ui_Multiple; +#define AL1039_ui_SlotIndex L1039_ui_Multiple +#define AL1039_ui_PaletteIndex L1039_ui_Multiple +#define AL1039_ui_Counter L1039_ui_Multiple + int16* L1040_pi_Multiple; +#define AL1040_pi_TorchLightPower L1040_pi_Multiple +#define AL1040_pi_LightAmount L1040_pi_Multiple + int16* L1041_pi_TorchLightPower; + Weapon* L1042_ps_Weapon; + Champion* L1043_ps_Champion; + uint16 L1044_ui_Multiple; +#define AL1044_T_Thing L1044_ui_Multiple +#define AL1044_ui_TorchLightPower L1044_ui_Multiple + int16 L1045_ai_TorchesLightPower[8]; + + int16 g40_palIndexToLightAmmount[6] = {99, 75, 50, 25, 1, 0}; // @ G0040_ai_Graphic562_PaletteIndexToLightAmount + + if (_vm->_dungeonMan->_g269_currMap->_difficulty == 0) { + _vm->_displayMan->_g304_dungeonViewPaletteIndex = 0; /* Brightest color palette index */ + } else { + /* Get torch light power from both hands of each champion in the party */ + L1038_i_Counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */ + L1043_ps_Champion = _vm->_championMan->_gK71_champions; + AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower; + while (L1038_i_Counter--) { + AL1039_ui_SlotIndex = k1_ChampionSlotActionHand + 1; + while (AL1039_ui_SlotIndex--) { + if ((_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16())) >= k4_IconIndiceWeaponTorchUnlit) && + (_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16())) <= k7_IconIndiceWeaponTorchLit)) { + L1042_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(Thing(AL1044_T_Thing)); + *AL1040_pi_TorchLightPower = L1042_ps_Weapon->getChargeCount(); + } else { + *AL1040_pi_TorchLightPower = 0; + } + AL1040_pi_TorchLightPower++; + } + L1043_ps_Champion++; + } + /* Sort torch light power values so that the four highest values are in the first four entries in the array L1045_ai_TorchesLightPower in decreasing order. The last four entries contain the smallest values but they are not sorted */ + AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower; + AL1039_ui_Counter = 0; + while (AL1039_ui_Counter != 4) { + L1038_i_Counter = 7 - AL1039_ui_Counter; + L1041_pi_TorchLightPower = &L1045_ai_TorchesLightPower[AL1039_ui_Counter + 1]; + while (L1038_i_Counter--) { + if (*L1041_pi_TorchLightPower > *AL1040_pi_TorchLightPower) { + AL1044_ui_TorchLightPower = *L1041_pi_TorchLightPower; + *L1041_pi_TorchLightPower = *AL1040_pi_TorchLightPower; + *AL1040_pi_TorchLightPower = AL1044_ui_TorchLightPower; + } + L1041_pi_TorchLightPower++; + } + AL1040_pi_TorchLightPower++; + AL1039_ui_Counter++; + } + /* Get total light amount provided by the four torches with the highest light power values and by the fifth torch in the array which may be any one of the four torches with the smallest ligh power values */ + L1037_ui_TorchLightAmountMultiplier = 6; + AL1039_ui_Counter = 5; + L1036_i_TotalLightAmount = 0; + AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower; + while (AL1039_ui_Counter--) { + if (*AL1040_pi_TorchLightPower) { + L1036_i_TotalLightAmount += (g39_LightPowerToLightAmount[*AL1040_pi_TorchLightPower] << L1037_ui_TorchLightAmountMultiplier) >> 6; + L1037_ui_TorchLightAmountMultiplier = MAX(0, L1037_ui_TorchLightAmountMultiplier - 1); + } + AL1040_pi_TorchLightPower++; + } + L1036_i_TotalLightAmount += _vm->_championMan->_g407_party._magicalLightAmount; + /* Select palette corresponding to the total light amount */ + AL1040_pi_LightAmount = g40_palIndexToLightAmmount; + if (L1036_i_TotalLightAmount > 0) { + AL1039_ui_PaletteIndex = 0; /* Brightest color palette index */ + while (*AL1040_pi_LightAmount++ > L1036_i_TotalLightAmount) { + AL1039_ui_PaletteIndex++; + } + } else { + AL1039_ui_PaletteIndex = 5; /* Darkest color palette index */ + } + _vm->_displayMan->_g304_dungeonViewPaletteIndex = AL1039_ui_PaletteIndex; + } + + _vm->_displayMan->_g342_refreshDungeonViewPaleteRequested = true; +} } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index df429af70b..aa9b2150d4 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -78,6 +78,7 @@ public: void f335_drawPanelObjectDescriptionString(char *descString); // @ F0335_INVENTORY_DrawPanel_ObjectDescriptionString void f339_drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye void f342_drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object + void f337_setDungeonViewPalette(); // @ F0337_INVENTORY_SetDungeonViewPalette }; diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 376b629d28..66b293ac3e 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -32,6 +32,7 @@ #include "objectman.h" #include "inventory.h" #include "text.h" +#include "eventman.h" namespace DM { @@ -371,4 +372,33 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) { dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 48, k160_byteWidthScreen, k255_ColorNoTransparency); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } + +void MenuMan::f457_drawEnabledMenus() { + int16 L1462_i_Multiple; +#define AL1462_i_MagicCasterChampionIndex L1462_i_Multiple +#define AL1462_i_InventoryChampionOrdinal L1462_i_Multiple + + + if (_vm->_championMan->_g300_partyIsSleeping) { + _vm->_eventMan->f379_drawSleepScreen(); + _vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView); + } else { + AL1462_i_MagicCasterChampionIndex = _vm->_championMan->_g514_magicCasterChampionIndex; + _vm->_championMan->_g514_magicCasterChampionIndex = kM1_ChampionNone; /* Force next function to draw the spell area */ + _vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(AL1462_i_MagicCasterChampionIndex); + if (!_vm->_championMan->_g506_actingChampionOrdinal) { + _vm->_menuMan->_g509_actionAreaContainsIcons = true; + } + _vm->_menuMan->f387_drawActionArea(); + if (AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_g432_inventoryChampionOrdinal) { + _vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone); + _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)_vm->M1_ordinalToIndex(AL1462_i_InventoryChampionOrdinal)); + } else { + _vm->_displayMan->f98_drawFloorAndCeiling(); + _vm->_menuMan->f395_drawMovementArrows(); + } + _vm->_eventMan->f69_setMousePointer(); + } +} + } diff --git a/engines/dm/menus.h b/engines/dm/menus.h index ef5f86d153..4e0324205b 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -71,6 +71,7 @@ public: void f393_drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls void f392_buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine void f394_setMagicCasterAndDrawSpellArea(int16 champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea + void f457_drawEnabledMenus(); // @ F0457_START_DrawEnabledMenus_CPSF }; } diff --git a/engines/dm/module.mk b/engines/dm/module.mk index a1460ae944..50a8364cd4 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -42,6 +42,7 @@ MODULE_OBJS := \ menus.o \ movesens.o \ objectman.o \ + projexpl.o \ text.o \ timeline.o diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 9fab510ecf..70f8cc8220 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -31,6 +31,10 @@ #include "inventory.h" #include "dungeonman.h" #include "objectman.h" +#include "timeline.h" +#include "group.h" +#include "projexpl.h" +#include "text.h" namespace DM { @@ -38,158 +42,1042 @@ namespace DM { MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {} bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam) { - ChampionMan &champMan = *_vm->_championMan; - DungeonMan &dunMan = *_vm->_dungeonMan; - ObjectMan &objMan = *_vm->_objectMan; - - - bool atLeastOneSensorWasTriggered = false; - Thing leaderHandObject = champMan._g414_leaderHandObject; - int16 sensorCountToProcessPerCell[4]; - uint16 cell; - for (cell = k0_CellNorthWest; cell < k3_CellSouthWest; ++cell) { - sensorCountToProcessPerCell[cell] = 0; - } - Thing squareFirstThing; - Thing thingBeingProcessed = squareFirstThing = dunMan.f161_getSquareFirstThing(mapX, mapY); - ThingType thingType; - while (thingBeingProcessed != Thing::_endOfList) { - thingType = thingBeingProcessed.getType(); - if (thingType == k3_SensorThingType) { - sensorCountToProcessPerCell[thingBeingProcessed.getCell()]++; - } else if (thingType >= k4_GroupThingType) { - break; + Thing L0750_T_ThingBeingProcessed; + uint16 L0751_ui_ThingType; + uint16 L0752_ui_Cell; + bool L0753_B_DoNotTriggerSensor; + Thing* L0754_ps_Generic; + Sensor* L0755_ps_Sensor; + int16 L0756_i_SensorEffect; + uint16 L0757_ui_SensorType; + int16 L0758_i_SensorData; + bool L0759_B_AtLeastOneSensorWasTriggered; + int16 L0760_ai_SensorCountToProcessPerCell[4]; + Thing L0761_T_LeaderHandObject; + Thing L0762_T_ThingOnSquare; + Thing L0763_T_LastProcessedThing; + Thing L0764_T_SquareFirstThing; + Sensor* L0765_ps_Sensor; + + + L0759_B_AtLeastOneSensorWasTriggered = false; + L0761_T_LeaderHandObject = _vm->_championMan->_g414_leaderHandObject; + for (L0752_ui_Cell = k0_CellNorthWest; L0752_ui_Cell < k3_CellSouthWest + 1; L0752_ui_Cell++) { + L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell] = 0; + } + L0764_T_SquareFirstThing = L0750_T_ThingBeingProcessed = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY); + while (L0750_T_ThingBeingProcessed != Thing::_endOfList) { + if ((L0751_ui_ThingType = (L0750_T_ThingBeingProcessed).getType()) == k3_SensorThingType) { + L0760_ai_SensorCountToProcessPerCell[(L0750_T_ThingBeingProcessed).getCell()]++; + } else { + if (L0751_ui_ThingType >= k4_GroupThingType) + break; } - thingBeingProcessed = dunMan.f159_getNextThing(thingBeingProcessed); + L0750_T_ThingBeingProcessed = _vm->_dungeonMan->f159_getNextThing(L0750_T_ThingBeingProcessed); } - Thing lastProcessedThing = thingBeingProcessed = squareFirstThing; - - while (thingBeingProcessed != Thing::_endOfList) { - thingType = thingBeingProcessed.getType(); - if (thingType == k3_SensorThingType) { - cell = thingBeingProcessed.getCell(); - sensorCountToProcessPerCell[cell]--; - Sensor *sensor = (Sensor*)dunMan.f156_getThingData(thingBeingProcessed); // IF YOU CHECK ME, I'LL CALL THE COPS! - SensorType sensorType = sensor->getType(); - if (sensorType == k0_SensorDisabled) + L0763_T_LastProcessedThing = L0750_T_ThingBeingProcessed = L0764_T_SquareFirstThing; + while (L0750_T_ThingBeingProcessed != Thing::_endOfList) { + if ((L0751_ui_ThingType = (L0750_T_ThingBeingProcessed).getType()) == k3_SensorThingType) { + L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell = (L0750_T_ThingBeingProcessed).getCell()]--; + L0755_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0750_T_ThingBeingProcessed); + if ((L0757_ui_SensorType = (L0755_ps_Sensor)->getType()) == k0_SensorDisabled) goto T0275058_ProceedToNextThing; - if ((champMan._g411_leaderIndex == kM1_ChampionNone) && (sensorType != k127_SensorWallChampionPortrait)) + if ((_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) && (L0757_ui_SensorType != k127_SensorWallChampionPortrait)) goto T0275058_ProceedToNextThing; - if (cell != cellParam) + if (L0752_ui_Cell != cellParam) goto T0275058_ProceedToNextThing; - int16 sensorData = sensor->getData(); - int16 sensorEffect = sensor->getEffectA(); - bool doNotTriggerSensor; - switch (sensorType) { + L0758_i_SensorData = L0755_ps_Sensor->getData(); + L0756_i_SensorEffect = L0755_ps_Sensor->getEffectA(); + switch (L0757_ui_SensorType) { case k1_SensorWallOrnClick: - doNotTriggerSensor = false; - if (sensor->getEffectA() == k3_SensorEffHold) { + L0753_B_DoNotTriggerSensor = false; + if (L0755_ps_Sensor->getEffectA() == k3_SensorEffHold) { goto T0275058_ProceedToNextThing; } break; case k2_SensorWallOrnClickWithAnyObj: - doNotTriggerSensor = (champMan._g415_leaderEmptyHanded != sensor->getRevertEffectA()); + L0753_B_DoNotTriggerSensor = (_vm->_championMan->_g415_leaderEmptyHanded != L0755_ps_Sensor->getRevertEffectA()); break; case k17_SensorWallOrnClickWithSpecObjRemovedSensor: case k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors: - if (sensorCountToProcessPerCell[cell]) + if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */ goto T0275058_ProceedToNextThing; case k3_SensorWallOrnClickWithSpecObj: case k4_SensorWallOrnClickWithSpecObjRemoved: - doNotTriggerSensor = ((sensorData == objMan.f32_getObjectType(leaderHandObject)) == sensor->getRevertEffectA()); - if (!doNotTriggerSensor && (sensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) { - if (lastProcessedThing == thingBeingProcessed) + L0753_B_DoNotTriggerSensor = ((L0758_i_SensorData == _vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject)) == L0755_ps_Sensor->getRevertEffectA()); + if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) { + if (L0763_T_LastProcessedThing == L0750_T_ThingBeingProcessed) /* If the sensor is the only one of its type on the cell */ break; - ((Sensor*)dunMan.f156_getThingData(lastProcessedThing))->setNextThing(sensor->getNextThing()); - sensor->setNextThing(Thing::_none); - thingBeingProcessed = lastProcessedThing; + L0765_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0763_T_LastProcessedThing); + L0765_ps_Sensor->setNextThing(L0755_ps_Sensor->getNextThing()); + L0755_ps_Sensor->setNextThing(Thing::_none); + L0750_T_ThingBeingProcessed = L0763_T_LastProcessedThing; } - if (!doNotTriggerSensor && (sensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors)) { - warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect"); + if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors)) { + f270_sensorTriggetLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */ } break; case k12_SensorWallObjGeneratorRotateSensors: - if (sensorCountToProcessPerCell[cell]) + if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */ goto T0275058_ProceedToNextThing; - doNotTriggerSensor = !champMan._g415_leaderEmptyHanded; - if (!doNotTriggerSensor) { - warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect"); + L0753_B_DoNotTriggerSensor = !_vm->_championMan->_g415_leaderEmptyHanded; + if (!L0753_B_DoNotTriggerSensor) { + f270_sensorTriggetLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */ } break; case k13_SensorWallSingleObjStorageRotateSensors: - if (champMan._g415_leaderEmptyHanded) { - warning("MISSING CODE: F0273_SENSOR_GetObjectOfTypeInCell"); - warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList"); - warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand"); + if (_vm->_championMan->_g415_leaderEmptyHanded) { + if ((L0761_T_LeaderHandObject = f273_sensorGetObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData)) == Thing::_none) + goto T0275058_ProceedToNextThing; + _vm->_dungeonMan->f164_unlinkThingFromList(L0761_T_LeaderHandObject, Thing(0), mapX, mapY); + _vm->_championMan->f297_putObjectInLeaderHand(L0761_T_LeaderHandObject, true); } else { - warning("MISSING CODE: F0273_SENSOR_GetObjectOfTypeInCell"); - warning(("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand")); - warning("MISSING CODE: F0163_DUNGEON_LinkThingToList"); - leaderHandObject = Thing::_none; - } - warning("MISSING CODE: F0270_SENSOR_TriggerLocalEffect"); - if ((sensorEffect == k3_SensorEffHold) && !champMan._g415_leaderEmptyHanded) { - doNotTriggerSensor = true; + if ((_vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (f273_sensorGetObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData) != Thing::_none)) + goto T0275058_ProceedToNextThing; + _vm->_championMan->f298_getObjectRemovedFromLeaderHand(); + _vm->_dungeonMan->f163_linkThingToList(M15_thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY); + L0761_T_LeaderHandObject = Thing::_none; + } + f270_sensorTriggetLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */ + if ((L0756_i_SensorEffect == k3_SensorEffHold) && !_vm->_championMan->_g415_leaderEmptyHanded) { + L0753_B_DoNotTriggerSensor = true; } else { - doNotTriggerSensor = false; + L0753_B_DoNotTriggerSensor = false; } break; - case k16_SensorWallObjExchanger: { - if (sensorCountToProcessPerCell[cell]) + case k16_SensorWallObjExchanger: + if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */ goto T0275058_ProceedToNextThing; - Thing thingOnSquare = dunMan.f161_getSquareFirstThing(mapX, mapY); - if ((objMan.f32_getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_none)) + L0762_T_ThingOnSquare = _vm->_dungeonMan->f162_getSquareFirstObject(mapX, mapY); + if ((_vm->_objectMan->f32_getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (L0762_T_ThingOnSquare == Thing::_none)) goto T0275058_ProceedToNextThing; - warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList"); - warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand"); - warning("MISSING CODE: F0163_DUNGEON_LinkThingToList"); - warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand"); - doNotTriggerSensor = false; + _vm->_dungeonMan->f164_unlinkThingFromList(L0762_T_ThingOnSquare, Thing(0), mapX, mapY); + _vm->_championMan->f298_getObjectRemovedFromLeaderHand(); + _vm->_dungeonMan->f163_linkThingToList(M15_thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY); + _vm->_championMan->f297_putObjectInLeaderHand(L0762_T_ThingOnSquare, true); + L0753_B_DoNotTriggerSensor = false; break; - } case k127_SensorWallChampionPortrait: - champMan.f280_addCandidateChampionToParty(sensorData); + _vm->_championMan->f280_addCandidateChampionToParty(L0758_i_SensorData); goto T0275058_ProceedToNextThing; default: goto T0275058_ProceedToNextThing; } - - if (sensorEffect == k3_SensorEffHold) { - sensorEffect = doNotTriggerSensor ? k1_SensorEffClear : k0_SensorEffSet; - doNotTriggerSensor = false; + if (L0756_i_SensorEffect == k3_SensorEffHold) { + L0756_i_SensorEffect = L0753_B_DoNotTriggerSensor ? k1_SensorEffClear : k0_SensorEffSet; + L0753_B_DoNotTriggerSensor = false; } - - if (!doNotTriggerSensor) { - atLeastOneSensorWasTriggered = true; - if (sensor->getAudibleA()) { + if (!L0753_B_DoNotTriggerSensor) { + L0759_B_AtLeastOneSensorWasTriggered = true; + if (L0755_ps_Sensor->getAudibleA()) { warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } - if (!champMan._g415_leaderEmptyHanded && - ((sensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || - (sensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || - (sensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) { - - *((Thing*)dunMan.f156_getThingData(leaderHandObject)) = Thing::_none; - warning("MISSING CODE: F0298_CHAMPION_GetObjectRemovedFromLeaderHand"); - leaderHandObject = Thing::_none; + if (!_vm->_championMan->_g415_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) { + L0754_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0761_T_LeaderHandObject); + *L0754_ps_Generic = Thing::_none; + _vm->_championMan->f298_getObjectRemovedFromLeaderHand(); + L0761_T_LeaderHandObject = Thing::_none; } else { - warning("MISSING CODE: (leaderHandObject = F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator(sensorData)"); - if (champMan._g415_leaderEmptyHanded && (sensorType == k12_SensorWallObjGeneratorRotateSensors) && (leaderHandObject != Thing::_none)) { - warning("MISSING CODE: F0297_CHAMPION_PutObjectInLeaderHand"); + if (_vm->_championMan->_g415_leaderEmptyHanded && + (L0757_ui_SensorType == k12_SensorWallObjGeneratorRotateSensors) && + ((L0761_T_LeaderHandObject = _vm->_dungeonMan->f167_getObjForProjectileLaucherOrObjGen(L0758_i_SensorData)) != Thing::_none)) { + _vm->_championMan->f297_putObjectInLeaderHand(L0761_T_LeaderHandObject, true); } } - warning("MISSING CODE: F0272_SENSOR_TriggerEffect"); + f272_sensorTriggerEffect(L0755_ps_Sensor, L0756_i_SensorEffect, mapX, mapY, L0752_ui_Cell); } goto T0275058_ProceedToNextThing; } - if (thingType >= k4_GroupThingType) + if (L0751_ui_ThingType >= k4_GroupThingType) break; T0275058_ProceedToNextThing: - lastProcessedThing = thingBeingProcessed; - thingBeingProcessed = dunMan.f159_getNextThing(thingBeingProcessed); + L0763_T_LastProcessedThing = L0750_T_ThingBeingProcessed; + L0750_T_ThingBeingProcessed = _vm->_dungeonMan->f159_getNextThing(L0750_T_ThingBeingProcessed); + } + f271_processRotationEffect(); + return L0759_B_AtLeastOneSensorWasTriggered; +} + +bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destMapX, int16 destMapY) { + int16 L0708_i_Multiple = 0; +#define AL0708_i_DestinationSquare L0708_i_Multiple +#define AL0708_i_ScentIndex L0708_i_Multiple +#define AL0708_i_ActiveGroupIndex L0708_i_Multiple + int16 L0709_i_Multiple; +#define AL0709_i_DestinationSquareType L0709_i_Multiple +#define AL0709_i_ChampionIndex L0709_i_Multiple + int16 L0710_i_ThingType; + Champion* L0711_ps_Champion; + Teleporter* L0712_ps_Teleporter; + bool L0713_B_ThingLevitates; + uint16 L0714_ui_MapIndexSource = 0; + uint16 L0715_ui_MapIndexDestination = 0; + uint16 L0716_ui_Direction = 0; + uint16 L0717_ui_ThingCell = 0; + int16 L0718_i_RequiredTeleporterScope; + // Strangerke: Only present in v2.1, but it fixes a bug, so I propose to keep it + int16 L0719_i_TraversedPitCount; + uint16 L0720_ui_MoveGroupResult; + bool L0721_B_GroupOnPartyMap; + bool L0722_B_FallKilledGroup; + bool L0723_B_DrawDungeonViewWhileFalling; + bool L0724_B_DestinationIsTeleporterTarget; + bool L0725_B_PartySquare; + bool L0726_B_Audible; + uint16 L0727_ui_Multiple; +#define AL0727_ui_ThingCell L0727_ui_Multiple +#define AL0727_ui_Outcome L0727_ui_Multiple +#define AL0727_ui_Backup L0727_ui_Multiple + int16 L0728_i_ChainedMoveCount; + uint16 L1638_ui_MovementSoundIndex; + + L0710_i_ThingType = kM1_PartyThingType; + L0713_B_ThingLevitates = false; + L0719_i_TraversedPitCount = 0; + L0720_ui_MoveGroupResult = 0; + L0721_B_GroupOnPartyMap = false; + L0722_B_FallKilledGroup = false; + L0723_B_DrawDungeonViewWhileFalling = false; + L0724_B_DestinationIsTeleporterTarget = false; + L0725_B_PartySquare = false; + L0726_B_Audible = false; + if (thing != Thing::_party) { + L0710_i_ThingType = (thing).getType(); + L0717_ui_ThingCell = (thing).getCell(); + L0713_B_ThingLevitates = f264_isLevitating(thing); + } + /* If moving the party or a creature on the party map from a dungeon square then check for a projectile impact */ + if ((mapX >= 0) && ((thing == Thing::_party) || ((L0710_i_ThingType == k4_GroupThingType) && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)))) { + if (f266_moveIsKilledByProjectileImpact(mapX, mapY, destMapX, destMapY, thing)) { + return true; /* The specified group thing cannot be moved because it was killed by a projectile impact */ + } + } + if (destMapX >= 0) { + L0714_ui_MapIndexSource = L0715_ui_MapIndexDestination = _vm->_dungeonMan->_g272_currMapIndex; + L0721_B_GroupOnPartyMap = (L0714_ui_MapIndexSource == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX >= 0); + if (thing == Thing::_party) { + _vm->_dungeonMan->_g306_partyMapX = destMapX; + _vm->_dungeonMan->_g307_partyMapY = destMapY; + L0718_i_RequiredTeleporterScope = k0x0002_TelepScopeObjOrParty; + L0723_B_DrawDungeonViewWhileFalling = !_vm->_inventoryMan->_g432_inventoryChampionOrdinal && !_vm->_championMan->_g300_partyIsSleeping; + L0716_ui_Direction = _vm->_dungeonMan->_g308_partyDir; + } else { + if (L0710_i_ThingType == k4_GroupThingType) { + L0718_i_RequiredTeleporterScope = k0x0001_TelepScopeCreatures; + } else { + L0718_i_RequiredTeleporterScope = (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty); + } + } + if (L0710_i_ThingType == k14_ProjectileThingType) { + L0712_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(thing); + _g400_moveResultDir = (_vm->_timeline->_g370_events[((Projectile*)L0712_ps_Teleporter)->_eventIndex])._C._projectile.getDir(); + } + for (L0728_i_ChainedMoveCount = 1000; --L0728_i_ChainedMoveCount; ) { /* No more than 1000 chained moves at once (in a chain of teleporters and pits for example) */ + AL0708_i_DestinationSquare = _vm->_dungeonMan->_g271_currMapData[destMapX][destMapY]; + if ((AL0709_i_DestinationSquareType = Square(AL0708_i_DestinationSquare).getType()) == k5_ElementTypeTeleporter) { + if (!getFlag(AL0708_i_DestinationSquare, k0x0008_TeleporterOpen)) + break; + L0712_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(destMapX, destMapY); + if ((L0712_ps_Teleporter->getScope() == k0x0001_TelepScopeCreatures) && (L0710_i_ThingType != k4_GroupThingType)) + break; + if ((L0718_i_RequiredTeleporterScope != (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty)) && !getFlag(L0712_ps_Teleporter->getScope(), L0718_i_RequiredTeleporterScope)) + break; + L0724_B_DestinationIsTeleporterTarget = (destMapX == L0712_ps_Teleporter->getTargetMapX()) && (destMapY == L0712_ps_Teleporter->getTargetMapY()) && (L0715_ui_MapIndexDestination == L0712_ps_Teleporter->getTargetMapIndex()); + destMapX = L0712_ps_Teleporter->getTargetMapX(); + destMapY = L0712_ps_Teleporter->getTargetMapY(); + L0726_B_Audible = L0712_ps_Teleporter->isAudible(); + _vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination = L0712_ps_Teleporter->getTargetMapIndex()); + if (thing == Thing::_party) { + _vm->_dungeonMan->_g306_partyMapX = destMapX; + _vm->_dungeonMan->_g307_partyMapY = destMapY; + if (L0712_ps_Teleporter->isAudible()) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + L0723_B_DrawDungeonViewWhileFalling = true; + if (L0712_ps_Teleporter->getAbsoluteRotation()) { + _vm->_championMan->f284_setPartyDirection(L0712_ps_Teleporter->getRotation()); + } else { + _vm->_championMan->f284_setPartyDirection(M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + L0712_ps_Teleporter->getRotation())); + } + } else { + if (L0710_i_ThingType == k4_GroupThingType) { + if (L0712_ps_Teleporter->isAudible()) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + L0720_ui_MoveGroupResult = f262_getTeleporterRotatedGroupResult(L0712_ps_Teleporter, thing, L0714_ui_MapIndexSource); + } else { + if (L0710_i_ThingType == k14_ProjectileThingType) { + thing = f263_getTeleporterRotatedProjectileThing(L0712_ps_Teleporter, thing); + } else { + if (!(L0712_ps_Teleporter->getAbsoluteRotation()) && (mapX != -2)) { + thing = M15_thingWithNewCell(thing, M21_normalizeModulo4((thing).getCell() + L0712_ps_Teleporter->getRotation())); + } + } + } + } + if (L0724_B_DestinationIsTeleporterTarget) + break; + } else { + if ((AL0709_i_DestinationSquareType == k2_ElementTypePit) && !L0713_B_ThingLevitates && getFlag(AL0708_i_DestinationSquare, k0x0008_PitOpen) && !getFlag(AL0708_i_DestinationSquare, k0x0001_PitImaginary)) { + if (L0723_B_DrawDungeonViewWhileFalling && !_g402_useRopeToClimbDownPit) { + L0723_B_DrawDungeonViewWhileFalling = true; + if (L0719_i_TraversedPitCount) { + _vm->_dungeonMan->f174_setCurrentMapAndPartyMap(L0715_ui_MapIndexDestination); + _vm->_displayMan->f96_loadCurrentMapGraphics(); + } + L0719_i_TraversedPitCount++; + _vm->_displayMan->f128_drawDungeon(_vm->_dungeonMan->_g308_partyDir, destMapX, destMapY); /* BUG0_28 When falling through multiple pits the dungeon view is updated to show each traversed map but the graphics used for creatures, wall and floor ornaments may not be correct. The dungeon view is drawn for each map by using the graphics loaded for the source map. Therefore the graphics for creatures, wall and floor ornaments may not look like what they should */ + /* BUG0_71 Some timings are too short on fast computers. When the party falls in a series of pits, the dungeon view is refreshed too quickly because the execution speed is not limited */ + /* BUG0_01 While drawing creatures the engine will read invalid ACTIVE_GROUP data in _vm->_groupMan->_g375_activeGroups because the data is for the creatures on the source map and not the map being drawn. The only consequence is that creatures may be drawn with incorrect bitmaps and/or directions */ + } + L0715_ui_MapIndexDestination = _vm->_dungeonMan->f154_getLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &destMapX, &destMapY); + _vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination); + if (thing == Thing::_party) { + _vm->_dungeonMan->_g306_partyMapX = destMapX; + _vm->_dungeonMan->_g307_partyMapY = destMapY; + if (_vm->_championMan->_g305_partyChampionCount > 0) { + if (_g402_useRopeToClimbDownPit) { + for (AL0709_i_ChampionIndex = k0_ChampionFirst, L0711_ps_Champion = _vm->_championMan->_gK71_champions; AL0709_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL0709_i_ChampionIndex++, L0711_ps_Champion++) { + if (L0711_ps_Champion->_currHealth) { + _vm->_championMan->f325_decrementStamine(AL0709_i_ChampionIndex, ((L0711_ps_Champion->_load * 25) / _vm->_championMan->f309_getMaximumLoad(L0711_ps_Champion)) + 1); + } + } + } else { + if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF)) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + } + } + _g402_useRopeToClimbDownPit = false; + } else { + if (L0710_i_ThingType == k4_GroupThingType) { + _vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource); + AL0727_ui_Outcome = _vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group*)_vm->_dungeonMan->f156_getThingData(thing), mapX, mapY, 20, false); + _vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination); + if (L0722_B_FallKilledGroup = (AL0727_ui_Outcome == k2_outcomeKilledAllCreaturesInGroup)) + break; + if (AL0727_ui_Outcome == k1_outcomeKilledSomeCreaturesInGroup) { + _vm->_groupMan->f187_dropMovingCreatureFixedPossession(thing, destMapX, destMapY); + } + } + } + } else { + if ((AL0709_i_DestinationSquareType == k3_ElementTypeStairs) && (thing != Thing::_party) && (L0710_i_ThingType != k14_ProjectileThingType)) { + if (!getFlag(AL0708_i_DestinationSquare, k0x0004_StairsUp)) { + L0715_ui_MapIndexDestination = _vm->_dungeonMan->f154_getLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &destMapX, &destMapY); + _vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination); + } + L0716_ui_Direction = _vm->_dungeonMan->f155_getStairsExitDirection(destMapX, destMapY); + destMapX += _vm->_dirIntoStepCountEast[L0716_ui_Direction], destMapY += _vm->_dirIntoStepCountNorth[L0716_ui_Direction]; + L0716_ui_Direction = returnOppositeDir((direction)L0716_ui_Direction); + AL0727_ui_ThingCell = (thing).getCell(); + AL0727_ui_ThingCell = M21_normalizeModulo4((((AL0727_ui_ThingCell - L0716_ui_Direction + 1) & 0x0002) >> 1) + L0716_ui_Direction); + thing = M15_thingWithNewCell(thing, AL0727_ui_ThingCell); + } else + break; + } + } + } + if ((L0710_i_ThingType == k4_GroupThingType) && (L0722_B_FallKilledGroup || !_vm->_dungeonMan->f139_isCreatureAllowedOnMap(thing, L0715_ui_MapIndexDestination))) { + _vm->_groupMan->f187_dropMovingCreatureFixedPossession(thing, destMapX, destMapY); + _vm->_groupMan->f188_dropGroupPossessions(destMapX, destMapY, thing, k2_soundModePlayOneTickLater); + _vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource); + if (mapX >= 0) { + _vm->_groupMan->f189_delete(mapX, mapY); + } + return true; /* The specified group thing cannot be moved because it was killed by a fall or because it is not allowed on the destination map */ + } + _g397_moveResultMapX = destMapX; + _g398_moveResultMapY = destMapY; + _g399_moveResultMapIndex = L0715_ui_MapIndexDestination; + _g401_moveResultCell = (thing).getCell(); + L0725_B_PartySquare = (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) && (destMapX == mapX) && (destMapY == mapY); + if (L0725_B_PartySquare) { + if (thing == Thing::_party) { + if (_vm->_dungeonMan->_g308_partyDir == L0716_ui_Direction) { + return false; + } + } else { + if ((_g401_moveResultCell == L0717_ui_ThingCell) && (L0710_i_ThingType != k14_ProjectileThingType)) { + return false; + } + } + } else { + if ((thing == Thing::_party) && _vm->_championMan->_g305_partyChampionCount) { + AL0727_ui_Backup = AL0708_i_DestinationSquare; + AL0708_i_ScentIndex = _vm->_championMan->_g407_party._scentCount; + while (AL0708_i_ScentIndex >= 24) { + _vm->_championMan->f316_deleteScent(0); + AL0708_i_ScentIndex--; + } + if (AL0708_i_ScentIndex) { + _vm->_championMan->f317_addScentStrength(mapX, mapY, (int)(_vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime)); + } + _vm->_projexpl->_g362_lastPartyMovementTime = _vm->_g313_gameTime; + _vm->_championMan->_g407_party._scentCount++; + if (_vm->_championMan->_g407_party._event79Count_Footprints) { + _vm->_championMan->_g407_party._lastScentIndex = _vm->_championMan->_g407_party._scentCount; + } + _vm->_championMan->_g407_party._scents[AL0708_i_ScentIndex].setMapX(destMapX); + _vm->_championMan->_g407_party._scents[AL0708_i_ScentIndex].setMapY(destMapY); + _vm->_championMan->_g407_party._scents[AL0708_i_ScentIndex].setMapIndex(L0715_ui_MapIndexDestination); + _vm->_championMan->_g407_party._scentStrengths[AL0708_i_ScentIndex] = 0; + _vm->_championMan->f317_addScentStrength(destMapX, destMapY, k0x8000_mergeCycles | 24); + AL0708_i_DestinationSquare = AL0727_ui_Backup; + } + if (L0715_ui_MapIndexDestination != L0714_ui_MapIndexSource) { + _vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource); + } + } + } + if (mapX >= 0) { + if (thing == Thing::_party) { + f276_sensorProcessThingAdditionOrRemoval(mapX, mapY, Thing::_party, L0725_B_PartySquare, false); + } else { + if (L0713_B_ThingLevitates) { + _vm->_dungeonMan->f164_unlinkThingFromList(thing, Thing(0), mapX, mapY); + } else { + f276_sensorProcessThingAdditionOrRemoval(mapX, mapY, thing, (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX == _vm->_dungeonMan->_g306_partyMapX) && (mapY == _vm->_dungeonMan->_g307_partyMapY), false); + } + } + } + if (destMapX >= 0) { + if (thing == Thing::_party) { + _vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination); + if ((thing = _vm->_groupMan->f175_groupGetThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY)) != Thing::_endOfList) { /* Delete group if party moves onto its square */ + _vm->_groupMan->f188_dropGroupPossessions(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, thing, k1_soundModePlayIfPrioritized); + _vm->_groupMan->f189_delete(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); + } + if (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) { + f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, L0725_B_PartySquare, true); + } else { + _vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource); + _vm->_g327_newPartyMapIndex = L0715_ui_MapIndexDestination; + } + } else { + if (L0710_i_ThingType == k4_GroupThingType) { + _vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination); + L0712_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(thing); + AL0708_i_ActiveGroupIndex = ((Group*)L0712_ps_Teleporter)->getActiveGroupIndex(); + if (((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_g309_partyMapIndex) && (destMapX == _vm->_dungeonMan->_g306_partyMapX) && (destMapY == _vm->_dungeonMan->_g307_partyMapY)) || (_vm->_groupMan->f175_groupGetThing(destMapX, destMapY) != Thing::_endOfList)) { /* If a group tries to move to the party square or over another group then create an event to move the group later */ + _vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource); + if (mapX >= 0) { + _vm->_groupMan->f181_groupDeleteEvents(mapX, mapY); + } + if (L0721_B_GroupOnPartyMap) { + _vm->_groupMan->f184_removeActiveGroup(AL0708_i_ActiveGroupIndex); + } + f265_createEvent60to61_moveGroup(thing, destMapX, destMapY, L0715_ui_MapIndexDestination, L0726_B_Audible); + return true; /* The specified group thing cannot be moved because the party or another group is on the destination square */ + } + L1638_ui_MovementSoundIndex = f514_getSound(((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[(thing).getIndex()]._type); + if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != _vm->_dungeonMan->_g309_partyMapIndex)) { /* If the group leaves the party map */ + _vm->_groupMan->f184_removeActiveGroup(AL0708_i_ActiveGroupIndex); + L0720_ui_MoveGroupResult = true; + } else { + if ((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_g309_partyMapIndex) && (!L0721_B_GroupOnPartyMap)) { /* If the group arrives on the party map */ + _vm->_groupMan->f183_addActiveGroup(thing, destMapX, destMapY); + L0720_ui_MoveGroupResult = true; + } + } + if (L0713_B_ThingLevitates) { + _vm->_dungeonMan->f163_linkThingToList(thing, Thing(0), destMapX, destMapY); + } else { + f276_sensorProcessThingAdditionOrRemoval(destMapX, destMapY, thing, false, true); + } + if (L0720_ui_MoveGroupResult || (mapX < 0)) { /* If group moved from one map to another or if it was just placed on a square */ + _vm->_groupMan->f180_startWanedring(destMapX, destMapY); + } + _vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource); + if (mapX >= 0) { + if (L0720_ui_MoveGroupResult > 1) { /* If the group behavior was C6_BEHAVIOR_ATTACK before being teleported from and to the party map */ + _vm->_groupMan->f182_stopAttacking(&_vm->_groupMan->_g375_activeGroups[L0720_ui_MoveGroupResult - 2], mapX, mapY); + } else { + if (L0720_ui_MoveGroupResult) { /* If the group was teleported or leaved the party map or entered the party map */ + _vm->_groupMan->f181_groupDeleteEvents(mapX, mapY); + } + } + } + return L0720_ui_MoveGroupResult; + } + _vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination); + if (L0710_i_ThingType == k14_ProjectileThingType) { /* BUG0_29 An explosion can trigger a floor sensor. Explosions do not trigger floor sensors on the square where they are created. However, if an explosion is moved by a teleporter (or by falling into a pit, see BUG0_26) after it was created, it can trigger floor sensors on the destination square. This is because explosions are not considered as levitating in the code, while projectiles are. The condition here should be (L0713_B_ThingLevitates) so that explosions would not start sensor processing on their destination square as they should be Levitating. This would work if F0264_MOVE_IsLevitating returned true for explosions (see BUG0_26) */ + _vm->_dungeonMan->f163_linkThingToList(thing, Thing(0), destMapX, destMapY); + } else { + f276_sensorProcessThingAdditionOrRemoval(destMapX, destMapY, thing, (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (destMapX == _vm->_dungeonMan->_g306_partyMapX) && (destMapY == _vm->_dungeonMan->_g307_partyMapY), true); + } + _vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource); + } + } + return false; +} + +bool MovesensMan::f264_isLevitating(Thing thing) { + int16 L0695_i_ThingType; + + + if ((L0695_i_ThingType = (thing).getType()) == k4_GroupThingType) { + return getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(thing), k0x0020_MaskCreatureInfo_levitation); + } + if (L0695_i_ThingType == k14_ProjectileThingType) { /* BUG0_26 An explosion may fall in a pit. If a pit is opened while there is an explosion above then the explosion falls into the pit in F0267_MOVE_GetMoveResult_CPSCE. Explosions are not considered as levitating so they are moved when the pit is opened. This function should return true for explosions */ + return true; + } + return false; +} + +bool MovesensMan::f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY, Thing thing) { + Thing L0697_T_Thing; + uint16 L0699_ui_Multiple; +#define AL0699_ui_Cell L0699_ui_Multiple +#define AL0699_ui_PrimaryDirection L0699_ui_Multiple +#define AL0699_ui_ChampionOrCreatureOrdinal L0699_ui_Multiple + int16 L0700_i_Multiple; +#define AL0700_B_CreatureAlive L0700_i_Multiple +#define AL0700_i_Distance L0700_i_Multiple +#define AL0700_i_SecondaryDirection L0700_i_Multiple + Group* L0701_ps_Group; + int16 L0702_i_ImpactType; + bool L0703_B_CheckDestinationSquareProjectileImpacts; + uint16 L0704_ui_ProjectileMapX; + uint16 L0705_ui_ProjectileMapY; + byte L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[4]; /* This array is used only when moving between two adjacent squares and is used to test projectile impacts when the party or group is in the 'intermediary' step between the two squares. Without this test, in the example below no impact would be detected. In this example, the party moves from the source square on the left (which contains a single champion at cell 2) to the destination square on the right (which contains a single projectile at cell 3). + Party: Projectiles on target square: Incorrect result without the test for the intermediary step (the champion would have passed through the projectile without impact): + 00 -> 00 00 + 01 P0 P1 */ + byte L0707_auc_ChampionOrCreatureOrdinalInCell[4]; /* This array has an entry for each cell on the source square, containing the ordinal of the champion or creature (0 if there is no champion or creature at this cell) */ + + + L0703_B_CheckDestinationSquareProjectileImpacts = false; + for (int16 i = 0; i < 4; ++i) + L0707_auc_ChampionOrCreatureOrdinalInCell[i] = 0; + if (thing == Thing::_party) { + L0702_i_ImpactType = kM2_ChampionElemType; + for (AL0699_ui_Cell = k0_CellNorthWest; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) { + if (_vm->_championMan->f285_getIndexInCell((ViewCell)AL0699_ui_Cell) >= 0) { + L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = _vm->M0_indexToOrdinal(AL0699_ui_Cell); + } + } + } else { + L0702_i_ImpactType = kM1_CreatureElemType; + L0701_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing); + for (AL0699_ui_Cell = k0_CellNorthWest, AL0700_B_CreatureAlive = false; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) { + AL0700_B_CreatureAlive |= L0701_ps_Group->_health[AL0699_ui_Cell]; + if (_vm->_groupMan->f176_getCreatureOrdinalInCell(L0701_ps_Group, AL0699_ui_Cell)) { + L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = _vm->M0_indexToOrdinal(AL0699_ui_Cell); + } + } + if (!AL0700_B_CreatureAlive) { + return false; + } + } + if ((destMapX >= 0) && (((((AL0700_i_Distance = srcMapX - destMapX) < 0) ? -AL0700_i_Distance : AL0700_i_Distance) + (((AL0700_i_Distance = srcMapY - destMapY) < 0) ? -AL0700_i_Distance : AL0700_i_Distance)) == 1)) { /* If source and destination squares are adjacent (if party or group is not being teleported) */ + AL0699_ui_PrimaryDirection = _vm->_groupMan->f228_getDirsWhereDestIsVisibleFromSource(srcMapX, srcMapY, destMapX, destMapY); + AL0700_i_SecondaryDirection = returnNextVal(AL0699_ui_PrimaryDirection); + for (int16 i = 0; i < 4; ++i) + L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[i] = 0; + if (L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnPrevVal(AL0699_ui_PrimaryDirection)] = L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection]) { + L0703_B_CheckDestinationSquareProjectileImpacts = true; + } + if (L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnNextVal(AL0700_i_SecondaryDirection)] = L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection]) { + L0703_B_CheckDestinationSquareProjectileImpacts = true; + } + if (!L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection]) { + L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection] = L0707_auc_ChampionOrCreatureOrdinalInCell[returnPrevVal(AL0699_ui_PrimaryDirection)]; + } + if (!L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection]) { + L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection] = L0707_auc_ChampionOrCreatureOrdinalInCell[returnNextVal(AL0700_i_SecondaryDirection)]; + } + } + L0704_ui_ProjectileMapX = srcMapX; /* Check impacts with projectiles on the source square */ + L0705_ui_ProjectileMapY = srcMapY; +T0266017_CheckProjectileImpacts: + L0697_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0704_ui_ProjectileMapX, L0705_ui_ProjectileMapY); + while (L0697_T_Thing != Thing::_endOfList) { + if (((L0697_T_Thing).getType() == k14_ProjectileThingType) && + (_vm->_timeline->_g370_events[(((Projectile*)_vm->_dungeonMan->_g284_thingData[k14_ProjectileThingType])[(L0697_T_Thing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[(L0697_T_Thing).getCell()]) && + _vm->_projexpl->f217_projectileHasImpactOccurred(L0702_i_ImpactType, srcMapX, srcMapY, _vm->M1_ordinalToIndex(AL0699_ui_ChampionOrCreatureOrdinal), L0697_T_Thing)) { + _vm->_projexpl->f214_projectileDeleteEvent(L0697_T_Thing); + if (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup) { + return true; + } + goto T0266017_CheckProjectileImpacts; + } + L0697_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0697_T_Thing); + } + if (L0703_B_CheckDestinationSquareProjectileImpacts) { + srcMapX |= ((L0704_ui_ProjectileMapX = destMapX) + 1) << 8; /* Check impacts with projectiles on the destination square */ + srcMapY |= (L0705_ui_ProjectileMapY = destMapY) << 8; + for (uint16 i = 0; i < 4; ++i) + L0707_auc_ChampionOrCreatureOrdinalInCell[i] = L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[i]; + L0703_B_CheckDestinationSquareProjectileImpacts = false; + goto T0266017_CheckProjectileImpacts; + } + return false; +} + +void MovesensMan::f268_addEvent(byte type, byte mapX, byte mapY, byte cell, byte effect, int32 time) { + TimelineEvent L0729_s_Event; + + + M33_setMapAndTime(L0729_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, time); + L0729_s_Event._type = type; + L0729_s_Event._priority = 0; + L0729_s_Event._B._location._mapX = mapX; + L0729_s_Event._B._location._mapY = mapY; + L0729_s_Event._C.A._cell = cell; + L0729_s_Event._C.A._effect = effect; + _vm->_timeline->f238_addEventGetEventIndex(&L0729_s_Event); +} + +int16 MovesensMan::f514_getSound(byte creatureType) { + if (_vm->_championMan->_g300_partyIsSleeping) { + return 35; + } + + switch (creatureType) { + case k3_CreatureTypeWizardEyeFlyingEye: + case k8_CreatureTypeGhostRive: + case k11_CreatureTypeBlackFlame: + case k19_CreatureTypeMaterializerZytaz: + case k23_CreatureTypeLordChaos: + case k25_CreatureTypeLordOrder: + case k26_CreatureTypeGreyLord: + return 35; + case k2_CreatureTypeGiggler: + case k9_CreatureTypeStoneGolem: + case k10_CreatureTypeMummy: + case k14_CreatureTypeVexirk: + case k16_CreatureTypeTrolinAntman: + case k22_CreatureTypeDemon: + return k24_soundMOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON; + case k0_CreatureTypeGiantScorpionScorpion: + case k4_CreatureTypePainRatHellHound: + case k5_CreatureTypeRuster: + case k6_CreatureTypeScreamer: + case k7_CreatureTypeRockpile: + case k15_CreatureTypeMagnetaWormWorm: + case k21_CreatureTypeOitu: + return k26_soundMOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU; + case k24_CreatureTypeRedDragon: + return k32_soundMOVE_RED_DRAGON; + case k12_CreatureTypeSkeleton: + return k33_soundMOVE_SKELETON; + case k18_CreatureTypeAnimatedArmourDethKnight: + return k22_soundMOVE_ANIMATED_ARMOUR_DETH_KNIGHT; + case k1_CreatureTypeSwampSlimeSlime: + case k20_CreatureTypeWaterElemental: + return k27_soundMOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL; + case k13_CreatureTypeCouatl: + case k17_CreatureTypeGiantWaspMuncher: + return k23_soundMOVE_COUATL_GIANT_WASP_MUNCHER; + } + return -1000; // if this is returned, it's an error, this should break it good +} + +int16 MovesensMan::f262_getTeleporterRotatedGroupResult(Teleporter* teleporter, Thing thing, uint16 mapIndex) { + int16 L0683_i_Rotation; + uint16 L0684_ui_GroupDirections; + uint16 L0685_ui_UpdatedGroupDirections; + Group* L0686_ps_Group; + uint16 L0687_ui_UpdatedGroupCells; + int16 L0688_i_CreatureIndex; + bool L0689_B_AbsoluteRotation; + uint16 L0690_ui_GroupCells; + int16 L0691_i_CreatureSize; + int16 L0692_i_RelativeRotation; + + L0686_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing); + L0683_i_Rotation = teleporter->getRotation(); + L0684_ui_GroupDirections = _vm->_groupMan->f147_getGroupDirections(L0686_ps_Group, mapIndex); + if (L0689_B_AbsoluteRotation = teleporter->getAbsoluteRotation()) { + L0685_ui_UpdatedGroupDirections = L0683_i_Rotation; + } else { + L0685_ui_UpdatedGroupDirections = M21_normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation); + } + if ((L0687_ui_UpdatedGroupCells = _vm->_groupMan->f145_getGroupCells(L0686_ps_Group, mapIndex)) != k255_CreatureTypeSingleCenteredCreature) { + L0690_ui_GroupCells = L0687_ui_UpdatedGroupCells; + L0691_i_CreatureSize = getFlag(g243_CreatureInfo[L0686_ps_Group->_type]._attributes, k0x0003_MaskCreatureInfo_size); + L0692_i_RelativeRotation = M21_normalizeModulo4(4 + L0685_ui_UpdatedGroupDirections - L0684_ui_GroupDirections); + for (L0688_i_CreatureIndex = 0; L0688_i_CreatureIndex <= L0686_ps_Group->getCount(); L0688_i_CreatureIndex++) { + L0685_ui_UpdatedGroupDirections = _vm->_groupMan->f178_getGroupValueUpdatedWithCreatureValue(L0685_ui_UpdatedGroupDirections, L0688_i_CreatureIndex, L0689_B_AbsoluteRotation ? L0683_i_Rotation : M21_normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation)); + if ((L0691_i_CreatureSize == k0_MaskCreatureSizeQuarter) && (L0692_i_RelativeRotation = !L0689_B_AbsoluteRotation)) { + L0692_i_RelativeRotation = L0683_i_Rotation; + } + if (L0692_i_RelativeRotation) { + L0687_ui_UpdatedGroupCells = _vm->_groupMan->f178_getGroupValueUpdatedWithCreatureValue(L0687_ui_UpdatedGroupCells, L0688_i_CreatureIndex, M21_normalizeModulo4(L0690_ui_GroupCells + L0692_i_RelativeRotation)); + } + L0684_ui_GroupDirections >>= 2; + L0690_ui_GroupCells >>= 2; + } + } + _vm->_dungeonMan->f148_setGroupDirections(L0686_ps_Group, L0685_ui_UpdatedGroupDirections, mapIndex); + _vm->_dungeonMan->f146_setGroupCells(L0686_ps_Group, L0687_ui_UpdatedGroupCells, mapIndex); + if ((mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0686_ps_Group->setBehaviour(k6_behavior_ATTACK))) { + return L0686_ps_Group->getActiveGroupIndex() + 2; + } + return 1; +} + +Thing MovesensMan::f263_getTeleporterRotatedProjectileThing(Teleporter* teleporter, Thing projectileThing) { + int16 L0693_i_UpdatedDirection; + int16 L0694_i_Rotation; + + + L0693_i_UpdatedDirection = _g400_moveResultDir; + L0694_i_Rotation = teleporter->getRotation(); + if (teleporter->getAbsoluteRotation()) { + L0693_i_UpdatedDirection = L0694_i_Rotation; + } else { + L0693_i_UpdatedDirection = M21_normalizeModulo4(L0693_i_UpdatedDirection + L0694_i_Rotation); + projectileThing = M15_thingWithNewCell(projectileThing, M21_normalizeModulo4((projectileThing).getCell() + L0694_i_Rotation)); + } + _g400_moveResultDir = L0693_i_UpdatedDirection; + return projectileThing; +} + +void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing thing, bool partySquare, bool addThing) { + Thing L0766_T_Thing; + int16 L0767_i_ThingType; + bool L0768_B_TriggerSensor; + Sensor* L0769_ps_Sensor; + uint16 L0770_ui_SensorTriggeredCell; + uint16 L0771_ui_ThingType; + bool L0772_B_SquareContainsObject; + bool L0773_B_SquareContainsGroup; + int16 L0774_i_ObjectType; + bool L0775_B_SquareContainsThingOfSameType; + bool L0776_B_SquareContainsThingOfDifferentType; + uint16 L0777_ui_Square; + int16 L0778_i_Effect; + int16 L0779_i_SensorData; + + + if (thing != Thing::_party) { + L0767_i_ThingType = (thing).getType(); + L0774_i_ObjectType = _vm->_objectMan->f32_getObjectType(thing); + } else { + L0767_i_ThingType = kM1_PartyThingType; + L0774_i_ObjectType = kM1_IconIndiceNone; + } + if ((!addThing) && (L0767_i_ThingType != kM1_PartyThingType)) { + _vm->_dungeonMan->f164_unlinkThingFromList(thing, Thing(0), mapX, mapY); + } + if (Square(L0777_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType() == k0_ElementTypeWall) { + L0770_ui_SensorTriggeredCell = (thing).getCell(); + } else { + L0770_ui_SensorTriggeredCell = (uint16)kM1_CellAny; // this will wrap around + } + L0772_B_SquareContainsObject = L0773_B_SquareContainsGroup = L0775_B_SquareContainsThingOfSameType = L0776_B_SquareContainsThingOfDifferentType = false; + L0766_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY); + if (L0770_ui_SensorTriggeredCell == kM1_CellAny) { + while (L0766_T_Thing != Thing::_endOfList) { + if ((L0771_ui_ThingType = (L0766_T_Thing).getType()) == k4_GroupThingType) { + L0773_B_SquareContainsGroup = true; + } else { + if ((L0771_ui_ThingType == k2_TextstringType) && (L0767_i_ThingType == kM1_PartyThingType) && addThing && !partySquare) { + _vm->_dungeonMan->f168_decodeText(_vm->_g353_stringBuildBuffer, L0766_T_Thing, k1_TextTypeMessage); + _vm->_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, _vm->_g353_stringBuildBuffer); + } else { + if ((L0771_ui_ThingType > k4_GroupThingType) && (L0771_ui_ThingType < k14_ProjectileThingType)) { + L0772_B_SquareContainsObject = true; + L0775_B_SquareContainsThingOfSameType |= (_vm->_objectMan->f32_getObjectType(L0766_T_Thing) == L0774_i_ObjectType); + L0776_B_SquareContainsThingOfDifferentType |= (_vm->_objectMan->f32_getObjectType(L0766_T_Thing) != L0774_i_ObjectType); + } + } + } + L0766_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0766_T_Thing); + } + } else { + while (L0766_T_Thing != Thing::_endOfList) { + if ((L0770_ui_SensorTriggeredCell == (L0766_T_Thing).getCell()) && ((L0766_T_Thing).getType() > k4_GroupThingType)) { + L0772_B_SquareContainsObject = true; + L0775_B_SquareContainsThingOfSameType |= (_vm->_objectMan->f32_getObjectType(L0766_T_Thing) == L0774_i_ObjectType); + L0776_B_SquareContainsThingOfDifferentType |= (_vm->_objectMan->f32_getObjectType(L0766_T_Thing) != L0774_i_ObjectType); + } + L0766_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0766_T_Thing); + } + } + if (addThing && (L0767_i_ThingType != kM1_PartyThingType)) { + _vm->_dungeonMan->f163_linkThingToList(thing, Thing(0), mapX, mapY); + } + L0766_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY); + while (L0766_T_Thing != Thing::_endOfList) { + if ((L0771_ui_ThingType = (L0766_T_Thing).getType()) == k3_SensorThingType) { + L0769_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0766_T_Thing); + if ((L0769_ps_Sensor)->getType() == k0_SensorDisabled) + goto T0276079; + L0779_i_SensorData = L0769_ps_Sensor->getData(); + L0768_B_TriggerSensor = addThing; + if (L0770_ui_SensorTriggeredCell == kM1_CellAny) { + switch (L0769_ps_Sensor->getType()) { + case k1_SensorFloorTheronPartyCreatureObj: + if (partySquare || L0772_B_SquareContainsObject || L0773_B_SquareContainsGroup) /* BUG0_30 A floor sensor is not triggered when you put an object on the floor if a levitating creature is present on the same square. The condition to determine if the sensor should be triggered checks if there is a creature on the square but does not check whether the creature is levitating. While it is normal not to trigger the sensor if there is a non levitating creature on the square (because it was already triggered by the creature itself), a levitating creature should not prevent triggering the sensor with an object. */ + goto T0276079; + break; + case k2_SensorFloorTheronPartyCreature: + if ((L0767_i_ThingType > k4_GroupThingType) || partySquare || L0773_B_SquareContainsGroup) + goto T0276079; + break; + case k3_SensorFloorParty: + if ((L0767_i_ThingType != kM1_PartyThingType) || (_vm->_championMan->_g305_partyChampionCount == 0)) + goto T0276079; + if (L0779_i_SensorData == 0) { + if (partySquare) + goto T0276079; + } else { + if (!addThing) { + L0768_B_TriggerSensor = false; + } else { + L0768_B_TriggerSensor = (L0779_i_SensorData == _vm->M0_indexToOrdinal(_vm->_dungeonMan->_g308_partyDir)); + } + } + break; + case k4_SensorFloorObj: + if ((L0779_i_SensorData != _vm->_objectMan->f32_getObjectType(thing)) || L0775_B_SquareContainsThingOfSameType) + goto T0276079; + break; + case k5_SensorFloorPartyOnStairs: + // Strangerke: Only present in v2.1, but it fixes a bug so we'll keep it. +#ifdef COMPILE52_CSB21EN /* CHANGE8_05_FIX The wrong variable is replaced by the correct variable in the condition. The test should not be on L0771_ui_ThingType but on L0767_i_ThingType */ + if ((L0767_i_ThingType != kM1_PartyThingType) || (M34_SQUARE_TYPE(L0777_ui_Square) != k3_ElementTypeStairs)) +#endif + goto T0276079; + break; + case k6_SensorFloorGroupGenerator: + goto T0276079; + case k7_SensorFloorCreature: + if ((L0767_i_ThingType > k4_GroupThingType) || (L0767_i_ThingType == kM1_PartyThingType) || L0773_B_SquareContainsGroup) + goto T0276079; + break; + case k8_SensorFloorPartyPossession: + if (L0767_i_ThingType != kM1_PartyThingType) + goto T0276079; + L0768_B_TriggerSensor = f274_sensorIsObjcetInPartyPossession(L0779_i_SensorData); + break; + case k9_SensorFloorVersionChecker: + if ((L0767_i_ThingType != kM1_PartyThingType) || !addThing || partySquare) + goto T0276079; + // Strangerke: 20 is a harcoded version of the game. later version uses 21. Not present in the original dungeons anyway. + L0768_B_TriggerSensor = (L0779_i_SensorData <= 20); + break; + default: + goto T0276079; + } + } else { + if (L0770_ui_SensorTriggeredCell != (L0766_T_Thing).getCell()) + goto T0276079; + switch (L0769_ps_Sensor->getType()) { + case k1_SensorWallOrnClick: + if (L0772_B_SquareContainsObject) + goto T0276079; + break; + case k2_SensorWallOrnClickWithAnyObj: + if (L0775_B_SquareContainsThingOfSameType || (L0769_ps_Sensor->getData() != _vm->_objectMan->f32_getObjectType(thing))) + goto T0276079; + break; + case k3_SensorWallOrnClickWithSpecObj: + if (L0776_B_SquareContainsThingOfDifferentType || (L0769_ps_Sensor->getData() == _vm->_objectMan->f32_getObjectType(thing))) + goto T0276079; + break; + default: + goto T0276079; + } + } + L0768_B_TriggerSensor ^= L0769_ps_Sensor->getRevertEffectA(); + if ((L0778_i_Effect = L0769_ps_Sensor->getEffectA()) == k3_SensorEffHold) { + L0778_i_Effect = L0768_B_TriggerSensor ? k0_SensorEffSet : k1_SensorEffClear; + } else { + if (!L0768_B_TriggerSensor) + goto T0276079; + } + if (L0769_ps_Sensor->getAudibleA()) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + f272_sensorTriggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around + goto T0276079; + } + if (L0771_ui_ThingType >= k4_GroupThingType) + break; +T0276079: + L0766_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0766_T_Thing); + } + f271_processRotationEffect(); +} + +bool MovesensMan::f274_sensorIsObjcetInPartyPossession(int16 objectType) { + int16 L0742_i_ChampionIndex; + uint16 L0743_ui_SlotIndex = 0; + Thing L0744_T_Thing = Thing::_none; + Champion* L0745_ps_Champion; + Thing* L0746_pT_Thing = nullptr; + int16 L0747_i_ObjectType; + bool L0748_B_LeaderHandObjectProcessed; + Container* L0749_ps_Container; + + + L0748_B_LeaderHandObjectProcessed = false; + for (L0742_i_ChampionIndex = k0_ChampionFirst, L0745_ps_Champion = _vm->_championMan->_gK71_champions; L0742_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0742_i_ChampionIndex++, L0745_ps_Champion++) { + if (L0745_ps_Champion->_currHealth) { + L0746_pT_Thing = L0745_ps_Champion->_slots; + for (L0743_ui_SlotIndex = k0_ChampionSlotReadyHand; (L0743_ui_SlotIndex < k30_ChampionSlotChest_1) && !L0748_B_LeaderHandObjectProcessed; L0743_ui_SlotIndex++) { + L0744_T_Thing = *L0746_pT_Thing++; +T0274003: + if ((L0747_i_ObjectType = _vm->_objectMan->f32_getObjectType(L0744_T_Thing)) == objectType) { + return true; + } + if (L0747_i_ObjectType == k144_IconIndiceContainerChestClosed) { + L0749_ps_Container = (Container*)_vm->_dungeonMan->f156_getThingData(L0744_T_Thing); + L0744_T_Thing = L0749_ps_Container->getSlot(); + while (L0744_T_Thing != Thing::_endOfList) { + if (_vm->_objectMan->f32_getObjectType(L0744_T_Thing) == objectType) { + return true; + } + L0744_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0744_T_Thing); + } + } + } + } + } + if (!L0748_B_LeaderHandObjectProcessed) { + L0748_B_LeaderHandObjectProcessed = true; + L0744_T_Thing = _vm->_championMan->_g414_leaderHandObject; + goto T0274003; + } + return false; +} + +void MovesensMan::f272_sensorTriggerEffect(Sensor* sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell) { + byte g59_squareTypeToEventType[7] = { // @ G0059_auc_Graphic562_SquareTypeToEventType + k6_TMEventTypeWall, + k5_TMEventTypeCorridor, + k9_TMEventTypePit, + k0_TMEventTypeNone, + k10_TMEventTypeDoor, + k8_TMEventTypeTeleporter, + k7_TMEventTypeFakeWall}; /* 1 byte of padding inserted by compiler */ + + int16 L0736_i_TargetMapX; + int16 L0737_i_TargetMapY; + register long L0738_l_Time; + uint16 L0739_ui_SquareType; + uint16 L0740_ui_TargetCell; + + + if (sensor->getOnlyOnce()) { + sensor->setTypeDisabled(); + } + L0738_l_Time = _vm->_g313_gameTime + sensor->getValue(); + if (sensor->getLocalEffect()) { + f270_sensorTriggetLocalEffect(sensor->M49_localEffect(), mapX, mapY, cell); + } else { + L0736_i_TargetMapX = sensor->getTargetMapX(); + L0737_i_TargetMapY = sensor->getTargetMapY(); + L0739_ui_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[L0736_i_TargetMapX][L0737_i_TargetMapY]).getType(); + if (L0739_ui_SquareType == k0_ElementTypeWall) { + L0740_ui_TargetCell = sensor->getTargetCell(); + } else { + L0740_ui_TargetCell = k0_CellNorthWest; + } + f268_addEvent(g59_squareTypeToEventType[L0739_ui_SquareType], L0736_i_TargetMapX, L0737_i_TargetMapY, L0740_ui_TargetCell, effect, L0738_l_Time); + } +} + +void MovesensMan::f270_sensorTriggetLocalEffect(int16 localEffect, int16 effX, int16 effY, int16 effCell) { + if (localEffect == k10_SensorEffAddExp) { + f269_sensorAddSkillExperience(k8_ChampionSkillSteal, 300, localEffect != kM1_CellAny); + return; } - warning("MISSING CODE: F0271_SENSOR_ProcessRotationEffect"); - return atLeastOneSensorWasTriggered; + _g403_sensorRotationEffect = localEffect; + _g404_sensorRotationEffMapX = effX; + _g405_sensorRotationEffMapY = effY; + _g406_sensorRotationEffCell = effCell; } +void MovesensMan::f269_sensorAddSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly) { + int16 L0730_i_ChampionIndex; + Champion* L0731_ps_Champion; + + if (leaderOnly) { + if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) { + _vm->_championMan->f304_addSkillExperience(_vm->_championMan->_g411_leaderIndex, skillIndex, exp); + } + } else { + exp /= _vm->_championMan->_g305_partyChampionCount; + for (L0730_i_ChampionIndex = k0_ChampionFirst, L0731_ps_Champion = _vm->_championMan->_gK71_champions; L0730_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0730_i_ChampionIndex++, L0731_ps_Champion++) { + if (L0731_ps_Champion->_currHealth) { + _vm->_championMan->f304_addSkillExperience(L0730_i_ChampionIndex, skillIndex, exp); + } + } + } +} + +void MovesensMan::f271_processRotationEffect() { + Thing L0732_T_FirstSensorThing; + Thing L0733_T_LastSensorThing; + Sensor* L0734_ps_FirstSensor; + Sensor* L0735_ps_LastSensor; + + + if (_g403_sensorRotationEffect == kM1_SensorEffNone) { + return; + } + switch (_g403_sensorRotationEffect) { + case k1_SensorEffClear: + case k2_SensorEffToggle: + L0732_T_FirstSensorThing = _vm->_dungeonMan->f161_getSquareFirstThing(_g404_sensorRotationEffMapX, _g405_sensorRotationEffMapY); + while (((L0732_T_FirstSensorThing).getType() != k3_SensorThingType) || ((_g406_sensorRotationEffCell != kM1_CellAny) && ((L0732_T_FirstSensorThing).getCell() != _g406_sensorRotationEffCell))) { + L0732_T_FirstSensorThing = _vm->_dungeonMan->f159_getNextThing(L0732_T_FirstSensorThing); + } + L0734_ps_FirstSensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0732_T_FirstSensorThing); + L0733_T_LastSensorThing = L0734_ps_FirstSensor->getNextThing(); + while ((L0733_T_LastSensorThing != Thing::_endOfList) && (((L0733_T_LastSensorThing).getType() != k3_SensorThingType) || ((_g406_sensorRotationEffCell != kM1_CellAny) && ((L0733_T_LastSensorThing).getCell() != _g406_sensorRotationEffCell)))) { + L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing); + } + if (L0733_T_LastSensorThing == Thing::_endOfList) + break; + _vm->_dungeonMan->f164_unlinkThingFromList(L0732_T_FirstSensorThing, Thing(0), _g404_sensorRotationEffMapX, _g405_sensorRotationEffMapY); + L0735_ps_LastSensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0733_T_LastSensorThing); + L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing); + while (((L0733_T_LastSensorThing != Thing::_endOfList) && ((L0733_T_LastSensorThing).getType() == k3_SensorThingType))) { + if ((_g406_sensorRotationEffCell == kM1_CellAny) || ((L0733_T_LastSensorThing).getCell() == _g406_sensorRotationEffCell)) { + L0735_ps_LastSensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0733_T_LastSensorThing); + } + L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing); + } + L0734_ps_FirstSensor->setNextThing(L0735_ps_LastSensor->getNextThing()); + L0735_ps_LastSensor->setNextThing(L0732_T_FirstSensorThing); + } + _g403_sensorRotationEffect = kM1_SensorEffNone; +} + +void MovesensMan::f265_createEvent60to61_moveGroup(Thing groupThing, int16 mapX, int16 mapY, int16 mapIndex, bool audible) { + TimelineEvent L0696_s_Event; + + M33_setMapAndTime(L0696_s_Event._mapTime, mapIndex, _vm->_g313_gameTime + 5); + L0696_s_Event._type = audible ? k61_TMEventTypeMoveGroupAudible : k60_TMEventTypeMoveGroupSilent; + L0696_s_Event._priority = 0; + L0696_s_Event._B._location._mapX = mapX; + L0696_s_Event._B._location._mapY = mapY; + L0696_s_Event._C._slot = groupThing; + _vm->_timeline->f238_addEventGetEventIndex(&L0696_s_Event); +} + +Thing MovesensMan::f273_sensorGetObjectOfTypeInCell(int16 mapX, int16 mapY, int16 cell, int16 objectType) { + Thing L0741_T_Thing; + + + L0741_T_Thing = _vm->_dungeonMan->f162_getSquareFirstObject(mapX, mapY); + while (L0741_T_Thing != Thing::_endOfList) { + if (_vm->_objectMan->f32_getObjectType(L0741_T_Thing) == objectType) { + if ((cell == kM1_CellAny) || ((L0741_T_Thing.getCell()) == cell)) { + return L0741_T_Thing; + } + } + L0741_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0741_T_Thing); + } + return Thing::_none; +} } diff --git a/engines/dm/movesens.h b/engines/dm/movesens.h index 6a8a53ac96..79a1fa9bf1 100644 --- a/engines/dm/movesens.h +++ b/engines/dm/movesens.h @@ -32,12 +32,43 @@ #include "dm.h" namespace DM { + class Sensor; + class Teleporter; -class MovesensMan { + class MovesensMan { DMEngine *_vm; public: + int16 _g397_moveResultMapX; // @ G0397_i_MoveResultMapX + int16 _g398_moveResultMapY; // @ G0398_i_MoveResultMapY + uint16 _g399_moveResultMapIndex; // @ G0399_ui_MoveResultMapIndex + int16 _g400_moveResultDir; // @ G0400_i_MoveResultDirection + uint16 _g401_moveResultCell; // @ G0401_ui_MoveResultCell + bool _g402_useRopeToClimbDownPit; // @ G0402_B_UseRopeToClimbDownPit + int16 _g403_sensorRotationEffect; // @ G0403_i_SensorRotationEffect + int16 _g404_sensorRotationEffMapX; // @ G0404_i_SensorRotationEffectMapX + int16 _g405_sensorRotationEffMapY; // @ G0405_i_SensorRotationEffectMapY + int16 _g406_sensorRotationEffCell; // @ G0406_i_SensorRotationEffectCell explicit MovesensMan(DMEngine *vm); bool f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam); // @ F0275_SENSOR_IsTriggeredByClickOnWall + bool f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destMapX, int16 destMapY); // @ F0267_MOVE_GetMoveResult_CPSCE + bool f264_isLevitating(Thing thing); // @ F0264_MOVE_IsLevitating + bool f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY, Thing thing); // @ F0266_MOVE_IsKilledByProjectileImpact + void f268_addEvent(byte type, byte mapX, byte mapY, byte cell, byte effect, int32 time); // @ F0268_SENSOR_AddEvent + int16 f514_getSound(byte creatureType); // @ F0514_MOVE_GetSound + int16 f262_getTeleporterRotatedGroupResult(Teleporter *teleporter, Thing thing, uint16 mapIndex);// @ F0262_MOVE_GetTeleporterRotatedGroupResult + Thing f263_getTeleporterRotatedProjectileThing(Teleporter *teleporter, Thing projectileThing); // @ F0263_MOVE_GetTeleporterRotatedProjectileThing + void f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing thing, bool partySquare, bool addThing);// @ F0276_SENSOR_ProcessThingAdditionOrRemoval + bool f274_sensorIsObjcetInPartyPossession(int16 objectType); // @ F0274_SENSOR_IsObjectInPartyPossession + void f272_sensorTriggerEffect(Sensor *sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell); // @ F0272_SENSOR_TriggerEffect + void f270_sensorTriggetLocalEffect(int16 localEffect, int16 effX, int16 effY, int16 effCell); // @ F0270_SENSOR_TriggerLocalEffect + void f269_sensorAddSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly); // @ F0269_SENSOR_AddSkillExperience + void f271_processRotationEffect();// @ F0271_SENSOR_ProcessRotationEffect + void f265_createEvent60to61_moveGroup(Thing groupThing, int16 mapX, int16 mapY, int16 mapIndex, bool audible); // @ F0265_MOVE_CreateEvent60To61_MoveGroup + Thing f273_sensorGetObjectOfTypeInCell(int16 mapX, int16 mapY, int16 cell, int16 objectType); // @ F0273_SENSOR_GetObjectOfTypeInCell + + + + }; } diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index ff7ff4dd9d..157cfd8ad8 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -252,4 +252,10 @@ void ObjectMan::f34_drawLeaderObjectName(Thing thing) { IconIndice ObjectMan::f39_getIconIndexInSlotBox(uint16 slotBoxIndex) { return (IconIndice)_g30_slotBoxes[slotBoxIndex]._iconIndex; } + +void ObjectMan::f35_clearLeaderObjectName() { + static Box g28_BoxLeaderHandObjectName(233, 319, 33, 38); // @ G0028_s_Graphic562_Box_LeaderHandObjectName + _vm->_displayMan->D24_fillScreenBox(g28_BoxLeaderHandObjectName, k0_ColorBlack); +} + } diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index b01957da8a..3f90f805d4 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -64,6 +64,7 @@ public: void f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex); // @ F0038_OBJECT_DrawIconInSlotBox void f34_drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName IconIndice f39_getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox + void f35_clearLeaderObjectName(); // @ F0035_OBJECT_ClearLeaderHandObjectName }; diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp new file mode 100644 index 0000000000..95d40bbaea --- /dev/null +++ b/engines/dm/projexpl.cpp @@ -0,0 +1,418 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + + +#include "projexpl.h" +#include "dungeonman.h" +#include "timeline.h" +#include "group.h" +#include "objectman.h" +#include "movesens.h" + +namespace DM { + +ProjExpl::ProjExpl(DMEngine* vm) : _vm(vm) { + _g361_lastCreatureAttackTime = -200; +} + +void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, direction dir, byte kineticEnergy, byte attack, byte stepEnergy) { + Thing L0466_T_ProjectileThing; + Projectile* L0467_ps_Projectile; + TimelineEvent L0468_s_Event; + + + if ((L0466_T_ProjectileThing = _vm->_dungeonMan->f166_getUnusedThing(k14_ProjectileThingType)) == Thing::_none) { /* BUG0_16 If the game cannot create a projectile thing because it has run out of such things (60 maximum) then the object being thrown/shot/launched is orphaned. If the game has run out of projectile things it will try to remove a projectile from elsewhere in the dungeon, except in an area of 11x11 squares centered around the party (to make sure the player cannot actually see the thing disappear on screen) */ + return; + } + L0466_T_ProjectileThing = M15_thingWithNewCell(L0466_T_ProjectileThing, cell); + L0467_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(L0466_T_ProjectileThing); + L0467_ps_Projectile->_slot = thing; + L0467_ps_Projectile->_kineticEnergy = MIN((int16)kineticEnergy, (int16)255); + L0467_ps_Projectile->_attack = attack; + _vm->_dungeonMan->f163_linkThingToList(L0466_T_ProjectileThing, Thing(0), mapX, mapY); /* Projectiles are added on the square and not 'moved' onto the square. In the case of a projectile launcher sensor, this means that the new projectile traverses the square in front of the launcher without any trouble: there is no impact if it is a wall, the projectile direction is not changed if it is a teleporter. Impacts with creatures and champions are still processed */ + M33_setMapAndTime(L0468_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + 1); + if (_g365_createLanucherProjectile) { + L0468_s_Event._type = k49_TMEventTypeMoveProjectile; /* Launcher projectiles can impact immediately */ + } else { + L0468_s_Event._type = k48_TMEventTypeMoveProjectileIgnoreImpacts; /* Projectiles created by champions or creatures ignore impacts on their first movement */ + } + L0468_s_Event._priority = 0; + L0468_s_Event._B._slot = L0466_T_ProjectileThing; + L0468_s_Event._C._projectile.setMapX(mapX); + L0468_s_Event._C._projectile.setMapY(mapY); + L0468_s_Event._C._projectile.setStepEnergy(stepEnergy); + L0468_s_Event._C._projectile.setDir(dir); + L0467_ps_Projectile->_eventIndex = _vm->_timeline->f238_addEventGetEventIndex(&L0468_s_Event); +} + +bool ProjExpl::f217_projectileHasImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo, int16 cell, Thing projectileThing) { +#define AP0454_i_ProjectileTargetMapX mapXCombo +#define AP0455_i_ProjectileTargetMapY mapYCombo +#define AP0456_i_ChampionIndex cell + Projectile* L0490_ps_Projectile; + Group* L0491_ps_Group; + Thing L0486_T_ProjectileAssociatedThing; + int16 L0487_i_Multiple; +#define AL0487_i_DoorState L0487_i_Multiple +#define AL0487_i_IconIndex L0487_i_Multiple +#define AL0487_i_Outcome L0487_i_Multiple +#define AL0487_i_WeaponType L0487_i_Multiple + int16 L0488_i_Attack = 0; + Potion* L0492_ps_Potion = nullptr; + CreatureInfo* L0493_ps_CreatureInfo; + Door* L0494_ps_Door; + Weapon* L0495_ps_Weapon; + uint16* L0496_pui_CreatureHealth; + Thing* L0497_pT_GroupSlot; + Thing L0498_T_ExplosionThing; + int16 L0499_i_ProjectileMapX; + int16 L0500_i_ProjectileMapY; + int16 L0501_i_MapXCombo; + int16 L0502_i_MapYCombo; + byte L0503_uc_Square; + bool L0505_B_CreateExplosionOnImpact; + int16 L0489_i_ChampionAttack; + uint16 L0507_ui_Multiple; +#define AL0507_ui_ExplosionAttack L0507_ui_Multiple +#define AL0507_ui_SoundIndex L0507_ui_Multiple + int16 L0508_i_PotionPower = 0; + bool L0509_B_RemovePotion; + int16 L0510_i_ProjectileAssociatedThingType; + uint16 L0511_ui_CreatureType; + uint16 L0512_ui_CreatureIndex; + + L0490_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(Thing(projectileThing)); + L0501_i_MapXCombo = mapXCombo; + L0502_i_MapYCombo = mapYCombo; + L0509_B_RemovePotion = false; + _g364_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup; + if ((L0510_i_ProjectileAssociatedThingType = (L0486_T_ProjectileAssociatedThing = L0490_ps_Projectile->_slot).getType()) == k8_PotionThingType) { + L0491_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0486_T_ProjectileAssociatedThing); + switch (((Potion*)L0491_ps_Group)->getType()) { + case k3_PotionTypeVen: + L0498_T_ExplosionThing = Thing::_explPoisonCloud; + goto T0217004; + case k19_PotionTypeFulBomb: + L0498_T_ExplosionThing = Thing::_explFireBall; +T0217004: + L0509_B_RemovePotion = true; + L0508_i_PotionPower = ((Potion*)L0491_ps_Group)->getPower(); + L0492_ps_Potion = (Potion*)L0491_ps_Group; + } + } + L0505_B_CreateExplosionOnImpact = (L0510_i_ProjectileAssociatedThingType == k15_ExplosionThingType) && (L0486_T_ProjectileAssociatedThing != Thing::_explSlime) && (L0486_T_ProjectileAssociatedThing != Thing::_explPoisonBolt); + L0497_pT_GroupSlot = NULL; + L0489_i_ChampionAttack = 0; + if (mapXCombo <= 255) { + L0499_i_ProjectileMapX = mapXCombo; + L0500_i_ProjectileMapY = mapYCombo; + } else { + L0499_i_ProjectileMapX = (mapXCombo >> 8) - 1; + L0500_i_ProjectileMapY = (mapYCombo >> 8); + AP0454_i_ProjectileTargetMapX &= 0x00FF; + AP0455_i_ProjectileTargetMapY &= 0x00FF; + } + switch (impactType) { + case k4_DoorElemType: + AL0487_i_DoorState = Square(L0503_uc_Square = _vm->_dungeonMan->_g271_currMapData[AP0454_i_ProjectileTargetMapX][AP0455_i_ProjectileTargetMapY]).getDoorState(); + L0494_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY); + if ((AL0487_i_DoorState != k5_doorState_DESTROYED) && (L0486_T_ProjectileAssociatedThing == Thing::_explOpenDoor)) { + if (L0494_ps_Door->hasButton()) { + _vm->_movsens->f268_addEvent(k10_TMEventTypeDoor, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1); + } + break; + } + if ((AL0487_i_DoorState == k5_doorState_DESTROYED) || + (AL0487_i_DoorState <= k1_doorState_FOURTH) || + (getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[L0494_ps_Door->getType()]._attributes, k0x0002_MaskDoorInfo_ProjectilesCanPassThrough) && + ((L0510_i_ProjectileAssociatedThingType == k15_ExplosionThingType) ? + (L0486_T_ProjectileAssociatedThing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) : + ((L0490_ps_Projectile->_attack > _vm->getRandomNumber(128)) && + getFlag(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0486_T_ProjectileAssociatedThing)].getAllowedSlots(), k0x0100_ObjectAllowedSlotPouchPassAndThroughDoors) + && ((L0510_i_ProjectileAssociatedThingType != k10_JunkThingType) || + ((AL0487_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0486_T_ProjectileAssociatedThing)) < 0) || + (!((AL0487_i_IconIndex >= k176_IconIndiceJunkIronKey) && (AL0487_i_IconIndex <= k191_IconIndiceJunkMasterKey)))) + )))) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */ + return false; + } + L0488_i_Attack = f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing) + 1; + _vm->_groupMan->f232_groupIsDoorDestoryedByAttack(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->getRandomNumber(L0488_i_Attack), false, 0); + break; + case kM2_ChampionElemType: + if ((AP0456_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(cell)) < 0) { + return false; + } + L0489_i_ChampionAttack = L0488_i_Attack = f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing); + break; + case kM1_CreatureElemType: + L0491_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY)); + if (!(L0512_ui_CreatureIndex = _vm->_groupMan->f176_getCreatureOrdinalInCell(L0491_ps_Group, cell))) { + return false; + } + L0512_ui_CreatureIndex--; + L0493_ps_CreatureInfo = &g243_CreatureInfo[L0511_ui_CreatureType = L0491_ps_Group->_type]; + if ((L0486_T_ProjectileAssociatedThing == Thing::_explFireBall) && (L0511_ui_CreatureType == k11_CreatureTypeBlackFlame)) { + L0496_pui_CreatureHealth = &L0491_ps_Group->_health[L0512_ui_CreatureIndex]; + *L0496_pui_CreatureHealth = MIN(1000, *L0496_pui_CreatureHealth + f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing)); + goto T0217044; + } + if (getFlag(L0493_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) && (L0486_T_ProjectileAssociatedThing != Thing::_explHarmNonMaterial)) { + return false; + } + if (L0488_i_Attack = (uint16)((unsigned long)f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing) << 6) / L0493_ps_CreatureInfo->_defense) { + if ((AL0487_i_Outcome = _vm->_groupMan->f190_groupGetDamageCreatureOutcome(L0491_ps_Group, L0512_ui_CreatureIndex, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, L0488_i_Attack + _vm->_groupMan->f192_groupGetResistanceAdjustedPoisonAttack(L0511_ui_CreatureType, _g366_projectilePoisonAttack), true)) != k0_outcomeKilledNoCreaturesInGroup) { + _vm->_groupMan->f209_processEvents29to41(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, kM2_TMEventTypeCreateReactionEvent30HitByProjectile, 0); + } + _g364_creatureDamageOutcome = AL0487_i_Outcome; + if (!L0505_B_CreateExplosionOnImpact && + (AL0487_i_Outcome == k0_outcomeKilledNoCreaturesInGroup) && + (L0510_i_ProjectileAssociatedThingType == k5_WeaponThingType) && + getFlag(L0493_ps_CreatureInfo->_attributes, k0x0400_MaskCreatureInfo_keepThrownSharpWeapon)) { + L0495_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0486_T_ProjectileAssociatedThing); + AL0487_i_WeaponType = L0495_ps_Weapon->getType(); + if ((AL0487_i_WeaponType == k8_WeaponTypeDagger) || (AL0487_i_WeaponType == k27_WeaponTypeArrow) || (AL0487_i_WeaponType == k28_WeaponTypeSlayer) || (AL0487_i_WeaponType == k31_WeaponTypePoisonDart) || (AL0487_i_WeaponType == k32_WeaponTypeThrowingStar)) { + L0497_pT_GroupSlot = &L0491_ps_Group->_slot; + } + } + } + } + if (L0489_i_ChampionAttack && _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(AP0456_i_ChampionIndex, L0488_i_Attack, k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso, _g367_projectileAttackType) && _g366_projectilePoisonAttack && _vm->getRandomNumber(2)) { + _vm->_championMan->f322_championPoison(AP0456_i_ChampionIndex, _g366_projectilePoisonAttack); + } + if (L0505_B_CreateExplosionOnImpact || L0509_B_RemovePotion + ) { + if (L0509_B_RemovePotion) { + L0486_T_ProjectileAssociatedThing = L0498_T_ExplosionThing; + AL0507_ui_ExplosionAttack = L0508_i_PotionPower; + } else { + AL0507_ui_ExplosionAttack = L0490_ps_Projectile->_kineticEnergy; + } + if ((L0486_T_ProjectileAssociatedThing == Thing::_explLightningBolt) && !(AL0507_ui_ExplosionAttack >>= 1)) + goto T0217044; + f213_explosionCreate(L0486_T_ProjectileAssociatedThing, AL0507_ui_ExplosionAttack, L0501_i_MapXCombo, L0502_i_MapYCombo, (L0486_T_ProjectileAssociatedThing == Thing::_explPoisonCloud) ? k255_CreatureTypeSingleCenteredCreature : cell); + } else { + if ((L0486_T_ProjectileAssociatedThing).getType() == k5_WeaponThingType) { + AL0507_ui_SoundIndex = k00_soundMETALLIC_THUD; + } else { + if (L0486_T_ProjectileAssociatedThing == Thing::_explPoisonBolt) { + AL0507_ui_SoundIndex = k13_soundSPELL; + } else { + AL0507_ui_SoundIndex = k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM; + } + } + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } +T0217044: + if (L0509_B_RemovePotion) { + L0492_ps_Potion->_nextThing = Thing::_none; + L0490_ps_Projectile->_slot = L0498_T_ExplosionThing; + } + _vm->_dungeonMan->f164_unlinkThingFromList(projectileThing, Thing(0), L0499_i_ProjectileMapX, L0500_i_ProjectileMapY); + f215_projectileDelete(projectileThing, L0497_pT_GroupSlot, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY); + return true; +} + +uint16 ProjExpl::f216_projectileGetImpactAttack(Projectile* projectile, Thing thing) { + WeaponInfo* L0485_ps_WeaponInfo; + uint16 L0483_ui_Multiple; +#define AL0483_ui_ThingType L0483_ui_Multiple +#define AL0483_ui_Attack L0483_ui_Multiple + uint16 L0484_ui_KineticEnergy; + + + _g366_projectilePoisonAttack = 0; + _g367_projectileAttackType = k3_attackType_BLUNT; + + L0484_ui_KineticEnergy = projectile->_kineticEnergy; + if ((AL0483_ui_ThingType = (thing).getType()) != k15_ExplosionThingType) { + if (AL0483_ui_ThingType == k5_WeaponThingType) { + L0485_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(thing); + AL0483_ui_Attack = L0485_ps_WeaponInfo->_kineticEnergy; + _g367_projectileAttackType = k3_attackType_BLUNT; + } else { + AL0483_ui_Attack = _vm->getRandomNumber(4); + } + AL0483_ui_Attack += _vm->_dungeonMan->f140_getObjectWeight(thing) >> 1; + } else { + if (thing == Thing::_explSlime) { + AL0483_ui_Attack = _vm->getRandomNumber(16); + _g366_projectilePoisonAttack = AL0483_ui_Attack + 10; + AL0483_ui_Attack += _vm->getRandomNumber(32); + } else { + if (thing.toUint16() >= Thing::_explHarmNonMaterial.toUint16()) { + _g367_projectileAttackType = k5_attackType_MAGIC; + if (thing == Thing::_explPoisonBolt) { + _g366_projectilePoisonAttack = L0484_ui_KineticEnergy; + return 1; + } + return 0; + } + _g367_projectileAttackType = k1_attackType_FIRE; + AL0483_ui_Attack = _vm->getRandomNumber(16) + _vm->getRandomNumber(16) + 10; + if (thing == Thing::_explLightningBolt) { + _g367_projectileAttackType = k7_attackType_LIGHTNING; + AL0483_ui_Attack *= 5; + } + } + } + AL0483_ui_Attack = ((AL0483_ui_Attack + L0484_ui_KineticEnergy) >> 4) + 1; + AL0483_ui_Attack += _vm->getRandomNumber((AL0483_ui_Attack >> 1) + 1) + _vm->getRandomNumber(4); + AL0483_ui_Attack = MAX(AL0483_ui_Attack >> 1, AL0483_ui_Attack - (32 - (projectile->_attack >> 3))); + return AL0483_ui_Attack; +} + +void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXCombo, uint16 mapYCombo, uint16 cell) { +#define AP0443_ui_ProjectileMapX mapXCombo +#define AP0444_ui_ProjectileMapY mapYCombo + Explosion* L0470_ps_Explosion; + CreatureInfo* L0471_ps_CreatureInfo; + Group* L0472_ps_Group; + Thing L0473_T_Thing; + int16 L0474_i_ProjectileTargetMapX; + int16 L0475_i_ProjectileTargetMapY; + int16 L0469_i_CreatureFireResistance; + TimelineEvent L0476_s_Event; + + + if ((L0473_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType)) == Thing::_none) { + return; + } + L0470_ps_Explosion = &((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[(L0473_T_Thing).getIndex()]; + if (mapXCombo <= 255) { + L0474_i_ProjectileTargetMapX = mapXCombo; + L0475_i_ProjectileTargetMapY = mapYCombo; + } else { + L0474_i_ProjectileTargetMapX = mapXCombo & 0x00FF; + L0475_i_ProjectileTargetMapY = mapYCombo & 0x00FF; + AP0443_ui_ProjectileMapX >>= 8; + AP0443_ui_ProjectileMapX--; + AP0444_ui_ProjectileMapY >>= 8; + } + if (cell == k255_CreatureTypeSingleCenteredCreature) { + L0470_ps_Explosion->setCentered(true); + } else { + L0470_ps_Explosion->setCentered(false); + L0473_T_Thing = M15_thingWithNewCell(L0473_T_Thing, cell); + } + L0470_ps_Explosion->setType(explThing.toUint16() - Thing::_firstExplosion.toUint16()); + L0470_ps_Explosion->setAttack(attack); + if (explThing.toUint16() < Thing::_explHarmNonMaterial.toUint16()) { + warning("MISING CODE: F0064_SOUND_RequestPlay_CPSD"); + } else { + if (explThing != Thing::_explSmoke) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + } + _vm->_dungeonMan->f163_linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY); + M33_setMapAndTime(L0476_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ((explThing == Thing::_explRebirthStep1) ? 5 : 1)); + L0476_s_Event._type = k25_TMEventTypeExplosion; + L0476_s_Event._priority = 0; + L0476_s_Event._C._slot = L0473_T_Thing; + L0476_s_Event._B._location._mapX = AP0443_ui_ProjectileMapX; + L0476_s_Event._B._location._mapY = AP0444_ui_ProjectileMapY; + _vm->_timeline->f238_addEventGetEventIndex(&L0476_s_Event); + if ((explThing == Thing::_explLightningBolt) || (explThing == Thing::_explFireBall)) { + AP0443_ui_ProjectileMapX = L0474_i_ProjectileTargetMapX; + AP0444_ui_ProjectileMapY = L0475_i_ProjectileTargetMapY; + attack = (attack >> 1) + 1; + attack += _vm->getRandomNumber(attack) + 1; + if ((explThing == Thing::_explFireBall) || (attack >>= 1)) { + if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (AP0443_ui_ProjectileMapX == _vm->_dungeonMan->_g306_partyMapX) && (AP0444_ui_ProjectileMapY == _vm->_dungeonMan->_g307_partyMapY)) { + _vm->_championMan->f324_damageAll_getDamagedChampionCount(attack, k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand | k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k1_attackType_FIRE); + } else { + if ((L0473_T_Thing = _vm->_groupMan->f175_groupGetThing(AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY)) != Thing::_endOfList) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */ + L0472_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0473_T_Thing); + L0471_ps_CreatureInfo = &g243_CreatureInfo[L0472_ps_Group->_type]; + if ((L0469_i_CreatureFireResistance = (L0471_ps_CreatureInfo->M60_getFireResistance())) != k15_immuneToFire) { + if (getFlag(L0471_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) { + attack >>= 2; + } + if ((attack -= _vm->getRandomNumber((L0469_i_CreatureFireResistance << 1) + 1)) > 0) { + _g364_creatureDamageOutcome = _vm->_groupMan->f191_getDamageAllCreaturesOutcome(L0472_ps_Group, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, attack, true); + } + } + } + } + } + } +} + +int16 ProjExpl::f218_projectileGetImpactCount(int16 impactType, int16 mapX, int16 mapY, int16 cell) { + Thing L0513_T_Thing; + int16 L0514_i_ImpactCount; + + + L0514_i_ImpactCount = 0; + _g364_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup; +T0218001: + L0513_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY); + while (L0513_T_Thing != Thing::_endOfList) { + if (((L0513_T_Thing).getType() == k14_ProjectileThingType) && + ((L0513_T_Thing).getCell() == cell) && + f217_projectileHasImpactOccurred(impactType, mapX, mapY, cell, L0513_T_Thing)) { + f214_projectileDeleteEvent(L0513_T_Thing); + L0514_i_ImpactCount++; + if ((impactType == kM1_CreatureElemType) && (_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) + break; + goto T0218001; + } + L0513_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0513_T_Thing); + } + return L0514_i_ImpactCount; +} + +void ProjExpl::f214_projectileDeleteEvent(Thing thing) { + Projectile* L0477_ps_Projectile; + + + L0477_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(thing); + _vm->_timeline->f237_deleteEvent(L0477_ps_Projectile->_eventIndex); +} + +void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, int16 mapX, int16 mapY) { + Thing L0478_T_PreviousThing; + Thing L0479_T_Thing; + Projectile* L0480_ps_Projectile; + Thing* L0481_ps_Generic; + + L0480_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(projectileThing); + if ((L0479_T_Thing = L0480_ps_Projectile->_slot).getType() != k15_ExplosionThingType) { + if (groupSlot != NULL) { + if ((L0478_T_PreviousThing = *groupSlot) == Thing::_endOfList) { + L0481_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0479_T_Thing); + *L0481_ps_Generic = Thing::_endOfList; + *groupSlot = L0479_T_Thing; + } else { + _vm->_dungeonMan->f163_linkThingToList(L0479_T_Thing, L0478_T_PreviousThing, kM1_MapXNotOnASquare, 0); + } + } else { + _vm->_movsens->f267_getMoveResult(Thing((L0479_T_Thing).getTypeAndIndex() | getFlag(projectileThing.toUint16(), 0xC)), -2, 0, mapX, mapY); + } + } + L0480_ps_Projectile->_nextThing = Thing::_none; +} +} diff --git a/engines/dm/projexpl.h b/engines/dm/projexpl.h new file mode 100644 index 0000000000..15f74543fc --- /dev/null +++ b/engines/dm/projexpl.h @@ -0,0 +1,101 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ +#ifndef DM_PROJEXPL_H +#define DM_PROJEXPL_H + +#include "dm.h" + + +#define k0_outcomeKilledNoCreaturesInGroup 0 // @ C0_OUTCOME_KILLED_NO_CREATURES_IN_GROUP +#define k1_outcomeKilledSomeCreaturesInGroup 1 // @ C1_OUTCOME_KILLED_SOME_CREATURES_IN_GROUP +#define k2_outcomeKilledAllCreaturesInGroup 2 // @ C2_OUTCOME_KILLED_ALL_CREATURES_IN_GROUP + +#define k00_soundMETALLIC_THUD 0 // @ C00_SOUND_METALLIC_THUD +#define k01_soundSWITCH 1 // @ C01_SOUND_SWITCH +#define k02_soundDOOR_RATTLE 2 // @ C02_SOUND_DOOR_RATTLE +#define k03_soundATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON 3 // @ C03_SOUND_ATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON +#define k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM 4 // @ C04_SOUND_WOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM +#define k05_soundSTRONG_EXPLOSION 5 // @ C05_SOUND_STRONG_EXPLOSION +#define k06_soundSCREAM 6 // @ C06_SOUND_SCREAM +#define k07_soundATTACK_MUMMY_GHOST_RIVE 7 // @ C07_SOUND_ATTACK_MUMMY_GHOST_RIVE +#define k08_soundSWALLOW 8 // @ C08_SOUND_SWALLOW +#define k09_soundCHAMPION_0_DAMAGED 9 // @ C09_SOUND_CHAMPION_0_DAMAGED +#define k10_soundCHAMPION_1_DAMAGED 10 // @ C10_SOUND_CHAMPION_1_DAMAGED +#define k11_soundCHAMPION_2_DAMAGED 11 // @ C11_SOUND_CHAMPION_2_DAMAGED +#define k12_soundCHAMPION_3_DAMAGED 12 // @ C12_SOUND_CHAMPION_3_DAMAGED +#define k13_soundSPELL 13 // @ C13_SOUND_SPELL +#define k14_soundATTACK_SCREAMER_OITU 14 // @ C14_SOUND_ATTACK_SCREAMER_OITU +#define k15_soundATTACK_GIANT_SCORPION_SCORPION 15 // @ C15_SOUND_ATTACK_GIANT_SCORPION_SCORPION +#define k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT 16 // @ C16_SOUND_COMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT +#define k17_soundBUZZ 17 // @ C17_SOUND_BUZZ +#define k18_soundPARTY_DAMAGED 18 // @ C18_SOUND_PARTY_DAMAGED +#define k19_soundATTACK_MAGENTA_WORM_WORM 19 // @ C19_SOUND_ATTACK_MAGENTA_WORM_WORM +#define k20_soundWEAK_EXPLOSION 20 // @ C20_SOUND_WEAK_EXPLOSION +#define k21_soundATTACK_GIGGLER 21 // @ C21_SOUND_ATTACK_GIGGLER +#define k22_soundMOVE_ANIMATED_ARMOUR_DETH_KNIGHT 22 // @ C22_SOUND_MOVE_ANIMATED_ARMOUR_DETH_KNIGHT +#define k23_soundMOVE_COUATL_GIANT_WASP_MUNCHER 23 // @ C23_SOUND_MOVE_COUATL_GIANT_WASP_MUNCHER +#define k24_soundMOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON 24 // @ C24_SOUND_MOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON +#define k25_soundBLOW_HORN 25 // @ C25_SOUND_BLOW_HORN +#define k26_soundMOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU 26 // @ C26_SOUND_MOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU +#define k27_soundMOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL 27 // @ C27_SOUND_MOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL +#define k28_soundWAR_CRY 28 // @ C28_SOUND_WAR_CRY +#define k29_soundATTACK_ROCK_ROCKPILE 29 // @ C29_SOUND_ATTACK_ROCK_ROCKPILE +#define k30_soundATTACK_WATER_ELEMENTAL 30 // @ C30_SOUND_ATTACK_WATER_ELEMENTAL +#define k31_soundATTACK_COUATL 31 // @ C31_SOUND_ATTACK_COUATL +#define k32_soundMOVE_RED_DRAGON 32 // @ C32_SOUND_MOVE_RED_DRAGON +#define k33_soundMOVE_SKELETON 33 // @ C33_SOUND_MOVE_SKELETON + + +namespace DM { + class Projectile; + + class ProjExpl { + DMEngine *_vm; +public: + int16 _g364_creatureDamageOutcome; // @ G0364_i_CreatureDamageOutcome + int16 _g363_secondaryDirToOrFromParty; // @ G0363_i_SecondaryDirectionToOrFromParty + int32 _g361_lastCreatureAttackTime; // @ G0361_l_LastCreatureAttackTime + bool _g365_createLanucherProjectile; // @ G0365_B_CreateLauncherProjectile + int16 _g366_projectilePoisonAttack; // @ G0366_i_ProjectilePoisonAttack + int16 _g367_projectileAttackType; // @ G0367_i_ProjectileAttackType + int32 _g362_lastPartyMovementTime; // @ G0362_l_LastPartyMovementTime + ProjExpl(DMEngine *vm); + void f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, direction dir, + byte kineticEnergy, byte attack, byte stepEnergy); // @ F0212_PROJECTILE_Create + bool f217_projectileHasImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo, + int16 cell, Thing projectileThing); // @ F0217_PROJECTILE_HasImpactOccured + uint16 f216_projectileGetImpactAttack(Projectile *projectile, Thing thing); // @ F0216_PROJECTILE_GetImpactAttack + void f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXCombo, + uint16 mapYCombo, uint16 cell); // @ F0213_EXPLOSION_Create + int16 f218_projectileGetImpactCount(int16 impactType, int16 mapX, int16 mapY, int16 cell); // @ F0218_PROJECTILE_GetImpactCount + void f214_projectileDeleteEvent(Thing thing); // @ F0214_PROJECTILE_DeleteEvent + void f215_projectileDelete(Thing projectileThing, Thing *groupSlot, int16 mapX, int16 mapY); // @ F0215_PROJECTILE_Delete +}; + +} + +#endif diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index 5426dd0f61..d9ca4b7fd1 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -30,13 +30,19 @@ namespace DM { -TextMan::TextMan(DMEngine* vm) : _vm(vm) {} +TextMan::TextMan(DMEngine* vm) : _vm(vm) { + _g356_bitmapMessageAreaNewRow = new byte[320 * 7]; +} + +TextMan::~TextMan() { + delete[] _g356_bitmapMessageAreaNewRow; +} #define k5_LetterWidth 5 #define k6_LetterHeight 6 void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, uint16 destX, uint16 destY, - Color textColor, Color bgColor, const char* text, uint16 destHeight) { + Color textColor, Color bgColor, const char* text, uint16 destHeight) { destX -= 1; // fixes missalignment, to be checked destY -= 4; // fixes missalignment, to be checked @@ -78,11 +84,81 @@ void TextMan::f52_printToViewport(int16 posX, int16 posY, Color textColor, const } void TextMan::f41_printWithTrailingSpaces(byte* destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor, - Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) { + Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) { Common::String str = text; for (int16 i = str.size(); i < requiredTextLength; ++i) str += ' '; f40_printTextToBitmap(destBitmap, destByteWidth, destX, destY, textColor, bgColor, str.c_str(), destHeight); } +void TextMan::f51_messageAreaPrintLineFeed() { + f47_messageAreaPrintMessage(k0_ColorBlack, "\n"); +} + +void TextMan::f47_messageAreaPrintMessage(Color color, const char* string) { + uint16 L0031_ui_CharacterIndex; + char L0033_ac_String[54]; + + + while (*string) { + if (*string == '\n') { /* New line */ + string++; + if ((_g359_messageAreaCursorColumn != 0) || (_g358_messageAreaCursorRow != 0)) { + _g359_messageAreaCursorColumn = 0; + f45_messageAreaCreateNewRow(); + } + } else { + if (*string == ' ') { + string++; + if (_g359_messageAreaCursorColumn != 53) { + f46_messageAreaPrintString(color, " "); // TODO: I'm not sure this is like the original + } + } else { + L0031_ui_CharacterIndex = 0; + do { + L0033_ac_String[L0031_ui_CharacterIndex++] = *string++; + } while (*string && (*string != ' ') && (*string != '\n')); /* End of string, space or New line */ + L0033_ac_String[L0031_ui_CharacterIndex] = '\0'; + if (_g359_messageAreaCursorColumn + L0031_ui_CharacterIndex > 53) { + _g359_messageAreaCursorColumn = 2; + f45_messageAreaCreateNewRow(); + } + f46_messageAreaPrintString(color, L0033_ac_String); + } + } + } +} + +void TextMan::f45_messageAreaCreateNewRow() { + uint16 L0029_ui_RowIndex; + + if (_g358_messageAreaCursorRow == 3) { + warning("MISSING CODE: F0561_SCROLLER_IsTextScrolling"); + memset(_g356_bitmapMessageAreaNewRow, k0_ColorBlack, 320 * 7); + warning("MISSING CODE: F0560_SCROLLER_SetCommand"); + for (L0029_ui_RowIndex = 0; L0029_ui_RowIndex < 3; L0029_ui_RowIndex++) { + _g360_messageAreaRowExpirationTime[L0029_ui_RowIndex] = _g360_messageAreaRowExpirationTime[L0029_ui_RowIndex + 1]; + } + _g360_messageAreaRowExpirationTime[3] = -1; + } else { + _g358_messageAreaCursorRow++; + } +} + +void TextMan::f46_messageAreaPrintString(Color color, const char* string) { + int16 L0030_i_StringLength; + + L0030_i_StringLength = strlen(string); + warning("MISSING CODE: F0561_SCROLLER_IsTextScrolling"); + if (true) { // there is a test here with F0561_SCROLLER_IsTextScrolling + _vm->_textMan->f53_printToLogicalScreen(_g359_messageAreaCursorColumn * 6, (_g358_messageAreaCursorRow * 7) + 177, color, k0_ColorBlack, string); + } else { + f40_printTextToBitmap(_g356_bitmapMessageAreaNewRow, k160_byteWidthScreen, _g359_messageAreaCursorColumn * 6, 5, color, k0_ColorBlack, string, 7); + warning("MISSING CODE: F0561_SCROLLER_IsTextScrolling"); + warning("MISSING CODE: F0560_SCROLLER_SetCommand"); + } + _g359_messageAreaCursorColumn += L0030_i_StringLength; + _g360_messageAreaRowExpirationTime[_g358_messageAreaCursorRow] = _vm->_g313_gameTime + 200; +} + } diff --git a/engines/dm/text.h b/engines/dm/text.h index 31344e21d9..b0ecb48716 100644 --- a/engines/dm/text.h +++ b/engines/dm/text.h @@ -35,14 +35,25 @@ namespace DM { class TextMan { DMEngine *_vm; + int16 _g359_messageAreaCursorColumn; // @ G0359_i_MessageAreaCursorColumn + int16 _g358_messageAreaCursorRow; // @ G0358_i_MessageAreaCursorRow + int32 _g360_messageAreaRowExpirationTime[4]; // @ G0360_al_MessageAreaRowExpirationTime + byte *_g356_bitmapMessageAreaNewRow; // @ G0356_puc_Bitmap_MessageAreaNewRow public: explicit TextMan(DMEngine *vm); + ~TextMan(); void f40_printTextToBitmap(byte *destBitmap, uint16 destByteWidth, uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text, uint16 destHeight); // @ F0040_TEXT_Print void f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text); // @ F0053_TEXT_PrintToLogicalScreen void f52_printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport void f41_printWithTrailingSpaces(byte *destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor, Color bgColor, const char *text, int16 strLenght, int16 destHeight); // @ F0041_TEXT_PrintWithTrailingSpaces + void f51_messageAreaPrintLineFeed(); // @ F0051_TEXT_MESSAGEAREA_PrintLineFeed + void f47_messageAreaPrintMessage(Color color, const char *string); // @ F0047_TEXT_MESSAGEAREA_PrintMessage + void f45_messageAreaCreateNewRow(); // @ F0045_TEXT_MESSAGEAREA_CreateNewRow + void f46_messageAreaPrintString(Color color, const char* string);// @ F0046_TEXT_MESSAGEAREA_PrintString + + }; } diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 4b5cfd411d..2b58203b35 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -52,4 +52,157 @@ void Timeline::f233_initTimeline() { } } +void Timeline::f237_deleteEvent(uint16 eventIndex) { + uint16 L0586_ui_TimelineIndex; + uint16 L0587_ui_EventCount; + + + _vm->_timeline->_g370_events[eventIndex]._type = k0_TMEventTypeNone; + if (eventIndex < _vm->_timeline->_g373_firstUnusedEventIndex) { + _vm->_timeline->_g373_firstUnusedEventIndex = eventIndex; + } + _vm->_timeline->_g372_eventCount--; + if ((L0587_ui_EventCount = _vm->_timeline->_g372_eventCount) == 0) { + return; + } + L0586_ui_TimelineIndex = f235_getIndex(eventIndex); + if (L0586_ui_TimelineIndex == L0587_ui_EventCount) { + return; + } + _vm->_timeline->_g371_timeline[L0586_ui_TimelineIndex] = _vm->_timeline->_g371_timeline[L0587_ui_EventCount]; + f236_fixChronology(L0586_ui_TimelineIndex); +} + +void Timeline::f236_fixChronology(uint16 timelineIndex) { + uint16 L0581_ui_TimelineIndex; + uint16 L0582_ui_EventIndex; + uint16 L0583_ui_EventCount; + TimelineEvent* L0584_ps_Event; + bool L0585_B_ChronologyFixed; + + + if ((L0583_ui_EventCount = _vm->_timeline->_g372_eventCount) == 1) { + return; + } + + L0584_ps_Event = &_vm->_timeline->_g370_events[L0582_ui_EventIndex = _vm->_timeline->_g371_timeline[timelineIndex]]; + L0585_B_ChronologyFixed = false; + while (timelineIndex > 0) { /* Check if the event should be moved earlier in the timeline */ + L0581_ui_TimelineIndex = (timelineIndex - 1) >> 1; + if (f234_isEventABeforeB(L0584_ps_Event, &_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex]])) { + _vm->_timeline->_g371_timeline[timelineIndex] = _vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex]; + timelineIndex = L0581_ui_TimelineIndex; + L0585_B_ChronologyFixed = true; + } else { + break; + } + } + if (L0585_B_ChronologyFixed) + goto T0236011; + L0583_ui_EventCount = ((L0583_ui_EventCount - 1) - 1) >> 1; + while (timelineIndex <= L0583_ui_EventCount) { /* Check if the event should be moved later in the timeline */ + L0581_ui_TimelineIndex = (timelineIndex << 1) + 1; + if (((L0581_ui_TimelineIndex + 1) < _vm->_timeline->_g372_eventCount) && (f234_isEventABeforeB(&_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex + 1]], &_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex]]))) { + L0581_ui_TimelineIndex++; + } + if (f234_isEventABeforeB(&_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex]], L0584_ps_Event)) { + _vm->_timeline->_g371_timeline[timelineIndex] = _vm->_timeline->_g371_timeline[L0581_ui_TimelineIndex]; + timelineIndex = L0581_ui_TimelineIndex; + } else { + break; + } + } +T0236011: + _vm->_timeline->_g371_timeline[timelineIndex] = L0582_ui_EventIndex; +} + +bool Timeline::f234_isEventABeforeB(TimelineEvent* eventA, TimelineEvent* eventB) { + bool L0578_B_Simultaneous; + + return (M30_time(eventA->_mapTime) < M30_time(eventB->_mapTime)) || + ((L0578_B_Simultaneous = (M30_time(eventA->_mapTime) == M30_time(eventB->_mapTime))) && (eventA->getTypePriority() > eventB->getTypePriority())) || + (L0578_B_Simultaneous && (eventA->getTypePriority() == eventB->getTypePriority()) && (eventA <= eventB)); +} + +uint16 Timeline::f235_getIndex(uint16 eventIndex) { + uint16 L0579_ui_TimelineIndex; + uint16* L0580_pui_TimelineEntry; + + + for (L0579_ui_TimelineIndex = 0, L0580_pui_TimelineEntry = _vm->_timeline->_g371_timeline; L0579_ui_TimelineIndex < _vm->_timeline->_g369_eventMaxCount; L0579_ui_TimelineIndex++) { + if (*L0580_pui_TimelineEntry++ == eventIndex) + break; + } + if (L0579_ui_TimelineIndex >= _vm->_timeline->_g369_eventMaxCount) { /* BUG0_00 Useless code. The function is always called with event indices that are in the timeline */ + L0579_ui_TimelineIndex = 0; /* BUG0_01 Coding error without consequence. Wrong return value. If the specified event index is not found in the timeline the function returns 0 which is the same value that is returned if the event index is found in the first timeline entry. No consequence because this code is never executed */ + } + return L0579_ui_TimelineIndex; +} + +uint16 Timeline::f238_addEventGetEventIndex(TimelineEvent* event) { + uint16 L0588_ui_EventIndex; + uint16 L0590_ui_NewEventIndex; + TimelineEvent* L0591_ps_Event; + + + if (_vm->_timeline->_g372_eventCount == _vm->_timeline->_g369_eventMaxCount) { + _vm->f19_displayErrorAndStop(45); + } + if ((event->_type >= k5_TMEventTypeCorridor) && (event->_type <= k10_TMEventTypeDoor)) { + for (L0588_ui_EventIndex = 0, L0591_ps_Event = _vm->_timeline->_g370_events; L0588_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) { + if ((L0591_ps_Event->_type >= k5_TMEventTypeCorridor) && (L0591_ps_Event->_type <= k10_TMEventTypeDoor)) { + if ((event->_mapTime == L0591_ps_Event->_mapTime) && (event->getMapXY() == L0591_ps_Event->getMapXY()) && ((L0591_ps_Event->_type != k6_TMEventTypeWall) || (L0591_ps_Event->_C.A._cell == event->_C.A._cell))) { + L0591_ps_Event->_C.A._effect = event->_C.A._effect; + return L0588_ui_EventIndex; + } + continue; + } else { + if ((L0591_ps_Event->_type == k1_TMEventTypeDoorAnimation) && (event->_mapTime == L0591_ps_Event->_mapTime) && (event->getMapXY() == L0591_ps_Event->getMapXY())) { + if (event->_C.A._effect == k2_SensorEffToggle) { + event->_C.A._effect = 1 - L0591_ps_Event->_C.A._effect; + } + f237_deleteEvent(L0588_ui_EventIndex); + break; + } + } + } + } else { + if (event->_type == k1_TMEventTypeDoorAnimation) { + for (L0588_ui_EventIndex = 0, L0591_ps_Event = _vm->_timeline->_g370_events; L0588_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) { + if ((event->_mapTime == L0591_ps_Event->_mapTime) && (event->getMapXY() == L0591_ps_Event->getMapXY())) { + if (L0591_ps_Event->_type == k10_TMEventTypeDoor) { + if (L0591_ps_Event->_C.A._effect == k2_SensorEffToggle) { + L0591_ps_Event->_C.A._effect = 1 - event->_C.A._effect; + } + return L0588_ui_EventIndex; + } + if (L0591_ps_Event->_type == k1_TMEventTypeDoorAnimation) { + L0591_ps_Event->_C.A._effect = event->_C.A._effect; + return L0588_ui_EventIndex; + } + } + } + } else { + if (event->_type == k2_TMEventTypeDoorDestruction) { + for (L0588_ui_EventIndex = 0, L0591_ps_Event = _vm->_timeline->_g370_events; L0588_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0588_ui_EventIndex++, L0591_ps_Event++) { + if ((event->getMapXY() == L0591_ps_Event->getMapXY()) && (M29_map(event->_mapTime) == M29_map(L0591_ps_Event->_mapTime))) { + if ((L0591_ps_Event->_type == k1_TMEventTypeDoorAnimation) || (L0591_ps_Event->_type == k10_TMEventTypeDoor)) { + f237_deleteEvent(L0588_ui_EventIndex); + } + } + } + } + } + } + _vm->_timeline->_g370_events[L0590_ui_NewEventIndex = _vm->_timeline->_g373_firstUnusedEventIndex] = *event; /* Copy the event data (Megamax C can assign structures) */ + do { + if (_vm->_timeline->_g373_firstUnusedEventIndex == _vm->_timeline->_g369_eventMaxCount) + break; + _vm->_timeline->_g373_firstUnusedEventIndex++; + } while ((_vm->_timeline->_g370_events[_vm->_timeline->_g373_firstUnusedEventIndex])._type != k0_TMEventTypeNone); + _vm->_timeline->_g371_timeline[_vm->_timeline->_g372_eventCount] = L0590_ui_NewEventIndex; + f236_fixChronology(_vm->_timeline->_g372_eventCount++); + return L0590_ui_NewEventIndex; +} + } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index c2e06bcd9c..1c184e3980 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -154,6 +154,12 @@ public: Timeline(DMEngine *vm); ~Timeline(); void f233_initTimeline(); // @ F0233_TIMELINE_Initialize + void f237_deleteEvent(uint16 eventIndex);// @ F0237_TIMELINE_DeleteEvent + void f236_fixChronology(uint16 timelineIndex); // @ F0236_TIMELINE_FixChronology + bool f234_isEventABeforeB(TimelineEvent *eventA, TimelineEvent *eventB); // @ F0234_TIMELINE_IsEventABeforeEventB + uint16 f235_getIndex(uint16 eventIndex); // @ F0235_TIMELINE_GetIndex + uint16 f238_addEventGetEventIndex(TimelineEvent *event); // @ F0238_TIMELINE_AddEvent_GetEventIndex_CPSE + }; -- cgit v1.2.3 From f33b4f38770843ac1096ba3db8a83698fa2a865e Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:49:26 +0200 Subject: DM: Fix some compilation errors using MSVC9 --- engines/dm/dungeonman.cpp | 342 +--------- engines/dm/group.cpp | 1640 +-------------------------------------------- engines/dm/group.h | 3 +- 3 files changed, 11 insertions(+), 1974 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index ca7785652b..c7f59b7c97 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -31,9 +31,7 @@ #include "dungeonman.h" #include "timeline.h" #include "champion.h" -#include "group.h" -#include "movesens.h" -#include "projexpl.h" + namespace DM { @@ -837,11 +835,11 @@ void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 #define footprintsAllowed L0307_uc_Multiple #define scentOrdinal L0307_uc_Multiple Sensor* sensor; - bool leftRandWallOrnAllowed = false; - int16 L0310_i_Multiple = 0; + bool leftRandWallOrnAllowed; + int16 L0310_i_Multiple; #define frontRandWallOrnAllowed L0310_i_Multiple #define sideIndex L0310_i_Multiple - bool rightRandWallOrnAllowed = false; + bool rightRandWallOrnAllowed; int16 thingTypeRedEagle; bool squreIsFakeWall; Thing thing; @@ -948,12 +946,12 @@ T0172030_Pit: aspectArray[k2_TeleporterVisibleAspect] = getFlag(square, k0x0008_TeleporterOpen) && getFlag(square, k0x0004_TeleporterVisible); goto T0172029_Teleporter; case k3_ElementTypeStairs: - aspectArray[k0_ElemAspect] = (((getFlag(square, k0x0008_StairsNorthSouthOrient) >> 3) ? true : false) == isOrientedWestEast(dir)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront; + aspectArray[k0_ElemAspect] = ((getFlag(square, k0x0008_StairsNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront; aspectArray[k2_StairsUpAspect] = getFlag(square, k0x0004_StairsUp); footprintsAllowed = false; goto T0172046_Stairs; case k4_DoorElemType: - if (((getFlag(square, k0x0008_DoorNorthSouthOrient) >> 3) ? true : false) == isOrientedWestEast(dir)) { + if ((getFlag(square, k0x0008_DoorNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) { aspectArray[k0_ElemAspect] = k16_DoorSideElemType; } else { aspectArray[k0_ElemAspect] = k17_DoorFrontElemType; @@ -1192,45 +1190,6 @@ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) { *destString = ((type == k0_TextTypeInscription) ? 0x81 : '\0'); } -Thing DungeonMan::f166_getUnusedThing(uint16 thingType) { - int16 L0288_i_ThingIndex; - int16 L0289_i_ThingDataByteCount; - int16 L0290_i_ThingCount; - Thing* L0291_ps_Generic; - Thing L0292_T_Thing; - - - L0290_i_ThingCount = _vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[getFlag(thingType, k0x7FFF_thingType)]; - if (thingType == (k0x8000_championBones | k10_JunkThingType)) { - thingType = k10_JunkThingType; - } else { - if (thingType == k10_JunkThingType) { - L0290_i_ThingCount -= 3; /* Always keep 3 unused JUNK things for the bones of dead champions */ - } - } - L0288_i_ThingIndex = L0290_i_ThingCount; - L0289_i_ThingDataByteCount = g235_ThingDataWordCount[thingType] >> 1; - L0291_ps_Generic = (Thing*)_vm->_dungeonMan->_g284_thingData[thingType]; - for (;;) { /*_Infinite loop_*/ - if (*L0291_ps_Generic == Thing::_none) { /* If thing data is unused */ - L0292_T_Thing = Thing((thingType << 10) | (L0290_i_ThingCount - L0288_i_ThingIndex)); - break; - } - if (--L0288_i_ThingIndex) { /* If there are thing data left to process */ - L0291_ps_Generic += L0289_i_ThingDataByteCount; /* Proceed to the next thing data */ - } else { - if ((L0292_T_Thing = f165_getDiscardTHing(thingType)) == Thing::_none) { - return Thing::_none; - } - L0291_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0292_T_Thing); - break; - } - } - memset(L0291_ps_Generic, 0, L0289_i_ThingDataByteCount * 2); - - *L0291_ps_Generic = Thing::_endOfList; - return L0292_T_Thing; -} uint16 DungeonMan::f140_getObjectWeight(Thing thing) { static const uint16 g241_junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo @@ -1422,293 +1381,4 @@ int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDe } return kM1_mapIndexNone; } - -Thing DungeonMan::f162_getSquareFirstObject(int16 mapX, int16 mapY) { - Thing thing = f161_getSquareFirstThing(mapX, mapY); - while ((thing != Thing::_endOfList) && (thing.getType() < k4_GroupThingType)) { - thing = f159_getNextThing(thing); - } - return thing; -} - -uint16 DungeonMan::f143_getArmourDefense(ArmourInfo* armourInfo, bool useSharpDefense) { - uint16 L0244_ui_Defense; - - L0244_ui_Defense = armourInfo->_defense; - if (useSharpDefense) { - L0244_ui_Defense = _vm->f30_getScaledProduct(L0244_ui_Defense, 3, getFlag(armourInfo->_attributes, k0x0007_ArmourAttributeSharpDefense) + 4); - } - return L0244_ui_Defense; -} - -Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) { - uint16 L0276_ui_MapX; - uint16 L0277_ui_MapY; - Thing L0278_T_Thing; - uint16 L0279_ui_MapIndex; - byte* L0280_puc_Square; - Thing* L0281_pT_SquareFirstThing; - Thing* L0282_ps_Generic; - uint16 L0283_ui_DiscardThingMapIndex; - int L0284_i_CurrentMapIndex; - uint16 L0285_ui_MapWidth; - uint16 L0286_ui_MapHeight; - int L0287_i_ThingType; - static unsigned char G0294_auc_LastDiscardedThingMapIndex[16]; - - - if (thingType == k15_ExplosionThingType) { - return Thing::_none; - } - L0284_i_CurrentMapIndex = _vm->_dungeonMan->_g272_currMapIndex; - if (((L0279_ui_MapIndex = G0294_auc_LastDiscardedThingMapIndex[thingType]) == _vm->_dungeonMan->_g309_partyMapIndex) && (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount)) { - L0279_ui_MapIndex = 0; - } - L0283_ui_DiscardThingMapIndex = L0279_ui_MapIndex; - for (;;) { /*_Infinite loop_*/ - L0285_ui_MapWidth = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._width; - L0286_ui_MapHeight = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._height; - L0280_puc_Square = _vm->_dungeonMan->_g279_dungeonMapData[L0279_ui_MapIndex][0]; - L0281_pT_SquareFirstThing = &_vm->_dungeonMan->_g283_squareFirstThings[_vm->_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[L0279_ui_MapIndex]]]; - for (L0276_ui_MapX = 0; L0276_ui_MapX <= L0285_ui_MapWidth; L0276_ui_MapX++) { - for (L0277_ui_MapY = 0; L0277_ui_MapY <= L0286_ui_MapHeight; L0277_ui_MapY++) { - if (getFlag(*L0280_puc_Square++, k0x0010_ThingListPresent)) { - L0278_T_Thing = *L0281_pT_SquareFirstThing++; - if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && ((L0276_ui_MapX - _vm->_dungeonMan->_g306_partyMapX + 5) <= 10) && ((L0277_ui_MapY - _vm->_dungeonMan->_g307_partyMapY + 5) <= 10)) /* If square is too close to the party */ - goto T0165029; - do { - if ((L0287_i_ThingType = (L0278_T_Thing).getType()) == k3_SensorThingType) { - L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing); - if (((Sensor*)L0282_ps_Generic)->getType()) /* If sensor is not disabled */ - break; - } else { - if (L0287_i_ThingType == thingType) { - L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing); - switch (thingType) { - case k4_GroupThingType: - if (((Group*)L0282_ps_Generic)->getDoNotDiscard()) - continue; - case k14_ProjectileThingType: - _vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex); - if (thingType == k4_GroupThingType) { - _vm->_groupMan->f188_dropGroupPossessions(L0276_ui_MapX, L0277_ui_MapY, L0278_T_Thing, kM1_soundModeDoNotPlaySound); - _vm->_groupMan->f189_delete(L0276_ui_MapX, L0277_ui_MapY); - } else { - _vm->_projexpl->f214_projectileDeleteEvent(L0278_T_Thing); - f164_unlinkThingFromList(L0278_T_Thing, Thing(0), L0276_ui_MapX, L0277_ui_MapY); - _vm->_projexpl->f215_projectileDelete(L0278_T_Thing, 0, L0276_ui_MapX, L0277_ui_MapY); - } - break; - case k6_ArmourThingType: - if (((Armour*)L0282_ps_Generic)->getDoNotDiscard()) - continue; - goto T0165026; - case k5_WeaponThingType: - if (((Weapon*)L0282_ps_Generic)->getDoNotDiscard()) - continue; - goto T0165026; - case k10_JunkThingType: - if (((Junk*)L0282_ps_Generic)->getDoNotDiscard()) - continue; - goto T0165026; - case k8_PotionThingType: - if (((Potion*)L0282_ps_Generic)->getDoNotDiscard()) - continue; -T0165026: - _vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex); - _vm->_movsens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0); - } - _vm->_dungeonMan->f173_setCurrentMap(L0284_i_CurrentMapIndex); - G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex; - return Thing((L0278_T_Thing).getTypeAndIndex()); - } - } - } while ((L0278_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0278_T_Thing)) != Thing::_endOfList); -T0165029: - ; - } - } - } - if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) || (_vm->_dungeonMan->_g278_dungeonFileHeader._mapCount <= 1)) { - G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex; - return Thing::_none; - } - do { - if (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount) { - L0279_ui_MapIndex = 0; - } - } while (L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex); - if (L0279_ui_MapIndex == L0283_ui_DiscardThingMapIndex) { - L0279_ui_MapIndex = _vm->_dungeonMan->_g309_partyMapIndex; - } - } -} - -uint16 DungeonMan::f144_getCreatureAttributes(Thing thing) { - Group* L0245_ps_Group; - - L0245_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing); - return g243_CreatureInfo[L0245_ps_Group->_type]._attributes; -} - -void DungeonMan::f146_setGroupCells(Group* group, uint16 cells, uint16 mapIndex) { - if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) { - _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._cells = cells; - } else { - group->_cells = cells; - } -} - -void DungeonMan::f148_setGroupDirections(Group* group, int16 dir, uint16 mapIndex) { - if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) { - _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (direction)dir; - } else { - group->setDir(M21_normalizeModulo4(dir)); - } -} - -bool DungeonMan::f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) { - int16 L0234_i_Counter; - int16 L0235_i_CreatureType; - byte* L0236_puc_Multiple; -#define AL0236_puc_Group L0236_puc_Multiple -#define AL0236_puc_AllowedCreatureType L0236_puc_Multiple - Map* L0237_ps_Map; - - L0235_i_CreatureType = ((Group*)_vm->_dungeonMan->f156_getThingData(thing))->_type; - L0237_ps_Map = &_vm->_dungeonMan->_g277_dungeonMaps[mapIndex]; - AL0236_puc_AllowedCreatureType = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][L0237_ps_Map->_width] + L0237_ps_Map->_height + 1; - for (L0234_i_Counter = L0237_ps_Map->_creatureTypeCount; L0234_i_Counter > 0; L0234_i_Counter--) { - if (*AL0236_puc_AllowedCreatureType++ == L0235_i_CreatureType) { - return true; - } - } - return false; -} - -void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY) { - uint16 L0271_ui_SquareFirstThingIndex; - uint16 L0272_ui_Multiple; -#define AL0272_ui_SquareFirstThingIndex L0272_ui_Multiple -#define AL0272_ui_Column L0272_ui_Multiple - Thing L0273_T_Thing; - Thing* L0274_ps_Generic = nullptr; - Thing* L0275_pui_Multiple = nullptr; -#define AL0275_pT_Thing L0275_pui_Multiple -#define AL0275_pui_CumulativeFirstThingCount L0275_pui_Multiple - - - if (thingToUnlink == Thing::_endOfList) { - return; - } - - { - uint16 tmp = thingToUnlink.toUint16(); - clearFlag(tmp, 0xC000); - thingToUnlink = Thing(tmp); - } - - if (mapX >= 0) { - L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink); - AL0275_pT_Thing = &_vm->_dungeonMan->_g283_squareFirstThings[L0271_ui_SquareFirstThingIndex = _vm->_dungeonMan->f160_getSquareFirstThingIndex(mapX, mapY)]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. _vm->_dungeonMan->f160_getSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */ - if ((*L0274_ps_Generic == Thing::_endOfList) && (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16())) { /* If the thing to unlink is the last thing on the square */ - clearFlag(_vm->_dungeonMan->_g271_currMapData[mapX][mapY], k0x0010_ThingListPresent); - AL0272_ui_SquareFirstThingIndex = _vm->_dungeonMan->_g278_dungeonFileHeader._squareFirstThingCount - 1; - for (uint16 i = 0; i < AL0272_ui_SquareFirstThingIndex - L0271_ui_SquareFirstThingIndex; ++i) - AL0275_pT_Thing[i] = AL0275_pT_Thing[i + 1]; - - _vm->_dungeonMan->_g283_squareFirstThings[AL0272_ui_SquareFirstThingIndex] = Thing::_none; - AL0275_pui_CumulativeFirstThingCount = (Thing*)_vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount + mapX + 1; - AL0272_ui_Column = _vm->_dungeonMan->_g282_dungeonColumCount - (_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[_vm->_dungeonMan->_g272_currMapIndex] + mapX) - 1; - while (AL0272_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is unlinked */ - (*(uint16*)AL0275_pui_CumulativeFirstThingCount++)--; /* Decrement the cumulative first thing count */ - } - goto T0164011; - } - if (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16()) { - *AL0275_pT_Thing = *L0274_ps_Generic; - goto T0164011; - } - thingInList = *AL0275_pT_Thing; - } - L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList); - while (L0273_T_Thing.getTypeAndIndex() != thingToUnlink.toUint16()) { - if ((L0273_T_Thing == Thing::_endOfList) || (L0273_T_Thing == Thing::_none)) { - goto T0164011; - } - L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList = L0273_T_Thing); - } - L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingInList); - *L0274_ps_Generic = _vm->_dungeonMan->f159_getNextThing(L0273_T_Thing); - L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink); -T0164011: - *L0274_ps_Generic = Thing::_endOfList; -} - -int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) { - int16 L0256_i_SquareType; - bool L0257_B_NorthSouthOrientedStairs; - - - if (L0257_B_NorthSouthOrientedStairs = !getFlag(_vm->_dungeonMan->f151_getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient)) { - mapX = mapX + _vm->_dirIntoStepCountEast[kDirEast]; - mapY = mapY + _vm->_dirIntoStepCountNorth[kDirEast]; - } else { - mapX = mapX + _vm->_dirIntoStepCountEast[kDirNorth]; - mapY = mapY + _vm->_dirIntoStepCountNorth[kDirNorth]; - } - return ((((L0256_i_SquareType = Square(_vm->_dungeonMan->f151_getSquare(mapX, mapY)).getType()) == k0_ElementTypeWall) || (L0256_i_SquareType == k3_ElementTypeStairs)) << 1) + L0257_B_NorthSouthOrientedStairs; - -} - -Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) { - int16 L0293_i_Type; - int16 L0294_i_ThingType; - Thing L0295_T_Thing; - Junk* L0296_ps_Junk; - - - L0294_i_ThingType = k5_WeaponThingType; - if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit)) { - iconIndex = k4_IconIndiceWeaponTorchUnlit; - } - switch (iconIndex) { - case k54_IconIndiceWeaponRock: - L0293_i_Type = k30_WeaponTypeRock; - break; - case k128_IconIndiceJunkBoulder: - L0293_i_Type = k25_JunkTypeBoulder; - L0294_i_ThingType = k10_JunkThingType; - break; - case k51_IconIndiceWeaponArrow: - L0293_i_Type = k27_WeaponTypeArrow; - break; - case k52_IconIndiceWeaponSlayer: - L0293_i_Type = k28_WeaponTypeSlayer; - break; - case k55_IconIndiceWeaponPoisonDart: - L0293_i_Type = k31_WeaponTypePoisonDart; - break; - case k56_IconIndiceWeaponThrowingStar: - L0293_i_Type = k32_WeaponTypeThrowingStar; - break; - case k32_IconIndiceWeaponDagger: - L0293_i_Type = k8_WeaponTypeDagger; - break; - case k4_IconIndiceWeaponTorchUnlit: - L0293_i_Type = k2_WeaponTypeTorch; - break; - default: - return Thing::_none; - } - if ((L0295_T_Thing = f166_getUnusedThing(L0294_i_ThingType)) == Thing::_none) { - return Thing::_none; - } - L0296_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0295_T_Thing); - L0296_ps_Junk->setType(L0293_i_Type); /* Also works for WEAPON in cases other than Boulder */ - if ((iconIndex == k4_IconIndiceWeaponTorchUnlit) && ((Weapon*)L0296_ps_Junk)->isLit()) { /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */ - ((Weapon*)L0296_ps_Junk)->setChargeCount(15); - } - return L0295_T_Thing; -} } diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 7f845c6aa1..b4e89e0402 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -28,19 +28,15 @@ #include "group.h" #include "dungeonman.h" #include "champion.h" -#include "movesens.h" -#include "projexpl.h" -#include "timeline.h" + namespace DM { -int32 M32_setTime(int32 &map_time, int32 time) { - return map_time = (map_time & 0xFF000000) | time; -} + GroupMan::GroupMan(DMEngine* vm) : _vm(vm) { _g375_activeGroups = nullptr; - _g377_currActiveGroupCount = 0; + _g376_maxActiveGroupCount = 60; } GroupMan::~GroupMan() { @@ -102,1634 +98,4 @@ int16 GroupMan::f176_getCreatureOrdinalInCell(Group* group, uint16 cell) { uint16 GroupMan::M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex) { return (groupVal >> (creatureIndex << 1)) & 0x3; } - -void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode) { - Thing L0365_T_CurrentThing; - Thing L0366_T_NextThing; - Group* L0367_ps_Group; - uint16 L0368_ui_CreatureType; - int16 L0369_i_CreatureIndex; - uint16 L0370_ui_GroupCells; - bool L0371_B_WeaponDropped; - - - L0367_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(groupThing); - if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[L0368_ui_CreatureType = L0367_ps_Group->_type]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) { - L0369_i_CreatureIndex = L0367_ps_Group->getCount(); - L0370_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(L0367_ps_Group, _vm->_dungeonMan->_g272_currMapIndex); - do { - _vm->_groupMan->f186_dropCreatureFixedPossessions(L0368_ui_CreatureType, mapX, mapY, (L0370_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0370_ui_GroupCells, L0369_i_CreatureIndex), mode); - } while (L0369_i_CreatureIndex--); - } - if ((L0365_T_CurrentThing = L0367_ps_Group->_slot) != Thing::_endOfList) { - L0371_B_WeaponDropped = false; - do { - L0366_T_NextThing = _vm->_dungeonMan->f159_getNextThing(L0365_T_CurrentThing); - L0365_T_CurrentThing = M15_thingWithNewCell(L0365_T_CurrentThing, _vm->getRandomNumber(4)); - if ((L0365_T_CurrentThing).getType() == k5_WeaponThingType) { - L0371_B_WeaponDropped = true; - } - _vm->_movsens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY); - } while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList); - if (mode >= k0_soundModePlayImmediately) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); - } - } -} - -void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell, int16 mode) { - static uint16 g245FixedPossessionCreature_12Skeleton[3] = { // @ G0245_aui_Graphic559_FixedPossessionsCreature12Skeleton - k23_ObjectInfoIndexFirstWeapon + k9_WeaponTypeFalchion, - k69_ObjectInfoIndexFirstArmour + k30_ArmourTypeWoodenShield, 0}; - static uint16 g246FixedPossessionCreature_9StoneGolem[2] = { // @ G0246_aui_Graphic559_FixedPossessionsCreature09StoneGolem - k23_ObjectInfoIndexFirstWeapon + k24_WeaponTypeStoneClub, 0}; - static uint16 g247FixedPossessionCreature_16TrolinAntman[2] = { // @ G0247_aui_Graphic559_FixedPossessionsCreature16Trolin_Antman - k23_ObjectInfoIndexFirstWeapon + k23_WeaponTypeClub, 0}; - static uint16 g248FixedPossessionCreature_18AnimatedArmourDethKnight[7] = { // @ G0248_aui_Graphic559_FixedPossessionsCreature18AnimatedArmour_DethKnight - k69_ObjectInfoIndexFirstArmour + k41_ArmourTypeFootPlate, - k69_ObjectInfoIndexFirstArmour + k40_ArmourTypeLegPlate, - k69_ObjectInfoIndexFirstArmour + k39_ArmourTypeTorsoPlate, - k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword, - k69_ObjectInfoIndexFirstArmour + k38_ArmourTypeArmet, - k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword, 0}; - static uint16 g249FixedPossessionCreature_7rockRockPile[5] = { // @ G0249_aui_Graphic559_FixedPossessionsCreature07Rock_RockPile - k127_ObjectInfoIndexFirstJunk + k25_JunkTypeBoulder, - k127_ObjectInfoIndexFirstJunk + k25_JunkTypeBoulder | k0x8000_randomDrop, - k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop, - k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop, 0}; - static uint16 g250FixedPossessionCreature_4PainRatHellHound[3] = { // @ G0250_aui_Graphic559_FixedPossessionsCreature04PainRat_Hellhound - k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank, - k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank | k0x8000_randomDrop, 0}; - static uint16 g251FixedPossessionCreature_6screamer[3] = { // @ G0251_aui_Graphic559_FixedPossessionsCreature06Screamer - k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice, - k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice | k0x8000_randomDrop, 0}; - static uint16 g252FixedPossessionCreature_15MagnetaWormWorm[4] = { // @ G0252_aui_Graphic559_FixedPossessionsCreature15MagentaWorm_Worm - k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound, - k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop, - k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop, 0}; - static uint16 g253FixedPossessionCreature_24RedDragon[11] = { // @ G0253_aui_Graphic559_FixedPossessionsCreature24RedDragon - k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, - k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, - k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, - k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, - k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, - k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, - k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, - k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, - k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop, - k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop, 0}; - - uint16 L0356_ui_FixedPossession; - int16 L0357_i_ThingType; - Thing L0358_T_Thing; - uint16* L0359_pui_FixedPossessions; - Weapon* L0360_ps_Weapon; - bool L0361_B_Cursed; - bool L0362_B_WeaponDropped; - - - L0361_B_Cursed = false; - L0362_B_WeaponDropped = false; - switch (creatureType) { - default: - return; - case k12_CreatureTypeSkeleton: - L0359_pui_FixedPossessions = g245FixedPossessionCreature_12Skeleton; - break; - case k9_CreatureTypeStoneGolem: - L0359_pui_FixedPossessions = g246FixedPossessionCreature_9StoneGolem; - break; - case k16_CreatureTypeTrolinAntman: - L0359_pui_FixedPossessions = g247FixedPossessionCreature_16TrolinAntman; - break; - case k18_CreatureTypeAnimatedArmourDethKnight: - L0361_B_Cursed = true; - L0359_pui_FixedPossessions = g248FixedPossessionCreature_18AnimatedArmourDethKnight; - break; - case k7_CreatureTypeRockpile: - L0359_pui_FixedPossessions = g249FixedPossessionCreature_7rockRockPile; - break; - case k4_CreatureTypePainRatHellHound: - L0359_pui_FixedPossessions = g250FixedPossessionCreature_4PainRatHellHound; - break; - case k6_CreatureTypeScreamer: - L0359_pui_FixedPossessions = g251FixedPossessionCreature_6screamer; - break; - case k15_CreatureTypeMagnetaWormWorm: - L0359_pui_FixedPossessions = g252FixedPossessionCreature_15MagnetaWormWorm; - break; - case k24_CreatureTypeRedDragon: - L0359_pui_FixedPossessions = g253FixedPossessionCreature_24RedDragon; - } - while (L0356_ui_FixedPossession = *L0359_pui_FixedPossessions++) { - if (getFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) && _vm->getRandomNumber(2)) - continue; - if (clearFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) >= k127_ObjectInfoIndexFirstJunk) { - L0357_i_ThingType = k10_JunkThingType; - L0356_ui_FixedPossession -= k127_ObjectInfoIndexFirstJunk; - } else { - if (L0356_ui_FixedPossession >= k69_ObjectInfoIndexFirstArmour) { - L0357_i_ThingType = k6_ArmourThingType; - L0356_ui_FixedPossession -= k69_ObjectInfoIndexFirstArmour; - } else { - L0362_B_WeaponDropped = true; - L0357_i_ThingType = k5_WeaponThingType; - L0356_ui_FixedPossession -= k23_ObjectInfoIndexFirstWeapon; - } - } - if ((L0358_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(L0357_i_ThingType)) == Thing::_none) { - continue; - } - L0360_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0358_T_Thing); -/* The same pointer type is used no matter the actual type k5_WeaponThingType, k6_ArmourThingType or k10_JunkThingType */ - L0360_ps_Weapon->setType(L0356_ui_FixedPossession); - L0360_ps_Weapon->setCursed(L0361_B_Cursed); - L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell); - _vm->_movsens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY); - } - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); -} - -int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) { -#define AP0483_i_PrimaryDirection srcMapX - int16 L0556_i_Direction; - - - if (srcMapX == destMapX) { - _vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 1; /* Resulting direction may be 1 or 3 (East or West) */ - if (srcMapY > destMapY) { - return kDirNorth; - } - return kDirSouth; - } - if (srcMapY == destMapY) { - _vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 0; /* Resulting direction may be 0 or 2 (North or South) */ - if (srcMapX > destMapX) { - return kDirWest; - } - return kDirEast; - } - L0556_i_Direction = kDirNorth; - for (;;) { - if (f227_isDestVisibleFromSource(L0556_i_Direction, srcMapX, srcMapY, destMapX, destMapY)) { - if (!f227_isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) { - if ((L0556_i_Direction != kDirNorth) || !f227_isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnPrevVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) { - _vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + L0556_i_Direction); - return L0556_i_Direction; - } - } - if (_vm->getRandomNumber(2)) { - AP0483_i_PrimaryDirection = _vm->_projexpl->_g363_secondaryDirToOrFromParty; - _vm->_projexpl->_g363_secondaryDirToOrFromParty = L0556_i_Direction; - return AP0483_i_PrimaryDirection; - } - return L0556_i_Direction; - } - L0556_i_Direction++; - } -} - -bool GroupMan::f227_isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) { - int L1637_i_Temp; - - switch (dir) { /* If direction is not 'West' then swap variables so that the same test as for west can be applied */ - case kDirSouth: - L1637_i_Temp = srcMapX; - srcMapX = destMapY; - destMapY = L1637_i_Temp; - L1637_i_Temp = destMapX; - destMapX = srcMapY; - srcMapY = L1637_i_Temp; - break; - case kDirEast: - L1637_i_Temp = srcMapX; - srcMapX = destMapX; - destMapX = L1637_i_Temp; - L1637_i_Temp = destMapY; - destMapY = srcMapY; - srcMapY = L1637_i_Temp; - break; - case kDirNorth: - L1637_i_Temp = srcMapX; - srcMapX = srcMapY; - srcMapY = L1637_i_Temp; - L1637_i_Temp = destMapX; - destMapX = destMapY; - destMapY = L1637_i_Temp; - } - return ((srcMapX -= (destMapX - 1)) > 0) && ((((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY) <= srcMapX); -} - -bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack, bool magicAttack, int16 ticks) { - Door* L0573_ps_Door; - byte* L0574_puc_Square; - TimelineEvent L0575_s_Event; - - L0573_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY); - if ((magicAttack && !L0573_ps_Door->isMagicDestructible()) || (!magicAttack && !L0573_ps_Door->isMeleeDestructible())) { - return false; - } - if (attack >= _vm->_dungeonMan->_g275_currMapDoorInfo[L0573_ps_Door->getType()]._defense) { - L0574_puc_Square = &_vm->_dungeonMan->_g271_currMapData[mapX][mapY]; - if (Square(*L0574_puc_Square).getDoorState() == k4_doorState_CLOSED) { - if (ticks) { - M33_setMapAndTime(L0575_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ticks); - L0575_s_Event._type = k2_TMEventTypeDoorDestruction; - L0575_s_Event._priority = 0; - L0575_s_Event._B._location._mapX = mapX; - L0575_s_Event._B._location._mapY = mapY; - _vm->_timeline->f238_addEventGetEventIndex(&L0575_s_Event); - } else { - ((Square*)L0574_puc_Square)->setDoorState(k5_doorState_DESTROYED); - } - return true; - } - } - return false; -} - -Thing GroupMan::f175_groupGetThing(int16 mapX, int16 mapY) { - Thing L0317_T_Thing; - - L0317_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY); - while ((L0317_T_Thing != Thing::_endOfList) && ((L0317_T_Thing).getType() != k4_GroupThingType)) { - L0317_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0317_T_Thing); - } - return L0317_T_Thing; -} - -int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group* group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) { - uint16 L0374_ui_Multiple; -#define AL0374_ui_EventIndex L0374_ui_Multiple -#define AL0374_ui_CreatureIndex L0374_ui_Multiple -#define AL0374_ui_CreatureSize L0374_ui_Multiple -#define AL0374_ui_Attack L0374_ui_Multiple - uint16 L0375_ui_Multiple; -#define AL0375_ui_Outcome L0375_ui_Multiple -#define AL0375_ui_EventType L0375_ui_Multiple -#define AL0375_ui_NextCreatureIndex L0375_ui_Multiple - CreatureInfo* L0376_ps_CreatureInfo; - TimelineEvent* L0377_ps_Event; - ActiveGroup* L0378_ps_ActiveGroup = nullptr; - uint16 L0379_ui_CreatureCount; - uint16 L0380_ui_Multiple = 0; -#define AL0380_ui_CreatureType L0380_ui_Multiple -#define AL0380_ui_FearResistance L0380_ui_Multiple - uint16 L0381_ui_GroupCells; - uint16 L0382_ui_GroupDirections; - bool L0383_B_CurrentMapIsPartyMap; - uint16 L0384_ui_Cell; - - - L0376_ps_CreatureInfo = &g243_CreatureInfo[AL0380_ui_CreatureType = group->_type]; - if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) /* Lord Chaos cannot be damaged */ - goto T0190024; - if (group->_health[creatureIndex] <= damage) { - L0381_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(group, _vm->_dungeonMan->_g272_currMapIndex); - L0384_ui_Cell = (L0381_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0381_ui_GroupCells, creatureIndex); - if (!(L0379_ui_CreatureCount = group->getCount())) { /* If there is a single creature in the group */ - if (notMoving) { - f188_dropGroupPossessions(mapX, mapY, _vm->_groupMan->f175_groupGetThing(mapX, mapY), k2_soundModePlayOneTickLater); - f189_delete(mapX, mapY); - } - AL0375_ui_Outcome = k2_outcomeKilledAllCreaturesInGroup; - } else { /* If there are several creatures in the group */ - L0382_ui_GroupDirections = _vm->_groupMan->f147_getGroupDirections(group, _vm->_dungeonMan->_g272_currMapIndex); - if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) { - if (notMoving) { - f186_dropCreatureFixedPossessions(AL0380_ui_CreatureType, mapX, mapY, L0384_ui_Cell, k2_soundModePlayOneTickLater); - } else { - _g392_dropMovingCreatureFixedPossessionsCell[_g391_dropMovingCreatureFixedPossCellCount++] = L0384_ui_Cell; - } - } - if (L0383_B_CurrentMapIsPartyMap = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) { - L0378_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]; - } - if (group->getBehaviour() == k6_behavior_ATTACK) { - L0377_ps_Event = _vm->_timeline->_g370_events; - for (AL0374_ui_EventIndex = 0; AL0374_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; AL0374_ui_EventIndex++) { - if ((M29_map(L0377_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) && - (L0377_ps_Event->_B._location._mapX == mapX) && - (L0377_ps_Event->_B._location._mapY == mapY) && - ((AL0375_ui_EventType = L0377_ps_Event->_type) > k32_TMEventTypeUpdateAspectGroup) && - (AL0375_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1)) { - if (AL0375_ui_EventType < k37_TMEventTypeUpdateBehaviourGroup) { - AL0375_ui_EventType -= k33_TMEventTypeUpdateAspectCreature_0; /* Get creature index for events 33 to 36 */ - } else { - AL0375_ui_EventType -= k38_TMEventTypeUpdateBehaviour_0; /* Get creature index for events 38 to 41 */ - } - if (AL0375_ui_NextCreatureIndex == creatureIndex) { - _vm->_timeline->f237_deleteEvent(AL0374_ui_EventIndex); - } else { - if (AL0375_ui_NextCreatureIndex > creatureIndex) { - L0377_ps_Event->_type -= 1; - _vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(AL0374_ui_EventIndex)); - } - } - } - L0377_ps_Event++; - } - if (L0383_B_CurrentMapIsPartyMap && ((AL0380_ui_FearResistance = L0376_ps_CreatureInfo->M57_getFearResistance()) != k15_immuneToFear) && ((AL0380_ui_FearResistance += L0379_ui_CreatureCount - 1) < (_vm->getRandomNumber(16)))) { /* Test if the death of a creature frigthens the remaining creatures in the group */ - L0378_ps_ActiveGroup->_delayFleeingFromTarget = _vm->getRandomNumber(100 - (AL0380_ui_FearResistance << 2)) + 20; - group->setBehaviour(k5_behavior_FLEE); - } - } - for (AL0375_ui_NextCreatureIndex = AL0374_ui_CreatureIndex = creatureIndex; AL0374_ui_CreatureIndex < L0379_ui_CreatureCount; AL0374_ui_CreatureIndex++) { - AL0375_ui_NextCreatureIndex++; - group->_health[AL0374_ui_CreatureIndex] = group->_health[AL0375_ui_NextCreatureIndex]; - L0382_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0382_ui_GroupDirections, AL0374_ui_CreatureIndex, _vm->_groupMan->M50_getCreatureValue(L0382_ui_GroupDirections, AL0375_ui_NextCreatureIndex)); - L0381_ui_GroupCells = f178_getGroupValueUpdatedWithCreatureValue(L0381_ui_GroupCells, AL0374_ui_CreatureIndex, _vm->_groupMan->M50_getCreatureValue(L0381_ui_GroupCells, AL0375_ui_NextCreatureIndex)); - if (L0383_B_CurrentMapIsPartyMap) { - L0378_ps_ActiveGroup->_aspect[AL0374_ui_CreatureIndex] = L0378_ps_ActiveGroup->_aspect[AL0375_ui_NextCreatureIndex]; - } - } - L0381_ui_GroupCells &= 0x003F; - _vm->_dungeonMan->f146_setGroupCells(group, L0381_ui_GroupCells, _vm->_dungeonMan->_g272_currMapIndex); - _vm->_dungeonMan->f148_setGroupDirections(group, L0382_ui_GroupDirections, _vm->_dungeonMan->_g272_currMapIndex); - group->setCount(group->getCount() - 1); - AL0375_ui_Outcome = k1_outcomeKilledSomeCreaturesInGroup; - } - if ((AL0374_ui_CreatureSize = getFlag(L0376_ps_CreatureInfo->_attributes, k0x0003_MaskCreatureInfo_size)) == k0_MaskCreatureSizeQuarter) { - AL0374_ui_Attack = 110; - } else { - if (AL0374_ui_CreatureSize == k1_MaskCreatureSizeHalf) { - AL0374_ui_Attack = 190; - } else { - AL0374_ui_Attack = 255; - } - } - _vm->_projexpl->f213_explosionCreate(Thing::_explSmoke, AL0374_ui_Attack, mapX, mapY, L0384_ui_Cell); /* BUG0_66 Smoke is placed on the source map instead of the destination map when a creature dies by falling through a pit. The game has a special case to correctly drop the creature possessions on the destination map but there is no such special case for the smoke. Note that the death must be caused by the damage of the fall (there is no smoke if the creature is removed because its type is not allowed on the destination map). However this bug has no visible consequence because of BUG0_26: the smoke explosion falls in the pit right after being placed in the dungeon and before being drawn on screen so it is only visible on the destination square */ - return AL0375_ui_Outcome; - } - if (damage > 0) { - group->_health[creatureIndex] -= damage; - } -T0190024: - return k0_outcomeKilledNoCreaturesInGroup; -} - -void GroupMan::f189_delete(int16 mapX, int16 mapY) { - Thing L0372_T_GroupThing; - Group* L0373_ps_Group; - - - if ((L0372_T_GroupThing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) { - return; - } - L0373_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0372_T_GroupThing); - for (uint16 i = 0; i < 4; ++i) - L0373_ps_Group->_health[i] = 0; - _vm->_movsens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0); - L0373_ps_Group->_nextThing = Thing::_none; - if (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) { - _vm->_groupMan->_g375_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1; - _g377_currActiveGroupCount--; - } - f181_groupDeleteEvents(mapX, mapY); -} - -void GroupMan::f181_groupDeleteEvents(int16 mapX, int16 mapY) { - int16 L0334_i_EventIndex; - uint16 L0335_ui_EventType; - TimelineEvent* L0336_ps_Event; - - - L0336_ps_Event = _vm->_timeline->_g370_events; - for (L0334_i_EventIndex = 0; L0334_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0334_i_EventIndex++) { - if ((M29_map(L0336_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) && - ((L0335_ui_EventType = L0336_ps_Event->_type) > k29_TMEventTypeGroupReactionDangerOnSquare - 1) && (L0335_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1) && - (L0336_ps_Event->_B._location._mapX == mapX) && (L0336_ps_Event->_B._location._mapY == mapY)) { - _vm->_timeline->f237_deleteEvent(L0334_i_EventIndex); - } - L0336_ps_Event++; - } -} - -uint16 GroupMan::f178_getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatreVal) { - creatreVal &= 0x0003; - creatreVal <<= (creatureIndex <<= 1); - return creatreVal | (groupVal & ~(3 << creatreVal)); -} - -int16 GroupMan::f191_getDamageAllCreaturesOutcome(Group* group, int16 mapX, int16 mapY, int16 attack, bool notMoving) { - uint16 L0385_ui_RandomAttack; - int16 L0386_i_CreatureIndex; - int16 L0387_i_Outcome; - bool L0388_B_KilledSomeCreatures; - bool L0389_B_KilledAllCreatures; - - - L0388_B_KilledSomeCreatures = false; - L0389_B_KilledAllCreatures = true; - _g391_dropMovingCreatureFixedPossCellCount = 0; - if (attack > 0) { - L0386_i_CreatureIndex = group->getCount(); - attack -= (L0385_ui_RandomAttack = (attack >> 3) + 1); - L0385_ui_RandomAttack <<= 1; - do { - L0389_B_KilledAllCreatures = (L0387_i_Outcome = f190_groupGetDamageCreatureOutcome(group, L0386_i_CreatureIndex, mapX, mapY, attack + _vm->getRandomNumber(L0385_ui_RandomAttack), notMoving)) && L0389_B_KilledAllCreatures; - L0388_B_KilledSomeCreatures = L0388_B_KilledSomeCreatures || L0387_i_Outcome; - } while (L0386_i_CreatureIndex--); - if (L0389_B_KilledAllCreatures) { - return k2_outcomeKilledAllCreaturesInGroup; - } - if (L0388_B_KilledSomeCreatures) { - return k1_outcomeKilledSomeCreaturesInGroup; - } - return k0_outcomeKilledNoCreaturesInGroup; - } else { - return k0_outcomeKilledNoCreaturesInGroup; - } -} - -int16 GroupMan::f192_groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack) { - int16 L0390_i_PoisonResistance; - - - if (!poisonAttack || ((L0390_i_PoisonResistance = g243_CreatureInfo[creatreType].M61_poisonResistance()) == k15_immuneToPoison)) { - return 0; - } - return ((poisonAttack + _vm->getRandomNumber(4)) << 3) / ++L0390_i_PoisonResistance; -} - -void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks) { - Group* L0444_ps_Group; - ActiveGroup* L0445_ps_ActiveGroup; - int16 L0446_i_Multiple; -#define AL0446_i_EventType L0446_i_Multiple -#define AL0446_i_Direction L0446_i_Multiple -#define AL0446_i_Ticks L0446_i_Multiple -#define AL0446_i_Distance L0446_i_Multiple -#define AL0446_i_Behavior2Or3 L0446_i_Multiple -#define AL0446_i_CreatureAspectIndex L0446_i_Multiple -#define AL0446_i_Range L0446_i_Multiple -#define AL0446_i_CreatureAttributes L0446_i_Multiple -#define AL0446_i_Cell L0446_i_Multiple -#define AL0446_i_GroupCellsCriteria L0446_i_Multiple - int16 L0447_i_Multiple; -#define AL0447_i_Behavior L0447_i_Multiple -#define AL0447_i_CreatureIndex L0447_i_Multiple -#define AL0447_i_ReferenceDirection L0447_i_Multiple -#define AL0447_i_Ticks L0447_i_Multiple - CreatureInfo L0448_s_CreatureInfo; - Thing L0449_T_GroupThing; - int16 L0450_i_Multiple; -#define AL0450_i_DestinationMapX L0450_i_Multiple -#define AL0450_i_DistanceXToParty L0450_i_Multiple -#define AL0450_i_TargetMapX L0450_i_Multiple - int16 L0451_i_Multiple; -#define AL0451_i_DestinationMapY L0451_i_Multiple -#define AL0451_i_DistanceYToParty L0451_i_Multiple -#define AL0451_i_TargetMapY L0451_i_Multiple - int16 L0452_i_DistanceToVisibleParty = 0; - bool L0453_B_NewGroupDirectionFound; - int16 L0454_i_PrimaryDirectionToOrFromParty; - bool L0455_B_CurrentEventTypeIsNotUpdateBehavior; - bool L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls; - bool L0457_B_MoveToPriorLocation; - bool L0458_B_SetBehavior7_ApproachAfterReaction = false; - int16 L0459_i_CreatureSize; - uint16 L0460_ui_CreatureCount; - int16 L0461_i_MovementTicks; - int16 L0462_i_TicksSinceLastMove; - bool L0463_B_Archenemy; - int32 L0464_l_NextAspectUpdateTime; - TimelineEvent L0465_s_NextEvent; - - - /* If the party is not on the map specified in the event and the event type is not one of 32, 33, 37, 38 then the event is ignored */ - if ((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) && ((AL0446_i_EventType = eventType) != k37_TMEventTypeUpdateBehaviourGroup) && (AL0446_i_EventType != k32_TMEventTypeUpdateAspectGroup) && (AL0446_i_EventType != k38_TMEventTypeUpdateBehaviour_0) && (AL0446_i_EventType != k33_TMEventTypeUpdateAspectCreature_0)) - goto T0209139_Return; - /* If there is no creature at the location specified in the event then the event is ignored */ - if ((L0449_T_GroupThing = _vm->_groupMan->f175_groupGetThing(eventMapX, eventMapY)) == Thing::_endOfList) { - goto T0209139_Return; - } - L0444_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0449_T_GroupThing); - L0448_s_CreatureInfo = g243_CreatureInfo[L0444_ps_Group->_type]; - /* Update the event */ - M33_setMapAndTime(L0465_s_NextEvent._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime); - L0465_s_NextEvent._priority = 255 - L0448_s_CreatureInfo._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */ - L0465_s_NextEvent._B._location._mapX = eventMapX; - L0465_s_NextEvent._B._location._mapY = eventMapY; - /* If the creature is not on the party map then try and move the creature in a random direction and place a new event 37 in the timeline for the next creature movement */ - if (_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) { - if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->getRandomNumber(4), false)) { /* BUG0_67 A group that is not on the party map may wrongly move or not move into a teleporter. Normally, a creature type with Wariness >= 10 (Vexirk, Materializer / Zytaz, Demon, Lord Chaos, Red Dragon / Dragon) would only move into a teleporter if the creature type is allowed on the destination map. However, the variable G0380_T_CurrentGroupThing identifying the group is not set before being used by F0139_DUNGEON_IsCreatureAllowedOnMap called by f202_isMovementPossible so the check to see if the creature type is allowed may operate on another creature type and thus return an incorrect result, causing the creature to teleport while it should not, or not to teleport while it should */ - AL0450_i_DestinationMapX = eventMapX; - AL0451_i_DestinationMapY = eventMapY; - AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction]; - if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY)) - goto T0209139_Return; - L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX; - L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY; - } - L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup; - AL0446_i_Ticks = MAX(ABS(_vm->_dungeonMan->_g272_currMapIndex - _vm->_dungeonMan->_g309_partyMapIndex) << 4, L0448_s_CreatureInfo._movementTicks << 1); - /* BUG0_68 A group moves or acts with a wrong timing. Event is added below but L0465_s_NextEvent.C.Ticks has not been initialized. No consequence while the group is not on the party map. When the party enters the group map the first group event may have a wrong timing */ -T0209005_AddEventAndReturn: - L0465_s_NextEvent._mapTime += AL0446_i_Ticks; - _vm->_timeline->f238_addEventGetEventIndex(&L0465_s_NextEvent); - goto T0209139_Return; - } - /* If the creature is Lord Chaos then ignore the event if the game is won. Initialize data to analyze Fluxcages */ - if (L0463_B_Archenemy = getFlag(L0448_s_CreatureInfo._attributes, k0x2000_MaskCreatureInfo_archenemy)) { - if (_vm->_g302_gameWon) { - goto T0209139_Return; - } - _g386_fluxCageCount = 0; - _g385_fluxCages[0] = 0; - } - L0445_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[L0444_ps_Group->getActiveGroupIndex()]; - if ((L0462_i_TicksSinceLastMove = (unsigned char)_vm->_g313_gameTime - L0445_ps_ActiveGroup->_lastMoveTime) < 0) { - L0462_i_TicksSinceLastMove += 256; - } - if ((L0461_i_MovementTicks = L0448_s_CreatureInfo._movementTicks) == k255_immobile) { - L0461_i_MovementTicks = 100; - } - if (_vm->_championMan->_g407_party._freezeLifeTicks && !L0463_B_Archenemy) { /* If life is frozen and the creature is not Lord Chaos (Lord Chaos is immune to Freeze Life) then reschedule the event later (except for reactions which are ignored when life if frozen) */ - if (eventType < 0) - goto T0209139_Return; - L0465_s_NextEvent._type = eventType; - L0465_s_NextEvent._C._ticks = ticks; - AL0446_i_Ticks = 4; /* Retry in 4 ticks */ - goto T0209005_AddEventAndReturn; - } - /* If the specified event type is a 'reaction' instead of a real event from the timeline then create the corresponding reaction event with a delay: - For event kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, the reaction time is 1 tick - For event kM2_TMEventTypeCreateReactionEvent30HitByProjectile and kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, the reaction time may be 1 tick or slower: slow moving creatures react more slowly. The more recent is the last creature move, the slower the reaction */ - if (eventType < 0) { - L0465_s_NextEvent._type = eventType + k32_TMEventTypeUpdateAspectGroup; - if ((eventType == kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) || ((AL0446_i_Ticks = ((L0461_i_MovementTicks + 2) >> 2) - L0462_i_TicksSinceLastMove) < 1)) { /* AL0446_i_Ticks is the reaction time */ - AL0446_i_Ticks = 1; /* Retry in 1 tick */ - } - goto T0209005_AddEventAndReturn; /* BUG0_68 A group moves or acts with a wrong timing. Event is added but L0465_s_NextEvent.C.Ticks has not been initialized */ - } - AL0447_i_Behavior = L0444_ps_Group->getBehaviour(); - L0460_ui_CreatureCount = L0444_ps_Group->getCount(); - L0459_i_CreatureSize = getFlag(L0448_s_CreatureInfo._attributes, k0x0003_MaskCreatureInfo_size); - AL0450_i_DistanceXToParty = ((AL0446_i_Distance = eventMapX - _vm->_dungeonMan->_g306_partyMapX) < 0) ? -AL0446_i_Distance : AL0446_i_Distance; - AL0451_i_DistanceYToParty = ((AL0446_i_Distance = eventMapY - _vm->_dungeonMan->_g307_partyMapY) < 0) ? -AL0446_i_Distance : AL0446_i_Distance; - _g378_currentGroupMapX = eventMapX; - _g379_currentGroupMapY = eventMapY; - _g380_currGroupThing = L0449_T_GroupThing; - _g384_groupMovementTestedDirections[0] = 0; - _g381_currGroupDistanceToParty = f226_getDistanceBetweenSquares(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); - _g382_currGroupPrimaryDirToParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); - _g383_currGroupSecondaryDirToParty = _vm->_projexpl->_g363_secondaryDirToOrFromParty; - L0464_l_NextAspectUpdateTime = 0; - L0455_B_CurrentEventTypeIsNotUpdateBehavior = true; - if (eventType <= k31_TMEventTypeGroupReactionPartyIsAdjecent) { /* Process Reaction events 29 to 31 */ - switch (eventType = eventType - k32_TMEventTypeUpdateAspectGroup) { - case kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent: /* This event is used when the party bumps into a group or attacks a group physically (not with a spell). It causes the creature behavior to change to attack if it is not already attacking the party or fleeing from target */ - if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) { - f181_groupDeleteEvents(eventMapX, eventMapY); - goto T0209044_SetBehavior6_Attack; - } - L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; - L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; - goto T0209139_Return; - case kM2_TMEventTypeCreateReactionEvent30HitByProjectile: /* This event is used for the reaction of a group after a projectile impacted with one creature in the group (some creatures may have been killed) */ - if ((AL0447_i_Behavior == k6_behavior_ATTACK) || (AL0447_i_Behavior == k5_behavior_FLEE)) /* If the creature is attacking the party or fleeing from the target then there is no reaction */ - goto T0209139_Return; - if ((AL0446_i_Behavior2Or3 = ((AL0447_i_Behavior == k3_behavior_USELESS) || (AL0447_i_Behavior == k2_behavior_USELESS))) || (_vm->getRandomNumber(4))) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances */ - if (!f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { /* If the group cannot see the party then look in a random direction to try and search for the party */ - L0458_B_SetBehavior7_ApproachAfterReaction = L0453_B_NewGroupDirectionFound = false; - goto T0209073_SetDirectionGroup; - } - if (AL0446_i_Behavior2Or3 || (_vm->getRandomNumber(4))) /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances then no reaction */ - goto T0209139_Return; - } /* No 'break': proceed to instruction after the next 'case' below. Reaction is to move in a random direction to try and avoid other projectiles */ - case kM3_TMEventTypeCreateReactionEvent29DangerOnSquare: /* This event is used when some creatures in the group were killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by 3 Fluxcages. It causes the creature to move in a random direction to avoid the danger */ - L0458_B_SetBehavior7_ApproachAfterReaction = (AL0447_i_Behavior == k6_behavior_ATTACK); /* If the creature behavior is 'Attack' and it has to move to avoid danger then it will change its behavior to 'Approach' after the movement */ - L0453_B_NewGroupDirectionFound = false; - goto T0209058_MoveInRandomDirection; - } - } - if (eventType < k37_TMEventTypeUpdateBehaviourGroup) { /* Process Update Aspect events 32 to 36 */ - L0465_s_NextEvent._type = eventType + 5; - if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { - if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) { - if (M38_distance(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, eventMapX, eventMapY) <= 1) - goto T0209044_SetBehavior6_Attack; - if (((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k3_behavior_USELESS)) && (AL0447_i_Behavior != k7_behavior_APPROACH)) /* BUG0_00 Useless code. Behavior cannot be 3 because this value is never used. Moreover, the second condition in the && is redundant (if the value is 0 or 3, it cannot be 7). The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */ - goto T0209054_SetBehavior7_Approach; - } - L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; - L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; - } - if (AL0447_i_Behavior == k6_behavior_ATTACK) { - AL0446_i_CreatureAspectIndex = eventType - k33_TMEventTypeUpdateAspectCreature_0; /* Value -1 for event 32, meaning aspect will be updated for all creatures in the group */ - L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0446_i_CreatureAspectIndex, getFlag(L0445_ps_ActiveGroup->_aspect[AL0446_i_CreatureAspectIndex], k0x0080_MaskActiveGroupIsAttacking)); - goto T0209136; - } - if ((AL0450_i_DistanceXToParty > 3) || (AL0451_i_DistanceYToParty > 3)) { - L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime + ((L0448_s_CreatureInfo._animationTicks >> 4) & 0xF); - goto T0209136; - } - } else { /* Process Update Behavior events 37 to 41 */ - L0455_B_CurrentEventTypeIsNotUpdateBehavior = false; - if (ticks) { - L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime; - } - if (eventType == k37_TMEventTypeUpdateBehaviourGroup) { /* Process event 37, Update Group Behavior */ - if ((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k2_behavior_USELESS) || (AL0447_i_Behavior == k3_behavior_USELESS)) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */ - if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { - if ((L0452_i_DistanceToVisibleParty <= (L0448_s_CreatureInfo.M56_getAttackRange())) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) { /* If the creature is in range for attack and on the same row or column as the party on the map */ -T0209044_SetBehavior6_Attack: - if (eventType == kM2_TMEventTypeCreateReactionEvent30HitByProjectile) { - f181_groupDeleteEvents(eventMapX, eventMapY); - } - L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; - L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; - L0444_ps_Group->setBehaviour(k6_behavior_ATTACK); - AL0446_i_Direction = _g382_currGroupPrimaryDirToParty; - for (AL0447_i_CreatureIndex = L0460_ui_CreatureCount; AL0447_i_CreatureIndex >= 0; AL0447_i_CreatureIndex--) { - if ((_vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) != AL0446_i_Direction) && - ((!AL0447_i_CreatureIndex) || (!_vm->getRandomNumber(2)))) { - f205_setDirection(L0445_ps_ActiveGroup, AL0446_i_Direction, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf)); - M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + _vm->getRandomNumber(4) + 2); /* Random delay represents the time for the creature to turn */ - } else { - M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + 1); - } - if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) { - L0465_s_NextEvent._mapTime += MIN((uint16)((L0448_s_CreatureInfo._attackTicks >> 1) + _vm->getRandomNumber(4)), ticks); - } - L0465_s_NextEvent._type = k38_TMEventTypeUpdateBehaviour_0 + AL0447_i_CreatureIndex; - f208_groupAddEvent(&L0465_s_NextEvent, f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false)); - } - goto T0209139_Return; - } - if (AL0447_i_Behavior != k2_behavior_USELESS) { /* BUG0_00 Useless code. Behavior cannot be 2 because this value is never used */ -T0209054_SetBehavior7_Approach: - L0444_ps_Group->setBehaviour(k7_behavior_APPROACH); - L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; - L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; - L0465_s_NextEvent._mapTime += 1; - goto T0209134_SetEvent37; - } - } else { - if (AL0447_i_Behavior == k0_behavior_WANDER) { - if (L0454_i_PrimaryDirectionToOrFromParty = f201_getSmelledPartyPrimaryDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY)) { - L0454_i_PrimaryDirectionToOrFromParty--; - L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = false; - goto T0209085_SingleSquareMove; - } - L0453_B_NewGroupDirectionFound = false; - if (_vm->getRandomNumber(2)) { -T0209058_MoveInRandomDirection: - AL0446_i_Direction = _vm->getRandomNumber(4); - AL0447_i_ReferenceDirection = AL0446_i_Direction; - L0457_B_MoveToPriorLocation = false; - do { - AL0450_i_DestinationMapX = eventMapX; - AL0451_i_DestinationMapY = eventMapY; - AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction]; - if (((L0445_ps_ActiveGroup->_priorMapX != AL0450_i_DestinationMapX) || - (L0445_ps_ActiveGroup->_priorMapY != AL0451_i_DestinationMapY) || - (L0457_B_MoveToPriorLocation = !_vm->getRandomNumber(4))) /* 1/4 chance of moving back to the square that the creature comes from */ - && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction, false)) { -T0209061_MoveGroup: - if (L0453_B_NewGroupDirectionFound = ((AL0447_i_Ticks = (L0461_i_MovementTicks >> 1) - L0462_i_TicksSinceLastMove) <= 0)) { - if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY)) - goto T0209139_Return; - L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX; - L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY;; - L0445_ps_ActiveGroup->_priorMapX = eventMapX; - L0445_ps_ActiveGroup->_priorMapY = eventMapY; - L0445_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime; - } else { - L0461_i_MovementTicks = AL0447_i_Ticks; - L0462_i_TicksSinceLastMove = -1; - } - break; - } - if (_g390_groupMovementBlockedByParty) { - if ((eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) && - ((L0444_ps_Group->getBehaviour() != k5_behavior_FLEE) || - !f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false) || - _vm->getRandomNumber(2))) - goto T0209044_SetBehavior6_Attack; - L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; - L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; - } - } while ((AL0446_i_Direction = returnNextVal(AL0446_i_Direction)) != AL0447_i_ReferenceDirection); - } - if (!L0453_B_NewGroupDirectionFound && - (L0462_i_TicksSinceLastMove != -1) && - L0463_B_Archenemy && - ((eventType == kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) || !_vm->getRandomNumber(4))) { /* BUG0_15 The game hangs when you close a door on Lord Chaos. A condition is missing in the code to manage creatures and this may create an infinite loop between two parts in the code */ - _vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0454_i_PrimaryDirectionToOrFromParty = _vm->getRandomNumber(4)); - goto T0209089_DoubleSquareMove; /* BUG0_69 Memory corruption when you close a door on Lord Chaos. The local variable (L0454_i_PrimaryDirectionToOrFromParty) containing the direction where Lord Chaos tries to move may be used as an array index without being initialized and cause memory corruption */ - } - if (L0453_B_NewGroupDirectionFound || ((!_vm->getRandomNumber(4) || (L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M55_getSmellRange())) && (eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare))) { -T0209073_SetDirectionGroup: - if (!L0453_B_NewGroupDirectionFound && (L0462_i_TicksSinceLastMove >= 0)) { /* If direction is not found yet then look around in a random direction */ - AL0446_i_Direction = _vm->getRandomNumber(4); - } - f206_groupSetDirGroup(L0445_ps_ActiveGroup, AL0446_i_Direction, L0460_ui_CreatureCount, L0459_i_CreatureSize); - } - /* If event is kM3_TMEventTypeCreateReactionEvent29DangerOnSquare or kM2_TMEventTypeCreateReactionEvent30HitByProjectile */ - if (eventType < kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) { - if (!L0453_B_NewGroupDirectionFound) - goto T0209139_Return; - if (L0458_B_SetBehavior7_ApproachAfterReaction) { - L0444_ps_Group->setBehaviour(k7_behavior_APPROACH); - } - f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY); - } - } - } - } else { - if (AL0447_i_Behavior == k7_behavior_APPROACH) { - if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { - if ((L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M56_getAttackRange()) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) /* If the creature is in range for attack and on the same row or column as the party on the map */ - goto T0209044_SetBehavior6_Attack; -T0209081_RunTowardParty: - L0461_i_MovementTicks++; - L0461_i_MovementTicks = L0461_i_MovementTicks >> 1; /* Running speed is half the movement ticks */ - AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX); - AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY); - } else { -T0209082_WalkTowardTarget: - AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX; - AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY; - /* If the creature reached its target but the party is not there anymore */ - if ((eventMapX == AL0450_i_TargetMapX) && (eventMapY == AL0451_i_TargetMapY)) { - L0453_B_NewGroupDirectionFound = false; - L0444_ps_Group->setBehaviour(k0_behavior_WANDER); - goto T0209073_SetDirectionGroup; - } - } - L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true; -T0209084_SingleSquareMoveTowardParty: - L0454_i_PrimaryDirectionToOrFromParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY); -T0209085_SingleSquareMove: - if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls) || - f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls && _vm->getRandomNumber(2)) || - f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction), false) || - (!_vm->getRandomNumber(4) && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty), false))) { - AL0450_i_DestinationMapX = eventMapX; - AL0451_i_DestinationMapY = eventMapY; - AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction]; - goto T0209061_MoveGroup; - } - if (L0463_B_Archenemy) { -T0209089_DoubleSquareMove: - f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false); /* BUG0_00 Useless code. Returned value is ignored. When Lord Chaos teleports two squares away the ability to move to the first square is ignored which means Lord Chaos can teleport through walls or any other obstacle */ - if (f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty) || - f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty) || - (_g386_fluxCageCount && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction))) || - ((_g386_fluxCageCount >= 2) && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty)))) { - AL0450_i_DestinationMapX = eventMapX; - AL0451_i_DestinationMapY = eventMapY; - AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2; - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); - goto T0209061_MoveGroup; - } - } - f206_groupSetDirGroup(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, L0460_ui_CreatureCount, L0459_i_CreatureSize); - } else { - if (AL0447_i_Behavior == k5_behavior_FLEE) { -T0209094_FleeFromTarget: - L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true; - /* If the creature can see the party then update target coordinates */ - if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { - AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX); - AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY); - } else { - if (!(--(L0445_ps_ActiveGroup->_delayFleeingFromTarget))) { /* If the creature is not afraid anymore then stop fleeing from target */ -T0209096_SetBehavior0_Wander: - L0453_B_NewGroupDirectionFound = false; - L0444_ps_Group->setBehaviour(k0_behavior_WANDER); - goto T0209073_SetDirectionGroup; - } - if (_vm->getRandomNumber(2)) { - /* If the creature cannot move and the party is adjacent then stop fleeing */ - if (!f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false)) { - if (M38_distance(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1) - goto T0209096_SetBehavior0_Wander; - } - /* Set creature target to the home square where the creature was located when the party entered the map */ - AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_homeMapX; - AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_homeMapY; - goto T0209084_SingleSquareMoveTowardParty; - } - AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX; - AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY; - } - /* Try and flee from the party (opposite direction) */ - L0454_i_PrimaryDirectionToOrFromParty = returnOppositeDir((direction)f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY)); - _vm->_projexpl->_g363_secondaryDirToOrFromParty = returnOppositeDir((direction)_vm->_projexpl->_g363_secondaryDirToOrFromParty); - L0461_i_MovementTicks -= (L0461_i_MovementTicks >> 2); - goto T0209085_SingleSquareMove; - } - } - } - } else { /* Process events 38 to 41, Update Creature Behavior */ - if (AL0447_i_Behavior == k5_behavior_FLEE) { - if (L0460_ui_CreatureCount) { - f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY); - } - goto T0209094_FleeFromTarget; - } - /* If the creature is attacking, then compute the next aspect update time and the next attack time */ - if (getFlag(L0445_ps_ActiveGroup->_aspect[AL0447_i_CreatureIndex = eventType - k38_TMEventTypeUpdateBehaviour_0], k0x0080_MaskActiveGroupIsAttacking)) { - L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false); - L0465_s_NextEvent._mapTime += ((AL0447_i_Ticks = L0448_s_CreatureInfo._attackTicks) + _vm->getRandomNumber(4) - 1); - if (AL0447_i_Ticks > 15) { - L0465_s_NextEvent._mapTime += _vm->getRandomNumber(8) - 2; - } - } else { /* If the creature is not attacking, then try attacking if possible */ - if (AL0447_i_CreatureIndex > L0460_ui_CreatureCount) { /* Ignore event if it is for a creature that is not in the group */ - goto T0209139_Return; - } - L0454_i_PrimaryDirectionToOrFromParty = _g382_currGroupPrimaryDirToParty; - /* If the party is visible, update the target coordinates */ - if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, AL0447_i_CreatureIndex, eventMapX, eventMapY)) { - L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; - L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; - } - /* If there is a single creature in the group that is not full square sized and 1/4 chance */ - if (!L0460_ui_CreatureCount && (L0459_i_CreatureSize != k2_MaskCreatureSizeFull) && !((AL0446_i_GroupCellsCriteria = _vm->getRandomNumber(65536)) & 0x00C0)) { - if (L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) { - /* If the creature is not already on the center of the square then change its cell */ - if (AL0446_i_GroupCellsCriteria & 0x0038) { /* 7/8 chances of changing cell to the center of the square */ - L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature; - } else { /* 1/8 chance of changing cell to the next or previous cell on the square */ - AL0446_i_GroupCellsCriteria = M21_normalizeModulo4(M21_normalizeModulo4(L0445_ps_ActiveGroup->_cells) + ((AL0446_i_GroupCellsCriteria & 0x0001) ? 1 : -1)); - } - } - /* If 1/8 chance and the creature is not adjacent to the party and is a quarter square sized creature then process projectile impacts and update the creature cell if still alive. When the creature is not in front of the party, it has 7/8 chances of dodging a projectile by moving to another cell or staying in the center of the square */ - if (!(AL0446_i_GroupCellsCriteria & 0x0038) && (L0452_i_DistanceToVisibleParty != 1) && (L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter)) { - if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* This call to F0218_PROJECTILE_GetImpactCount works fine because there is a single creature in the group so L0445_ps_ActiveGroup->Cells contains only one cell index */ - goto T0209139_Return; - L0445_ps_ActiveGroup->_cells = M21_normalizeModulo4(AL0446_i_GroupCellsCriteria); - } - } - /* If the creature can see the party and is looking in the party direction or can attack in all direction */ - if (L0452_i_DistanceToVisibleParty && - (getFlag(L0448_s_CreatureInfo._attributes, k0x0004_MaskCreatureInfo_sideAttack) || - _vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) == L0454_i_PrimaryDirectionToOrFromParty)) { - /* If the creature is in range to attack the party and random test succeeds */ - if ((L0452_i_DistanceToVisibleParty <= (AL0446_i_Range = L0448_s_CreatureInfo.M56_getAttackRange())) && - (!AL0450_i_DistanceXToParty || !AL0451_i_DistanceYToParty) && - (AL0446_i_Range <= (_vm->getRandomNumber(16) + 1))) { - if ((AL0446_i_Range == 1) && - (!getFlag(AL0446_i_CreatureAttributes = L0448_s_CreatureInfo._attributes, k0x0008_MaskCreatureInfo_preferBackRow) || !_vm->getRandomNumber(4) || !getFlag(AL0446_i_CreatureAttributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) && - (L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter) && - (L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) && - ((AL0446_i_Cell = _vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex)) != L0454_i_PrimaryDirectionToOrFromParty) && - (AL0446_i_Cell != returnNextVal(L0454_i_PrimaryDirectionToOrFromParty))) { /* If the creature cannot cast spells (range = 1) and is not on a cell where it can attack the party directly and is a quarter square sized creature not in the center of the square then the creature moves to another cell and attack does not occur immediately */ - if (!L0460_ui_CreatureCount && _vm->getRandomNumber(2)) { - L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature; - } else { - if ((L0454_i_PrimaryDirectionToOrFromParty & 0x0001) == (AL0446_i_Cell & 0x0001)) { - AL0446_i_Cell--; - } else { - AL0446_i_Cell++; - } - if (!_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = M21_normalizeModulo4(AL0446_i_Cell)) || - (_vm->getRandomNumber(2) && !_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */ - if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */ - goto T0209139_Return; - if (_vm->_projexpl->_g364_creatureDamageOutcome != k1_outcomeKilledSomeCreaturesInGroup) { - L0445_ps_ActiveGroup->_cells = f178_getGroupValueUpdatedWithCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex, AL0446_i_Cell); - } - } - } - L0465_s_NextEvent._mapTime += MAX(1, (L0448_s_CreatureInfo._movementTicks >> 1) + _vm->getRandomNumber(2)); /* Time for the creature to change cell */ - L0465_s_NextEvent._type = eventType; - goto T0209135; - } - L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, f207_isCreatureAttacking(L0444_ps_Group, eventMapX, eventMapY, AL0447_i_CreatureIndex)); - L0465_s_NextEvent._mapTime += (L0448_s_CreatureInfo._animationTicks & 0xF) + _vm->getRandomNumber(2); - } else { - L0444_ps_Group->setBehaviour(k7_behavior_APPROACH); - if (L0460_ui_CreatureCount) { - f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY); - } - goto T0209081_RunTowardParty; - } - } else { - /* If the party is visible, update target coordinates */ - if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { - L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; - L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; - f205_setDirection(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf)); - L0465_s_NextEvent._mapTime += 2; - L0464_l_NextAspectUpdateTime = M30_time(L0465_s_NextEvent._mapTime); - } else { /* If the party is not visible, move to the target (last known party location) */ - L0444_ps_Group->setBehaviour(k7_behavior_APPROACH); - if (L0460_ui_CreatureCount) { - f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY); - } - goto T0209082_WalkTowardTarget; - } - } - } - L0465_s_NextEvent._type = eventType; - goto T0209136; - } - L0465_s_NextEvent._mapTime += MAX(1, _vm->getRandomNumber(4) + L0461_i_MovementTicks - 1); -T0209134_SetEvent37: - L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup; - } -T0209135: - if (!L0464_l_NextAspectUpdateTime) { - L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, kM1_wholeCreatureGroup, false); - } -T0209136: - if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) { - L0465_s_NextEvent._mapTime += ticks; - } else { - L0464_l_NextAspectUpdateTime += ticks; - } - f208_groupAddEvent(&L0465_s_NextEvent, L0464_l_NextAspectUpdateTime); -T0209139_Return: - ; -} - -bool GroupMan::f202_isMovementPossible(CreatureInfo* creatureInfo, int16 mapX, int16 mapY, uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls) { - int16 L0428_i_MapX; - int16 L0429_i_MapY; - uint16 L0430_ui_Square = 0; - int16 L0431_i_SquareType = 0; - Teleporter* L0432_ps_Teleporter; - Thing L0433_T_Thing; - - - _g384_groupMovementTestedDirections[dir] = true; - _g388_groupMovementBlockedByGroupThing = Thing::_endOfList; - _g389_groupMovementBlockedByDoor = false; - _g390_groupMovementBlockedByParty = false; - if (creatureInfo->_movementTicks == k255_immobile) { - return false; - } - _vm->_dungeonMan->f150_mapCoordsAfterRelMovement((direction)dir, 1, 0, mapX, mapY); - L0428_i_MapX = mapX; - L0429_i_MapY = mapY; - if (_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = - !(((L0428_i_MapX >= 0) && (L0428_i_MapX < _vm->_dungeonMan->_g273_currMapWidth)) && - ((L0429_i_MapY >= 0) && (L0429_i_MapY < _vm->_dungeonMan->_g274_currMapHeight)) && - ((L0431_i_SquareType = Square(L0430_ui_Square = _vm->_dungeonMan->_g271_currMapData[L0428_i_MapX][L0429_i_MapY]).getType()) != k0_ElementTypeWall) && - (L0431_i_SquareType != k3_ElementTypeStairs) && - ((L0431_i_SquareType != k2_ElementTypePit) || (getFlag(L0430_ui_Square, k0x0001_PitImaginary) && allowMovementOverImaginaryPitsAndFakeWalls) || !getFlag(L0430_ui_Square, k0x0008_PitOpen) || getFlag(creatureInfo->_attributes, k0x0020_MaskCreatureInfo_levitation)) && - ((L0431_i_SquareType != k6_ElementTypeFakeWall) || getFlag(L0430_ui_Square, k0x0004_FakeWallOpen) || (getFlag(L0430_ui_Square, k0x0001_FakeWallImaginary) && allowMovementOverImaginaryPitsAndFakeWalls)))) { - return false; - } - if (getFlag(creatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) { - L0433_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0428_i_MapX, L0429_i_MapY); - while (L0433_T_Thing != Thing::_endOfList) { - if ((L0433_T_Thing).getType() == k15_ExplosionThingType) { - L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(L0433_T_Thing); - if (((Explosion*)L0432_ps_Teleporter)->setType(k50_ExplosionType_Fluxcage)) { - _g385_fluxCages[dir] = true; - _g386_fluxCageCount++; - _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true; - return false; - } - } - L0433_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0433_T_Thing); - } - } - if ((L0431_i_SquareType == k5_ElementTypeTeleporter) && getFlag(L0430_ui_Square, k0x0008_TeleporterOpen) && (creatureInfo->M59_getWariness() >= 10)) { - L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY); - if (getFlag(L0432_ps_Teleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->f139_isCreatureAllowedOnMap(_g380_currGroupThing, L0432_ps_Teleporter->getTargetMapIndex())) { - _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true; - return false; - } - } - if (_g390_groupMovementBlockedByParty = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0428_i_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0429_i_MapY == _vm->_dungeonMan->_g307_partyMapY)) { - return false; - } - if (L0431_i_SquareType == k4_DoorElemType) { - L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY); - if (((Square(L0430_ui_Square).getDoorState()) > (((Door*)L0432_ps_Teleporter)->opensVertically() ? creatureInfo->M51_height() : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) { - _g389_groupMovementBlockedByDoor = true; - return false; - } - } - return (_g388_groupMovementBlockedByGroupThing = _vm->_groupMan->f175_groupGetThing(L0428_i_MapX, L0429_i_MapY)) == Thing::_endOfList; -} - -int16 GroupMan::f226_getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) { - return ((((srcMapX -= destMapX) < 0) ? -srcMapX : srcMapX) + - (((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY)); -} - -int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group* group, int16 creatureIndex, int16 mapX, int16 mapY) { - int16 L0420_i_CreatureDirection; - int16 L0421_i_CreatureViewDirectionCount; /* Count of directions to test in L0425_ai_CreatureViewDirections */ - int16 L0422_i_Multiple; -#define AL0422_i_Counter L0422_i_Multiple -#define AL0422_i_SightRange L0422_i_Multiple - uint16 L0423_ui_GroupDirections; - CreatureInfo* L0424_ps_CreatureInfo; - int16 L0425_ai_CreatureViewDirections[4]; /* List of directions to test */ - - - L0424_ps_CreatureInfo = &g243_CreatureInfo[group->_type]; - if (_vm->_championMan->_g407_party._event71Count_Invisibility && !getFlag(L0424_ps_CreatureInfo->_attributes, k0x0800_MaskCreatureInfo_seeInvisible)) { - return 0; - } - if (getFlag(L0424_ps_CreatureInfo->_attributes, k0x0004_MaskCreatureInfo_sideAttack)) /* If creature can see in all directions */ - goto T0200011; - L0423_ui_GroupDirections = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions; - if (creatureIndex < 0) { /* Negative index means test if each creature in the group can see the party in their respective direction */ - L0421_i_CreatureViewDirectionCount = 0; - for (creatureIndex = group->getCount(); creatureIndex >= 0; creatureIndex--) { - L0420_i_CreatureDirection = M21_normalizeModulo4(L0423_ui_GroupDirections >> (creatureIndex << 1)); - AL0422_i_Counter = L0421_i_CreatureViewDirectionCount; - while (AL0422_i_Counter--) { - if (L0425_ai_CreatureViewDirections[AL0422_i_Counter] == L0420_i_CreatureDirection) /* If the creature looks in the same direction as another one in the group */ - goto T0200006; - } - L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount++] = L0420_i_CreatureDirection; -T0200006: - ; - } - } else { /* Positive index means test only if the specified creature in the group can see the party in its direction */ - L0425_ai_CreatureViewDirections[0] = _vm->_groupMan->M50_getCreatureValue(L0423_ui_GroupDirections, creatureIndex); - L0421_i_CreatureViewDirectionCount = 1; - } - while (L0421_i_CreatureViewDirectionCount--) { - if (f227_isDestVisibleFromSource(L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount], mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY)) { -T0200011: - AL0422_i_SightRange = L0424_ps_CreatureInfo->M54_getSightRange(); - if (!getFlag(L0424_ps_CreatureInfo->_attributes, k0x1000_MaskCreatureInfo_nightVision)) { - AL0422_i_SightRange -= _vm->_displayMan->_g304_dungeonViewPaletteIndex >> 1; - } - if (_g381_currGroupDistanceToParty > MAX((int16)1, AL0422_i_SightRange)) { - return 0; - } - return f199_getDistanceBetweenUnblockedSquares(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f197_isViewPartyBlocked); - } - } - return 0; -} - -int16 GroupMan::f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 srcMapY, - int16 destMapX, int16 destMapY, bool (GroupMan::*isBlocked)(uint16, uint16)) { - int16 L0410_i_XAxisStep; - int16 L0411_i_YAxisStep; - int16 L0412_i_Multiple; -#define AL0412_i_DistanceX L0412_i_Multiple -#define AL0412_i_PathMapX L0412_i_Multiple - int16 L0413_i_Multiple; -#define AL0413_i_DistanceY L0413_i_Multiple -#define AL0413_i_PathMapY L0413_i_Multiple - int16 L0414_i_LargestAxisDistance; - bool L0415_B_DistanceXSmallerThanDistanceY; - int16 L0416_i_ValueA; - int16 L0417_i_ValueB; - bool L0418_B_DistanceXEqualsDistanceY; - int16 L0419_i_ValueC; - - - if (M38_distance(srcMapX, srcMapY, destMapX, destMapY) <= 1) { - return 1; - } - L0415_B_DistanceXSmallerThanDistanceY = (AL0412_i_DistanceX = ((AL0412_i_DistanceX = destMapX - srcMapX) < 0) ? -AL0412_i_DistanceX : AL0412_i_DistanceX) < (AL0413_i_DistanceY = ((AL0413_i_DistanceY = destMapY - srcMapY) < 0) ? -AL0413_i_DistanceY : AL0413_i_DistanceY); - L0418_B_DistanceXEqualsDistanceY = (AL0412_i_DistanceX == AL0413_i_DistanceY); - L0410_i_XAxisStep = (((AL0412_i_PathMapX = destMapX) - srcMapX) > 0) ? -1 : 1; - L0411_i_YAxisStep = (((AL0413_i_PathMapY = destMapY) - srcMapY) > 0) ? -1 : 1; - L0419_i_ValueC = L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY - srcMapY) ? ((AL0412_i_PathMapX - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) - : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX - srcMapX) ? ((AL0413_i_PathMapY - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128); - /* 128 when the creature is on the same row or column as the party */ - do { - if (L0418_B_DistanceXEqualsDistanceY) { - if (((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY) && (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX, AL0413_i_PathMapY + L0411_i_YAxisStep)) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX = AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY = AL0413_i_PathMapY + L0411_i_YAxisStep)) { - return 0; - } - } else { - if ((L0416_i_ValueA = ((L0414_i_LargestAxisDistance = (L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY - srcMapY) ? ((AL0412_i_PathMapX + L0410_i_XAxisStep - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX + L0410_i_XAxisStep - srcMapX) ? ((AL0413_i_PathMapY - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128)) - L0419_i_ValueC) < 0) ? -L0414_i_LargestAxisDistance : L0414_i_LargestAxisDistance) < (L0417_i_ValueB = ((L0414_i_LargestAxisDistance = (L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY + L0411_i_YAxisStep - srcMapY) ? ((AL0412_i_PathMapX - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX - srcMapX) ? ((AL0413_i_PathMapY + L0411_i_YAxisStep - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128)) - L0419_i_ValueC) < 0) ? -L0414_i_LargestAxisDistance : L0414_i_LargestAxisDistance)) { - AL0412_i_PathMapX += L0410_i_XAxisStep; - } else { - AL0413_i_PathMapY += L0411_i_YAxisStep; - } - if ((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX, AL0413_i_PathMapY) && ((L0416_i_ValueA != L0417_i_ValueB) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX = AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY = AL0413_i_PathMapY - L0411_i_YAxisStep))) { - return 0; - } - } - } while (M38_distance(AL0412_i_PathMapX, AL0413_i_PathMapY, srcMapX, srcMapY) > 1); - return f226_getDistanceBetweenSquares(srcMapX, srcMapY, destMapX, destMapY); -} - -bool GroupMan::f197_isViewPartyBlocked(uint16 mapX, uint16 mapY) { - uint16 L0404_ui_Square; - int16 L0405_i_SquareType; - int16 L0406_i_DoorState; - Door* L0407_ps_Door; - - if ((L0405_i_SquareType = Square(L0404_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k4_DoorElemType) { - L0407_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY); - return (((L0406_i_DoorState = Square(L0404_ui_Square).getDoorState()) == k3_doorState_FOURTH) || (L0406_i_DoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[L0407_ps_Door->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough); - } - return (L0405_i_SquareType == k0_ElementTypeWall) || ((L0405_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0404_ui_Square, k0x0004_FakeWallOpen)); -} - -int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup* activeGroup, int16 creatureIndex, bool isAttacking) { - uint16 L0326_ui_Multiple; -#define AL0326_ui_Aspect L0326_ui_Multiple -#define AL0326_ui_AnimationTicks L0326_ui_Multiple - uint16 L0327_ui_CreatureGraphicInfo; - int16 L0328_i_Offset; - Group* L0329_ps_Group; - bool L0330_B_ProcessGroup; - uint16 L0331_ui_CreatureType; - uint16 L1635_ui_SoundIndex; - - L0329_ps_Group = &(((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]); - L0327_ui_CreatureGraphicInfo = g243_CreatureInfo[L0331_ui_CreatureType = L0329_ps_Group->_type]._graphicInfo; - if (L0330_B_ProcessGroup = (creatureIndex < 0)) { /* If the creature index is negative then all creatures in the group are processed */ - creatureIndex = L0329_ps_Group->getCount(); - } - do { - AL0326_ui_Aspect = activeGroup->_aspect[creatureIndex]; - AL0326_ui_Aspect &= k0x0080_MaskActiveGroupIsAttacking | k0x0040_MaskActiveGroupFlipBitmap; - if (L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 12) & 0x3)) { - L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset); - if (_vm->getRandomNumber(2)) { - L0328_i_Offset = (-L0328_i_Offset) & 0x0007; - } - AL0326_ui_Aspect |= L0328_i_Offset; - } - if (L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 14) & 0x3)) { - L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset); - if (_vm->getRandomNumber(2)) { - L0328_i_Offset = (-L0328_i_Offset) & 0x0007; - } - AL0326_ui_Aspect |= (L0328_i_Offset << 3); - } - if (isAttacking) { - if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0200_CreatureInfoGraphicMaskFlipAttack)) { - if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) { - if (_vm->getRandomNumber(2)) { - toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); - } - } else { - if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) { - if (_vm->getRandomNumber(2)) { - setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); - } else { - clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); - } - } - } - } else { - clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); - } - setFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking); - } else { - if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) { - if (L0331_ui_CreatureType == k13_CreatureTypeCouatl) { - if (_vm->getRandomNumber(2)) { - toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); - L1635_ui_SoundIndex = _vm->_movsens->f514_getSound(k13_CreatureTypeCouatl); - if (L1635_ui_SoundIndex <= k34_D13_soundCount) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); - } - } - } else { - if (_vm->getRandomNumber(2)) { - setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); - } else { - clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); - } - } - } else { - clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); - } - clearFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking); - } - activeGroup->_aspect[creatureIndex] = AL0326_ui_Aspect; - } while (L0330_B_ProcessGroup && (creatureIndex--)); - AL0326_ui_AnimationTicks = g243_CreatureInfo[L0329_ps_Group->_type]._animationTicks; - return _vm->_g313_gameTime + (isAttacking ? ((AL0326_ui_AnimationTicks >> 8) & 0xF) : ((AL0326_ui_AnimationTicks >> 4) & 0xF)) + _vm->getRandomNumber(2); -} - -void GroupMan::f205_setDirection(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) { - uint16 L0435_ui_GroupDirections; - static long G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; /* These two variables are used to prevent setting direction of half square sized creatures twice at the same game time */ - static ActiveGroup* G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup; - - - warning("potentially dangerous cast to uint32 below"); - if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == (uint32)G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) { - return; - } - if (M21_normalizeModulo4(_vm->_groupMan->M50_getCreatureValue(L0435_ui_GroupDirections = activeGroup->_directions, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */ - L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + dir)); - } else { - L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir); - } - if (twoHalfSquareSizedCreatures) { - L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex ^ 1, dir); /* Set direction of the second half square sized creature */ - G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_g313_gameTime; - G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup = activeGroup; - } - activeGroup->_directions = (direction)L0435_ui_GroupDirections; -} - -void GroupMan::f208_groupAddEvent(TimelineEvent* event, uint32 time) { - warning("potentially dangerous cast to uint32 below"); - if (time < (uint32)M30_time(event->_mapTime)) { - event->_type -= 5; - event->_C._ticks = M30_time(event->_mapTime) - time; - M32_setTime(event->_mapTime, time); - } else { - event->_C._ticks = time - M30_time(event->_mapTime); - } - _vm->_timeline->f238_addEventGetEventIndex(event); -} - -int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo* creatureInfo, int16 mapY, int16 mapX) { - - uint16 L0426_ui_SmellRange; - int16 L0427_i_ScentOrdinal; - - - if (!(L0426_ui_SmellRange = creatureInfo->M55_getSmellRange())) { - return 0; - } - if ((((L0426_ui_SmellRange + 1) >> 1) >= _g381_currGroupDistanceToParty) && f199_getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f198_isSmellPartyBlocked)) { - _vm->_projexpl->_g363_secondaryDirToOrFromParty = _g383_currGroupSecondaryDirToParty; - return _vm->M0_indexToOrdinal(_g382_currGroupPrimaryDirToParty); - } - if ((L0427_i_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapY, mapX)) && ((_vm->_championMan->_g407_party._scentStrengths[_vm->M1_ordinalToIndex(L0427_i_ScentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (L0426_ui_SmellRange << 1)))) { /* If there is a fresh enough party scent on the group square */ - return _vm->M0_indexToOrdinal(f228_getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_g407_party._scents[L0427_i_ScentOrdinal].getMapX(), _vm->_championMan->_g407_party._scents[L0427_i_ScentOrdinal].getMapY())); - } - return 0; -} - -bool GroupMan::f198_isSmellPartyBlocked(uint16 mapX, uint16 mapY) { - uint16 L0408_ui_Square; - int16 L0409_i_SquareType; - - return ((L0409_i_SquareType = Square(L0408_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k0_ElementTypeWall) || ((L0409_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0408_ui_Square, k0x0004_FakeWallOpen)); -} - -int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo* info, int16 mapX, int16 mapY, bool allowMovementOverImaginaryPitsAndFakeWalls) { - int16 L0434_i_Direction; - - - for (L0434_i_Direction = kDirNorth; L0434_i_Direction <= kDirWest; L0434_i_Direction++) { - if ((!_g384_groupMovementTestedDirections[L0434_i_Direction]) && f202_isMovementPossible(info, mapX, mapY, L0434_i_Direction, allowMovementOverImaginaryPitsAndFakeWalls)) { - return _vm->M0_indexToOrdinal(L0434_i_Direction); - } - } - return 0; -} - -void GroupMan::f206_groupSetDirGroup(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, int16 creatureSize) { - bool L0436_B_TwoHalfSquareSizedCreatures; - - - if (L0436_B_TwoHalfSquareSizedCreatures = creatureIndex && (creatureSize == k1_MaskCreatureSizeHalf)) { - creatureIndex--; - } - do { - if (!creatureIndex || _vm->getRandomNumber(2)) { - f205_setDirection(activeGroup, dir, creatureIndex, L0436_B_TwoHalfSquareSizedCreatures); - } - } while (creatureIndex--); -} - -void GroupMan::f182_stopAttacking(ActiveGroup* group, int16 mapX, int16 mapY) { - int16 L0337_i_CreatureIndex; - - for (L0337_i_CreatureIndex = 0; L0337_i_CreatureIndex < 4; clearFlag(group->_aspect[L0337_i_CreatureIndex++], k0x0080_MaskActiveGroupIsAttacking)); - f181_groupDeleteEvents(mapX, mapY); - -} - -bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo* info, int16 mapX, int16 mapY, uint16 dir) { - if (_g385_fluxCages[dir]) { - return false; - } - mapX += _vm->_dirIntoStepCountEast[dir], mapY += _vm->_dirIntoStepCountNorth[dir]; - return f202_isMovementPossible(info, mapX, mapY, dir, false); -} - -bool GroupMan::f207_isCreatureAttacking(Group* group, int16 mapX, int16 mapY, uint16 creatureIndex) { - uint16 L0437_ui_Multiple; -#define AL0437_ui_CreatureType L0437_ui_Multiple -#define AL0437_T_Thing L0437_ui_Multiple - uint16 L0438_ui_PrimaryDirectionToParty; - int16 L0439_i_Multiple; -#define AL0439_i_GroupCells L0439_i_Multiple -#define AL0439_i_TargetCell L0439_i_Multiple -#define AL0439_i_ChampionIndex L0439_i_Multiple - int16 L0440_i_Multiple; -#define AL0440_i_KineticEnergy L0440_i_Multiple -#define AL0440_i_Counter L0440_i_Multiple -#define AL0440_i_Damage L0440_i_Multiple -#define AL0440_i_AttackSoundOrdinal L0440_i_Multiple - CreatureInfo* L0441_ps_CreatureInfo; - Champion* L0442_ps_Champion; - ActiveGroup L0443_s_ActiveGroup; - - - _vm->_projexpl->_g361_lastCreatureAttackTime = _vm->_g313_gameTime; - L0443_s_ActiveGroup = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]; - L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type]; - L0438_ui_PrimaryDirectionToParty = _g382_currGroupPrimaryDirToParty; - if ((AL0439_i_GroupCells = L0443_s_ActiveGroup._cells) == k255_CreatureTypeSingleCenteredCreature) { - AL0439_i_TargetCell = _vm->getRandomNumber(2); - } else { - AL0439_i_TargetCell = ((_vm->_groupMan->M50_getCreatureValue(AL0439_i_GroupCells, creatureIndex) + 5 - L0438_ui_PrimaryDirectionToParty) & 0x0002) >> 1; - } - AL0439_i_TargetCell += L0438_ui_PrimaryDirectionToParty; - AL0439_i_TargetCell &= 0x0003; - if ((L0441_ps_CreatureInfo->M56_getAttackRange() > 1) && ((_g381_currGroupDistanceToParty > 1) || _vm->getRandomNumber(2))) { - switch (AL0437_ui_CreatureType) { - case k14_CreatureTypeVexirk: - case k23_CreatureTypeLordChaos: - if (_vm->getRandomNumber(2)) { - AL0437_T_Thing = Thing::_explFireBall.toUint16(); - } else { - switch (_vm->getRandomNumber(4)) { - case 0: - AL0437_T_Thing = Thing::_explHarmNonMaterial.toUint16(); - break; - case 1: - AL0437_T_Thing = Thing::_explLightningBolt.toUint16(); - break; - case 2: - AL0437_T_Thing = Thing::_explPoisonCloud.toUint16(); - break; - case 3: - AL0437_T_Thing = Thing::_explOpenDoor.toUint16(); - } - } - break; - case k1_CreatureTypeSwampSlimeSlime: - AL0437_T_Thing = Thing::_explSlime.toUint16(); - break; - case k3_CreatureTypeWizardEyeFlyingEye: - if (_vm->getRandomNumber(8)) { - AL0437_T_Thing = Thing::_explLightningBolt.toUint16(); - } else { - AL0437_T_Thing = Thing::_explOpenDoor.toUint16(); - } - break; - case k19_CreatureTypeMaterializerZytaz: - if (_vm->getRandomNumber(2)) { - AL0437_T_Thing = Thing::_explPoisonCloud.toUint16(); - break; - } - case k22_CreatureTypeDemon: - case k24_CreatureTypeRedDragon: - AL0437_T_Thing = Thing::_explFireBall.toUint16(); - } /* BUG0_13 The game may crash when 'Lord Order' or 'Grey Lord' cast spells. This cannot happen with the original dungeons as they do not contain any groups of these types. 'Lord Order' and 'Grey Lord' creatures can cast spells (attack range > 1) but no projectile type is defined for them in the code. If these creatures are present in a dungeon they will cast projectiles containing undefined things because the variable is not initialized */ - AL0440_i_KineticEnergy = (L0441_ps_CreatureInfo->_attack >> 2) + 1; - AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy); - AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy); - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); - _vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8); - } else { - if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) { - AL0439_i_ChampionIndex = _vm->getRandomNumber(4); - for (AL0440_i_Counter = 0; (AL0440_i_Counter < 4) && !_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex]._currHealth; AL0440_i_Counter++) { - AL0439_i_ChampionIndex = returnNextVal(AL0439_i_ChampionIndex); - } - if (AL0440_i_Counter == 4) { - return false; - } - } else { - if ((AL0439_i_ChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(mapX, mapY, AL0439_i_TargetCell)) < 0) { - return false; - } - } - if (AL0437_ui_CreatureType == k2_CreatureTypeGiggler) { - f193_stealFromChampion(group, AL0439_i_ChampionIndex); - } else { - AL0440_i_Damage = f230_getChampionDamage(group, AL0439_i_ChampionIndex) + 1; - L0442_ps_Champion = &_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex]; - if (AL0440_i_Damage > L0442_ps_Champion->_maximumDamageReceived) { - L0442_ps_Champion->_maximumDamageReceived = AL0440_i_Damage; - L0442_ps_Champion->_directionMaximumDamageReceived = returnOppositeDir((direction)L0438_ui_PrimaryDirectionToParty); - } - } - } - if (AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); - } - return true; -} - -void GroupMan::f229_setOrderedCellsToAttack(signed char* orderedCellsToAttack, int16 targetMapX, int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource) { - static signed char g23_orderedCellsToAttack[8][4] = { // @ G0023_aac_Graphic562_OrderedCellsToAttack - {0, 1, 3, 2}, /* Attack South from position Northwest or Southwest */ - {1, 0, 2, 3}, /* Attack South from position Northeast or Southeast */ - {1, 2, 0, 3}, /* Attack West from position Northwest or Northeast */ - {2, 1, 3, 0}, /* Attack West from position Southeast or Southwest */ - {3, 2, 0, 1}, /* Attack North from position Northwest or Southwest */ - {2, 3, 1, 0}, /* Attack North from position Southeast or Northeast */ - {0, 3, 1, 2}, /* Attack East from position Northwest or Northeast */ - {3, 0, 2, 1}}; /* Attack East from position Southeast or Southwest */ - uint16 L0557_ui_OrderedCellsToAttackIndex; - - - if (!((L0557_ui_OrderedCellsToAttackIndex = f228_getDirsWhereDestIsVisibleFromSource(targetMapX, targetMapY, attackerMapX, attackerMapY) << 1) & 0x0002)) { - cellSource++; - } - L0557_ui_OrderedCellsToAttackIndex += (cellSource >> 1) & 0x0001; - for (uint16 i = 0; i < 4; ++i) - orderedCellsToAttack[i] = g23_orderedCellsToAttack[L0557_ui_OrderedCellsToAttackIndex][i]; -} - -void GroupMan::f193_stealFromChampion(Group* group, uint16 championIndex) { - int16 L0391_i_Percentage; - uint16 L0392_ui_StealFromSlotIndex; - uint16 L0393_ui_Counter; - Thing L0394_T_Thing; - Champion* L0395_ps_Champion; - bool L0396_B_ObjectStolen; - static unsigned char G0394_auc_StealFromSlotIndices[8]; /* Initialized with 0 bytes by C loader */ - - - L0396_B_ObjectStolen = false; - L0391_i_Percentage = 100 - _vm->_championMan->f311_getDexterity(L0395_ps_Champion = &_vm->_championMan->_gK71_champions[championIndex]); - L0393_ui_Counter = _vm->getRandomNumber(8); - while ((L0391_i_Percentage > 0) && !_vm->_championMan->f308_isLucky(L0395_ps_Champion, L0391_i_Percentage)) { - if ((L0392_ui_StealFromSlotIndex = G0394_auc_StealFromSlotIndices[L0393_ui_Counter]) == k13_ChampionSlotBackpackLine_1_1) { - L0392_ui_StealFromSlotIndex += _vm->getRandomNumber(17); /* Select a random slot in the backpack */ - } - if (((L0394_T_Thing = L0395_ps_Champion->_slots[L0392_ui_StealFromSlotIndex]) != Thing::_none)) { - L0396_B_ObjectStolen = true; - L0394_T_Thing = _vm->_championMan->f300_getObjectRemovedFromSlot(championIndex, L0392_ui_StealFromSlotIndex); - if (group->_slot == Thing::_endOfList) { - group->_slot = L0394_T_Thing; /* BUG0_12 An object is cloned and appears at two different locations in the dungeon and/or inventory. The game may crash when interacting with this object. If a Giggler with no possessions steals an object that was previously in a chest and was not the last object in the chest then the objects that followed it are cloned. In the chest, the object is part of a linked list of objects that is not reset when the object is removed from the chest and placed in the inventory (but not in the dungeon), nor when it is stolen and added as the first Giggler possession. If the Giggler already has a possession before stealing the object then this does not create a cloned object. - The following statement is missing: L0394_T_Thing->Next = Thing::_endOfList; - This creates cloned things if L0394_T_Thing->Next is not Thing::_endOfList which is the case when the object comes from a chest in which it was not the last object */ - } else { - _vm->_dungeonMan->f163_linkThingToList(L0394_T_Thing, group->_slot, kM1_MapXNotOnASquare, 0); - } - _vm->_championMan->f292_drawChampionState((ChampionIndex)championIndex); - } - ++L0393_ui_Counter; - L0393_ui_Counter &= 0x0007; - L0391_i_Percentage -= 20; - } - if (!_vm->getRandomNumber(8) || (L0396_B_ObjectStolen && _vm->getRandomNumber(2))) { - _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._delayFleeingFromTarget = _vm->getRandomNumber(64) + 20; - group->setBehaviour(k5_behavior_FLEE); - } -} - -int16 GroupMan::f230_getChampionDamage(Group* group, uint16 champIndex) { - unsigned char g24_woundProbabilityIndexToWoundMask[4] = {32, 16, 8, 4}; // @ G0024_auc_Graphic562_WoundProbabilityIndexToWoundMask - - Champion* L0562_ps_Champion; - int16 L0558_i_Multiple; -#define AL0558_i_Attack L0558_i_Multiple -#define AL0558_i_Damage L0558_i_Multiple - uint16 L0559_ui_Multiple; -#define AL0559_ui_WoundTest L0559_ui_Multiple -#define AL0559_ui_PoisonAttack L0559_ui_Multiple -#define AL0559_ui_CreatureDifficulty L0559_ui_Multiple - uint16 L0560_ui_WoundProbabilities; - uint16 L0561_ui_Multiple; -#define AL0561_ui_WoundProbabilityIndex L0561_ui_Multiple -#define AL0561_ui_AllowedWound L0561_ui_Multiple - int16 L0563_i_DoubledMapDifficulty; - CreatureInfo L0564_s_CreatureInfo; - - - L0562_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; - if (champIndex >= _vm->_championMan->_g305_partyChampionCount) { - return 0; - } - if (!L0562_ps_Champion->_currHealth) { - return 0; - } - if (_vm->_championMan->_g300_partyIsSleeping) { - _vm->_championMan->f314_wakeUp(); - } - L0563_i_DoubledMapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty << 1; - L0564_s_CreatureInfo = g243_CreatureInfo[group->_type]; - _vm->_championMan->f304_addSkillExperience(champIndex, k7_ChampionSkillParry, L0564_s_CreatureInfo.M58_getExperience()); - if (_vm->_championMan->_g300_partyIsSleeping || (((_vm->_championMan->f311_getDexterity(L0562_ps_Champion) < (_vm->getRandomNumber(32) + L0564_s_CreatureInfo._dexterity + L0563_i_DoubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->f308_isLucky(L0562_ps_Champion, 60))) { - if ((AL0559_ui_WoundTest = _vm->getRandomNumber(65536)) & 0x0070) { - AL0559_ui_WoundTest &= 0x000F; - L0560_ui_WoundProbabilities = L0564_s_CreatureInfo._woundProbabilities; - for (AL0561_ui_WoundProbabilityIndex = 0; AL0559_ui_WoundTest > (L0560_ui_WoundProbabilities & 0x000F); L0560_ui_WoundProbabilities >>= 4) { - AL0561_ui_WoundProbabilityIndex++; - } - AL0561_ui_AllowedWound = g24_woundProbabilityIndexToWoundMask[AL0561_ui_WoundProbabilityIndex]; - } else { - AL0561_ui_AllowedWound = AL0559_ui_WoundTest & 0x0001; /* 0 (Ready hand) or 1 (action hand) */ - } - if ((AL0558_i_Attack = (_vm->getRandomNumber(16) + L0564_s_CreatureInfo._attack + L0563_i_DoubledMapDifficulty) - (_vm->_championMan->f303_getSkillLevel(champIndex, k7_ChampionSkillParry) << 1)) <= 1) { - if (_vm->getRandomNumber(2)) { - goto T0230014; - } - AL0558_i_Attack = _vm->getRandomNumber(4) + 2; - } - AL0558_i_Attack >>= 1; - AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack) + _vm->getRandomNumber(4); - AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack); - AL0558_i_Attack >>= 2; - AL0558_i_Attack += _vm->getRandomNumber(4) + 1; - if (_vm->getRandomNumber(2)) { - AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1; - } - if (AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType)) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); - if ((AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack) && _vm->getRandomNumber(2) && ((AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack)) >= 0)) { - _vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack); - } - return AL0558_i_Damage; - } - } -T0230014: - return 0; -} - -void GroupMan::f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY) { - Group* L0363_ps_Group; - int16 L0364_i_CreatureType; - - - if (_g391_dropMovingCreatureFixedPossCellCount) { - L0363_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing); - L0364_i_CreatureType = L0363_ps_Group->_type; - while (_g391_dropMovingCreatureFixedPossCellCount) { - f186_dropCreatureFixedPossessions(L0364_i_CreatureType, mapX, mapY, _g392_dropMovingCreatureFixedPossessionsCell[--_g391_dropMovingCreatureFixedPossCellCount], k2_soundModePlayOneTickLater); - } - } -} - -void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) { - Group* L0332_ps_Group; - TimelineEvent L0333_s_Event; - - - L0332_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(mapX, mapY)); - if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) { - L0332_ps_Group->setBehaviour(k0_behavior_WANDER); - } - M33_setMapAndTime(L0333_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, (_vm->_g313_gameTime + 1)); - L0333_s_Event._type = k37_TMEventTypeUpdateBehaviourGroup; - L0333_s_Event._priority = 255 - g243_CreatureInfo[L0332_ps_Group->_type]._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */ - L0333_s_Event._C._ticks = 0; - L0333_s_Event._B._location._mapX = mapX; - L0333_s_Event._B._location._mapY = mapY; - _vm->_timeline->f238_addEventGetEventIndex(&L0333_s_Event); -} - -void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) { - uint16 L0339_ui_CreatureIndex; - Group* L0340_ps_Group; - ActiveGroup* L0341_ps_ActiveGroup; - int16 L0344_i_ActiveGroupIndex; - - - L0341_ps_ActiveGroup = _vm->_groupMan->_g375_activeGroups; - L0344_i_ActiveGroupIndex = 0; - while (L0341_ps_ActiveGroup->_groupThingIndex >= 0) { - if (++L0344_i_ActiveGroupIndex >= _vm->_groupMan->_g376_maxActiveGroupCount) { - return; /* BUG0_11 Data corruption in memory. Each group located on the same map as the party has additional associated data but there is only provision for 60 instances (_vm->_groupMan->_g376_maxActiveGroupCount). If there are more groups at the same time then some of them do not get their instance and when the game accesses this information it will corrupt other data in memory (either the instance of another group, parts of the timeline or events). This situation cannot occur in the original Dungeon Master and Chaos Strikes Back dungeons for the following reasons (but it may occur in custom dungeons if they are not designed carefully): there is no map with already more than 60 groups in the original dungeons and none of the following 3 possible ways to move a group into a map can increase the number of instances above the maximum of 60: - - A group generator sensor is triggered: the game never generates a group on the party map if there are less than 5 instances available. This limits the actual number of groups on a map to 55 in most cases. - - A group falls through a pit from the map above (the creature type must be allowed on the target map): a group will never willingly move to an open pit square. It may move to a closed pit square and fall if the pit is then open (either automatically or triggered by the party on the map below). There are no such pits in the original dungeons. - - A group is teleported from another map (the creature type must be allowed on the target map): in the original dungeons, all teleporters whose scope include groups and target another map are either inaccessible to groups or the groups are not allowed on the target map. The only exception is for some Gigglers in the Chaos Strikes Back dungeon but there are not enough to use the 5 reserved instances. - - This code returns immediately if all ACTIVE_GROUP entries are already in use, which avoids an out of bounds access into _vm->_groupMan->_g375_activeGroups below (through L0341_ps_ActiveGroup). However in this case the specified group ends up without an associated ACTIVE_GROUP structure which is assumed everywhere in the code to be present for groups on the same map as the party. If there are more than 60 groups on the party map at any given time then this will corrupt memory (in _vm->_timeline->_g370_events and _vm->_timeline->_g371_timeline allocated in _vm->_timeline->f233_initTimeline before _vm->_groupMan->_g375_activeGroups) because of read and write operations at incorrect memory addresses (the 'Cells' value of the GROUP will be used as an index in _vm->_groupMan->_g375_activeGroups even though that value was not replaced by the index of an ACTIVE_GROUP in this function) */ - } - L0341_ps_ActiveGroup++; - } - _g377_currActiveGroupCount++; - L0340_ps_Group = ((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType()); - L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells; - L0340_ps_Group->getActiveGroupIndex() = L0344_i_ActiveGroupIndex; - L0341_ps_ActiveGroup->_priorMapX = L0341_ps_ActiveGroup->_homeMapX = mapX; - L0341_ps_ActiveGroup->_priorMapY = L0341_ps_ActiveGroup->_homeMapY = mapY; - L0341_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime - 127; - L0339_ui_CreatureIndex = L0340_ps_Group->getCount(); - do { - L0341_ps_ActiveGroup->_directions = (direction)f178_getGroupValueUpdatedWithCreatureValue(L0341_ps_ActiveGroup->_directions, L0339_ui_CreatureIndex, L0340_ps_Group->getDir()); - L0341_ps_ActiveGroup->_aspect[L0339_ui_CreatureIndex] = 0; - } while (L0339_ui_CreatureIndex--); - f179_getCreatureAspectUpdateTime(L0341_ps_ActiveGroup, kM1_wholeCreatureGroup, false); -} - -void GroupMan::f184_removeActiveGroup(uint16 activeGroupIndex) { - ActiveGroup* L0347_ps_ActiveGroup; - Group* L0348_ps_Group; - - - if ((activeGroupIndex > _vm->_groupMan->_g376_maxActiveGroupCount) || (_vm->_groupMan->_g375_activeGroups[activeGroupIndex]._groupThingIndex < 0)) { - return; - } - L0347_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[activeGroupIndex]; - L0348_ps_Group = &((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex]; - _g377_currActiveGroupCount--; - L0348_ps_Group->_cells = L0347_ps_ActiveGroup->_cells; - L0348_ps_Group->setDir(M21_normalizeModulo4(L0347_ps_ActiveGroup->_directions)); - if (L0348_ps_Group->getBehaviour() >= k4_behavior_USELESS) { - L0348_ps_Group->setBehaviour(k0_behavior_WANDER); - } - L0347_ps_ActiveGroup->_groupThingIndex = -1; -} } diff --git a/engines/dm/group.h b/engines/dm/group.h index 151594a1d3..3530765b74 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -172,11 +172,12 @@ class GroupMan { bool _g390_groupMovementBlockedByParty; // @ G0390_B_GroupMovementBlockedByParty bool _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter; // @ G0387_B_GroupMovementBlockedByWallStairsPitFakeWallFluxcageTeleporter public: - uint16 _g376_maxActiveGroupCount = 60; // @ G0376_ui_MaximumActiveGroupCount + uint16 _g376_maxActiveGroupCount; // @ G0376_ui_MaximumActiveGroupCount ActiveGroup *_g375_activeGroups; // @ G0375_ps_ActiveGroups uint16 _g377_currActiveGroupCount; // @ G0377_ui_CurrentActiveGroupCount GroupMan(DMEngine *vm); ~GroupMan(); + void f196_initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups uint16 f145_getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells uint16 f147_getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections -- cgit v1.2.3 From c74c4f362ec358a650c292954bc57f2932e001b8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jul 2016 00:38:43 +0200 Subject: DM: Make some arrays static and local --- engines/dm/gfx.cpp | 212 +++++++++++++++++++++++++++++------------------------ 1 file changed, 115 insertions(+), 97 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 05c8f172cd..799ff45ee6 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -53,90 +53,6 @@ uint16 g208_doorButtonCoordSets[1][4][6] = { // @ G0208_aaauc_Graphic558_DoorBut {144, 155, 42, 47, 8, 6}, /* D2C */ {160, 175, 44, 52, 8, 9}}}; /* D1C */ -DoorFrames g179_doorFrame_D3L = { // @ G0179_s_Graphic558_Frames_Door_D3L - /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(24, 71, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ - Frame(24, 71, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ - Frame(24, 71, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ - Frame(24, 71, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ - Frame(24, 29, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ - Frame(24, 35, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ - Frame(24, 41, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ - Frame(66, 71, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ - Frame(60, 71, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ - Frame(54, 71, 28, 67, 24, 41, 24, 0)}; /* Right Horizontal Closed three fourth */ -DoorFrames g180_doorFrame_D3C = { // @ G0180_s_Graphic558_Frames_Door_D3C - /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(88, 135, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ - Frame(88, 135, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ - Frame(88, 135, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ - Frame(88, 135, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ - Frame(88, 93, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ - Frame(88, 99, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ - Frame(88, 105, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ - Frame(130, 135, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ - Frame(124, 135, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ - Frame(118, 135, 28, 67, 24, 41, 24, 0)}; /* Right Horizontal Closed three fourth */ -DoorFrames g181_doorFrame_D3R = { // @ G0181_s_Graphic558_Frames_Door_D3R - /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(150, 197, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ - Frame(150, 197, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ - Frame(150, 197, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ - Frame(150, 197, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ - Frame(150, 153, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ - Frame(150, 161, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ - Frame(150, 167, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ - Frame(192, 197, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ - Frame(186, 197, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ - Frame(180, 197, 28, 67, 24, 41, 24, 0)}; /* Right Horizontal Closed three fourth */ -DoorFrames g182_doorFrame_D2L = { // @ G0182_s_Graphic558_Frames_Door_D2L - /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(0, 63, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ - Frame(0, 63, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ - Frame(0, 63, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ - Frame(0, 63, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ - Frame(0, 7, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ - Frame(0, 15, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ - Frame(0, 23, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ - Frame(56, 63, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ - Frame(48, 63, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ - Frame(40, 63, 24, 82, 32, 61, 32, 0)}; /* Right Horizontal Closed three fourth */ -DoorFrames g183_doorFrame_D2C = { // @ G0183_s_Graphic558_Frames_Door_D2C - /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(80, 143, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ - Frame(80, 143, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ - Frame(80, 143, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ - Frame(80, 143, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ - Frame(80, 87, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ - Frame(80, 95, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ - Frame(80, 103, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ - Frame(136, 143, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ - Frame(128, 143, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ - Frame(120, 143, 24, 82, 32, 61, 32, 0)}; /* Right Horizontal Closed three fourth */ -DoorFrames g184_doorFrame_D2R = { // @ G0184_s_Graphic558_Frames_Door_D2R - /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(160, 223, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ - Frame(160, 223, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ - Frame(160, 223, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ - Frame(160, 223, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ - Frame(160, 167, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ - Frame(160, 175, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ - Frame(160, 183, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ - Frame(216, 223, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ - Frame(208, 223, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ - Frame(200, 223, 24, 82, 32, 61, 32, 0)}; /* Right Horizontal Closed three fourth */ -DoorFrames g185_doorFrame_D1L = { // @ G0185_s_Graphic558_Frames_Door_D1L - /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(0, 31, 17, 102, 48, 88, 64, 0), /* Closed Or Destroyed */ - Frame(0, 31, 17, 38, 48, 88, 64, 66), /* Vertical Closed one fourth */ - Frame(0, 31, 17, 60, 48, 88, 64, 44), /* Vertical Closed half */ - Frame(0, 31, 17, 82, 48, 88, 64, 22), /* Vertical Closed three fourth */ - Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed one fourth */ - Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed half */ - Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed three fourth */ - Frame(20, 31, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */ - Frame(8, 31, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */ - Frame(0, 31, 17, 102, 48, 88, 52, 0)}; /* Right Horizontal Closed three fourth */ DoorFrames g186_doorFrame_D1C = { // @ G0186_s_Graphic558_Frames_Door_D1C /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ Frame(64, 159, 17, 102, 48, 88, 0, 0), /* Closed Or Destroyed */ @@ -149,18 +65,6 @@ DoorFrames g186_doorFrame_D1C = { // @ G0186_s_Graphic558_Frames_Door_D1C Frame(148, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */ Frame(136, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */ Frame(124, 159, 17, 102, 48, 88, 48, 0)}; /* Right Horizontal Closed three fourth */ -DoorFrames g187_doorFrame_D1R = { // @ G0187_s_Graphic558_Frames_Door_D1R - /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(192, 223, 17, 102, 48, 88, 0, 0), /* Closed Or Destroyed */ - Frame(192, 223, 17, 38, 48, 88, 0, 66), /* Vertical Closed one fourth */ - Frame(192, 223, 17, 60, 48, 88, 0, 44), /* Vertical Closed half */ - Frame(192, 223, 17, 82, 48, 88, 0, 22), /* Vertical Closed three fourth */ - Frame(192, 203, 17, 102, 48, 88, 36, 0), /* Left Horizontal Closed one fourth */ - Frame(192, 215, 17, 102, 48, 88, 24, 0), /* Left Horizontal Closed half */ - Frame(192, 223, 17, 102, 48, 88, 12, 0), /* Left Horizontal Closed three fourth */ - Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Right Horizontal Closed one fourth */ - Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Right Horizontal Closed half */ - Frame(0, 0, 0, 0, 0, 0, 0, 0)}; /* Right Horizontal Closed three fourth */ uint16 g207_doorOrnCoordSets[4][3][6] = { // @ G0207_aaauc_Graphic558_DoorOrnamentCoordinateSets /* { X1, X2, Y1, Y2, ByteWidth, Height } */ @@ -1558,6 +1462,20 @@ void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) { // NOTE: has been screened for missing code void DisplayMan::f116_drawSquareD3L(direction dir, int16 posX, int16 posY) { + static DoorFrames g179_doorFrame_D3L = DoorFrames( // @ G0179_s_Graphic558_Frames_Door_D3L + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(24, 71, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ + Frame(24, 71, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ + Frame(24, 71, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ + Frame(24, 71, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ + Frame(24, 29, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ + Frame(24, 35, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ + Frame(24, 41, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ + Frame(66, 71, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ + Frame(60, 71, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ + Frame(54, 71, 28, 67, 24, 41, 24, 0) + ); /* Right Horizontal Closed three fourth */ + uint16 squareAspect[5]; int16 order; @@ -1609,6 +1527,20 @@ T0116017_orangeElk: } void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) { + static DoorFrames g181_doorFrame_D3R = DoorFrames( // @ G0181_s_Graphic558_Frames_Door_D3R + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(150, 197, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ + Frame(150, 197, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ + Frame(150, 197, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ + Frame(150, 197, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ + Frame(150, 153, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ + Frame(150, 161, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ + Frame(150, 167, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ + Frame(192, 197, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ + Frame(186, 197, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ + Frame(180, 197, 28, 67, 24, 41, 24, 0) /* Right Horizontal Closed three fourth */ + ); + int16 order; uint16 squareAspect[5]; @@ -1666,6 +1598,19 @@ T0117018: } void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) { + static DoorFrames g180_doorFrame_D3C = DoorFrames( // @ G0180_s_Graphic558_Frames_Door_D3C + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(88, 135, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ + Frame(88, 135, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ + Frame(88, 135, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ + Frame(88, 135, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ + Frame(88, 93, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ + Frame(88, 99, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ + Frame(88, 105, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ + Frame(130, 135, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ + Frame(124, 135, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ + Frame(118, 135, 28, 67, 24, 41, 24, 0) /* Right Horizontal Closed three fourth */ + ); int16 order; int16 squareAspect[5]; @@ -1715,11 +1660,25 @@ T0118028: f113_drawField(&g188_FieldAspects[k0_ViewSquare_D3C], g163_FrameWalls[k0_ViewSquare_D3C]._box); } } + void DisplayMan::f119_drawSquareD2L(direction dir, int16 posX, int16 posY) { + static DoorFrames g182_doorFrame_D2L = DoorFrames( // @ G0182_s_Graphic558_Frames_Door_D2L + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(0, 63, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ + Frame(0, 63, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ + Frame(0, 63, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ + Frame(0, 63, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ + Frame(0, 7, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ + Frame(0, 15, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ + Frame(0, 23, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ + Frame(56, 63, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ + Frame(48, 63, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ + Frame(40, 63, 24, 82, 32, 61, 32, 0) /* Right Horizontal Closed three fourth */ + ); + int16 order; int16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); switch (squareAspect[k0_ElemAspect]) { case k19_ElementTypeStaisFront: @@ -1767,7 +1726,22 @@ T0119020: _vm->_displayMan->f113_drawField(&g188_FieldAspects[k4_ViewSquare_D2L], g163_FrameWalls[k4_ViewSquare_D2L]._box); } } + void DisplayMan::f120_drawSquareD2R(direction dir, int16 posX, int16 posY) { + static DoorFrames g184_doorFrame_D2R = DoorFrames( // @ G0184_s_Graphic558_Frames_Door_D2R + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(160, 223, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ + Frame(160, 223, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ + Frame(160, 223, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ + Frame(160, 223, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ + Frame(160, 167, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ + Frame(160, 175, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ + Frame(160, 183, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ + Frame(216, 223, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ + Frame(208, 223, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ + Frame(200, 223, 24, 82, 32, 61, 32, 0) /* Right Horizontal Closed three fourth */ + ); + int16 order; int16 squareAspect[5]; @@ -1820,7 +1794,22 @@ T0120029: _vm->_displayMan->f113_drawField(&g188_FieldAspects[k5_ViewSquare_D2R], g163_FrameWalls[k5_ViewSquare_D2R]._box); } } + void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) { + static DoorFrames g183_doorFrame_D2C = DoorFrames( // @ G0183_s_Graphic558_Frames_Door_D2C + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(80, 143, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ + Frame(80, 143, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ + Frame(80, 143, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ + Frame(80, 143, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ + Frame(80, 87, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ + Frame(80, 95, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ + Frame(80, 103, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ + Frame(136, 143, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ + Frame(128, 143, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ + Frame(120, 143, 24, 82, 32, 61, 32, 0) /* Right Horizontal Closed three fourth */ + ); + int16 order; int16 squareAspect[5]; @@ -1873,6 +1862,20 @@ T0121016: } void DisplayMan::f122_drawSquareD1L(direction dir, int16 posX, int16 posY) { + static DoorFrames g185_doorFrame_D1L = DoorFrames( // @ G0185_s_Graphic558_Frames_Door_D1L + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(0, 31, 17, 102, 48, 88, 64, 0), /* Closed Or Destroyed */ + Frame(0, 31, 17, 38, 48, 88, 64, 66), /* Vertical Closed one fourth */ + Frame(0, 31, 17, 60, 48, 88, 64, 44), /* Vertical Closed half */ + Frame(0, 31, 17, 82, 48, 88, 64, 22), /* Vertical Closed three fourth */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed one fourth */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed half */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed three fourth */ + Frame(20, 31, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */ + Frame(8, 31, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */ + Frame(0, 31, 17, 102, 48, 88, 52, 0) /* Right Horizontal Closed three fourth */ + ); + int16 order; int16 squareAspect[5]; @@ -1924,7 +1927,22 @@ T0122021: f113_drawField(&g188_FieldAspects[k7_ViewSquare_D1L], g163_FrameWalls[k7_ViewSquare_D1L]._box); } } + void DisplayMan::f123_drawSquareD1R(direction dir, int16 posX, int16 posY) { + static DoorFrames g187_doorFrame_D1R = DoorFrames( // @ G0187_s_Graphic558_Frames_Door_D1R + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(192, 223, 17, 102, 48, 88, 0, 0), /* Closed Or Destroyed */ + Frame(192, 223, 17, 38, 48, 88, 0, 66), /* Vertical Closed one fourth */ + Frame(192, 223, 17, 60, 48, 88, 0, 44), /* Vertical Closed half */ + Frame(192, 223, 17, 82, 48, 88, 0, 22), /* Vertical Closed three fourth */ + Frame(192, 203, 17, 102, 48, 88, 36, 0), /* Left Horizontal Closed one fourth */ + Frame(192, 215, 17, 102, 48, 88, 24, 0), /* Left Horizontal Closed half */ + Frame(192, 223, 17, 102, 48, 88, 12, 0), /* Left Horizontal Closed three fourth */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Right Horizontal Closed one fourth */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Right Horizontal Closed half */ + Frame(0, 0, 0, 0, 0, 0, 0, 0) + ); /* Right Horizontal Closed three fourth */ + int16 order; int16 squareAspect[5]; -- cgit v1.2.3 From e02d165fceedec6aff32cc9529b72b07cf8d103a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Jul 2016 01:29:05 +0200 Subject: DM: Move g186_doorFrame_D1C to DisplayMan --- engines/dm/gfx.cpp | 33 ++++++++++++++++++--------------- engines/dm/gfx.h | 2 +- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 799ff45ee6..7411f0cc0c 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -53,19 +53,6 @@ uint16 g208_doorButtonCoordSets[1][4][6] = { // @ G0208_aaauc_Graphic558_DoorBut {144, 155, 42, 47, 8, 6}, /* D2C */ {160, 175, 44, 52, 8, 9}}}; /* D1C */ -DoorFrames g186_doorFrame_D1C = { // @ G0186_s_Graphic558_Frames_Door_D1C - /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(64, 159, 17, 102, 48, 88, 0, 0), /* Closed Or Destroyed */ - Frame(64, 159, 17, 38, 48, 88, 0, 66), /* Vertical Closed one fourth */ - Frame(64, 159, 17, 60, 48, 88, 0, 44), /* Vertical Closed half */ - Frame(64, 159, 17, 82, 48, 88, 0, 22), /* Vertical Closed three fourth */ - Frame(64, 75, 17, 102, 48, 88, 36, 0), /* Left Horizontal Closed one fourth */ - Frame(64, 87, 17, 102, 48, 88, 24, 0), /* Left Horizontal Closed half */ - Frame(64, 99, 17, 102, 48, 88, 12, 0), /* Left Horizontal Closed three fourth */ - Frame(148, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */ - Frame(136, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */ - Frame(124, 159, 17, 102, 48, 88, 48, 0)}; /* Right Horizontal Closed three fourth */ - uint16 g207_doorOrnCoordSets[4][3][6] = { // @ G0207_aaauc_Graphic558_DoorOrnamentCoordinateSets /* { X1, X2, Y1, Y2, ByteWidth, Height } */ {{17, 31, 8, 17, 8, 10}, /* D3LCR */ @@ -718,6 +705,20 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _g322_paletteSwitchingEnabled = false; warning("DUMMY CODE: setting _g304_dungeonViewPaletteIndex"); _g304_dungeonViewPaletteIndex = 0; + + g186_doorFrame_D1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C + /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ + Frame(64, 159, 17, 102, 48, 88, 0, 0), /* Closed Or Destroyed */ + Frame(64, 159, 17, 38, 48, 88, 0, 66), /* Vertical Closed one fourth */ + Frame(64, 159, 17, 60, 48, 88, 0, 44), /* Vertical Closed half */ + Frame(64, 159, 17, 82, 48, 88, 0, 22), /* Vertical Closed three fourth */ + Frame(64, 75, 17, 102, 48, 88, 36, 0), /* Left Horizontal Closed one fourth */ + Frame(64, 87, 17, 102, 48, 88, 24, 0), /* Left Horizontal Closed half */ + Frame(64, 99, 17, 102, 48, 88, 12, 0), /* Left Horizontal Closed three fourth */ + Frame(148, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */ + Frame(136, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */ + Frame(124, 159, 17, 102, 48, 88, 48, 0) /* Right Horizontal Closed three fourth */ + ); } DisplayMan::~DisplayMan() { @@ -760,6 +761,8 @@ DisplayMan::~DisplayMan() { delete[] _g92_bitmapWall_D1LCR_Flipped; delete[] _g93_bitmapWall_D0L_Flipped; delete[] _g94_bitmapWall_D0R_Flipped; + + delete g186_doorFrame_D1C; } void DisplayMan::setUpScreens(uint16 width, uint16 height) { @@ -1351,7 +1354,7 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d f131_flipVertical(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight); } } - if ((doorFramesTemp == &g186_doorFrame_D1C) && _vm->_championMan->_g407_party._event73Count_ThievesEye) { + if ((doorFramesTemp == g186_doorFrame_D1C) && _vm->_championMan->_g407_party._event73Count_ThievesEye) { f109_drawDoorOrnament(_vm->M0_indexToOrdinal(k16_DoorOrnThivesEyeMask), k2_ViewDoorOrnament_D1LCR); } if (doorState == k4_doorState_CLOSED) { @@ -2054,7 +2057,7 @@ void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) { f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C); } f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], - _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &g186_doorFrame_D1C); + _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, g186_doorFrame_D1C); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; goto T0124018; case k2_ElementTypePit: diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 4cdf6139ff..2fc01fbc45 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -504,7 +504,7 @@ class DisplayMan { uint32 *_packedItemPos; byte *_packedBitmaps; byte **_bitmaps; - + DoorFrames *g186_doorFrame_D1C; // pointers are not owned by these fields byte *_g75_palChangesProjectile[4]; // @G0075_apuc_PaletteChanges_Projectile -- cgit v1.2.3 From 723c96fffe2d0eb1775983f3059828ac58354a0e Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:50:01 +0200 Subject: DM: Clean up some initialization --- engines/dm/champion.cpp | 20 +- engines/dm/champion.h | 21 +- engines/dm/dm.cpp | 78 ++- engines/dm/dm.h | 5 +- engines/dm/dungeonman.cpp | 52 +- engines/dm/dungeonman.h | 7 +- engines/dm/eventman.cpp | 24 +- engines/dm/group.cpp | 1694 ++++++++++++++++++++++++++++++++++++++++++++- engines/dm/group.h | 3 +- engines/dm/inventory.cpp | 43 +- engines/dm/inventory.h | 1 + engines/dm/menus.cpp | 1 + engines/dm/menus.h | 5 +- engines/dm/movesens.cpp | 13 +- engines/dm/objectman.cpp | 3 + engines/dm/projexpl.cpp | 6 + engines/dm/text.cpp | 28 + engines/dm/text.h | 3 + engines/dm/timeline.cpp | 3 + 19 files changed, 1922 insertions(+), 88 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 5c1f5466a7..644914081e 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -96,18 +96,22 @@ uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks Box gBoxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { - _g411_leaderIndex = kM1_ChampionNone; - - _g303_partyDead = false; - _g300_partyIsSleeping = false; - _g413_leaderHandObjectIconIndex = kM1_IconIndiceNone; - _g415_leaderEmptyHanded = true; - _g514_magicCasterChampionIndex = kM1_ChampionNone; for (uint16 i = 0; i < 4; ++i) { _g409_championPendingDamage[i] = 0; _g410_championPendingWounds[i] = 0; + _gK71_champions[i].resetToZero(); } - + _g305_partyChampionCount = 0; + _g303_partyDead = false; + _g414_leaderHandObject = Thing(0); + _g411_leaderIndex = kM1_ChampionNone; + _g300_partyIsSleeping = false; + _g506_actingChampionOrdinal = 0; + _g413_leaderHandObjectIconIndex = (IconIndice)0; + _g415_leaderEmptyHanded = false; + _g407_party.resetToZero(); + _g514_magicCasterChampionIndex = kM1_ChampionNone; + _g420_mousePointerHiddenToDrawChangedObjIconOnScreen = false; } bool ChampionMan::f329_isLeaderHandObjectThrown(int16 side) { diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 282889d09e..a17f92ee2b 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -62,11 +62,7 @@ public: class Party { public: Party() { - _magicalLightAmount = _event73Count_ThievesEye = _event79Count_Footprints = _shieldDefense = 0; - _fireShieldDefense = _spellShieldDefense = _scentCount = _freezeLifeTicks = _firstScentIndex = 0; - _lastScentIndex = _event71Count_Invisibility = 0; - for (int16 i = 0; i < 24; ++i) - _scentStrengths[i] = 0; + resetToZero(); } int16 _magicalLightAmount; byte _event73Count_ThievesEye; @@ -83,6 +79,21 @@ public: Scent _scents[24]; // if I remember correctly, user defined default constructors are always called byte _scentStrengths[24]; byte _event71Count_Invisibility; + void resetToZero() { + _magicalLightAmount = 0; + _event73Count_ThievesEye = 0; + _event79Count_Footprints = 0; + _shieldDefense = 0; + + _fireShieldDefense = 0; + _spellShieldDefense = 0; + _scentCount = 0; + _freezeLifeTicks = 0; + _firstScentIndex = 0; + for (int16 i = 0; i < 24; ++i) + _scentStrengths[i] = 0; + _event71Count_Invisibility = 0; + } }; // @ PARTY enum IconIndice { diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 51b33c321d..aa47af2f7a 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -133,19 +133,31 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _groupMan = nullptr; _timeline = nullptr; _projexpl = nullptr; - _g321_stopWaitingForPlayerInput = false; + + _g298_newGame = false; + _g523_restartGameRequest = false; + _g321_stopWaitingForPlayerInput = true; _g301_gameTimeTicking = false; _g524_restartGameAllowed = false; + _g525_gameId = 0; _g331_pressingEye = false; - _g333_pressingMouth = false; _g332_stopPressingEye = false; + _g333_pressingMouth = false; _g334_stopPressingMouth = false; _g340_highlightBoxInversionRequested = false; - _g313_gameTime = 0; + _g311_projectileDisableMovementTicks = 0; + _g312_lastProjectileDisabledMovementDirection = 0; _g302_gameWon = false; _g327_newPartyMapIndex = kM1_mapIndexNone; - + _g325_setMousePointerToObjectInMainLoop = false; + _g310_disabledMovementTicks = 0; + _g313_gameTime = 0; + _g353_stringBuildBuffer[0] = '\0'; debug("DMEngine::DMEngine"); + + + warning("DUMMY CODE: setting _g298_newGame to true, should be in processEntrance"); + _g298_newGame = true; } DMEngine::~DMEngine() { @@ -184,23 +196,26 @@ void DMEngine::f463_initializeGame() { _displayMan->f479_loadGraphics(); _displayMan->f460_initializeGraphicData(); // DUMMY CODE: next line - _displayMan->loadPalette(g19_PalCredits); + _displayMan->loadPalette(g21_PalDungeonView[0]); + _displayMan->f94_loadFloorSet(k0_FloorSetStone); + _displayMan->f95_loadWallSet(k0_WallSetStone); + _textMan->f54_textInitialize(); + _objectMan->loadObjectNames(); _eventMan->initMouse(); - + //F0441_STARTEND_ProcessEntrance(); while (_loadsaveMan->f435_loadgame() != k1_LoadgameSuccess) { warning("TODO: F0441_STARTEND_ProcessEntrance"); } + //F0396_MENUS_LoadSpellAreaLinesBitmap() is not needed, every bitmap has been loaded - _displayMan->f94_loadFloorSet(k0_FloorSetStone); - _displayMan->f95_loadWallSet(k0_WallSetStone); - _objectMan->loadObjectNames(); // There was some memory wizardy for the Amiga platform, I skipped that part _displayMan->f461_allocateFlippedWallBitmaps(); f462_startGame(); - warning("MISSING CODE: F0267_MOVE_GetMoveResult_CPSCE (if newGame)"); + if (_g298_newGame) + _movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); _eventMan->f78_showMouse(); _eventMan->f357_discardAllInput(); } @@ -212,6 +227,11 @@ void DMEngine::f448_initMemoryManager() { } void DMEngine::f462_startGame() { + static Box g61_boxScreenTop(0, 319, 0, 32); // @ G0061_s_Graphic562_Box_ScreenTop + static Box g62_boxScreenRight(224, 319, 33, 169); // @ G0062_s_Graphic562_Box_ScreenRight + static Box g63_boxScreenBottom(0, 319, 169, 199); // @ G0063_s_Graphic562_Box_ScreenBottom + + _g331_pressingEye = false; _g332_stopPressingEye = false; _g333_pressingMouth = false; @@ -231,9 +251,12 @@ void DMEngine::f462_startGame() { if (!_g298_newGame) { warning("TODO: loading game"); + assert(false); } else { _displayMan->_g578_useByteBoxCoordinates = false; - warning("TODO: clear screen"); + _displayMan->D24_fillScreenBox(g61_boxScreenTop, k0_ColorBlack); + _displayMan->D24_fillScreenBox(g62_boxScreenRight, k0_ColorBlack); + _displayMan->D24_fillScreenBox(g63_boxScreenBottom, k0_ColorBlack); } warning("TODO: build copper"); @@ -243,10 +266,10 @@ void DMEngine::f462_startGame() { } void DMEngine::f3_processNewPartyMap(uint16 mapIndex) { - warning("MISSING CODE: F0194_GROUP_RemoveAllActiveGroups"); + _groupMan->f194_removeAllActiveGroups(); _dungeonMan->f174_setCurrentMapAndPartyMap(mapIndex); _displayMan->f96_loadCurrentMapGraphics(); - warning("MISSING CODE: F0195_GROUP_AddAllActiveGroups"); + _groupMan->f195_addAllActiveGroups(); _inventoryMan->f337_setDungeonViewPalette(); } @@ -290,8 +313,31 @@ void DMEngine::f2_gameloop() { warning("DUMMY CODE: clearing screen to black"); // in loop below while (true) { + if (_g327_newPartyMapIndex != kM1_mapIndexNone) { + T0002002: + f3_processNewPartyMap(_g327_newPartyMapIndex); + _movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); + _g327_newPartyMapIndex = kM1_mapIndexNone; + _eventMan->f357_discardAllInput(); + } + // MISSING: F0261_TIMELINE_Process_CPSEF + + if (_g327_newPartyMapIndex != kM1_mapIndexNone) + goto T0002002; + + if (_championMan->_g303_partyDead) + break; _g313_gameTime++; + + if (!(_g313_gameTime & 511)) + _inventoryMan->f338_decreaseTorchesLightPower(); + if (_g310_disabledMovementTicks) { + _g310_disabledMovementTicks--; + } + if (_championMan->_g407_party._freezeLifeTicks) { + _championMan->_g407_party._freezeLifeTicks -= 1; + } _menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived(); if (_g311_projectileDisableMovementTicks) @@ -299,9 +345,9 @@ void DMEngine::f2_gameloop() { _g321_stopWaitingForPlayerInput = false; //do { - _eventMan->processInput(); - _eventMan->f380_processCommandQueue(); - //} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking); + _eventMan->processInput(); + _eventMan->f380_processCommandQueue(); + //} while (!_g321_stopWaitingForPlayerInput /*|| !_g301_gameTimeTicking */); if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { Box box(0, 223, 0, 135); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 9ace815f51..3f7f55823c 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -180,7 +180,6 @@ class DMEngine : public Engine { void f448_initMemoryManager(); // @ F0448_STARTUP1_InitializeMemoryManager_CPSADEF void f2_gameloop(); // @ F0002_MAIN_GameLoop_CPSDF void initArrays(); - public: explicit DMEngine(OSystem *syst); ~DMEngine(); @@ -218,7 +217,7 @@ public: bool _g321_stopWaitingForPlayerInput; // @ G0321_B_StopWaitingForPlayerInput bool _g301_gameTimeTicking; // @ G0301_B_GameTimeTicking bool _g524_restartGameAllowed; // @ G0524_B_RestartGameAllowed - uint32 _g525_gameId; // @ G0525_l_GameID, probably useless here + int32 _g525_gameId; // @ G0525_l_GameID, probably useless here bool _g331_pressingEye; // @ G0331_B_PressingEye bool _g332_stopPressingEye; // @ G0332_B_StopPressingEye bool _g333_pressingMouth; // @ G0333_B_PressingMouth @@ -229,8 +228,8 @@ public: bool _g302_gameWon; // @ G0302_B_GameWon int16 _g327_newPartyMapIndex; // @ G0327_i_NewPartyMapIndex bool _g325_setMousePointerToObjectInMainLoop; // @ G0325_B_SetMousePointerToObjectInMainLoop + int16 _g310_disabledMovementTicks; // @ G0310_i_DisabledMovementTicks - // TODO: refactor direction into a class int8 _dirIntoStepCountEast[4]; // @ G0233_ai_Graphic559_DirectionToStepEastCount int8 _dirIntoStepCountNorth[4]; // @ G0234_ai_Graphic559_DirectionToStepNorthCount uint32 _g313_gameTime; // @ G0313_ul_GameTime diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index c7f59b7c97..b4cd96448a 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -369,59 +369,43 @@ void DungeonMan::f150_mapCoordsAfterRelMovement(direction dir, int16 stepsForwar posY += _vm->_dirIntoStepCountNorth[dir] * stepsRight; } -DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _g277_dungeonMaps(NULL), _g276_dungeonRawMapData(NULL) { +DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine) { + _rawDunFileDataSize = 0; + _rawDunFileData = nullptr; _g282_dungeonColumCount = 0; - _g281_dungeonMapsFirstColumnIndex = nullptr; + + + _g282_dungeonColumCount = 0; _g280_dungeonColumnsCumulativeSquareThingCount = nullptr; _g283_squareFirstThings = nullptr; _g260_dungeonTextData = nullptr; - _g279_dungeonMapData = nullptr; - - for (int i = 0; i < 16; i++) + for (uint16 i = 0; i < 16; ++i) _g284_thingData[i] = nullptr; - - _g308_partyDir = kDirNorth; + _g279_dungeonMapData = nullptr; + _g308_partyDir = (direction)0; _g306_partyMapX = 0; _g307_partyMapY = 0; _g309_partyMapIndex = 0; _g272_currMapIndex = kM1_mapIndexNone; - _g273_currMapWidth = 0; - _g274_currMapHeight = 0; - _g271_currMapData = nullptr; _g269_currMap = nullptr; + _g273_currMapWidth = 0; + _g274_currMapHeight = 0; _g270_currMapColCumulativeSquareFirstThingCount = nullptr; - - _vm->_g298_newGame = true; - _vm->_g523_restartGameRequest = false; - - _rawDunFileDataSize = 0; - _rawDunFileData = nullptr; - - _g278_dungeonFileHeader._dungeonId = 0; - _g278_dungeonFileHeader._ornamentRandomSeed = 0; - _g278_dungeonFileHeader._rawMapDataSize = 0; - _g278_dungeonFileHeader._mapCount = 0; - _g278_dungeonFileHeader._textDataWordCount = 0; - _g278_dungeonFileHeader._partyStartDir = kDirNorth; - _g278_dungeonFileHeader._partyStartPosX = 0; - _g278_dungeonFileHeader._partyStartPosY = 0; - _g278_dungeonFileHeader._squareFirstThingCount = 0; - - for (int i = 0; i < 16; i++) - _g278_dungeonFileHeader._thingCounts[i] = 0; - _g277_dungeonMaps = nullptr; _g276_dungeonRawMapData = nullptr; - _g265_currMapInscriptionWallOrnIndex = 0; + for (uint16 i = 0; i < 6; ++i) + _g291_dungeonViewClickableBoxes[i].setToZero(); _g286_isFacingAlcove = false; _g287_isFacingViAltar = false; _g288_isFacingFountain = false; - - for (int j = 0; j < 6; j++) - _g291_dungeonViewClickableBoxes[j].setToZero(); + _g285_squareAheadElement = (ElementType)0; + for (uint16 i = 0; i < 5; ++i) + _g292_pileTopObject[i] = Thing(0); + for (uint16 i = 0; i < 2; ++i) + _g275_currMapDoorInfo[i].resetToZero(); } DungeonMan::~DungeonMan() { diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index c591881094..26841a24bc 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -51,6 +51,7 @@ enum ElementType { k1_ElementTypeCorridor = 1, // @ C01_ELEMENT_CORRIDOR k2_ElementTypePit = 2, // @ C02_ELEMENT_PIT k3_ElementTypeStairs = 3, // @ C03_ELEMENT_STAIRS + // TODO: refactor direction into a class k4_ElementTypeDoor = 4, // @ C04_ELEMENT_DOOR k5_ElementTypeTeleporter = 5, // @ C05_ELEMENT_TELEPORTER k6_ElementTypeFakeWall = 6, // @ C06_ELEMENT_FAKEWALL @@ -374,13 +375,14 @@ public: _desc &= (~(1 << 15)); } uint16 getChargeCount() { return (_desc >> 10) & 0xF; } - void setChargeCount(uint16 val) { _desc = (_desc & ~(0xF << 10)) | ((val & 0xF) << 10); } + uint16 setChargeCount(uint16 val) { _desc = (_desc & ~(0xF << 10)) | ((val & 0xF) << 10); return (val & 0xF); } Thing getNextThing() { return _nextThing; } uint16 getCursed() { return (_desc >> 8) & 1; } void setCursed(uint16 val) { _desc = (_desc & ~(1 << 8)) | ((val & 1) << 8); } uint16 getPoisoned() { return (_desc >> 9) & 1; } uint16 getBroken() { return (_desc >> 14) & 1; } uint16 getDoNotDiscard() { return (_desc >> 7) & 1; } + void setDoNotDiscard(uint16 val) { _desc = (_desc & ~(1 << 7)) | ((val & 1) << 7); } }; // @ WEAPON enum ArmourType { @@ -631,7 +633,8 @@ public: byte _attributes; byte _defense; DoorInfo(byte b1, byte b2) : _attributes(b1), _defense(b2) {} - DoorInfo() {} + DoorInfo() { resetToZero(); } + void resetToZero() { _attributes = _defense = 0; } }; // @ DOOR_INFO class Group; diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 0104883e21..99a0e17769 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -290,20 +290,22 @@ MouseInput* g480_PrimaryMouseInput_DialogSets[2][4] = { // @ G0480_aaps_PrimaryM EventManager::EventManager(DMEngine *vm) : _vm(vm) { - _g441_primaryMouseInput = nullptr; - _g442_secondaryMouseInput = nullptr; - - _g436_pendingClickPresent = false; - _g435_isCommandQueueLocked = true; - _g598_mousePointerBitmapUpdated = false; - _g326_refreshMousePointerInMainLoop = false; - _g341_highlightBoxEnabled = false; - + _mousePos = Common::Point(0, 0); _dummyMapIndex = 0; - _g439_pendingClickButton = k0_NoneMouseButton; + _g436_pendingClickPresent = false; + _g437_pendingClickPos = Common::Point(0, 0); _g615_mousePointerOriginalColorsObject = nullptr; _g613_mousePointerOriginalColorsChampionIcon = nullptr; _gK190_mousePointerTempBuffer = nullptr; + _g435_isCommandQueueLocked = true; + _gK104_mousePointerType = 0; + _gK105_previousMousePointerType = 0; + _g441_primaryMouseInput = nullptr; + _g442_secondaryMouseInput = nullptr; + _g598_mousePointerBitmapUpdated = true; + _g326_refreshMousePointerInMainLoop = false; + _g341_highlightBoxEnabled = false; + _g599_useChampionIconOrdinalAsMousePointerBitmap = 0; } EventManager::~EventManager() { @@ -324,7 +326,7 @@ void EventManager::initMouse() { _gK105_previousMousePointerType = k1_pointerHand; _mousePos = Common::Point(0, 0); - CursorMan.pushCursor(g42_bitmapArrowPointer, 32, 18, 0, 0, 0); + f73_buildpointerScreenArea(_mousePos.x, _mousePos.y); CursorMan.showMouse(false); diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index b4e89e0402..f12ef8e57e 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -28,15 +28,38 @@ #include "group.h" #include "dungeonman.h" #include "champion.h" - +#include "movesens.h" +#include "projexpl.h" +#include "timeline.h" namespace DM { - +int32 M32_setTime(int32 &map_time, int32 time) { + return map_time = (map_time & 0xFF000000) | time; +} GroupMan::GroupMan(DMEngine* vm) : _vm(vm) { - _g375_activeGroups = nullptr; + for (uint16 i = 0; i < 4; ++i) + _g392_dropMovingCreatureFixedPossessionsCell[i] = 0; + _g391_dropMovingCreatureFixedPossCellCount = 0; + _g386_fluxCageCount = 0; + for (uint16 i = 0; i < 4; ++i) + _g385_fluxCages[i] = 0; + _g378_currentGroupMapX = 0; + _g379_currentGroupMapY = 0; + _g380_currGroupThing = Thing(0); + for (uint16 i = 0; i < 4; ++i) + _g384_groupMovementTestedDirections[i] = 0; + _g381_currGroupDistanceToParty = 0; + _g382_currGroupPrimaryDirToParty = 0; + _g383_currGroupSecondaryDirToParty = 0; + _g388_groupMovementBlockedByGroupThing = Thing(0); + _g389_groupMovementBlockedByDoor = false; + _g390_groupMovementBlockedByParty = false; + _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = false; _g376_maxActiveGroupCount = 60; + _g375_activeGroups = nullptr; + _g377_currActiveGroupCount = 0; } GroupMan::~GroupMan() { @@ -98,4 +121,1669 @@ int16 GroupMan::f176_getCreatureOrdinalInCell(Group* group, uint16 cell) { uint16 GroupMan::M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex) { return (groupVal >> (creatureIndex << 1)) & 0x3; } + +void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode) { + Thing L0365_T_CurrentThing; + Thing L0366_T_NextThing; + Group* L0367_ps_Group; + uint16 L0368_ui_CreatureType; + int16 L0369_i_CreatureIndex; + uint16 L0370_ui_GroupCells; + bool L0371_B_WeaponDropped; + + + L0367_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(groupThing); + if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[L0368_ui_CreatureType = L0367_ps_Group->_type]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) { + L0369_i_CreatureIndex = L0367_ps_Group->getCount(); + L0370_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(L0367_ps_Group, _vm->_dungeonMan->_g272_currMapIndex); + do { + _vm->_groupMan->f186_dropCreatureFixedPossessions(L0368_ui_CreatureType, mapX, mapY, (L0370_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0370_ui_GroupCells, L0369_i_CreatureIndex), mode); + } while (L0369_i_CreatureIndex--); + } + if ((L0365_T_CurrentThing = L0367_ps_Group->_slot) != Thing::_endOfList) { + L0371_B_WeaponDropped = false; + do { + L0366_T_NextThing = _vm->_dungeonMan->f159_getNextThing(L0365_T_CurrentThing); + L0365_T_CurrentThing = M15_thingWithNewCell(L0365_T_CurrentThing, _vm->getRandomNumber(4)); + if ((L0365_T_CurrentThing).getType() == k5_WeaponThingType) { + L0371_B_WeaponDropped = true; + } + _vm->_movsens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY); + } while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList); + if (mode >= k0_soundModePlayImmediately) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + } +} + +void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX, int16 mapY, uint16 cell, int16 mode) { + static uint16 g245FixedPossessionCreature_12Skeleton[3] = { // @ G0245_aui_Graphic559_FixedPossessionsCreature12Skeleton + k23_ObjectInfoIndexFirstWeapon + k9_WeaponTypeFalchion, + k69_ObjectInfoIndexFirstArmour + k30_ArmourTypeWoodenShield, 0}; + static uint16 g246FixedPossessionCreature_9StoneGolem[2] = { // @ G0246_aui_Graphic559_FixedPossessionsCreature09StoneGolem + k23_ObjectInfoIndexFirstWeapon + k24_WeaponTypeStoneClub, 0}; + static uint16 g247FixedPossessionCreature_16TrolinAntman[2] = { // @ G0247_aui_Graphic559_FixedPossessionsCreature16Trolin_Antman + k23_ObjectInfoIndexFirstWeapon + k23_WeaponTypeClub, 0}; + static uint16 g248FixedPossessionCreature_18AnimatedArmourDethKnight[7] = { // @ G0248_aui_Graphic559_FixedPossessionsCreature18AnimatedArmour_DethKnight + k69_ObjectInfoIndexFirstArmour + k41_ArmourTypeFootPlate, + k69_ObjectInfoIndexFirstArmour + k40_ArmourTypeLegPlate, + k69_ObjectInfoIndexFirstArmour + k39_ArmourTypeTorsoPlate, + k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword, + k69_ObjectInfoIndexFirstArmour + k38_ArmourTypeArmet, + k23_ObjectInfoIndexFirstWeapon + k10_WeaponTypeSword, 0}; + static uint16 g249FixedPossessionCreature_7rockRockPile[5] = { // @ G0249_aui_Graphic559_FixedPossessionsCreature07Rock_RockPile + k127_ObjectInfoIndexFirstJunk + k25_JunkTypeBoulder, + k127_ObjectInfoIndexFirstJunk + k25_JunkTypeBoulder | k0x8000_randomDrop, + k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop, + k23_ObjectInfoIndexFirstWeapon + k30_WeaponTypeRock | k0x8000_randomDrop, 0}; + static uint16 g250FixedPossessionCreature_4PainRatHellHound[3] = { // @ G0250_aui_Graphic559_FixedPossessionsCreature04PainRat_Hellhound + k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank, + k127_ObjectInfoIndexFirstJunk + k35_JunkTypeDrumstickShank | k0x8000_randomDrop, 0}; + static uint16 g251FixedPossessionCreature_6screamer[3] = { // @ G0251_aui_Graphic559_FixedPossessionsCreature06Screamer + k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice, + k127_ObjectInfoIndexFirstJunk + k33_JunkTypeScreamerSlice | k0x8000_randomDrop, 0}; + static uint16 g252FixedPossessionCreature_15MagnetaWormWorm[4] = { // @ G0252_aui_Graphic559_FixedPossessionsCreature15MagentaWorm_Worm + k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound, + k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop, + k127_ObjectInfoIndexFirstJunk + k34_JunkTypeWormRound | k0x8000_randomDrop, 0}; + static uint16 g253FixedPossessionCreature_24RedDragon[11] = { // @ G0253_aui_Graphic559_FixedPossessionsCreature24RedDragon + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop, + k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop, 0}; + + uint16 L0356_ui_FixedPossession; + int16 L0357_i_ThingType; + Thing L0358_T_Thing; + uint16* L0359_pui_FixedPossessions; + Weapon* L0360_ps_Weapon; + bool L0361_B_Cursed; + bool L0362_B_WeaponDropped; + + + L0361_B_Cursed = false; + L0362_B_WeaponDropped = false; + switch (creatureType) { + default: + return; + case k12_CreatureTypeSkeleton: + L0359_pui_FixedPossessions = g245FixedPossessionCreature_12Skeleton; + break; + case k9_CreatureTypeStoneGolem: + L0359_pui_FixedPossessions = g246FixedPossessionCreature_9StoneGolem; + break; + case k16_CreatureTypeTrolinAntman: + L0359_pui_FixedPossessions = g247FixedPossessionCreature_16TrolinAntman; + break; + case k18_CreatureTypeAnimatedArmourDethKnight: + L0361_B_Cursed = true; + L0359_pui_FixedPossessions = g248FixedPossessionCreature_18AnimatedArmourDethKnight; + break; + case k7_CreatureTypeRockpile: + L0359_pui_FixedPossessions = g249FixedPossessionCreature_7rockRockPile; + break; + case k4_CreatureTypePainRatHellHound: + L0359_pui_FixedPossessions = g250FixedPossessionCreature_4PainRatHellHound; + break; + case k6_CreatureTypeScreamer: + L0359_pui_FixedPossessions = g251FixedPossessionCreature_6screamer; + break; + case k15_CreatureTypeMagnetaWormWorm: + L0359_pui_FixedPossessions = g252FixedPossessionCreature_15MagnetaWormWorm; + break; + case k24_CreatureTypeRedDragon: + L0359_pui_FixedPossessions = g253FixedPossessionCreature_24RedDragon; + } + while (L0356_ui_FixedPossession = *L0359_pui_FixedPossessions++) { + if (getFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) && _vm->getRandomNumber(2)) + continue; + if (clearFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) >= k127_ObjectInfoIndexFirstJunk) { + L0357_i_ThingType = k10_JunkThingType; + L0356_ui_FixedPossession -= k127_ObjectInfoIndexFirstJunk; + } else { + if (L0356_ui_FixedPossession >= k69_ObjectInfoIndexFirstArmour) { + L0357_i_ThingType = k6_ArmourThingType; + L0356_ui_FixedPossession -= k69_ObjectInfoIndexFirstArmour; + } else { + L0362_B_WeaponDropped = true; + L0357_i_ThingType = k5_WeaponThingType; + L0356_ui_FixedPossession -= k23_ObjectInfoIndexFirstWeapon; + } + } + if ((L0358_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(L0357_i_ThingType)) == Thing::_none) { + continue; + } + L0360_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0358_T_Thing); +/* The same pointer type is used no matter the actual type k5_WeaponThingType, k6_ArmourThingType or k10_JunkThingType */ + L0360_ps_Weapon->setType(L0356_ui_FixedPossession); + L0360_ps_Weapon->setCursed(L0361_B_Cursed); + L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell); + _vm->_movsens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY); + } + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); +} + +int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) { +#define AP0483_i_PrimaryDirection srcMapX + int16 L0556_i_Direction; + + + if (srcMapX == destMapX) { + _vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 1; /* Resulting direction may be 1 or 3 (East or West) */ + if (srcMapY > destMapY) { + return kDirNorth; + } + return kDirSouth; + } + if (srcMapY == destMapY) { + _vm->_projexpl->_g363_secondaryDirToOrFromParty = (_vm->getRandomNumber(65536) & 0x0002) + 0; /* Resulting direction may be 0 or 2 (North or South) */ + if (srcMapX > destMapX) { + return kDirWest; + } + return kDirEast; + } + L0556_i_Direction = kDirNorth; + for (;;) { + if (f227_isDestVisibleFromSource(L0556_i_Direction, srcMapX, srcMapY, destMapX, destMapY)) { + if (!f227_isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) { + if ((L0556_i_Direction != kDirNorth) || !f227_isDestVisibleFromSource(_vm->_projexpl->_g363_secondaryDirToOrFromParty = returnPrevVal(L0556_i_Direction), srcMapX, srcMapY, destMapX, destMapY)) { + _vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + L0556_i_Direction); + return L0556_i_Direction; + } + } + if (_vm->getRandomNumber(2)) { + AP0483_i_PrimaryDirection = _vm->_projexpl->_g363_secondaryDirToOrFromParty; + _vm->_projexpl->_g363_secondaryDirToOrFromParty = L0556_i_Direction; + return AP0483_i_PrimaryDirection; + } + return L0556_i_Direction; + } + L0556_i_Direction++; + } +} + +bool GroupMan::f227_isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) { + int L1637_i_Temp; + + switch (dir) { /* If direction is not 'West' then swap variables so that the same test as for west can be applied */ + case kDirSouth: + L1637_i_Temp = srcMapX; + srcMapX = destMapY; + destMapY = L1637_i_Temp; + L1637_i_Temp = destMapX; + destMapX = srcMapY; + srcMapY = L1637_i_Temp; + break; + case kDirEast: + L1637_i_Temp = srcMapX; + srcMapX = destMapX; + destMapX = L1637_i_Temp; + L1637_i_Temp = destMapY; + destMapY = srcMapY; + srcMapY = L1637_i_Temp; + break; + case kDirNorth: + L1637_i_Temp = srcMapX; + srcMapX = srcMapY; + srcMapY = L1637_i_Temp; + L1637_i_Temp = destMapX; + destMapX = destMapY; + destMapY = L1637_i_Temp; + } + return ((srcMapX -= (destMapX - 1)) > 0) && ((((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY) <= srcMapX); +} + +bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack, bool magicAttack, int16 ticks) { + Door* L0573_ps_Door; + byte* L0574_puc_Square; + TimelineEvent L0575_s_Event; + + L0573_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY); + if ((magicAttack && !L0573_ps_Door->isMagicDestructible()) || (!magicAttack && !L0573_ps_Door->isMeleeDestructible())) { + return false; + } + if (attack >= _vm->_dungeonMan->_g275_currMapDoorInfo[L0573_ps_Door->getType()]._defense) { + L0574_puc_Square = &_vm->_dungeonMan->_g271_currMapData[mapX][mapY]; + if (Square(*L0574_puc_Square).getDoorState() == k4_doorState_CLOSED) { + if (ticks) { + M33_setMapAndTime(L0575_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ticks); + L0575_s_Event._type = k2_TMEventTypeDoorDestruction; + L0575_s_Event._priority = 0; + L0575_s_Event._B._location._mapX = mapX; + L0575_s_Event._B._location._mapY = mapY; + _vm->_timeline->f238_addEventGetEventIndex(&L0575_s_Event); + } else { + ((Square*)L0574_puc_Square)->setDoorState(k5_doorState_DESTROYED); + } + return true; + } + } + return false; +} + +Thing GroupMan::f175_groupGetThing(int16 mapX, int16 mapY) { + Thing L0317_T_Thing; + + L0317_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY); + while ((L0317_T_Thing != Thing::_endOfList) && ((L0317_T_Thing).getType() != k4_GroupThingType)) { + L0317_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0317_T_Thing); + } + return L0317_T_Thing; +} + +int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group* group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) { + uint16 L0374_ui_Multiple; +#define AL0374_ui_EventIndex L0374_ui_Multiple +#define AL0374_ui_CreatureIndex L0374_ui_Multiple +#define AL0374_ui_CreatureSize L0374_ui_Multiple +#define AL0374_ui_Attack L0374_ui_Multiple + uint16 L0375_ui_Multiple; +#define AL0375_ui_Outcome L0375_ui_Multiple +#define AL0375_ui_EventType L0375_ui_Multiple +#define AL0375_ui_NextCreatureIndex L0375_ui_Multiple + CreatureInfo* L0376_ps_CreatureInfo; + TimelineEvent* L0377_ps_Event; + ActiveGroup* L0378_ps_ActiveGroup = nullptr; + uint16 L0379_ui_CreatureCount; + uint16 L0380_ui_Multiple = 0; +#define AL0380_ui_CreatureType L0380_ui_Multiple +#define AL0380_ui_FearResistance L0380_ui_Multiple + uint16 L0381_ui_GroupCells; + uint16 L0382_ui_GroupDirections; + bool L0383_B_CurrentMapIsPartyMap; + uint16 L0384_ui_Cell; + + + L0376_ps_CreatureInfo = &g243_CreatureInfo[AL0380_ui_CreatureType = group->_type]; + if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) /* Lord Chaos cannot be damaged */ + goto T0190024; + if (group->_health[creatureIndex] <= damage) { + L0381_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(group, _vm->_dungeonMan->_g272_currMapIndex); + L0384_ui_Cell = (L0381_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0381_ui_GroupCells, creatureIndex); + if (!(L0379_ui_CreatureCount = group->getCount())) { /* If there is a single creature in the group */ + if (notMoving) { + f188_dropGroupPossessions(mapX, mapY, _vm->_groupMan->f175_groupGetThing(mapX, mapY), k2_soundModePlayOneTickLater); + f189_delete(mapX, mapY); + } + AL0375_ui_Outcome = k2_outcomeKilledAllCreaturesInGroup; + } else { /* If there are several creatures in the group */ + L0382_ui_GroupDirections = _vm->_groupMan->f147_getGroupDirections(group, _vm->_dungeonMan->_g272_currMapIndex); + if (getFlag(L0376_ps_CreatureInfo->_attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) { + if (notMoving) { + f186_dropCreatureFixedPossessions(AL0380_ui_CreatureType, mapX, mapY, L0384_ui_Cell, k2_soundModePlayOneTickLater); + } else { + _g392_dropMovingCreatureFixedPossessionsCell[_g391_dropMovingCreatureFixedPossCellCount++] = L0384_ui_Cell; + } + } + if (L0383_B_CurrentMapIsPartyMap = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) { + L0378_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]; + } + if (group->getBehaviour() == k6_behavior_ATTACK) { + L0377_ps_Event = _vm->_timeline->_g370_events; + for (AL0374_ui_EventIndex = 0; AL0374_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; AL0374_ui_EventIndex++) { + if ((M29_map(L0377_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) && + (L0377_ps_Event->_B._location._mapX == mapX) && + (L0377_ps_Event->_B._location._mapY == mapY) && + ((AL0375_ui_EventType = L0377_ps_Event->_type) > k32_TMEventTypeUpdateAspectGroup) && + (AL0375_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1)) { + if (AL0375_ui_EventType < k37_TMEventTypeUpdateBehaviourGroup) { + AL0375_ui_EventType -= k33_TMEventTypeUpdateAspectCreature_0; /* Get creature index for events 33 to 36 */ + } else { + AL0375_ui_EventType -= k38_TMEventTypeUpdateBehaviour_0; /* Get creature index for events 38 to 41 */ + } + if (AL0375_ui_NextCreatureIndex == creatureIndex) { + _vm->_timeline->f237_deleteEvent(AL0374_ui_EventIndex); + } else { + if (AL0375_ui_NextCreatureIndex > creatureIndex) { + L0377_ps_Event->_type -= 1; + _vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(AL0374_ui_EventIndex)); + } + } + } + L0377_ps_Event++; + } + if (L0383_B_CurrentMapIsPartyMap && ((AL0380_ui_FearResistance = L0376_ps_CreatureInfo->M57_getFearResistance()) != k15_immuneToFear) && ((AL0380_ui_FearResistance += L0379_ui_CreatureCount - 1) < (_vm->getRandomNumber(16)))) { /* Test if the death of a creature frigthens the remaining creatures in the group */ + L0378_ps_ActiveGroup->_delayFleeingFromTarget = _vm->getRandomNumber(100 - (AL0380_ui_FearResistance << 2)) + 20; + group->setBehaviour(k5_behavior_FLEE); + } + } + for (AL0375_ui_NextCreatureIndex = AL0374_ui_CreatureIndex = creatureIndex; AL0374_ui_CreatureIndex < L0379_ui_CreatureCount; AL0374_ui_CreatureIndex++) { + AL0375_ui_NextCreatureIndex++; + group->_health[AL0374_ui_CreatureIndex] = group->_health[AL0375_ui_NextCreatureIndex]; + L0382_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0382_ui_GroupDirections, AL0374_ui_CreatureIndex, _vm->_groupMan->M50_getCreatureValue(L0382_ui_GroupDirections, AL0375_ui_NextCreatureIndex)); + L0381_ui_GroupCells = f178_getGroupValueUpdatedWithCreatureValue(L0381_ui_GroupCells, AL0374_ui_CreatureIndex, _vm->_groupMan->M50_getCreatureValue(L0381_ui_GroupCells, AL0375_ui_NextCreatureIndex)); + if (L0383_B_CurrentMapIsPartyMap) { + L0378_ps_ActiveGroup->_aspect[AL0374_ui_CreatureIndex] = L0378_ps_ActiveGroup->_aspect[AL0375_ui_NextCreatureIndex]; + } + } + L0381_ui_GroupCells &= 0x003F; + _vm->_dungeonMan->f146_setGroupCells(group, L0381_ui_GroupCells, _vm->_dungeonMan->_g272_currMapIndex); + _vm->_dungeonMan->f148_setGroupDirections(group, L0382_ui_GroupDirections, _vm->_dungeonMan->_g272_currMapIndex); + group->setCount(group->getCount() - 1); + AL0375_ui_Outcome = k1_outcomeKilledSomeCreaturesInGroup; + } + if ((AL0374_ui_CreatureSize = getFlag(L0376_ps_CreatureInfo->_attributes, k0x0003_MaskCreatureInfo_size)) == k0_MaskCreatureSizeQuarter) { + AL0374_ui_Attack = 110; + } else { + if (AL0374_ui_CreatureSize == k1_MaskCreatureSizeHalf) { + AL0374_ui_Attack = 190; + } else { + AL0374_ui_Attack = 255; + } + } + _vm->_projexpl->f213_explosionCreate(Thing::_explSmoke, AL0374_ui_Attack, mapX, mapY, L0384_ui_Cell); /* BUG0_66 Smoke is placed on the source map instead of the destination map when a creature dies by falling through a pit. The game has a special case to correctly drop the creature possessions on the destination map but there is no such special case for the smoke. Note that the death must be caused by the damage of the fall (there is no smoke if the creature is removed because its type is not allowed on the destination map). However this bug has no visible consequence because of BUG0_26: the smoke explosion falls in the pit right after being placed in the dungeon and before being drawn on screen so it is only visible on the destination square */ + return AL0375_ui_Outcome; + } + if (damage > 0) { + group->_health[creatureIndex] -= damage; + } +T0190024: + return k0_outcomeKilledNoCreaturesInGroup; +} + +void GroupMan::f189_delete(int16 mapX, int16 mapY) { + Thing L0372_T_GroupThing; + Group* L0373_ps_Group; + + + if ((L0372_T_GroupThing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) { + return; + } + L0373_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0372_T_GroupThing); + for (uint16 i = 0; i < 4; ++i) + L0373_ps_Group->_health[i] = 0; + _vm->_movsens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0); + L0373_ps_Group->_nextThing = Thing::_none; + if (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) { + _vm->_groupMan->_g375_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1; + _g377_currActiveGroupCount--; + } + f181_groupDeleteEvents(mapX, mapY); +} + +void GroupMan::f181_groupDeleteEvents(int16 mapX, int16 mapY) { + int16 L0334_i_EventIndex; + uint16 L0335_ui_EventType; + TimelineEvent* L0336_ps_Event; + + + L0336_ps_Event = _vm->_timeline->_g370_events; + for (L0334_i_EventIndex = 0; L0334_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0334_i_EventIndex++) { + if ((M29_map(L0336_ps_Event->_mapTime) == _vm->_dungeonMan->_g272_currMapIndex) && + ((L0335_ui_EventType = L0336_ps_Event->_type) > k29_TMEventTypeGroupReactionDangerOnSquare - 1) && (L0335_ui_EventType < k41_TMEventTypeUpdateBehaviour_3 + 1) && + (L0336_ps_Event->_B._location._mapX == mapX) && (L0336_ps_Event->_B._location._mapY == mapY)) { + _vm->_timeline->f237_deleteEvent(L0334_i_EventIndex); + } + L0336_ps_Event++; + } +} + +uint16 GroupMan::f178_getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uint16 creatureIndex, uint16 creatreVal) { + creatreVal &= 0x0003; + creatreVal <<= (creatureIndex <<= 1); + return creatreVal | (groupVal & ~(3 << creatreVal)); +} + +int16 GroupMan::f191_getDamageAllCreaturesOutcome(Group* group, int16 mapX, int16 mapY, int16 attack, bool notMoving) { + uint16 L0385_ui_RandomAttack; + int16 L0386_i_CreatureIndex; + int16 L0387_i_Outcome; + bool L0388_B_KilledSomeCreatures; + bool L0389_B_KilledAllCreatures; + + + L0388_B_KilledSomeCreatures = false; + L0389_B_KilledAllCreatures = true; + _g391_dropMovingCreatureFixedPossCellCount = 0; + if (attack > 0) { + L0386_i_CreatureIndex = group->getCount(); + attack -= (L0385_ui_RandomAttack = (attack >> 3) + 1); + L0385_ui_RandomAttack <<= 1; + do { + L0389_B_KilledAllCreatures = (L0387_i_Outcome = f190_groupGetDamageCreatureOutcome(group, L0386_i_CreatureIndex, mapX, mapY, attack + _vm->getRandomNumber(L0385_ui_RandomAttack), notMoving)) && L0389_B_KilledAllCreatures; + L0388_B_KilledSomeCreatures = L0388_B_KilledSomeCreatures || L0387_i_Outcome; + } while (L0386_i_CreatureIndex--); + if (L0389_B_KilledAllCreatures) { + return k2_outcomeKilledAllCreaturesInGroup; + } + if (L0388_B_KilledSomeCreatures) { + return k1_outcomeKilledSomeCreaturesInGroup; + } + return k0_outcomeKilledNoCreaturesInGroup; + } else { + return k0_outcomeKilledNoCreaturesInGroup; + } +} + +int16 GroupMan::f192_groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, int16 poisonAttack) { + int16 L0390_i_PoisonResistance; + + + if (!poisonAttack || ((L0390_i_PoisonResistance = g243_CreatureInfo[creatreType].M61_poisonResistance()) == k15_immuneToPoison)) { + return 0; + } + return ((poisonAttack + _vm->getRandomNumber(4)) << 3) / ++L0390_i_PoisonResistance; +} + +void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks) { + Group* L0444_ps_Group; + ActiveGroup* L0445_ps_ActiveGroup; + int16 L0446_i_Multiple; +#define AL0446_i_EventType L0446_i_Multiple +#define AL0446_i_Direction L0446_i_Multiple +#define AL0446_i_Ticks L0446_i_Multiple +#define AL0446_i_Distance L0446_i_Multiple +#define AL0446_i_Behavior2Or3 L0446_i_Multiple +#define AL0446_i_CreatureAspectIndex L0446_i_Multiple +#define AL0446_i_Range L0446_i_Multiple +#define AL0446_i_CreatureAttributes L0446_i_Multiple +#define AL0446_i_Cell L0446_i_Multiple +#define AL0446_i_GroupCellsCriteria L0446_i_Multiple + int16 L0447_i_Multiple; +#define AL0447_i_Behavior L0447_i_Multiple +#define AL0447_i_CreatureIndex L0447_i_Multiple +#define AL0447_i_ReferenceDirection L0447_i_Multiple +#define AL0447_i_Ticks L0447_i_Multiple + CreatureInfo L0448_s_CreatureInfo; + Thing L0449_T_GroupThing; + int16 L0450_i_Multiple; +#define AL0450_i_DestinationMapX L0450_i_Multiple +#define AL0450_i_DistanceXToParty L0450_i_Multiple +#define AL0450_i_TargetMapX L0450_i_Multiple + int16 L0451_i_Multiple; +#define AL0451_i_DestinationMapY L0451_i_Multiple +#define AL0451_i_DistanceYToParty L0451_i_Multiple +#define AL0451_i_TargetMapY L0451_i_Multiple + int16 L0452_i_DistanceToVisibleParty = 0; + bool L0453_B_NewGroupDirectionFound; + int16 L0454_i_PrimaryDirectionToOrFromParty; + bool L0455_B_CurrentEventTypeIsNotUpdateBehavior; + bool L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls; + bool L0457_B_MoveToPriorLocation; + bool L0458_B_SetBehavior7_ApproachAfterReaction = false; + int16 L0459_i_CreatureSize; + uint16 L0460_ui_CreatureCount; + int16 L0461_i_MovementTicks; + int16 L0462_i_TicksSinceLastMove; + bool L0463_B_Archenemy; + int32 L0464_l_NextAspectUpdateTime; + TimelineEvent L0465_s_NextEvent; + + + /* If the party is not on the map specified in the event and the event type is not one of 32, 33, 37, 38 then the event is ignored */ + if ((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) && ((AL0446_i_EventType = eventType) != k37_TMEventTypeUpdateBehaviourGroup) && (AL0446_i_EventType != k32_TMEventTypeUpdateAspectGroup) && (AL0446_i_EventType != k38_TMEventTypeUpdateBehaviour_0) && (AL0446_i_EventType != k33_TMEventTypeUpdateAspectCreature_0)) + goto T0209139_Return; + /* If there is no creature at the location specified in the event then the event is ignored */ + if ((L0449_T_GroupThing = _vm->_groupMan->f175_groupGetThing(eventMapX, eventMapY)) == Thing::_endOfList) { + goto T0209139_Return; + } + L0444_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0449_T_GroupThing); + L0448_s_CreatureInfo = g243_CreatureInfo[L0444_ps_Group->_type]; + /* Update the event */ + M33_setMapAndTime(L0465_s_NextEvent._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime); + L0465_s_NextEvent._priority = 255 - L0448_s_CreatureInfo._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */ + L0465_s_NextEvent._B._location._mapX = eventMapX; + L0465_s_NextEvent._B._location._mapY = eventMapY; + /* If the creature is not on the party map then try and move the creature in a random direction and place a new event 37 in the timeline for the next creature movement */ + if (_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) { + if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->getRandomNumber(4), false)) { /* BUG0_67 A group that is not on the party map may wrongly move or not move into a teleporter. Normally, a creature type with Wariness >= 10 (Vexirk, Materializer / Zytaz, Demon, Lord Chaos, Red Dragon / Dragon) would only move into a teleporter if the creature type is allowed on the destination map. However, the variable G0380_T_CurrentGroupThing identifying the group is not set before being used by F0139_DUNGEON_IsCreatureAllowedOnMap called by f202_isMovementPossible so the check to see if the creature type is allowed may operate on another creature type and thus return an incorrect result, causing the creature to teleport while it should not, or not to teleport while it should */ + AL0450_i_DestinationMapX = eventMapX; + AL0451_i_DestinationMapY = eventMapY; + AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction]; + if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY)) + goto T0209139_Return; + L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX; + L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY; + } + L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup; + AL0446_i_Ticks = MAX(ABS(_vm->_dungeonMan->_g272_currMapIndex - _vm->_dungeonMan->_g309_partyMapIndex) << 4, L0448_s_CreatureInfo._movementTicks << 1); + /* BUG0_68 A group moves or acts with a wrong timing. Event is added below but L0465_s_NextEvent.C.Ticks has not been initialized. No consequence while the group is not on the party map. When the party enters the group map the first group event may have a wrong timing */ +T0209005_AddEventAndReturn: + L0465_s_NextEvent._mapTime += AL0446_i_Ticks; + _vm->_timeline->f238_addEventGetEventIndex(&L0465_s_NextEvent); + goto T0209139_Return; + } + /* If the creature is Lord Chaos then ignore the event if the game is won. Initialize data to analyze Fluxcages */ + if (L0463_B_Archenemy = getFlag(L0448_s_CreatureInfo._attributes, k0x2000_MaskCreatureInfo_archenemy)) { + if (_vm->_g302_gameWon) { + goto T0209139_Return; + } + _g386_fluxCageCount = 0; + _g385_fluxCages[0] = 0; + } + L0445_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[L0444_ps_Group->getActiveGroupIndex()]; + if ((L0462_i_TicksSinceLastMove = (unsigned char)_vm->_g313_gameTime - L0445_ps_ActiveGroup->_lastMoveTime) < 0) { + L0462_i_TicksSinceLastMove += 256; + } + if ((L0461_i_MovementTicks = L0448_s_CreatureInfo._movementTicks) == k255_immobile) { + L0461_i_MovementTicks = 100; + } + if (_vm->_championMan->_g407_party._freezeLifeTicks && !L0463_B_Archenemy) { /* If life is frozen and the creature is not Lord Chaos (Lord Chaos is immune to Freeze Life) then reschedule the event later (except for reactions which are ignored when life if frozen) */ + if (eventType < 0) + goto T0209139_Return; + L0465_s_NextEvent._type = eventType; + L0465_s_NextEvent._C._ticks = ticks; + AL0446_i_Ticks = 4; /* Retry in 4 ticks */ + goto T0209005_AddEventAndReturn; + } + /* If the specified event type is a 'reaction' instead of a real event from the timeline then create the corresponding reaction event with a delay: + For event kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, the reaction time is 1 tick + For event kM2_TMEventTypeCreateReactionEvent30HitByProjectile and kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, the reaction time may be 1 tick or slower: slow moving creatures react more slowly. The more recent is the last creature move, the slower the reaction */ + if (eventType < 0) { + L0465_s_NextEvent._type = eventType + k32_TMEventTypeUpdateAspectGroup; + if ((eventType == kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) || ((AL0446_i_Ticks = ((L0461_i_MovementTicks + 2) >> 2) - L0462_i_TicksSinceLastMove) < 1)) { /* AL0446_i_Ticks is the reaction time */ + AL0446_i_Ticks = 1; /* Retry in 1 tick */ + } + goto T0209005_AddEventAndReturn; /* BUG0_68 A group moves or acts with a wrong timing. Event is added but L0465_s_NextEvent.C.Ticks has not been initialized */ + } + AL0447_i_Behavior = L0444_ps_Group->getBehaviour(); + L0460_ui_CreatureCount = L0444_ps_Group->getCount(); + L0459_i_CreatureSize = getFlag(L0448_s_CreatureInfo._attributes, k0x0003_MaskCreatureInfo_size); + AL0450_i_DistanceXToParty = ((AL0446_i_Distance = eventMapX - _vm->_dungeonMan->_g306_partyMapX) < 0) ? -AL0446_i_Distance : AL0446_i_Distance; + AL0451_i_DistanceYToParty = ((AL0446_i_Distance = eventMapY - _vm->_dungeonMan->_g307_partyMapY) < 0) ? -AL0446_i_Distance : AL0446_i_Distance; + _g378_currentGroupMapX = eventMapX; + _g379_currentGroupMapY = eventMapY; + _g380_currGroupThing = L0449_T_GroupThing; + _g384_groupMovementTestedDirections[0] = 0; + _g381_currGroupDistanceToParty = f226_getDistanceBetweenSquares(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); + _g382_currGroupPrimaryDirToParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); + _g383_currGroupSecondaryDirToParty = _vm->_projexpl->_g363_secondaryDirToOrFromParty; + L0464_l_NextAspectUpdateTime = 0; + L0455_B_CurrentEventTypeIsNotUpdateBehavior = true; + if (eventType <= k31_TMEventTypeGroupReactionPartyIsAdjecent) { /* Process Reaction events 29 to 31 */ + switch (eventType = eventType - k32_TMEventTypeUpdateAspectGroup) { + case kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent: /* This event is used when the party bumps into a group or attacks a group physically (not with a spell). It causes the creature behavior to change to attack if it is not already attacking the party or fleeing from target */ + if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) { + f181_groupDeleteEvents(eventMapX, eventMapY); + goto T0209044_SetBehavior6_Attack; + } + L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; + L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; + goto T0209139_Return; + case kM2_TMEventTypeCreateReactionEvent30HitByProjectile: /* This event is used for the reaction of a group after a projectile impacted with one creature in the group (some creatures may have been killed) */ + if ((AL0447_i_Behavior == k6_behavior_ATTACK) || (AL0447_i_Behavior == k5_behavior_FLEE)) /* If the creature is attacking the party or fleeing from the target then there is no reaction */ + goto T0209139_Return; + if ((AL0446_i_Behavior2Or3 = ((AL0447_i_Behavior == k3_behavior_USELESS) || (AL0447_i_Behavior == k2_behavior_USELESS))) || (_vm->getRandomNumber(4))) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances */ + if (!f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { /* If the group cannot see the party then look in a random direction to try and search for the party */ + L0458_B_SetBehavior7_ApproachAfterReaction = L0453_B_NewGroupDirectionFound = false; + goto T0209073_SetDirectionGroup; + } + if (AL0446_i_Behavior2Or3 || (_vm->getRandomNumber(4))) /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances then no reaction */ + goto T0209139_Return; + } /* No 'break': proceed to instruction after the next 'case' below. Reaction is to move in a random direction to try and avoid other projectiles */ + case kM3_TMEventTypeCreateReactionEvent29DangerOnSquare: /* This event is used when some creatures in the group were killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by 3 Fluxcages. It causes the creature to move in a random direction to avoid the danger */ + L0458_B_SetBehavior7_ApproachAfterReaction = (AL0447_i_Behavior == k6_behavior_ATTACK); /* If the creature behavior is 'Attack' and it has to move to avoid danger then it will change its behavior to 'Approach' after the movement */ + L0453_B_NewGroupDirectionFound = false; + goto T0209058_MoveInRandomDirection; + } + } + if (eventType < k37_TMEventTypeUpdateBehaviourGroup) { /* Process Update Aspect events 32 to 36 */ + L0465_s_NextEvent._type = eventType + 5; + if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { + if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) { + if (M38_distance(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, eventMapX, eventMapY) <= 1) + goto T0209044_SetBehavior6_Attack; + if (((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k3_behavior_USELESS)) && (AL0447_i_Behavior != k7_behavior_APPROACH)) /* BUG0_00 Useless code. Behavior cannot be 3 because this value is never used. Moreover, the second condition in the && is redundant (if the value is 0 or 3, it cannot be 7). The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */ + goto T0209054_SetBehavior7_Approach; + } + L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; + L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; + } + if (AL0447_i_Behavior == k6_behavior_ATTACK) { + AL0446_i_CreatureAspectIndex = eventType - k33_TMEventTypeUpdateAspectCreature_0; /* Value -1 for event 32, meaning aspect will be updated for all creatures in the group */ + L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0446_i_CreatureAspectIndex, getFlag(L0445_ps_ActiveGroup->_aspect[AL0446_i_CreatureAspectIndex], k0x0080_MaskActiveGroupIsAttacking)); + goto T0209136; + } + if ((AL0450_i_DistanceXToParty > 3) || (AL0451_i_DistanceYToParty > 3)) { + L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime + ((L0448_s_CreatureInfo._animationTicks >> 4) & 0xF); + goto T0209136; + } + } else { /* Process Update Behavior events 37 to 41 */ + L0455_B_CurrentEventTypeIsNotUpdateBehavior = false; + if (ticks) { + L0464_l_NextAspectUpdateTime = _vm->_g313_gameTime; + } + if (eventType == k37_TMEventTypeUpdateBehaviourGroup) { /* Process event 37, Update Group Behavior */ + if ((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k2_behavior_USELESS) || (AL0447_i_Behavior == k3_behavior_USELESS)) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */ + if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { + if ((L0452_i_DistanceToVisibleParty <= (L0448_s_CreatureInfo.M56_getAttackRange())) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) { /* If the creature is in range for attack and on the same row or column as the party on the map */ +T0209044_SetBehavior6_Attack: + if (eventType == kM2_TMEventTypeCreateReactionEvent30HitByProjectile) { + f181_groupDeleteEvents(eventMapX, eventMapY); + } + L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; + L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; + L0444_ps_Group->setBehaviour(k6_behavior_ATTACK); + AL0446_i_Direction = _g382_currGroupPrimaryDirToParty; + for (AL0447_i_CreatureIndex = L0460_ui_CreatureCount; AL0447_i_CreatureIndex >= 0; AL0447_i_CreatureIndex--) { + if ((_vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) != AL0446_i_Direction) && + ((!AL0447_i_CreatureIndex) || (!_vm->getRandomNumber(2)))) { + f205_setDirection(L0445_ps_ActiveGroup, AL0446_i_Direction, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf)); + M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + _vm->getRandomNumber(4) + 2); /* Random delay represents the time for the creature to turn */ + } else { + M32_setTime(L0465_s_NextEvent._mapTime, _vm->_g313_gameTime + 1); + } + if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) { + L0465_s_NextEvent._mapTime += MIN((uint16)((L0448_s_CreatureInfo._attackTicks >> 1) + _vm->getRandomNumber(4)), ticks); + } + L0465_s_NextEvent._type = k38_TMEventTypeUpdateBehaviour_0 + AL0447_i_CreatureIndex; + f208_groupAddEvent(&L0465_s_NextEvent, f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false)); + } + goto T0209139_Return; + } + if (AL0447_i_Behavior != k2_behavior_USELESS) { /* BUG0_00 Useless code. Behavior cannot be 2 because this value is never used */ +T0209054_SetBehavior7_Approach: + L0444_ps_Group->setBehaviour(k7_behavior_APPROACH); + L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; + L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; + L0465_s_NextEvent._mapTime += 1; + goto T0209134_SetEvent37; + } + } else { + if (AL0447_i_Behavior == k0_behavior_WANDER) { + if (L0454_i_PrimaryDirectionToOrFromParty = f201_getSmelledPartyPrimaryDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY)) { + L0454_i_PrimaryDirectionToOrFromParty--; + L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = false; + goto T0209085_SingleSquareMove; + } + L0453_B_NewGroupDirectionFound = false; + if (_vm->getRandomNumber(2)) { +T0209058_MoveInRandomDirection: + AL0446_i_Direction = _vm->getRandomNumber(4); + AL0447_i_ReferenceDirection = AL0446_i_Direction; + L0457_B_MoveToPriorLocation = false; + do { + AL0450_i_DestinationMapX = eventMapX; + AL0451_i_DestinationMapY = eventMapY; + AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction]; + if (((L0445_ps_ActiveGroup->_priorMapX != AL0450_i_DestinationMapX) || + (L0445_ps_ActiveGroup->_priorMapY != AL0451_i_DestinationMapY) || + (L0457_B_MoveToPriorLocation = !_vm->getRandomNumber(4))) /* 1/4 chance of moving back to the square that the creature comes from */ + && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction, false)) { +T0209061_MoveGroup: + if (L0453_B_NewGroupDirectionFound = ((AL0447_i_Ticks = (L0461_i_MovementTicks >> 1) - L0462_i_TicksSinceLastMove) <= 0)) { + if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY)) + goto T0209139_Return; + L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX; + L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY;; + L0445_ps_ActiveGroup->_priorMapX = eventMapX; + L0445_ps_ActiveGroup->_priorMapY = eventMapY; + L0445_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime; + } else { + L0461_i_MovementTicks = AL0447_i_Ticks; + L0462_i_TicksSinceLastMove = -1; + } + break; + } + if (_g390_groupMovementBlockedByParty) { + if ((eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) && + ((L0444_ps_Group->getBehaviour() != k5_behavior_FLEE) || + !f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false) || + _vm->getRandomNumber(2))) + goto T0209044_SetBehavior6_Attack; + L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; + L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; + } + } while ((AL0446_i_Direction = returnNextVal(AL0446_i_Direction)) != AL0447_i_ReferenceDirection); + } + if (!L0453_B_NewGroupDirectionFound && + (L0462_i_TicksSinceLastMove != -1) && + L0463_B_Archenemy && + ((eventType == kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) || !_vm->getRandomNumber(4))) { /* BUG0_15 The game hangs when you close a door on Lord Chaos. A condition is missing in the code to manage creatures and this may create an infinite loop between two parts in the code */ + _vm->_projexpl->_g363_secondaryDirToOrFromParty = returnNextVal(L0454_i_PrimaryDirectionToOrFromParty = _vm->getRandomNumber(4)); + goto T0209089_DoubleSquareMove; /* BUG0_69 Memory corruption when you close a door on Lord Chaos. The local variable (L0454_i_PrimaryDirectionToOrFromParty) containing the direction where Lord Chaos tries to move may be used as an array index without being initialized and cause memory corruption */ + } + if (L0453_B_NewGroupDirectionFound || ((!_vm->getRandomNumber(4) || (L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M55_getSmellRange())) && (eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare))) { +T0209073_SetDirectionGroup: + if (!L0453_B_NewGroupDirectionFound && (L0462_i_TicksSinceLastMove >= 0)) { /* If direction is not found yet then look around in a random direction */ + AL0446_i_Direction = _vm->getRandomNumber(4); + } + f206_groupSetDirGroup(L0445_ps_ActiveGroup, AL0446_i_Direction, L0460_ui_CreatureCount, L0459_i_CreatureSize); + } + /* If event is kM3_TMEventTypeCreateReactionEvent29DangerOnSquare or kM2_TMEventTypeCreateReactionEvent30HitByProjectile */ + if (eventType < kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent) { + if (!L0453_B_NewGroupDirectionFound) + goto T0209139_Return; + if (L0458_B_SetBehavior7_ApproachAfterReaction) { + L0444_ps_Group->setBehaviour(k7_behavior_APPROACH); + } + f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY); + } + } + } + } else { + if (AL0447_i_Behavior == k7_behavior_APPROACH) { + if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { + if ((L0452_i_DistanceToVisibleParty <= L0448_s_CreatureInfo.M56_getAttackRange()) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) /* If the creature is in range for attack and on the same row or column as the party on the map */ + goto T0209044_SetBehavior6_Attack; +T0209081_RunTowardParty: + L0461_i_MovementTicks++; + L0461_i_MovementTicks = L0461_i_MovementTicks >> 1; /* Running speed is half the movement ticks */ + AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX); + AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY); + } else { +T0209082_WalkTowardTarget: + AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX; + AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY; + /* If the creature reached its target but the party is not there anymore */ + if ((eventMapX == AL0450_i_TargetMapX) && (eventMapY == AL0451_i_TargetMapY)) { + L0453_B_NewGroupDirectionFound = false; + L0444_ps_Group->setBehaviour(k0_behavior_WANDER); + goto T0209073_SetDirectionGroup; + } + } + L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true; +T0209084_SingleSquareMoveTowardParty: + L0454_i_PrimaryDirectionToOrFromParty = f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY); +T0209085_SingleSquareMove: + if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls) || + f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls && _vm->getRandomNumber(2)) || + f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction), false) || + (!_vm->getRandomNumber(4) && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty), false))) { + AL0450_i_DestinationMapX = eventMapX; + AL0451_i_DestinationMapY = eventMapY; + AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction]; + goto T0209061_MoveGroup; + } + if (L0463_B_Archenemy) { +T0209089_DoubleSquareMove: + f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false); /* BUG0_00 Useless code. Returned value is ignored. When Lord Chaos teleports two squares away the ability to move to the first square is ignored which means Lord Chaos can teleport through walls or any other obstacle */ + if (f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty) || + f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty) || + (_g386_fluxCageCount && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction))) || + ((_g386_fluxCageCount >= 2) && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty)))) { + AL0450_i_DestinationMapX = eventMapX; + AL0451_i_DestinationMapY = eventMapY; + AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2; + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + goto T0209061_MoveGroup; + } + } + f206_groupSetDirGroup(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, L0460_ui_CreatureCount, L0459_i_CreatureSize); + } else { + if (AL0447_i_Behavior == k5_behavior_FLEE) { +T0209094_FleeFromTarget: + L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls = true; + /* If the creature can see the party then update target coordinates */ + if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { + AL0450_i_TargetMapX = (L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX); + AL0451_i_TargetMapY = (L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY); + } else { + if (!(--(L0445_ps_ActiveGroup->_delayFleeingFromTarget))) { /* If the creature is not afraid anymore then stop fleeing from target */ +T0209096_SetBehavior0_Wander: + L0453_B_NewGroupDirectionFound = false; + L0444_ps_Group->setBehaviour(k0_behavior_WANDER); + goto T0209073_SetDirectionGroup; + } + if (_vm->getRandomNumber(2)) { + /* If the creature cannot move and the party is adjacent then stop fleeing */ + if (!f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false)) { + if (M38_distance(eventMapX, eventMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1) + goto T0209096_SetBehavior0_Wander; + } + /* Set creature target to the home square where the creature was located when the party entered the map */ + AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_homeMapX; + AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_homeMapY; + goto T0209084_SingleSquareMoveTowardParty; + } + AL0450_i_TargetMapX = L0445_ps_ActiveGroup->_targetMapX; + AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY; + } + /* Try and flee from the party (opposite direction) */ + L0454_i_PrimaryDirectionToOrFromParty = returnOppositeDir((direction)f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY)); + _vm->_projexpl->_g363_secondaryDirToOrFromParty = returnOppositeDir((direction)_vm->_projexpl->_g363_secondaryDirToOrFromParty); + L0461_i_MovementTicks -= (L0461_i_MovementTicks >> 2); + goto T0209085_SingleSquareMove; + } + } + } + } else { /* Process events 38 to 41, Update Creature Behavior */ + if (AL0447_i_Behavior == k5_behavior_FLEE) { + if (L0460_ui_CreatureCount) { + f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY); + } + goto T0209094_FleeFromTarget; + } + /* If the creature is attacking, then compute the next aspect update time and the next attack time */ + if (getFlag(L0445_ps_ActiveGroup->_aspect[AL0447_i_CreatureIndex = eventType - k38_TMEventTypeUpdateBehaviour_0], k0x0080_MaskActiveGroupIsAttacking)) { + L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, false); + L0465_s_NextEvent._mapTime += ((AL0447_i_Ticks = L0448_s_CreatureInfo._attackTicks) + _vm->getRandomNumber(4) - 1); + if (AL0447_i_Ticks > 15) { + L0465_s_NextEvent._mapTime += _vm->getRandomNumber(8) - 2; + } + } else { /* If the creature is not attacking, then try attacking if possible */ + if (AL0447_i_CreatureIndex > L0460_ui_CreatureCount) { /* Ignore event if it is for a creature that is not in the group */ + goto T0209139_Return; + } + L0454_i_PrimaryDirectionToOrFromParty = _g382_currGroupPrimaryDirToParty; + /* If the party is visible, update the target coordinates */ + if (L0452_i_DistanceToVisibleParty = f200_groupGetDistanceToVisibleParty(L0444_ps_Group, AL0447_i_CreatureIndex, eventMapX, eventMapY)) { + L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; + L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; + } + /* If there is a single creature in the group that is not full square sized and 1/4 chance */ + if (!L0460_ui_CreatureCount && (L0459_i_CreatureSize != k2_MaskCreatureSizeFull) && !((AL0446_i_GroupCellsCriteria = _vm->getRandomNumber(65536)) & 0x00C0)) { + if (L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) { + /* If the creature is not already on the center of the square then change its cell */ + if (AL0446_i_GroupCellsCriteria & 0x0038) { /* 7/8 chances of changing cell to the center of the square */ + L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature; + } else { /* 1/8 chance of changing cell to the next or previous cell on the square */ + AL0446_i_GroupCellsCriteria = M21_normalizeModulo4(M21_normalizeModulo4(L0445_ps_ActiveGroup->_cells) + ((AL0446_i_GroupCellsCriteria & 0x0001) ? 1 : -1)); + } + } + /* If 1/8 chance and the creature is not adjacent to the party and is a quarter square sized creature then process projectile impacts and update the creature cell if still alive. When the creature is not in front of the party, it has 7/8 chances of dodging a projectile by moving to another cell or staying in the center of the square */ + if (!(AL0446_i_GroupCellsCriteria & 0x0038) && (L0452_i_DistanceToVisibleParty != 1) && (L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter)) { + if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* This call to F0218_PROJECTILE_GetImpactCount works fine because there is a single creature in the group so L0445_ps_ActiveGroup->Cells contains only one cell index */ + goto T0209139_Return; + L0445_ps_ActiveGroup->_cells = M21_normalizeModulo4(AL0446_i_GroupCellsCriteria); + } + } + /* If the creature can see the party and is looking in the party direction or can attack in all direction */ + if (L0452_i_DistanceToVisibleParty && + (getFlag(L0448_s_CreatureInfo._attributes, k0x0004_MaskCreatureInfo_sideAttack) || + _vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_directions, AL0447_i_CreatureIndex) == L0454_i_PrimaryDirectionToOrFromParty)) { + /* If the creature is in range to attack the party and random test succeeds */ + if ((L0452_i_DistanceToVisibleParty <= (AL0446_i_Range = L0448_s_CreatureInfo.M56_getAttackRange())) && + (!AL0450_i_DistanceXToParty || !AL0451_i_DistanceYToParty) && + (AL0446_i_Range <= (_vm->getRandomNumber(16) + 1))) { + if ((AL0446_i_Range == 1) && + (!getFlag(AL0446_i_CreatureAttributes = L0448_s_CreatureInfo._attributes, k0x0008_MaskCreatureInfo_preferBackRow) || !_vm->getRandomNumber(4) || !getFlag(AL0446_i_CreatureAttributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) && + (L0459_i_CreatureSize == k0_MaskCreatureSizeQuarter) && + (L0445_ps_ActiveGroup->_cells != k255_CreatureTypeSingleCenteredCreature) && + ((AL0446_i_Cell = _vm->_groupMan->M50_getCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex)) != L0454_i_PrimaryDirectionToOrFromParty) && + (AL0446_i_Cell != returnNextVal(L0454_i_PrimaryDirectionToOrFromParty))) { /* If the creature cannot cast spells (range = 1) and is not on a cell where it can attack the party directly and is a quarter square sized creature not in the center of the square then the creature moves to another cell and attack does not occur immediately */ + if (!L0460_ui_CreatureCount && _vm->getRandomNumber(2)) { + L0445_ps_ActiveGroup->_cells = k255_CreatureTypeSingleCenteredCreature; + } else { + if ((L0454_i_PrimaryDirectionToOrFromParty & 0x0001) == (AL0446_i_Cell & 0x0001)) { + AL0446_i_Cell--; + } else { + AL0446_i_Cell++; + } + if (!_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = M21_normalizeModulo4(AL0446_i_Cell)) || + (_vm->getRandomNumber(2) && !_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */ + if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */ + goto T0209139_Return; + if (_vm->_projexpl->_g364_creatureDamageOutcome != k1_outcomeKilledSomeCreaturesInGroup) { + L0445_ps_ActiveGroup->_cells = f178_getGroupValueUpdatedWithCreatureValue(L0445_ps_ActiveGroup->_cells, AL0447_i_CreatureIndex, AL0446_i_Cell); + } + } + } + L0465_s_NextEvent._mapTime += MAX(1, (L0448_s_CreatureInfo._movementTicks >> 1) + _vm->getRandomNumber(2)); /* Time for the creature to change cell */ + L0465_s_NextEvent._type = eventType; + goto T0209135; + } + L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, AL0447_i_CreatureIndex, f207_isCreatureAttacking(L0444_ps_Group, eventMapX, eventMapY, AL0447_i_CreatureIndex)); + L0465_s_NextEvent._mapTime += (L0448_s_CreatureInfo._animationTicks & 0xF) + _vm->getRandomNumber(2); + } else { + L0444_ps_Group->setBehaviour(k7_behavior_APPROACH); + if (L0460_ui_CreatureCount) { + f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY); + } + goto T0209081_RunTowardParty; + } + } else { + /* If the party is visible, update target coordinates */ + if (f200_groupGetDistanceToVisibleParty(L0444_ps_Group, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { + L0445_ps_ActiveGroup->_targetMapX = _vm->_dungeonMan->_g306_partyMapX; + L0445_ps_ActiveGroup->_targetMapY = _vm->_dungeonMan->_g307_partyMapY; + f205_setDirection(L0445_ps_ActiveGroup, L0454_i_PrimaryDirectionToOrFromParty, AL0447_i_CreatureIndex, L0460_ui_CreatureCount && (L0459_i_CreatureSize == k1_MaskCreatureSizeHalf)); + L0465_s_NextEvent._mapTime += 2; + L0464_l_NextAspectUpdateTime = M30_time(L0465_s_NextEvent._mapTime); + } else { /* If the party is not visible, move to the target (last known party location) */ + L0444_ps_Group->setBehaviour(k7_behavior_APPROACH); + if (L0460_ui_CreatureCount) { + f182_stopAttacking(L0445_ps_ActiveGroup, eventMapX, eventMapY); + } + goto T0209082_WalkTowardTarget; + } + } + } + L0465_s_NextEvent._type = eventType; + goto T0209136; + } + L0465_s_NextEvent._mapTime += MAX(1, _vm->getRandomNumber(4) + L0461_i_MovementTicks - 1); +T0209134_SetEvent37: + L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup; + } +T0209135: + if (!L0464_l_NextAspectUpdateTime) { + L0464_l_NextAspectUpdateTime = f179_getCreatureAspectUpdateTime(L0445_ps_ActiveGroup, kM1_wholeCreatureGroup, false); + } +T0209136: + if (L0455_B_CurrentEventTypeIsNotUpdateBehavior) { + L0465_s_NextEvent._mapTime += ticks; + } else { + L0464_l_NextAspectUpdateTime += ticks; + } + f208_groupAddEvent(&L0465_s_NextEvent, L0464_l_NextAspectUpdateTime); +T0209139_Return: + ; +} + +bool GroupMan::f202_isMovementPossible(CreatureInfo* creatureInfo, int16 mapX, int16 mapY, uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls) { + int16 L0428_i_MapX; + int16 L0429_i_MapY; + uint16 L0430_ui_Square = 0; + int16 L0431_i_SquareType = 0; + Teleporter* L0432_ps_Teleporter; + Thing L0433_T_Thing; + + + _g384_groupMovementTestedDirections[dir] = true; + _g388_groupMovementBlockedByGroupThing = Thing::_endOfList; + _g389_groupMovementBlockedByDoor = false; + _g390_groupMovementBlockedByParty = false; + if (creatureInfo->_movementTicks == k255_immobile) { + return false; + } + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement((direction)dir, 1, 0, mapX, mapY); + L0428_i_MapX = mapX; + L0429_i_MapY = mapY; + if (_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = + !(((L0428_i_MapX >= 0) && (L0428_i_MapX < _vm->_dungeonMan->_g273_currMapWidth)) && + ((L0429_i_MapY >= 0) && (L0429_i_MapY < _vm->_dungeonMan->_g274_currMapHeight)) && + ((L0431_i_SquareType = Square(L0430_ui_Square = _vm->_dungeonMan->_g271_currMapData[L0428_i_MapX][L0429_i_MapY]).getType()) != k0_ElementTypeWall) && + (L0431_i_SquareType != k3_ElementTypeStairs) && + ((L0431_i_SquareType != k2_ElementTypePit) || (getFlag(L0430_ui_Square, k0x0001_PitImaginary) && allowMovementOverImaginaryPitsAndFakeWalls) || !getFlag(L0430_ui_Square, k0x0008_PitOpen) || getFlag(creatureInfo->_attributes, k0x0020_MaskCreatureInfo_levitation)) && + ((L0431_i_SquareType != k6_ElementTypeFakeWall) || getFlag(L0430_ui_Square, k0x0004_FakeWallOpen) || (getFlag(L0430_ui_Square, k0x0001_FakeWallImaginary) && allowMovementOverImaginaryPitsAndFakeWalls)))) { + return false; + } + if (getFlag(creatureInfo->_attributes, k0x2000_MaskCreatureInfo_archenemy)) { + L0433_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0428_i_MapX, L0429_i_MapY); + while (L0433_T_Thing != Thing::_endOfList) { + if ((L0433_T_Thing).getType() == k15_ExplosionThingType) { + L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(L0433_T_Thing); + if (((Explosion*)L0432_ps_Teleporter)->setType(k50_ExplosionType_Fluxcage)) { + _g385_fluxCages[dir] = true; + _g386_fluxCageCount++; + _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true; + return false; + } + } + L0433_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0433_T_Thing); + } + } + if ((L0431_i_SquareType == k5_ElementTypeTeleporter) && getFlag(L0430_ui_Square, k0x0008_TeleporterOpen) && (creatureInfo->M59_getWariness() >= 10)) { + L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY); + if (getFlag(L0432_ps_Teleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->f139_isCreatureAllowedOnMap(_g380_currGroupThing, L0432_ps_Teleporter->getTargetMapIndex())) { + _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true; + return false; + } + } + if (_g390_groupMovementBlockedByParty = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0428_i_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0429_i_MapY == _vm->_dungeonMan->_g307_partyMapY)) { + return false; + } + if (L0431_i_SquareType == k4_DoorElemType) { + L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY); + if (((Square(L0430_ui_Square).getDoorState()) > (((Door*)L0432_ps_Teleporter)->opensVertically() ? creatureInfo->M51_height() : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) { + _g389_groupMovementBlockedByDoor = true; + return false; + } + } + return (_g388_groupMovementBlockedByGroupThing = _vm->_groupMan->f175_groupGetThing(L0428_i_MapX, L0429_i_MapY)) == Thing::_endOfList; +} + +int16 GroupMan::f226_getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) { + return ((((srcMapX -= destMapX) < 0) ? -srcMapX : srcMapX) + + (((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY)); +} + +int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group* group, int16 creatureIndex, int16 mapX, int16 mapY) { + int16 L0420_i_CreatureDirection; + int16 L0421_i_CreatureViewDirectionCount; /* Count of directions to test in L0425_ai_CreatureViewDirections */ + int16 L0422_i_Multiple; +#define AL0422_i_Counter L0422_i_Multiple +#define AL0422_i_SightRange L0422_i_Multiple + uint16 L0423_ui_GroupDirections; + CreatureInfo* L0424_ps_CreatureInfo; + int16 L0425_ai_CreatureViewDirections[4]; /* List of directions to test */ + + + L0424_ps_CreatureInfo = &g243_CreatureInfo[group->_type]; + if (_vm->_championMan->_g407_party._event71Count_Invisibility && !getFlag(L0424_ps_CreatureInfo->_attributes, k0x0800_MaskCreatureInfo_seeInvisible)) { + return 0; + } + if (getFlag(L0424_ps_CreatureInfo->_attributes, k0x0004_MaskCreatureInfo_sideAttack)) /* If creature can see in all directions */ + goto T0200011; + L0423_ui_GroupDirections = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions; + if (creatureIndex < 0) { /* Negative index means test if each creature in the group can see the party in their respective direction */ + L0421_i_CreatureViewDirectionCount = 0; + for (creatureIndex = group->getCount(); creatureIndex >= 0; creatureIndex--) { + L0420_i_CreatureDirection = M21_normalizeModulo4(L0423_ui_GroupDirections >> (creatureIndex << 1)); + AL0422_i_Counter = L0421_i_CreatureViewDirectionCount; + while (AL0422_i_Counter--) { + if (L0425_ai_CreatureViewDirections[AL0422_i_Counter] == L0420_i_CreatureDirection) /* If the creature looks in the same direction as another one in the group */ + goto T0200006; + } + L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount++] = L0420_i_CreatureDirection; +T0200006: + ; + } + } else { /* Positive index means test only if the specified creature in the group can see the party in its direction */ + L0425_ai_CreatureViewDirections[0] = _vm->_groupMan->M50_getCreatureValue(L0423_ui_GroupDirections, creatureIndex); + L0421_i_CreatureViewDirectionCount = 1; + } + while (L0421_i_CreatureViewDirectionCount--) { + if (f227_isDestVisibleFromSource(L0425_ai_CreatureViewDirections[L0421_i_CreatureViewDirectionCount], mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY)) { +T0200011: + AL0422_i_SightRange = L0424_ps_CreatureInfo->M54_getSightRange(); + if (!getFlag(L0424_ps_CreatureInfo->_attributes, k0x1000_MaskCreatureInfo_nightVision)) { + AL0422_i_SightRange -= _vm->_displayMan->_g304_dungeonViewPaletteIndex >> 1; + } + if (_g381_currGroupDistanceToParty > MAX((int16)1, AL0422_i_SightRange)) { + return 0; + } + return f199_getDistanceBetweenUnblockedSquares(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f197_isViewPartyBlocked); + } + } + return 0; +} + +int16 GroupMan::f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 srcMapY, + int16 destMapX, int16 destMapY, bool (GroupMan::*isBlocked)(uint16, uint16)) { + int16 L0410_i_XAxisStep; + int16 L0411_i_YAxisStep; + int16 L0412_i_Multiple; +#define AL0412_i_DistanceX L0412_i_Multiple +#define AL0412_i_PathMapX L0412_i_Multiple + int16 L0413_i_Multiple; +#define AL0413_i_DistanceY L0413_i_Multiple +#define AL0413_i_PathMapY L0413_i_Multiple + int16 L0414_i_LargestAxisDistance; + bool L0415_B_DistanceXSmallerThanDistanceY; + int16 L0416_i_ValueA; + int16 L0417_i_ValueB; + bool L0418_B_DistanceXEqualsDistanceY; + int16 L0419_i_ValueC; + + + if (M38_distance(srcMapX, srcMapY, destMapX, destMapY) <= 1) { + return 1; + } + L0415_B_DistanceXSmallerThanDistanceY = (AL0412_i_DistanceX = ((AL0412_i_DistanceX = destMapX - srcMapX) < 0) ? -AL0412_i_DistanceX : AL0412_i_DistanceX) < (AL0413_i_DistanceY = ((AL0413_i_DistanceY = destMapY - srcMapY) < 0) ? -AL0413_i_DistanceY : AL0413_i_DistanceY); + L0418_B_DistanceXEqualsDistanceY = (AL0412_i_DistanceX == AL0413_i_DistanceY); + L0410_i_XAxisStep = (((AL0412_i_PathMapX = destMapX) - srcMapX) > 0) ? -1 : 1; + L0411_i_YAxisStep = (((AL0413_i_PathMapY = destMapY) - srcMapY) > 0) ? -1 : 1; + L0419_i_ValueC = L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY - srcMapY) ? ((AL0412_i_PathMapX - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) + : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX - srcMapX) ? ((AL0413_i_PathMapY - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128); + /* 128 when the creature is on the same row or column as the party */ + do { + if (L0418_B_DistanceXEqualsDistanceY) { + if (((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY) && (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX, AL0413_i_PathMapY + L0411_i_YAxisStep)) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX = AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY = AL0413_i_PathMapY + L0411_i_YAxisStep)) { + return 0; + } + } else { + if ((L0416_i_ValueA = ((L0414_i_LargestAxisDistance = (L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY - srcMapY) ? ((AL0412_i_PathMapX + L0410_i_XAxisStep - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX + L0410_i_XAxisStep - srcMapX) ? ((AL0413_i_PathMapY - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128)) - L0419_i_ValueC) < 0) ? -L0414_i_LargestAxisDistance : L0414_i_LargestAxisDistance) < (L0417_i_ValueB = ((L0414_i_LargestAxisDistance = (L0415_B_DistanceXSmallerThanDistanceY ? ((L0414_i_LargestAxisDistance = AL0413_i_PathMapY + L0411_i_YAxisStep - srcMapY) ? ((AL0412_i_PathMapX - srcMapX) << 6) / L0414_i_LargestAxisDistance : 128) : ((L0414_i_LargestAxisDistance = AL0412_i_PathMapX - srcMapX) ? ((AL0413_i_PathMapY + L0411_i_YAxisStep - srcMapY) << 6) / L0414_i_LargestAxisDistance : 128)) - L0419_i_ValueC) < 0) ? -L0414_i_LargestAxisDistance : L0414_i_LargestAxisDistance)) { + AL0412_i_PathMapX += L0410_i_XAxisStep; + } else { + AL0413_i_PathMapY += L0411_i_YAxisStep; + } + if ((CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX, AL0413_i_PathMapY) && ((L0416_i_ValueA != L0417_i_ValueB) || (CALL_MEMBER_FN(*_vm->_groupMan, isBlocked))(AL0412_i_PathMapX = AL0412_i_PathMapX + L0410_i_XAxisStep, AL0413_i_PathMapY = AL0413_i_PathMapY - L0411_i_YAxisStep))) { + return 0; + } + } + } while (M38_distance(AL0412_i_PathMapX, AL0413_i_PathMapY, srcMapX, srcMapY) > 1); + return f226_getDistanceBetweenSquares(srcMapX, srcMapY, destMapX, destMapY); +} + +bool GroupMan::f197_isViewPartyBlocked(uint16 mapX, uint16 mapY) { + uint16 L0404_ui_Square; + int16 L0405_i_SquareType; + int16 L0406_i_DoorState; + Door* L0407_ps_Door; + + if ((L0405_i_SquareType = Square(L0404_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k4_DoorElemType) { + L0407_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY); + return (((L0406_i_DoorState = Square(L0404_ui_Square).getDoorState()) == k3_doorState_FOURTH) || (L0406_i_DoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[L0407_ps_Door->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough); + } + return (L0405_i_SquareType == k0_ElementTypeWall) || ((L0405_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0404_ui_Square, k0x0004_FakeWallOpen)); +} + +int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup* activeGroup, int16 creatureIndex, bool isAttacking) { + uint16 L0326_ui_Multiple; +#define AL0326_ui_Aspect L0326_ui_Multiple +#define AL0326_ui_AnimationTicks L0326_ui_Multiple + uint16 L0327_ui_CreatureGraphicInfo; + int16 L0328_i_Offset; + Group* L0329_ps_Group; + bool L0330_B_ProcessGroup; + uint16 L0331_ui_CreatureType; + uint16 L1635_ui_SoundIndex; + + L0329_ps_Group = &(((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]); + L0327_ui_CreatureGraphicInfo = g243_CreatureInfo[L0331_ui_CreatureType = L0329_ps_Group->_type]._graphicInfo; + if (L0330_B_ProcessGroup = (creatureIndex < 0)) { /* If the creature index is negative then all creatures in the group are processed */ + creatureIndex = L0329_ps_Group->getCount(); + } + do { + AL0326_ui_Aspect = activeGroup->_aspect[creatureIndex]; + AL0326_ui_Aspect &= k0x0080_MaskActiveGroupIsAttacking | k0x0040_MaskActiveGroupFlipBitmap; + if (L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 12) & 0x3)) { + L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset); + if (_vm->getRandomNumber(2)) { + L0328_i_Offset = (-L0328_i_Offset) & 0x0007; + } + AL0326_ui_Aspect |= L0328_i_Offset; + } + if (L0328_i_Offset = ((L0327_ui_CreatureGraphicInfo >> 14) & 0x3)) { + L0328_i_Offset = _vm->getRandomNumber(L0328_i_Offset); + if (_vm->getRandomNumber(2)) { + L0328_i_Offset = (-L0328_i_Offset) & 0x0007; + } + AL0326_ui_Aspect |= (L0328_i_Offset << 3); + } + if (isAttacking) { + if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0200_CreatureInfoGraphicMaskFlipAttack)) { + if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) { + if (_vm->getRandomNumber(2)) { + toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + } else { + if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) { + if (_vm->getRandomNumber(2)) { + setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + } else { + clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + } + } + } + } else { + clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + } + setFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking); + } else { + if (getFlag(L0327_ui_CreatureGraphicInfo, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) { + if (L0331_ui_CreatureType == k13_CreatureTypeCouatl) { + if (_vm->getRandomNumber(2)) { + toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + L1635_ui_SoundIndex = _vm->_movsens->f514_getSound(k13_CreatureTypeCouatl); + if (L1635_ui_SoundIndex <= k34_D13_soundCount) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + } + } else { + if (_vm->getRandomNumber(2)) { + setFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + } else { + clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + } + } + } else { + clearFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); + } + clearFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking); + } + activeGroup->_aspect[creatureIndex] = AL0326_ui_Aspect; + } while (L0330_B_ProcessGroup && (creatureIndex--)); + AL0326_ui_AnimationTicks = g243_CreatureInfo[L0329_ps_Group->_type]._animationTicks; + return _vm->_g313_gameTime + (isAttacking ? ((AL0326_ui_AnimationTicks >> 8) & 0xF) : ((AL0326_ui_AnimationTicks >> 4) & 0xF)) + _vm->getRandomNumber(2); +} + +void GroupMan::f205_setDirection(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) { + uint16 L0435_ui_GroupDirections; + static long G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; /* These two variables are used to prevent setting direction of half square sized creatures twice at the same game time */ + static ActiveGroup* G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup; + + + warning("potentially dangerous cast to uint32 below"); + if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == (uint32)G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) { + return; + } + if (M21_normalizeModulo4(_vm->_groupMan->M50_getCreatureValue(L0435_ui_GroupDirections = activeGroup->_directions, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */ + L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir = returnNextVal((_vm->getRandomNumber(65536) & 0x0002) + dir)); + } else { + L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex, dir); + } + if (twoHalfSquareSizedCreatures) { + L0435_ui_GroupDirections = f178_getGroupValueUpdatedWithCreatureValue(L0435_ui_GroupDirections, creatureIndex ^ 1, dir); /* Set direction of the second half square sized creature */ + G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_g313_gameTime; + G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup = activeGroup; + } + activeGroup->_directions = (direction)L0435_ui_GroupDirections; +} + +void GroupMan::f208_groupAddEvent(TimelineEvent* event, uint32 time) { + warning("potentially dangerous cast to uint32 below"); + if (time < (uint32)M30_time(event->_mapTime)) { + event->_type -= 5; + event->_C._ticks = M30_time(event->_mapTime) - time; + M32_setTime(event->_mapTime, time); + } else { + event->_C._ticks = time - M30_time(event->_mapTime); + } + _vm->_timeline->f238_addEventGetEventIndex(event); +} + +int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo* creatureInfo, int16 mapY, int16 mapX) { + + uint16 L0426_ui_SmellRange; + int16 L0427_i_ScentOrdinal; + + + if (!(L0426_ui_SmellRange = creatureInfo->M55_getSmellRange())) { + return 0; + } + if ((((L0426_ui_SmellRange + 1) >> 1) >= _g381_currGroupDistanceToParty) && f199_getDistanceBetweenUnblockedSquares(mapY, mapX, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, &GroupMan::f198_isSmellPartyBlocked)) { + _vm->_projexpl->_g363_secondaryDirToOrFromParty = _g383_currGroupSecondaryDirToParty; + return _vm->M0_indexToOrdinal(_g382_currGroupPrimaryDirToParty); + } + if ((L0427_i_ScentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapY, mapX)) && ((_vm->_championMan->_g407_party._scentStrengths[_vm->M1_ordinalToIndex(L0427_i_ScentOrdinal)] + _vm->getRandomNumber(4)) > (30 - (L0426_ui_SmellRange << 1)))) { /* If there is a fresh enough party scent on the group square */ + return _vm->M0_indexToOrdinal(f228_getDirsWhereDestIsVisibleFromSource(mapY, mapX, _vm->_championMan->_g407_party._scents[L0427_i_ScentOrdinal].getMapX(), _vm->_championMan->_g407_party._scents[L0427_i_ScentOrdinal].getMapY())); + } + return 0; +} + +bool GroupMan::f198_isSmellPartyBlocked(uint16 mapX, uint16 mapY) { + uint16 L0408_ui_Square; + int16 L0409_i_SquareType; + + return ((L0409_i_SquareType = Square(L0408_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k0_ElementTypeWall) || ((L0409_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0408_ui_Square, k0x0004_FakeWallOpen)); +} + +int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo* info, int16 mapX, int16 mapY, bool allowMovementOverImaginaryPitsAndFakeWalls) { + int16 L0434_i_Direction; + + + for (L0434_i_Direction = kDirNorth; L0434_i_Direction <= kDirWest; L0434_i_Direction++) { + if ((!_g384_groupMovementTestedDirections[L0434_i_Direction]) && f202_isMovementPossible(info, mapX, mapY, L0434_i_Direction, allowMovementOverImaginaryPitsAndFakeWalls)) { + return _vm->M0_indexToOrdinal(L0434_i_Direction); + } + } + return 0; +} + +void GroupMan::f206_groupSetDirGroup(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, int16 creatureSize) { + bool L0436_B_TwoHalfSquareSizedCreatures; + + + if (L0436_B_TwoHalfSquareSizedCreatures = creatureIndex && (creatureSize == k1_MaskCreatureSizeHalf)) { + creatureIndex--; + } + do { + if (!creatureIndex || _vm->getRandomNumber(2)) { + f205_setDirection(activeGroup, dir, creatureIndex, L0436_B_TwoHalfSquareSizedCreatures); + } + } while (creatureIndex--); +} + +void GroupMan::f182_stopAttacking(ActiveGroup* group, int16 mapX, int16 mapY) { + int16 L0337_i_CreatureIndex; + + for (L0337_i_CreatureIndex = 0; L0337_i_CreatureIndex < 4; clearFlag(group->_aspect[L0337_i_CreatureIndex++], k0x0080_MaskActiveGroupIsAttacking)); + f181_groupDeleteEvents(mapX, mapY); + +} + +bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo* info, int16 mapX, int16 mapY, uint16 dir) { + if (_g385_fluxCages[dir]) { + return false; + } + mapX += _vm->_dirIntoStepCountEast[dir], mapY += _vm->_dirIntoStepCountNorth[dir]; + return f202_isMovementPossible(info, mapX, mapY, dir, false); +} + +bool GroupMan::f207_isCreatureAttacking(Group* group, int16 mapX, int16 mapY, uint16 creatureIndex) { + uint16 L0437_ui_Multiple; +#define AL0437_ui_CreatureType L0437_ui_Multiple +#define AL0437_T_Thing L0437_ui_Multiple + uint16 L0438_ui_PrimaryDirectionToParty; + int16 L0439_i_Multiple; +#define AL0439_i_GroupCells L0439_i_Multiple +#define AL0439_i_TargetCell L0439_i_Multiple +#define AL0439_i_ChampionIndex L0439_i_Multiple + int16 L0440_i_Multiple; +#define AL0440_i_KineticEnergy L0440_i_Multiple +#define AL0440_i_Counter L0440_i_Multiple +#define AL0440_i_Damage L0440_i_Multiple +#define AL0440_i_AttackSoundOrdinal L0440_i_Multiple + CreatureInfo* L0441_ps_CreatureInfo; + Champion* L0442_ps_Champion; + ActiveGroup L0443_s_ActiveGroup; + + + _vm->_projexpl->_g361_lastCreatureAttackTime = _vm->_g313_gameTime; + L0443_s_ActiveGroup = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]; + L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type]; + L0438_ui_PrimaryDirectionToParty = _g382_currGroupPrimaryDirToParty; + if ((AL0439_i_GroupCells = L0443_s_ActiveGroup._cells) == k255_CreatureTypeSingleCenteredCreature) { + AL0439_i_TargetCell = _vm->getRandomNumber(2); + } else { + AL0439_i_TargetCell = ((_vm->_groupMan->M50_getCreatureValue(AL0439_i_GroupCells, creatureIndex) + 5 - L0438_ui_PrimaryDirectionToParty) & 0x0002) >> 1; + } + AL0439_i_TargetCell += L0438_ui_PrimaryDirectionToParty; + AL0439_i_TargetCell &= 0x0003; + if ((L0441_ps_CreatureInfo->M56_getAttackRange() > 1) && ((_g381_currGroupDistanceToParty > 1) || _vm->getRandomNumber(2))) { + switch (AL0437_ui_CreatureType) { + case k14_CreatureTypeVexirk: + case k23_CreatureTypeLordChaos: + if (_vm->getRandomNumber(2)) { + AL0437_T_Thing = Thing::_explFireBall.toUint16(); + } else { + switch (_vm->getRandomNumber(4)) { + case 0: + AL0437_T_Thing = Thing::_explHarmNonMaterial.toUint16(); + break; + case 1: + AL0437_T_Thing = Thing::_explLightningBolt.toUint16(); + break; + case 2: + AL0437_T_Thing = Thing::_explPoisonCloud.toUint16(); + break; + case 3: + AL0437_T_Thing = Thing::_explOpenDoor.toUint16(); + } + } + break; + case k1_CreatureTypeSwampSlimeSlime: + AL0437_T_Thing = Thing::_explSlime.toUint16(); + break; + case k3_CreatureTypeWizardEyeFlyingEye: + if (_vm->getRandomNumber(8)) { + AL0437_T_Thing = Thing::_explLightningBolt.toUint16(); + } else { + AL0437_T_Thing = Thing::_explOpenDoor.toUint16(); + } + break; + case k19_CreatureTypeMaterializerZytaz: + if (_vm->getRandomNumber(2)) { + AL0437_T_Thing = Thing::_explPoisonCloud.toUint16(); + break; + } + case k22_CreatureTypeDemon: + case k24_CreatureTypeRedDragon: + AL0437_T_Thing = Thing::_explFireBall.toUint16(); + } /* BUG0_13 The game may crash when 'Lord Order' or 'Grey Lord' cast spells. This cannot happen with the original dungeons as they do not contain any groups of these types. 'Lord Order' and 'Grey Lord' creatures can cast spells (attack range > 1) but no projectile type is defined for them in the code. If these creatures are present in a dungeon they will cast projectiles containing undefined things because the variable is not initialized */ + AL0440_i_KineticEnergy = (L0441_ps_CreatureInfo->_attack >> 2) + 1; + AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy); + AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy); + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8); + } else { + if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) { + AL0439_i_ChampionIndex = _vm->getRandomNumber(4); + for (AL0440_i_Counter = 0; (AL0440_i_Counter < 4) && !_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex]._currHealth; AL0440_i_Counter++) { + AL0439_i_ChampionIndex = returnNextVal(AL0439_i_ChampionIndex); + } + if (AL0440_i_Counter == 4) { + return false; + } + } else { + if ((AL0439_i_ChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(mapX, mapY, AL0439_i_TargetCell)) < 0) { + return false; + } + } + if (AL0437_ui_CreatureType == k2_CreatureTypeGiggler) { + f193_stealFromChampion(group, AL0439_i_ChampionIndex); + } else { + AL0440_i_Damage = f230_getChampionDamage(group, AL0439_i_ChampionIndex) + 1; + L0442_ps_Champion = &_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex]; + if (AL0440_i_Damage > L0442_ps_Champion->_maximumDamageReceived) { + L0442_ps_Champion->_maximumDamageReceived = AL0440_i_Damage; + L0442_ps_Champion->_directionMaximumDamageReceived = returnOppositeDir((direction)L0438_ui_PrimaryDirectionToParty); + } + } + } + if (AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + return true; +} + +void GroupMan::f229_setOrderedCellsToAttack(signed char* orderedCellsToAttack, int16 targetMapX, int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource) { + static signed char g23_orderedCellsToAttack[8][4] = { // @ G0023_aac_Graphic562_OrderedCellsToAttack + {0, 1, 3, 2}, /* Attack South from position Northwest or Southwest */ + {1, 0, 2, 3}, /* Attack South from position Northeast or Southeast */ + {1, 2, 0, 3}, /* Attack West from position Northwest or Northeast */ + {2, 1, 3, 0}, /* Attack West from position Southeast or Southwest */ + {3, 2, 0, 1}, /* Attack North from position Northwest or Southwest */ + {2, 3, 1, 0}, /* Attack North from position Southeast or Northeast */ + {0, 3, 1, 2}, /* Attack East from position Northwest or Northeast */ + {3, 0, 2, 1}}; /* Attack East from position Southeast or Southwest */ + uint16 L0557_ui_OrderedCellsToAttackIndex; + + + if (!((L0557_ui_OrderedCellsToAttackIndex = f228_getDirsWhereDestIsVisibleFromSource(targetMapX, targetMapY, attackerMapX, attackerMapY) << 1) & 0x0002)) { + cellSource++; + } + L0557_ui_OrderedCellsToAttackIndex += (cellSource >> 1) & 0x0001; + for (uint16 i = 0; i < 4; ++i) + orderedCellsToAttack[i] = g23_orderedCellsToAttack[L0557_ui_OrderedCellsToAttackIndex][i]; +} + +void GroupMan::f193_stealFromChampion(Group* group, uint16 championIndex) { + int16 L0391_i_Percentage; + uint16 L0392_ui_StealFromSlotIndex; + uint16 L0393_ui_Counter; + Thing L0394_T_Thing; + Champion* L0395_ps_Champion; + bool L0396_B_ObjectStolen; + static unsigned char G0394_auc_StealFromSlotIndices[8]; /* Initialized with 0 bytes by C loader */ + + + L0396_B_ObjectStolen = false; + L0391_i_Percentage = 100 - _vm->_championMan->f311_getDexterity(L0395_ps_Champion = &_vm->_championMan->_gK71_champions[championIndex]); + L0393_ui_Counter = _vm->getRandomNumber(8); + while ((L0391_i_Percentage > 0) && !_vm->_championMan->f308_isLucky(L0395_ps_Champion, L0391_i_Percentage)) { + if ((L0392_ui_StealFromSlotIndex = G0394_auc_StealFromSlotIndices[L0393_ui_Counter]) == k13_ChampionSlotBackpackLine_1_1) { + L0392_ui_StealFromSlotIndex += _vm->getRandomNumber(17); /* Select a random slot in the backpack */ + } + if (((L0394_T_Thing = L0395_ps_Champion->_slots[L0392_ui_StealFromSlotIndex]) != Thing::_none)) { + L0396_B_ObjectStolen = true; + L0394_T_Thing = _vm->_championMan->f300_getObjectRemovedFromSlot(championIndex, L0392_ui_StealFromSlotIndex); + if (group->_slot == Thing::_endOfList) { + group->_slot = L0394_T_Thing; /* BUG0_12 An object is cloned and appears at two different locations in the dungeon and/or inventory. The game may crash when interacting with this object. If a Giggler with no possessions steals an object that was previously in a chest and was not the last object in the chest then the objects that followed it are cloned. In the chest, the object is part of a linked list of objects that is not reset when the object is removed from the chest and placed in the inventory (but not in the dungeon), nor when it is stolen and added as the first Giggler possession. If the Giggler already has a possession before stealing the object then this does not create a cloned object. + The following statement is missing: L0394_T_Thing->Next = Thing::_endOfList; + This creates cloned things if L0394_T_Thing->Next is not Thing::_endOfList which is the case when the object comes from a chest in which it was not the last object */ + } else { + _vm->_dungeonMan->f163_linkThingToList(L0394_T_Thing, group->_slot, kM1_MapXNotOnASquare, 0); + } + _vm->_championMan->f292_drawChampionState((ChampionIndex)championIndex); + } + ++L0393_ui_Counter; + L0393_ui_Counter &= 0x0007; + L0391_i_Percentage -= 20; + } + if (!_vm->getRandomNumber(8) || (L0396_B_ObjectStolen && _vm->getRandomNumber(2))) { + _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._delayFleeingFromTarget = _vm->getRandomNumber(64) + 20; + group->setBehaviour(k5_behavior_FLEE); + } +} + +int16 GroupMan::f230_getChampionDamage(Group* group, uint16 champIndex) { + unsigned char g24_woundProbabilityIndexToWoundMask[4] = {32, 16, 8, 4}; // @ G0024_auc_Graphic562_WoundProbabilityIndexToWoundMask + + Champion* L0562_ps_Champion; + int16 L0558_i_Multiple; +#define AL0558_i_Attack L0558_i_Multiple +#define AL0558_i_Damage L0558_i_Multiple + uint16 L0559_ui_Multiple; +#define AL0559_ui_WoundTest L0559_ui_Multiple +#define AL0559_ui_PoisonAttack L0559_ui_Multiple +#define AL0559_ui_CreatureDifficulty L0559_ui_Multiple + uint16 L0560_ui_WoundProbabilities; + uint16 L0561_ui_Multiple; +#define AL0561_ui_WoundProbabilityIndex L0561_ui_Multiple +#define AL0561_ui_AllowedWound L0561_ui_Multiple + int16 L0563_i_DoubledMapDifficulty; + CreatureInfo L0564_s_CreatureInfo; + + + L0562_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + if (champIndex >= _vm->_championMan->_g305_partyChampionCount) { + return 0; + } + if (!L0562_ps_Champion->_currHealth) { + return 0; + } + if (_vm->_championMan->_g300_partyIsSleeping) { + _vm->_championMan->f314_wakeUp(); + } + L0563_i_DoubledMapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty << 1; + L0564_s_CreatureInfo = g243_CreatureInfo[group->_type]; + _vm->_championMan->f304_addSkillExperience(champIndex, k7_ChampionSkillParry, L0564_s_CreatureInfo.M58_getExperience()); + if (_vm->_championMan->_g300_partyIsSleeping || (((_vm->_championMan->f311_getDexterity(L0562_ps_Champion) < (_vm->getRandomNumber(32) + L0564_s_CreatureInfo._dexterity + L0563_i_DoubledMapDifficulty - 16)) || !_vm->getRandomNumber(4)) && !_vm->_championMan->f308_isLucky(L0562_ps_Champion, 60))) { + if ((AL0559_ui_WoundTest = _vm->getRandomNumber(65536)) & 0x0070) { + AL0559_ui_WoundTest &= 0x000F; + L0560_ui_WoundProbabilities = L0564_s_CreatureInfo._woundProbabilities; + for (AL0561_ui_WoundProbabilityIndex = 0; AL0559_ui_WoundTest > (L0560_ui_WoundProbabilities & 0x000F); L0560_ui_WoundProbabilities >>= 4) { + AL0561_ui_WoundProbabilityIndex++; + } + AL0561_ui_AllowedWound = g24_woundProbabilityIndexToWoundMask[AL0561_ui_WoundProbabilityIndex]; + } else { + AL0561_ui_AllowedWound = AL0559_ui_WoundTest & 0x0001; /* 0 (Ready hand) or 1 (action hand) */ + } + if ((AL0558_i_Attack = (_vm->getRandomNumber(16) + L0564_s_CreatureInfo._attack + L0563_i_DoubledMapDifficulty) - (_vm->_championMan->f303_getSkillLevel(champIndex, k7_ChampionSkillParry) << 1)) <= 1) { + if (_vm->getRandomNumber(2)) { + goto T0230014; + } + AL0558_i_Attack = _vm->getRandomNumber(4) + 2; + } + AL0558_i_Attack >>= 1; + AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack) + _vm->getRandomNumber(4); + AL0558_i_Attack += _vm->getRandomNumber(AL0558_i_Attack); + AL0558_i_Attack >>= 2; + AL0558_i_Attack += _vm->getRandomNumber(4) + 1; + if (_vm->getRandomNumber(2)) { + AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1; + } + if (AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType)) { + warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + if ((AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack) && _vm->getRandomNumber(2) && ((AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack)) >= 0)) { + _vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack); + } + return AL0558_i_Damage; + } + } +T0230014: + return 0; +} + +void GroupMan::f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY) { + Group* L0363_ps_Group; + int16 L0364_i_CreatureType; + + + if (_g391_dropMovingCreatureFixedPossCellCount) { + L0363_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing); + L0364_i_CreatureType = L0363_ps_Group->_type; + while (_g391_dropMovingCreatureFixedPossCellCount) { + f186_dropCreatureFixedPossessions(L0364_i_CreatureType, mapX, mapY, _g392_dropMovingCreatureFixedPossessionsCell[--_g391_dropMovingCreatureFixedPossCellCount], k2_soundModePlayOneTickLater); + } + } +} + +void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) { + Group* L0332_ps_Group; + TimelineEvent L0333_s_Event; + + + L0332_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(mapX, mapY)); + if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) { + L0332_ps_Group->setBehaviour(k0_behavior_WANDER); + } + M33_setMapAndTime(L0333_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, (_vm->_g313_gameTime + 1)); + L0333_s_Event._type = k37_TMEventTypeUpdateBehaviourGroup; + L0333_s_Event._priority = 255 - g243_CreatureInfo[L0332_ps_Group->_type]._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */ + L0333_s_Event._C._ticks = 0; + L0333_s_Event._B._location._mapX = mapX; + L0333_s_Event._B._location._mapY = mapY; + _vm->_timeline->f238_addEventGetEventIndex(&L0333_s_Event); +} + +void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) { + uint16 L0339_ui_CreatureIndex; + Group* L0340_ps_Group; + ActiveGroup* L0341_ps_ActiveGroup; + int16 L0344_i_ActiveGroupIndex; + + + L0341_ps_ActiveGroup = _vm->_groupMan->_g375_activeGroups; + L0344_i_ActiveGroupIndex = 0; + while (L0341_ps_ActiveGroup->_groupThingIndex >= 0) { + if (++L0344_i_ActiveGroupIndex >= _vm->_groupMan->_g376_maxActiveGroupCount) { + return; /* BUG0_11 Data corruption in memory. Each group located on the same map as the party has additional associated data but there is only provision for 60 instances (_vm->_groupMan->_g376_maxActiveGroupCount). If there are more groups at the same time then some of them do not get their instance and when the game accesses this information it will corrupt other data in memory (either the instance of another group, parts of the timeline or events). This situation cannot occur in the original Dungeon Master and Chaos Strikes Back dungeons for the following reasons (but it may occur in custom dungeons if they are not designed carefully): there is no map with already more than 60 groups in the original dungeons and none of the following 3 possible ways to move a group into a map can increase the number of instances above the maximum of 60: + - A group generator sensor is triggered: the game never generates a group on the party map if there are less than 5 instances available. This limits the actual number of groups on a map to 55 in most cases. + - A group falls through a pit from the map above (the creature type must be allowed on the target map): a group will never willingly move to an open pit square. It may move to a closed pit square and fall if the pit is then open (either automatically or triggered by the party on the map below). There are no such pits in the original dungeons. + - A group is teleported from another map (the creature type must be allowed on the target map): in the original dungeons, all teleporters whose scope include groups and target another map are either inaccessible to groups or the groups are not allowed on the target map. The only exception is for some Gigglers in the Chaos Strikes Back dungeon but there are not enough to use the 5 reserved instances. + + This code returns immediately if all ACTIVE_GROUP entries are already in use, which avoids an out of bounds access into _vm->_groupMan->_g375_activeGroups below (through L0341_ps_ActiveGroup). However in this case the specified group ends up without an associated ACTIVE_GROUP structure which is assumed everywhere in the code to be present for groups on the same map as the party. If there are more than 60 groups on the party map at any given time then this will corrupt memory (in _vm->_timeline->_g370_events and _vm->_timeline->_g371_timeline allocated in _vm->_timeline->f233_initTimeline before _vm->_groupMan->_g375_activeGroups) because of read and write operations at incorrect memory addresses (the 'Cells' value of the GROUP will be used as an index in _vm->_groupMan->_g375_activeGroups even though that value was not replaced by the index of an ACTIVE_GROUP in this function) */ + } + L0341_ps_ActiveGroup++; + } + _g377_currActiveGroupCount++; + L0340_ps_Group = ((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType()); + L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells; + L0340_ps_Group->getActiveGroupIndex() = L0344_i_ActiveGroupIndex; + L0341_ps_ActiveGroup->_priorMapX = L0341_ps_ActiveGroup->_homeMapX = mapX; + L0341_ps_ActiveGroup->_priorMapY = L0341_ps_ActiveGroup->_homeMapY = mapY; + L0341_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime - 127; + L0339_ui_CreatureIndex = L0340_ps_Group->getCount(); + do { + L0341_ps_ActiveGroup->_directions = (direction)f178_getGroupValueUpdatedWithCreatureValue(L0341_ps_ActiveGroup->_directions, L0339_ui_CreatureIndex, L0340_ps_Group->getDir()); + L0341_ps_ActiveGroup->_aspect[L0339_ui_CreatureIndex] = 0; + } while (L0339_ui_CreatureIndex--); + f179_getCreatureAspectUpdateTime(L0341_ps_ActiveGroup, kM1_wholeCreatureGroup, false); +} + +void GroupMan::f184_removeActiveGroup(uint16 activeGroupIndex) { + ActiveGroup* L0347_ps_ActiveGroup; + Group* L0348_ps_Group; + + + if ((activeGroupIndex > _vm->_groupMan->_g376_maxActiveGroupCount) || (_vm->_groupMan->_g375_activeGroups[activeGroupIndex]._groupThingIndex < 0)) { + return; + } + L0347_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[activeGroupIndex]; + L0348_ps_Group = &((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex]; + _g377_currActiveGroupCount--; + L0348_ps_Group->_cells = L0347_ps_ActiveGroup->_cells; + L0348_ps_Group->setDir(M21_normalizeModulo4(L0347_ps_ActiveGroup->_directions)); + if (L0348_ps_Group->getBehaviour() >= k4_behavior_USELESS) { + L0348_ps_Group->setBehaviour(k0_behavior_WANDER); + } + L0347_ps_ActiveGroup->_groupThingIndex = -1; +} + +void GroupMan::f194_removeAllActiveGroups() { + for (int16 L0397_ui_ActiveGroupIndex = 0; _g377_currActiveGroupCount > 0; L0397_ui_ActiveGroupIndex++) { + if (_vm->_groupMan->_g375_activeGroups[L0397_ui_ActiveGroupIndex]._groupThingIndex >= 0) { + f184_removeActiveGroup(L0397_ui_ActiveGroupIndex); + } + } +} + +void GroupMan::f195_addAllActiveGroups() { + uint16 L0398_ui_MapX; + uint16 L0399_ui_MapY; + Thing L0400_T_Thing; + byte* L0401_puc_Square; + Thing* L0402_pT_SquareFirstThing; + + + L0401_puc_Square = _vm->_dungeonMan->_g271_currMapData[0]; + L0402_pT_SquareFirstThing = &_vm->_dungeonMan->_g283_squareFirstThings[_vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount[0]]; + for (L0398_ui_MapX = 0; L0398_ui_MapX < _vm->_dungeonMan->_g273_currMapWidth; L0398_ui_MapX++) { + for (L0399_ui_MapY = 0; L0399_ui_MapY < _vm->_dungeonMan->_g274_currMapHeight; L0399_ui_MapY++) { + if (getFlag(*L0401_puc_Square++, k0x0010_ThingListPresent)) { + L0400_T_Thing = *L0402_pT_SquareFirstThing++; + do { + if (L0400_T_Thing.getType() == k4_GroupThingType) { + f181_groupDeleteEvents(L0398_ui_MapX, L0399_ui_MapY); + f183_addActiveGroup(L0400_T_Thing, L0398_ui_MapX, L0399_ui_MapY); + f180_startWanedring(L0398_ui_MapX, L0399_ui_MapY); + break; + } + } while ((L0400_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0400_T_Thing)) != Thing::_endOfList); + } + } + } +} } diff --git a/engines/dm/group.h b/engines/dm/group.h index 3530765b74..f9aa038aee 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -231,7 +231,8 @@ public: void f180_startWanedring(int16 mapX, int16 mapY); // @ F0180_GROUP_StartWandering void f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY); // @ F0183_GROUP_AddActiveGroup void f184_removeActiveGroup(uint16 activeGroupIndex); // @ F0184_GROUP_RemoveActiveGroup - + void f194_removeAllActiveGroups(); // @ F0194_GROUP_RemoveAllActiveGroups + void f195_addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index b8b0ba8a60..35bdf21ebb 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -43,11 +43,13 @@ Box g36_BoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water Box g37_BoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) { + _g432_inventoryChampionOrdinal = 0; _g424_panelContent = k0_PanelContentFoodWaterPoisoned; for (uint16 i = 0; i < 8; ++i) - _g425_chestSlots[i] = Thing::_none; - _g426_openChest = Thing::_none; + _g425_chestSlots[i] = Thing(0); _g426_openChest = Thing::_none; + _g421_objDescTextXpos = 0; + _g422_objDescTextYpos = 0; } void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) { @@ -643,4 +645,41 @@ void InventoryMan::f337_setDungeonViewPalette() { _vm->_displayMan->_g342_refreshDungeonViewPaleteRequested = true; } + +void InventoryMan::f338_decreaseTorchesLightPower() { + int16 L1046_i_ChampionCount; + int16 L1047_i_SlotIndex; + bool L1048_B_TorchChargeCountChanged; + int16 L1049_i_IconIndex; + Champion* L1050_ps_Champion; + Weapon* L1051_ps_Weapon; + + + L1048_B_TorchChargeCountChanged = false; + L1046_i_ChampionCount = _vm->_championMan->_g305_partyChampionCount; + if (_vm->_championMan->_g299_candidateChampionOrdinal) { + L1046_i_ChampionCount--; + } + L1050_ps_Champion = _vm->_championMan->_gK71_champions; + while (L1046_i_ChampionCount--) { + L1047_i_SlotIndex = k1_ChampionSlotActionHand + 1; + while (L1047_i_SlotIndex--) { + L1049_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L1050_ps_Champion->_slots[L1047_i_SlotIndex]); + if ((L1049_i_IconIndex >= k4_IconIndiceWeaponTorchUnlit) && (L1049_i_IconIndex <= k7_IconIndiceWeaponTorchLit)) { + L1051_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L1050_ps_Champion->_slots[L1047_i_SlotIndex]); + if (L1051_ps_Weapon->getChargeCount()) { + if (L1051_ps_Weapon->setChargeCount(L1051_ps_Weapon->getChargeCount() - 1) == 0) { + L1051_ps_Weapon->setDoNotDiscard(false); + } + L1048_B_TorchChargeCountChanged = true; + } + } + } + L1050_ps_Champion++; + } + if (L1048_B_TorchChargeCountChanged) { + f337_setDungeonViewPalette(); + _vm->_championMan->f296_drawChangedObjectIcons(); + } +} } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index aa9b2150d4..35a76c4e9f 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -79,6 +79,7 @@ public: void f339_drawPanelArrowOrEye(bool pressingEye); // @ F0339_INVENTORY_DrawPanel_ArrowOrEye void f342_drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object void f337_setDungeonViewPalette(); // @ F0337_INVENTORY_SetDungeonViewPalette + void f338_decreaseTorchesLightPower(); // @ F0338_INVENTORY_DecreaseTorchesLightPower_CPSE }; diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 66b293ac3e..f42d955b3d 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -52,6 +52,7 @@ MenuMan::MenuMan(DMEngine *vm) : _vm(vm) { _g508_refreshActionArea = false; _g509_actionAreaContainsIcons = false; _g513_actionDamage = 0; + _g713_actionList.resetToZero(); _gK72_bitmapSpellAreaLine = new byte[96 * 12]; } diff --git a/engines/dm/menus.h b/engines/dm/menus.h index 4e0324205b..9c93fd00a7 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -40,10 +40,11 @@ class ActionList { public: byte _minimumSkillLevel[3]; /* Bit 7: requires charge, Bit 6-0: minimum skill level. */ ChampionAction _actionIndices[3]; - ActionList() { + ActionList() { resetToZero(); } + void resetToZero() { for (uint16 i = 0; i < 3; ++i) { _minimumSkillLevel[i] = 0; - _actionIndices[i] = k255_ChampionActionNone; + _actionIndices[i] = (ChampionAction)0; } } }; // @ ACTION_LIST diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 70f8cc8220..2da2ee054b 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -39,7 +39,18 @@ namespace DM { -MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {} +MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) { + _g397_moveResultMapX = 0; + _g398_moveResultMapY = 0; + _g399_moveResultMapIndex = 0; + _g400_moveResultDir = 0; + _g401_moveResultCell = 0; + _g402_useRopeToClimbDownPit = false; + _g403_sensorRotationEffect = 0; + _g404_sensorRotationEffMapX = 0; + _g405_sensorRotationEffMapY = 0; + _g406_sensorRotationEffCell = 0; +} bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam) { Thing L0750_T_ThingBeingProcessed; diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 157cfd8ad8..976e671730 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -91,6 +91,9 @@ ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) { _g30_slotBoxes[44] = SlotBox(179, 104, 0); /* Chest 7 */ _g30_slotBoxes[45] = SlotBox(196, 105, 0); /* Chest 8 */ + for (uint16 i = 0; i < k199_ObjectNameCount; ++i) + _g352_objectNames[i] = nullptr; + _g412_objectIconForMousePointer = nullptr; } diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index 95d40bbaea..5ce7b20fd2 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -36,7 +36,13 @@ namespace DM { ProjExpl::ProjExpl(DMEngine* vm) : _vm(vm) { + _g364_creatureDamageOutcome = 0; + _g363_secondaryDirToOrFromParty = 0; _g361_lastCreatureAttackTime = -200; + _g365_createLanucherProjectile = false; + _g366_projectilePoisonAttack = 0; + _g367_projectileAttackType = 0; + _g362_lastPartyMovementTime = 0; } void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, direction dir, byte kineticEnergy, byte attack, byte stepEnergy) { diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index d9ca4b7fd1..06a10b2784 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -31,6 +31,10 @@ namespace DM { TextMan::TextMan(DMEngine* vm) : _vm(vm) { + _g359_messageAreaCursorColumn = 0; + _g358_messageAreaCursorRow = 0; + for (uint16 i = 0; i < 4; ++i) + _g360_messageAreaRowExpirationTime[i] = 0; _g356_bitmapMessageAreaNewRow = new byte[320 * 7]; } @@ -161,4 +165,28 @@ void TextMan::f46_messageAreaPrintString(Color color, const char* string) { _g360_messageAreaRowExpirationTime[_g358_messageAreaCursorRow] = _vm->_g313_gameTime + 200; } +void TextMan::f54_textInitialize() { + f42_messageAreaMoveCursor(0, 3); + for (uint16 i = 0; i < 4; ++i) + _g360_messageAreaRowExpirationTime[i] = -1; +} + +void TextMan::f42_messageAreaMoveCursor(int16 column, int16 row) { + if (column < 0) { + column = 0; + } else { + if (column >= 53) { + column = 52; + } + } + _g359_messageAreaCursorColumn = column; + if (row < 0) { + row = 0; + } else { + if (row >= 4) { + row = 3; + } + } + _g358_messageAreaCursorRow = row; +} } diff --git a/engines/dm/text.h b/engines/dm/text.h index b0ecb48716..ce38c55cbf 100644 --- a/engines/dm/text.h +++ b/engines/dm/text.h @@ -52,6 +52,9 @@ public: void f47_messageAreaPrintMessage(Color color, const char *string); // @ F0047_TEXT_MESSAGEAREA_PrintMessage void f45_messageAreaCreateNewRow(); // @ F0045_TEXT_MESSAGEAREA_CreateNewRow void f46_messageAreaPrintString(Color color, const char* string);// @ F0046_TEXT_MESSAGEAREA_PrintString + void f54_textInitialize(); // @ F0054_TEXT_Initialize + void f42_messageAreaMoveCursor(int16 column, int16 row); // @ F0042_TEXT_MESSAGEAREA_MoveCursor + }; diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 2b58203b35..8b26210017 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -32,8 +32,11 @@ namespace DM { Timeline::Timeline(DMEngine* vm) : _vm(vm) { + _g369_eventMaxCount = 0; _g370_events = nullptr; + _g372_eventCount = 0; _g371_timeline = nullptr; + _g373_firstUnusedEventIndex = 0; } Timeline::~Timeline() { -- cgit v1.2.3 From 0d4b09980e7b7bb3cb0a63b9df6de7e01067a977 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 7 Jul 2016 20:15:38 +0200 Subject: DM: Replace ChampionMan::f292_drawChampionState with original --- engines/dm/champion.cpp | 297 +++++++++++++++++++++++------------------------ engines/dm/eventman.cpp | 4 +- engines/dm/gfx.cpp | 201 +++++++++++++++++--------------- engines/dm/gfx.h | 7 +- engines/dm/inventory.cpp | 64 +++++++++- engines/dm/inventory.h | 1 + engines/dm/menus.cpp | 16 +-- engines/dm/objectman.cpp | 6 +- engines/dm/text.cpp | 2 +- 9 files changed, 329 insertions(+), 269 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 644914081e..96604e3140 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1187,7 +1187,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) { // limit destBox scope Box &destBox = gBoxChampionPortrait; dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), champ->_portrait, - destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 128, 16, k255_ColorNoTransparency); + destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 128, 16, kM1_ColorNoTransparency); } champ->_actionIndex = k255_ChampionActionNone; @@ -1442,186 +1442,175 @@ uint16 ChampionMan::f309_getMaximumLoad(Champion *champ) { } void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { - InventoryMan &invMan = *_vm->_inventoryMan; - DisplayMan &dispMan = *_vm->_displayMan; - MenuMan &menuMan = *_vm->_menuMan; - EventManager &eventMan = *_vm->_eventMan; - - Box box; - int16 champStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing; - Champion *champ = &_gK71_champions[champIndex]; - uint16 champAttributes = champ->getAttributes(); - if (!((champAttributes) & (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | - k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | - k0x8000_ChampionAttributeActionHand))) { + uint16 L0862_ui_ChampionAttributes; + bool L0863_B_IsInventoryChampion; + int16 L0864_i_Multiple; +#define AL0864_i_BorderCount L0864_i_Multiple +#define AL0864_i_ColorIndex L0864_i_Multiple +#define AL0864_i_Load L0864_i_Multiple +#define AL0864_i_ChampionIconIndex L0864_i_Multiple +#define AL0864_i_StatisticIndex L0864_i_Multiple +#define AL0864_i_SlotIndex L0864_i_Multiple + Champion* L0865_ps_Champion; + char* L0866_pc_ChampionName; + char L0867_c_ChampionTitleFirstCharacter; + int16 L0868_i_ChampionStatusBoxX; + int16 L0869_i_ChampionTitleX; + int16 L0870_i_Multiple; +#define AL0870_i_NativeBitmapIndex L0870_i_Multiple +#define AL0870_i_Color L0870_i_Multiple + Box L0871_s_Box; + int16 L0872_ai_NativeBitmapIndices[3]; + + + L0868_i_ChampionStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing; + L0865_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + L0862_ui_ChampionAttributes = L0865_ps_Champion->_attributes; + if (!getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand)) { return; } - bool isInventoryChamp = (_vm->M0_indexToOrdinal(champIndex) == invMan._g432_inventoryChampionOrdinal); - dispMan._g578_useByteBoxCoordinates = false; - if (champAttributes & k0x1000_ChampionAttributeStatusBox) { - box._y1 = 0; - box._y2 = 28; - box._x1 = champStatusBoxX; - box._x2 = box._x1 + 66; - if (champ->_currHealth) { - dispMan.D24_fillScreenBox(box, k12_ColorDarkestGray); - int16 nativeBitmapIndices[3]; - for (int16 i = 0; i < 3; ++i) - nativeBitmapIndices[i] = 0; - int16 AL_0_borderCount = 0; - if (_g407_party._fireShieldDefense > 0) - nativeBitmapIndices[AL_0_borderCount++] = k38_BorderPartyFireshieldIndice; - if (_g407_party._spellShieldDefense > 0) - nativeBitmapIndices[AL_0_borderCount++] = k39_BorderPartySpellshieldIndice; - if (_g407_party._shieldDefense > 0) - nativeBitmapIndices[AL_0_borderCount++] = k37_BorderPartyShieldIndice; - while (AL_0_borderCount--) { - dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(nativeBitmapIndices[AL_0_borderCount]), - dispMan._g348_bitmapScreen, box, 0, 0, 40, k160_byteWidthScreen, k10_ColorFlesh); + L0863_B_IsInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal); + _vm->_displayMan->_g578_useByteBoxCoordinates = false; + _vm->_eventMan->f78_showMouse(); + if (getFlag(L0862_ui_ChampionAttributes, k0x1000_ChampionAttributeStatusBox)) { + L0871_s_Box._y1 = 0; + L0871_s_Box._y2 = 28; + L0871_s_Box._x2 = (L0871_s_Box._x1 = L0868_i_ChampionStatusBoxX) + 66; + if (L0865_ps_Champion->_currHealth) { + _vm->_displayMan->D24_fillScreenBox(L0871_s_Box, k12_ColorDarkestGray); + for (uint16 i = 0; i < 3; ++i) + L0872_ai_NativeBitmapIndices[i] = 0; + AL0864_i_BorderCount = 0; + if (_vm->_championMan->_g407_party._fireShieldDefense > 0) { + L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k38_BorderPartyFireshieldIndice; + } + if (_vm->_championMan->_g407_party._spellShieldDefense > 0) { + L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k39_BorderPartySpellshieldIndice; + } + if ((_vm->_championMan->_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) { + L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k37_BorderPartyShieldIndice; } - if (isInventoryChamp) { - invMan.f354_drawStatusBoxPortrait(champIndex); - champAttributes |= k0x0100_ChampionAttributeStatistics; + while (AL0864_i_BorderCount--) { + _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount]), &L0871_s_Box, k40_byteWidth, k10_ColorFlesh, 29); + } + if (L0863_B_IsInventoryChampion) { + _vm->_inventoryMan->f354_drawStatusBoxPortrait(champIndex); + setFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics); } else { - champAttributes |= (k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand); + setFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand); } } else { - dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), dispMan._g348_bitmapScreen, - box, 0, 0, 40, k160_byteWidthScreen, k255_ColorNoTransparency); - _vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, champ->_name); - menuMan.f386_drawActionIcon(champIndex); - goto T0292042_green; - } - } - - if (!champ->_currHealth) - goto T0292042_green; - - if (champAttributes & k0x0080_ChampionAttributeNameTitle) { - Color AL_0_colorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; // unused because of missing functions - if (isInventoryChamp) { - char *champName = champ->_name; - _vm->_textMan->f52_printToViewport(3, 7, AL_0_colorIndex, champName); - int16 champTitleX = 6 * strlen(champName) + 3; - char champTitleFirstChar = champ->_title[0]; - if ((champTitleFirstChar != ',') && (champTitleFirstChar != ';') && (champTitleFirstChar != '-')) { - champTitleX += 6; + _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), &L0871_s_Box, k40_byteWidth, kM1_ColorNoTransparency, 29); + _vm->_textMan->f53_printToLogicalScreen(L0868_i_ChampionStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, L0865_ps_Champion->_name); + _vm->_menuMan->f386_drawActionIcon(champIndex); + goto T0292042; + } + } + if (!(L0865_ps_Champion->_currHealth)) + goto T0292042; + if (getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle)) { + AL0864_i_ColorIndex = (champIndex == _vm->_championMan->_g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; + if (L0863_B_IsInventoryChampion) { + _vm->_textMan->f52_printToViewport(3, 7, (Color)AL0864_i_ColorIndex, L0866_pc_ChampionName = L0865_ps_Champion->_name); + L0869_i_ChampionTitleX = 6 * strlen(L0866_pc_ChampionName) + 3; + L0867_c_ChampionTitleFirstCharacter = L0865_ps_Champion->_title[0]; + if ((L0867_c_ChampionTitleFirstCharacter != ',') && (L0867_c_ChampionTitleFirstCharacter != ';') && (L0867_c_ChampionTitleFirstCharacter != '-')) { + L0869_i_ChampionTitleX += 6; } - _vm->_textMan->f52_printToViewport(champTitleX, 7, AL_0_colorIndex, champ->_title); - champAttributes |= k0x4000_ChampionAttributeViewport; + _vm->_textMan->f52_printToViewport(L0869_i_ChampionTitleX, 7, (Color)AL0864_i_ColorIndex, L0865_ps_Champion->_title); + setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); } else { - box._y1 = 0; - box._y2 = 6; - box._x1 = champStatusBoxX; - box._x2 = box._x1 + 42; - dispMan.D24_fillScreenBox(box, k1_ColorDarkGary); - _vm->_textMan->f53_printToLogicalScreen(champStatusBoxX + 1, 5, AL_0_colorIndex, k1_ColorDarkGary, champ->_name); - } - } - - if (champAttributes & k0x0100_ChampionAttributeStatistics) { - f287_drawChampionBarGraphs(champIndex); - if (isInventoryChamp) { - f290_drawHealthStaminaManaValues(champ); - int16 AL_2_nativeBitmapIndex; - if ((champ->_food < 0) || (champ->_water < 0) || (champ->_poisonEventCount)) { - AL_2_nativeBitmapIndex = k34_SlotBoxWoundedIndice; + L0871_s_Box._y1 = 0; + L0871_s_Box._y2 = 6; + L0871_s_Box._x2 = (L0871_s_Box._x1 = L0868_i_ChampionStatusBoxX) + 42; + _vm->_displayMan->D24_fillScreenBox(L0871_s_Box, k1_ColorDarkGary); + _vm->_textMan->f53_printToLogicalScreen(L0868_i_ChampionStatusBoxX + 1, 5, (Color)AL0864_i_ColorIndex, k1_ColorDarkGary, L0865_ps_Champion->_name); + } + } + if (getFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics)) { + _vm->_championMan->f287_drawChampionBarGraphs(champIndex); + if (L0863_B_IsInventoryChampion) { + _vm->_championMan->f290_drawHealthStaminaManaValues(L0865_ps_Champion); + if ((L0865_ps_Champion->_food < 0) || (L0865_ps_Champion->_water < 0) || (L0865_ps_Champion->_poisonEventCount)) { + AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice; } else { - AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; + AL0870_i_NativeBitmapIndex = k33_SlotBoxNormalIndice; } - dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport, - gBoxMouth, 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray); - AL_2_nativeBitmapIndex = k33_SlotBoxNormalIndice; - for (int16 AL_0_statisticIndex = k1_ChampionStatStrength; AL_0_statisticIndex <= k6_ChampionStatAntifire; AL_0_statisticIndex++) { - if (champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent) - < champ->getStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum)) { - AL_2_nativeBitmapIndex = k34_SlotBoxWoundedIndice; + _vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(AL0870_i_NativeBitmapIndex), gBoxMouth, k16_byteWidth, k12_ColorDarkestGray, 18); + AL0870_i_NativeBitmapIndex = k33_SlotBoxNormalIndice; + for (AL0864_i_StatisticIndex = k1_ChampionStatStrength; AL0864_i_StatisticIndex <= k6_ChampionStatAntifire; AL0864_i_StatisticIndex++) { + if ((L0865_ps_Champion->_statistics[AL0864_i_StatisticIndex][k1_ChampionStatCurrent] < L0865_ps_Champion->_statistics[AL0864_i_StatisticIndex][k0_ChampionStatMaximum])) { + AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice; break; } } - dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(AL_2_nativeBitmapIndex), dispMan._g296_bitmapViewport, gBoxEye, - 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray); - champAttributes |= k0x4000_ChampionAttributeViewport; + _vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(AL0870_i_NativeBitmapIndex), gBoxEye, k16_byteWidth, k12_ColorDarkestGray, 18); + setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); } } - - if (champAttributes & k0x2000_ChampionAttributeWounds) { - for (int16 AL_0_slotIndex = isInventoryChamp ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL_0_slotIndex >= k0_ChampionSlotReadyHand; AL_0_slotIndex--) { - f291_drawSlot(champIndex, (ChampionSlot)AL_0_slotIndex); + if (getFlag(L0862_ui_ChampionAttributes, k0x2000_ChampionAttributeWounds)) { + for (AL0864_i_SlotIndex = L0863_B_IsInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL0864_i_SlotIndex >= k0_ChampionSlotReadyHand; AL0864_i_SlotIndex--) { + _vm->_championMan->f291_drawSlot(champIndex, AL0864_i_SlotIndex); } - if (isInventoryChamp) { - champAttributes |= k0x4000_ChampionAttributeViewport; + if (L0863_B_IsInventoryChampion) { + setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); } } - - if ((champAttributes & k0x0200_ChampionAttributeLoad) && isInventoryChamp) { - Color loadColor; - int16 champMaxLoad = f309_getMaximumLoad(champ); - if (champ->_load > champMaxLoad) { - loadColor = k8_ColorRed; - } else if (((int32)champ->_load) * 8 > ((int32)champMaxLoad) * 5) { - loadColor = k11_ColorYellow; + if (getFlag(L0862_ui_ChampionAttributes, k0x0200_ChampionAttributeLoad) && L0863_B_IsInventoryChampion) { + if (L0865_ps_Champion->_load > (AL0864_i_Load = _vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion))) { + AL0870_i_Color = k8_ColorRed; } else { - loadColor = k13_ColorLightestGray; - } - _vm->_textMan->f52_printToViewport(104, 132, loadColor, "LOAD "); - - int16 loadTmp = champ->_load / 10; - Common::String str = f288_getStringFromInteger(loadTmp, true, 3); - str += '.'; - loadTmp = champ->_load - (loadTmp * 10); - str += f288_getStringFromInteger(loadTmp, false, 1); - str += '/'; - loadTmp = (f309_getMaximumLoad(champ) + 5) / 10; - str += "KG"; - _vm->_textMan->f52_printToViewport(148, 132, loadColor, str.c_str()); - champAttributes |= k0x4000_ChampionAttributeViewport; - } - - { // block so goto won't skip AL_0_championIconIndex initialization - int16 AL_0_championIconIndex = M26_championIconIndex(champ->_cell, _vm->_dungeonMan->_g308_partyDir); - - if ((champAttributes & k28_ChampionIcons) && (eventMan._g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL_0_championIconIndex))) { - dispMan.D24_fillScreenBox(g54_BoxChampionIcons[AL_0_championIconIndex], g46_ChampionColor[champIndex]); - dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k28_ChampionIcons), - dispMan._g348_bitmapScreen, - g54_BoxChampionIcons[AL_0_championIconIndex << 2], - M26_championIconIndex(champ->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, - 40, k160_byteWidthScreen, k12_ColorDarkestGray); + if (((long)L0865_ps_Champion->_load << 3) > ((long)AL0864_i_Load * 5)) { + AL0870_i_Color = k11_ColorYellow; + } else { + AL0870_i_Color = k13_ColorLightestGray; + } } - } - - if ((champAttributes & k0x0800_ChampionAttributePanel) && isInventoryChamp) { + _vm->_textMan->f52_printToViewport(104, 132, (Color)AL0870_i_Color, "LOAD "); + AL0864_i_Load = L0865_ps_Champion->_load / 10; + strcpy(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); + strcat(_vm->_g353_stringBuildBuffer, "."); + AL0864_i_Load = L0865_ps_Champion->_load - (AL0864_i_Load * 10); + strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str()); + strcat(_vm->_g353_stringBuildBuffer, "/"); + AL0864_i_Load = (_vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10; + strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); + strcat(_vm->_g353_stringBuildBuffer, " KG"); + _vm->_textMan->f52_printToViewport(148, 132, (Color)AL0870_i_Color, _vm->_g353_stringBuildBuffer); + setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); + } + AL0864_i_ChampionIconIndex = _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir); + if (getFlag(L0862_ui_ChampionAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL0864_i_ChampionIconIndex))) { + _vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], g46_ChampionColor[champIndex]); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen); + } + if (getFlag(L0862_ui_ChampionAttributes, k0x0800_ChampionAttributePanel) && L0863_B_IsInventoryChampion) { if (_vm->_g333_pressingMouth) { - invMan.f345_drawPanelFoodWaterPoisoned(); - } else if (_vm->_g331_pressingEye) { - if (_g415_leaderEmptyHanded) { - warning("MISSING CODE: F0351_INVENTORY_DrawChampionSkillsAndStatistics"); - } + _vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned(); } else { - invMan.f347_drawPanel(); + if (_vm->_g331_pressingEye) { + if (_vm->_championMan->_g415_leaderEmptyHanded) { + _vm->_inventoryMan->f351_drawChampionSkillsAndStatistics(); + } + } else { + _vm->_inventoryMan->f347_drawPanel(); + } } - champAttributes |= k0x4000_ChampionAttributeViewport; + setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); } - - if (champAttributes & k0x8000_ChampionAttributeActionHand) { - f291_drawSlot(champIndex, k1_ChampionSlotActionHand); - menuMan.f386_drawActionIcon(champIndex); - if (isInventoryChamp) { - champAttributes |= k0x4000_ChampionAttributeViewport; + if (getFlag(L0862_ui_ChampionAttributes, k0x8000_ChampionAttributeActionHand)) { + _vm->_championMan->f291_drawSlot(champIndex, k1_ChampionSlotActionHand); + _vm->_menuMan->f386_drawActionIcon(champIndex); + if (L0863_B_IsInventoryChampion) { + setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); } } - - if (champAttributes & k0x4000_ChampionAttributeViewport) { - dispMan.f97_drawViewport(k0_viewportNotDungeonView); + if (getFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport)) { + _vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView); } - - -T0292042_green: - champ->setAttributeFlag((ChampionAttribute)(k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | - k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | - k0x8000_ChampionAttributeActionHand), false); - _vm->_eventMan->f78_showMouse(); +T0292042: + clearFlag(L0865_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand); + _vm->_eventMan->f77_hideMouse(); } uint16 ChampionMan::M26_championIconIndex(int16 val, direction dir) { diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 99a0e17769..2fbefb118d 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -359,7 +359,7 @@ void EventManager::f68_setPointerToObject(byte* bitmap) { L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject; memset(L0051_puc_Bitmap, 0, 32 * 18); _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, gK27_palChangesMousepointerOjbectIconShadow); - _vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, k255_ColorNoTransparency, 16, 18); + _vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18); _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, g44_palChangesMousePointerIcon); _vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18); _gK100_preventBuildPointerScreenArea = false; @@ -472,7 +472,7 @@ void EventManager::f78_showMouse() { } void EventManager::f77_hideMouse() { - CursorMan.showMouse(false); + // CursorMan.showMouse(false); } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 7411f0cc0c..25f0e4bd59 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -708,16 +708,16 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { g186_doorFrame_D1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(64, 159, 17, 102, 48, 88, 0, 0), /* Closed Or Destroyed */ - Frame(64, 159, 17, 38, 48, 88, 0, 66), /* Vertical Closed one fourth */ - Frame(64, 159, 17, 60, 48, 88, 0, 44), /* Vertical Closed half */ - Frame(64, 159, 17, 82, 48, 88, 0, 22), /* Vertical Closed three fourth */ - Frame(64, 75, 17, 102, 48, 88, 36, 0), /* Left Horizontal Closed one fourth */ - Frame(64, 87, 17, 102, 48, 88, 24, 0), /* Left Horizontal Closed half */ - Frame(64, 99, 17, 102, 48, 88, 12, 0), /* Left Horizontal Closed three fourth */ - Frame(148, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */ - Frame(136, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */ - Frame(124, 159, 17, 102, 48, 88, 48, 0) /* Right Horizontal Closed three fourth */ + Frame(64, 159, 17, 102, 48, 88, 0, 0), /* Closed Or Destroyed */ + Frame(64, 159, 17, 38, 48, 88, 0, 66), /* Vertical Closed one fourth */ + Frame(64, 159, 17, 60, 48, 88, 0, 44), /* Vertical Closed half */ + Frame(64, 159, 17, 82, 48, 88, 0, 22), /* Vertical Closed three fourth */ + Frame(64, 75, 17, 102, 48, 88, 36, 0), /* Left Horizontal Closed one fourth */ + Frame(64, 87, 17, 102, 48, 88, 24, 0), /* Left Horizontal Closed half */ + Frame(64, 99, 17, 102, 48, 88, 12, 0), /* Left Horizontal Closed three fourth */ + Frame(148, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */ + Frame(136, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */ + Frame(124, 159, 17, 102, 48, 88, 48, 0) /* Right Horizontal Closed three fourth */ ); } @@ -1056,7 +1056,7 @@ void DisplayMan::f566_viewportBlitToScreen() { warning("MISSING FUNCTIONALITY: using correct colorpalette"); Box box(0, 223, 33, 33 + 135); - f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport, k160_byteWidthScreen, k255_ColorNoTransparency); + f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport, k160_byteWidthScreen, kM1_ColorNoTransparency); } void DisplayMan::loadPalette(uint16 *palette) { @@ -1442,6 +1442,15 @@ void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame* frame, int1 } } +void DisplayMan::f20_blitToViewport(byte* bitmap, Box& box, int16 byteWidth, Color transparent, int16 height) { + f132_blitToBitmap(bitmap, _g296_bitmapViewport, box, 0, 0, byteWidth, k112_byteWidthViewport, transparent, height, k136_heightViewport); +} + +void DisplayMan::f20_blitToViewport(byte* bitmap, int16* box, int16 byteWidth, Color transparent, int16 height) { + Box actualBox(box[0], box[1], box[2], box[3]); + f20_blitToViewport(bitmap, actualBox, byteWidth, transparent, height); +} + void DisplayMan::f21_blitToScreen(byte *bitmap, int16* box, int16 byteWidth, Color transparent, int16 height) { Box actualBox(box[0], box[1], box[2], box[3]); f21_blitToScreen(bitmap, &actualBox, byteWidth, transparent, height); @@ -1454,7 +1463,7 @@ void DisplayMan::f21_blitToScreen(byte* bitmap, Box* box, int16 viewDoorOrnIndex void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { if (f._srcByteWidth) - f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency); + f132_blitToBitmap(bitmap, _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency); } void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) { @@ -1467,16 +1476,16 @@ void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) { void DisplayMan::f116_drawSquareD3L(direction dir, int16 posX, int16 posY) { static DoorFrames g179_doorFrame_D3L = DoorFrames( // @ G0179_s_Graphic558_Frames_Door_D3L /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(24, 71, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ - Frame(24, 71, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ - Frame(24, 71, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ - Frame(24, 71, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ - Frame(24, 29, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ - Frame(24, 35, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ - Frame(24, 41, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ - Frame(66, 71, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ - Frame(60, 71, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ - Frame(54, 71, 28, 67, 24, 41, 24, 0) + Frame(24, 71, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ + Frame(24, 71, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ + Frame(24, 71, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ + Frame(24, 71, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ + Frame(24, 29, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ + Frame(24, 35, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ + Frame(24, 41, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ + Frame(66, 71, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ + Frame(60, 71, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ + Frame(54, 71, 28, 67, 24, 41, 24, 0) ); /* Right Horizontal Closed three fourth */ uint16 squareAspect[5]; @@ -1532,16 +1541,16 @@ T0116017_orangeElk: void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) { static DoorFrames g181_doorFrame_D3R = DoorFrames( // @ G0181_s_Graphic558_Frames_Door_D3R /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(150, 197, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ - Frame(150, 197, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ - Frame(150, 197, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ - Frame(150, 197, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ - Frame(150, 153, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ - Frame(150, 161, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ - Frame(150, 167, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ - Frame(192, 197, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ - Frame(186, 197, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ - Frame(180, 197, 28, 67, 24, 41, 24, 0) /* Right Horizontal Closed three fourth */ + Frame(150, 197, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ + Frame(150, 197, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ + Frame(150, 197, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ + Frame(150, 197, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ + Frame(150, 153, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ + Frame(150, 161, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ + Frame(150, 167, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ + Frame(192, 197, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ + Frame(186, 197, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ + Frame(180, 197, 28, 67, 24, 41, 24, 0) /* Right Horizontal Closed three fourth */ ); int16 order; @@ -1603,16 +1612,16 @@ T0117018: void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) { static DoorFrames g180_doorFrame_D3C = DoorFrames( // @ G0180_s_Graphic558_Frames_Door_D3C /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(88, 135, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ - Frame(88, 135, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ - Frame(88, 135, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ - Frame(88, 135, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ - Frame(88, 93, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ - Frame(88, 99, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ - Frame(88, 105, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ - Frame(130, 135, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ - Frame(124, 135, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ - Frame(118, 135, 28, 67, 24, 41, 24, 0) /* Right Horizontal Closed three fourth */ + Frame(88, 135, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ + Frame(88, 135, 28, 38, 24, 41, 0, 30), /* Vertical Closed one fourth */ + Frame(88, 135, 28, 48, 24, 41, 0, 20), /* Vertical Closed half */ + Frame(88, 135, 28, 58, 24, 41, 0, 10), /* Vertical Closed three fourth */ + Frame(88, 93, 28, 67, 24, 41, 18, 0), /* Left Horizontal Closed one fourth */ + Frame(88, 99, 28, 67, 24, 41, 12, 0), /* Left Horizontal Closed half */ + Frame(88, 105, 28, 67, 24, 41, 6, 0), /* Left Horizontal Closed three fourth */ + Frame(130, 135, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed one fourth */ + Frame(124, 135, 28, 67, 24, 41, 24, 0), /* Right Horizontal Closed half */ + Frame(118, 135, 28, 67, 24, 41, 24, 0) /* Right Horizontal Closed three fourth */ ); int16 order; int16 squareAspect[5]; @@ -1667,16 +1676,16 @@ T0118028: void DisplayMan::f119_drawSquareD2L(direction dir, int16 posX, int16 posY) { static DoorFrames g182_doorFrame_D2L = DoorFrames( // @ G0182_s_Graphic558_Frames_Door_D2L /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(0, 63, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ - Frame(0, 63, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ - Frame(0, 63, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ - Frame(0, 63, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ - Frame(0, 7, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ - Frame(0, 15, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ - Frame(0, 23, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ - Frame(56, 63, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ - Frame(48, 63, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ - Frame(40, 63, 24, 82, 32, 61, 32, 0) /* Right Horizontal Closed three fourth */ + Frame(0, 63, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ + Frame(0, 63, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ + Frame(0, 63, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ + Frame(0, 63, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ + Frame(0, 7, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ + Frame(0, 15, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ + Frame(0, 23, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ + Frame(56, 63, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ + Frame(48, 63, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ + Frame(40, 63, 24, 82, 32, 61, 32, 0) /* Right Horizontal Closed three fourth */ ); int16 order; @@ -1733,16 +1742,16 @@ T0119020: void DisplayMan::f120_drawSquareD2R(direction dir, int16 posX, int16 posY) { static DoorFrames g184_doorFrame_D2R = DoorFrames( // @ G0184_s_Graphic558_Frames_Door_D2R /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(160, 223, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ - Frame(160, 223, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ - Frame(160, 223, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ - Frame(160, 223, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ - Frame(160, 167, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ - Frame(160, 175, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ - Frame(160, 183, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ - Frame(216, 223, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ - Frame(208, 223, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ - Frame(200, 223, 24, 82, 32, 61, 32, 0) /* Right Horizontal Closed three fourth */ + Frame(160, 223, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ + Frame(160, 223, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ + Frame(160, 223, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ + Frame(160, 223, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ + Frame(160, 167, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ + Frame(160, 175, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ + Frame(160, 183, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ + Frame(216, 223, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ + Frame(208, 223, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ + Frame(200, 223, 24, 82, 32, 61, 32, 0) /* Right Horizontal Closed three fourth */ ); int16 order; @@ -1801,16 +1810,16 @@ T0120029: void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) { static DoorFrames g183_doorFrame_D2C = DoorFrames( // @ G0183_s_Graphic558_Frames_Door_D2C /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(80, 143, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ - Frame(80, 143, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ - Frame(80, 143, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ - Frame(80, 143, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ - Frame(80, 87, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ - Frame(80, 95, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ - Frame(80, 103, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ - Frame(136, 143, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ - Frame(128, 143, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ - Frame(120, 143, 24, 82, 32, 61, 32, 0) /* Right Horizontal Closed three fourth */ + Frame(80, 143, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ + Frame(80, 143, 24, 39, 32, 61, 0, 45), /* Vertical Closed one fourth */ + Frame(80, 143, 24, 54, 32, 61, 0, 30), /* Vertical Closed half */ + Frame(80, 143, 24, 69, 32, 61, 0, 15), /* Vertical Closed three fourth */ + Frame(80, 87, 24, 82, 32, 61, 24, 0), /* Left Horizontal Closed one fourth */ + Frame(80, 95, 24, 82, 32, 61, 16, 0), /* Left Horizontal Closed half */ + Frame(80, 103, 24, 82, 32, 61, 8, 0), /* Left Horizontal Closed three fourth */ + Frame(136, 143, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed one fourth */ + Frame(128, 143, 24, 82, 32, 61, 32, 0), /* Right Horizontal Closed half */ + Frame(120, 143, 24, 82, 32, 61, 32, 0) /* Right Horizontal Closed three fourth */ ); int16 order; @@ -1867,16 +1876,16 @@ T0121016: void DisplayMan::f122_drawSquareD1L(direction dir, int16 posX, int16 posY) { static DoorFrames g185_doorFrame_D1L = DoorFrames( // @ G0185_s_Graphic558_Frames_Door_D1L /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(0, 31, 17, 102, 48, 88, 64, 0), /* Closed Or Destroyed */ - Frame(0, 31, 17, 38, 48, 88, 64, 66), /* Vertical Closed one fourth */ - Frame(0, 31, 17, 60, 48, 88, 64, 44), /* Vertical Closed half */ - Frame(0, 31, 17, 82, 48, 88, 64, 22), /* Vertical Closed three fourth */ - Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed one fourth */ - Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed half */ - Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed three fourth */ - Frame(20, 31, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */ - Frame(8, 31, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */ - Frame(0, 31, 17, 102, 48, 88, 52, 0) /* Right Horizontal Closed three fourth */ + Frame(0, 31, 17, 102, 48, 88, 64, 0), /* Closed Or Destroyed */ + Frame(0, 31, 17, 38, 48, 88, 64, 66), /* Vertical Closed one fourth */ + Frame(0, 31, 17, 60, 48, 88, 64, 44), /* Vertical Closed half */ + Frame(0, 31, 17, 82, 48, 88, 64, 22), /* Vertical Closed three fourth */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed one fourth */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed half */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Left Horizontal Closed three fourth */ + Frame(20, 31, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */ + Frame(8, 31, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */ + Frame(0, 31, 17, 102, 48, 88, 52, 0) /* Right Horizontal Closed three fourth */ ); int16 order; @@ -1934,16 +1943,16 @@ T0122021: void DisplayMan::f123_drawSquareD1R(direction dir, int16 posX, int16 posY) { static DoorFrames g187_doorFrame_D1R = DoorFrames( // @ G0187_s_Graphic558_Frames_Door_D1R /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(192, 223, 17, 102, 48, 88, 0, 0), /* Closed Or Destroyed */ - Frame(192, 223, 17, 38, 48, 88, 0, 66), /* Vertical Closed one fourth */ - Frame(192, 223, 17, 60, 48, 88, 0, 44), /* Vertical Closed half */ - Frame(192, 223, 17, 82, 48, 88, 0, 22), /* Vertical Closed three fourth */ - Frame(192, 203, 17, 102, 48, 88, 36, 0), /* Left Horizontal Closed one fourth */ - Frame(192, 215, 17, 102, 48, 88, 24, 0), /* Left Horizontal Closed half */ - Frame(192, 223, 17, 102, 48, 88, 12, 0), /* Left Horizontal Closed three fourth */ - Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Right Horizontal Closed one fourth */ - Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Right Horizontal Closed half */ - Frame(0, 0, 0, 0, 0, 0, 0, 0) + Frame(192, 223, 17, 102, 48, 88, 0, 0), /* Closed Or Destroyed */ + Frame(192, 223, 17, 38, 48, 88, 0, 66), /* Vertical Closed one fourth */ + Frame(192, 223, 17, 60, 48, 88, 0, 44), /* Vertical Closed half */ + Frame(192, 223, 17, 82, 48, 88, 0, 22), /* Vertical Closed three fourth */ + Frame(192, 203, 17, 102, 48, 88, 36, 0), /* Left Horizontal Closed one fourth */ + Frame(192, 215, 17, 102, 48, 88, 24, 0), /* Left Horizontal Closed half */ + Frame(192, 223, 17, 102, 48, 88, 12, 0), /* Left Horizontal Closed three fourth */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Right Horizontal Closed one fourth */ + Frame(0, 0, 0, 0, 0, 0, 0, 0), /* Right Horizontal Closed half */ + Frame(0, 0, 0, 0, 0, 0, 0, 0) ); /* Right Horizontal Closed three fourth */ int16 order; @@ -2023,7 +2032,7 @@ void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) { g107_BoxThievesEyeVisibleArea, g106_BoxThievesEye_ViewPortVisibleArea._x1, g106_BoxThievesEye_ViewPortVisibleArea._y1, - k112_byteWidthViewport, 48, k255_ColorNoTransparency, 136, 95); + k112_byteWidthViewport, 48, kM1_ColorNoTransparency, 136, 95); bitmap = f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice); /* BUG0_74 Creatures are drawn with wrong colors when viewed through a wall with the 'Thieve's Eye' spell. The 'hole in wall' graphic is applied to the visible area with transparency on color 10. However the visible area may contain creature graphics @@ -2330,12 +2339,12 @@ void DisplayMan::f96_loadCurrentMapGraphics() { f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap, g163_FrameWalls[k0_ViewSquare_D3C]._srcByteWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight); f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 64, 51); - f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, g161_BoxWallBitmap_D3LCR, 11, 0, 64, 64, k255_ColorNoTransparency); + f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, g161_BoxWallBitmap_D3LCR, 11, 0, 64, 64, kM1_ColorNoTransparency); f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap, g163_FrameWalls[k3_ViewSquare_D2C]._srcByteWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight); f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 72, 71); - f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, g162_BoxWallBitmap_D2LCR, 8, 0, 72, 72, k255_ColorNoTransparency); + f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, g162_BoxWallBitmap_D2LCR, 8, 0, 72, 72, kM1_ColorNoTransparency); f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped, g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight); @@ -2538,7 +2547,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, g202_BoxWallPatchBehindInscription, 94, 28, g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, - k112_byteWidthViewport, k255_ColorNoTransparency, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport); + k112_byteWidthViewport, kM1_ColorNoTransparency, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport); byte *AL0090_puc_String = L0099_auc_InscriptionString; L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont); L0097_i_TextLineIndex = 0; diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 2fc01fbc45..2ca77b99d1 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -339,7 +339,7 @@ enum ViewWall { }; enum Color { - k255_ColorNoTransparency = 255, + kM1_ColorNoTransparency = -1, k0_ColorBlack = 0, k1_ColorDarkGary = 1, k2_ColorLightGray = 2, @@ -644,7 +644,8 @@ public: void f109_drawDoorOrnament(int16 doorOrnOdinal, int16 viewDoorOrnIndex); // @ F0109_DUNGEONVIEW_DrawDoorOrnament void f112_drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int16 mapX, int16 mapY, bool flipHorizontal); // @ F0112_DUNGEONVIEW_DrawCeilingPit - + void f20_blitToViewport(byte *bitmap, Box &box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport + void f20_blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport void f21_blitToScreen(byte* bitmap, int16 *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen void f21_blitToScreen(byte* bitmap, Box *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen @@ -654,7 +655,7 @@ public: match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/ /* Expects inclusive boundaries in box */ void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth, - uint16 destByteWidth, Color transparent = k255_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit + uint16 destByteWidth, Color transparent = kM1_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit /* Expects inclusive boundaries in box */ void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destByteWidth, Color transparent, diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 35bdf21ebb..30bb05c73b 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -130,7 +130,7 @@ void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) { box._y2 = 28; box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7; box._x2 = box._x1 + 31; - dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, dispMan._g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, dispMan._g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen, kM1_ColorNoTransparency); } void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) { @@ -337,7 +337,7 @@ void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int box._x2 = (box._x1 = xPos) + 15; box._y2 = (box._y1 = yPos) + 15; _vm->_objectMan->f36_extractIconFromBitmap(iconIndex, iconBitmap); - _vm->_displayMan->f132_blitToBitmap(iconBitmap, _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 8, k112_byteWidthViewport, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(iconBitmap, _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 8, k112_byteWidthViewport, kM1_ColorNoTransparency); } void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) { @@ -682,4 +682,64 @@ void InventoryMan::f338_decreaseTorchesLightPower() { _vm->_championMan->f296_drawChangedObjectIcons(); } } + +void InventoryMan::f351_drawChampionSkillsAndStatistics() { + uint16 L1090_ui_Multiple; +#define AL1090_ui_SkillIndex L1090_ui_Multiple +#define AL1090_ui_StatisticIndex L1090_ui_Multiple + int16 L1091_i_Y; + int16 L1092_i_Multiple; +#define AL1092_i_SkillLevel L1092_i_Multiple +#define AL1092_i_StatisticCurrentValue L1092_i_Multiple + uint16 L1093_ui_ChampionIndex; + Champion* L1094_ps_Champion; + int16 L1095_i_StatisticColor; + uint16 L1096_ui_StatisticMaximumValue; + char L1097_ac_String[20]; + // TODO: localization + static char* G0431_apc_StatisticNames[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"}; + + + _vm->_inventoryMan->f334_closeChest(); + L1094_ps_Champion = &_vm->_championMan->_gK71_champions[L1093_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal)]; + _vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), g32_BoxPanel, k72_byteWidth, k8_ColorRed, 73); + L1091_i_Y = 58; + for (AL1090_ui_SkillIndex = k0_ChampionSkillFighter; AL1090_ui_SkillIndex <= k3_ChampionSkillWizard; AL1090_ui_SkillIndex++) { + AL1092_i_SkillLevel = MIN((uint16)16, _vm->_championMan->f303_getSkillLevel(L1093_ui_ChampionIndex, AL1090_ui_SkillIndex | k0x8000_IgnoreTemporaryExperience)); + if (AL1092_i_SkillLevel == 1) + continue; +#ifdef COMPILE17_DM10aEN_DM10bEN_DM11EN_DM12EN_CSB20EN_CSB21EN_DMDEMO20EN_DM20EN_DM21EN_DM22EN /* CHANGE4_00_LOCALIZATION Translation to German language */ + strcpy(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]); + strcat(L1097_ac_String, " "); + strcat(L1097_ac_String, G0417_apc_BaseSkillNames[AL1090_ui_SkillIndex]); +#endif +#ifdef COMPILE36_DM12GE_DM13aFR_DM13bFR_DM20GE_DM20FR_DM22GE /* CHANGE4_00_LOCALIZATION Translation to German language */ + strcpy(L1097_ac_String, G0417_apc_BaseSkillNames[AL1090_ui_SkillIndex]); + strcat(L1097_ac_String, " "); + strcat(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]); +#endif + _vm->_textMan->f52_printToViewport(108, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String); + L1091_i_Y += 7; + } + L1091_i_Y = 86; + for (AL1090_ui_StatisticIndex = k1_ChampionStatStrength; AL1090_ui_StatisticIndex <= k6_ChampionStatAntifire; AL1090_ui_StatisticIndex++) { + _vm->_textMan->f52_printToViewport(108, L1091_i_Y, k13_ColorLightestGray, G0431_apc_StatisticNames[AL1090_ui_StatisticIndex]); + AL1092_i_StatisticCurrentValue = L1094_ps_Champion->_statistics[AL1090_ui_StatisticIndex][k1_ChampionStatCurrent]; + L1096_ui_StatisticMaximumValue = L1094_ps_Champion->_statistics[AL1090_ui_StatisticIndex][k0_ChampionStatMaximum]; + if (AL1092_i_StatisticCurrentValue < L1096_ui_StatisticMaximumValue) { + L1095_i_StatisticColor = k8_ColorRed; + } else { + if (AL1092_i_StatisticCurrentValue > L1096_ui_StatisticMaximumValue) { + L1095_i_StatisticColor = k7_ColorLightGreen; + } else { + L1095_i_StatisticColor = k13_ColorLightestGray; + } + } + _vm->_textMan->f52_printToViewport(174, L1091_i_Y, (Color)L1095_i_StatisticColor, _vm->_championMan->f288_getStringFromInteger(AL1092_i_StatisticCurrentValue, true, 3).c_str()); + strcpy(L1097_ac_String, "/"); + strcat(L1097_ac_String, _vm->_championMan->f288_getStringFromInteger(L1096_ui_StatisticMaximumValue, true, 3).c_str()); + _vm->_textMan->f52_printToViewport(192, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String); + L1091_i_Y += 7; + } +} } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 35a76c4e9f..93bb17fbe6 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -80,6 +80,7 @@ public: void f342_drawPanelObject(Thing thingToDraw, bool pressingEye); // @ F0342_INVENTORY_DrawPanel_Object void f337_setDungeonViewPalette(); // @ F0337_INVENTORY_SetDungeonViewPalette void f338_decreaseTorchesLightPower(); // @ F0338_INVENTORY_DecreaseTorchesLightPower_CPSE + void f351_drawChampionSkillsAndStatistics(); // @ F0351_INVENTORY_DrawChampionSkillsAndStatistics }; diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index f42d955b3d..1338130459 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -66,7 +66,7 @@ void MenuMan::f395_drawMovementArrows() { Box &dest = g2_BoxMovementArrows; uint16 byteWidth = disp.getPixelWidth(k13_MovementArrowsIndice) / 2; - disp.f132_blitToBitmap(arrowsBitmap, disp._g348_bitmapScreen, dest, 0, 0, byteWidth, k160_byteWidthScreen, k255_ColorNoTransparency); + disp.f132_blitToBitmap(arrowsBitmap, disp._g348_bitmapScreen, dest, 0, 0, byteWidth, k160_byteWidthScreen, kM1_ColorNoTransparency); } void MenuMan::f388_clearActingChampion() { ChampionMan &cm = *_vm->_championMan; @@ -115,7 +115,7 @@ T0386006: box2._x2 = box._x2 - 2; box2._y1 = 95; box2._y2 = 110; - dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 8, k160_byteWidthScreen, k255_ColorNoTransparency); + dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 8, k160_byteWidthScreen, kM1_ColorNoTransparency); if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } @@ -211,7 +211,7 @@ void MenuMan::f387_drawActionArea() { if (_g713_actionList._actionIndices[1] == k255_ChampionActionNone) box = g501_BoxActionArea1ActionMenu; dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k10_MenuActionAreaIndice), dispMan._g348_bitmapScreen, - box, 0, 0, 48, k160_byteWidthScreen, k255_ColorNoTransparency); + box, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency); textMan.f41_printWithTrailingSpaces(dispMan._g348_bitmapScreen, k160_byteWidthScreen, 235, 83, k0_ColorBlack, k4_ColorCyan, champMan._gK71_champions[_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)]._name, k7_ChampionNameMaximumLength, k200_heightScreen); @@ -320,7 +320,7 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) { if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) { dispMan._g578_useByteBoxCoordinates = false; dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine, - gK74_BoxSpellAreaLine, 0, 12, 48, 48, k255_ColorNoTransparency); + gK74_BoxSpellAreaLine, 0, 12, 48, 48, kM1_ColorNoTransparency); int16 x = 1; byte c = 96 + (6 * champ._symbolStep); char spellSymbolString[2] = {'\0', '\0'}; @@ -331,7 +331,7 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) { } else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) { dispMan._g578_useByteBoxCoordinates = false; dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k11_MenuSpellAreLinesIndice), _gK72_bitmapSpellAreaLine, - gK74_BoxSpellAreaLine, 0, 24, 48, 48, k255_ColorNoTransparency); + gK74_BoxSpellAreaLine, 0, 24, 48, 48, kM1_ColorNoTransparency); char spellSymbolString[2] = {'\0', '\0'}; int16 x = 8; for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) { @@ -352,7 +352,7 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) { if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) { warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), dispMan._g348_bitmapScreen, g0_BoxSpellArea, 0, 0, - 48, k160_byteWidthScreen, k255_ColorNoTransparency); + 48, k160_byteWidthScreen, kM1_ColorNoTransparency); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } if (champIndex == kM1_ChampionNone) { @@ -368,9 +368,9 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) { f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols); warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); f393_drawSpellAreaControls((ChampionIndex)champIndex); - dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK75_BoxSpellAreaLine2, 0, 0, 48, k160_byteWidthScreen, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK75_BoxSpellAreaLine2, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency); f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols); - dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 48, k160_byteWidthScreen, k255_ColorNoTransparency); + dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency); warning("MISSING CODE: F0078_MOUSE_ShowPointer"); } diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 976e671730..6ab49fbf44 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -199,7 +199,7 @@ void ObjectMan::f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { iconIndex -= g26_IconGraphicFirstIndex[i]; _vm->_displayMan->_g578_useByteBoxCoordinates = true; Box box(0, 0, 15, 15); - _vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency); } void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { @@ -227,10 +227,10 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { _vm->_displayMan->_g578_useByteBoxCoordinates = false; if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) { - _vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g296_bitmapViewport, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k112_byteWidthViewport, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g296_bitmapViewport, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k112_byteWidthViewport, kM1_ColorNoTransparency); } else { - _vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g348_bitmapScreen, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k160_byteWidthScreen, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g348_bitmapScreen, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k160_byteWidthScreen, kM1_ColorNoTransparency); } } diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index 06a10b2784..4329cb3083 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -73,7 +73,7 @@ void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, uint uint16 srcX = (1 + 5) * toupper(*begin); // 1 + 5 is not the letter width, arbitrary choice of the unpacking code Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1); - _vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128 / 2, destByteWidth, k255_ColorNoTransparency); + _vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (nextX == destX) ? (srcX + 1) : srcX, 0, 6 * 128 / 2, destByteWidth, kM1_ColorNoTransparency); nextX += k5_LetterWidth + 1; } -- cgit v1.2.3 From 92a3ccb4a7d1eafb16ae5f469c271f277d1261a3 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 7 Jul 2016 21:04:55 +0200 Subject: DM: Replace InventoryMan::f355_toggleInventory with original --- engines/dm/inventory.cpp | 85 +++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 30bb05c73b..b72be8a7f8 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -53,71 +53,68 @@ InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) { } void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) { - ChampionMan &cm = *_vm->_championMan; - EventManager &em = *_vm->_eventMan; - DisplayMan &dm = *_vm->_displayMan; + uint16 L1102_ui_Multiple; +#define AL1102_ui_InventoryChampionOrdinal L1102_ui_Multiple +#define AL1102_ui_SlotIndex L1102_ui_Multiple + Champion* L1103_ps_Champion; + - if ((championIndex != k4_ChampionCloseInventory) && !cm._gK71_champions[championIndex]._currHealth) + if ((championIndex != k4_ChampionCloseInventory) && !_vm->_championMan->_gK71_champions[championIndex]._currHealth) { return; - if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) + } + if (_vm->_g333_pressingMouth || _vm->_g331_pressingEye) { return; + } _vm->_g321_stopWaitingForPlayerInput = true; - int16 invChampOrdinal = _g432_inventoryChampionOrdinal; // copy, as the original will be edited - if (_vm->M0_indexToOrdinal(championIndex) == invChampOrdinal) { + AL1102_ui_InventoryChampionOrdinal = _vm->_inventoryMan->_g432_inventoryChampionOrdinal; + if (_vm->M0_indexToOrdinal(championIndex) == AL1102_ui_InventoryChampionOrdinal) { championIndex = k4_ChampionCloseInventory; } - - Champion *champion; - if (invChampOrdinal) { - _g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone); - f334_closeChest(); - champion = &cm._gK71_champions[_vm->M1_ordinalToIndex(invChampOrdinal)]; - if (champion->_currHealth && !cm._g299_candidateChampionOrdinal) { - champion->setAttributeFlag(k0x1000_ChampionAttributeStatusBox, true); - cm.f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal)); + _vm->_eventMan->f78_showMouse(); + if (AL1102_ui_InventoryChampionOrdinal) { + _vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone); + _vm->_inventoryMan->f334_closeChest(); + L1103_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(AL1102_ui_InventoryChampionOrdinal)]; + if (L1103_ps_Champion->_currHealth && !_vm->_championMan->_g299_candidateChampionOrdinal) { + setFlag(L1103_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox); + _vm->_championMan->f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(AL1102_ui_InventoryChampionOrdinal)); } - if (cm._g300_partyIsSleeping) { + if (_vm->_championMan->_g300_partyIsSleeping) { + _vm->_eventMan->f77_hideMouse(); return; } if (championIndex == k4_ChampionCloseInventory) { - em._g326_refreshMousePointerInMainLoop = true; + _vm->_eventMan->_g326_refreshMousePointerInMainLoop = true; _vm->_menuMan->f395_drawMovementArrows(); - em._g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement; - warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput"); + _vm->_eventMan->f77_hideMouse(); + _vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement; + warning("MISSING CODE: setting G0444_ps_SecondaryKeyboardInput"); _vm->_eventMan->f357_discardAllInput(); + _vm->_displayMan->f98_drawFloorAndCeiling(); return; } } - - dm._g578_useByteBoxCoordinates = false; - _g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(championIndex); - if (!invChampOrdinal) { + _vm->_displayMan->_g578_useByteBoxCoordinates = false; + _vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(championIndex); + if (!AL1102_ui_InventoryChampionOrdinal) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } - - champion = &cm._gK71_champions[championIndex]; - dm.f466_loadIntoBitmap(k17_InventoryGraphicIndice, dm._g296_bitmapViewport); - if (cm._g299_candidateChampionOrdinal) { - dm.f135_fillBoxBitmap(dm._g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport); + L1103_ps_Champion = &_vm->_championMan->_gK71_champions[championIndex]; + _vm->_displayMan->f466_loadIntoBitmap(k17_InventoryGraphicIndice, _vm->_displayMan->_g296_bitmapViewport); + if (_vm->_championMan->_g299_candidateChampionOrdinal) { + _vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport); } _vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "HEALTH"); _vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "STAMINA"); _vm->_textMan->f52_printToViewport(5, 132, k13_ColorLightestGray, "MANA"); - - for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) { - _vm->_championMan->f291_drawSlot(championIndex, (ChampionSlot)slotIndex); - } - - champion->setAttributeFlag(k0x4000_ChampionAttributeViewport, true); - champion->setAttributeFlag(k0x1000_ChampionAttributeStatusBox, true); - champion->setAttributeFlag(k0x0800_ChampionAttributePanel, true); - champion->setAttributeFlag(k0x0200_ChampionAttributeLoad, true); - champion->setAttributeFlag(k0x0100_ChampionAttributeStatistics, true); - champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true); - - cm.f292_drawChampionState(championIndex); - em._g598_mousePointerBitmapUpdated = true; - em._g442_secondaryMouseInput = g449_SecondaryMouseInput_ChampionInventory; + for (AL1102_ui_SlotIndex = k0_ChampionSlotReadyHand; AL1102_ui_SlotIndex < k30_ChampionSlotChest_1; AL1102_ui_SlotIndex++) { + _vm->_championMan->f291_drawSlot(championIndex, AL1102_ui_SlotIndex); + } + setFlag(L1103_ps_Champion->_attributes, k0x4000_ChampionAttributeViewport | k0x1000_ChampionAttributeStatusBox | k0x0800_ChampionAttributePanel | k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics | k0x0080_ChampionAttributeNameTitle); + _vm->_championMan->f292_drawChampionState(championIndex); + _vm->_eventMan->_g598_mousePointerBitmapUpdated = true; + _vm->_eventMan->f77_hideMouse(); + _vm->_eventMan->_g442_secondaryMouseInput = g449_SecondaryMouseInput_ChampionInventory; warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput"); _vm->_eventMan->f357_discardAllInput(); } -- cgit v1.2.3 From 89473344d872962dc4ac2c828f6a1c7dfc17867d Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:50:13 +0200 Subject: DM: Fix several bugs realted to dungeon thing management and item handling --- engines/dm/TODOs/todo.txt | 14 +- engines/dm/champion.cpp | 338 +++++++++++++-------------- engines/dm/champion.h | 2 +- engines/dm/dm.cpp | 45 ++-- engines/dm/dm.h | 2 +- engines/dm/dungeonman.cpp | 565 +++++++++++++++++++++++++++++++++++++--------- engines/dm/dungeonman.h | 10 +- engines/dm/eventman.cpp | 35 +-- engines/dm/objectman.cpp | 152 +++++++------ 9 files changed, 767 insertions(+), 396 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 183889e994..1d08b44ca4 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -2,12 +2,11 @@ Bugs: Display: Broken colour palette Portraits, alcoves etc. look broken from afar - Ornaments are not displayed if looked at from certain angles - Ornaments are displayed where they should not be, probably error in the pseudo RNG - Command gui is broken + Arrow and hand display is messed up + Logic: - Game crashes when reincaranting a fourth champion and trying to copy his portrait -e + When object are put on the right side of the current square, they disappear + Todo: @@ -20,9 +19,4 @@ Todo: Double check strcat, strstr usages, I might have messed them up in many places I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions - Missing functions: - Add missing F0163_DUNGEON_LinkThingToList in MovesensMan::sensorIsTriggeredByClickOnWall (I don't think it's safe yet) - -Refactoring - Add constructor to CreatureInfo diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 96604e3140..90dbbf92dd 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1106,26 +1106,26 @@ void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount Scent L0958_s_Scent; /* BUG0_00 Useless code */ - if (L0954_i_ScentIndex = _vm->_championMan->_g407_party._scentCount) { + if (L0954_i_ScentIndex = _g407_party._scentCount) { if (L0955_B_Merge = getFlag(cycleCount, k0x8000_mergeCycles)) { clearFlag(cycleCount, k0x8000_mergeCycles); } L0958_s_Scent.setMapX(mapX); /* BUG0_00 Useless code */ L0958_s_Scent.setMapY(mapY); /* BUG0_00 Useless code */ L0958_s_Scent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */ - L0957_ps_Scent = _vm->_championMan->_g407_party._scents; /* BUG0_00 Useless code */ + L0957_ps_Scent = _g407_party._scents; /* BUG0_00 Useless code */ L0956_B_CycleCountDefined = false; while (L0954_i_ScentIndex--) { if (&*L0957_ps_Scent++ == &L0958_s_Scent) { if (!L0956_B_CycleCountDefined) { L0956_B_CycleCountDefined = true; if (L0955_B_Merge) { - cycleCount = MAX((int32)_vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount); + cycleCount = MAX((int32)_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount); } else { - cycleCount = MIN(80, _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount); + cycleCount = MIN(80, _g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount); } } - _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount; + _g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount; } } } @@ -1135,8 +1135,10 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) if (thing == Thing::_none) { return; } - _vm->_championMan->_g415_leaderEmptyHanded = false; - _vm->_objectMan->f36_extractIconFromBitmap(_vm->_championMan->_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_vm->_championMan->_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer); + _g415_leaderEmptyHanded = false; + _vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer); + + _vm->_eventMan->f78_showMouse(); _vm->_objectMan->f34_drawLeaderObjectName(thing); if (setMousePointer) { @@ -1145,10 +1147,10 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) _vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer); } _vm->_eventMan->f77_hideMouse(); - if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) { - _vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing); - setFlag(_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad); - _vm->_championMan->f292_drawChampionState(_vm->_championMan->_g411_leaderIndex); + if (_g411_leaderIndex != kM1_ChampionNone) { + _gK71_champions[_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing); + setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad); + f292_drawChampionState(_g411_leaderIndex); } } @@ -1174,180 +1176,180 @@ void ChampionMan::f278_resetDataToStartGame() { void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) { - DisplayMan &dispMan = *_vm->_displayMan; - DungeonMan &dunMan = *_vm->_dungeonMan; - - if (!_g415_leaderEmptyHanded || _g305_partyChampionCount == 4) + Thing L0793_T_Thing; + uint16 L0794_ui_Multiple; +#define AL0794_ui_ViewCell L0794_ui_Multiple +#define AL0794_ui_SlotIndex L0794_ui_Multiple +#define AL0794_ui_CharacterIndex L0794_ui_Multiple +#define AL0794_ui_StatisticIndex L0794_ui_Multiple +#define AL0794_ui_SkillIndex L0794_ui_Multiple + int16 L0795_i_HiddenSkillIndex; + uint16 L0796_ui_Multiple; +#define AL0796_ui_Character L0796_ui_Multiple +#define AL0796_ui_SkillValue L0796_ui_Multiple +#define AL0796_ui_ThingType L0796_ui_Multiple + Champion* L0797_ps_Champion; + char* L0798_pc_Character; + uint16 L0799_ui_PreviousPartyChampionCount; + uint16 L0800_ui_Multiple; +#define AL0800_B_ChampionTitleCopied L0800_ui_Multiple +#define AL0800_ui_HiddenSkillCounter L0800_ui_Multiple + uint16 L0801_ui_SlotIndex; + int16 L0802_i_MapX; + int16 L0803_i_MapY; + uint16 L0804_ui_ChampionObjectsCell; + int16 L0805_i_ObjectAllowedSlots; + int32 L0806_l_BaseSkillExperience; + char L0807_ac_DecodedChampionText[77]; + + if (!_vm->_championMan->_g415_leaderEmptyHanded) { return; - - uint16 prevChampCount = _g305_partyChampionCount; - Champion *champ = &_gK71_champions[prevChampCount]; - champ->resetToZero(); - dispMan._g578_useByteBoxCoordinates = true; - { // limit destBox scope - Box &destBox = gBoxChampionPortrait; - dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), champ->_portrait, - destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 128, 16, kM1_ColorNoTransparency); - } - - champ->_actionIndex = k255_ChampionActionNone; - champ->_enableActionEventIndex = -1; - champ->_hideDamageReceivedIndex = -1; - champ->_dir = dunMan._g308_partyDir; - ViewCell AL_0_viewCell = k0_ViewCellFronLeft; - while (f285_getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3)) != kM1_ChampionNone) - AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); - champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3); - champ->clearAttributes(k0x0400_ChampionAttributeIcon); - champ->_directionMaximumDamageReceived = dunMan._g308_partyDir; - champ->_food = 1500 + _vm->_rnd->getRandomNumber(256); - champ->_water = 1500 + _vm->_rnd->getRandomNumber(256); - int16 AL_0_slotIndex_Red; - for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) { - champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none); - } - Thing thing = dunMan.f161_getSquareFirstThing(dunMan._g306_partyMapX, dunMan._g307_partyMapY); - while (thing.getType() != k2_TextstringType) { - thing = dunMan.f159_getNextThing(thing); - } - char decodedChampionText[77]; - char* character_Green = decodedChampionText; - dunMan.f168_decodeText(character_Green, thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible)); - int16 AL_0_characterIndex = 0; - uint16 AL_2_character; - while ((AL_2_character = *character_Green++) != '\n') { - champ->_name[AL_0_characterIndex++] = AL_2_character; - } - champ->_name[AL_0_characterIndex] = '\0'; - AL_0_characterIndex = 0; - bool AL_4_champTitleCopied = false; - for (;;) { // infinite - AL_2_character = *character_Green++; - if (AL_2_character == '\n') { - if (AL_4_champTitleCopied) - break; - AL_4_champTitleCopied = true; - } else { - champ->_title[AL_0_characterIndex++] = AL_2_character; - } - } - champ->_title[AL_0_characterIndex] = '\0'; - if (*character_Green++ == 'M') { - champ->setAttributeFlag(k0x0010_ChampionAttributeMale, true); - } - character_Green++; - champ->_currHealth = champ->_maxHealth = f279_getDecodedValue(character_Green, 4); - character_Green += 4; - champ->_currStamina = champ->_maxStamina = f279_getDecodedValue(character_Green, 4); - character_Green += 4; - champ->_currMana = champ->_maxMana = f279_getDecodedValue(character_Green, 4); - character_Green += 4; - character_Green++; - - int16 AL_0_statisticIndex; - for (AL_0_statisticIndex = k0_ChampionStatLuck; AL_0_statisticIndex <= k6_ChampionStatAntifire; ++AL_0_statisticIndex) { - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k2_ChampionStatMinimum, 30); - uint16 currMaxVal = f279_getDecodedValue(character_Green, 2); - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent, currMaxVal); - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum, currMaxVal); - character_Green += 2; - } - - champ->setStatistic(k0_ChampionStatLuck, k2_ChampionStatMinimum, 10); - character_Green++; - - int16 AL_0_skillIndex; - int16 AL_2_skillValue; - for (AL_0_skillIndex = k4_ChampionSkillSwing; AL_0_skillIndex <= k19_ChampionSkillWater; AL_0_skillIndex++) { - if ((AL_2_skillValue = *character_Green++ - 'A') > 0) { - champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue); - } } - - for (AL_0_skillIndex = k0_ChampionSkillFighter; AL_0_skillIndex <= k3_ChampionSkillWizard; ++AL_0_skillIndex) { - int32 baseSkillExp = 0; - int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2; - for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) { - baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience; - } - champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp); + if (_vm->_championMan->_g305_partyChampionCount == 4) { + return; } - - _g299_candidateChampionOrdinal = prevChampCount + 1; - if (++_g305_partyChampionCount == 1) { + L0797_ps_Champion = &_vm->_championMan->_gK71_champions[L0799_ui_PreviousPartyChampionCount = _vm->_championMan->_g305_partyChampionCount]; + L0797_ps_Champion->resetToZero(); + // Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portaits could be missing in the data) + _vm->_displayMan->_g578_useByteBoxCoordinates = true; + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), L0797_ps_Champion->_portrait, gBoxChampionPortrait, _vm->_championMan->M27_getChampionPortraitX(championPortraitIndex), _vm->_championMan->M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency); + L0797_ps_Champion->_actionIndex = k255_ChampionActionNone; + L0797_ps_Champion->_enableActionEventIndex = -1; + L0797_ps_Champion->_hideDamageReceivedIndex = -1; + L0797_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir; + AL0794_ui_ViewCell = k0_ViewCellFronLeft; + while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone) { + AL0794_ui_ViewCell++; + } + L0797_ps_Champion->_cell = (ViewCell)M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir); + L0797_ps_Champion->_attributes = k0x0400_ChampionAttributeIcon; + L0797_ps_Champion->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir; + L0797_ps_Champion->_food = 1500 + _vm->getRandomNumber(256); + L0797_ps_Champion->_water = 1500 + _vm->getRandomNumber(256); + for (AL0794_ui_SlotIndex = k0_ChampionSlotReadyHand; AL0794_ui_SlotIndex < k30_ChampionSlotChest_1; AL0794_ui_SlotIndex++) { + L0797_ps_Champion->_slots[AL0794_ui_SlotIndex] = Thing::_none; + } + L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); + while ((L0793_T_Thing.getType()) != k2_TextstringType) { + L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing); + } + _vm->_dungeonMan->f168_decodeText(L0798_pc_Character = L0807_ac_DecodedChampionText, L0793_T_Thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible)); + AL0794_ui_CharacterIndex = 0; + while ((AL0796_ui_Character = *L0798_pc_Character++) != '\n') { /* New line */ + L0797_ps_Champion->_name[AL0794_ui_CharacterIndex++] = AL0796_ui_Character; + } + L0797_ps_Champion->_name[AL0794_ui_CharacterIndex] = '\0'; + AL0794_ui_CharacterIndex = 0; + AL0800_B_ChampionTitleCopied = false; + for (;;) { /*_Infinite loop_*/ + AL0796_ui_Character = *L0798_pc_Character++; + if (AL0796_ui_Character == '\n') { /* New line */ + if (AL0800_B_ChampionTitleCopied) + break; + AL0800_B_ChampionTitleCopied = true; + } else { + L0797_ps_Champion->_title[AL0794_ui_CharacterIndex++] = AL0796_ui_Character; + } + } + L0797_ps_Champion->_title[AL0794_ui_CharacterIndex] = '\0'; + if (*L0798_pc_Character++ == 'M') { + setFlag(L0797_ps_Champion->_attributes, k0x0010_ChampionAttributeMale); + } + L0798_pc_Character++; + L0797_ps_Champion->_currHealth = L0797_ps_Champion->_maxHealth = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4); + L0798_pc_Character += 4; + L0797_ps_Champion->_currStamina = L0797_ps_Champion->_maxStamina = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4); + L0798_pc_Character += 4; + L0797_ps_Champion->_currMana = L0797_ps_Champion->_maxMana = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4); + L0798_pc_Character += 4; + L0798_pc_Character++; + for (AL0794_ui_StatisticIndex = k0_ChampionStatLuck; AL0794_ui_StatisticIndex <= k6_ChampionStatAntifire; AL0794_ui_StatisticIndex++) { + L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k2_ChampionStatMinimum] = 30; + L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k1_ChampionStatCurrent] = L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k0_ChampionStatMaximum] = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 2); + L0798_pc_Character += 2; + } + L0797_ps_Champion->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10; + L0798_pc_Character++; + for (AL0794_ui_SkillIndex = k4_ChampionSkillSwing; AL0794_ui_SkillIndex <= k19_ChampionSkillWater; AL0794_ui_SkillIndex++) { + if ((AL0796_ui_SkillValue = *L0798_pc_Character++ - 'A') > 0) { + L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = 125L << AL0796_ui_SkillValue; + } + } + for (AL0794_ui_SkillIndex = k0_ChampionSkillFighter; AL0794_ui_SkillIndex <= k3_ChampionSkillWizard; AL0794_ui_SkillIndex++) { + L0806_l_BaseSkillExperience = 0; + L0795_i_HiddenSkillIndex = (AL0794_ui_SkillIndex + 1) << 2; + for (AL0800_ui_HiddenSkillCounter = 0; AL0800_ui_HiddenSkillCounter < 4; AL0800_ui_HiddenSkillCounter++) { + L0806_l_BaseSkillExperience += L0797_ps_Champion->_skills[L0795_i_HiddenSkillIndex + AL0800_ui_HiddenSkillCounter]._experience; + } + L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = L0806_l_BaseSkillExperience; + } + _vm->_championMan->_g299_candidateChampionOrdinal = L0799_ui_PreviousPartyChampionCount + 1; + if (++_vm->_championMan->_g305_partyChampionCount == 1) { _vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst); _vm->_menuMan->_g508_refreshActionArea = true; - } else { + } else { _vm->_menuMan->f388_clearActingChampion(); - _vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1)); - } - - int16 mapX = _vm->_dungeonMan->_g306_partyMapX; - int16 mapY = _vm->_dungeonMan->_g307_partyMapY; - - uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._g308_partyDir)); - mapX += _vm->_dirIntoStepCountEast[dunMan._g308_partyDir]; - mapY += _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir]; - thing = dunMan.f161_getSquareFirstThing(mapX, mapY); - AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1; - uint16 slotIndex_Green; - while (thing != Thing::_endOfList) { - ThingType AL_2_thingType = thing.getType(); - if ((AL_2_thingType > k3_SensorThingType) && (thing.getCell() == championObjectsCell)) { - int16 objectAllowedSlots = g237_ObjectInfo[dunMan.f141_getObjectInfoIndex(thing)].getAllowedSlots(); - switch (AL_2_thingType) { + _vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_vm->_championMan->_g305_partyChampionCount - 1)); + } + L0802_i_MapX = _vm->_dungeonMan->_g306_partyMapX; + L0803_i_MapY = _vm->_dungeonMan->_g307_partyMapY; + L0804_ui_ChampionObjectsCell = returnOppositeDir(_vm->_dungeonMan->_g308_partyDir); + L0802_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L0803_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir]; + L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0802_i_MapX, L0803_i_MapY); + AL0794_ui_SlotIndex = k13_ChampionSlotBackpackLine_1_1; + while (L0793_T_Thing != Thing::_endOfList) { + if (((AL0796_ui_ThingType = (L0793_T_Thing.getType())) > k3_SensorThingType) && ((L0793_T_Thing.getCell()) == L0804_ui_ChampionObjectsCell)) { + L0805_i_ObjectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0793_T_Thing)]._allowedSlots; + switch (AL0796_ui_ThingType) { case k6_ArmourThingType: - for (slotIndex_Green = k2_ChampionSlotHead; slotIndex_Green <= k5_ChampionSlotFeet; slotIndex_Green++) { - if (objectAllowedSlots & gSlotMasks[slotIndex_Green]) + for (L0801_ui_SlotIndex = k2_ChampionSlotHead; L0801_ui_SlotIndex <= k5_ChampionSlotFeet; L0801_ui_SlotIndex++) { + if (L0805_i_ObjectAllowedSlots & gSlotMasks[L0801_ui_SlotIndex]) goto T0280048; } - if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) { - slotIndex_Green = k10_ChampionSlotNeck; + if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) { + L0801_ui_SlotIndex = k10_ChampionSlotNeck; } else { goto T0280046; } break; case k5_WeaponThingType: - if (champ->getSlot(k1_ChampionSlotActionHand) == Thing::_none) { - slotIndex_Green = k1_ChampionSlotActionHand; + if (L0797_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) { + L0801_ui_SlotIndex = k1_ChampionSlotActionHand; } else { goto T0280046; } break; case k7_ScrollThingType: case k8_PotionThingType: - if (champ->getSlot(k11_ChampionSlotPouch_1) == Thing::_none) { - slotIndex_Green = k11_ChampionSlotPouch_1; - } else if (champ->getSlot(k6_ChampionSlotPouch_2) == Thing::_none) { - slotIndex_Green = k6_ChampionSlotPouch_2; + if (L0797_ps_Champion->_slots[k11_ChampionSlotPouch_1] == Thing::_none) { + L0801_ui_SlotIndex = k11_ChampionSlotPouch_1; } else { - goto T0280046; + if (L0797_ps_Champion->_slots[k6_ChampionSlotPouch_2] == Thing::_none) { + L0801_ui_SlotIndex = k6_ChampionSlotPouch_2; + } else { + goto T0280046; + } } break; case k9_ContainerThingType: case k10_JunkThingType: T0280046: - if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) { - slotIndex_Green = k10_ChampionSlotNeck; + if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) { + L0801_ui_SlotIndex = k10_ChampionSlotNeck; } else { - slotIndex_Green = AL_0_slotIndex_Red++; + L0801_ui_SlotIndex = AL0794_ui_SlotIndex++; } - break; - - default: - break; } T0280048: - if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_none) { + if (L0797_ps_Champion->_slots[L0801_ui_SlotIndex] != Thing::_none) { goto T0280046; } - f301_addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green); + _vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0799_ui_PreviousPartyChampionCount, L0793_T_Thing, (ChampionSlot)L0801_ui_SlotIndex); } - thing = dunMan.f159_getNextThing(thing); + L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing); } - - _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)prevChampCount); - _vm->_menuMan->f456_drawDisabledMenu(); + _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)L0799_ui_PreviousPartyChampionCount); + _vm->_menuMan->f456_drawDisabledMenu();; } void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) { @@ -1464,7 +1466,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { L0868_i_ChampionStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing; - L0865_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + L0865_ps_Champion = &_gK71_champions[champIndex]; L0862_ui_ChampionAttributes = L0865_ps_Champion->_attributes; if (!getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand)) { return; @@ -1481,13 +1483,13 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { for (uint16 i = 0; i < 3; ++i) L0872_ai_NativeBitmapIndices[i] = 0; AL0864_i_BorderCount = 0; - if (_vm->_championMan->_g407_party._fireShieldDefense > 0) { + if (_g407_party._fireShieldDefense > 0) { L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k38_BorderPartyFireshieldIndice; } - if (_vm->_championMan->_g407_party._spellShieldDefense > 0) { + if (_g407_party._spellShieldDefense > 0) { L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k39_BorderPartySpellshieldIndice; } - if ((_vm->_championMan->_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) { + if ((_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) { L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k37_BorderPartyShieldIndice; } while (AL0864_i_BorderCount--) { @@ -1509,7 +1511,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { if (!(L0865_ps_Champion->_currHealth)) goto T0292042; if (getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle)) { - AL0864_i_ColorIndex = (champIndex == _vm->_championMan->_g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; + AL0864_i_ColorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; if (L0863_B_IsInventoryChampion) { _vm->_textMan->f52_printToViewport(3, 7, (Color)AL0864_i_ColorIndex, L0866_pc_ChampionName = L0865_ps_Champion->_name); L0869_i_ChampionTitleX = 6 * strlen(L0866_pc_ChampionName) + 3; @@ -1528,9 +1530,9 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { } } if (getFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics)) { - _vm->_championMan->f287_drawChampionBarGraphs(champIndex); + f287_drawChampionBarGraphs(champIndex); if (L0863_B_IsInventoryChampion) { - _vm->_championMan->f290_drawHealthStaminaManaValues(L0865_ps_Champion); + f290_drawHealthStaminaManaValues(L0865_ps_Champion); if ((L0865_ps_Champion->_food < 0) || (L0865_ps_Champion->_water < 0) || (L0865_ps_Champion->_poisonEventCount)) { AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice; } else { @@ -1550,14 +1552,14 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { } if (getFlag(L0862_ui_ChampionAttributes, k0x2000_ChampionAttributeWounds)) { for (AL0864_i_SlotIndex = L0863_B_IsInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL0864_i_SlotIndex >= k0_ChampionSlotReadyHand; AL0864_i_SlotIndex--) { - _vm->_championMan->f291_drawSlot(champIndex, AL0864_i_SlotIndex); + f291_drawSlot(champIndex, AL0864_i_SlotIndex); } if (L0863_B_IsInventoryChampion) { setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); } } if (getFlag(L0862_ui_ChampionAttributes, k0x0200_ChampionAttributeLoad) && L0863_B_IsInventoryChampion) { - if (L0865_ps_Champion->_load > (AL0864_i_Load = _vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion))) { + if (L0865_ps_Champion->_load > (AL0864_i_Load = f309_getMaximumLoad(L0865_ps_Champion))) { AL0870_i_Color = k8_ColorRed; } else { if (((long)L0865_ps_Champion->_load << 3) > ((long)AL0864_i_Load * 5)) { @@ -1568,28 +1570,28 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { } _vm->_textMan->f52_printToViewport(104, 132, (Color)AL0870_i_Color, "LOAD "); AL0864_i_Load = L0865_ps_Champion->_load / 10; - strcpy(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); + strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); strcat(_vm->_g353_stringBuildBuffer, "."); AL0864_i_Load = L0865_ps_Champion->_load - (AL0864_i_Load * 10); - strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str()); + strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str()); strcat(_vm->_g353_stringBuildBuffer, "/"); - AL0864_i_Load = (_vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10; - strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); + AL0864_i_Load = (f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10; + strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); strcat(_vm->_g353_stringBuildBuffer, " KG"); _vm->_textMan->f52_printToViewport(148, 132, (Color)AL0870_i_Color, _vm->_g353_stringBuildBuffer); setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); } - AL0864_i_ChampionIconIndex = _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir); + AL0864_i_ChampionIconIndex = M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir); if (getFlag(L0862_ui_ChampionAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL0864_i_ChampionIconIndex))) { _vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], g46_ChampionColor[champIndex]); - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen); } if (getFlag(L0862_ui_ChampionAttributes, k0x0800_ChampionAttributePanel) && L0863_B_IsInventoryChampion) { if (_vm->_g333_pressingMouth) { _vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned(); } else { if (_vm->_g331_pressingEye) { - if (_vm->_championMan->_g415_leaderEmptyHanded) { + if (_g415_leaderEmptyHanded) { _vm->_inventoryMan->f351_drawChampionSkillsAndStatistics(); } } else { @@ -1599,7 +1601,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); } if (getFlag(L0862_ui_ChampionAttributes, k0x8000_ChampionAttributeActionHand)) { - _vm->_championMan->f291_drawSlot(champIndex, k1_ChampionSlotActionHand); + f291_drawSlot(champIndex, k1_ChampionSlotActionHand); _vm->_menuMan->f386_drawActionIcon(champIndex); if (L0863_B_IsInventoryChampion) { setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); diff --git a/engines/dm/champion.h b/engines/dm/champion.h index a17f92ee2b..2dc4579ee4 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -386,7 +386,7 @@ public: int16 _water; uint16 _load; int16 _shieldDefense; - byte _portrait[464]; // 32 x 29 pixel portrait + byte _portrait[928]; // 32 x 29 pixel portrait Thing &getSlot(ChampionSlot slot) { return _slots[slot]; } void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index aa47af2f7a..f591399e2c 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -69,11 +69,6 @@ uint16 returnNextVal(uint16 val) { bool isOrientedWestEast(direction dir) { return dir & 1; } - -uint16 setFlag(uint16 &val, uint16 mask) { - return val |= mask; -} - uint16 toggleFlag(uint16& val, uint16 mask) { return val ^= mask; } @@ -314,7 +309,7 @@ void DMEngine::f2_gameloop() { while (true) { if (_g327_newPartyMapIndex != kM1_mapIndexNone) { - T0002002: +T0002002: f3_processNewPartyMap(_g327_newPartyMapIndex); _movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); _g327_newPartyMapIndex = kM1_mapIndexNone; @@ -326,15 +321,34 @@ void DMEngine::f2_gameloop() { if (_g327_newPartyMapIndex != kM1_mapIndexNone) goto T0002002; + if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { + Box box(0, 223, 0, 135); + _displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // dummy code + _displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); + if (_g325_setMousePointerToObjectInMainLoop) { + _g325_setMousePointerToObjectInMainLoop = false; + _eventMan->f78_showMouse(); + _eventMan->f68_setPointerToObject(_objectMan->_g412_objectIconForMousePointer); + _eventMan->f77_hideMouse(); + + } + if (_eventMan->_g326_refreshMousePointerInMainLoop) { + _eventMan->_g326_refreshMousePointerInMainLoop = false; + _eventMan->_g598_mousePointerBitmapUpdated = true; + _eventMan->f78_showMouse(); + _eventMan->f77_hideMouse(); + } + } + if (_championMan->_g303_partyDead) break; _g313_gameTime++; if (!(_g313_gameTime & 511)) - _inventoryMan->f338_decreaseTorchesLightPower(); - if (_g310_disabledMovementTicks) { - _g310_disabledMovementTicks--; - } + //_inventoryMan->f338_decreaseTorchesLightPower(); + if (_g310_disabledMovementTicks) { + _g310_disabledMovementTicks--; + } if (_championMan->_g407_party._freezeLifeTicks) { _championMan->_g407_party._freezeLifeTicks -= 1; } @@ -345,15 +359,10 @@ void DMEngine::f2_gameloop() { _g321_stopWaitingForPlayerInput = false; //do { - _eventMan->processInput(); - _eventMan->f380_processCommandQueue(); - //} while (!_g321_stopWaitingForPlayerInput /*|| !_g301_gameTimeTicking */); + _eventMan->processInput(); + _eventMan->f380_processCommandQueue(); + //} while (!_g321_stopWaitingForPlayerInput /*|| !_g301_gameTimeTicking */); - if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { - Box box(0, 223, 0, 135); - _displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // dummy code - _displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); - } _displayMan->updateScreen(); _system->delayMillis(18); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 3f7f55823c..d0bc378beb 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -125,7 +125,7 @@ uint16 returnNextVal(uint16 val); // @ M17_NEXT bool isOrientedWestEast(direction dir); // @ M16_IS_ORIENTED_WEST_EAST -uint16 setFlag(uint16 &val, uint16 mask); // @ M08_SET +#define setFlag(val, mask) ((val) |= (mask)) #define getFlag(val, mask) ((val) & (mask)) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index b4cd96448a..8a49d957ed 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -31,7 +31,9 @@ #include "dungeonman.h" #include "timeline.h" #include "champion.h" - +#include "group.h" +#include "movesens.h" +#include "projexpl.h" namespace DM { @@ -417,8 +419,6 @@ DungeonMan::~DungeonMan() { delete[] _g260_dungeonTextData; delete[] _g279_dungeonMapData; for (uint16 i = 0; i < 16; ++i) { - if (_g284_thingData[i]) - delete[] _g284_thingData[i][0]; delete[] _g284_thingData[i]; } } @@ -651,34 +651,34 @@ void DungeonMan::f434_loadDungeonFile() { continue; if (_g284_thingData[thingType]) { - delete[] _g284_thingData[thingType][0]; delete[] _g284_thingData[thingType]; } - _g284_thingData[thingType] = new uint16*[_g278_dungeonFileHeader._thingCounts[thingType]]; - _g284_thingData[thingType][0] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount]; - for (uint16 i = 0; i < _g278_dungeonFileHeader._thingCounts[thingType]; ++i) - _g284_thingData[thingType][i] = _g284_thingData[thingType][0] + i * thingStoreWordCount; + _g284_thingData[thingType] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount]; if (thingType == k4_GroupThingType) { - for (uint16 i = 0; i < thingCount; ++i) + for (uint16 i = 0; i < thingCount; ++i) { + uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount; for (uint16 j = 0; j < thingStoreWordCount; ++j) { if (j == 2 || j == 3) - _g284_thingData[thingType][i][j] = dunDataStream.readByte(); + nextSlot[j] = dunDataStream.readByte(); else - _g284_thingData[thingType][i][j] = dunDataStream.readUint16BE(); + nextSlot[j] = dunDataStream.readUint16BE(); } + } } else if (thingType == k14_ProjectileThingType) { for (uint16 i = 0; i < thingCount; ++i) { - _g284_thingData[thingType][i][0] = dunDataStream.readUint16BE(); - _g284_thingData[thingType][i][1] = dunDataStream.readUint16BE(); - _g284_thingData[thingType][i][2] = dunDataStream.readByte(); - _g284_thingData[thingType][i][3] = dunDataStream.readByte(); - _g284_thingData[thingType][i][4] = dunDataStream.readUint16BE(); + uint16 *nextSlot = _g284_thingData[thingType] + i * thingStoreWordCount; + nextSlot[0] = dunDataStream.readUint16BE(); + nextSlot[1] = dunDataStream.readUint16BE(); + nextSlot[2] = dunDataStream.readByte(); + nextSlot[3] = dunDataStream.readByte(); + nextSlot[4] = dunDataStream.readUint16BE(); } } else { for (uint16 i = 0; i < thingCount; ++i) { + uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount; for (uint16 j = 0; j < thingStoreWordCount; ++j) - _g284_thingData[thingType][i][j] = dunDataStream.readUint16BE(); + nextSlot[j] = dunDataStream.readUint16BE(); } } @@ -686,7 +686,7 @@ void DungeonMan::f434_loadDungeonFile() { if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType) _vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType]; for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) { - _g284_thingData[thingType][thingCount + i][0] = Thing::_none.toUint16(); + (_g284_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16(); } } } @@ -755,33 +755,36 @@ void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) { Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) { - bool isInXBounds = (mapX >= 0) && (mapX < _g273_currMapWidth); - bool isInYBounds = (mapY >= 0) && (mapY < _g274_currMapHeight); - - if (isInXBounds && isInYBounds) - return Square(_g271_currMapData[mapX][mapY]); - - - Square tmpSquare; - if (isInYBounds) { - tmpSquare.set(_g271_currMapData[0][mapY]); - if (mapX == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square(k0_WallElemType).set(k0x0004_WallEastRandOrnAllowed); - - tmpSquare.set(_g271_currMapData[_g273_currMapWidth - 1][mapY]); - if (mapX == _g273_currMapWidth && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square(k0_WallElemType).set(k0x0001_WallWestRandOrnAllowed); - } else if (isInXBounds) { - tmpSquare.set(_g271_currMapData[mapX][0]); - if (mapY == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square(k0_WallElemType).set(k0x0002_WallSouthRandOrnAllowed); - - tmpSquare.set(_g271_currMapData[mapX][_g274_currMapHeight - 1]); - if (mapY == _g274_currMapHeight && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square((k0_WallElemType << 5) | k0x0008_WallNorthRandOrnAllowed); + int16 L0248_i_Multiple; +#define AL0248_B_IsMapXInBounds L0248_i_Multiple +#define AL0248_i_SquareType L0248_i_Multiple + int16 L0249_i_Multiple; +#define AL0249_B_IsMapYInBounds L0249_i_Multiple +#define AL0249_i_SquareType L0249_i_Multiple + + AL0249_B_IsMapYInBounds = (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight); + if ((AL0248_B_IsMapXInBounds = (mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth)) && AL0249_B_IsMapYInBounds) { + return Square(_vm->_dungeonMan->_g271_currMapData[mapX][mapY]); } - return Square(k0_WallElemType); + if (AL0249_B_IsMapYInBounds) { + if (((mapX == -1) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[0][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0004_WallEastRandOrnAllowed); + } + if (((mapX == _vm->_dungeonMan->_g273_currMapWidth) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[_vm->_dungeonMan->_g273_currMapWidth - 1][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0001_WallWestRandOrnAllowed); + } + } else { + if (AL0248_B_IsMapXInBounds) { + if (((mapY == -1) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][0]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed); + } + if (((mapY == _vm->_dungeonMan->_g274_currMapHeight) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][_vm->_dungeonMan->_g274_currMapHeight - 1]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed); + } + } + } + return Square(k0_ElementTypeWall, 0); } Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { @@ -790,17 +793,23 @@ Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 st } int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) { - if (mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight || !Square(_g271_currMapData[mapX][mapY]).get(k0x0010_ThingListPresent)) - return -1; + uint16 L0260_ui_ThingIndex; + int16 L0261_i_MapY; + register unsigned char* L0262_puc_Square; - int16 y = 0; - uint16 index = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; - byte* square = _g271_currMapData[mapX]; - while (y++ != mapY) - if (Square(*square++).get(k0x0010_ThingListPresent)) - index++; - return index; + L0262_puc_Square = _vm->_dungeonMan->_g271_currMapData[mapX]; + if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight) || !getFlag(L0262_puc_Square[mapY], k0x0010_ThingListPresent)) { + return -1; + } + L0261_i_MapY = 0; + L0260_ui_ThingIndex = _vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount[mapX]; + while (L0261_i_MapY++ != mapY) { + if (getFlag(*L0262_puc_Square++, k0x0010_ThingListPresent)) { + L0260_ui_ThingIndex++; + } + } + return L0260_ui_ThingIndex; } Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) { @@ -819,11 +828,11 @@ void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 #define footprintsAllowed L0307_uc_Multiple #define scentOrdinal L0307_uc_Multiple Sensor* sensor; - bool leftRandWallOrnAllowed; - int16 L0310_i_Multiple; + bool leftRandWallOrnAllowed = false; + int16 L0310_i_Multiple = 0; #define frontRandWallOrnAllowed L0310_i_Multiple #define sideIndex L0310_i_Multiple - bool rightRandWallOrnAllowed; + bool rightRandWallOrnAllowed = false; int16 thingTypeRedEagle; bool squreIsFakeWall; Thing thing; @@ -957,31 +966,33 @@ T0172049_Footprints: aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16(); } -void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, +void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir, int16 mapX, int16 mapY, bool isFakeWall) { - int16 ornCount = _g269_currMap->_randWallOrnCount; - - turnDirRight(dir); - aspectArray[k2_RightWallOrnOrdAspect] = f170_getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - turnDirRight(dir); - aspectArray[k3_FrontWallOrnOrdAspect] = f170_getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - turnDirRight(dir); - aspectArray[k4_LeftWallOrnOrdAspect] = f170_getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - - if (isFakeWall || mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight) { - for (uint16 i = k2_RightWallOrnOrdAspect; i <= k4_LeftWallOrnOrdAspect; ++i) { - if (f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[i]))) - aspectArray[i] = 0; + int16 L0306_i_Multiple; +#define AL0306_i_RandomWallOrnamentCount L0306_i_Multiple +#define AL0306_i_SideIndex L0306_i_Multiple + + + AL0306_i_RandomWallOrnamentCount = _vm->_dungeonMan->_g269_currMap->_randWallOrnCount; + aspectArray[k2_RightWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(leftAllowed, AL0306_i_RandomWallOrnamentCount, mapX, ++mapY * (M21_normalizeModulo4(++dir) + 1), 30); + aspectArray[k3_FrontWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(frontAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY * (M21_normalizeModulo4(++dir) + 1), 30); + aspectArray[k4_LeftWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(rightAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY-- * (M21_normalizeModulo4(++dir) + 1), 30); + if (isFakeWall || (mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight)) { /* If square is a fake wall or is out of map bounds */ + for (AL0306_i_SideIndex = k2_RightWallOrnOrdAspect; AL0306_i_SideIndex <= k4_LeftWallOrnOrdAspect; AL0306_i_SideIndex++) { /* Loop to remove any random ornament that is an alcove */ + if (_vm->_dungeonMan->f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[AL0306_i_SideIndex]))) { + aspectArray[AL0306_i_SideIndex] = 0; + } } } } int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) { - int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1) - + (3000 + (_g272_currMapIndex << 6) + _g273_currMapWidth + _g274_currMapHeight) * 11 - + _g278_dungeonFileHeader._ornamentRandomSeed) >> 2) % modulo; - if (allowed && index < count) - return _vm->M0_indexToOrdinal(index); + int16 L0305_i_RandomOrnamentIndex; + + + if (allowed && ((L0305_i_RandomOrnamentIndex = f169_getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_vm->_dungeonMan->_g272_currMapIndex << (int16)6) + _vm->_dungeonMan->_g273_currMapWidth + _vm->_dungeonMan->_g274_currMapHeight, modulo)) < count)) { + return _vm->M0_indexToOrdinal(L0305_i_RandomOrnamentIndex); + } return 0; } @@ -995,7 +1006,7 @@ bool DungeonMan::f149_isWallOrnAnAlcove(int16 wallOrnIndex) { } uint16 *DungeonMan::f156_getThingData(Thing thing) { - return _g284_thingData[thing.getType()][thing.getIndex()]; + return _g284_thingData[thing.getType()] + thing.getIndex() * g235_ThingDataWordCount[thing.getType()]; } uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) { @@ -1003,7 +1014,7 @@ uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) { } Thing DungeonMan::f159_getNextThing(Thing thing) { - return Thing(f156_getThingData(thing)[0]); // :) + return Thing(f156_getThingData(thing)[0]); } char g255_MessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings @@ -1109,7 +1120,7 @@ char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) { char sepChar; - TextString textString(_g284_thingData[k2_TextstringType][thing.getIndex()]); + TextString textString(_g284_thingData[k2_TextstringType] + thing.getIndex() * g235_ThingDataWordCount[k2_TextstringType]); if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) { type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible); if (type == k1_TextTypeMessage) { @@ -1174,6 +1185,45 @@ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) { *destString = ((type == k0_TextTypeInscription) ? 0x81 : '\0'); } +Thing DungeonMan::f166_getUnusedThing(uint16 thingType) { + int16 L0288_i_ThingIndex; + int16 L0289_i_ThingDataByteCount; + int16 L0290_i_ThingCount; + Thing* L0291_ps_Generic; + Thing L0292_T_Thing; + + + L0290_i_ThingCount = _vm->_dungeonMan->_g278_dungeonFileHeader._thingCounts[getFlag(thingType, k0x7FFF_thingType)]; + if (thingType == (k0x8000_championBones | k10_JunkThingType)) { + thingType = k10_JunkThingType; + } else { + if (thingType == k10_JunkThingType) { + L0290_i_ThingCount -= 3; /* Always keep 3 unused JUNK things for the bones of dead champions */ + } + } + L0288_i_ThingIndex = L0290_i_ThingCount; + L0289_i_ThingDataByteCount = g235_ThingDataWordCount[thingType] >> 1; + L0291_ps_Generic = (Thing*)_vm->_dungeonMan->_g284_thingData[thingType]; + for (;;) { /*_Infinite loop_*/ + if (*L0291_ps_Generic == Thing::_none) { /* If thing data is unused */ + L0292_T_Thing = Thing((thingType << 10) | (L0290_i_ThingCount - L0288_i_ThingIndex)); + break; + } + if (--L0288_i_ThingIndex) { /* If there are thing data left to process */ + L0291_ps_Generic += L0289_i_ThingDataByteCount; /* Proceed to the next thing data */ + } else { + if ((L0292_T_Thing = f165_getDiscardTHing(thingType)) == Thing::_none) { + return Thing::_none; + } + L0291_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0292_T_Thing); + break; + } + } + memset(L0291_ps_Generic, 0, L0289_i_ThingDataByteCount * 2); + + *L0291_ps_Generic = Thing::_endOfList; + return L0292_T_Thing; +} uint16 DungeonMan::f140_getObjectWeight(Thing thing) { static const uint16 g241_junkInfo[] = { // @ G0241_auc_Graphic559_JunkInfo @@ -1263,46 +1313,56 @@ int16 DungeonMan::f141_getObjectInfoIndex(Thing thing) { } void DungeonMan::f163_linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) { - if (thingToLink == Thing::_endOfList) - return; + Thing L0265_T_Thing; + uint16 L0266_ui_Multiple; +#define AL0266_ui_Column L0266_ui_Multiple +#define AL0266_ui_SquareFirstThingIndex L0266_ui_Multiple + Thing* L0267_pT_Thing; + byte* L0268_puc_Square; + Thing* L0269_ps_Generic; + uint16 L0270_ui_MapY; - uint16 *rawObjPtr = f156_getThingData(thingToLink); - *rawObjPtr = Thing::_endOfList.toUint16(); + if (thingToLink == Thing::_endOfList) { + return; + } + L0269_ps_Generic = (Thing*)f156_getThingData(thingToLink); + *L0269_ps_Generic = Thing::_endOfList; + /* If mapX >= 0 then the thing is linked to the list of things on the specified square else it is linked at the end of the specified thing list */ if (mapX >= 0) { - Square *squarePtr = (Square*)&_g271_currMapData[mapX][mapY]; - if (squarePtr->get(k0x0010_ThingListPresent)) { + L0268_puc_Square = &_g271_currMapData[mapX][mapY]; + if (getFlag(*L0268_puc_Square, k0x0010_ThingListPresent)) { thingInList = f161_getSquareFirstThing(mapX, mapY); } else { - squarePtr->set(k0x0010_ThingListPresent); - uint16 *cumulativeCount = &_g270_currMapColCumulativeSquareFirstThingCount[mapX + 1]; - uint16 column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1; - while (column--) { - (*cumulativeCount++)++; + setFlag(*L0268_puc_Square, k0x0010_ThingListPresent); + uint16 * tmp = _g270_currMapColCumulativeSquareFirstThingCount + mapX + 1; + AL0266_ui_Column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1; + while (AL0266_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is added */ + (*tmp++)++; /* Increment the cumulative first thing count */ } - uint16 mapYStep = 0; - squarePtr -= mapY; - uint16 squareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; - while (mapYStep++ != mapY) { - if (squarePtr->get(k0x0010_ThingListPresent)) { - squareFirstThingIndex++; + L0270_ui_MapY = 0; + L0268_puc_Square -= mapY; + AL0266_ui_SquareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; + while (L0270_ui_MapY++ != mapY) { + if (getFlag(*L0268_puc_Square++, k0x0010_ThingListPresent)) { + AL0266_ui_SquareFirstThingIndex++; } - squarePtr++; } - Thing* thingPtr = &_g283_squareFirstThings[squareFirstThingIndex]; - memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_g278_dungeonFileHeader._squareFirstThingCount - squareFirstThingIndex - 1)); - *thingPtr = thingToLink; + L0267_pT_Thing = &_g283_squareFirstThings[AL0266_ui_SquareFirstThingIndex]; + // the second '- 1' is for the loop initialization, > 0 is because we are copying from one behind + for (int16 i = _g278_dungeonFileHeader._squareFirstThingCount - AL0266_ui_SquareFirstThingIndex - 1 - 1; i > 0; --i) + L0267_pT_Thing[i] = L0267_pT_Thing[i - 1]; + + *L0267_pT_Thing = thingToLink; return; } } - - Thing thing = f159_getNextThing(thingInList); - while (thing != Thing::_endOfList) { - thing = f159_getNextThing(thing); - thingInList = thing; + L0265_T_Thing = f159_getNextThing(thingInList); + while (L0265_T_Thing != Thing::_endOfList) { + L0265_T_Thing = f159_getNextThing(thingInList = L0265_T_Thing); } - rawObjPtr = f156_getThingData(thingInList); - *rawObjPtr = thingToLink.toUint16(); + L0269_ps_Generic = (Thing*)f156_getThingData(thingInList); + *L0269_ps_Generic = thingToLink; } WeaponInfo* DungeonMan::f158_getWeaponInfo(Thing thing) { @@ -1365,4 +1425,299 @@ int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDe } return kM1_mapIndexNone; } + +Thing DungeonMan::f162_getSquareFirstObject(int16 mapX, int16 mapY) { + Thing thing = f161_getSquareFirstThing(mapX, mapY); + while ((thing != Thing::_endOfList) && (thing.getType() < k4_GroupThingType)) { + thing = f159_getNextThing(thing); + } + return thing; +} + +uint16 DungeonMan::f143_getArmourDefense(ArmourInfo* armourInfo, bool useSharpDefense) { + uint16 L0244_ui_Defense; + + L0244_ui_Defense = armourInfo->_defense; + if (useSharpDefense) { + L0244_ui_Defense = _vm->f30_getScaledProduct(L0244_ui_Defense, 3, getFlag(armourInfo->_attributes, k0x0007_ArmourAttributeSharpDefense) + 4); + } + return L0244_ui_Defense; +} + +Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) { + uint16 L0276_ui_MapX; + uint16 L0277_ui_MapY; + Thing L0278_T_Thing; + uint16 L0279_ui_MapIndex; + byte* L0280_puc_Square; + Thing* L0281_pT_SquareFirstThing; + Thing* L0282_ps_Generic; + uint16 L0283_ui_DiscardThingMapIndex; + int L0284_i_CurrentMapIndex; + uint16 L0285_ui_MapWidth; + uint16 L0286_ui_MapHeight; + int L0287_i_ThingType; + static unsigned char G0294_auc_LastDiscardedThingMapIndex[16]; + + + if (thingType == k15_ExplosionThingType) { + return Thing::_none; + } + L0284_i_CurrentMapIndex = _vm->_dungeonMan->_g272_currMapIndex; + if (((L0279_ui_MapIndex = G0294_auc_LastDiscardedThingMapIndex[thingType]) == _vm->_dungeonMan->_g309_partyMapIndex) && (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount)) { + L0279_ui_MapIndex = 0; + } + L0283_ui_DiscardThingMapIndex = L0279_ui_MapIndex; + for (;;) { /*_Infinite loop_*/ + L0285_ui_MapWidth = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._width; + L0286_ui_MapHeight = _vm->_dungeonMan->_g277_dungeonMaps[L0279_ui_MapIndex]._height; + L0280_puc_Square = _vm->_dungeonMan->_g279_dungeonMapData[L0279_ui_MapIndex][0]; + L0281_pT_SquareFirstThing = &_vm->_dungeonMan->_g283_squareFirstThings[_vm->_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[L0279_ui_MapIndex]]]; + for (L0276_ui_MapX = 0; L0276_ui_MapX <= L0285_ui_MapWidth; L0276_ui_MapX++) { + for (L0277_ui_MapY = 0; L0277_ui_MapY <= L0286_ui_MapHeight; L0277_ui_MapY++) { + if (getFlag(*L0280_puc_Square++, k0x0010_ThingListPresent)) { + L0278_T_Thing = *L0281_pT_SquareFirstThing++; + if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && ((L0276_ui_MapX - _vm->_dungeonMan->_g306_partyMapX + 5) <= 10) && ((L0277_ui_MapY - _vm->_dungeonMan->_g307_partyMapY + 5) <= 10)) /* If square is too close to the party */ + goto T0165029; + do { + if ((L0287_i_ThingType = (L0278_T_Thing).getType()) == k3_SensorThingType) { + L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing); + if (((Sensor*)L0282_ps_Generic)->getType()) /* If sensor is not disabled */ + break; + } else { + if (L0287_i_ThingType == thingType) { + L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing); + switch (thingType) { + case k4_GroupThingType: + if (((Group*)L0282_ps_Generic)->getDoNotDiscard()) + continue; + case k14_ProjectileThingType: + _vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex); + if (thingType == k4_GroupThingType) { + _vm->_groupMan->f188_dropGroupPossessions(L0276_ui_MapX, L0277_ui_MapY, L0278_T_Thing, kM1_soundModeDoNotPlaySound); + _vm->_groupMan->f189_delete(L0276_ui_MapX, L0277_ui_MapY); + } else { + _vm->_projexpl->f214_projectileDeleteEvent(L0278_T_Thing); + f164_unlinkThingFromList(L0278_T_Thing, Thing(0), L0276_ui_MapX, L0277_ui_MapY); + _vm->_projexpl->f215_projectileDelete(L0278_T_Thing, 0, L0276_ui_MapX, L0277_ui_MapY); + } + break; + case k6_ArmourThingType: + if (((Armour*)L0282_ps_Generic)->getDoNotDiscard()) + continue; + goto T0165026; + case k5_WeaponThingType: + if (((Weapon*)L0282_ps_Generic)->getDoNotDiscard()) + continue; + goto T0165026; + case k10_JunkThingType: + if (((Junk*)L0282_ps_Generic)->getDoNotDiscard()) + continue; + goto T0165026; + case k8_PotionThingType: + if (((Potion*)L0282_ps_Generic)->getDoNotDiscard()) + continue; +T0165026: + _vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex); + _vm->_movsens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0); + } + _vm->_dungeonMan->f173_setCurrentMap(L0284_i_CurrentMapIndex); + G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex; + return Thing((L0278_T_Thing).getTypeAndIndex()); + } + } + } while ((L0278_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0278_T_Thing)) != Thing::_endOfList); +T0165029: + ; + } + } + } + if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) || (_vm->_dungeonMan->_g278_dungeonFileHeader._mapCount <= 1)) { + G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex; + return Thing::_none; + } + do { + if (++L0279_ui_MapIndex >= _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount) { + L0279_ui_MapIndex = 0; + } + } while (L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex); + if (L0279_ui_MapIndex == L0283_ui_DiscardThingMapIndex) { + L0279_ui_MapIndex = _vm->_dungeonMan->_g309_partyMapIndex; + } + } +} + +uint16 DungeonMan::f144_getCreatureAttributes(Thing thing) { + Group* L0245_ps_Group; + + L0245_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing); + return g243_CreatureInfo[L0245_ps_Group->_type]._attributes; +} + +void DungeonMan::f146_setGroupCells(Group* group, uint16 cells, uint16 mapIndex) { + if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) { + _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._cells = cells; + } else { + group->_cells = cells; + } +} + +void DungeonMan::f148_setGroupDirections(Group* group, int16 dir, uint16 mapIndex) { + if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) { + _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (direction)dir; + } else { + group->setDir(M21_normalizeModulo4(dir)); + } +} + +bool DungeonMan::f139_isCreatureAllowedOnMap(Thing thing, uint16 mapIndex) { + int16 L0234_i_Counter; + int16 L0235_i_CreatureType; + byte* L0236_puc_Multiple; +#define AL0236_puc_Group L0236_puc_Multiple +#define AL0236_puc_AllowedCreatureType L0236_puc_Multiple + Map* L0237_ps_Map; + + L0235_i_CreatureType = ((Group*)_vm->_dungeonMan->f156_getThingData(thing))->_type; + L0237_ps_Map = &_vm->_dungeonMan->_g277_dungeonMaps[mapIndex]; + AL0236_puc_AllowedCreatureType = _vm->_dungeonMan->_g279_dungeonMapData[mapIndex][L0237_ps_Map->_width] + L0237_ps_Map->_height + 1; + for (L0234_i_Counter = L0237_ps_Map->_creatureTypeCount; L0234_i_Counter > 0; L0234_i_Counter--) { + if (*AL0236_puc_AllowedCreatureType++ == L0235_i_CreatureType) { + return true; + } + } + return false; +} + +void DungeonMan::f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY) { + uint16 L0271_ui_SquareFirstThingIndex; + uint16 L0272_ui_Multiple; +#define AL0272_ui_SquareFirstThingIndex L0272_ui_Multiple +#define AL0272_ui_Column L0272_ui_Multiple + Thing L0273_T_Thing; + Thing* L0274_ps_Generic = nullptr; + Thing* L0275_pui_Multiple = nullptr; +#define AL0275_pT_Thing L0275_pui_Multiple +#define AL0275_pui_CumulativeFirstThingCount L0275_pui_Multiple + + + if (thingToUnlink == Thing::_endOfList) { + return; + } + + { + uint16 tmp = thingToUnlink.toUint16(); + clearFlag(tmp, 0xC000); + thingToUnlink = Thing(tmp); + } + + if (mapX >= 0) { + L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink); + AL0275_pT_Thing = &_vm->_dungeonMan->_g283_squareFirstThings[L0271_ui_SquareFirstThingIndex = _vm->_dungeonMan->f160_getSquareFirstThingIndex(mapX, mapY)]; /* BUG0_01 Coding error without consequence. The engine does not check that there are things at the specified square coordinates. _vm->_dungeonMan->f160_getSquareFirstThingIndex would return -1 for an empty square. No consequence as the function is never called with the coordinates of an empty square (except in the case of BUG0_59) */ + if ((*L0274_ps_Generic == Thing::_endOfList) && (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16())) { /* If the thing to unlink is the last thing on the square */ + clearFlag(_vm->_dungeonMan->_g271_currMapData[mapX][mapY], k0x0010_ThingListPresent); + AL0272_ui_SquareFirstThingIndex = _vm->_dungeonMan->_g278_dungeonFileHeader._squareFirstThingCount - 1; + for (uint16 i = 0; i < AL0272_ui_SquareFirstThingIndex - L0271_ui_SquareFirstThingIndex; ++i) + AL0275_pT_Thing[i] = AL0275_pT_Thing[i + 1]; + + _vm->_dungeonMan->_g283_squareFirstThings[AL0272_ui_SquareFirstThingIndex] = Thing::_none; + AL0275_pui_CumulativeFirstThingCount = (Thing*)_vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount + mapX + 1; + AL0272_ui_Column = _vm->_dungeonMan->_g282_dungeonColumCount - (_vm->_dungeonMan->_g281_dungeonMapsFirstColumnIndex[_vm->_dungeonMan->_g272_currMapIndex] + mapX) - 1; + while (AL0272_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is unlinked */ + (*(uint16*)AL0275_pui_CumulativeFirstThingCount++)--; /* Decrement the cumulative first thing count */ + } + goto T0164011; + } + if (((Thing*)AL0275_pT_Thing)->getTypeAndIndex() == thingToUnlink.toUint16()) { + *AL0275_pT_Thing = *L0274_ps_Generic; + goto T0164011; + } + thingInList = *AL0275_pT_Thing; + } + L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList); + while (L0273_T_Thing.getTypeAndIndex() != thingToUnlink.toUint16()) { + if ((L0273_T_Thing == Thing::_endOfList) || (L0273_T_Thing == Thing::_none)) { + goto T0164011; + } + L0273_T_Thing = _vm->_dungeonMan->f159_getNextThing(thingInList = L0273_T_Thing); + } + L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingInList); + *L0274_ps_Generic = _vm->_dungeonMan->f159_getNextThing(L0273_T_Thing); + L0274_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(thingToUnlink); +T0164011: + *L0274_ps_Generic = Thing::_endOfList; +} + +int16 DungeonMan::f155_getStairsExitDirection(int16 mapX, int16 mapY) { + int16 L0256_i_SquareType; + bool L0257_B_NorthSouthOrientedStairs; + + + if (L0257_B_NorthSouthOrientedStairs = !getFlag(_vm->_dungeonMan->f151_getSquare(mapX, mapY).toByte(), k0x0008_StairsNorthSouthOrient)) { + mapX = mapX + _vm->_dirIntoStepCountEast[kDirEast]; + mapY = mapY + _vm->_dirIntoStepCountNorth[kDirEast]; + } else { + mapX = mapX + _vm->_dirIntoStepCountEast[kDirNorth]; + mapY = mapY + _vm->_dirIntoStepCountNorth[kDirNorth]; + } + return ((((L0256_i_SquareType = Square(_vm->_dungeonMan->f151_getSquare(mapX, mapY)).getType()) == k0_ElementTypeWall) || (L0256_i_SquareType == k3_ElementTypeStairs)) << 1) + L0257_B_NorthSouthOrientedStairs; + +} + +Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) { + int16 L0293_i_Type; + int16 L0294_i_ThingType; + Thing L0295_T_Thing; + Junk* L0296_ps_Junk; + + + L0294_i_ThingType = k5_WeaponThingType; + if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit)) { + iconIndex = k4_IconIndiceWeaponTorchUnlit; + } + switch (iconIndex) { + case k54_IconIndiceWeaponRock: + L0293_i_Type = k30_WeaponTypeRock; + break; + case k128_IconIndiceJunkBoulder: + L0293_i_Type = k25_JunkTypeBoulder; + L0294_i_ThingType = k10_JunkThingType; + break; + case k51_IconIndiceWeaponArrow: + L0293_i_Type = k27_WeaponTypeArrow; + break; + case k52_IconIndiceWeaponSlayer: + L0293_i_Type = k28_WeaponTypeSlayer; + break; + case k55_IconIndiceWeaponPoisonDart: + L0293_i_Type = k31_WeaponTypePoisonDart; + break; + case k56_IconIndiceWeaponThrowingStar: + L0293_i_Type = k32_WeaponTypeThrowingStar; + break; + case k32_IconIndiceWeaponDagger: + L0293_i_Type = k8_WeaponTypeDagger; + break; + case k4_IconIndiceWeaponTorchUnlit: + L0293_i_Type = k2_WeaponTypeTorch; + break; + default: + return Thing::_none; + } + if ((L0295_T_Thing = f166_getUnusedThing(L0294_i_ThingType)) == Thing::_none) { + return Thing::_none; + } + L0296_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0295_T_Thing); + L0296_ps_Junk->setType(L0293_i_Type); /* Also works for WEAPON in cases other than Boulder */ + if ((iconIndex == k4_IconIndiceWeaponTorchUnlit) && ((Weapon*)L0296_ps_Junk)->isLit()) { /* BUG0_65 Torches created by object generator or projectile launcher sensors have no charges. Charges are only defined if the Torch is lit which is not possible at the time it is created */ + ((Weapon*)L0296_ps_Junk)->setChargeCount(15); + } + return L0295_T_Thing; +} + +int16 DungeonMan::f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo) { + return ((((((val1 * 31417) & 0xFFFF) >> 1) + ((val2 * 11) & 0xFFFF) + + _vm->_dungeonMan->_g278_dungeonFileHeader._ornamentRandomSeed) & 0xFFFF) >> 2) % modulo; /* Pseudorandom number generator */ +} + } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 26841a24bc..f9e21d4633 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -81,9 +81,7 @@ public: int16 _type; uint16 _objectAspectIndex; uint16 _actionSetIndex; -private: uint16 _allowedSlots; -public: ObjectInfo(int16 type, uint16 objectAspectIndex, uint16 actionSetIndex, uint16 allowedSlots) : _type(type), _objectAspectIndex(objectAspectIndex), _actionSetIndex(actionSetIndex), _allowedSlots(allowedSlots) {} bool getAllowedSlot(ObjectAllowedSlot slot) { return _allowedSlots & slot; } @@ -583,6 +581,7 @@ class Square { public: explicit Square(byte dat = 0) : _data(dat) {} explicit Square(SquareType type) { setType(type); } + explicit Square(byte element, byte mask) : _data((element << 5) | mask) {} Square &set(byte dat) { this->_data = dat; return *this; } Square &set(SquareMask mask) { _data |= mask; return *this; } byte get(SquareMask mask) { return _data & mask; } @@ -653,8 +652,8 @@ class DungeonMan { int16 f160_getSquareFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex int16 f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal - void f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, - int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals + void f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir, + int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals public: @@ -697,6 +696,7 @@ public: void f164_unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY); // @ F0164_DUNGEON_UnlinkThingFromList int16 f155_getStairsExitDirection(int16 mapX, int16 mapY); // @ F0155_DUNGEON_GetStairsExitDirection Thing f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex); // @ F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator + int16 f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo); // @ F0169_DUNGEON_GetRandomOrnamentIndex uint32 _rawDunFileDataSize; // @ probably NONE @@ -709,7 +709,7 @@ public: uint16 *_g280_dungeonColumnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount Thing *_g283_squareFirstThings; // @ G0283_pT_SquareFirstThings uint16 *_g260_dungeonTextData; // @ G0260_pui_DungeonTextData - uint16 **_g284_thingData[16]; // @ G0284_apuc_ThingData + uint16 *_g284_thingData[16]; // @ G0284_apuc_ThingData byte ***_g279_dungeonMapData; // @ G0279_pppuc_DungeonMapData diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 2fbefb118d..86b30d55dd 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -41,7 +41,6 @@ namespace DM { - byte g42_bitmapArrowPointer[576] = { // @ G0042_auc_Graphic562_Bitmap_ArrowPointer 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xE, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @@ -329,7 +328,6 @@ void EventManager::initMouse() { f73_buildpointerScreenArea(_mousePos.x, _mousePos.y); CursorMan.showMouse(false); - setMousePos(Common::Point(320 / 2, 200 / 2)); } @@ -358,10 +356,17 @@ void EventManager::f68_setPointerToObject(byte* bitmap) { _vm->_displayMan->_g578_useByteBoxCoordinates = true; L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject; memset(L0051_puc_Bitmap, 0, 32 * 18); + + /* _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, gK27_palChangesMousepointerOjbectIconShadow); _vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18); _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, g44_palChangesMousePointerIcon); _vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18); + */ + // dummy code + _vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18); + _vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18); + _gK100_preventBuildPointerScreenArea = false; f73_buildpointerScreenArea(_mousePos.x, _mousePos.y); } @@ -386,8 +391,8 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY) int16 L1578_i_XOverChampionStatusBox; - if (_gK100_preventBuildPointerScreenArea) - return; + // if (_gK100_preventBuildPointerScreenArea) + // return; _gK100_preventBuildPointerScreenArea = true; if (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) { @@ -442,16 +447,16 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY) _vm->_eventMan->_g598_mousePointerBitmapUpdated = false; switch (_gK104_mousePointerType) { case k0_pointerTypeArrow: - CursorMan.pushCursor(g42_bitmapArrowPointer, 32, 18, 0, 0, 0); + CursorMan.replaceCursor(g42_bitmapArrowPointer, 32, 18, 0, 0, 0); break; case k1_pointerTypeObjectIcon: - CursorMan.pushCursor(_g615_mousePointerOriginalColorsObject, 32, 18, 0, 0, 0); + CursorMan.replaceCursor(_g615_mousePointerOriginalColorsObject, 32, 18, 0, 0, 0); break; case k2_pointerTypeChampionIcon: - CursorMan.pushCursor(_g613_mousePointerOriginalColorsChampionIcon, 32, 18, 0, 0, 0); + CursorMan.replaceCursor(_g613_mousePointerOriginalColorsChampionIcon, 32, 18, 0, 0, 0); break; case k3_pointerTypeHand: - CursorMan.pushCursor(g43_bitmapHanPointer, 32, 18, 0, 0, 0); + CursorMan.replaceCursor(g43_bitmapHanPointer, 32, 18, 0, 0, 0); break; } } @@ -724,11 +729,15 @@ void EventManager::f368_commandSetLeader(ChampionIndex champIndex) { } void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() { - DungeonMan &dunMan = *_vm->_dungeonMan; - int16 mapX = dunMan._g306_partyMapX + _vm->_dirIntoStepCountEast[dunMan._g308_partyDir]; - int16 mapY = dunMan._g307_partyMapY + _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir]; - if ((mapX >= 0) && (mapX < dunMan._g273_currMapWidth) && (mapY >= 0) && (mapY < dunMan._g274_currMapHeight)) { - _vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->f275_sensorIsTriggeredByClickOnWall(mapX, mapY, returnOppositeDir(dunMan._g308_partyDir)); + uint16 L1135_ui_MapX; + uint16 L1136_ui_MapY; + + + L1135_ui_MapX = _vm->_dungeonMan->_g306_partyMapX; + L1136_ui_MapY = _vm->_dungeonMan->_g307_partyMapY; + L1135_ui_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1136_ui_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir]; + if ((L1135_ui_MapX >= 0) && (L1135_ui_MapX < _vm->_dungeonMan->_g273_currMapWidth) && (L1136_ui_MapY >= 0) && (L1136_ui_MapY < _vm->_dungeonMan->_g274_currMapHeight)) { + _vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->f275_sensorIsTriggeredByClickOnWall(L1135_ui_MapX, L1136_ui_MapY, returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)); } } diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 6ab49fbf44..05a86de66a 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -138,100 +138,102 @@ IconIndice ObjectMan::f32_getObjectType(Thing thing) { byte g29_ChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType IconIndice ObjectMan::f33_getIconIndex(Thing thing) { - IconIndice iconIndex = f32_getObjectType(thing); - - if ((iconIndex != kM1_IconIndiceNone) && - (((iconIndex < k32_IconIndiceWeaponDagger) && (iconIndex >= k0_IconIndiceJunkCompassNorth)) || // < instead of <= is no error - ((iconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (iconIndex <= k163_IconIndicePotionWaterFlask)) || - (iconIndex == k195_IconIndicePotionEmptyFlask)) - ) { - uint16 *rawType = _vm->_dungeonMan->f156_getThingData(thing); - switch (iconIndex) { - case k0_IconIndiceJunkCompassNorth: - iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_g308_partyDir); - break; - case k4_IconIndiceWeaponTorchUnlit: { - Weapon weapon(rawType); - if (weapon.isLit()) { - iconIndex = (IconIndice)(iconIndex + g29_ChargeCountToTorchType[weapon.getChargeCount()]); + int16 L0005_i_IconIndex; + Junk* L0006_ps_Junk; + + + if ((L0005_i_IconIndex = _vm->_objectMan->f32_getObjectType(thing)) != kM1_IconIndiceNone) { + if (((L0005_i_IconIndex < k32_IconIndiceWeaponDagger) && (L0005_i_IconIndex >= k0_IconIndiceJunkCompassNorth)) || + ((L0005_i_IconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (L0005_i_IconIndex <= k163_IconIndicePotionWaterFlask)) || + (L0005_i_IconIndex == k195_IconIndicePotionEmptyFlask)) { + L0006_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing); + switch (L0005_i_IconIndex) { + case k0_IconIndiceJunkCompassNorth: + L0005_i_IconIndex += _vm->_dungeonMan->_g308_partyDir; + break; + case k4_IconIndiceWeaponTorchUnlit: + if (((Weapon*)L0006_ps_Junk)->isLit()) { + L0005_i_IconIndex += g29_ChargeCountToTorchType[((Weapon*)L0006_ps_Junk)->getChargeCount()]; + } + break; + case k30_IconIndiceScrollOpen: + if (((Scroll*)L0006_ps_Junk)->getClosed()) { + L0005_i_IconIndex++; + } + break; + case k8_IconIndiceJunkWater: + case k12_IconIndiceJunkIllumuletUnequipped: + case k10_IconIndiceJunkJewelSymalUnequipped: + if (L0006_ps_Junk->getChargeCount()) { + L0005_i_IconIndex++; + } + break; + case k23_IconIndiceWeaponBoltBladeStormEmpty: + case k14_IconIndiceWeaponFlamittEmpty: + case k18_IconIndiceWeaponStormringEmpty: + case k25_IconIndiceWeaponFuryRaBladeEmpty: + case k16_IconIndiceWeaponEyeOfTimeEmpty: + case k20_IconIndiceWeaponStaffOfClawsEmpty: + if (((Weapon*)L0006_ps_Junk)->getChargeCount()) { + L0005_i_IconIndex++; + } } - break; - } - case k30_IconIndiceScrollOpen: - if (Scroll(rawType).getClosed()) { - iconIndex = (IconIndice)(iconIndex + 1); - } - break; - case k8_IconIndiceJunkWater: - case k12_IconIndiceJunkIllumuletUnequipped: - case k10_IconIndiceJunkJewelSymalUnequipped: - if (Junk(rawType).getChargeCount()) { - iconIndex = (IconIndice)(iconIndex + 1); - } - break; - case k23_IconIndiceWeaponBoltBladeStormEmpty: - case k14_IconIndiceWeaponFlamittEmpty: - case k18_IconIndiceWeaponStormringEmpty: - case k25_IconIndiceWeaponFuryRaBladeEmpty: - case k16_IconIndiceWeaponEyeOfTimeEmpty: - case k20_IconIndiceWeaponStaffOfClawsEmpty: - if (Weapon(rawType).getChargeCount()) { - iconIndex = (IconIndice)(iconIndex + 1); - } - break; - default: - break; } } - - return iconIndex; + return (IconIndice)L0005_i_IconIndex; } void ObjectMan::f36_extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) { - int16 i; - for (i = 0; i < 7; ++i) { - if (g26_IconGraphicFirstIndex[i] > iconIndex) + uint16 L0011_ui_Counter; + byte* L0012_pl_Bitmap_Icon; + Box L1568_s_Box; + + for (L0011_ui_Counter = 0; L0011_ui_Counter < 7; L0011_ui_Counter++) { + if (g26_IconGraphicFirstIndex[L0011_ui_Counter] > iconIndex) break; } - - --i; - byte *srcBitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k42_ObjectIcons_000_TO_031 + i); - iconIndex -= g26_IconGraphicFirstIndex[i]; + L0012_pl_Bitmap_Icon = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k42_ObjectIcons_000_TO_031 + --L0011_ui_Counter); + iconIndex -= g26_IconGraphicFirstIndex[L0011_ui_Counter]; _vm->_displayMan->_g578_useByteBoxCoordinates = true; - Box box(0, 0, 15, 15); - _vm->_displayMan->f132_blitToBitmap(srcBitmap, destBitmap, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency); + L1568_s_Box._y1 = 0; + L1568_s_Box._x1 = 0; + L1568_s_Box._y2 = 15; + L1568_s_Box._x2 = 15; + _vm->_displayMan->f132_blitToBitmap(L0012_pl_Bitmap_Icon, destBitmap, L1568_s_Box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, 8, kM1_ColorNoTransparency, gK77_IconGraphicHeight[L0011_ui_Counter], 16); } void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { - SlotBox *slotBox = &_g30_slotBoxes[slotBoxIndex]; - slotBox->_iconIndex = iconIndex; // yes, this modifies the global array - if (slotBox->_iconIndex == kM1_IconIndiceNone) { + uint16 L0015_ui_IconGraphicIndex; + int16 L0016_i_ByteWidth; + SlotBox* L0017_ps_SlotBox; + byte* L0018_puc_Bitmap_Icons; + Box L0019_s_Box; + byte* L0020_puc_Bitmap_Destination; + int16 L1569_i_Width; + + L0017_ps_SlotBox = &_vm->_objectMan->_g30_slotBoxes[slotBoxIndex]; + if ((L0017_ps_SlotBox->_iconIndex = iconIndex) == kM1_IconIndiceNone) { return; } - - Box box; - box._x1 = slotBox->_x; - box._y1 = slotBox->_y; - box._x2 = box._x1 + 15; - box._y2 = box._y1 + 15; - - uint16 iconGraphicIndex; - for (iconGraphicIndex = 0; iconGraphicIndex < 7; ++iconGraphicIndex) { - if (g26_IconGraphicFirstIndex[iconGraphicIndex] > iconIndex) { + L0019_s_Box._x2 = (L0019_s_Box._x1 = L0017_ps_SlotBox->_x) + 15; + L0019_s_Box._y2 = (L0019_s_Box._y1 = L0017_ps_SlotBox->_y) + 15; + for (L0015_ui_IconGraphicIndex = 0; L0015_ui_IconGraphicIndex < 7; L0015_ui_IconGraphicIndex++) { + if (g26_IconGraphicFirstIndex[L0015_ui_IconGraphicIndex] > iconIndex) break; - } } - iconGraphicIndex--; - byte *iconsBitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(iconGraphicIndex + k42_ObjectIcons_000_TO_031); - iconIndex -= g26_IconGraphicFirstIndex[iconGraphicIndex]; - - _vm->_displayMan->_g578_useByteBoxCoordinates = false; + L0015_ui_IconGraphicIndex--; + L0018_puc_Bitmap_Icons = _vm->_displayMan->f489_getNativeBitmapOrGraphic(L0015_ui_IconGraphicIndex + k42_ObjectIcons_000_TO_031); + iconIndex -= g26_IconGraphicFirstIndex[L0015_ui_IconGraphicIndex]; if (slotBoxIndex >= k8_SlotBoxInventoryFirstSlot) { - _vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g296_bitmapViewport, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k112_byteWidthViewport, kM1_ColorNoTransparency); - + L0020_puc_Bitmap_Destination = _vm->_displayMan->_g296_bitmapViewport; + L0016_i_ByteWidth = k112_byteWidthViewport; + L1569_i_Width = 136; } else { - _vm->_displayMan->f132_blitToBitmap(iconsBitmap, _vm->_displayMan->_g348_bitmapScreen, box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, 128, k160_byteWidthScreen, kM1_ColorNoTransparency); + L0020_puc_Bitmap_Destination = (unsigned char*)_vm->_displayMan->_g348_bitmapScreen; + L0016_i_ByteWidth = k160_byteWidthScreen; + L1569_i_Width = 200; } + _vm->_displayMan->_g578_useByteBoxCoordinates = false, _vm->_displayMan->f132_blitToBitmap(L0018_puc_Bitmap_Icons, L0020_puc_Bitmap_Destination, L0019_s_Box, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, k128_byteWidth, L0016_i_ByteWidth, kM1_ColorNoTransparency, gK77_IconGraphicHeight[L0015_ui_IconGraphicIndex], L1569_i_Width); } #define k14_ObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH -- cgit v1.2.3 From 0a0e79357d2495e376e3be408e0272072a96d233 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jul 2016 23:14:40 +0200 Subject: DM: Fix compilation using MSVC9 --- engines/dm/movesens.cpp | 2 +- engines/dm/projexpl.cpp | 4 ++-- engines/dm/timeline.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 2da2ee054b..80cc1cc204 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -1072,7 +1072,7 @@ void MovesensMan::f265_createEvent60to61_moveGroup(Thing groupThing, int16 mapX, L0696_s_Event._priority = 0; L0696_s_Event._B._location._mapX = mapX; L0696_s_Event._B._location._mapY = mapY; - L0696_s_Event._C._slot = groupThing; + L0696_s_Event._C._slot = groupThing.toUint16(); _vm->_timeline->f238_addEventGetEventIndex(&L0696_s_Event); } diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index 5ce7b20fd2..f773ffbc58 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -67,7 +67,7 @@ void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 L0468_s_Event._type = k48_TMEventTypeMoveProjectileIgnoreImpacts; /* Projectiles created by champions or creatures ignore impacts on their first movement */ } L0468_s_Event._priority = 0; - L0468_s_Event._B._slot = L0466_T_ProjectileThing; + L0468_s_Event._B._slot = L0466_T_ProjectileThing.toUint16(); L0468_s_Event._C._projectile.setMapX(mapX); L0468_s_Event._C._projectile.setMapY(mapY); L0468_s_Event._C._projectile.setStepEnergy(stepEnergy); @@ -337,7 +337,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC M33_setMapAndTime(L0476_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ((explThing == Thing::_explRebirthStep1) ? 5 : 1)); L0476_s_Event._type = k25_TMEventTypeExplosion; L0476_s_Event._priority = 0; - L0476_s_Event._C._slot = L0473_T_Thing; + L0476_s_Event._C._slot = L0473_T_Thing.toUint16(); L0476_s_Event._B._location._mapX = AP0443_ui_ProjectileMapX; L0476_s_Event._B._location._mapY = AP0444_ui_ProjectileMapY; _vm->_timeline->f238_addEventGetEventIndex(&L0476_s_Event); diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index 1c184e3980..5cf3f85a18 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -109,7 +109,7 @@ public: int16 _attack; int16 _defense; int16 _lightPower; - Thing _slot; + uint16 _slot; // Thing int16 _slotOrdinal; B_unionTimelineEvent() {} } _B; @@ -135,7 +135,7 @@ public: void setStepEnergy(uint16 val) { _backing = (_backing & ~(0xF << 12)) | ((val & 0xF) << 12); } } _projectile; - Thing _slot; + uint16 _slot; int16 _soundIndex; byte _ticks; C_uionTimelineEvent() {} -- cgit v1.2.3 From 8504f944e07d4a73f570e642476ae1819eb28568 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Jul 2016 23:27:13 +0200 Subject: DM: Fix style used for pointer casts --- engines/dm/champion.cpp | 30 +++++++-------- engines/dm/gfx.cpp | 100 ++++++++++++++++++++++++------------------------ engines/dm/movesens.cpp | 36 ++++++++--------- engines/dm/projexpl.cpp | 28 +++++++------- 4 files changed, 97 insertions(+), 97 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 90dbbf92dd..24cfda9225 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -229,8 +229,8 @@ void ChampionMan::f299_applyModifiersToStatistics(Champion* champ, int16 slotInd if (((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType)) && (slotIndex >= k0_ChampionSlotReadyHand) && (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) { - Weapon *weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(thing); - Armour *armour = (Armour*)_vm->_dungeonMan->f156_getThingData(thing); + Weapon *weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(thing); + Armour *armour = (Armour *)_vm->_dungeonMan->f156_getThingData(thing); if (((thingType == k5_WeaponThingType) && weapon->getCursed()) || ((thingType == k6_ArmourThingType) && armour->getCursed())) { statIndex = k0_ChampionStatLuck; @@ -477,13 +477,13 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch menuMan.f388_clearActingChampion(); if ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)) { - ((Scroll*)rawObjPtr)->setClosed(false); + ((Scroll *)rawObjPtr)->setClosed(false); f296_drawChangedObjectIcons(); } } if (iconIndex = k4_IconIndiceWeaponTorchUnlit) { - ((Weapon*)rawObjPtr)->setLit(true); + ((Weapon *)rawObjPtr)->setLit(true); _vm->_inventoryMan->f337_setDungeonViewPalette(); f296_drawChangedObjectIcons(); } else if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand) && @@ -494,12 +494,12 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch } else if (slotIndex == k10_ChampionSlotNeck) { if ((iconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (iconIndex <= k13_IconIndiceJunkIllumuletEquipped)) { - ((Junk*)rawObjPtr)->setChargeCount(1); + ((Junk *)rawObjPtr)->setChargeCount(1); _g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2]; _vm->_inventoryMan->f337_setDungeonViewPalette(); iconIndex = (IconIndice)(iconIndex + 1); } else if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) { - ((Junk*)rawObjPtr)->setChargeCount(1); + ((Junk *)rawObjPtr)->setChargeCount(1); iconIndex = (IconIndice)(iconIndex + 1); } @@ -625,15 +625,15 @@ Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotI L0898_B_IsInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal); L0895_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0894_T_Thing); f299_applyModifiersToStatistics(L0896_ps_Champion, slotIndex, L0895_i_IconIndex, -1, L0894_T_Thing); /* Remove objet modifiers */ - L0897_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0894_T_Thing); + L0897_ps_Weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(L0894_T_Thing); if (slotIndex == k10_ChampionSlotNeck) { if ((L0895_i_IconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (L0895_i_IconIndex <= k13_IconIndiceJunkIllumuletEquipped)) { - ((Junk*)L0897_ps_Weapon)->setChargeCount(0); + ((Junk *)L0897_ps_Weapon)->setChargeCount(0); _g407_party._magicalLightAmount -= g39_LightPowerToLightAmount[2]; _vm->_inventoryMan->f337_setDungeonViewPalette(); } else { if ((L0895_i_IconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (L0895_i_IconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) { - ((Junk*)L0897_ps_Weapon)->setChargeCount(0); + ((Junk *)L0897_ps_Weapon)->setChargeCount(0); } } } @@ -648,7 +648,7 @@ Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotI _vm->_menuMan->f388_clearActingChampion(); } if ((L0895_i_IconIndex >= k30_IconIndiceScrollOpen) && (L0895_i_IconIndex <= k31_IconIndiceScrollClosed)) { - ((Scroll*)L0897_ps_Weapon)->setClosed(true); + ((Scroll *)L0897_ps_Weapon)->setClosed(true); f296_drawChangedObjectIcons(); } } @@ -755,7 +755,7 @@ T0321024: goto T0321004; if (attack > (AL0976_i_AdjustedAttack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k4_ChampionStatVitality, _vm->_rnd->getRandomNumber(127) + 10))) { /* BUG0_45 This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the probability of being wounded. However if it was fixed, the behavior would be the opposite of what it should: the higher the vitality of a champion, the lower the result of F0307_CHAMPION_GetStatisticAdjustedAttack and the more likely the champion could get wounded (because of more iterations in the loop below) */ do { - setFlag(*(uint16*)&_g410_championPendingWounds[champIndex], (1 << _vm->_rnd->getRandomNumber(7)) & allowedWounds); + setFlag(*(uint16 *)&_g410_championPendingWounds[champIndex], (1 << _vm->_rnd->getRandomNumber(7)) & allowedWounds); } while ((attack > (AL0976_i_AdjustedAttack <<= 1)) && AL0976_i_AdjustedAttack); } if (_g300_partyIsSleeping) { @@ -785,8 +785,8 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) { } for (L0943_ui_ArmourShieldDefense = 0, AL0942_i_SlotIndex = k0_ChampionSlotReadyHand; AL0942_i_SlotIndex <= k1_ChampionSlotActionHand; AL0942_i_SlotIndex++) { if ((L0945_T_Thing = L0946_ps_Champion->_slots[AL0942_i_SlotIndex]).getType() == k6_ArmourThingType) { - L0947_ps_ArmourInfo = (ArmourInfo*)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing); - L0947_ps_ArmourInfo = &g239_ArmourInfo[((Armour*)L0947_ps_ArmourInfo)->getType()]; + L0947_ps_ArmourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing); + L0947_ps_ArmourInfo = &g239_ArmourInfo[((Armour *)L0947_ps_ArmourInfo)->getType()]; if (getFlag(L0947_ps_ArmourInfo->_attributes, k0x0080_ArmourAttributeIsAShield)) { L0943_ui_ArmourShieldDefense += ((f312_getStrength(champIndex, AL0942_i_SlotIndex) + _vm->_dungeonMan->f143_getArmourDefense(L0947_ps_ArmourInfo, L0944_B_UseSharpDefense)) * g50_woundDefenseFactor[woundIndex]) >> ((AL0942_i_SlotIndex == woundIndex) ? 4 : 5); } @@ -798,8 +798,8 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) { } AL0942_i_WoundDefense += L0946_ps_Champion->_actionDefense + L0946_ps_Champion->_shieldDefense + _g407_party._shieldDefense + L0943_ui_ArmourShieldDefense; if ((woundIndex > k1_ChampionSlotActionHand) && ((L0945_T_Thing = L0946_ps_Champion->_slots[woundIndex]).getType() == k6_ArmourThingType)) { - L0947_ps_ArmourInfo = (ArmourInfo*)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing); - AL0942_i_WoundDefense += _vm->_dungeonMan->f143_getArmourDefense(&g239_ArmourInfo[((Armour*)L0947_ps_ArmourInfo)->getType()], L0944_B_UseSharpDefense); + L0947_ps_ArmourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing); + AL0942_i_WoundDefense += _vm->_dungeonMan->f143_getArmourDefense(&g239_ArmourInfo[((Armour *)L0947_ps_ArmourInfo)->getType()], L0944_B_UseSharpDefense); } if (getFlag(L0946_ps_Champion->_wounds, 1 << woundIndex)) { AL0942_i_WoundDefense -= 8 + _vm->getRandomNumber(4); diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 25f0e4bd59..a6dd0874f5 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1040,7 +1040,7 @@ void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButt } bitmap = f492_getDerivedBitmap(doorButtonOrdinal); } - f132_blitToBitmap(bitmap, _g296_bitmapViewport, *(Box*)coordSetRedEagle, 0, 0, + f132_blitToBitmap(bitmap, _g296_bitmapViewport, *(Box *)coordSetRedEagle, 0, 0, coordSetRedEagle[4], k112_byteWidthViewport, k10_ColorFlesh, coordSetRedEagle[5], k136_heightViewport); } } @@ -1327,7 +1327,7 @@ void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloor bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); } f132_blitToBitmap(bitmap, _g296_bitmapViewport, - *(Box*)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport); + *(Box *)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport); T0108005: if (drawFootprints) { f108_drawFloorOrnament(_vm->M0_indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex); @@ -1343,7 +1343,7 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d doorFramesTemp = doorFrames; if (doorState != k0_doorState_OPEN) { - door = (Door*)(_vm->_dungeonMan->_g284_thingData[k0_DoorThingType]) + doorThingIndex; + door = (Door *)(_vm->_dungeonMan->_g284_thingData[k0_DoorThingType]) + doorThingIndex; memmove(_g74_tmpBitmap, f489_getNativeBitmapOrGraphic(doorNativeBitmapIndices[doorType = door->getType()]), byteCount * 2); f109_drawDoorOrnament(door->getOrnOrdinal(), viewDoorOrnIndex); if (getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[doorType]._attributes, k0x0004_MaskDoorInfo_Animated)) { @@ -1421,7 +1421,7 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn } } f132_blitToBitmap(bitmap, _g74_tmpBitmap, - *(Box*)coordSetOrangeElk, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height); + *(Box *)coordSetOrangeElk, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height); } } @@ -1583,7 +1583,7 @@ void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) { f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44); f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g165_Frame_DoorFrameRight_D3R); - if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { + if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k0_viewDoorButton_D3R); } f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], @@ -1627,7 +1627,7 @@ void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) { int16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY); switch (squareAspect[k0_ElemAspect]) { case k19_ElementTypeStaisFront: if (squareAspect[k2_StairsUpAspect]) { @@ -1649,7 +1649,7 @@ void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) { f100_drawWallSetBitmap(_g706_bitmapWallSet_DoorFrameLeft_D3C, g166_Frame_DoorFrameLeft_D3C); memmove(_g74_tmpBitmap, _g706_bitmapWallSet_DoorFrameLeft_D3C, 32 * 44); f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g167_Frame_DoorFrameRight_D3C); - if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { + if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k1_ViewDoorOrnament_D2LCR); } f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], @@ -1691,7 +1691,7 @@ void DisplayMan::f119_drawSquareD2L(direction dir, int16 posX, int16 posY) { int16 order; int16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY); switch (squareAspect[k0_ElemAspect]) { case k19_ElementTypeStaisFront: if (squareAspect[k2_StairsUpAspect]) { @@ -1758,7 +1758,7 @@ void DisplayMan::f120_drawSquareD2R(direction dir, int16 posX, int16 posY) { int16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY); switch (squareAspect[k0_ElemAspect]) { case k19_ElementTypeStaisFront: if (squareAspect[k2_StairsUpAspect]) { @@ -1826,7 +1826,7 @@ void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) { int16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY); switch (squareAspect[k0_ElemAspect]) { case k19_ElementTypeStaisFront: if (squareAspect[k2_StairsUpAspect]) { @@ -1849,7 +1849,7 @@ void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) { f100_drawWallSetBitmap(_g707_bitmapWallSet_DoorFrameLeft_D2C, g168_Frame_DoorFrameLeft_D2C); memcpy(_g74_tmpBitmap, _g707_bitmapWallSet_DoorFrameLeft_D2C, 48 * 65); f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g169_Frame_DoorFrameRight_D2C); - if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { + if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k2_viewDoorButton_D2C); } f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], @@ -1892,7 +1892,7 @@ void DisplayMan::f122_drawSquareD1L(direction dir, int16 posX, int16 posY) { int16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY); switch (squareAspect[k0_ElemAspect]) { case k19_ElementTypeStaisFront: if (squareAspect[k2_StairsUpAspect]) { @@ -2013,7 +2013,7 @@ void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) { byte* bitmap; - _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY); switch (_vm->_dungeonMan->_g285_squareAheadElement = (ElementType)squareAspect[k0_ElemAspect]) { case k19_ElementTypeStaisFront: if (squareAspect[k2_StairsUpAspect]) { @@ -2062,7 +2062,7 @@ void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) { f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g177_Frame_DoorFrameTop_D1C); f100_drawWallSetBitmap(_g708_bitmapWallSet_DoorFrameLeft_D1C, g170_Frame_DoorFrameLeft_D1C); f100_drawWallSetBitmap(_g710_bitmapWallSet_DoorFrameRight_D1C, g171_Frame_DoorFrameRight_D1C); - if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { + if (((Door *)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C); } f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], @@ -2134,7 +2134,7 @@ void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) { int16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + _vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY); switch (squareAspect[k0_ElemAspect]) { case k16_DoorSideElemType: if (_vm->_championMan->_g407_party._event73Count_ThievesEye) { @@ -2653,7 +2653,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall } } f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport, - *(Box*)AL0090_puc_CoordinateSet, AL0089_i_X, 0, + *(Box *)AL0090_puc_CoordinateSet, AL0089_i_X, 0, AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport); /* BUG0_05 A champion portrait sensor on a wall square is visible on all sides of the wall. If there is another sensor with a wall ornament on one side of the wall then the champion portrait is drawn over that wall ornament */ @@ -2894,9 +2894,9 @@ void DisplayMan::f115_cthulhu(Thing thingParam, direction directionParam, int16 DungeonMan &dunMan = *_vm->_dungeonMan; // AL_0 shared - uint16 &AL_0_creatureIndexRed = *(uint16*)&thingParam; - uint16 &AL_0_creatureGraphicInfoRed = *(uint16*)&thingParam; - uint16 &AL_0_creaturePosX = *(uint16*)&thingParam; + uint16 &AL_0_creatureIndexRed = *(uint16 *)&thingParam; + uint16 &AL_0_creatureGraphicInfoRed = *(uint16 *)&thingParam; + uint16 &AL_0_creaturePosX = *(uint16 *)&thingParam; // AL_1 shared int16 &AL_1_viewSquareExplosionIndex = viewSquareIndex; // AL_2 shared @@ -3190,14 +3190,14 @@ T0115015_DrawProjectileAsObject: if ((groupThing == Thing::_none) || drawCreaturesCompleted) goto T0115129_DrawProjectiles; /* Skip code to draw creatures */ if (group == nullptr) { /* If all creature data and info has not already been gathered */ - group = (Group*)dunMan.f156_getThingData(groupThing); + group = (Group *)dunMan.f156_getThingData(groupThing); activeGroup = &_vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]; creatureInfo = &g243_CreatureInfo[group->_type]; creatureAspectStruct = &g219_CreatureAspects[creatureInfo->_creatureAspectIndex]; creatureSize = getFlag(creatureInfo->_attributes, k0x0003_MaskCreatureInfo_size); creatureGraphicInfoGreen = creatureInfo->_graphicInfo; } - objectAspect = (ObjectAspect*)creatureAspectStruct; + objectAspect = (ObjectAspect *)creatureAspectStruct; if (AL_0_creatureIndexRed = _vm->_groupMan->f176_getCreatureOrdinalInCell(group, cellYellowBear)) { /* If there is a creature on the cell being processed */ AL_0_creatureIndexRed--; /* Convert ordinal to index */ creatureIndexGreen = AL_0_creatureIndexRed; @@ -3261,26 +3261,26 @@ T0115015_DrawProjectileAsObject: viewSquareIndex--; } T0115077_DrawSecondHalfSquareCreature: - coordinateSet = g224_CreatureCoordinateSets[((CreatureAspect*)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell]; + coordinateSet = g224_CreatureCoordinateSets[((CreatureAspect *)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell]; if (!coordinateSet[1]) goto T0115126_CreatureNotVisible; AL_0_creatureGraphicInfoRed = creatureGraphicInfoGreen; - AL_4_nativeBitmapIndex = k446_FirstCreatureGraphicIndice + ((CreatureAspect*)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */ - derivedBitmapIndex = ((CreatureAspect*)objectAspect)->_firstDerivedBitmapIndex; + AL_4_nativeBitmapIndex = k446_FirstCreatureGraphicIndice + ((CreatureAspect *)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */ + derivedBitmapIndex = ((CreatureAspect *)objectAspect)->_firstDerivedBitmapIndex; if (useCreatureSideBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide) && (creatureDirectionDelta & 0x0001)) { useCreatureAttackBitmap = useFlippedHorizontallyCreatureFrontImage = useCreatureBackBitmap = false; AL_4_nativeBitmapIndex++; /* Skip the front image. Side image is right after the front image */ derivedBitmapIndex += 2; - sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthSide; - sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightSide; + sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthSide; + sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightSide; } else { useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0); if (useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, k0x0080_MaskActiveGroupIsAttacking) && getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack)) { useFlippedHorizontallyCreatureFrontImage = false; - sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthAttack; - sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightAttack; + sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthAttack; + sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightAttack; AL_4_nativeBitmapIndex++; /* Skip the front image */ derivedBitmapIndex += 2; if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) { @@ -3292,8 +3292,8 @@ T0115077_DrawSecondHalfSquareCreature: derivedBitmapIndex += 2; } } else { - sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthFront; - sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightFront; + sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthFront; + sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightFront; if (useCreatureBackBitmap) { useFlippedHorizontallyCreatureFrontImage = false; if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) { @@ -3323,7 +3323,7 @@ T0115077_DrawSecondHalfSquareCreature: if (viewSquareIndex >= k6_ViewSquare_D1C) { /* Creature is on D1 */ creaturePaddingPixelCount = 0; AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front; - transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour(); + transparentColor = ((CreatureAspect *)objectAspect)->getTranspColour(); if (useCreatureSideBitmap) { AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); if (creatureDirectionDelta == 1) { @@ -3372,7 +3372,7 @@ T0115077_DrawSecondHalfSquareCreature: } byteWidth = M78_getScaledDimension(sourceByteWidth, scale); heightRedEagle = M78_getScaledDimension(sourceHeight, scale); - transparentColor = paletteChanges[((CreatureAspect*)objectAspect)->getTranspColour()] / 10; + transparentColor = paletteChanges[((CreatureAspect *)objectAspect)->getTranspColour()] / 10; if (derivedBitmapInCache = f491_isDerivedBitmapInCache(derivedBitmapIndex)) { AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); } else { @@ -3444,24 +3444,24 @@ continue; do { if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) { - projectile = (Projectile*)dunMan.f156_getThingData(thingParam); + projectile = (Projectile *)dunMan.f156_getThingData(thingParam); if ((AL_4_projectileAspect = dunMan.f142_getProjectileAspect(projectile->_slot)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */ - objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)]; - AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice; - projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask); - if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) + objectAspect = (ObjectAspect *)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-AL_4_projectileAspect)]; + AL_4_nativeBitmapIndex = ((ProjectileAspect *)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice; + projectileAspectType = getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask); + if (((doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask)) || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == k9_ViewSquare_D0C)) { scale = 0; /* Use native bitmap without resizing */ - byteWidth = ((ProjectileAspect*)objectAspect)->_byteWidth; - heightRedEagle = ((ProjectileAspect*)objectAspect)->_height; + byteWidth = ((ProjectileAspect *)objectAspect)->_byteWidth; + heightRedEagle = ((ProjectileAspect *)objectAspect)->_height; } else { AL_8_projectileScaleIndex = ((viewSquareIndex / 3) << 1) + (AL_2_viewCell >> 1); scale = g215_ProjectileScales[AL_8_projectileScaleIndex]; if (!doNotScaleWithKineticEnergy) { scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8; } - byteWidth = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_byteWidth, scale); - heightRedEagle = M78_getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale); + byteWidth = M78_getScaledDimension(((ProjectileAspect *)objectAspect)->_byteWidth, scale); + heightRedEagle = M78_getScaledDimension(((ProjectileAspect *)objectAspect)->_height, scale); } if (projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == k0_ProjectileAspectHasBackGraphicRotation)) { projectileFlipVertical = ((mapXpos + mapYpos) & 0x0001); @@ -3496,7 +3496,7 @@ continue; projectileBitmapIndexData = 1; } flipVertical = projectileAspectTypeHasBackGraphicAndRotation && (AL_2_viewCell < k2_ViewCellBackRight); - flipHorizontal = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0010_ProjectileSideMask) + flipHorizontal = getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0010_ProjectileSideMask) && !((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight)))); } } @@ -3508,7 +3508,7 @@ continue; if (flipHorizontal) { paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1; } - derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6); + derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect *)objectAspect)->_firstNativeBitmapRelativeIndex + (projectileBitmapIndexData * 6); if (doNotScaleWithKineticEnergy && f491_isDerivedBitmapInCache(derivedBitmapIndex) + AL_8_projectileScaleIndex) { AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); } else { @@ -3518,7 +3518,7 @@ continue; } else { AL_6_bitmapRedBanana = _g74_tmpBitmap; } - f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_byteWidth * 2, ((ProjectileAspect*)objectAspect)->_height, + f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect *)objectAspect)->_byteWidth * 2, ((ProjectileAspect *)objectAspect)->_height, byteWidth * 2, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]); if (doNotScaleWithKineticEnergy) { warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap"); @@ -3583,7 +3583,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; do { if (thingParam.getType() == k15_ExplosionThingType) { AL_2_cellPurpleMan = thingParam.getCell(); - explosion = (Explosion*)dunMan.f156_getThingData(thingParam); + explosion = (Explosion *)dunMan.f156_getThingData(thingParam); if ((rebirthExplosion = ((unsigned int)(AL_4_explosionType = explosion->getType()) >= k100_ExplosionType_RebirthStep1)) && ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion) || (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion) @@ -3601,14 +3601,14 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke; } else { if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) { - objectAspect = (ObjectAspect*)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-dunMan.f142_getProjectileAspect(Thing::_explLightningBolt))]; - AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1)); + objectAspect = (ObjectAspect *)&g210_ProjectileAspect[_vm->M1_ordinalToIndex(-dunMan.f142_getProjectileAspect(Thing::_explLightningBolt))]; + AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(((ProjectileAspect *)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1)); explosionCoordinates = g228_RebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3]; - byteWidth = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]); - heightRedEagle = M78_getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]); + byteWidth = M78_getScaledDimension((((ProjectileAspect *)objectAspect)->_byteWidth), explosionCoordinates[2]); + heightRedEagle = M78_getScaledDimension((((ProjectileAspect *)objectAspect)->_height), explosionCoordinates[2]); if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) { f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, - ((ProjectileAspect*)objectAspect)->_byteWidth * 2, ((ProjectileAspect*)objectAspect)->_height, + ((ProjectileAspect *)objectAspect)->_byteWidth * 2, ((ProjectileAspect *)objectAspect)->_height, byteWidth * 2, heightRedEagle, g17_PalChangesNoChanges); AL_6_bitmapRedBanana = _g74_tmpBitmap; } diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 80cc1cc204..cb73d3f9a4 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -90,7 +90,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui while (L0750_T_ThingBeingProcessed != Thing::_endOfList) { if ((L0751_ui_ThingType = (L0750_T_ThingBeingProcessed).getType()) == k3_SensorThingType) { L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell = (L0750_T_ThingBeingProcessed).getCell()]--; - L0755_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0750_T_ThingBeingProcessed); + L0755_ps_Sensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0750_T_ThingBeingProcessed); if ((L0757_ui_SensorType = (L0755_ps_Sensor)->getType()) == k0_SensorDisabled) goto T0275058_ProceedToNextThing; if ((_vm->_championMan->_g411_leaderIndex == kM1_ChampionNone) && (L0757_ui_SensorType != k127_SensorWallChampionPortrait)) @@ -119,7 +119,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) { if (L0763_T_LastProcessedThing == L0750_T_ThingBeingProcessed) /* If the sensor is the only one of its type on the cell */ break; - L0765_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0763_T_LastProcessedThing); + L0765_ps_Sensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0763_T_LastProcessedThing); L0765_ps_Sensor->setNextThing(L0755_ps_Sensor->getNextThing()); L0755_ps_Sensor->setNextThing(Thing::_none); L0750_T_ThingBeingProcessed = L0763_T_LastProcessedThing; @@ -184,7 +184,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } if (!_vm->_championMan->_g415_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) { - L0754_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0761_T_LeaderHandObject); + L0754_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0761_T_LeaderHandObject); *L0754_ps_Generic = Thing::_none; _vm->_championMan->f298_getObjectRemovedFromLeaderHand(); L0761_T_LeaderHandObject = Thing::_none; @@ -280,15 +280,15 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 } } if (L0710_i_ThingType == k14_ProjectileThingType) { - L0712_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(thing); - _g400_moveResultDir = (_vm->_timeline->_g370_events[((Projectile*)L0712_ps_Teleporter)->_eventIndex])._C._projectile.getDir(); + L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f156_getThingData(thing); + _g400_moveResultDir = (_vm->_timeline->_g370_events[((Projectile *)L0712_ps_Teleporter)->_eventIndex])._C._projectile.getDir(); } for (L0728_i_ChainedMoveCount = 1000; --L0728_i_ChainedMoveCount; ) { /* No more than 1000 chained moves at once (in a chain of teleporters and pits for example) */ AL0708_i_DestinationSquare = _vm->_dungeonMan->_g271_currMapData[destMapX][destMapY]; if ((AL0709_i_DestinationSquareType = Square(AL0708_i_DestinationSquare).getType()) == k5_ElementTypeTeleporter) { if (!getFlag(AL0708_i_DestinationSquare, k0x0008_TeleporterOpen)) break; - L0712_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(destMapX, destMapY); + L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f157_getSquareFirstThingData(destMapX, destMapY); if ((L0712_ps_Teleporter->getScope() == k0x0001_TelepScopeCreatures) && (L0710_i_ThingType != k4_GroupThingType)) break; if ((L0718_i_RequiredTeleporterScope != (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty)) && !getFlag(L0712_ps_Teleporter->getScope(), L0718_i_RequiredTeleporterScope)) @@ -363,7 +363,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 } else { if (L0710_i_ThingType == k4_GroupThingType) { _vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource); - AL0727_ui_Outcome = _vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group*)_vm->_dungeonMan->f156_getThingData(thing), mapX, mapY, 20, false); + AL0727_ui_Outcome = _vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group *)_vm->_dungeonMan->f156_getThingData(thing), mapX, mapY, 20, false); _vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination); if (L0722_B_FallKilledGroup = (AL0727_ui_Outcome == k2_outcomeKilledAllCreaturesInGroup)) break; @@ -468,8 +468,8 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 } else { if (L0710_i_ThingType == k4_GroupThingType) { _vm->_dungeonMan->f173_setCurrentMap(L0715_ui_MapIndexDestination); - L0712_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(thing); - AL0708_i_ActiveGroupIndex = ((Group*)L0712_ps_Teleporter)->getActiveGroupIndex(); + L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f156_getThingData(thing); + AL0708_i_ActiveGroupIndex = ((Group *)L0712_ps_Teleporter)->getActiveGroupIndex(); if (((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_g309_partyMapIndex) && (destMapX == _vm->_dungeonMan->_g306_partyMapX) && (destMapY == _vm->_dungeonMan->_g307_partyMapY)) || (_vm->_groupMan->f175_groupGetThing(destMapX, destMapY) != Thing::_endOfList)) { /* If a group tries to move to the party square or over another group then create an event to move the group later */ _vm->_dungeonMan->f173_setCurrentMap(L0714_ui_MapIndexSource); if (mapX >= 0) { @@ -481,7 +481,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 f265_createEvent60to61_moveGroup(thing, destMapX, destMapY, L0715_ui_MapIndexDestination, L0726_B_Audible); return true; /* The specified group thing cannot be moved because the party or another group is on the destination square */ } - L1638_ui_MovementSoundIndex = f514_getSound(((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[(thing).getIndex()]._type); + L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[(thing).getIndex()]._type); if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) { warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } @@ -573,7 +573,7 @@ bool MovesensMan::f266_moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMa } } else { L0702_i_ImpactType = kM1_CreatureElemType; - L0701_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing); + L0701_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(thing); for (AL0699_ui_Cell = k0_CellNorthWest, AL0700_B_CreatureAlive = false; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) { AL0700_B_CreatureAlive |= L0701_ps_Group->_health[AL0699_ui_Cell]; if (_vm->_groupMan->f176_getCreatureOrdinalInCell(L0701_ps_Group, AL0699_ui_Cell)) { @@ -608,7 +608,7 @@ T0266017_CheckProjectileImpacts: L0697_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0704_ui_ProjectileMapX, L0705_ui_ProjectileMapY); while (L0697_T_Thing != Thing::_endOfList) { if (((L0697_T_Thing).getType() == k14_ProjectileThingType) && - (_vm->_timeline->_g370_events[(((Projectile*)_vm->_dungeonMan->_g284_thingData[k14_ProjectileThingType])[(L0697_T_Thing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[(L0697_T_Thing).getCell()]) && + (_vm->_timeline->_g370_events[(((Projectile *)_vm->_dungeonMan->_g284_thingData[k14_ProjectileThingType])[(L0697_T_Thing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[(L0697_T_Thing).getCell()]) && _vm->_projexpl->f217_projectileHasImpactOccurred(L0702_i_ImpactType, srcMapX, srcMapY, _vm->M1_ordinalToIndex(AL0699_ui_ChampionOrCreatureOrdinal), L0697_T_Thing)) { _vm->_projexpl->f214_projectileDeleteEvent(L0697_T_Thing); if (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup) { @@ -700,7 +700,7 @@ int16 MovesensMan::f262_getTeleporterRotatedGroupResult(Teleporter* teleporter, int16 L0691_i_CreatureSize; int16 L0692_i_RelativeRotation; - L0686_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing); + L0686_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(thing); L0683_i_Rotation = teleporter->getRotation(); L0684_ui_GroupDirections = _vm->_groupMan->f147_getGroupDirections(L0686_ps_Group, mapIndex); if (L0689_B_AbsoluteRotation = teleporter->getAbsoluteRotation()) { @@ -817,7 +817,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m L0766_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY); while (L0766_T_Thing != Thing::_endOfList) { if ((L0771_ui_ThingType = (L0766_T_Thing).getType()) == k3_SensorThingType) { - L0769_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0766_T_Thing); + L0769_ps_Sensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0766_T_Thing); if ((L0769_ps_Sensor)->getType() == k0_SensorDisabled) goto T0276079; L0779_i_SensorData = L0769_ps_Sensor->getData(); @@ -940,7 +940,7 @@ T0274003: return true; } if (L0747_i_ObjectType == k144_IconIndiceContainerChestClosed) { - L0749_ps_Container = (Container*)_vm->_dungeonMan->f156_getThingData(L0744_T_Thing); + L0749_ps_Container = (Container *)_vm->_dungeonMan->f156_getThingData(L0744_T_Thing); L0744_T_Thing = L0749_ps_Container->getSlot(); while (L0744_T_Thing != Thing::_endOfList) { if (_vm->_objectMan->f32_getObjectType(L0744_T_Thing) == objectType) { @@ -1042,7 +1042,7 @@ void MovesensMan::f271_processRotationEffect() { while (((L0732_T_FirstSensorThing).getType() != k3_SensorThingType) || ((_g406_sensorRotationEffCell != kM1_CellAny) && ((L0732_T_FirstSensorThing).getCell() != _g406_sensorRotationEffCell))) { L0732_T_FirstSensorThing = _vm->_dungeonMan->f159_getNextThing(L0732_T_FirstSensorThing); } - L0734_ps_FirstSensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0732_T_FirstSensorThing); + L0734_ps_FirstSensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0732_T_FirstSensorThing); L0733_T_LastSensorThing = L0734_ps_FirstSensor->getNextThing(); while ((L0733_T_LastSensorThing != Thing::_endOfList) && (((L0733_T_LastSensorThing).getType() != k3_SensorThingType) || ((_g406_sensorRotationEffCell != kM1_CellAny) && ((L0733_T_LastSensorThing).getCell() != _g406_sensorRotationEffCell)))) { L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing); @@ -1050,11 +1050,11 @@ void MovesensMan::f271_processRotationEffect() { if (L0733_T_LastSensorThing == Thing::_endOfList) break; _vm->_dungeonMan->f164_unlinkThingFromList(L0732_T_FirstSensorThing, Thing(0), _g404_sensorRotationEffMapX, _g405_sensorRotationEffMapY); - L0735_ps_LastSensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0733_T_LastSensorThing); + L0735_ps_LastSensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0733_T_LastSensorThing); L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing); while (((L0733_T_LastSensorThing != Thing::_endOfList) && ((L0733_T_LastSensorThing).getType() == k3_SensorThingType))) { if ((_g406_sensorRotationEffCell == kM1_CellAny) || ((L0733_T_LastSensorThing).getCell() == _g406_sensorRotationEffCell)) { - L0735_ps_LastSensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0733_T_LastSensorThing); + L0735_ps_LastSensor = (Sensor *)_vm->_dungeonMan->f156_getThingData(L0733_T_LastSensorThing); } L0733_T_LastSensorThing = _vm->_dungeonMan->f159_getNextThing(L0733_T_LastSensorThing); } diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index f773ffbc58..4c0821487d 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -55,7 +55,7 @@ void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 return; } L0466_T_ProjectileThing = M15_thingWithNewCell(L0466_T_ProjectileThing, cell); - L0467_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(L0466_T_ProjectileThing); + L0467_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(L0466_T_ProjectileThing); L0467_ps_Projectile->_slot = thing; L0467_ps_Projectile->_kineticEnergy = MIN((int16)kineticEnergy, (int16)255); L0467_ps_Projectile->_attack = attack; @@ -111,14 +111,14 @@ bool ProjExpl::f217_projectileHasImpactOccurred(int16 impactType, int16 mapXComb uint16 L0511_ui_CreatureType; uint16 L0512_ui_CreatureIndex; - L0490_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(Thing(projectileThing)); + L0490_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(Thing(projectileThing)); L0501_i_MapXCombo = mapXCombo; L0502_i_MapYCombo = mapYCombo; L0509_B_RemovePotion = false; _g364_creatureDamageOutcome = k0_outcomeKilledNoCreaturesInGroup; if ((L0510_i_ProjectileAssociatedThingType = (L0486_T_ProjectileAssociatedThing = L0490_ps_Projectile->_slot).getType()) == k8_PotionThingType) { - L0491_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0486_T_ProjectileAssociatedThing); - switch (((Potion*)L0491_ps_Group)->getType()) { + L0491_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0486_T_ProjectileAssociatedThing); + switch (((Potion *)L0491_ps_Group)->getType()) { case k3_PotionTypeVen: L0498_T_ExplosionThing = Thing::_explPoisonCloud; goto T0217004; @@ -126,8 +126,8 @@ bool ProjExpl::f217_projectileHasImpactOccurred(int16 impactType, int16 mapXComb L0498_T_ExplosionThing = Thing::_explFireBall; T0217004: L0509_B_RemovePotion = true; - L0508_i_PotionPower = ((Potion*)L0491_ps_Group)->getPower(); - L0492_ps_Potion = (Potion*)L0491_ps_Group; + L0508_i_PotionPower = ((Potion *)L0491_ps_Group)->getPower(); + L0492_ps_Potion = (Potion *)L0491_ps_Group; } } L0505_B_CreateExplosionOnImpact = (L0510_i_ProjectileAssociatedThingType == k15_ExplosionThingType) && (L0486_T_ProjectileAssociatedThing != Thing::_explSlime) && (L0486_T_ProjectileAssociatedThing != Thing::_explPoisonBolt); @@ -145,7 +145,7 @@ T0217004: switch (impactType) { case k4_DoorElemType: AL0487_i_DoorState = Square(L0503_uc_Square = _vm->_dungeonMan->_g271_currMapData[AP0454_i_ProjectileTargetMapX][AP0455_i_ProjectileTargetMapY]).getDoorState(); - L0494_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY); + L0494_ps_Door = (Door *)_vm->_dungeonMan->f157_getSquareFirstThingData(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY); if ((AL0487_i_DoorState != k5_doorState_DESTROYED) && (L0486_T_ProjectileAssociatedThing == Thing::_explOpenDoor)) { if (L0494_ps_Door->hasButton()) { _vm->_movsens->f268_addEvent(k10_TMEventTypeDoor, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1); @@ -175,7 +175,7 @@ T0217004: L0489_i_ChampionAttack = L0488_i_Attack = f216_projectileGetImpactAttack(L0490_ps_Projectile, L0486_T_ProjectileAssociatedThing); break; case kM1_CreatureElemType: - L0491_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY)); + L0491_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY)); if (!(L0512_ui_CreatureIndex = _vm->_groupMan->f176_getCreatureOrdinalInCell(L0491_ps_Group, cell))) { return false; } @@ -198,7 +198,7 @@ T0217004: (AL0487_i_Outcome == k0_outcomeKilledNoCreaturesInGroup) && (L0510_i_ProjectileAssociatedThingType == k5_WeaponThingType) && getFlag(L0493_ps_CreatureInfo->_attributes, k0x0400_MaskCreatureInfo_keepThrownSharpWeapon)) { - L0495_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0486_T_ProjectileAssociatedThing); + L0495_ps_Weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(L0486_T_ProjectileAssociatedThing); AL0487_i_WeaponType = L0495_ps_Weapon->getType(); if ((AL0487_i_WeaponType == k8_WeaponTypeDagger) || (AL0487_i_WeaponType == k27_WeaponTypeArrow) || (AL0487_i_WeaponType == k28_WeaponTypeSlayer) || (AL0487_i_WeaponType == k31_WeaponTypePoisonDart) || (AL0487_i_WeaponType == k32_WeaponTypeThrowingStar)) { L0497_pT_GroupSlot = &L0491_ps_Group->_slot; @@ -307,7 +307,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC if ((L0473_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType)) == Thing::_none) { return; } - L0470_ps_Explosion = &((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[(L0473_T_Thing).getIndex()]; + L0470_ps_Explosion = &((Explosion *)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[(L0473_T_Thing).getIndex()]; if (mapXCombo <= 255) { L0474_i_ProjectileTargetMapX = mapXCombo; L0475_i_ProjectileTargetMapY = mapYCombo; @@ -351,7 +351,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC _vm->_championMan->f324_damageAll_getDamagedChampionCount(attack, k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand | k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k1_attackType_FIRE); } else { if ((L0473_T_Thing = _vm->_groupMan->f175_groupGetThing(AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY)) != Thing::_endOfList) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */ - L0472_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0473_T_Thing); + L0472_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0473_T_Thing); L0471_ps_CreatureInfo = &g243_CreatureInfo[L0472_ps_Group->_type]; if ((L0469_i_CreatureFireResistance = (L0471_ps_CreatureInfo->M60_getFireResistance())) != k15_immuneToFire) { if (getFlag(L0471_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) { @@ -395,7 +395,7 @@ void ProjExpl::f214_projectileDeleteEvent(Thing thing) { Projectile* L0477_ps_Projectile; - L0477_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(thing); + L0477_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(thing); _vm->_timeline->f237_deleteEvent(L0477_ps_Projectile->_eventIndex); } @@ -405,11 +405,11 @@ void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, in Projectile* L0480_ps_Projectile; Thing* L0481_ps_Generic; - L0480_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(projectileThing); + L0480_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(projectileThing); if ((L0479_T_Thing = L0480_ps_Projectile->_slot).getType() != k15_ExplosionThingType) { if (groupSlot != NULL) { if ((L0478_T_PreviousThing = *groupSlot) == Thing::_endOfList) { - L0481_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0479_T_Thing); + L0481_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0479_T_Thing); *L0481_ps_Generic = Thing::_endOfList; *groupSlot = L0479_T_Thing; } else { -- cgit v1.2.3 From 3447af80f8a48413958f64e60890138c9dbe12da Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:50:17 +0200 Subject: DM: Some soft refactoring in champion.cpp --- engines/dm/champion.cpp | 397 +++++++++++++++++++++++------------------------- 1 file changed, 188 insertions(+), 209 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 24cfda9225..823a37f72c 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -511,18 +511,15 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch } int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) { - uint16 searchedScentRedEagle; - int16 scentIndex; - Scent* scent; - Scent searchedScent; + int16 scentIndex = _g407_party._scentCount; - - if (scentIndex = _g407_party._scentCount) { + if (scentIndex) { + Scent searchedScent; searchedScent.setMapX(mapX); searchedScent.setMapY(mapY); searchedScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); - searchedScentRedEagle = searchedScent.toUint16(); - scent = &_g407_party._scents[scentIndex--]; + uint16 searchedScentRedEagle = searchedScent.toUint16(); + Scent* scent = &_g407_party._scents[scentIndex--]; do { if ((*(--scent)).toUint16() == searchedScentRedEagle) { return _vm->M0_indexToOrdinal(scentIndex); @@ -992,27 +989,20 @@ int16 ChampionMan::f324_damageAll_getDamagedChampionCount(uint16 attack, int16 w } int16 ChampionMan::f286_getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) { - uint16 L0838_ui_Counter; - int16 L0839_i_ChampionIndex; - signed char L0840_auc_OrderedCellsToAttack[4]; - - if (_g305_partyChampionCount && (M38_distance(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)) { + signed char L0840_auc_OrderedCellsToAttack[4]; _vm->_groupMan->f229_setOrderedCellsToAttack(L0840_auc_OrderedCellsToAttack, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, mapX, mapY, cell); - for (L0838_ui_Counter = 0; L0838_ui_Counter < 4; L0838_ui_Counter++) { - if ((L0839_i_ChampionIndex = f285_getIndexInCell(L0840_auc_OrderedCellsToAttack[L0838_ui_Counter])) >= 0) { + for (uint16 L0838_ui_Counter = 0; L0838_ui_Counter < 4; L0838_ui_Counter++) { + int16 L0839_i_ChampionIndex = f285_getIndexInCell(L0840_auc_OrderedCellsToAttack[L0838_ui_Counter]); + if (L0839_i_ChampionIndex >= 0) return L0839_i_ChampionIndex; - } } } return kM1_ChampionNone; } int16 ChampionMan::f311_getDexterity(Champion* champ) { - int16 L0934_i_Dexterity; - - - L0934_i_Dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent]; + int16 L0934_i_Dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent]; L0934_i_Dexterity -= ((int32)(L0934_i_Dexterity >> 1) * (int32)champ->_load) / f309_getMaximumLoad(champ); if (_g300_partyIsSleeping) { L0934_i_Dexterity >>= 1; @@ -1022,27 +1012,21 @@ int16 ChampionMan::f311_getDexterity(Champion* champ) { bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) { #define AP0646_ui_IsLucky percentage - register unsigned char* L0928_puc_Statistic; - if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage)) { return true; } - L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck]; + register unsigned char* L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck]; AP0646_ui_IsLucky = (_vm->getRandomNumber(L0928_puc_Statistic[k1_ChampionStatCurrent]) > percentage); L0928_puc_Statistic[k1_ChampionStatCurrent] = f26_getBoundedValue((int32)L0928_puc_Statistic[k2_ChampionStatMinimum], (int32)L0928_puc_Statistic[k1_ChampionStatCurrent] + (AP0646_ui_IsLucky ? -2 : 2), (int32)L0928_puc_Statistic[k0_ChampionStatMaximum]); return AP0646_ui_IsLucky; } void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) { - TimelineEvent L0980_s_Event; - Champion* L0981_ps_Champion; - - - if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _g299_candidateChampionOrdinal)) { + if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _g299_candidateChampionOrdinal)) return; - } - L0981_ps_Champion = &_gK71_champions[champIndex]; + + Champion* L0981_ps_Champion = &_gK71_champions[champIndex]; f321_addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), k0x0000_ChampionWoundNone, k0_attackType_NORMAL); setFlag(L0981_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); if ((_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) && (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) { @@ -1050,6 +1034,7 @@ void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) { } if (--attack) { L0981_ps_Champion->_poisonEventCount++; + TimelineEvent L0980_s_Event; L0980_s_Event._type = k75_TMEventTypePoisonChampion; L0980_s_Event._priority = champIndex; M33_setMapAndTime(L0980_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 36); @@ -1099,33 +1084,29 @@ void ChampionMan::f316_deleteScent(uint16 scentIndex) { } void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount) { - int16 L0954_i_ScentIndex; - bool L0955_B_Merge; - bool L0956_B_CycleCountDefined; - Scent* L0957_ps_Scent; /* BUG0_00 Useless code */ - Scent L0958_s_Scent; /* BUG0_00 Useless code */ - - - if (L0954_i_ScentIndex = _g407_party._scentCount) { - if (L0955_B_Merge = getFlag(cycleCount, k0x8000_mergeCycles)) { + int16 L0954_i_ScentIndex = _vm->_championMan->_g407_party._scentCount; + if (L0954_i_ScentIndex) { + bool L0955_B_Merge = getFlag(cycleCount, k0x8000_mergeCycles); + if (L0955_B_Merge) { clearFlag(cycleCount, k0x8000_mergeCycles); } + Scent L0958_s_Scent; /* BUG0_00 Useless code */ L0958_s_Scent.setMapX(mapX); /* BUG0_00 Useless code */ L0958_s_Scent.setMapY(mapY); /* BUG0_00 Useless code */ L0958_s_Scent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */ - L0957_ps_Scent = _g407_party._scents; /* BUG0_00 Useless code */ - L0956_B_CycleCountDefined = false; + Scent* L0957_ps_Scent = _vm->_championMan->_g407_party._scents; /* BUG0_00 Useless code */ + bool L0956_B_CycleCountDefined = false; while (L0954_i_ScentIndex--) { if (&*L0957_ps_Scent++ == &L0958_s_Scent) { if (!L0956_B_CycleCountDefined) { L0956_B_CycleCountDefined = true; if (L0955_B_Merge) { - cycleCount = MAX((int32)_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount); + cycleCount = MAX((int32)_vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount); } else { - cycleCount = MIN(80, _g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount); + cycleCount = MIN(80, _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount); } } - _g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount; + _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount; } } } @@ -1135,10 +1116,8 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) if (thing == Thing::_none) { return; } - _g415_leaderEmptyHanded = false; - _vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer); - - + _vm->_championMan->_g415_leaderEmptyHanded = false; + _vm->_objectMan->f36_extractIconFromBitmap(_vm->_championMan->_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_vm->_championMan->_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer); _vm->_eventMan->f78_showMouse(); _vm->_objectMan->f34_drawLeaderObjectName(thing); if (setMousePointer) { @@ -1147,10 +1126,10 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) _vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer); } _vm->_eventMan->f77_hideMouse(); - if (_g411_leaderIndex != kM1_ChampionNone) { - _gK71_champions[_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing); - setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad); - f292_drawChampionState(_g411_leaderIndex); + if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) { + _vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing); + setFlag(_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad); + _vm->_championMan->f292_drawChampionState(_vm->_championMan->_g411_leaderIndex); } } @@ -1176,180 +1155,180 @@ void ChampionMan::f278_resetDataToStartGame() { void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) { - Thing L0793_T_Thing; - uint16 L0794_ui_Multiple; -#define AL0794_ui_ViewCell L0794_ui_Multiple -#define AL0794_ui_SlotIndex L0794_ui_Multiple -#define AL0794_ui_CharacterIndex L0794_ui_Multiple -#define AL0794_ui_StatisticIndex L0794_ui_Multiple -#define AL0794_ui_SkillIndex L0794_ui_Multiple - int16 L0795_i_HiddenSkillIndex; - uint16 L0796_ui_Multiple; -#define AL0796_ui_Character L0796_ui_Multiple -#define AL0796_ui_SkillValue L0796_ui_Multiple -#define AL0796_ui_ThingType L0796_ui_Multiple - Champion* L0797_ps_Champion; - char* L0798_pc_Character; - uint16 L0799_ui_PreviousPartyChampionCount; - uint16 L0800_ui_Multiple; -#define AL0800_B_ChampionTitleCopied L0800_ui_Multiple -#define AL0800_ui_HiddenSkillCounter L0800_ui_Multiple - uint16 L0801_ui_SlotIndex; - int16 L0802_i_MapX; - int16 L0803_i_MapY; - uint16 L0804_ui_ChampionObjectsCell; - int16 L0805_i_ObjectAllowedSlots; - int32 L0806_l_BaseSkillExperience; - char L0807_ac_DecodedChampionText[77]; - - if (!_vm->_championMan->_g415_leaderEmptyHanded) { - return; - } - if (_vm->_championMan->_g305_partyChampionCount == 4) { + DisplayMan &dispMan = *_vm->_displayMan; + DungeonMan &dunMan = *_vm->_dungeonMan; + + if (!_g415_leaderEmptyHanded || _g305_partyChampionCount == 4) return; - } - L0797_ps_Champion = &_vm->_championMan->_gK71_champions[L0799_ui_PreviousPartyChampionCount = _vm->_championMan->_g305_partyChampionCount]; - L0797_ps_Champion->resetToZero(); - // Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portaits could be missing in the data) - _vm->_displayMan->_g578_useByteBoxCoordinates = true; - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), L0797_ps_Champion->_portrait, gBoxChampionPortrait, _vm->_championMan->M27_getChampionPortraitX(championPortraitIndex), _vm->_championMan->M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency); - L0797_ps_Champion->_actionIndex = k255_ChampionActionNone; - L0797_ps_Champion->_enableActionEventIndex = -1; - L0797_ps_Champion->_hideDamageReceivedIndex = -1; - L0797_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir; - AL0794_ui_ViewCell = k0_ViewCellFronLeft; - while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone) { - AL0794_ui_ViewCell++; - } - L0797_ps_Champion->_cell = (ViewCell)M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir); - L0797_ps_Champion->_attributes = k0x0400_ChampionAttributeIcon; - L0797_ps_Champion->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir; - L0797_ps_Champion->_food = 1500 + _vm->getRandomNumber(256); - L0797_ps_Champion->_water = 1500 + _vm->getRandomNumber(256); - for (AL0794_ui_SlotIndex = k0_ChampionSlotReadyHand; AL0794_ui_SlotIndex < k30_ChampionSlotChest_1; AL0794_ui_SlotIndex++) { - L0797_ps_Champion->_slots[AL0794_ui_SlotIndex] = Thing::_none; - } - L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); - while ((L0793_T_Thing.getType()) != k2_TextstringType) { - L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing); - } - _vm->_dungeonMan->f168_decodeText(L0798_pc_Character = L0807_ac_DecodedChampionText, L0793_T_Thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible)); - AL0794_ui_CharacterIndex = 0; - while ((AL0796_ui_Character = *L0798_pc_Character++) != '\n') { /* New line */ - L0797_ps_Champion->_name[AL0794_ui_CharacterIndex++] = AL0796_ui_Character; - } - L0797_ps_Champion->_name[AL0794_ui_CharacterIndex] = '\0'; - AL0794_ui_CharacterIndex = 0; - AL0800_B_ChampionTitleCopied = false; - for (;;) { /*_Infinite loop_*/ - AL0796_ui_Character = *L0798_pc_Character++; - if (AL0796_ui_Character == '\n') { /* New line */ - if (AL0800_B_ChampionTitleCopied) + + uint16 prevChampCount = _g305_partyChampionCount; + Champion *champ = &_gK71_champions[prevChampCount]; + champ->resetToZero(); + dispMan._g578_useByteBoxCoordinates = true; + { // limit destBox scope + Box &destBox = gBoxChampionPortrait; + dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), champ->_portrait, + destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 128, 16, kM1_ColorNoTransparency); + } + + champ->_actionIndex = k255_ChampionActionNone; + champ->_enableActionEventIndex = -1; + champ->_hideDamageReceivedIndex = -1; + champ->_dir = dunMan._g308_partyDir; + ViewCell AL_0_viewCell = k0_ViewCellFronLeft; + while (f285_getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3)) != kM1_ChampionNone) + AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); + champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3); + champ->clearAttributes(k0x0400_ChampionAttributeIcon); + champ->_directionMaximumDamageReceived = dunMan._g308_partyDir; + champ->_food = 1500 + _vm->_rnd->getRandomNumber(256); + champ->_water = 1500 + _vm->_rnd->getRandomNumber(256); + int16 AL_0_slotIndex_Red; + for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) { + champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none); + } + Thing thing = dunMan.f161_getSquareFirstThing(dunMan._g306_partyMapX, dunMan._g307_partyMapY); + while (thing.getType() != k2_TextstringType) { + thing = dunMan.f159_getNextThing(thing); + } + char decodedChampionText[77]; + char* character_Green = decodedChampionText; + dunMan.f168_decodeText(character_Green, thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible)); + int16 AL_0_characterIndex = 0; + uint16 AL_2_character; + while ((AL_2_character = *character_Green++) != '\n') { + champ->_name[AL_0_characterIndex++] = AL_2_character; + } + champ->_name[AL_0_characterIndex] = '\0'; + AL_0_characterIndex = 0; + bool AL_4_champTitleCopied = false; + for (;;) { // infinite + AL_2_character = *character_Green++; + if (AL_2_character == '\n') { + if (AL_4_champTitleCopied) break; - AL0800_B_ChampionTitleCopied = true; + AL_4_champTitleCopied = true; } else { - L0797_ps_Champion->_title[AL0794_ui_CharacterIndex++] = AL0796_ui_Character; - } - } - L0797_ps_Champion->_title[AL0794_ui_CharacterIndex] = '\0'; - if (*L0798_pc_Character++ == 'M') { - setFlag(L0797_ps_Champion->_attributes, k0x0010_ChampionAttributeMale); - } - L0798_pc_Character++; - L0797_ps_Champion->_currHealth = L0797_ps_Champion->_maxHealth = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4); - L0798_pc_Character += 4; - L0797_ps_Champion->_currStamina = L0797_ps_Champion->_maxStamina = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4); - L0798_pc_Character += 4; - L0797_ps_Champion->_currMana = L0797_ps_Champion->_maxMana = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4); - L0798_pc_Character += 4; - L0798_pc_Character++; - for (AL0794_ui_StatisticIndex = k0_ChampionStatLuck; AL0794_ui_StatisticIndex <= k6_ChampionStatAntifire; AL0794_ui_StatisticIndex++) { - L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k2_ChampionStatMinimum] = 30; - L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k1_ChampionStatCurrent] = L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k0_ChampionStatMaximum] = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 2); - L0798_pc_Character += 2; - } - L0797_ps_Champion->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10; - L0798_pc_Character++; - for (AL0794_ui_SkillIndex = k4_ChampionSkillSwing; AL0794_ui_SkillIndex <= k19_ChampionSkillWater; AL0794_ui_SkillIndex++) { - if ((AL0796_ui_SkillValue = *L0798_pc_Character++ - 'A') > 0) { - L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = 125L << AL0796_ui_SkillValue; - } - } - for (AL0794_ui_SkillIndex = k0_ChampionSkillFighter; AL0794_ui_SkillIndex <= k3_ChampionSkillWizard; AL0794_ui_SkillIndex++) { - L0806_l_BaseSkillExperience = 0; - L0795_i_HiddenSkillIndex = (AL0794_ui_SkillIndex + 1) << 2; - for (AL0800_ui_HiddenSkillCounter = 0; AL0800_ui_HiddenSkillCounter < 4; AL0800_ui_HiddenSkillCounter++) { - L0806_l_BaseSkillExperience += L0797_ps_Champion->_skills[L0795_i_HiddenSkillIndex + AL0800_ui_HiddenSkillCounter]._experience; - } - L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = L0806_l_BaseSkillExperience; - } - _vm->_championMan->_g299_candidateChampionOrdinal = L0799_ui_PreviousPartyChampionCount + 1; - if (++_vm->_championMan->_g305_partyChampionCount == 1) { + champ->_title[AL_0_characterIndex++] = AL_2_character; + } + } + champ->_title[AL_0_characterIndex] = '\0'; + if (*character_Green++ == 'M') { + champ->setAttributeFlag(k0x0010_ChampionAttributeMale, true); + } + character_Green++; + champ->_currHealth = champ->_maxHealth = f279_getDecodedValue(character_Green, 4); + character_Green += 4; + champ->_currStamina = champ->_maxStamina = f279_getDecodedValue(character_Green, 4); + character_Green += 4; + champ->_currMana = champ->_maxMana = f279_getDecodedValue(character_Green, 4); + character_Green += 4; + character_Green++; + + int16 AL_0_statisticIndex; + for (AL_0_statisticIndex = k0_ChampionStatLuck; AL_0_statisticIndex <= k6_ChampionStatAntifire; ++AL_0_statisticIndex) { + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k2_ChampionStatMinimum, 30); + uint16 currMaxVal = f279_getDecodedValue(character_Green, 2); + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent, currMaxVal); + champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum, currMaxVal); + character_Green += 2; + } + + champ->setStatistic(k0_ChampionStatLuck, k2_ChampionStatMinimum, 10); + character_Green++; + + int16 AL_0_skillIndex; + int16 AL_2_skillValue; + for (AL_0_skillIndex = k4_ChampionSkillSwing; AL_0_skillIndex <= k19_ChampionSkillWater; AL_0_skillIndex++) { + if ((AL_2_skillValue = *character_Green++ - 'A') > 0) { + champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue); + } + } + + for (AL_0_skillIndex = k0_ChampionSkillFighter; AL_0_skillIndex <= k3_ChampionSkillWizard; ++AL_0_skillIndex) { + int32 baseSkillExp = 0; + int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2; + for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) { + baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience; + } + champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp); + } + + _g299_candidateChampionOrdinal = prevChampCount + 1; + if (++_g305_partyChampionCount == 1) { _vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst); _vm->_menuMan->_g508_refreshActionArea = true; - } else { + } else { _vm->_menuMan->f388_clearActingChampion(); - _vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_vm->_championMan->_g305_partyChampionCount - 1)); - } - L0802_i_MapX = _vm->_dungeonMan->_g306_partyMapX; - L0803_i_MapY = _vm->_dungeonMan->_g307_partyMapY; - L0804_ui_ChampionObjectsCell = returnOppositeDir(_vm->_dungeonMan->_g308_partyDir); - L0802_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L0803_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir]; - L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0802_i_MapX, L0803_i_MapY); - AL0794_ui_SlotIndex = k13_ChampionSlotBackpackLine_1_1; - while (L0793_T_Thing != Thing::_endOfList) { - if (((AL0796_ui_ThingType = (L0793_T_Thing.getType())) > k3_SensorThingType) && ((L0793_T_Thing.getCell()) == L0804_ui_ChampionObjectsCell)) { - L0805_i_ObjectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0793_T_Thing)]._allowedSlots; - switch (AL0796_ui_ThingType) { + _vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1)); + } + + int16 mapX = _vm->_dungeonMan->_g306_partyMapX; + int16 mapY = _vm->_dungeonMan->_g307_partyMapY; + + uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._g308_partyDir)); + mapX += _vm->_dirIntoStepCountEast[dunMan._g308_partyDir]; + mapY += _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir]; + thing = dunMan.f161_getSquareFirstThing(mapX, mapY); + AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1; + uint16 slotIndex_Green; + while (thing != Thing::_endOfList) { + ThingType AL_2_thingType = thing.getType(); + if ((AL_2_thingType > k3_SensorThingType) && (thing.getCell() == championObjectsCell)) { + int16 objectAllowedSlots = g237_ObjectInfo[dunMan.f141_getObjectInfoIndex(thing)].getAllowedSlots(); + switch (AL_2_thingType) { case k6_ArmourThingType: - for (L0801_ui_SlotIndex = k2_ChampionSlotHead; L0801_ui_SlotIndex <= k5_ChampionSlotFeet; L0801_ui_SlotIndex++) { - if (L0805_i_ObjectAllowedSlots & gSlotMasks[L0801_ui_SlotIndex]) + for (slotIndex_Green = k2_ChampionSlotHead; slotIndex_Green <= k5_ChampionSlotFeet; slotIndex_Green++) { + if (objectAllowedSlots & gSlotMasks[slotIndex_Green]) goto T0280048; } - if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) { - L0801_ui_SlotIndex = k10_ChampionSlotNeck; + if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) { + slotIndex_Green = k10_ChampionSlotNeck; } else { goto T0280046; } break; case k5_WeaponThingType: - if (L0797_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) { - L0801_ui_SlotIndex = k1_ChampionSlotActionHand; + if (champ->getSlot(k1_ChampionSlotActionHand) == Thing::_none) { + slotIndex_Green = k1_ChampionSlotActionHand; } else { goto T0280046; } break; case k7_ScrollThingType: case k8_PotionThingType: - if (L0797_ps_Champion->_slots[k11_ChampionSlotPouch_1] == Thing::_none) { - L0801_ui_SlotIndex = k11_ChampionSlotPouch_1; + if (champ->getSlot(k11_ChampionSlotPouch_1) == Thing::_none) { + slotIndex_Green = k11_ChampionSlotPouch_1; + } else if (champ->getSlot(k6_ChampionSlotPouch_2) == Thing::_none) { + slotIndex_Green = k6_ChampionSlotPouch_2; } else { - if (L0797_ps_Champion->_slots[k6_ChampionSlotPouch_2] == Thing::_none) { - L0801_ui_SlotIndex = k6_ChampionSlotPouch_2; - } else { - goto T0280046; - } + goto T0280046; } break; case k9_ContainerThingType: case k10_JunkThingType: T0280046: - if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) { - L0801_ui_SlotIndex = k10_ChampionSlotNeck; + if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) { + slotIndex_Green = k10_ChampionSlotNeck; } else { - L0801_ui_SlotIndex = AL0794_ui_SlotIndex++; + slotIndex_Green = AL_0_slotIndex_Red++; } + break; + + default: + break; } T0280048: - if (L0797_ps_Champion->_slots[L0801_ui_SlotIndex] != Thing::_none) { + if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_none) { goto T0280046; } - _vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0799_ui_PreviousPartyChampionCount, L0793_T_Thing, (ChampionSlot)L0801_ui_SlotIndex); + f301_addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green); } - L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing); + thing = dunMan.f159_getNextThing(thing); } - _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)L0799_ui_PreviousPartyChampionCount); - _vm->_menuMan->f456_drawDisabledMenu();; + + _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)prevChampCount); + _vm->_menuMan->f456_drawDisabledMenu(); } void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) { @@ -1466,7 +1445,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { L0868_i_ChampionStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing; - L0865_ps_Champion = &_gK71_champions[champIndex]; + L0865_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; L0862_ui_ChampionAttributes = L0865_ps_Champion->_attributes; if (!getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand)) { return; @@ -1483,13 +1462,13 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { for (uint16 i = 0; i < 3; ++i) L0872_ai_NativeBitmapIndices[i] = 0; AL0864_i_BorderCount = 0; - if (_g407_party._fireShieldDefense > 0) { + if (_vm->_championMan->_g407_party._fireShieldDefense > 0) { L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k38_BorderPartyFireshieldIndice; } - if (_g407_party._spellShieldDefense > 0) { + if (_vm->_championMan->_g407_party._spellShieldDefense > 0) { L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k39_BorderPartySpellshieldIndice; } - if ((_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) { + if ((_vm->_championMan->_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) { L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k37_BorderPartyShieldIndice; } while (AL0864_i_BorderCount--) { @@ -1511,7 +1490,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { if (!(L0865_ps_Champion->_currHealth)) goto T0292042; if (getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle)) { - AL0864_i_ColorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; + AL0864_i_ColorIndex = (champIndex == _vm->_championMan->_g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; if (L0863_B_IsInventoryChampion) { _vm->_textMan->f52_printToViewport(3, 7, (Color)AL0864_i_ColorIndex, L0866_pc_ChampionName = L0865_ps_Champion->_name); L0869_i_ChampionTitleX = 6 * strlen(L0866_pc_ChampionName) + 3; @@ -1530,9 +1509,9 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { } } if (getFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics)) { - f287_drawChampionBarGraphs(champIndex); + _vm->_championMan->f287_drawChampionBarGraphs(champIndex); if (L0863_B_IsInventoryChampion) { - f290_drawHealthStaminaManaValues(L0865_ps_Champion); + _vm->_championMan->f290_drawHealthStaminaManaValues(L0865_ps_Champion); if ((L0865_ps_Champion->_food < 0) || (L0865_ps_Champion->_water < 0) || (L0865_ps_Champion->_poisonEventCount)) { AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice; } else { @@ -1552,14 +1531,14 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { } if (getFlag(L0862_ui_ChampionAttributes, k0x2000_ChampionAttributeWounds)) { for (AL0864_i_SlotIndex = L0863_B_IsInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL0864_i_SlotIndex >= k0_ChampionSlotReadyHand; AL0864_i_SlotIndex--) { - f291_drawSlot(champIndex, AL0864_i_SlotIndex); + _vm->_championMan->f291_drawSlot(champIndex, AL0864_i_SlotIndex); } if (L0863_B_IsInventoryChampion) { setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); } } if (getFlag(L0862_ui_ChampionAttributes, k0x0200_ChampionAttributeLoad) && L0863_B_IsInventoryChampion) { - if (L0865_ps_Champion->_load > (AL0864_i_Load = f309_getMaximumLoad(L0865_ps_Champion))) { + if (L0865_ps_Champion->_load > (AL0864_i_Load = _vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion))) { AL0870_i_Color = k8_ColorRed; } else { if (((long)L0865_ps_Champion->_load << 3) > ((long)AL0864_i_Load * 5)) { @@ -1570,28 +1549,28 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { } _vm->_textMan->f52_printToViewport(104, 132, (Color)AL0870_i_Color, "LOAD "); AL0864_i_Load = L0865_ps_Champion->_load / 10; - strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); + strcpy(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); strcat(_vm->_g353_stringBuildBuffer, "."); AL0864_i_Load = L0865_ps_Champion->_load - (AL0864_i_Load * 10); - strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str()); + strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str()); strcat(_vm->_g353_stringBuildBuffer, "/"); - AL0864_i_Load = (f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10; - strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); + AL0864_i_Load = (_vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10; + strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); strcat(_vm->_g353_stringBuildBuffer, " KG"); _vm->_textMan->f52_printToViewport(148, 132, (Color)AL0870_i_Color, _vm->_g353_stringBuildBuffer); setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); } - AL0864_i_ChampionIconIndex = M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir); + AL0864_i_ChampionIconIndex = _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir); if (getFlag(L0862_ui_ChampionAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL0864_i_ChampionIconIndex))) { _vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], g46_ChampionColor[champIndex]); - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen); } if (getFlag(L0862_ui_ChampionAttributes, k0x0800_ChampionAttributePanel) && L0863_B_IsInventoryChampion) { if (_vm->_g333_pressingMouth) { _vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned(); } else { if (_vm->_g331_pressingEye) { - if (_g415_leaderEmptyHanded) { + if (_vm->_championMan->_g415_leaderEmptyHanded) { _vm->_inventoryMan->f351_drawChampionSkillsAndStatistics(); } } else { @@ -1601,7 +1580,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); } if (getFlag(L0862_ui_ChampionAttributes, k0x8000_ChampionAttributeActionHand)) { - f291_drawSlot(champIndex, k1_ChampionSlotActionHand); + _vm->_championMan->f291_drawSlot(champIndex, k1_ChampionSlotActionHand); _vm->_menuMan->f386_drawActionIcon(champIndex); if (L0863_B_IsInventoryChampion) { setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); -- cgit v1.2.3 From dce7465ad53fcf3179b47099e873b7d2b858b1d1 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:50:21 +0200 Subject: DM: Silent some more CppCheck warnings --- engines/dm/dungeonman.cpp | 229 +++++++++++++++++++++------------------------- engines/dm/eventman.cpp | 4 + engines/dm/gfx.cpp | 32 +++---- engines/dm/group.h | 2 +- engines/dm/projexpl.h | 2 +- engines/dm/timeline.h | 2 +- 6 files changed, 121 insertions(+), 150 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 8a49d957ed..3b009c2e31 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -419,6 +419,8 @@ DungeonMan::~DungeonMan() { delete[] _g260_dungeonTextData; delete[] _g279_dungeonMapData; for (uint16 i = 0; i < 16; ++i) { + if (_g284_thingData[i]) + delete[] _g284_thingData[i][0]; delete[] _g284_thingData[i]; } } @@ -651,34 +653,34 @@ void DungeonMan::f434_loadDungeonFile() { continue; if (_g284_thingData[thingType]) { + delete[] _g284_thingData[thingType][0]; delete[] _g284_thingData[thingType]; } - _g284_thingData[thingType] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount]; + _g284_thingData[thingType] = new uint16*[_g278_dungeonFileHeader._thingCounts[thingType]]; + _g284_thingData[thingType][0] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount]; + for (uint16 i = 0; i < _g278_dungeonFileHeader._thingCounts[thingType]; ++i) + _g284_thingData[thingType][i] = _g284_thingData[thingType][0] + i * thingStoreWordCount; if (thingType == k4_GroupThingType) { - for (uint16 i = 0; i < thingCount; ++i) { - uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount; + for (uint16 i = 0; i < thingCount; ++i) for (uint16 j = 0; j < thingStoreWordCount; ++j) { if (j == 2 || j == 3) - nextSlot[j] = dunDataStream.readByte(); + _g284_thingData[thingType][i][j] = dunDataStream.readByte(); else - nextSlot[j] = dunDataStream.readUint16BE(); + _g284_thingData[thingType][i][j] = dunDataStream.readUint16BE(); } - } } else if (thingType == k14_ProjectileThingType) { for (uint16 i = 0; i < thingCount; ++i) { - uint16 *nextSlot = _g284_thingData[thingType] + i * thingStoreWordCount; - nextSlot[0] = dunDataStream.readUint16BE(); - nextSlot[1] = dunDataStream.readUint16BE(); - nextSlot[2] = dunDataStream.readByte(); - nextSlot[3] = dunDataStream.readByte(); - nextSlot[4] = dunDataStream.readUint16BE(); + _g284_thingData[thingType][i][0] = dunDataStream.readUint16BE(); + _g284_thingData[thingType][i][1] = dunDataStream.readUint16BE(); + _g284_thingData[thingType][i][2] = dunDataStream.readByte(); + _g284_thingData[thingType][i][3] = dunDataStream.readByte(); + _g284_thingData[thingType][i][4] = dunDataStream.readUint16BE(); } } else { for (uint16 i = 0; i < thingCount; ++i) { - uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount; for (uint16 j = 0; j < thingStoreWordCount; ++j) - nextSlot[j] = dunDataStream.readUint16BE(); + _g284_thingData[thingType][i][j] = dunDataStream.readUint16BE(); } } @@ -686,7 +688,7 @@ void DungeonMan::f434_loadDungeonFile() { if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType) _vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType]; for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) { - (_g284_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16(); + _g284_thingData[thingType][thingCount + i][0] = Thing::_none.toUint16(); } } } @@ -755,36 +757,33 @@ void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) { Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) { - int16 L0248_i_Multiple; -#define AL0248_B_IsMapXInBounds L0248_i_Multiple -#define AL0248_i_SquareType L0248_i_Multiple - int16 L0249_i_Multiple; -#define AL0249_B_IsMapYInBounds L0249_i_Multiple -#define AL0249_i_SquareType L0249_i_Multiple - - AL0249_B_IsMapYInBounds = (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight); - if ((AL0248_B_IsMapXInBounds = (mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth)) && AL0249_B_IsMapYInBounds) { - return Square(_vm->_dungeonMan->_g271_currMapData[mapX][mapY]); + bool isInXBounds = (mapX >= 0) && (mapX < _g273_currMapWidth); + bool isInYBounds = (mapY >= 0) && (mapY < _g274_currMapHeight); + + if (isInXBounds && isInYBounds) + return Square(_g271_currMapData[mapX][mapY]); + + + Square tmpSquare; + if (isInYBounds) { + tmpSquare.set(_g271_currMapData[0][mapY]); + if (mapX == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) + return Square(k0_WallElemType).set(k0x0004_WallEastRandOrnAllowed); + + tmpSquare.set(_g271_currMapData[_g273_currMapWidth - 1][mapY]); + if (mapX == _g273_currMapWidth && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) + return Square(k0_WallElemType).set(k0x0001_WallWestRandOrnAllowed); + } else if (isInXBounds) { + tmpSquare.set(_g271_currMapData[mapX][0]); + if (mapY == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) + return Square(k0_WallElemType).set(k0x0002_WallSouthRandOrnAllowed); + + tmpSquare.set(_g271_currMapData[mapX][_g274_currMapHeight - 1]); + if (mapY == _g274_currMapHeight && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) + return Square((k0_WallElemType << 5) | k0x0008_WallNorthRandOrnAllowed); } - if (AL0249_B_IsMapYInBounds) { - if (((mapX == -1) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[0][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) { - return Square(k0_ElementTypeWall, k0x0004_WallEastRandOrnAllowed); - } - if (((mapX == _vm->_dungeonMan->_g273_currMapWidth) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[_vm->_dungeonMan->_g273_currMapWidth - 1][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) { - return Square(k0_ElementTypeWall, k0x0001_WallWestRandOrnAllowed); - } - } else { - if (AL0248_B_IsMapXInBounds) { - if (((mapY == -1) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][0]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) { - return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed); - } - if (((mapY == _vm->_dungeonMan->_g274_currMapHeight) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][_vm->_dungeonMan->_g274_currMapHeight - 1]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) { - return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed); - } - } - } - return Square(k0_ElementTypeWall, 0); + return Square(k0_WallElemType); } Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { @@ -793,23 +792,17 @@ Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 st } int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) { - uint16 L0260_ui_ThingIndex; - int16 L0261_i_MapY; - register unsigned char* L0262_puc_Square; + if (mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight || !Square(_g271_currMapData[mapX][mapY]).get(k0x0010_ThingListPresent)) + return -1; + int16 y = 0; + uint16 index = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; + byte* square = _g271_currMapData[mapX]; + while (y++ != mapY) + if (Square(*square++).get(k0x0010_ThingListPresent)) + index++; - L0262_puc_Square = _vm->_dungeonMan->_g271_currMapData[mapX]; - if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight) || !getFlag(L0262_puc_Square[mapY], k0x0010_ThingListPresent)) { - return -1; - } - L0261_i_MapY = 0; - L0260_ui_ThingIndex = _vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount[mapX]; - while (L0261_i_MapY++ != mapY) { - if (getFlag(*L0262_puc_Square++, k0x0010_ThingListPresent)) { - L0260_ui_ThingIndex++; - } - } - return L0260_ui_ThingIndex; + return index; } Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) { @@ -966,33 +959,31 @@ T0172049_Footprints: aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16(); } -void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir, +void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, int16 mapX, int16 mapY, bool isFakeWall) { - int16 L0306_i_Multiple; -#define AL0306_i_RandomWallOrnamentCount L0306_i_Multiple -#define AL0306_i_SideIndex L0306_i_Multiple - - - AL0306_i_RandomWallOrnamentCount = _vm->_dungeonMan->_g269_currMap->_randWallOrnCount; - aspectArray[k2_RightWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(leftAllowed, AL0306_i_RandomWallOrnamentCount, mapX, ++mapY * (M21_normalizeModulo4(++dir) + 1), 30); - aspectArray[k3_FrontWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(frontAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY * (M21_normalizeModulo4(++dir) + 1), 30); - aspectArray[k4_LeftWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(rightAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY-- * (M21_normalizeModulo4(++dir) + 1), 30); - if (isFakeWall || (mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight)) { /* If square is a fake wall or is out of map bounds */ - for (AL0306_i_SideIndex = k2_RightWallOrnOrdAspect; AL0306_i_SideIndex <= k4_LeftWallOrnOrdAspect; AL0306_i_SideIndex++) { /* Loop to remove any random ornament that is an alcove */ - if (_vm->_dungeonMan->f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[AL0306_i_SideIndex]))) { - aspectArray[AL0306_i_SideIndex] = 0; - } + int16 ornCount = _g269_currMap->_randWallOrnCount; + + turnDirRight(dir); + aspectArray[k2_RightWallOrnOrdAspect] = f170_getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); + turnDirRight(dir); + aspectArray[k3_FrontWallOrnOrdAspect] = f170_getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); + turnDirRight(dir); + aspectArray[k4_LeftWallOrnOrdAspect] = f170_getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); + + if (isFakeWall || mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight) { + for (uint16 i = k2_RightWallOrnOrdAspect; i <= k4_LeftWallOrnOrdAspect; ++i) { + if (f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[i]))) + aspectArray[i] = 0; } } } int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) { - int16 L0305_i_RandomOrnamentIndex; - - - if (allowed && ((L0305_i_RandomOrnamentIndex = f169_getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_vm->_dungeonMan->_g272_currMapIndex << (int16)6) + _vm->_dungeonMan->_g273_currMapWidth + _vm->_dungeonMan->_g274_currMapHeight, modulo)) < count)) { - return _vm->M0_indexToOrdinal(L0305_i_RandomOrnamentIndex); - } + int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1) + + (3000 + (_g272_currMapIndex << 6) + _g273_currMapWidth + _g274_currMapHeight) * 11 + + _g278_dungeonFileHeader._ornamentRandomSeed) >> 2) % modulo; + if (allowed && index < count) + return _vm->M0_indexToOrdinal(index); return 0; } @@ -1006,7 +997,7 @@ bool DungeonMan::f149_isWallOrnAnAlcove(int16 wallOrnIndex) { } uint16 *DungeonMan::f156_getThingData(Thing thing) { - return _g284_thingData[thing.getType()] + thing.getIndex() * g235_ThingDataWordCount[thing.getType()]; + return _g284_thingData[thing.getType()][thing.getIndex()]; } uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) { @@ -1014,7 +1005,7 @@ uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) { } Thing DungeonMan::f159_getNextThing(Thing thing) { - return Thing(f156_getThingData(thing)[0]); + return Thing(f156_getThingData(thing)[0]); // :) } char g255_MessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings @@ -1119,10 +1110,10 @@ char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) { - char sepChar; - TextString textString(_g284_thingData[k2_TextstringType] + thing.getIndex() * g235_ThingDataWordCount[k2_TextstringType]); + TextString textString(_g284_thingData[k2_TextstringType][thing.getIndex()]); if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) { type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible); + char sepChar; if (type == k1_TextTypeMessage) { *destString++ = '\n'; sepChar = ' '; @@ -1313,56 +1304,46 @@ int16 DungeonMan::f141_getObjectInfoIndex(Thing thing) { } void DungeonMan::f163_linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY) { - Thing L0265_T_Thing; - uint16 L0266_ui_Multiple; -#define AL0266_ui_Column L0266_ui_Multiple -#define AL0266_ui_SquareFirstThingIndex L0266_ui_Multiple - Thing* L0267_pT_Thing; - byte* L0268_puc_Square; - Thing* L0269_ps_Generic; - uint16 L0270_ui_MapY; + if (thingToLink == Thing::_endOfList) + return; + uint16 *rawObjPtr = f156_getThingData(thingToLink); + *rawObjPtr = Thing::_endOfList.toUint16(); - if (thingToLink == Thing::_endOfList) { - return; - } - L0269_ps_Generic = (Thing*)f156_getThingData(thingToLink); - *L0269_ps_Generic = Thing::_endOfList; - /* If mapX >= 0 then the thing is linked to the list of things on the specified square else it is linked at the end of the specified thing list */ if (mapX >= 0) { - L0268_puc_Square = &_g271_currMapData[mapX][mapY]; - if (getFlag(*L0268_puc_Square, k0x0010_ThingListPresent)) { + Square *squarePtr = (Square*)&_g271_currMapData[mapX][mapY]; + if (squarePtr->get(k0x0010_ThingListPresent)) { thingInList = f161_getSquareFirstThing(mapX, mapY); } else { - setFlag(*L0268_puc_Square, k0x0010_ThingListPresent); - uint16 * tmp = _g270_currMapColCumulativeSquareFirstThingCount + mapX + 1; - AL0266_ui_Column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1; - while (AL0266_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is added */ - (*tmp++)++; /* Increment the cumulative first thing count */ + squarePtr->set(k0x0010_ThingListPresent); + uint16 *cumulativeCount = &_g270_currMapColCumulativeSquareFirstThingCount[mapX + 1]; + uint16 column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1; + while (column--) { + (*cumulativeCount++)++; } - L0270_ui_MapY = 0; - L0268_puc_Square -= mapY; - AL0266_ui_SquareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; - while (L0270_ui_MapY++ != mapY) { - if (getFlag(*L0268_puc_Square++, k0x0010_ThingListPresent)) { - AL0266_ui_SquareFirstThingIndex++; + uint16 mapYStep = 0; + squarePtr -= mapY; + uint16 squareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; + while (mapYStep++ != mapY) { + if (squarePtr->get(k0x0010_ThingListPresent)) { + squareFirstThingIndex++; } + squarePtr++; } - L0267_pT_Thing = &_g283_squareFirstThings[AL0266_ui_SquareFirstThingIndex]; - // the second '- 1' is for the loop initialization, > 0 is because we are copying from one behind - for (int16 i = _g278_dungeonFileHeader._squareFirstThingCount - AL0266_ui_SquareFirstThingIndex - 1 - 1; i > 0; --i) - L0267_pT_Thing[i] = L0267_pT_Thing[i - 1]; - - *L0267_pT_Thing = thingToLink; + Thing* thingPtr = &_g283_squareFirstThings[squareFirstThingIndex]; + memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_g278_dungeonFileHeader._squareFirstThingCount - squareFirstThingIndex - 1)); + *thingPtr = thingToLink; return; } } - L0265_T_Thing = f159_getNextThing(thingInList); - while (L0265_T_Thing != Thing::_endOfList) { - L0265_T_Thing = f159_getNextThing(thingInList = L0265_T_Thing); + + Thing thing = f159_getNextThing(thingInList); + while (thing != Thing::_endOfList) { + thing = f159_getNextThing(thing); + thingInList = thing; } - L0269_ps_Generic = (Thing*)f156_getThingData(thingInList); - *L0269_ps_Generic = thingToLink; + rawObjPtr = f156_getThingData(thingInList); + *rawObjPtr = thingToLink.toUint16(); } WeaponInfo* DungeonMan::f158_getWeaponInfo(Thing thing) { @@ -1714,10 +1695,4 @@ Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) { } return L0295_T_Thing; } - -int16 DungeonMan::f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo) { - return ((((((val1 * 31417) & 0xFFFF) >> 1) + ((val2 * 11) & 0xFFFF) - + _vm->_dungeonMan->_g278_dungeonFileHeader._ornamentRandomSeed) & 0xFFFF) >> 2) % modulo; /* Pseudorandom number generator */ -} - } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 86b30d55dd..204a29640e 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -305,6 +305,10 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) { _g326_refreshMousePointerInMainLoop = false; _g341_highlightBoxEnabled = false; _g599_useChampionIconOrdinalAsMousePointerBitmap = 0; + _g439_pendingClickButton = k0_NoneMouseButton; + _g600_useObjectAsMousePointerBitmap = false; + _g601_useHandAsMousePointerBitmap = false; + _gK100_preventBuildPointerScreenArea = false; } EventManager::~EventManager() { diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index a6dd0874f5..e90b3a34aa 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1009,16 +1009,13 @@ void DisplayMan::f103_drawDoorFrameBitmapFlippedHorizontally(byte* bitmap, Frame } void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButtonIndex) { - int16 nativeBitmapIndex; - int coordSet; - uint16* coordSetRedEagle; - byte* bitmap; - byte* bitmapNative; - if (doorButtonOrdinal) { doorButtonOrdinal--; - nativeBitmapIndex = doorButtonOrdinal + k315_firstDoorButton_GraphicIndice; - coordSetRedEagle = g208_doorButtonCoordSets[coordSet = g197_doorButtonCoordSet[doorButtonOrdinal]][viewDoorButtonIndex]; + int16 nativeBitmapIndex = doorButtonOrdinal + k315_firstDoorButton_GraphicIndice; + int coordSet = g197_doorButtonCoordSet[doorButtonOrdinal]; + uint16 *coordSetRedEagle = g208_doorButtonCoordSets[coordSet][viewDoorButtonIndex]; + + byte* bitmap = nullptr; if (viewDoorButtonIndex == k3_viewDoorButton_D1C) { bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); @@ -1028,8 +1025,8 @@ void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButt _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordSetRedEagle[3]; } else { if (!f491_isDerivedBitmapInCache(doorButtonOrdinal = k102_DerivedBitmapFirstDoorButton + (doorButtonOrdinal * 2) + ((!viewDoorButtonIndex) ? 0 : viewDoorButtonIndex - 1))) { - uint16* coordSetBlueGoat = g208_doorButtonCoordSets[coordSet][k3_viewDoorButton_D1C]; - bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + uint16 *coordSetBlueGoat = g208_doorButtonCoordSets[coordSet][k3_viewDoorButton_D1C]; + byte *bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); f129_blitToBitmapShrinkWithPalChange(bitmapNative, f492_getDerivedBitmap(doorButtonOrdinal), coordSetBlueGoat[4] << 1, coordSetBlueGoat[5], coordSetRedEagle[1] - coordSetRedEagle[0] + 1, @@ -1383,18 +1380,13 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn #define height doorOrnOrdinal #define byteWidth viewDoorOrnIndex - int16 nativeBitmapIndex; - int16 coordSetGreenToad; - uint16* coordSetOrangeElk; - byte* L0107_puc_Multiple; -#define bitmap L0107_puc_Multiple - byte* bitmapNative; - if (doorOrnOrdinal) { doorOrnOrdinal--; - nativeBitmapIndex = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex]; - coordSetOrangeElk = g207_doorOrnCoordSets[coordSetGreenToad = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]][viewDoorOrnIndex]; + int16 nativeBitmapIndex = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex]; + int16 coordSetGreenToad = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]; + uint16 *coordSetOrangeElk = g207_doorOrnCoordSets[coordSetGreenToad][viewDoorOrnIndex]; + byte *bitmap = nullptr; if (viewDoorOrnIndex == k2_ViewDoorOrnament_D1LCR) { bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); byteWidth = 48; @@ -1402,7 +1394,7 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn } else { if (!f491_isDerivedBitmapInCache(doorOrnOrdinal = k68_DerivedBitmapFirstDoorOrnament_D3 + (doorOrnOrdinal * 2) + viewDoorOrnIndex)) { uint16 *coordSetRedEagle = g207_doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR]; - bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + byte* bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); f129_blitToBitmapShrinkWithPalChange(bitmapNative, f492_getDerivedBitmap(doorOrnOrdinal), coordSetRedEagle[4] << 1, coordSetRedEagle[5], diff --git a/engines/dm/group.h b/engines/dm/group.h index f9aa038aee..ca7cb527ed 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -175,7 +175,7 @@ public: uint16 _g376_maxActiveGroupCount; // @ G0376_ui_MaximumActiveGroupCount ActiveGroup *_g375_activeGroups; // @ G0375_ps_ActiveGroups uint16 _g377_currActiveGroupCount; // @ G0377_ui_CurrentActiveGroupCount - GroupMan(DMEngine *vm); + explicit GroupMan(DMEngine *vm); ~GroupMan(); void f196_initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups diff --git a/engines/dm/projexpl.h b/engines/dm/projexpl.h index 15f74543fc..32829f15af 100644 --- a/engines/dm/projexpl.h +++ b/engines/dm/projexpl.h @@ -83,7 +83,7 @@ public: int16 _g366_projectilePoisonAttack; // @ G0366_i_ProjectilePoisonAttack int16 _g367_projectileAttackType; // @ G0367_i_ProjectileAttackType int32 _g362_lastPartyMovementTime; // @ G0362_l_LastPartyMovementTime - ProjExpl(DMEngine *vm); + explicit ProjExpl(DMEngine *vm); void f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, direction dir, byte kineticEnergy, byte attack, byte stepEnergy); // @ F0212_PROJECTILE_Create bool f217_projectileHasImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo, diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index 5cf3f85a18..b77c0d1081 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -151,7 +151,7 @@ public: uint16 *_g371_timeline; // @ G0371_pui_Timeline uint16 _g373_firstUnusedEventIndex; // @ G0373_ui_FirstUnusedEventIndex - Timeline(DMEngine *vm); + explicit Timeline(DMEngine *vm); ~Timeline(); void f233_initTimeline(); // @ F0233_TIMELINE_Initialize void f237_deleteEvent(uint16 eventIndex);// @ F0237_TIMELINE_DeleteEvent -- cgit v1.2.3 From 2edabfae994014bcc27fb6f45760b5f67175ba6e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 8 Jul 2016 07:59:17 +0200 Subject: DM: Some rework in group.cpp --- engines/dm/group.cpp | 190 +++++++++++++++++++++++---------------------------- 1 file changed, 85 insertions(+), 105 deletions(-) diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index f12ef8e57e..f2b2fda936 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -38,7 +38,7 @@ int32 M32_setTime(int32 &map_time, int32 time) { return map_time = (map_time & 0xFF000000) | time; } -GroupMan::GroupMan(DMEngine* vm) : _vm(vm) { +GroupMan::GroupMan(DMEngine *vm) : _vm(vm) { for (uint16 i = 0; i < 4; ++i) _g392_dropMovingCreatureFixedPossessionsCell[i] = 0; _g391_dropMovingCreatureFixedPossCellCount = 0; @@ -76,7 +76,7 @@ void GroupMan::f196_initActiveGroups() { _g375_activeGroups[i]._groupThingIndex = -1; } -uint16 GroupMan::f145_getGroupCells(Group* group, int16 mapIndex) { +uint16 GroupMan::f145_getGroupCells(Group *group, int16 mapIndex) { byte cells; cells = group->_cells; if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) @@ -86,14 +86,14 @@ uint16 GroupMan::f145_getGroupCells(Group* group, int16 mapIndex) { byte gGroupDirections[4] = {0x00, 0x55, 0xAA, 0xFF}; // @ G0258_auc_Graphic559_GroupDirections -uint16 GroupMan::f147_getGroupDirections(Group* group, int16 mapIndex) { +uint16 GroupMan::f147_getGroupDirections(Group *group, int16 mapIndex) { if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) return _g375_activeGroups[group->getActiveGroupIndex()]._directions; return gGroupDirections[group->getDir()]; } -int16 GroupMan::f176_getCreatureOrdinalInCell(Group* group, uint16 cell) { +int16 GroupMan::f176_getCreatureOrdinalInCell(Group *group, uint16 cell) { uint16 currMapIndex = _vm->_dungeonMan->_g272_currMapIndex; byte groupCells = f145_getGroupCells(group, currMapIndex); if (groupCells == k255_CreatureTypeSingleCenteredCreature) @@ -123,25 +123,19 @@ uint16 GroupMan::M50_getCreatureValue(uint16 groupVal, uint16 creatureIndex) { } void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, int16 mode) { - Thing L0365_T_CurrentThing; - Thing L0366_T_NextThing; - Group* L0367_ps_Group; - uint16 L0368_ui_CreatureType; - int16 L0369_i_CreatureIndex; - uint16 L0370_ui_GroupCells; - bool L0371_B_WeaponDropped; - - - L0367_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(groupThing); - if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[L0368_ui_CreatureType = L0367_ps_Group->_type]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) { - L0369_i_CreatureIndex = L0367_ps_Group->getCount(); - L0370_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(L0367_ps_Group, _vm->_dungeonMan->_g272_currMapIndex); + Group *L0367_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(groupThing); + uint16 L0368_ui_CreatureType = L0367_ps_Group->_type; + if ((mode >= k0_soundModePlayImmediately) && getFlag(g243_CreatureInfo[L0368_ui_CreatureType]._attributes, k0x0200_MaskCreatureInfo_dropFixedPoss)) { + int16 L0369_i_CreatureIndex = L0367_ps_Group->getCount(); + uint16 L0370_ui_GroupCells = _vm->_groupMan->f145_getGroupCells(L0367_ps_Group, _vm->_dungeonMan->_g272_currMapIndex); do { _vm->_groupMan->f186_dropCreatureFixedPossessions(L0368_ui_CreatureType, mapX, mapY, (L0370_ui_GroupCells == k255_CreatureTypeSingleCenteredCreature) ? k255_CreatureTypeSingleCenteredCreature : _vm->_groupMan->M50_getCreatureValue(L0370_ui_GroupCells, L0369_i_CreatureIndex), mode); } while (L0369_i_CreatureIndex--); } - if ((L0365_T_CurrentThing = L0367_ps_Group->_slot) != Thing::_endOfList) { - L0371_B_WeaponDropped = false; + Thing L0365_T_CurrentThing = L0367_ps_Group->_slot; + if ((L0365_T_CurrentThing) != Thing::_endOfList) { + bool L0371_B_WeaponDropped = false; + Thing L0366_T_NextThing; do { L0366_T_NextThing = _vm->_dungeonMan->f159_getNextThing(L0365_T_CurrentThing); L0365_T_CurrentThing = M15_thingWithNewCell(L0365_T_CurrentThing, _vm->getRandomNumber(4)); @@ -198,17 +192,9 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop, k127_ObjectInfoIndexFirstJunk + k36_JunkTypeDragonSteak | k0x8000_randomDrop, 0}; - uint16 L0356_ui_FixedPossession; - int16 L0357_i_ThingType; - Thing L0358_T_Thing; - uint16* L0359_pui_FixedPossessions; - Weapon* L0360_ps_Weapon; - bool L0361_B_Cursed; - bool L0362_B_WeaponDropped; - + uint16 *L0359_pui_FixedPossessions; - L0361_B_Cursed = false; - L0362_B_WeaponDropped = false; + bool L0361_B_Cursed = false; switch (creatureType) { default: return; @@ -240,9 +226,12 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX case k24_CreatureTypeRedDragon: L0359_pui_FixedPossessions = g253FixedPossessionCreature_24RedDragon; } + uint16 L0356_ui_FixedPossession; while (L0356_ui_FixedPossession = *L0359_pui_FixedPossessions++) { if (getFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) && _vm->getRandomNumber(2)) continue; + int16 L0357_i_ThingType; + bool L0362_B_WeaponDropped = false; if (clearFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) >= k127_ObjectInfoIndexFirstJunk) { L0357_i_ThingType = k10_JunkThingType; L0356_ui_FixedPossession -= k127_ObjectInfoIndexFirstJunk; @@ -256,10 +245,11 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX L0356_ui_FixedPossession -= k23_ObjectInfoIndexFirstWeapon; } } - if ((L0358_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(L0357_i_ThingType)) == Thing::_none) { + Thing L0358_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(L0357_i_ThingType); + if ((L0358_T_Thing) == Thing::_none) continue; - } - L0360_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L0358_T_Thing); + + Weapon *L0360_ps_Weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(L0358_T_Thing); /* The same pointer type is used no matter the actual type k5_WeaponThingType, k6_ArmourThingType or k10_JunkThingType */ L0360_ps_Weapon->setType(L0356_ui_FixedPossession); L0360_ps_Weapon->setCursed(L0361_B_Cursed); @@ -340,18 +330,15 @@ bool GroupMan::f227_isDestVisibleFromSource(uint16 dir, int16 srcMapX, int16 src } bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 attack, bool magicAttack, int16 ticks) { - Door* L0573_ps_Door; - byte* L0574_puc_Square; - TimelineEvent L0575_s_Event; - - L0573_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY); + Door *L0573_ps_Door = (Door *)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY); if ((magicAttack && !L0573_ps_Door->isMagicDestructible()) || (!magicAttack && !L0573_ps_Door->isMeleeDestructible())) { return false; } if (attack >= _vm->_dungeonMan->_g275_currMapDoorInfo[L0573_ps_Door->getType()]._defense) { - L0574_puc_Square = &_vm->_dungeonMan->_g271_currMapData[mapX][mapY]; + byte *L0574_puc_Square = &_vm->_dungeonMan->_g271_currMapData[mapX][mapY]; if (Square(*L0574_puc_Square).getDoorState() == k4_doorState_CLOSED) { if (ticks) { + TimelineEvent L0575_s_Event; M33_setMapAndTime(L0575_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ticks); L0575_s_Event._type = k2_TMEventTypeDoorDestruction; L0575_s_Event._priority = 0; @@ -359,7 +346,7 @@ bool GroupMan::f232_groupIsDoorDestoryedByAttack(uint16 mapX, uint16 mapY, int16 L0575_s_Event._B._location._mapY = mapY; _vm->_timeline->f238_addEventGetEventIndex(&L0575_s_Event); } else { - ((Square*)L0574_puc_Square)->setDoorState(k5_doorState_DESTROYED); + ((Square *)L0574_puc_Square)->setDoorState(k5_doorState_DESTROYED); } return true; } @@ -377,7 +364,7 @@ Thing GroupMan::f175_groupGetThing(int16 mapX, int16 mapY) { return L0317_T_Thing; } -int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group* group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) { +int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex, int16 mapX, int16 mapY, int16 damage, bool notMoving) { uint16 L0374_ui_Multiple; #define AL0374_ui_EventIndex L0374_ui_Multiple #define AL0374_ui_CreatureIndex L0374_ui_Multiple @@ -387,9 +374,9 @@ int16 GroupMan::f190_groupGetDamageCreatureOutcome(Group* group, uint16 creature #define AL0375_ui_Outcome L0375_ui_Multiple #define AL0375_ui_EventType L0375_ui_Multiple #define AL0375_ui_NextCreatureIndex L0375_ui_Multiple - CreatureInfo* L0376_ps_CreatureInfo; - TimelineEvent* L0377_ps_Event; - ActiveGroup* L0378_ps_ActiveGroup = nullptr; + CreatureInfo *L0376_ps_CreatureInfo; + TimelineEvent *L0377_ps_Event; + ActiveGroup *L0378_ps_ActiveGroup = nullptr; uint16 L0379_ui_CreatureCount; uint16 L0380_ui_Multiple = 0; #define AL0380_ui_CreatureType L0380_ui_Multiple @@ -489,13 +476,13 @@ T0190024: void GroupMan::f189_delete(int16 mapX, int16 mapY) { Thing L0372_T_GroupThing; - Group* L0373_ps_Group; + Group *L0373_ps_Group; if ((L0372_T_GroupThing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) { return; } - L0373_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0372_T_GroupThing); + L0373_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0372_T_GroupThing); for (uint16 i = 0; i < 4; ++i) L0373_ps_Group->_health[i] = 0; _vm->_movsens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0); @@ -510,7 +497,7 @@ void GroupMan::f189_delete(int16 mapX, int16 mapY) { void GroupMan::f181_groupDeleteEvents(int16 mapX, int16 mapY) { int16 L0334_i_EventIndex; uint16 L0335_ui_EventType; - TimelineEvent* L0336_ps_Event; + TimelineEvent *L0336_ps_Event; L0336_ps_Event = _vm->_timeline->_g370_events; @@ -530,7 +517,7 @@ uint16 GroupMan::f178_getGroupValueUpdatedWithCreatureValue(uint16 groupVal, uin return creatreVal | (groupVal & ~(3 << creatreVal)); } -int16 GroupMan::f191_getDamageAllCreaturesOutcome(Group* group, int16 mapX, int16 mapY, int16 attack, bool notMoving) { +int16 GroupMan::f191_getDamageAllCreaturesOutcome(Group *group, int16 mapX, int16 mapY, int16 attack, bool notMoving) { uint16 L0385_ui_RandomAttack; int16 L0386_i_CreatureIndex; int16 L0387_i_Outcome; @@ -572,8 +559,8 @@ int16 GroupMan::f192_groupGetResistanceAdjustedPoisonAttack(uint16 creatreType, } void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16 eventType, uint16 ticks) { - Group* L0444_ps_Group; - ActiveGroup* L0445_ps_ActiveGroup; + Group *L0444_ps_Group; + ActiveGroup *L0445_ps_ActiveGroup; int16 L0446_i_Multiple; #define AL0446_i_EventType L0446_i_Multiple #define AL0446_i_Direction L0446_i_Multiple @@ -623,7 +610,7 @@ void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16 if ((L0449_T_GroupThing = _vm->_groupMan->f175_groupGetThing(eventMapX, eventMapY)) == Thing::_endOfList) { goto T0209139_Return; } - L0444_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0449_T_GroupThing); + L0444_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0449_T_GroupThing); L0448_s_CreatureInfo = g243_CreatureInfo[L0444_ps_Group->_type]; /* Update the event */ M33_setMapAndTime(L0465_s_NextEvent._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime); @@ -1067,12 +1054,12 @@ T0209139_Return: ; } -bool GroupMan::f202_isMovementPossible(CreatureInfo* creatureInfo, int16 mapX, int16 mapY, uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls) { +bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, int16 mapY, uint16 dir, bool allowMovementOverImaginaryPitsAndFakeWalls) { int16 L0428_i_MapX; int16 L0429_i_MapY; uint16 L0430_ui_Square = 0; int16 L0431_i_SquareType = 0; - Teleporter* L0432_ps_Teleporter; + Teleporter *L0432_ps_Teleporter; Thing L0433_T_Thing; @@ -1099,8 +1086,8 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo* creatureInfo, int16 mapX, i L0433_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0428_i_MapX, L0429_i_MapY); while (L0433_T_Thing != Thing::_endOfList) { if ((L0433_T_Thing).getType() == k15_ExplosionThingType) { - L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f156_getThingData(L0433_T_Thing); - if (((Explosion*)L0432_ps_Teleporter)->setType(k50_ExplosionType_Fluxcage)) { + L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f156_getThingData(L0433_T_Thing); + if (((Explosion *)L0432_ps_Teleporter)->setType(k50_ExplosionType_Fluxcage)) { _g385_fluxCages[dir] = true; _g386_fluxCageCount++; _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true; @@ -1111,7 +1098,7 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo* creatureInfo, int16 mapX, i } } if ((L0431_i_SquareType == k5_ElementTypeTeleporter) && getFlag(L0430_ui_Square, k0x0008_TeleporterOpen) && (creatureInfo->M59_getWariness() >= 10)) { - L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY); + L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY); if (getFlag(L0432_ps_Teleporter->getScope(), k0x0001_TelepScopeCreatures) && !_vm->_dungeonMan->f139_isCreatureAllowedOnMap(_g380_currGroupThing, L0432_ps_Teleporter->getTargetMapIndex())) { _g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = true; return false; @@ -1121,8 +1108,8 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo* creatureInfo, int16 mapX, i return false; } if (L0431_i_SquareType == k4_DoorElemType) { - L0432_ps_Teleporter = (Teleporter*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY); - if (((Square(L0430_ui_Square).getDoorState()) > (((Door*)L0432_ps_Teleporter)->opensVertically() ? creatureInfo->M51_height() : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) { + L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY); + if (((Square(L0430_ui_Square).getDoorState()) > (((Door *)L0432_ps_Teleporter)->opensVertically() ? creatureInfo->M51_height() : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) { _g389_groupMovementBlockedByDoor = true; return false; } @@ -1135,14 +1122,14 @@ int16 GroupMan::f226_getDistanceBetweenSquares(int16 srcMapX, int16 srcMapY, int (((srcMapY -= destMapY) < 0) ? -srcMapY : srcMapY)); } -int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group* group, int16 creatureIndex, int16 mapX, int16 mapY) { +int16 GroupMan::f200_groupGetDistanceToVisibleParty(Group *group, int16 creatureIndex, int16 mapX, int16 mapY) { int16 L0420_i_CreatureDirection; int16 L0421_i_CreatureViewDirectionCount; /* Count of directions to test in L0425_ai_CreatureViewDirections */ int16 L0422_i_Multiple; #define AL0422_i_Counter L0422_i_Multiple #define AL0422_i_SightRange L0422_i_Multiple uint16 L0423_ui_GroupDirections; - CreatureInfo* L0424_ps_CreatureInfo; + CreatureInfo *L0424_ps_CreatureInfo; int16 L0425_ai_CreatureViewDirections[4]; /* List of directions to test */ @@ -1234,30 +1221,28 @@ int16 GroupMan::f199_getDistanceBetweenUnblockedSquares(int16 srcMapX, int16 src } bool GroupMan::f197_isViewPartyBlocked(uint16 mapX, uint16 mapY) { - uint16 L0404_ui_Square; - int16 L0405_i_SquareType; - int16 L0406_i_DoorState; - Door* L0407_ps_Door; - - if ((L0405_i_SquareType = Square(L0404_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k4_DoorElemType) { - L0407_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY); - return (((L0406_i_DoorState = Square(L0404_ui_Square).getDoorState()) == k3_doorState_FOURTH) || (L0406_i_DoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[L0407_ps_Door->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough); + uint16 L0404_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]; + int16 L0405_i_SquareType = Square(L0404_ui_Square).getType(); + if (L0405_i_SquareType == k4_DoorElemType) { + Door *L0407_ps_Door = (Door *)_vm->_dungeonMan->f157_getSquareFirstThingData(mapX, mapY); + int16 L0406_i_DoorState = Square(L0404_ui_Square).getDoorState(); + return ((L0406_i_DoorState == k3_doorState_FOURTH) || (L0406_i_DoorState == k4_doorState_CLOSED)) && !getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[L0407_ps_Door->getType()]._attributes, k0x0001_MaskDoorInfo_CraturesCanSeeThrough); } return (L0405_i_SquareType == k0_ElementTypeWall) || ((L0405_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0404_ui_Square, k0x0004_FakeWallOpen)); } -int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup* activeGroup, int16 creatureIndex, bool isAttacking) { +int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 creatureIndex, bool isAttacking) { uint16 L0326_ui_Multiple; #define AL0326_ui_Aspect L0326_ui_Multiple #define AL0326_ui_AnimationTicks L0326_ui_Multiple uint16 L0327_ui_CreatureGraphicInfo; int16 L0328_i_Offset; - Group* L0329_ps_Group; + Group *L0329_ps_Group; bool L0330_B_ProcessGroup; uint16 L0331_ui_CreatureType; uint16 L1635_ui_SoundIndex; - L0329_ps_Group = &(((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]); + L0329_ps_Group = &(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[activeGroup->_groupThingIndex]); L0327_ui_CreatureGraphicInfo = g243_CreatureInfo[L0331_ui_CreatureType = L0329_ps_Group->_type]._graphicInfo; if (L0330_B_ProcessGroup = (creatureIndex < 0)) { /* If the creature index is negative then all creatures in the group are processed */ creatureIndex = L0329_ps_Group->getCount(); @@ -1327,10 +1312,10 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup* activeGroup, int16 return _vm->_g313_gameTime + (isAttacking ? ((AL0326_ui_AnimationTicks >> 8) & 0xF) : ((AL0326_ui_AnimationTicks >> 4) & 0xF)) + _vm->getRandomNumber(2); } -void GroupMan::f205_setDirection(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) { +void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) { uint16 L0435_ui_GroupDirections; static long G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; /* These two variables are used to prevent setting direction of half square sized creatures twice at the same game time */ - static ActiveGroup* G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup; + static ActiveGroup *G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup; warning("potentially dangerous cast to uint32 below"); @@ -1350,7 +1335,7 @@ void GroupMan::f205_setDirection(ActiveGroup* activeGroup, int16 dir, int16 crea activeGroup->_directions = (direction)L0435_ui_GroupDirections; } -void GroupMan::f208_groupAddEvent(TimelineEvent* event, uint32 time) { +void GroupMan::f208_groupAddEvent(TimelineEvent *event, uint32 time) { warning("potentially dangerous cast to uint32 below"); if (time < (uint32)M30_time(event->_mapTime)) { event->_type -= 5; @@ -1362,7 +1347,7 @@ void GroupMan::f208_groupAddEvent(TimelineEvent* event, uint32 time) { _vm->_timeline->f238_addEventGetEventIndex(event); } -int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo* creatureInfo, int16 mapY, int16 mapX) { +int16 GroupMan::f201_getSmelledPartyPrimaryDirOrdinal(CreatureInfo *creatureInfo, int16 mapY, int16 mapX) { uint16 L0426_ui_SmellRange; int16 L0427_i_ScentOrdinal; @@ -1388,7 +1373,7 @@ bool GroupMan::f198_isSmellPartyBlocked(uint16 mapX, uint16 mapY) { return ((L0409_i_SquareType = Square(L0408_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType()) == k0_ElementTypeWall) || ((L0409_i_SquareType == k6_ElementTypeFakeWall) && !getFlag(L0408_ui_Square, k0x0004_FakeWallOpen)); } -int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo* info, int16 mapX, int16 mapY, bool allowMovementOverImaginaryPitsAndFakeWalls) { +int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo *info, int16 mapX, int16 mapY, bool allowMovementOverImaginaryPitsAndFakeWalls) { int16 L0434_i_Direction; @@ -1400,7 +1385,7 @@ int16 GroupMan::f203_getFirstPossibleMovementDirOrdinal(CreatureInfo* info, int1 return 0; } -void GroupMan::f206_groupSetDirGroup(ActiveGroup* activeGroup, int16 dir, int16 creatureIndex, int16 creatureSize) { +void GroupMan::f206_groupSetDirGroup(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, int16 creatureSize) { bool L0436_B_TwoHalfSquareSizedCreatures; @@ -1414,7 +1399,7 @@ void GroupMan::f206_groupSetDirGroup(ActiveGroup* activeGroup, int16 dir, int16 } while (creatureIndex--); } -void GroupMan::f182_stopAttacking(ActiveGroup* group, int16 mapX, int16 mapY) { +void GroupMan::f182_stopAttacking(ActiveGroup *group, int16 mapX, int16 mapY) { int16 L0337_i_CreatureIndex; for (L0337_i_CreatureIndex = 0; L0337_i_CreatureIndex < 4; clearFlag(group->_aspect[L0337_i_CreatureIndex++], k0x0080_MaskActiveGroupIsAttacking)); @@ -1422,7 +1407,7 @@ void GroupMan::f182_stopAttacking(ActiveGroup* group, int16 mapX, int16 mapY) { } -bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo* info, int16 mapX, int16 mapY, uint16 dir) { +bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo *info, int16 mapX, int16 mapY, uint16 dir) { if (_g385_fluxCages[dir]) { return false; } @@ -1430,11 +1415,10 @@ bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo* info, int16 return f202_isMovementPossible(info, mapX, mapY, dir, false); } -bool GroupMan::f207_isCreatureAttacking(Group* group, int16 mapX, int16 mapY, uint16 creatureIndex) { +bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 creatureIndex) { uint16 L0437_ui_Multiple; #define AL0437_ui_CreatureType L0437_ui_Multiple #define AL0437_T_Thing L0437_ui_Multiple - uint16 L0438_ui_PrimaryDirectionToParty; int16 L0439_i_Multiple; #define AL0439_i_GroupCells L0439_i_Multiple #define AL0439_i_TargetCell L0439_i_Multiple @@ -1444,15 +1428,11 @@ bool GroupMan::f207_isCreatureAttacking(Group* group, int16 mapX, int16 mapY, ui #define AL0440_i_Counter L0440_i_Multiple #define AL0440_i_Damage L0440_i_Multiple #define AL0440_i_AttackSoundOrdinal L0440_i_Multiple - CreatureInfo* L0441_ps_CreatureInfo; - Champion* L0442_ps_Champion; - ActiveGroup L0443_s_ActiveGroup; - _vm->_projexpl->_g361_lastCreatureAttackTime = _vm->_g313_gameTime; - L0443_s_ActiveGroup = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]; - L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type]; - L0438_ui_PrimaryDirectionToParty = _g382_currGroupPrimaryDirToParty; + ActiveGroup L0443_s_ActiveGroup = _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]; + CreatureInfo *L0441_ps_CreatureInfo = &g243_CreatureInfo[AL0437_ui_CreatureType = group->_type]; + uint16 L0438_ui_PrimaryDirectionToParty = _g382_currGroupPrimaryDirToParty; if ((AL0439_i_GroupCells = L0443_s_ActiveGroup._cells) == k255_CreatureTypeSingleCenteredCreature) { AL0439_i_TargetCell = _vm->getRandomNumber(2); } else { @@ -1524,7 +1504,7 @@ bool GroupMan::f207_isCreatureAttacking(Group* group, int16 mapX, int16 mapY, ui f193_stealFromChampion(group, AL0439_i_ChampionIndex); } else { AL0440_i_Damage = f230_getChampionDamage(group, AL0439_i_ChampionIndex) + 1; - L0442_ps_Champion = &_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex]; + Champion *L0442_ps_Champion = &_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex]; if (AL0440_i_Damage > L0442_ps_Champion->_maximumDamageReceived) { L0442_ps_Champion->_maximumDamageReceived = AL0440_i_Damage; L0442_ps_Champion->_directionMaximumDamageReceived = returnOppositeDir((direction)L0438_ui_PrimaryDirectionToParty); @@ -1537,7 +1517,7 @@ bool GroupMan::f207_isCreatureAttacking(Group* group, int16 mapX, int16 mapY, ui return true; } -void GroupMan::f229_setOrderedCellsToAttack(signed char* orderedCellsToAttack, int16 targetMapX, int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource) { +void GroupMan::f229_setOrderedCellsToAttack(signed char *orderedCellsToAttack, int16 targetMapX, int16 targetMapY, int16 attackerMapX, int16 attackerMapY, uint16 cellSource) { static signed char g23_orderedCellsToAttack[8][4] = { // @ G0023_aac_Graphic562_OrderedCellsToAttack {0, 1, 3, 2}, /* Attack South from position Northwest or Southwest */ {1, 0, 2, 3}, /* Attack South from position Northeast or Southeast */ @@ -1558,12 +1538,12 @@ void GroupMan::f229_setOrderedCellsToAttack(signed char* orderedCellsToAttack, i orderedCellsToAttack[i] = g23_orderedCellsToAttack[L0557_ui_OrderedCellsToAttackIndex][i]; } -void GroupMan::f193_stealFromChampion(Group* group, uint16 championIndex) { +void GroupMan::f193_stealFromChampion(Group *group, uint16 championIndex) { int16 L0391_i_Percentage; uint16 L0392_ui_StealFromSlotIndex; uint16 L0393_ui_Counter; Thing L0394_T_Thing; - Champion* L0395_ps_Champion; + Champion *L0395_ps_Champion; bool L0396_B_ObjectStolen; static unsigned char G0394_auc_StealFromSlotIndices[8]; /* Initialized with 0 bytes by C loader */ @@ -1597,10 +1577,10 @@ void GroupMan::f193_stealFromChampion(Group* group, uint16 championIndex) { } } -int16 GroupMan::f230_getChampionDamage(Group* group, uint16 champIndex) { +int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) { unsigned char g24_woundProbabilityIndexToWoundMask[4] = {32, 16, 8, 4}; // @ G0024_auc_Graphic562_WoundProbabilityIndexToWoundMask - Champion* L0562_ps_Champion; + Champion *L0562_ps_Champion; int16 L0558_i_Multiple; #define AL0558_i_Attack L0558_i_Multiple #define AL0558_i_Damage L0558_i_Multiple @@ -1667,12 +1647,12 @@ T0230014: } void GroupMan::f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 mapY) { - Group* L0363_ps_Group; + Group *L0363_ps_Group; int16 L0364_i_CreatureType; if (_g391_dropMovingCreatureFixedPossCellCount) { - L0363_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(thing); + L0363_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(thing); L0364_i_CreatureType = L0363_ps_Group->_type; while (_g391_dropMovingCreatureFixedPossCellCount) { f186_dropCreatureFixedPossessions(L0364_i_CreatureType, mapX, mapY, _g392_dropMovingCreatureFixedPossessionsCell[--_g391_dropMovingCreatureFixedPossCellCount], k2_soundModePlayOneTickLater); @@ -1681,11 +1661,11 @@ void GroupMan::f187_dropMovingCreatureFixedPossession(Thing thing, int16 mapX, i } void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) { - Group* L0332_ps_Group; + Group *L0332_ps_Group; TimelineEvent L0333_s_Event; - L0332_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(mapX, mapY)); + L0332_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(_vm->_groupMan->f175_groupGetThing(mapX, mapY)); if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) { L0332_ps_Group->setBehaviour(k0_behavior_WANDER); } @@ -1700,8 +1680,8 @@ void GroupMan::f180_startWanedring(int16 mapX, int16 mapY) { void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) { uint16 L0339_ui_CreatureIndex; - Group* L0340_ps_Group; - ActiveGroup* L0341_ps_ActiveGroup; + Group *L0340_ps_Group; + ActiveGroup *L0341_ps_ActiveGroup; int16 L0344_i_ActiveGroupIndex; @@ -1719,7 +1699,7 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) { L0341_ps_ActiveGroup++; } _g377_currActiveGroupCount++; - L0340_ps_Group = ((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType()); + L0340_ps_Group = ((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType()); L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells; L0340_ps_Group->getActiveGroupIndex() = L0344_i_ActiveGroupIndex; L0341_ps_ActiveGroup->_priorMapX = L0341_ps_ActiveGroup->_homeMapX = mapX; @@ -1734,15 +1714,15 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) { } void GroupMan::f184_removeActiveGroup(uint16 activeGroupIndex) { - ActiveGroup* L0347_ps_ActiveGroup; - Group* L0348_ps_Group; + ActiveGroup *L0347_ps_ActiveGroup; + Group *L0348_ps_Group; if ((activeGroupIndex > _vm->_groupMan->_g376_maxActiveGroupCount) || (_vm->_groupMan->_g375_activeGroups[activeGroupIndex]._groupThingIndex < 0)) { return; } L0347_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[activeGroupIndex]; - L0348_ps_Group = &((Group*)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex]; + L0348_ps_Group = &((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[L0347_ps_ActiveGroup->_groupThingIndex]; _g377_currActiveGroupCount--; L0348_ps_Group->_cells = L0347_ps_ActiveGroup->_cells; L0348_ps_Group->setDir(M21_normalizeModulo4(L0347_ps_ActiveGroup->_directions)); @@ -1764,8 +1744,8 @@ void GroupMan::f195_addAllActiveGroups() { uint16 L0398_ui_MapX; uint16 L0399_ui_MapY; Thing L0400_T_Thing; - byte* L0401_puc_Square; - Thing* L0402_pT_SquareFirstThing; + byte *L0401_puc_Square; + Thing *L0402_pT_SquareFirstThing; L0401_puc_Square = _vm->_dungeonMan->_g271_currMapData[0]; -- cgit v1.2.3 From 2c860f106977677f59c3843312ea19b24bfe5d31 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:50:26 +0200 Subject: DM: Some soft refactoring, in order to silent some CppCheck warnings --- engines/dm/dungeonman.cpp | 215 +++++++++++++++++++++++++--------------------- engines/dm/eventman.cpp | 13 +-- engines/dm/inventory.cpp | 18 ++-- engines/dm/movesens.cpp | 5 +- 4 files changed, 127 insertions(+), 124 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 3b009c2e31..545b11f553 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -419,8 +419,6 @@ DungeonMan::~DungeonMan() { delete[] _g260_dungeonTextData; delete[] _g279_dungeonMapData; for (uint16 i = 0; i < 16; ++i) { - if (_g284_thingData[i]) - delete[] _g284_thingData[i][0]; delete[] _g284_thingData[i]; } } @@ -653,34 +651,34 @@ void DungeonMan::f434_loadDungeonFile() { continue; if (_g284_thingData[thingType]) { - delete[] _g284_thingData[thingType][0]; delete[] _g284_thingData[thingType]; } - _g284_thingData[thingType] = new uint16*[_g278_dungeonFileHeader._thingCounts[thingType]]; - _g284_thingData[thingType][0] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount]; - for (uint16 i = 0; i < _g278_dungeonFileHeader._thingCounts[thingType]; ++i) - _g284_thingData[thingType][i] = _g284_thingData[thingType][0] + i * thingStoreWordCount; + _g284_thingData[thingType] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount]; if (thingType == k4_GroupThingType) { - for (uint16 i = 0; i < thingCount; ++i) + for (uint16 i = 0; i < thingCount; ++i) { + uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount; for (uint16 j = 0; j < thingStoreWordCount; ++j) { if (j == 2 || j == 3) - _g284_thingData[thingType][i][j] = dunDataStream.readByte(); + nextSlot[j] = dunDataStream.readByte(); else - _g284_thingData[thingType][i][j] = dunDataStream.readUint16BE(); + nextSlot[j] = dunDataStream.readUint16BE(); } + } } else if (thingType == k14_ProjectileThingType) { for (uint16 i = 0; i < thingCount; ++i) { - _g284_thingData[thingType][i][0] = dunDataStream.readUint16BE(); - _g284_thingData[thingType][i][1] = dunDataStream.readUint16BE(); - _g284_thingData[thingType][i][2] = dunDataStream.readByte(); - _g284_thingData[thingType][i][3] = dunDataStream.readByte(); - _g284_thingData[thingType][i][4] = dunDataStream.readUint16BE(); + uint16 *nextSlot = _g284_thingData[thingType] + i * thingStoreWordCount; + nextSlot[0] = dunDataStream.readUint16BE(); + nextSlot[1] = dunDataStream.readUint16BE(); + nextSlot[2] = dunDataStream.readByte(); + nextSlot[3] = dunDataStream.readByte(); + nextSlot[4] = dunDataStream.readUint16BE(); } } else { for (uint16 i = 0; i < thingCount; ++i) { + uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount; for (uint16 j = 0; j < thingStoreWordCount; ++j) - _g284_thingData[thingType][i][j] = dunDataStream.readUint16BE(); + nextSlot[j] = dunDataStream.readUint16BE(); } } @@ -688,7 +686,7 @@ void DungeonMan::f434_loadDungeonFile() { if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType) _vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType]; for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) { - _g284_thingData[thingType][thingCount + i][0] = Thing::_none.toUint16(); + (_g284_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16(); } } } @@ -757,33 +755,36 @@ void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) { Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) { - bool isInXBounds = (mapX >= 0) && (mapX < _g273_currMapWidth); - bool isInYBounds = (mapY >= 0) && (mapY < _g274_currMapHeight); - - if (isInXBounds && isInYBounds) - return Square(_g271_currMapData[mapX][mapY]); - - - Square tmpSquare; - if (isInYBounds) { - tmpSquare.set(_g271_currMapData[0][mapY]); - if (mapX == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square(k0_WallElemType).set(k0x0004_WallEastRandOrnAllowed); - - tmpSquare.set(_g271_currMapData[_g273_currMapWidth - 1][mapY]); - if (mapX == _g273_currMapWidth && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square(k0_WallElemType).set(k0x0001_WallWestRandOrnAllowed); - } else if (isInXBounds) { - tmpSquare.set(_g271_currMapData[mapX][0]); - if (mapY == -1 && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square(k0_WallElemType).set(k0x0002_WallSouthRandOrnAllowed); - - tmpSquare.set(_g271_currMapData[mapX][_g274_currMapHeight - 1]); - if (mapY == _g274_currMapHeight && (tmpSquare.getType() == k1_CorridorElemType || tmpSquare.getType() == k2_PitElemType)) - return Square((k0_WallElemType << 5) | k0x0008_WallNorthRandOrnAllowed); + int16 L0248_i_Multiple; +#define AL0248_B_IsMapXInBounds L0248_i_Multiple +#define AL0248_i_SquareType L0248_i_Multiple + int16 L0249_i_Multiple; +#define AL0249_B_IsMapYInBounds L0249_i_Multiple +#define AL0249_i_SquareType L0249_i_Multiple + + AL0249_B_IsMapYInBounds = (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight); + if ((AL0248_B_IsMapXInBounds = (mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth)) && AL0249_B_IsMapYInBounds) { + return Square(_vm->_dungeonMan->_g271_currMapData[mapX][mapY]); } - return Square(k0_WallElemType); + if (AL0249_B_IsMapYInBounds) { + if (((mapX == -1) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[0][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0004_WallEastRandOrnAllowed); + } + if (((mapX == _vm->_dungeonMan->_g273_currMapWidth) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[_vm->_dungeonMan->_g273_currMapWidth - 1][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0001_WallWestRandOrnAllowed); + } + } else { + if (AL0248_B_IsMapXInBounds) { + if (((mapY == -1) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][0]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed); + } + if (((mapY == _vm->_dungeonMan->_g274_currMapHeight) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][_vm->_dungeonMan->_g274_currMapHeight - 1]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) { + return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed); + } + } + } + return Square(k0_ElementTypeWall, 0); } Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { @@ -792,17 +793,23 @@ Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 st } int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) { - if (mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight || !Square(_g271_currMapData[mapX][mapY]).get(k0x0010_ThingListPresent)) - return -1; + uint16 L0260_ui_ThingIndex; + int16 L0261_i_MapY; + register unsigned char* L0262_puc_Square; - int16 y = 0; - uint16 index = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; - byte* square = _g271_currMapData[mapX]; - while (y++ != mapY) - if (Square(*square++).get(k0x0010_ThingListPresent)) - index++; - return index; + L0262_puc_Square = _vm->_dungeonMan->_g271_currMapData[mapX]; + if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight) || !getFlag(L0262_puc_Square[mapY], k0x0010_ThingListPresent)) { + return -1; + } + L0261_i_MapY = 0; + L0260_ui_ThingIndex = _vm->_dungeonMan->_g270_currMapColCumulativeSquareFirstThingCount[mapX]; + while (L0261_i_MapY++ != mapY) { + if (getFlag(*L0262_puc_Square++, k0x0010_ThingListPresent)) { + L0260_ui_ThingIndex++; + } + } + return L0260_ui_ThingIndex; } Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) { @@ -959,31 +966,33 @@ T0172049_Footprints: aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16(); } -void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, +void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir, int16 mapX, int16 mapY, bool isFakeWall) { - int16 ornCount = _g269_currMap->_randWallOrnCount; - - turnDirRight(dir); - aspectArray[k2_RightWallOrnOrdAspect] = f170_getRandomOrnOrdinal(leftAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - turnDirRight(dir); - aspectArray[k3_FrontWallOrnOrdAspect] = f170_getRandomOrnOrdinal(frontAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - turnDirRight(dir); - aspectArray[k4_LeftWallOrnOrdAspect] = f170_getRandomOrnOrdinal(rightAllowed, ornCount, mapX, ++mapY * (dir + 1), 30); - - if (isFakeWall || mapX < 0 || mapX >= _g273_currMapWidth || mapY < 0 || mapY >= _g274_currMapHeight) { - for (uint16 i = k2_RightWallOrnOrdAspect; i <= k4_LeftWallOrnOrdAspect; ++i) { - if (f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[i]))) - aspectArray[i] = 0; + int16 L0306_i_Multiple; +#define AL0306_i_RandomWallOrnamentCount L0306_i_Multiple +#define AL0306_i_SideIndex L0306_i_Multiple + + + AL0306_i_RandomWallOrnamentCount = _vm->_dungeonMan->_g269_currMap->_randWallOrnCount; + aspectArray[k2_RightWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(leftAllowed, AL0306_i_RandomWallOrnamentCount, mapX, ++mapY * (M21_normalizeModulo4(++dir) + 1), 30); + aspectArray[k3_FrontWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(frontAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY * (M21_normalizeModulo4(++dir) + 1), 30); + aspectArray[k4_LeftWallOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(rightAllowed, AL0306_i_RandomWallOrnamentCount, mapX, mapY-- * (M21_normalizeModulo4(++dir) + 1), 30); + if (isFakeWall || (mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight)) { /* If square is a fake wall or is out of map bounds */ + for (AL0306_i_SideIndex = k2_RightWallOrnOrdAspect; AL0306_i_SideIndex <= k4_LeftWallOrnOrdAspect; AL0306_i_SideIndex++) { /* Loop to remove any random ornament that is an alcove */ + if (_vm->_dungeonMan->f149_isWallOrnAnAlcove(_vm->M1_ordinalToIndex(aspectArray[AL0306_i_SideIndex]))) { + aspectArray[AL0306_i_SideIndex] = 0; + } } } } int16 DungeonMan::f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo) { - int16 index = (((((2000 + (mapX << 5) + mapY) * 31417) >> 1) - + (3000 + (_g272_currMapIndex << 6) + _g273_currMapWidth + _g274_currMapHeight) * 11 - + _g278_dungeonFileHeader._ornamentRandomSeed) >> 2) % modulo; - if (allowed && index < count) - return _vm->M0_indexToOrdinal(index); + int16 L0305_i_RandomOrnamentIndex; + + + if (allowed && ((L0305_i_RandomOrnamentIndex = f169_getRandomOrnamentIndex((int16)2000 + (mapX << 5) + mapY, (int16)3000 + (_vm->_dungeonMan->_g272_currMapIndex << (int16)6) + _vm->_dungeonMan->_g273_currMapWidth + _vm->_dungeonMan->_g274_currMapHeight, modulo)) < count)) { + return _vm->M0_indexToOrdinal(L0305_i_RandomOrnamentIndex); + } return 0; } @@ -997,7 +1006,7 @@ bool DungeonMan::f149_isWallOrnAnAlcove(int16 wallOrnIndex) { } uint16 *DungeonMan::f156_getThingData(Thing thing) { - return _g284_thingData[thing.getType()][thing.getIndex()]; + return _g284_thingData[thing.getType()] + thing.getIndex() * g235_ThingDataWordCount[thing.getType()]; } uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) { @@ -1005,7 +1014,7 @@ uint16* DungeonMan::f157_getSquareFirstThingData(int16 mapX, int16 mapY) { } Thing DungeonMan::f159_getNextThing(Thing thing) { - return Thing(f156_getThingData(thing)[0]); // :) + return Thing(f156_getThingData(thing)[0]); } char g255_MessageAndScrollEscReplacementStrings[32][8] = { // @ G0255_aac_Graphic559_MessageAndScrollEscapeReplacementStrings @@ -1110,7 +1119,7 @@ char g257_InscriptionEscReplacementStrings[32][8] = { // @ G0257_aac_Graphic559_ void DungeonMan::f168_decodeText(char *destString, Thing thing, TextType type) { - TextString textString(_g284_thingData[k2_TextstringType][thing.getIndex()]); + TextString textString(_g284_thingData[k2_TextstringType] + thing.getIndex() * g235_ThingDataWordCount[k2_TextstringType]); if ((textString.isVisible()) || (type & k0x8000_DecodeEvenIfInvisible)) { type = (TextType)(type & ~k0x8000_DecodeEvenIfInvisible); char sepChar; @@ -1307,43 +1316,43 @@ void DungeonMan::f163_linkThingToList(Thing thingToLink, Thing thingInList, int1 if (thingToLink == Thing::_endOfList) return; - uint16 *rawObjPtr = f156_getThingData(thingToLink); - *rawObjPtr = Thing::_endOfList.toUint16(); - + Thing *L0269_ps_Generic = (Thing *)f156_getThingData(thingToLink); + *L0269_ps_Generic = Thing::_endOfList; + /* If mapX >= 0 then the thing is linked to the list of things on the specified square else it is linked at the end of the specified thing list */ if (mapX >= 0) { - Square *squarePtr = (Square*)&_g271_currMapData[mapX][mapY]; - if (squarePtr->get(k0x0010_ThingListPresent)) { + byte *L0268_puc_Square = &_g271_currMapData[mapX][mapY]; + if (getFlag(*L0268_puc_Square, k0x0010_ThingListPresent)) { thingInList = f161_getSquareFirstThing(mapX, mapY); } else { - squarePtr->set(k0x0010_ThingListPresent); - uint16 *cumulativeCount = &_g270_currMapColCumulativeSquareFirstThingCount[mapX + 1]; - uint16 column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1; - while (column--) { - (*cumulativeCount++)++; + setFlag(*L0268_puc_Square, k0x0010_ThingListPresent); + uint16 * tmp = _g270_currMapColCumulativeSquareFirstThingCount + mapX + 1; + uint16 AL0266_ui_Column = _g282_dungeonColumCount - (_g281_dungeonMapsFirstColumnIndex[_g272_currMapIndex] + mapX) - 1; + while (AL0266_ui_Column--) { /* For each column starting from and after the column containing the square where the thing is added */ + (*tmp++)++; /* Increment the cumulative first thing count */ } - uint16 mapYStep = 0; - squarePtr -= mapY; - uint16 squareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; - while (mapYStep++ != mapY) { - if (squarePtr->get(k0x0010_ThingListPresent)) { - squareFirstThingIndex++; + uint16 L0270_ui_MapY = 0; + L0268_puc_Square -= mapY; + uint16 AL0266_ui_SquareFirstThingIndex = _g270_currMapColCumulativeSquareFirstThingCount[mapX]; + while (L0270_ui_MapY++ != mapY) { + if (getFlag(*L0268_puc_Square++, k0x0010_ThingListPresent)) { + AL0266_ui_SquareFirstThingIndex++; } - squarePtr++; } - Thing* thingPtr = &_g283_squareFirstThings[squareFirstThingIndex]; - memmove(thingPtr + 1, thingPtr, sizeof(Thing) * (_g278_dungeonFileHeader._squareFirstThingCount - squareFirstThingIndex - 1)); - *thingPtr = thingToLink; + Thing *L0267_pT_Thing = &_g283_squareFirstThings[AL0266_ui_SquareFirstThingIndex]; + // the second '- 1' is for the loop initialization, > 0 is because we are copying from one behind + for (int16 i = _g278_dungeonFileHeader._squareFirstThingCount - AL0266_ui_SquareFirstThingIndex - 1 - 1; i > 0; --i) + L0267_pT_Thing[i] = L0267_pT_Thing[i - 1]; + + *L0267_pT_Thing = thingToLink; return; } } - - Thing thing = f159_getNextThing(thingInList); - while (thing != Thing::_endOfList) { - thing = f159_getNextThing(thing); - thingInList = thing; + Thing L0265_T_Thing = f159_getNextThing(thingInList); + while (L0265_T_Thing != Thing::_endOfList) { + L0265_T_Thing = f159_getNextThing(thingInList = L0265_T_Thing); } - rawObjPtr = f156_getThingData(thingInList); - *rawObjPtr = thingToLink.toUint16(); + L0269_ps_Generic = (Thing *)f156_getThingData(thingInList); + *L0269_ps_Generic = thingToLink; } WeaponInfo* DungeonMan::f158_getWeaponInfo(Thing thing) { @@ -1695,4 +1704,10 @@ Thing DungeonMan::f167_getObjForProjectileLaucherOrObjGen(uint16 iconIndex) { } return L0295_T_Thing; } + +int16 DungeonMan::f169_getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo) { + return ((((((val1 * 31417) & 0xFFFF) >> 1) + ((val2 * 11) & 0xFFFF) + + _vm->_dungeonMan->_g278_dungeonFileHeader._ornamentRandomSeed) & 0xFFFF) >> 2) % modulo; /* Pseudorandom number generator */ +} + } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 204a29640e..da7da401b0 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -351,14 +351,13 @@ void EventManager::f68_setPointerToObject(byte* bitmap) { 100, 110, 0, 130, 140, 150}; // @ G0044_auc_Graphic562_PaletteChanges_MousePointerIcon static Box g619_BoxMousePointerObjectShadow(2, 17, 2, 17); // @ G0619_s_Box_MousePointer_ObjectShadow static Box g620_BoxMousePointerObject(0, 15, 0, 15); // @ G0620_s_Box_MousePointer_Object - byte* L0051_puc_Bitmap; _gK100_preventBuildPointerScreenArea = true; _g600_useObjectAsMousePointerBitmap = true; _g601_useHandAsMousePointerBitmap = false; _g598_mousePointerBitmapUpdated = true; _vm->_displayMan->_g578_useByteBoxCoordinates = true; - L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject; + byte *L0051_puc_Bitmap = _g615_mousePointerOriginalColorsObject; memset(L0051_puc_Bitmap, 0, 32 * 18); /* @@ -367,6 +366,7 @@ void EventManager::f68_setPointerToObject(byte* bitmap) { _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, g44_palChangesMousePointerIcon); _vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18); */ + warning("TODO - Call f129_blitToBitmapShrinkWithPalChange"); // dummy code _vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18); _vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18); @@ -376,15 +376,11 @@ void EventManager::f68_setPointerToObject(byte* bitmap) { } void EventManager::f71_mouseDropChampionIcon() { - bool L0057_B_UseByteBoxCoordinatesBackup; - uint16 L0058_ui_ChampionIconIndex; - - _gK100_preventBuildPointerScreenArea = true; - L0058_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap); + uint16 L0058_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap); _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone); _vm->_eventMan->_g598_mousePointerBitmapUpdated = true; - L0057_B_UseByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates; + bool L0057_B_UseByteBoxCoordinatesBackup = _vm->_displayMan->_g578_useByteBoxCoordinates; _vm->_displayMan->f21_blitToScreen(_g613_mousePointerOriginalColorsChampionIcon, &g54_BoxChampionIcons[L0058_ui_ChampionIconIndex << 2], 16, k12_ColorDarkestGray, 18); _vm->_displayMan->_g578_useByteBoxCoordinates = L0057_B_UseByteBoxCoordinatesBackup; _gK100_preventBuildPointerScreenArea = false; @@ -394,7 +390,6 @@ void EventManager::f73_buildpointerScreenArea(int16 mousePosX, int16 mousePosY) uint16 L1577_i_ChampionIndex; int16 L1578_i_XOverChampionStatusBox; - // if (_gK100_preventBuildPointerScreenArea) // return; diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index b72be8a7f8..c1d2aedd8a 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -556,9 +556,6 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) { } void InventoryMan::f337_setDungeonViewPalette() { - int16 L1036_i_TotalLightAmount; - uint16 L1037_ui_TorchLightAmountMultiplier; - int16 L1038_i_Counter; uint16 L1039_ui_Multiple; #define AL1039_ui_SlotIndex L1039_ui_Multiple #define AL1039_ui_PaletteIndex L1039_ui_Multiple @@ -566,9 +563,6 @@ void InventoryMan::f337_setDungeonViewPalette() { int16* L1040_pi_Multiple; #define AL1040_pi_TorchLightPower L1040_pi_Multiple #define AL1040_pi_LightAmount L1040_pi_Multiple - int16* L1041_pi_TorchLightPower; - Weapon* L1042_ps_Weapon; - Champion* L1043_ps_Champion; uint16 L1044_ui_Multiple; #define AL1044_T_Thing L1044_ui_Multiple #define AL1044_ui_TorchLightPower L1044_ui_Multiple @@ -580,15 +574,15 @@ void InventoryMan::f337_setDungeonViewPalette() { _vm->_displayMan->_g304_dungeonViewPaletteIndex = 0; /* Brightest color palette index */ } else { /* Get torch light power from both hands of each champion in the party */ - L1038_i_Counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */ - L1043_ps_Champion = _vm->_championMan->_gK71_champions; + int16 L1038_i_Counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */ + Champion *L1043_ps_Champion = _vm->_championMan->_gK71_champions; AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower; while (L1038_i_Counter--) { AL1039_ui_SlotIndex = k1_ChampionSlotActionHand + 1; while (AL1039_ui_SlotIndex--) { if ((_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16())) >= k4_IconIndiceWeaponTorchUnlit) && (_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16())) <= k7_IconIndiceWeaponTorchLit)) { - L1042_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(Thing(AL1044_T_Thing)); + Weapon *L1042_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(Thing(AL1044_T_Thing)); *AL1040_pi_TorchLightPower = L1042_ps_Weapon->getChargeCount(); } else { *AL1040_pi_TorchLightPower = 0; @@ -602,7 +596,7 @@ void InventoryMan::f337_setDungeonViewPalette() { AL1039_ui_Counter = 0; while (AL1039_ui_Counter != 4) { L1038_i_Counter = 7 - AL1039_ui_Counter; - L1041_pi_TorchLightPower = &L1045_ai_TorchesLightPower[AL1039_ui_Counter + 1]; + int16 *L1041_pi_TorchLightPower = &L1045_ai_TorchesLightPower[AL1039_ui_Counter + 1]; while (L1038_i_Counter--) { if (*L1041_pi_TorchLightPower > *AL1040_pi_TorchLightPower) { AL1044_ui_TorchLightPower = *L1041_pi_TorchLightPower; @@ -615,9 +609,9 @@ void InventoryMan::f337_setDungeonViewPalette() { AL1039_ui_Counter++; } /* Get total light amount provided by the four torches with the highest light power values and by the fifth torch in the array which may be any one of the four torches with the smallest ligh power values */ - L1037_ui_TorchLightAmountMultiplier = 6; + uint16 L1037_ui_TorchLightAmountMultiplier = 6; AL1039_ui_Counter = 5; - L1036_i_TotalLightAmount = 0; + int16 L1036_i_TotalLightAmount = 0; AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower; while (AL1039_ui_Counter--) { if (*AL1040_pi_TorchLightPower) { diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index cb73d3f9a4..93d78ed5fa 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -1008,8 +1008,6 @@ void MovesensMan::f270_sensorTriggetLocalEffect(int16 localEffect, int16 effX, i } void MovesensMan::f269_sensorAddSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly) { - int16 L0730_i_ChampionIndex; - Champion* L0731_ps_Champion; if (leaderOnly) { if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) { @@ -1017,7 +1015,8 @@ void MovesensMan::f269_sensorAddSkillExperience(int16 skillIndex, uint16 exp, bo } } else { exp /= _vm->_championMan->_g305_partyChampionCount; - for (L0730_i_ChampionIndex = k0_ChampionFirst, L0731_ps_Champion = _vm->_championMan->_gK71_champions; L0730_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0730_i_ChampionIndex++, L0731_ps_Champion++) { + Champion *L0731_ps_Champion = _vm->_championMan->_gK71_champions; + for (int16 L0730_i_ChampionIndex = k0_ChampionFirst; L0730_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0730_i_ChampionIndex++, L0731_ps_Champion++) { if (L0731_ps_Champion->_currHealth) { _vm->_championMan->f304_addSkillExperience(L0730_i_ChampionIndex, skillIndex, exp); } -- cgit v1.2.3 From af42277a93bfb9286c6487f0820d45899547f55f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 10 Jul 2016 12:23:27 +0200 Subject: DM: Reduce some variable scopes, silent CppCheck warnings --- engines/dm/objectman.cpp | 9 +++------ engines/dm/projexpl.cpp | 41 +++++++++++++++++------------------------ 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 05a86de66a..ea07c582bf 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -138,15 +138,12 @@ IconIndice ObjectMan::f32_getObjectType(Thing thing) { byte g29_ChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType IconIndice ObjectMan::f33_getIconIndex(Thing thing) { - int16 L0005_i_IconIndex; - Junk* L0006_ps_Junk; - - - if ((L0005_i_IconIndex = _vm->_objectMan->f32_getObjectType(thing)) != kM1_IconIndiceNone) { + int16 L0005_i_IconIndex = _vm->_objectMan->f32_getObjectType(thing); + if (L0005_i_IconIndex != kM1_IconIndiceNone) { if (((L0005_i_IconIndex < k32_IconIndiceWeaponDagger) && (L0005_i_IconIndex >= k0_IconIndiceJunkCompassNorth)) || ((L0005_i_IconIndex >= k148_IconIndicePotionMaPotionMonPotion) && (L0005_i_IconIndex <= k163_IconIndicePotionWaterFlask)) || (L0005_i_IconIndex == k195_IconIndicePotionEmptyFlask)) { - L0006_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing); + Junk *L0006_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing); switch (L0005_i_IconIndex) { case k0_IconIndiceJunkCompassNorth: L0005_i_IconIndex += _vm->_dungeonMan->_g308_partyDir; diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index 4c0821487d..c312be1f4b 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -294,20 +294,14 @@ uint16 ProjExpl::f216_projectileGetImpactAttack(Projectile* projectile, Thing th void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXCombo, uint16 mapYCombo, uint16 cell) { #define AP0443_ui_ProjectileMapX mapXCombo #define AP0444_ui_ProjectileMapY mapYCombo - Explosion* L0470_ps_Explosion; - CreatureInfo* L0471_ps_CreatureInfo; - Group* L0472_ps_Group; - Thing L0473_T_Thing; - int16 L0474_i_ProjectileTargetMapX; - int16 L0475_i_ProjectileTargetMapY; - int16 L0469_i_CreatureFireResistance; - TimelineEvent L0476_s_Event; - - - if ((L0473_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType)) == Thing::_none) { + Thing L0473_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType); + if (L0473_T_Thing == Thing::_none) { return; } - L0470_ps_Explosion = &((Explosion *)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[(L0473_T_Thing).getIndex()]; + + Explosion *L0470_ps_Explosion = &((Explosion *)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[(L0473_T_Thing).getIndex()]; + int16 L0474_i_ProjectileTargetMapX; + int16 L0475_i_ProjectileTargetMapY; if (mapXCombo <= 255) { L0474_i_ProjectileTargetMapX = mapXCombo; L0475_i_ProjectileTargetMapY = mapYCombo; @@ -334,6 +328,7 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC } } _vm->_dungeonMan->f163_linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY); + TimelineEvent L0476_s_Event; M33_setMapAndTime(L0476_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + ((explThing == Thing::_explRebirthStep1) ? 5 : 1)); L0476_s_Event._type = k25_TMEventTypeExplosion; L0476_s_Event._priority = 0; @@ -351,9 +346,10 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC _vm->_championMan->f324_damageAll_getDamagedChampionCount(attack, k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand | k0x0004_ChampionWoundHead | k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k1_attackType_FIRE); } else { if ((L0473_T_Thing = _vm->_groupMan->f175_groupGetThing(AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY)) != Thing::_endOfList) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */ - L0472_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0473_T_Thing); - L0471_ps_CreatureInfo = &g243_CreatureInfo[L0472_ps_Group->_type]; - if ((L0469_i_CreatureFireResistance = (L0471_ps_CreatureInfo->M60_getFireResistance())) != k15_immuneToFire) { + Group *L0472_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0473_T_Thing); + CreatureInfo *L0471_ps_CreatureInfo = &g243_CreatureInfo[L0472_ps_Group->_type]; + int16 L0469_i_CreatureFireResistance = L0471_ps_CreatureInfo->M60_getFireResistance(); + if (L0469_i_CreatureFireResistance != k15_immuneToFire) { if (getFlag(L0471_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) { attack >>= 2; } @@ -400,16 +396,13 @@ void ProjExpl::f214_projectileDeleteEvent(Thing thing) { } void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, int16 mapX, int16 mapY) { - Thing L0478_T_PreviousThing; - Thing L0479_T_Thing; - Projectile* L0480_ps_Projectile; - Thing* L0481_ps_Generic; - - L0480_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(projectileThing); - if ((L0479_T_Thing = L0480_ps_Projectile->_slot).getType() != k15_ExplosionThingType) { + Projectile *L0480_ps_Projectile = (Projectile *)_vm->_dungeonMan->f156_getThingData(projectileThing); + Thing L0479_T_Thing = L0480_ps_Projectile->_slot; + if (L0479_T_Thing.getType() != k15_ExplosionThingType) { if (groupSlot != NULL) { - if ((L0478_T_PreviousThing = *groupSlot) == Thing::_endOfList) { - L0481_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0479_T_Thing); + Thing L0478_T_PreviousThing = *groupSlot; + if (L0478_T_PreviousThing == Thing::_endOfList) { + Thing *L0481_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0479_T_Thing); *L0481_ps_Generic = Thing::_endOfList; *groupSlot = L0479_T_Thing; } else { -- cgit v1.2.3 From 9c4236d0392f8e8c844566d8af9cb514d91b56d0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 10 Jul 2016 12:34:41 +0200 Subject: DM: Remove extra parenthesis --- engines/dm/dungeonman.cpp | 2 +- engines/dm/movesens.cpp | 48 +++++++++++++++++++++-------------------------- engines/dm/projexpl.cpp | 2 +- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 545b11f553..3c03749345 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1470,7 +1470,7 @@ Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) { if ((L0279_ui_MapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && ((L0276_ui_MapX - _vm->_dungeonMan->_g306_partyMapX + 5) <= 10) && ((L0277_ui_MapY - _vm->_dungeonMan->_g307_partyMapY + 5) <= 10)) /* If square is too close to the party */ goto T0165029; do { - if ((L0287_i_ThingType = (L0278_T_Thing).getType()) == k3_SensorThingType) { + if ((L0287_i_ThingType = L0278_T_Thing.getType()) == k3_SensorThingType) { L0282_ps_Generic = (Thing*)_vm->_dungeonMan->f156_getThingData(L0278_T_Thing); if (((Sensor*)L0282_ps_Generic)->getType()) /* If sensor is not disabled */ break; diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 93d78ed5fa..da8c5e506e 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -220,21 +220,10 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 int16 L0710_i_ThingType; Champion* L0711_ps_Champion; Teleporter* L0712_ps_Teleporter; - bool L0713_B_ThingLevitates; - uint16 L0714_ui_MapIndexSource = 0; - uint16 L0715_ui_MapIndexDestination = 0; - uint16 L0716_ui_Direction = 0; - uint16 L0717_ui_ThingCell = 0; int16 L0718_i_RequiredTeleporterScope; // Strangerke: Only present in v2.1, but it fixes a bug, so I propose to keep it int16 L0719_i_TraversedPitCount; uint16 L0720_ui_MoveGroupResult; - bool L0721_B_GroupOnPartyMap; - bool L0722_B_FallKilledGroup; - bool L0723_B_DrawDungeonViewWhileFalling; - bool L0724_B_DestinationIsTeleporterTarget; - bool L0725_B_PartySquare; - bool L0726_B_Audible; uint16 L0727_ui_Multiple; #define AL0727_ui_ThingCell L0727_ui_Multiple #define AL0727_ui_Outcome L0727_ui_Multiple @@ -243,18 +232,20 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 uint16 L1638_ui_MovementSoundIndex; L0710_i_ThingType = kM1_PartyThingType; - L0713_B_ThingLevitates = false; + bool L0713_B_ThingLevitates = false; L0719_i_TraversedPitCount = 0; L0720_ui_MoveGroupResult = 0; - L0721_B_GroupOnPartyMap = false; - L0722_B_FallKilledGroup = false; - L0723_B_DrawDungeonViewWhileFalling = false; - L0724_B_DestinationIsTeleporterTarget = false; - L0725_B_PartySquare = false; - L0726_B_Audible = false; + bool L0721_B_GroupOnPartyMap = false; + bool L0722_B_FallKilledGroup = false; + bool L0723_B_DrawDungeonViewWhileFalling = false; + bool L0724_B_DestinationIsTeleporterTarget = false; + bool L0725_B_PartySquare = false; + bool L0726_B_Audible = false; + + uint16 L0717_ui_ThingCell = 0; if (thing != Thing::_party) { - L0710_i_ThingType = (thing).getType(); - L0717_ui_ThingCell = (thing).getCell(); + L0710_i_ThingType = thing.getType(); + L0717_ui_ThingCell = thing.getCell(); L0713_B_ThingLevitates = f264_isLevitating(thing); } /* If moving the party or a creature on the party map from a dungeon square then check for a projectile impact */ @@ -263,9 +254,12 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 return true; /* The specified group thing cannot be moved because it was killed by a projectile impact */ } } + uint16 L0714_ui_MapIndexSource = 0; + uint16 L0715_ui_MapIndexDestination = 0; if (destMapX >= 0) { L0714_ui_MapIndexSource = L0715_ui_MapIndexDestination = _vm->_dungeonMan->_g272_currMapIndex; L0721_B_GroupOnPartyMap = (L0714_ui_MapIndexSource == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX >= 0); + uint16 L0716_ui_Direction = 0; if (thing == Thing::_party) { _vm->_dungeonMan->_g306_partyMapX = destMapX; _vm->_dungeonMan->_g307_partyMapY = destMapY; @@ -321,7 +315,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 thing = f263_getTeleporterRotatedProjectileThing(L0712_ps_Teleporter, thing); } else { if (!(L0712_ps_Teleporter->getAbsoluteRotation()) && (mapX != -2)) { - thing = M15_thingWithNewCell(thing, M21_normalizeModulo4((thing).getCell() + L0712_ps_Teleporter->getRotation())); + thing = M15_thingWithNewCell(thing, M21_normalizeModulo4(thing.getCell() + L0712_ps_Teleporter->getRotation())); } } } @@ -381,7 +375,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 L0716_ui_Direction = _vm->_dungeonMan->f155_getStairsExitDirection(destMapX, destMapY); destMapX += _vm->_dirIntoStepCountEast[L0716_ui_Direction], destMapY += _vm->_dirIntoStepCountNorth[L0716_ui_Direction]; L0716_ui_Direction = returnOppositeDir((direction)L0716_ui_Direction); - AL0727_ui_ThingCell = (thing).getCell(); + AL0727_ui_ThingCell = thing.getCell(); AL0727_ui_ThingCell = M21_normalizeModulo4((((AL0727_ui_ThingCell - L0716_ui_Direction + 1) & 0x0002) >> 1) + L0716_ui_Direction); thing = M15_thingWithNewCell(thing, AL0727_ui_ThingCell); } else @@ -401,7 +395,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 _g397_moveResultMapX = destMapX; _g398_moveResultMapY = destMapY; _g399_moveResultMapIndex = L0715_ui_MapIndexDestination; - _g401_moveResultCell = (thing).getCell(); + _g401_moveResultCell = thing.getCell(); L0725_B_PartySquare = (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) && (destMapX == mapX) && (destMapY == mapY); if (L0725_B_PartySquare) { if (thing == Thing::_party) { @@ -481,7 +475,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 f265_createEvent60to61_moveGroup(thing, destMapX, destMapY, L0715_ui_MapIndexDestination, L0726_B_Audible); return true; /* The specified group thing cannot be moved because the party or another group is on the destination square */ } - L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[(thing).getIndex()]._type); + L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[thing.getIndex()]._type); if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) { warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } @@ -530,7 +524,7 @@ bool MovesensMan::f264_isLevitating(Thing thing) { int16 L0695_i_ThingType; - if ((L0695_i_ThingType = (thing).getType()) == k4_GroupThingType) { + if ((L0695_i_ThingType = thing.getType()) == k4_GroupThingType) { return getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(thing), k0x0020_MaskCreatureInfo_levitation); } if (L0695_i_ThingType == k14_ProjectileThingType) { /* BUG0_26 An explosion may fall in a pit. If a pit is opened while there is an explosion above then the explosion falls into the pit in F0267_MOVE_GetMoveResult_CPSCE. Explosions are not considered as levitating so they are moved when the pit is opened. This function should return true for explosions */ @@ -767,7 +761,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m if (thing != Thing::_party) { - L0767_i_ThingType = (thing).getType(); + L0767_i_ThingType = thing.getType(); L0774_i_ObjectType = _vm->_objectMan->f32_getObjectType(thing); } else { L0767_i_ThingType = kM1_PartyThingType; @@ -777,7 +771,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m _vm->_dungeonMan->f164_unlinkThingFromList(thing, Thing(0), mapX, mapY); } if (Square(L0777_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType() == k0_ElementTypeWall) { - L0770_ui_SensorTriggeredCell = (thing).getCell(); + L0770_ui_SensorTriggeredCell = thing.getCell(); } else { L0770_ui_SensorTriggeredCell = (uint16)kM1_CellAny; // this will wrap around } diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index c312be1f4b..97240bc929 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -254,7 +254,7 @@ uint16 ProjExpl::f216_projectileGetImpactAttack(Projectile* projectile, Thing th _g367_projectileAttackType = k3_attackType_BLUNT; L0484_ui_KineticEnergy = projectile->_kineticEnergy; - if ((AL0483_ui_ThingType = (thing).getType()) != k15_ExplosionThingType) { + if ((AL0483_ui_ThingType = thing.getType()) != k15_ExplosionThingType) { if (AL0483_ui_ThingType == k5_WeaponThingType) { L0485_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(thing); AL0483_ui_Attack = L0485_ps_WeaponInfo->_kineticEnergy; -- cgit v1.2.3 From c8f6666480361e972032fe3f12a618b08815bc4f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 10 Jul 2016 12:46:14 +0200 Subject: DM: Remove some more extra parenthesis, remove a useless call to c_str() --- engines/dm/champion.cpp | 5 +++-- engines/dm/dungeonman.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 823a37f72c..117703453b 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -201,7 +201,7 @@ int16 ChampionMan::f279_getDecodedValue(char *string, uint16 characterCount) { } void ChampionMan::f289_drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) { - Common::String tmp = f288_getStringFromInteger(currVal, true, 3).c_str(); + Common::String tmp = f288_getStringFromInteger(currVal, true, 3); _vm->_textMan->f52_printToViewport(55, posY, k13_ColorLightestGray, tmp.c_str()); _vm->_textMan->f52_printToViewport(73, posY, k13_ColorLightestGray, "/"); tmp = f288_getStringFromInteger(maxVal, true, 3); @@ -781,7 +781,8 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) { clearFlag(woundIndex, k0x8000_maskUseSharpDefense); } for (L0943_ui_ArmourShieldDefense = 0, AL0942_i_SlotIndex = k0_ChampionSlotReadyHand; AL0942_i_SlotIndex <= k1_ChampionSlotActionHand; AL0942_i_SlotIndex++) { - if ((L0945_T_Thing = L0946_ps_Champion->_slots[AL0942_i_SlotIndex]).getType() == k6_ArmourThingType) { + L0945_T_Thing = L0946_ps_Champion->_slots[AL0942_i_SlotIndex]; + if (L0945_T_Thing.getType() == k6_ArmourThingType) { L0947_ps_ArmourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing); L0947_ps_ArmourInfo = &g239_ArmourInfo[((Armour *)L0947_ps_ArmourInfo)->getType()]; if (getFlag(L0947_ps_ArmourInfo->_attributes, k0x0080_ArmourAttributeIsAShield)) { diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 3c03749345..8cb1496de1 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1513,7 +1513,7 @@ T0165026: } _vm->_dungeonMan->f173_setCurrentMap(L0284_i_CurrentMapIndex); G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex; - return Thing((L0278_T_Thing).getTypeAndIndex()); + return Thing(L0278_T_Thing.getTypeAndIndex()); } } } while ((L0278_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0278_T_Thing)) != Thing::_endOfList); -- cgit v1.2.3 From 9272b18329de0a13a095f26b27a18c4a9023f485 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 10 Jul 2016 12:49:38 +0200 Subject: DM: Fix typo in comment --- engines/dm/dungeonman.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 8cb1496de1..e1a964f279 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -886,7 +886,7 @@ T0172010_ClosedFakeWall: aspectArray[sideIndex + 1] = _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex + 1; /* BUG0_76 The same text is drawn on multiple sides of a wall square. The engine stores only a single text to draw on a wall in a global variable. Even if different texts are placed on -differents sides of the wall, the same text is drawn on each affected side */ +different sides of the wall, the same text is drawn on each affected side */ _vm->_displayMan->_g290_inscriptionThing = thing; } } else { -- cgit v1.2.3 From 1f73323113c4194a8bc0ef41fcce88a1b8e37bd8 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 10:52:38 +0200 Subject: DM: Add proper keyboard input handling --- engines/dm/champion.cpp | 4 +- engines/dm/dm.cpp | 3 +- engines/dm/eventman.cpp | 105 ++++++++++++++++++++++++++++++++--------------- engines/dm/eventman.h | 14 ++++++- engines/dm/inventory.cpp | 4 +- 5 files changed, 89 insertions(+), 41 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 117703453b..2a2047e7b0 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -824,8 +824,8 @@ void ChampionMan::f314_wakeUp() { _vm->_displayMan->f98_drawFloorAndCeiling(); _vm->_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface; _vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement; - warning("MISSING CODE: set G0443_ps_PrimaryKeyboardInput"); - warning("MISSING CODE: G0444_ps_SecondaryKeyboardInput"); + _vm->_eventMan->_g443_primaryKeyboardInput = g458_primaryKeyboardInput_interface; + _vm->_eventMan->_g444_secondaryKeyboardInput = g459_secondaryKeyboardInput_movement; _vm->_eventMan->f357_discardAllInput(); _vm->_menuMan->f457_drawEnabledMenus(); } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index f591399e2c..d6a4a26ab1 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -240,7 +240,8 @@ void DMEngine::f462_startGame() { _eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface; _eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement; - warning("MISSING CODE: set primary/secondary keyboard input"); + _eventMan->_g443_primaryKeyboardInput = g458_primaryKeyboardInput_interface; + _eventMan->_g444_secondaryKeyboardInput = g459_secondaryKeyboardInput_movement; f3_processNewPartyMap(_dungeonMan->_g309_partyMapIndex); diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index da7da401b0..e5db995b5f 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -87,6 +87,50 @@ Box g462_BoxObjectPiles[4] = { // @ G0462_as_Graphic561_Box_ObjectPiles Box(112, 183, 122, 147), /* Back right */ Box(40, 111, 122, 147)}; /* Back left */ + +KeyboardInput g458_primaryKeyboardInput_interface[7] = { // @ G0458_as_Graphic561_PrimaryKeyboardInput_Interface + /* { Command, Code } */ + KeyboardInput(k7_CommandToggleInventoryChampion_0, Common::KEYCODE_F1, 0), /* F1 (1~) Atari ST: Code = 0x3B00 */ + KeyboardInput(k8_CommandToggleInventoryChampion_1, Common::KEYCODE_F2, 0), /* F2 (2~) Atari ST: Code = 0x3C00 */ + KeyboardInput(k9_CommandToggleInventoryChampion_2, Common::KEYCODE_F3, 0), /* F3 (3~) Atari ST: Code = 0x3D00 */ + KeyboardInput(k10_CommandToggleInventoryChampion_3, Common::KEYCODE_F4, 0), /* F4 (4~) Atari ST: Code = 0x3E00 */ + KeyboardInput(k140_CommandSaveGame, Common::KEYCODE_s, Common::KBD_CTRL), /* CTRL-S Atari ST: Code = 0x0013 */ + KeyboardInput(k147_CommandFreezeGame, Common::KEYCODE_ESCAPE, 0), /* Esc (0x1B) Atari ST: Code = 0x001B */ + KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)}; + + +KeyboardInput g459_secondaryKeyboardInput_movement[19] = { // @ G0459_as_Graphic561_SecondaryKeyboardInput_Movement + /* { Command, Code } */ + KeyboardInput(k1_CommandTurnLeft, Common::KEYCODE_KP4, 0), /* Numeric pad 4 Atari ST: Code = 0x5200 */ + KeyboardInput(k3_CommandMoveForward, Common::KEYCODE_KP5, 0), /* Numeric pad 5 Atari ST: Code = 0x4800 */ + KeyboardInput(k2_CommandTurnRight, Common::KEYCODE_KP6, 0), /* Numeric pad 6 Atari ST: Code = 0x4700 */ + KeyboardInput(k6_CommandMoveLeft, Common::KEYCODE_KP1, 0), /* Numeric pad 1 Atari ST: Code = 0x4B00 */ + KeyboardInput(k5_CommandMoveBackward, Common::KEYCODE_KP2, 0), /* Numeric pad 2 Atari ST: Code = 0x5000 */ + KeyboardInput(k4_CommandMoveRight, Common::KEYCODE_KP3, 0), /* Numeric pad 3 Atari ST: Code = 0x4D00. Remaining entries below not present */ + KeyboardInput(k3_CommandMoveForward, Common::KEYCODE_w, 0), /* Up Arrow (A) */ /*Differs for testing convenience*/ + KeyboardInput(k3_CommandMoveForward, Common::KEYCODE_w, Common::KBD_SHIFT), /* Shift Up Arrow (T) */ /*Differs for testing convenience*/ + KeyboardInput(k6_CommandMoveLeft, Common::KEYCODE_a, 0), /* Backward Arrow (D) */ /*Differs for testing convenience*/ + KeyboardInput(k6_CommandMoveLeft, Common::KEYCODE_a, Common::KBD_SHIFT), /* Shift Forward Arrow ( A) */ /*Differs for testing convenience*/ + KeyboardInput(k4_CommandMoveRight, Common::KEYCODE_d, 0), /* Forward Arrow (C) */ /*Differs for testing convenience*/ + KeyboardInput(k4_CommandMoveRight, Common::KEYCODE_d, Common::KBD_SHIFT), /* Shift Backward Arrow ( @) */ /*Differs for testing convenience*/ + KeyboardInput(k5_CommandMoveBackward, Common::KEYCODE_s, 0), /* Down arrow (B) */ /*Differs for testing convenience*/ + KeyboardInput(k5_CommandMoveBackward, Common::KEYCODE_s, Common::KBD_SHIFT), /* Shift Down arrow (S) */ /*Differs for testing convenience*/ + KeyboardInput(k1_CommandTurnLeft, Common::KEYCODE_q, 0), /* Del (0x7F) */ /*Differs for testing convenience*/ + KeyboardInput(k1_CommandTurnLeft, Common::KEYCODE_q, Common::KBD_SHIFT), /* Shift Del (0x7F) */ /*Differs for testing convenience*/ + KeyboardInput(k2_CommandTurnRight, Common::KEYCODE_e, 0), /* Help (?~) */ /*Differs for testing convenience*/ + KeyboardInput(k2_CommandTurnRight, Common::KEYCODE_e, Common::KBD_SHIFT), /* Shift Help (?~) */ /*Differs for testing convenience*/ + KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)}; +KeyboardInput g460_primaryKeyboardInput_partySleeping[3] = { // @ G0460_as_Graphic561_PrimaryKeyboardInput_PartySleeping + /* { Command, Code } */ + KeyboardInput(k146_CommandWakeUp, Common::KEYCODE_RETURN, 0), /* Return */ + KeyboardInput(k147_CommandFreezeGame, Common::KEYCODE_ESCAPE, 0), /* Esc */ + KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)}; +KeyboardInput g461_primaryKeyboardInput_frozenGame[2] = { // @ G0461_as_Graphic561_PrimaryKeyboardInput_FrozenGame + /* { Command, Code } */ + KeyboardInput(k148_CommandUnfreezeGame, Common::KEYCODE_ESCAPE, 0), /* Esc */ + KeyboardInput(k0_CommandNone, Common::KEYCODE_INVALID, 0)}; + + MouseInput g445_PrimaryMouseInput_Entrance[4] = { // @ G0445_as_Graphic561_PrimaryMouseInput_Entrance[4] /* { Command, Box.X1, Box.X2, Box.Y1, Box.Y2, Button } */ MouseInput(k200_CommandEntranceEnterDungeon, 244, 298, 45, 58, k1_LeftMouseButton), @@ -309,6 +353,8 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) { _g600_useObjectAsMousePointerBitmap = false; _g601_useHandAsMousePointerBitmap = false; _gK100_preventBuildPointerScreenArea = false; + _g443_primaryKeyboardInput = nullptr; + _g444_secondaryKeyboardInput = nullptr; } EventManager::~EventManager() { @@ -486,45 +532,36 @@ void EventManager::setMousePos(Common::Point pos) { void EventManager::processInput() { - DungeonMan &dungeonMan = *_vm->_dungeonMan; - Common::Event event; while (_vm->_system->getEventManager()->pollEvent(event)) { switch (event.type) { - // DUMMY CODE: case EVENT_KEYDOWN, only for testing - case Common::EVENT_KEYDOWN: + case Common::EVENT_KEYDOWN: { if (event.synthetic) break; - - switch (event.kbd.keycode) { - case Common::KEYCODE_w: - dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); - break; - case Common::KEYCODE_a: - dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); - break; - case Common::KEYCODE_s: - dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); - break; - case Common::KEYCODE_d: - dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); - break; - case Common::KEYCODE_q: - turnDirLeft(dungeonMan._g308_partyDir); - break; - case Common::KEYCODE_e: - turnDirRight(dungeonMan._g308_partyDir); - break; - case Common::KEYCODE_UP: - if (_dummyMapIndex < 13) - dungeonMan.f174_setCurrentMapAndPartyMap(++_dummyMapIndex); - break; - case Common::KEYCODE_DOWN: - if (_dummyMapIndex > 0) - dungeonMan.f174_setCurrentMapAndPartyMap(--_dummyMapIndex); - break; - default: - break; + if (_g443_primaryKeyboardInput) { + KeyboardInput *input = _g443_primaryKeyboardInput; + while (input->_commandToIssue != k0_CommandNone) { + if ((input->_key == event.kbd.keycode) && (input->_modifiers == (event.kbd.flags & input->_modifiers))) { + f360_processPendingClick(); // possible fix to BUG0_73 + _commandQueue.push(Command(Common::Point(-1, -1), input->_commandToIssue)); + break; + } + input++; + } + } + + if (_g444_secondaryKeyboardInput) { + KeyboardInput *input = _g444_secondaryKeyboardInput; + while (input->_commandToIssue != k0_CommandNone) { + if ((input->_key == event.kbd.keycode) && (input->_modifiers == (event.kbd.flags & input->_modifiers))) { + f360_processPendingClick(); // possible fix to BUG0_73 + _commandQueue.push(Command(Common::Point(-1, -1), input->_commandToIssue)); + break; + } + input++; + } + } + } case Common::EVENT_MOUSEMOVE: _mousePos = event.mouse; diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index d1ded67f35..eafb64ee1a 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -202,13 +202,21 @@ extern MouseInput* g480_PrimaryMouseInput_DialogSets[2][4]; // @ G0480_aaps_Prim class KeyboardInput { public: - Command _commandToIssue; + CommandType _commandToIssue; Common::KeyCode _key; byte _modifiers; - KeyboardInput(Command command, Common::KeyCode keycode, byte modifierFlags) : _commandToIssue(command), _key(keycode), _modifiers(modifierFlags) {} + KeyboardInput(CommandType command, Common::KeyCode keycode, byte modifierFlags) : _commandToIssue(command), _key(keycode), _modifiers(modifierFlags) {} }; // @ KEYBOARD_INPUT + + +extern KeyboardInput g458_primaryKeyboardInput_interface[7]; +extern KeyboardInput g459_secondaryKeyboardInput_movement[19]; +extern KeyboardInput g460_primaryKeyboardInput_partySleeping[3]; +extern KeyboardInput g461_primaryKeyboardInput_frozenGame[2]; + + class DMEngine; #define k0_pointerArrow 0 // @ C0_POINTER_ARROW @@ -258,6 +266,8 @@ public: bool _g326_refreshMousePointerInMainLoop; // @ G0326_B_RefreshMousePointerInMainLoop bool _g341_highlightBoxEnabled; // @ G0341_B_HighlightBoxEnabled uint16 _g599_useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap + KeyboardInput *_g443_primaryKeyboardInput; // @ G0443_ps_PrimaryKeyboardInput + KeyboardInput *_g444_secondaryKeyboardInput; // @ G0444_ps_SecondaryKeyboardInput void initMouse(); void f67_setMousePointerToNormal(int16 mousePointer); // @ F0067_MOUSE_SetPointerToNormal diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index c1d2aedd8a..3da4956b3d 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -88,7 +88,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) { _vm->_menuMan->f395_drawMovementArrows(); _vm->_eventMan->f77_hideMouse(); _vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement; - warning("MISSING CODE: setting G0444_ps_SecondaryKeyboardInput"); + _vm->_eventMan->_g444_secondaryKeyboardInput = g459_secondaryKeyboardInput_movement; _vm->_eventMan->f357_discardAllInput(); _vm->_displayMan->f98_drawFloorAndCeiling(); return; @@ -115,7 +115,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) { _vm->_eventMan->_g598_mousePointerBitmapUpdated = true; _vm->_eventMan->f77_hideMouse(); _vm->_eventMan->_g442_secondaryMouseInput = g449_SecondaryMouseInput_ChampionInventory; - warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput"); + _vm->_eventMan->_g444_secondaryKeyboardInput = nullptr; _vm->_eventMan->f357_discardAllInput(); } -- cgit v1.2.3 From 14bef5326a0c9939c3a8d669ffba7e2d86ddf295 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 11:37:01 +0200 Subject: DM: Add warning with repeat parameter --- engines/dm/champion.cpp | 12 ++++----- engines/dm/dm.cpp | 40 ++++++++++++++++++++++-------- engines/dm/dm.h | 2 +- engines/dm/dungeonman.cpp | 2 +- engines/dm/eventman.cpp | 6 ++--- engines/dm/gfx.cpp | 34 +++++++++++++------------- engines/dm/group.cpp | 20 +++++++-------- engines/dm/inventory.cpp | 14 +++++------ engines/dm/menus.cpp | 62 +++++++++++++++++++++++------------------------ engines/dm/movesens.cpp | 12 ++++----- engines/dm/projexpl.cpp | 6 ++--- engines/dm/text.cpp | 10 ++++---- 12 files changed, 120 insertions(+), 100 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 2a2047e7b0..dc77567daf 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -157,7 +157,7 @@ bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 return false; } } - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); f325_decrementStamine(champIndex, f305_getThrowingStaminaCost(L0996_T_Thing)); f330_disableAction(champIndex, 4); AL0994_i_Experience = 8; @@ -887,7 +887,7 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, int16 L0922_i_BaseSkillLevel; - warning("potaneitally dangerous cast of uint32 below"); + warning(false, "potaneitally dangerous cast of uint32 below"); if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && ((uint32)_vm->_projexpl->_g361_lastCreatureAttackTime < (_vm->_g313_gameTime - 150))) { exp >>= 1; } @@ -902,7 +902,7 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, L0916_ui_BaseSkillIndex = skillIndex; } AL0915_ui_SkillLevelBefore = f303_getSkillLevel(champIndex, L0916_ui_BaseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience)); - warning("potentially dangerous cast of uint32 below"); + warning(false, "potentially dangerous cast of uint32 below"); if ((skillIndex >= k4_ChampionSkillSwing) && ((uint32)_vm->_projexpl->_g361_lastCreatureAttackTime > (_vm->_g313_gameTime - 25))) { exp <<= 1; } @@ -1145,7 +1145,7 @@ ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) { void ChampionMan::f278_resetDataToStartGame() { if (!_vm->_g298_newGame) { - warning("MISSING CODE: stuff for resetting for loaded games"); + warning(false, "MISSING CODE: stuff for resetting for loaded games"); assert(false); } @@ -1401,7 +1401,7 @@ uint16 ChampionMan::f306_getStaminaAdjustedValue(Champion *champ, int16 val) { int16 currStamina = champ->_currStamina; int16 halfMaxStamina = champ->_maxStamina / 2; if (currStamina < halfMaxStamina) { - warning("Possible undefined behavior in the original code"); + warning(false, "Possible undefined behavior in the original code"); val /= 2; return val + ((uint32)val * (uint32)currStamina) / halfMaxStamina; } @@ -1693,7 +1693,7 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) { } void ChampionMan::f281_renameChampion(Champion* champ) { - warning("STUB METHOD: Champion::renameChampion, F0281_CHAMPION_Rename"); + warning(false, "STUB METHOD: Champion::renameChampion, F0281_CHAMPION_Rename"); DisplayMan &dispMan = *_vm->_displayMan; TextMan &textMan = *_vm->_textMan; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index d6a4a26ab1..cf75acbe58 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -37,6 +37,8 @@ #include "graphics/palette.h" #include "common/file.h" #include "common/events.h" +#include "common/array.h" +#include "common/algorithm.h" #include "dm/dm.h" #include "gfx.h" @@ -54,6 +56,24 @@ #include "projexpl.h" namespace DM { +void warning(bool repeat, const char* s, ...) { + va_list va; + + va_start(va, s); + Common::String output = Common::String::vformat(s, va); + va_end(va); + + if (repeat) { + ::warning(output.c_str()); + } else { + static Common::Array stringsPrinted; + + if (Common::find(stringsPrinted.begin(), stringsPrinted.end(), s) == stringsPrinted.end()) { + stringsPrinted.push_back(output); + ::warning(output.c_str()); + } + } +} void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); } @@ -151,7 +171,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { debug("DMEngine::DMEngine"); - warning("DUMMY CODE: setting _g298_newGame to true, should be in processEntrance"); + warning(false, "DUMMY CODE: setting _g298_newGame to true, should be in processEntrance"); _g298_newGame = true; } @@ -200,7 +220,7 @@ void DMEngine::f463_initializeGame() { _eventMan->initMouse(); //F0441_STARTEND_ProcessEntrance(); while (_loadsaveMan->f435_loadgame() != k1_LoadgameSuccess) { - warning("TODO: F0441_STARTEND_ProcessEntrance"); + warning(false, "TODO: F0441_STARTEND_ProcessEntrance"); } //F0396_MENUS_LoadSpellAreaLinesBitmap() is not needed, every bitmap has been loaded @@ -216,7 +236,7 @@ void DMEngine::f463_initializeGame() { } void DMEngine::f448_initMemoryManager() { - warning("STUB FUNCTION"); + warning(false, "STUB FUNCTION"); for (uint16 i = 0; i < 16; ++i) _displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i]; } @@ -246,7 +266,7 @@ void DMEngine::f462_startGame() { f3_processNewPartyMap(_dungeonMan->_g309_partyMapIndex); if (!_g298_newGame) { - warning("TODO: loading game"); + warning(false, "TODO: loading game"); assert(false); } else { _displayMan->_g578_useByteBoxCoordinates = false; @@ -255,7 +275,7 @@ void DMEngine::f462_startGame() { _displayMan->D24_fillScreenBox(g63_boxScreenBottom, k0_ColorBlack); } - warning("TODO: build copper"); + warning(false, "TODO: build copper"); _menuMan->f395_drawMovementArrows(); _championMan->f278_resetDataToStartGame(); _g301_gameTimeTicking = true; @@ -293,20 +313,20 @@ Common::Error DMEngine::run() { f463_initializeGame(); // @ F0463_START_InitializeGame_CPSADEF while (true) { f2_gameloop(); - warning("TODO: F0444_STARTEND_Endgame(G0303_B_PartyDead);"); + warning(false, "TODO: F0444_STARTEND_Endgame(G0303_B_PartyDead);"); } return Common::kNoError; } void DMEngine::f2_gameloop() { - warning("DUMMY CODE SETTING PARTY POS AND DIRECTION"); + warning(false, "DUMMY CODE SETTING PARTY POS AND DIRECTION"); _dungeonMan->_g306_partyMapX = 10; _dungeonMan->_g307_partyMapY = 4; _dungeonMan->_g308_partyDir = kDirNorth; - warning("DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero"); + warning(false, "DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero"); _inventoryMan->_g432_inventoryChampionOrdinal = 0; - warning("DUMMY CODE: clearing screen to black"); // in loop below + warning(false, "DUMMY CODE: clearing screen to black"); // in loop below while (true) { if (_g327_newPartyMapIndex != kM1_mapIndexNone) { @@ -331,7 +351,7 @@ T0002002: _eventMan->f78_showMouse(); _eventMan->f68_setPointerToObject(_objectMan->_g412_objectIconForMousePointer); _eventMan->f77_hideMouse(); - + } if (_eventMan->_g326_refreshMousePointerInMainLoop) { _eventMan->_g326_refreshMousePointerInMainLoop = false; diff --git a/engines/dm/dm.h b/engines/dm/dm.h index d0bc378beb..1b4850a849 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -50,7 +50,7 @@ class GroupMan; class Timeline; class ProjExpl; - +void warning(bool repeat, const char *s, ...); enum direction { kDirNorth = 0, diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index e1a964f279..8100139581 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -475,7 +475,7 @@ void DungeonMan::f455_decompressDungeonFile() { } } } else { - warning("TODO: if the dungeon is uncompressed, read it here"); + warning(false, "TODO: if the dungeon is uncompressed, read it here"); } f.close(); } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index e5db995b5f..ad6bd3067c 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -412,7 +412,7 @@ void EventManager::f68_setPointerToObject(byte* bitmap) { _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmap, _gK190_mousePointerTempBuffer, 16, 16, 16, 16, g44_palChangesMousePointerIcon); _vm->_displayMan->f132_blitToBitmap(_gK190_mousePointerTempBuffer, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18); */ - warning("TODO - Call f129_blitToBitmapShrinkWithPalChange"); + warning(false, "TODO - Call f129_blitToBitmapShrinkWithPalChange"); // dummy code _vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18); _vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18); @@ -797,7 +797,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16 L1151_ps_Junk = (Junk*)_vm->_dungeonMan->f157_getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY); if ((((Door*)L1151_ps_Junk)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) { _vm->_g321_stopWaitingForPlayerInput = true; - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); _vm->_movsens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1); return; } @@ -954,7 +954,7 @@ void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) { return; commandType = f358_getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton); if (commandType != k0_CommandNone) - warning("MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox"); + warning(false, "MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox"); break; case k5_PanelContentResurrectReincarnate: if (!champMan._g415_leaderEmptyHanded) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index e90b3a34aa..bf07cd655a 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -703,7 +703,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _g99_bitmapWall_D0R_Native = nullptr; _g322_paletteSwitchingEnabled = false; - warning("DUMMY CODE: setting _g304_dungeonViewPaletteIndex"); + warning(false, "DUMMY CODE: setting _g304_dungeonViewPaletteIndex"); _g304_dungeonViewPaletteIndex = 0; g186_doorFrame_D1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C @@ -815,8 +815,8 @@ void DisplayMan::f460_initializeGraphicData() { _g709_bitmapWallSet_DoorFrameFront = new byte[32 * 123]; _g296_bitmapViewport = new byte[224 * 136]; - warning("SKIPPED CODE: G0086_puc_Bitmap_ViewportBlackArea it is useless"); - warning("SKIPPED CODE: G0087_puc_Bitmap_ViewportFloorArea it is useless"); + warning(false, "SKIPPED CODE: G0086_puc_Bitmap_ViewportBlackArea it is useless"); + warning(false, "SKIPPED CODE: G0087_puc_Bitmap_ViewportFloorArea it is useless"); if (!_g639_derivedBitmapByteCount) _g639_derivedBitmapByteCount = new uint16[k730_DerivedBitmapMaximumCount]; @@ -1050,7 +1050,7 @@ void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* to } void DisplayMan::f566_viewportBlitToScreen() { - warning("MISSING FUNCTIONALITY: using correct colorpalette"); + warning(false, "MISSING FUNCTIONALITY: using correct colorpalette"); Box box(0, 223, 33, 33 + 135); f132_blitToBitmap(_g296_bitmapViewport, _g348_bitmapScreen, box, 0, 0, k112_byteWidthViewport, k160_byteWidthScreen, kM1_ColorNoTransparency); @@ -1144,7 +1144,7 @@ void DisplayMan::f133_blitBoxFilledWithMaskedBitmap(byte* src, byte* dest, byte* int16 lastUnitIndex, int16 firstUnitIndex, int16 destByteWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2) { // make sure to take care of inclusive boundaries - warning("STUB FUNCTION: does nothing at all"); + warning(false, "STUB FUNCTION: does nothing at all"); } @@ -2045,7 +2045,7 @@ void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) { _g296_bitmapViewport, g106_BoxThievesEye_ViewPortVisibleArea, 0, 0, 48, k112_byteWidthViewport, k9_ColorGold, 95, k136_heightViewport); /* BUG0_74 */ f493_addDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea); - warning("MISSING CODE: F0480_CACHE_ReleaseBlock"); + warning(false, "MISSING CODE: F0480_CACHE_ReleaseBlock"); } return; case k17_DoorFrontElemType: @@ -2265,7 +2265,7 @@ void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) { } void DisplayMan::f98_drawFloorAndCeiling() { - warning("f98_drawFloorAndCeiling doesn't do anything"); + warning(false, "f98_drawFloorAndCeiling doesn't do anything"); _g297_drawFloorAndCeilingRequested = false; } @@ -2711,9 +2711,9 @@ void DisplayMan::f113_drawField(FieldAspect* fieldAspect, Box& box) { } // byte *bitmap = dispMan.f489_getNativeBitmapOrGraphic(k73_FieldTeleporterGraphicIndice + fieldAspect->_nativeBitmapRelativeIndex); - warning("MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap"); + warning(false, "MISSING CODE: F0133_VIDEO_BlitBoxFilledWithMaskedBitmap"); - warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock"); + warning(false, "IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache, F0493_CACHE_AddDerivedBitmap, F0480_CACHE_ReleaseBlock"); } int16 DisplayMan::f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale) { @@ -3109,7 +3109,7 @@ T0115015_DrawProjectileAsObject: if (flipHorizontal) { f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, M77_getNormalizedByteWidth(byteWidth), heightRedEagle); } - warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); + warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } } AL_4_xPos = coordinateSet[0]; @@ -3341,7 +3341,7 @@ T0115077_DrawSecondHalfSquareCreature: memmove(AL_6_bitmapRedBanana, bitmapGreenAnt, byteWidth * 2 * heightRedEagle * sizeof(byte)); f130_flipBitmapHorizontal(AL_6_bitmapRedBanana, byteWidth, heightRedEagle); } - warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); + warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } } } @@ -3371,7 +3371,7 @@ T0115077_DrawSecondHalfSquareCreature: bitmapGreenAnt = f489_getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex); AL_6_bitmapRedBanana = f492_getDerivedBitmap(derivedBitmapIndex); f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, sourceByteWidth * 2, sourceHeight, byteWidth * 2, heightRedEagle, paletteChanges); - warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); + warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } if ((useCreatureSideBitmap && (creatureDirectionDelta == 1)) || /* If creature is viewed from the right, the side view must be flipped */ (useCreatureAttackBitmap && getFlag(creatureAspectInt, k0x0040_MaskActiveGroupFlipBitmap)) || @@ -3513,7 +3513,7 @@ continue; f129_blitToBitmapShrinkWithPalChange(bitmapGreenAnt, AL_6_bitmapRedBanana, ((ProjectileAspect *)objectAspect)->_byteWidth * 2, ((ProjectileAspect *)objectAspect)->_height, byteWidth * 2, heightRedEagle, _g75_palChangesProjectile[AL_8_projectileScaleIndex >> 1]); if (doNotScaleWithKineticEnergy) { - warning("IGNORED CODE F0493_CACHE_AddDerivedBitmap"); + warning(false, "IGNORED CODE F0493_CACHE_AddDerivedBitmap"); } } } @@ -3627,7 +3627,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; AL_4_explosionAspectIndex++; /* Use third graphic in the pattern for large explosion attack */ } } - warning("IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache"); + warning(false, "IGNORED CODE: F0491_CACHE_IsDerivedBitmapInCache"); AL_6_bitmapRedBanana = f489_getNativeBitmapOrGraphic(AL_4_explosionAspectIndex + k351_FirstExplosionPatternGraphicIndice); if (smoke) { f129_blitToBitmapShrinkWithPalChange(AL_6_bitmapRedBanana, _g74_tmpBitmap, 48, 32, 48, 32, g212_PalChangeSmoke); @@ -3636,8 +3636,8 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C, _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64), 224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93); - warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); - warning("IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); + warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); + warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); } else { if (rebirthExplosion) { explosionCoordinates = g227_RebirthStep2ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3]; @@ -3736,7 +3736,7 @@ byte* DisplayMan::f492_getDerivedBitmap(int16 derivedBitmapIndex) { } void DisplayMan::f493_addDerivedBitmap(int16 derivedBitmapIndex) { - warning("f493_addDerivedBitmap DOES NOTHING"); + warning(false, "f493_addDerivedBitmap DOES NOTHING"); } } diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index f2b2fda936..ffd466f6b6 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -145,7 +145,7 @@ void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThin _vm->_movsens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY); } while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList); if (mode >= k0_soundModePlayImmediately) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } } } @@ -256,7 +256,7 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell); _vm->_movsens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY); } - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) { @@ -888,7 +888,7 @@ T0209089_DoubleSquareMove: AL0450_i_DestinationMapX = eventMapX; AL0451_i_DestinationMapY = eventMapY; AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2; - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); goto T0209061_MoveGroup; } } @@ -1269,7 +1269,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) { if (_vm->getRandomNumber(2)) { toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } } else { if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) { @@ -1291,7 +1291,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); L1635_ui_SoundIndex = _vm->_movsens->f514_getSound(k13_CreatureTypeCouatl); if (L1635_ui_SoundIndex <= k34_D13_soundCount) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } } } else { @@ -1318,7 +1318,7 @@ void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 crea static ActiveGroup *G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup; - warning("potentially dangerous cast to uint32 below"); + warning(false, "potentially dangerous cast to uint32 below"); if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == (uint32)G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) { return; } @@ -1336,7 +1336,7 @@ void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 crea } void GroupMan::f208_groupAddEvent(TimelineEvent *event, uint32 time) { - warning("potentially dangerous cast to uint32 below"); + warning(false, "potentially dangerous cast to uint32 below"); if (time < (uint32)M30_time(event->_mapTime)) { event->_type -= 5; event->_C._ticks = M30_time(event->_mapTime) - time; @@ -1484,7 +1484,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui AL0440_i_KineticEnergy = (L0441_ps_CreatureInfo->_attack >> 2) + 1; AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy); AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy); - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); _vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8); } else { if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) { @@ -1512,7 +1512,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui } } if (AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } return true; } @@ -1635,7 +1635,7 @@ int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) { AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1; } if (AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType)) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); if ((AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack) && _vm->getRandomNumber(2) && ((AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack)) >= 0)) { _vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack); } diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 3da4956b3d..41e325aaa8 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -97,7 +97,7 @@ void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) { _vm->_displayMan->_g578_useByteBoxCoordinates = false; _vm->_inventoryMan->_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(championIndex); if (!AL1102_ui_InventoryChampionOrdinal) { - warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); + warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } L1103_ps_Champion = &_vm->_championMan->_gK71_champions[championIndex]; _vm->_displayMan->f466_loadIntoBitmap(k17_InventoryGraphicIndice, _vm->_displayMan->_g296_bitmapViewport); @@ -177,7 +177,7 @@ void InventoryMan::f346_drawPanelResurrectReincarnate() { } void InventoryMan::f347_drawPanel() { - warning("possible reintroduction of BUG0_48"); + warning(false, "possible reintroduction of BUG0_48"); f334_closeChest(); // possibility of BUG0_48 ChampionMan &cm = *_vm->_championMan; @@ -235,7 +235,7 @@ void InventoryMan::f334_closeChest() { } void InventoryMan::f340_drawPanelScrollTextLine(int16 yPos, char* text) { - warning("CHANGE5_03_IMPROVEMENT"); + warning(false, "CHANGE5_03_IMPROVEMENT"); for (char* iter = text; *iter != '\0'; ++iter) { if ((*iter >= 'A') && (*iter <= 'Z')) { *iter -= 64; @@ -261,7 +261,7 @@ void InventoryMan::f341_drawPanelScroll(Scroll* scroll) { charRed++; char *charGreen = charRed; // first char of the second line while (*charGreen) { - warning("BUG0_47"); + warning(false, "BUG0_47"); /* BUG0_47 Graphical glitch when you open a scroll. If there is a single line of text in a scroll (with no carriage return) then charGreen points to undefined data. This may result in a graphical glitch and also corrupt other memory. This is not an issue in the original dungeons where all @@ -300,7 +300,7 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo if (_g426_openChest == thingToOpen) return; - warning("CHANGE8_09_FIX"); + warning(false, "CHANGE8_09_FIX"); if (_g426_openChest != Thing::_none) f334_closeChest(); // CHANGE8_09_FIX @@ -314,7 +314,7 @@ void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bo Thing thing = chest->getSlot(); int16 thingCount = 0; while (thing != Thing::_endOfList) { - warning("CHANGE8_08_FIX"); + warning(false, "CHANGE8_08_FIX"); if (++thingCount > 8) break; // CHANGE8_08_FIX, make sure that no more than the first 8 objects in a chest are drawn @@ -428,7 +428,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) { TextMan &textMan = *_vm->_textMan; if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) { - warning("BUG0_48 The contents of a chest are reorganized when an object with a statistic modifier is placed or removed on a champion"); + warning(false, "BUG0_48 The contents of a chest are reorganized when an object with a statistic modifier is placed or removed on a champion"); f334_closeChest(); } diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 1338130459..d63cab0012 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -117,24 +117,24 @@ T0386006: box2._y2 = 110; dm.f132_blitToBitmap(bitmapIcon, dm._g348_bitmapScreen, box2, 0, 0, 8, k160_byteWidthScreen, kM1_ColorNoTransparency); if (champion.getAttributes(k0x0008_ChampionAttributeDisableAction) || _vm->_championMan->_g299_candidateChampionOrdinal || _vm->_championMan->_g300_partyIsSleeping) { - warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); + warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } } void MenuMan::f456_drawDisabledMenu() { if (!_vm->_championMan->_g300_partyIsSleeping) { - warning("MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); + warning(false, "MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); _vm->_displayMan->_g578_useByteBoxCoordinates = false; if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) { if (_vm->_inventoryMan->_g424_panelContent == k4_PanelContentChest) { _vm->_inventoryMan->f334_closeChest(); } } else { - warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); + warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox"); } - warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); - warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); - warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal"); + warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox"); + warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox"); + warning(false, "MISSING CODE: F0067_MOUSE_SetPointerToNormal"); } } @@ -175,7 +175,7 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() { if (_g508_refreshActionArea) { if (!champMan._g506_actingChampionOrdinal) { if (_g513_actionDamage) { - warning("MISSING CODE: F0385_MENUS_DrawActionDamage"); + warning(false, "MISSING CODE: F0385_MENUS_DrawActionDamage"); _g513_actionDamage = 0; } else { _g509_actionAreaContainsIcons = true; @@ -185,7 +185,7 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() { _g509_actionAreaContainsIcons = false; champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true); champMan.f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)); - warning("MISSING CODE: F0387_MENUS_DrawActionArea"); + warning(false, "MISSING CODE: F0387_MENUS_DrawActionArea"); } } } @@ -198,7 +198,7 @@ void MenuMan::f387_drawActionArea() { ChampionMan &champMan = *_vm->_championMan; TextMan &textMan = *_vm->_textMan; - warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); dispMan._g578_useByteBoxCoordinates = false; dispMan.D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack); if (_g509_actionAreaContainsIcons) { @@ -221,7 +221,7 @@ void MenuMan::f387_drawActionArea() { k12_ActionNameMaximumLength, k200_heightScreen); } } - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer"); _g508_refreshActionArea = false; } @@ -251,26 +251,26 @@ void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) { int16 champCurrHealth[4]; for (uint16 i = 0; i < 4; ++i) champCurrHealth[i] = champMan._gK71_champions[i]._currHealth; - warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); dispMan.D24_fillScreenBox(g504_BoxSpellAreaControls, k0_ColorBlack); int16 champCount = champMan._g305_partyChampionCount; switch (champIndex) { case k0_ChampionFirst: - warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox"); textMan.f53_printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ._name); if (champCount) { if (champCurrHealth[1]) { - warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox"); } labelChamp2: if (champCount > 2) { if (champCurrHealth[2]) { - warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox"); } labelChamp3: if (champCount > 3) { if (champCurrHealth[3]) { - warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox"); } } } @@ -278,36 +278,36 @@ labelChamp3: break; case k1_ChampionSecond: if (champCurrHealth[0]) { - warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox"); } - warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox"); textMan.f53_printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ._name); goto labelChamp2; case k2_ChampionThird: if (champCurrHealth[0]) { - warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox"); } if (champCurrHealth[1]) { - warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox"); } - warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox"); textMan.f53_printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ._name); goto labelChamp3; case k3_ChampionFourth: if (champCurrHealth[0]) { - warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox"); } if (champCurrHealth[1]) { - warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox"); } if (champCurrHealth[2]) { - warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox"); } - warning("MISSING CODE: F0006_MAIN_HighlightScreenBox"); + warning(false, "MISSING CODE: F0006_MAIN_HighlightScreenBox"); textMan.f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ._name); break; } - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer"); } #define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS @@ -350,28 +350,28 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) { || ((champIndex != kM1_ChampionNone) && !champMan._gK71_champions[champIndex]._currHealth)) return; if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) { - warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), dispMan._g348_bitmapScreen, g0_BoxSpellArea, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency); - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer"); } if (champIndex == kM1_ChampionNone) { champMan._g514_magicCasterChampionIndex = kM1_ChampionNone; - warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); dispMan._g578_useByteBoxCoordinates = false; dispMan.D24_fillScreenBox(g0_BoxSpellArea, k0_ColorBlack); - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer"); return; } champMan._g514_magicCasterChampionIndex = (ChampionIndex)champIndex; f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols); - warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); f393_drawSpellAreaControls((ChampionIndex)champIndex); dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK75_BoxSpellAreaLine2, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency); f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols); dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency); - warning("MISSING CODE: F0078_MOUSE_ShowPointer"); + warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer"); } void MenuMan::f457_drawEnabledMenus() { diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index da8c5e506e..f154053b87 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -181,7 +181,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui if (!L0753_B_DoNotTriggerSensor) { L0759_B_AtLeastOneSensorWasTriggered = true; if (L0755_ps_Sensor->getAudibleA()) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } if (!_vm->_championMan->_g415_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) { L0754_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0761_T_LeaderHandObject); @@ -296,7 +296,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 _vm->_dungeonMan->_g306_partyMapX = destMapX; _vm->_dungeonMan->_g307_partyMapY = destMapY; if (L0712_ps_Teleporter->isAudible()) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } L0723_B_DrawDungeonViewWhileFalling = true; if (L0712_ps_Teleporter->getAbsoluteRotation()) { @@ -307,7 +307,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 } else { if (L0710_i_ThingType == k4_GroupThingType) { if (L0712_ps_Teleporter->isAudible()) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } L0720_ui_MoveGroupResult = f262_getTeleporterRotatedGroupResult(L0712_ps_Teleporter, thing, L0714_ui_MapIndexSource); } else { @@ -349,7 +349,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 } } else { if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF)) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } } } @@ -477,7 +477,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 } L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[thing.getIndex()]._type); if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != _vm->_dungeonMan->_g309_partyMapIndex)) { /* If the group leaves the party map */ _vm->_groupMan->f184_removeActiveGroup(AL0708_i_ActiveGroupIndex); @@ -899,7 +899,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m goto T0276079; } if (L0769_ps_Sensor->getAudibleA()) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } f272_sensorTriggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around goto T0276079; diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index 97240bc929..94d9d21847 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -230,7 +230,7 @@ T0217004: AL0507_ui_SoundIndex = k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM; } } - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } T0217044: if (L0509_B_RemovePotion) { @@ -321,10 +321,10 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC L0470_ps_Explosion->setType(explThing.toUint16() - Thing::_firstExplosion.toUint16()); L0470_ps_Explosion->setAttack(attack); if (explThing.toUint16() < Thing::_explHarmNonMaterial.toUint16()) { - warning("MISING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISING CODE: F0064_SOUND_RequestPlay_CPSD"); } else { if (explThing != Thing::_explSmoke) { - warning("MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); } } _vm->_dungeonMan->f163_linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY); diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index 4329cb3083..eff2447343 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -137,9 +137,9 @@ void TextMan::f45_messageAreaCreateNewRow() { uint16 L0029_ui_RowIndex; if (_g358_messageAreaCursorRow == 3) { - warning("MISSING CODE: F0561_SCROLLER_IsTextScrolling"); + warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling"); memset(_g356_bitmapMessageAreaNewRow, k0_ColorBlack, 320 * 7); - warning("MISSING CODE: F0560_SCROLLER_SetCommand"); + warning(false, "MISSING CODE: F0560_SCROLLER_SetCommand"); for (L0029_ui_RowIndex = 0; L0029_ui_RowIndex < 3; L0029_ui_RowIndex++) { _g360_messageAreaRowExpirationTime[L0029_ui_RowIndex] = _g360_messageAreaRowExpirationTime[L0029_ui_RowIndex + 1]; } @@ -153,13 +153,13 @@ void TextMan::f46_messageAreaPrintString(Color color, const char* string) { int16 L0030_i_StringLength; L0030_i_StringLength = strlen(string); - warning("MISSING CODE: F0561_SCROLLER_IsTextScrolling"); + warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling"); if (true) { // there is a test here with F0561_SCROLLER_IsTextScrolling _vm->_textMan->f53_printToLogicalScreen(_g359_messageAreaCursorColumn * 6, (_g358_messageAreaCursorRow * 7) + 177, color, k0_ColorBlack, string); } else { f40_printTextToBitmap(_g356_bitmapMessageAreaNewRow, k160_byteWidthScreen, _g359_messageAreaCursorColumn * 6, 5, color, k0_ColorBlack, string, 7); - warning("MISSING CODE: F0561_SCROLLER_IsTextScrolling"); - warning("MISSING CODE: F0560_SCROLLER_SetCommand"); + warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling"); + warning(false, "MISSING CODE: F0560_SCROLLER_SetCommand"); } _g359_messageAreaCursorColumn += L0030_i_StringLength; _g360_messageAreaRowExpirationTime[_g358_messageAreaCursorRow] = _vm->_g313_gameTime + 200; -- cgit v1.2.3 From 9c79d02a1fb7c30cd47a8c0392b05642f2be12a3 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:50:30 +0200 Subject: DM: Add missing code to command move party --- engines/dm/champion.cpp | 363 ++++++++++++++++++++++++++---------------------- engines/dm/champion.h | 1 + engines/dm/dm.cpp | 4 +- engines/dm/dungeonman.h | 2 +- engines/dm/eventman.cpp | 142 +++++++++++++++---- engines/dm/eventman.h | 2 + 6 files changed, 318 insertions(+), 196 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index dc77567daf..6973d0fe73 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -176,8 +176,8 @@ bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 AL0994_i_Attack = f26_getBoundedValue((uint16)40, (uint16)((AL0995_i_SkillLevel << 3) + _vm->_rnd->getRandomNumber(31)), (uint16)200); AL0995_i_StepEnergy = MAX(5, 11 - AL0995_i_SkillLevel); _vm->_projexpl->f212_projectileCreate(L0996_T_Thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, - M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side), - _vm->_dungeonMan->_g308_partyDir, L0993_i_KineticEnergy, AL0994_i_Attack, AL0995_i_StepEnergy); + M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side), + _vm->_dungeonMan->_g308_partyDir, L0993_i_KineticEnergy, AL0994_i_Attack, AL0995_i_StepEnergy); _vm->_g311_projectileDisableMovementTicks = 4; _vm->_g312_lastProjectileDisabledMovementDirection = _vm->_dungeonMan->_g308_partyDir; f292_drawChampionState((ChampionIndex)champIndex); @@ -1102,12 +1102,12 @@ void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount if (!L0956_B_CycleCountDefined) { L0956_B_CycleCountDefined = true; if (L0955_B_Merge) { - cycleCount = MAX((int32)_vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount); + cycleCount = MAX((int32)_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount); } else { - cycleCount = MIN(80, _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount); + cycleCount = MIN(80, _g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount); } } - _vm->_championMan->_g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount; + _g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount; } } } @@ -1117,8 +1117,10 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) if (thing == Thing::_none) { return; } - _vm->_championMan->_g415_leaderEmptyHanded = false; - _vm->_objectMan->f36_extractIconFromBitmap(_vm->_championMan->_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_vm->_championMan->_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer); + _g415_leaderEmptyHanded = false; + _vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer); + + _vm->_eventMan->f78_showMouse(); _vm->_objectMan->f34_drawLeaderObjectName(thing); if (setMousePointer) { @@ -1127,11 +1129,38 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) _vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer); } _vm->_eventMan->f77_hideMouse(); - if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) { - _vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing); - setFlag(_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad); - _vm->_championMan->f292_drawChampionState(_vm->_championMan->_g411_leaderIndex); + if (_g411_leaderIndex != kM1_ChampionNone) { + _gK71_champions[_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing); + setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad); + f292_drawChampionState(_g411_leaderIndex); + } +} + +int16 ChampionMan::f310_getMovementTicks(Champion* champ) { + uint16 L0931_ui_Multiple; +#define AL0931_ui_Load L0931_ui_Multiple +#define AL0931_ui_WoundTicks L0931_ui_Multiple + uint16 L0932_ui_MaximumLoad; + int16 L0933_i_Ticks; + + + if ((L0932_ui_MaximumLoad = _vm->_championMan->f309_getMaximumLoad(champ)) > (AL0931_ui_Load = champ->_load)) { /* BUG0_72 The party moves very slowly even though no champion 'Load' value is drawn in red. When the Load of a champion has exactly the maximum value he can carry then the Load is drawn in yellow but the speed is the same as when the champion is overloaded (when the Load is drawn in red). The comparison operator should be >= instead of > */ + L0933_i_Ticks = 2; + if (((int32)AL0931_ui_Load << 3) > ((int32)L0932_ui_MaximumLoad * 5)) { + L0933_i_Ticks++; + } + AL0931_ui_WoundTicks = 1; + } else { + L0933_i_Ticks = 4 + (((AL0931_ui_Load - L0932_ui_MaximumLoad) << 2) / L0932_ui_MaximumLoad); + AL0931_ui_WoundTicks = 2; } + if (getFlag(champ->_wounds, k0x0020_ChampionWoundFeet)) { + L0933_i_Ticks += AL0931_ui_WoundTicks; + } + if (_vm->_objectMan->f33_getIconIndex(champ->_slots[k5_ChampionSlotFeet]) == k194_IconIndiceArmourBootOfSpeed) { + L0933_i_Ticks--; + } + return L0933_i_Ticks; } ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) { @@ -1156,180 +1185,180 @@ void ChampionMan::f278_resetDataToStartGame() { void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) { - DisplayMan &dispMan = *_vm->_displayMan; - DungeonMan &dunMan = *_vm->_dungeonMan; - - if (!_g415_leaderEmptyHanded || _g305_partyChampionCount == 4) + Thing L0793_T_Thing; + uint16 L0794_ui_Multiple; +#define AL0794_ui_ViewCell L0794_ui_Multiple +#define AL0794_ui_SlotIndex L0794_ui_Multiple +#define AL0794_ui_CharacterIndex L0794_ui_Multiple +#define AL0794_ui_StatisticIndex L0794_ui_Multiple +#define AL0794_ui_SkillIndex L0794_ui_Multiple + int16 L0795_i_HiddenSkillIndex; + uint16 L0796_ui_Multiple; +#define AL0796_ui_Character L0796_ui_Multiple +#define AL0796_ui_SkillValue L0796_ui_Multiple +#define AL0796_ui_ThingType L0796_ui_Multiple + Champion* L0797_ps_Champion; + char* L0798_pc_Character; + uint16 L0799_ui_PreviousPartyChampionCount; + uint16 L0800_ui_Multiple; +#define AL0800_B_ChampionTitleCopied L0800_ui_Multiple +#define AL0800_ui_HiddenSkillCounter L0800_ui_Multiple + uint16 L0801_ui_SlotIndex; + int16 L0802_i_MapX; + int16 L0803_i_MapY; + uint16 L0804_ui_ChampionObjectsCell; + int16 L0805_i_ObjectAllowedSlots; + int32 L0806_l_BaseSkillExperience; + char L0807_ac_DecodedChampionText[77]; + + if (!_vm->_championMan->_g415_leaderEmptyHanded) { return; - - uint16 prevChampCount = _g305_partyChampionCount; - Champion *champ = &_gK71_champions[prevChampCount]; - champ->resetToZero(); - dispMan._g578_useByteBoxCoordinates = true; - { // limit destBox scope - Box &destBox = gBoxChampionPortrait; - dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), champ->_portrait, - destBox, M27_getChampionPortraitX(championPortraitIndex), M28_getChampionPortraitY(championPortraitIndex), 128, 16, kM1_ColorNoTransparency); - } - - champ->_actionIndex = k255_ChampionActionNone; - champ->_enableActionEventIndex = -1; - champ->_hideDamageReceivedIndex = -1; - champ->_dir = dunMan._g308_partyDir; - ViewCell AL_0_viewCell = k0_ViewCellFronLeft; - while (f285_getIndexInCell((ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3)) != kM1_ChampionNone) - AL_0_viewCell = (ViewCell)(AL_0_viewCell + 1); - champ->_cell = (ViewCell)((AL_0_viewCell + dunMan._g308_partyDir) & 3); - champ->clearAttributes(k0x0400_ChampionAttributeIcon); - champ->_directionMaximumDamageReceived = dunMan._g308_partyDir; - champ->_food = 1500 + _vm->_rnd->getRandomNumber(256); - champ->_water = 1500 + _vm->_rnd->getRandomNumber(256); - int16 AL_0_slotIndex_Red; - for (AL_0_slotIndex_Red = k0_ChampionSlotReadyHand; AL_0_slotIndex_Red < k30_ChampionSlotChest_1; ++AL_0_slotIndex_Red) { - champ->setSlot((ChampionSlot)AL_0_slotIndex_Red, Thing::_none); - } - Thing thing = dunMan.f161_getSquareFirstThing(dunMan._g306_partyMapX, dunMan._g307_partyMapY); - while (thing.getType() != k2_TextstringType) { - thing = dunMan.f159_getNextThing(thing); - } - char decodedChampionText[77]; - char* character_Green = decodedChampionText; - dunMan.f168_decodeText(character_Green, thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible)); - int16 AL_0_characterIndex = 0; - uint16 AL_2_character; - while ((AL_2_character = *character_Green++) != '\n') { - champ->_name[AL_0_characterIndex++] = AL_2_character; - } - champ->_name[AL_0_characterIndex] = '\0'; - AL_0_characterIndex = 0; - bool AL_4_champTitleCopied = false; - for (;;) { // infinite - AL_2_character = *character_Green++; - if (AL_2_character == '\n') { - if (AL_4_champTitleCopied) - break; - AL_4_champTitleCopied = true; - } else { - champ->_title[AL_0_characterIndex++] = AL_2_character; - } - } - champ->_title[AL_0_characterIndex] = '\0'; - if (*character_Green++ == 'M') { - champ->setAttributeFlag(k0x0010_ChampionAttributeMale, true); } - character_Green++; - champ->_currHealth = champ->_maxHealth = f279_getDecodedValue(character_Green, 4); - character_Green += 4; - champ->_currStamina = champ->_maxStamina = f279_getDecodedValue(character_Green, 4); - character_Green += 4; - champ->_currMana = champ->_maxMana = f279_getDecodedValue(character_Green, 4); - character_Green += 4; - character_Green++; - - int16 AL_0_statisticIndex; - for (AL_0_statisticIndex = k0_ChampionStatLuck; AL_0_statisticIndex <= k6_ChampionStatAntifire; ++AL_0_statisticIndex) { - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k2_ChampionStatMinimum, 30); - uint16 currMaxVal = f279_getDecodedValue(character_Green, 2); - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k1_ChampionStatCurrent, currMaxVal); - champ->setStatistic((ChampionStatisticType)AL_0_statisticIndex, k0_ChampionStatMaximum, currMaxVal); - character_Green += 2; - } - - champ->setStatistic(k0_ChampionStatLuck, k2_ChampionStatMinimum, 10); - character_Green++; - - int16 AL_0_skillIndex; - int16 AL_2_skillValue; - for (AL_0_skillIndex = k4_ChampionSkillSwing; AL_0_skillIndex <= k19_ChampionSkillWater; AL_0_skillIndex++) { - if ((AL_2_skillValue = *character_Green++ - 'A') > 0) { - champ->setSkillExp((ChampionSkill)AL_0_skillIndex, 125L << AL_2_skillValue); - } - } - - for (AL_0_skillIndex = k0_ChampionSkillFighter; AL_0_skillIndex <= k3_ChampionSkillWizard; ++AL_0_skillIndex) { - int32 baseSkillExp = 0; - int16 hiddenSkillIndex = (AL_0_skillIndex + 1) << 2; - for (uint16 AL_4_hiddenSkillCounter = 0; AL_4_hiddenSkillCounter < 4; ++AL_4_hiddenSkillCounter) { - baseSkillExp += champ->getSkill((ChampionSkill)(hiddenSkillIndex + AL_4_hiddenSkillCounter))._experience; - } - champ->setSkillExp((ChampionSkill)AL_0_skillIndex, baseSkillExp); + if (_vm->_championMan->_g305_partyChampionCount == 4) { + return; } - - _g299_candidateChampionOrdinal = prevChampCount + 1; - if (++_g305_partyChampionCount == 1) { + L0797_ps_Champion = &_vm->_championMan->_gK71_champions[L0799_ui_PreviousPartyChampionCount = _vm->_championMan->_g305_partyChampionCount]; + L0797_ps_Champion->resetToZero(); + // Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portaits could be missing in the data) + _vm->_displayMan->_g578_useByteBoxCoordinates = true; + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), L0797_ps_Champion->_portrait, gBoxChampionPortrait, _vm->_championMan->M27_getChampionPortraitX(championPortraitIndex), _vm->_championMan->M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency); + L0797_ps_Champion->_actionIndex = k255_ChampionActionNone; + L0797_ps_Champion->_enableActionEventIndex = -1; + L0797_ps_Champion->_hideDamageReceivedIndex = -1; + L0797_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir; + AL0794_ui_ViewCell = k0_ViewCellFronLeft; + while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone) { + AL0794_ui_ViewCell++; + } + L0797_ps_Champion->_cell = (ViewCell)M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir); + L0797_ps_Champion->_attributes = k0x0400_ChampionAttributeIcon; + L0797_ps_Champion->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir; + L0797_ps_Champion->_food = 1500 + _vm->getRandomNumber(256); + L0797_ps_Champion->_water = 1500 + _vm->getRandomNumber(256); + for (AL0794_ui_SlotIndex = k0_ChampionSlotReadyHand; AL0794_ui_SlotIndex < k30_ChampionSlotChest_1; AL0794_ui_SlotIndex++) { + L0797_ps_Champion->_slots[AL0794_ui_SlotIndex] = Thing::_none; + } + L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); + while ((L0793_T_Thing.getType()) != k2_TextstringType) { + L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing); + } + _vm->_dungeonMan->f168_decodeText(L0798_pc_Character = L0807_ac_DecodedChampionText, L0793_T_Thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible)); + AL0794_ui_CharacterIndex = 0; + while ((AL0796_ui_Character = *L0798_pc_Character++) != '\n') { /* New line */ + L0797_ps_Champion->_name[AL0794_ui_CharacterIndex++] = AL0796_ui_Character; + } + L0797_ps_Champion->_name[AL0794_ui_CharacterIndex] = '\0'; + AL0794_ui_CharacterIndex = 0; + AL0800_B_ChampionTitleCopied = false; + for (;;) { /*_Infinite loop_*/ + AL0796_ui_Character = *L0798_pc_Character++; + if (AL0796_ui_Character == '\n') { /* New line */ + if (AL0800_B_ChampionTitleCopied) + break; + AL0800_B_ChampionTitleCopied = true; + } else { + L0797_ps_Champion->_title[AL0794_ui_CharacterIndex++] = AL0796_ui_Character; + } + } + L0797_ps_Champion->_title[AL0794_ui_CharacterIndex] = '\0'; + if (*L0798_pc_Character++ == 'M') { + setFlag(L0797_ps_Champion->_attributes, k0x0010_ChampionAttributeMale); + } + L0798_pc_Character++; + L0797_ps_Champion->_currHealth = L0797_ps_Champion->_maxHealth = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4); + L0798_pc_Character += 4; + L0797_ps_Champion->_currStamina = L0797_ps_Champion->_maxStamina = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4); + L0798_pc_Character += 4; + L0797_ps_Champion->_currMana = L0797_ps_Champion->_maxMana = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4); + L0798_pc_Character += 4; + L0798_pc_Character++; + for (AL0794_ui_StatisticIndex = k0_ChampionStatLuck; AL0794_ui_StatisticIndex <= k6_ChampionStatAntifire; AL0794_ui_StatisticIndex++) { + L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k2_ChampionStatMinimum] = 30; + L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k1_ChampionStatCurrent] = L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k0_ChampionStatMaximum] = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 2); + L0798_pc_Character += 2; + } + L0797_ps_Champion->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10; + L0798_pc_Character++; + for (AL0794_ui_SkillIndex = k4_ChampionSkillSwing; AL0794_ui_SkillIndex <= k19_ChampionSkillWater; AL0794_ui_SkillIndex++) { + if ((AL0796_ui_SkillValue = *L0798_pc_Character++ - 'A') > 0) { + L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = 125L << AL0796_ui_SkillValue; + } + } + for (AL0794_ui_SkillIndex = k0_ChampionSkillFighter; AL0794_ui_SkillIndex <= k3_ChampionSkillWizard; AL0794_ui_SkillIndex++) { + L0806_l_BaseSkillExperience = 0; + L0795_i_HiddenSkillIndex = (AL0794_ui_SkillIndex + 1) << 2; + for (AL0800_ui_HiddenSkillCounter = 0; AL0800_ui_HiddenSkillCounter < 4; AL0800_ui_HiddenSkillCounter++) { + L0806_l_BaseSkillExperience += L0797_ps_Champion->_skills[L0795_i_HiddenSkillIndex + AL0800_ui_HiddenSkillCounter]._experience; + } + L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = L0806_l_BaseSkillExperience; + } + _vm->_championMan->_g299_candidateChampionOrdinal = L0799_ui_PreviousPartyChampionCount + 1; + if (++_vm->_championMan->_g305_partyChampionCount == 1) { _vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst); _vm->_menuMan->_g508_refreshActionArea = true; } else { _vm->_menuMan->f388_clearActingChampion(); - _vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_g305_partyChampionCount - 1)); - } - - int16 mapX = _vm->_dungeonMan->_g306_partyMapX; - int16 mapY = _vm->_dungeonMan->_g307_partyMapY; - - uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._g308_partyDir)); - mapX += _vm->_dirIntoStepCountEast[dunMan._g308_partyDir]; - mapY += _vm->_dirIntoStepCountNorth[dunMan._g308_partyDir]; - thing = dunMan.f161_getSquareFirstThing(mapX, mapY); - AL_0_slotIndex_Red = k13_ChampionSlotBackpackLine_1_1; - uint16 slotIndex_Green; - while (thing != Thing::_endOfList) { - ThingType AL_2_thingType = thing.getType(); - if ((AL_2_thingType > k3_SensorThingType) && (thing.getCell() == championObjectsCell)) { - int16 objectAllowedSlots = g237_ObjectInfo[dunMan.f141_getObjectInfoIndex(thing)].getAllowedSlots(); - switch (AL_2_thingType) { + _vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_vm->_championMan->_g305_partyChampionCount - 1)); + } + L0802_i_MapX = _vm->_dungeonMan->_g306_partyMapX; + L0803_i_MapY = _vm->_dungeonMan->_g307_partyMapY; + L0804_ui_ChampionObjectsCell = returnOppositeDir(_vm->_dungeonMan->_g308_partyDir); + L0802_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L0803_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir]; + L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0802_i_MapX, L0803_i_MapY); + AL0794_ui_SlotIndex = k13_ChampionSlotBackpackLine_1_1; + while (L0793_T_Thing != Thing::_endOfList) { + if (((AL0796_ui_ThingType = (L0793_T_Thing.getType())) > k3_SensorThingType) && ((L0793_T_Thing.getCell()) == L0804_ui_ChampionObjectsCell)) { + L0805_i_ObjectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0793_T_Thing)]._allowedSlots; + switch (AL0796_ui_ThingType) { case k6_ArmourThingType: - for (slotIndex_Green = k2_ChampionSlotHead; slotIndex_Green <= k5_ChampionSlotFeet; slotIndex_Green++) { - if (objectAllowedSlots & gSlotMasks[slotIndex_Green]) + for (L0801_ui_SlotIndex = k2_ChampionSlotHead; L0801_ui_SlotIndex <= k5_ChampionSlotFeet; L0801_ui_SlotIndex++) { + if (L0805_i_ObjectAllowedSlots & gSlotMasks[L0801_ui_SlotIndex]) goto T0280048; } - if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) { - slotIndex_Green = k10_ChampionSlotNeck; + if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) { + L0801_ui_SlotIndex = k10_ChampionSlotNeck; } else { goto T0280046; } break; case k5_WeaponThingType: - if (champ->getSlot(k1_ChampionSlotActionHand) == Thing::_none) { - slotIndex_Green = k1_ChampionSlotActionHand; + if (L0797_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) { + L0801_ui_SlotIndex = k1_ChampionSlotActionHand; } else { goto T0280046; } break; case k7_ScrollThingType: case k8_PotionThingType: - if (champ->getSlot(k11_ChampionSlotPouch_1) == Thing::_none) { - slotIndex_Green = k11_ChampionSlotPouch_1; - } else if (champ->getSlot(k6_ChampionSlotPouch_2) == Thing::_none) { - slotIndex_Green = k6_ChampionSlotPouch_2; + if (L0797_ps_Champion->_slots[k11_ChampionSlotPouch_1] == Thing::_none) { + L0801_ui_SlotIndex = k11_ChampionSlotPouch_1; } else { - goto T0280046; + if (L0797_ps_Champion->_slots[k6_ChampionSlotPouch_2] == Thing::_none) { + L0801_ui_SlotIndex = k6_ChampionSlotPouch_2; + } else { + goto T0280046; + } } break; case k9_ContainerThingType: case k10_JunkThingType: T0280046: - if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (champ->getSlot(k10_ChampionSlotNeck) == Thing::_none)) { - slotIndex_Green = k10_ChampionSlotNeck; + if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) { + L0801_ui_SlotIndex = k10_ChampionSlotNeck; } else { - slotIndex_Green = AL_0_slotIndex_Red++; + L0801_ui_SlotIndex = AL0794_ui_SlotIndex++; } - break; - - default: - break; } T0280048: - if (champ->getSlot((ChampionSlot)slotIndex_Green) != Thing::_none) { + if (L0797_ps_Champion->_slots[L0801_ui_SlotIndex] != Thing::_none) { goto T0280046; } - f301_addObjectInSlot((ChampionIndex)prevChampCount, thing, (ChampionSlot)slotIndex_Green); + _vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0799_ui_PreviousPartyChampionCount, L0793_T_Thing, (ChampionSlot)L0801_ui_SlotIndex); } - thing = dunMan.f159_getNextThing(thing); + L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing); } - - _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)prevChampCount); - _vm->_menuMan->f456_drawDisabledMenu(); + _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)L0799_ui_PreviousPartyChampionCount); + _vm->_menuMan->f456_drawDisabledMenu();; } void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) { @@ -1446,7 +1475,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { L0868_i_ChampionStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing; - L0865_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + L0865_ps_Champion = &_gK71_champions[champIndex]; L0862_ui_ChampionAttributes = L0865_ps_Champion->_attributes; if (!getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand)) { return; @@ -1463,13 +1492,13 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { for (uint16 i = 0; i < 3; ++i) L0872_ai_NativeBitmapIndices[i] = 0; AL0864_i_BorderCount = 0; - if (_vm->_championMan->_g407_party._fireShieldDefense > 0) { + if (_g407_party._fireShieldDefense > 0) { L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k38_BorderPartyFireshieldIndice; } - if (_vm->_championMan->_g407_party._spellShieldDefense > 0) { + if (_g407_party._spellShieldDefense > 0) { L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k39_BorderPartySpellshieldIndice; } - if ((_vm->_championMan->_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) { + if ((_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) { L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k37_BorderPartyShieldIndice; } while (AL0864_i_BorderCount--) { @@ -1491,7 +1520,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { if (!(L0865_ps_Champion->_currHealth)) goto T0292042; if (getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle)) { - AL0864_i_ColorIndex = (champIndex == _vm->_championMan->_g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; + AL0864_i_ColorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; if (L0863_B_IsInventoryChampion) { _vm->_textMan->f52_printToViewport(3, 7, (Color)AL0864_i_ColorIndex, L0866_pc_ChampionName = L0865_ps_Champion->_name); L0869_i_ChampionTitleX = 6 * strlen(L0866_pc_ChampionName) + 3; @@ -1510,9 +1539,9 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { } } if (getFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics)) { - _vm->_championMan->f287_drawChampionBarGraphs(champIndex); + f287_drawChampionBarGraphs(champIndex); if (L0863_B_IsInventoryChampion) { - _vm->_championMan->f290_drawHealthStaminaManaValues(L0865_ps_Champion); + f290_drawHealthStaminaManaValues(L0865_ps_Champion); if ((L0865_ps_Champion->_food < 0) || (L0865_ps_Champion->_water < 0) || (L0865_ps_Champion->_poisonEventCount)) { AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice; } else { @@ -1532,14 +1561,14 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { } if (getFlag(L0862_ui_ChampionAttributes, k0x2000_ChampionAttributeWounds)) { for (AL0864_i_SlotIndex = L0863_B_IsInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL0864_i_SlotIndex >= k0_ChampionSlotReadyHand; AL0864_i_SlotIndex--) { - _vm->_championMan->f291_drawSlot(champIndex, AL0864_i_SlotIndex); + f291_drawSlot(champIndex, AL0864_i_SlotIndex); } if (L0863_B_IsInventoryChampion) { setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); } } if (getFlag(L0862_ui_ChampionAttributes, k0x0200_ChampionAttributeLoad) && L0863_B_IsInventoryChampion) { - if (L0865_ps_Champion->_load > (AL0864_i_Load = _vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion))) { + if (L0865_ps_Champion->_load > (AL0864_i_Load = f309_getMaximumLoad(L0865_ps_Champion))) { AL0870_i_Color = k8_ColorRed; } else { if (((long)L0865_ps_Champion->_load << 3) > ((long)AL0864_i_Load * 5)) { @@ -1550,28 +1579,28 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { } _vm->_textMan->f52_printToViewport(104, 132, (Color)AL0870_i_Color, "LOAD "); AL0864_i_Load = L0865_ps_Champion->_load / 10; - strcpy(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); + strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); strcat(_vm->_g353_stringBuildBuffer, "."); AL0864_i_Load = L0865_ps_Champion->_load - (AL0864_i_Load * 10); - strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str()); + strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str()); strcat(_vm->_g353_stringBuildBuffer, "/"); - AL0864_i_Load = (_vm->_championMan->f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10; - strcat(_vm->_g353_stringBuildBuffer, _vm->_championMan->f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); + AL0864_i_Load = (f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10; + strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); strcat(_vm->_g353_stringBuildBuffer, " KG"); _vm->_textMan->f52_printToViewport(148, 132, (Color)AL0870_i_Color, _vm->_g353_stringBuildBuffer); setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); } - AL0864_i_ChampionIconIndex = _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir); + AL0864_i_ChampionIconIndex = M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir); if (getFlag(L0862_ui_ChampionAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL0864_i_ChampionIconIndex))) { _vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], g46_ChampionColor[champIndex]); - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen); } if (getFlag(L0862_ui_ChampionAttributes, k0x0800_ChampionAttributePanel) && L0863_B_IsInventoryChampion) { if (_vm->_g333_pressingMouth) { _vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned(); } else { if (_vm->_g331_pressingEye) { - if (_vm->_championMan->_g415_leaderEmptyHanded) { + if (_g415_leaderEmptyHanded) { _vm->_inventoryMan->f351_drawChampionSkillsAndStatistics(); } } else { @@ -1581,7 +1610,7 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); } if (getFlag(L0862_ui_ChampionAttributes, k0x8000_ChampionAttributeActionHand)) { - _vm->_championMan->f291_drawSlot(champIndex, k1_ChampionSlotActionHand); + f291_drawSlot(champIndex, k1_ChampionSlotActionHand); _vm->_menuMan->f386_drawActionIcon(champIndex); if (L0863_B_IsInventoryChampion) { setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 2dc4579ee4..16c53c8c58 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -520,6 +520,7 @@ public: void f316_deleteScent(uint16 scentIndex); // @ F0316_CHAMPION_DeleteScent void f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount); // @ F0317_CHAMPION_AddScentStrength void f297_putObjectInLeaderHand(Thing thing, bool setMousePointer); // @ F0297_CHAMPION_PutObjectInLeaderHand + int16 f310_getMovementTicks(Champion *champ); // @ F0310_CHAMPION_GetMovementTicks diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index cf75acbe58..fa94f258c4 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -326,7 +326,6 @@ void DMEngine::f2_gameloop() { _dungeonMan->_g308_partyDir = kDirNorth; warning(false, "DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero"); _inventoryMan->_g432_inventoryChampionOrdinal = 0; - warning(false, "DUMMY CODE: clearing screen to black"); // in loop below while (true) { if (_g327_newPartyMapIndex != kM1_mapIndexNone) { @@ -337,13 +336,14 @@ T0002002: _eventMan->f357_discardAllInput(); } - // MISSING: F0261_TIMELINE_Process_CPSEF + warning(false, "MISSING CODE: F0261_TIMELINE_Process_CPSEF"); if (_g327_newPartyMapIndex != kM1_mapIndexNone) goto T0002002; if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { Box box(0, 223, 0, 135); + warning(false, "DUMMY CODE: clearing screen to black"); _displayMan->f135_fillBoxBitmap(_displayMan->_g296_bitmapViewport, box, k0_ColorBlack, k112_byteWidthViewport, k136_heightViewport); // dummy code _displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); if (_g325_setMousePointerToObjectInMainLoop) { diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index f9e21d4633..0b01a44a99 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -644,7 +644,6 @@ class DungeonMan { DungeonMan(const DungeonMan &other); // no implementation on purpose void operator=(const DungeonMan &rhs); // no implementation on purpose - Square f151_getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare Square f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare void f455_decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon @@ -660,6 +659,7 @@ public: explicit DungeonMan(DMEngine *dmEngine); ~DungeonMan(); + Square f151_getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare void f173_setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap Thing f161_getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing Thing f159_getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index ad6bd3067c..f57f98688e 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -416,7 +416,7 @@ void EventManager::f68_setPointerToObject(byte* bitmap) { // dummy code _vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g619_BoxMousePointerObjectShadow, 0, 0, 8, 16, kM1_ColorNoTransparency, 16, 18); _vm->_displayMan->f132_blitToBitmap(bitmap, L0051_puc_Bitmap, g620_BoxMousePointerObject, 0, 0, 8, 16, k0_ColorBlack, 16, 18); - + _gK100_preventBuildPointerScreenArea = false; f73_buildpointerScreenArea(_mousePos.x, _mousePos.y); } @@ -549,7 +549,7 @@ void EventManager::processInput() { input++; } } - + if (_g444_secondaryKeyboardInput) { KeyboardInput *input = _g444_secondaryKeyboardInput; while (input->_commandToIssue != k0_CommandNone) { @@ -561,8 +561,8 @@ void EventManager::processInput() { input++; } } - - } + + } case Common::EVENT_MOUSEMOVE: _mousePos = event.mouse; break; @@ -665,31 +665,114 @@ void EventManager::f365_commandTurnParty(CommandType cmdType) { } void EventManager::f366_commandMoveParty(CommandType cmdType) { - _vm->_g321_stopWaitingForPlayerInput = true; - - // MISSING CODE: Lots of code + static Box g463_BoxMovementArrows[4] = { // @ G0463_as_Graphic561_Box_MovementArrows + /* { X1, X2, Y1, Y2 } */ + Box(263, 289, 125, 145), /* Forward */ + Box(291, 318, 147, 167), /* Right */ + Box(263, 289, 147, 167), /* Backward */ + Box(234, 261, 147, 167)}; /* Left */ + + static int16 g465_movementArrowToStepForwardCount[4] = { // @ G0465_ai_Graphic561_MovementArrowToStepForwardCount + 1, /* Forward */ + 0, /* Right */ + -1, /* Backward */ + 0}; /* Left */ + static int16 g466_movementArrowToSepRightCount[4] = { // @ G0466_ai_Graphic561_MovementArrowToStepRightCount + 0, /* Forward */ + 1, /* Right */ + 0, /* Backward */ + -1}; /* Left */ + + uint16 L1115_ui_Multiple; +#define AL1115_ui_Square L1115_ui_Multiple +#define AL1115_ui_Ticks L1115_ui_Multiple + int16 L1116_i_SquareType; + int16 L1117_B_MovementBlocked; + uint16 L1118_ui_Multiple; +#define AL1118_ui_ChampionIndex L1118_ui_Multiple +#define AL1118_ui_MovementArrowIndex L1118_ui_Multiple + Champion* L1119_ps_Champion; + Box* L1120_ps_Box; + int16 L1121_i_MapX; + int16 L1122_i_MapY; + bool L1123_B_StairsSquare; + int16 L1124_i_FirstDamagedChampionIndex; + int16 L1125_i_SecondDamagedChampionIndex; - // DUMMY CODE: - DungeonMan &dungeonMan = *_vm->_dungeonMan; - switch (cmdType) { - case k3_CommandMoveForward: - dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); - break; - case k6_CommandMoveLeft: - dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, -1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); - break; - case k5_CommandMoveBackward: - dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, -1, 0, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); - break; - case k4_CommandMoveRight: - dungeonMan.f150_mapCoordsAfterRelMovement(dungeonMan._g308_partyDir, 0, 1, dungeonMan._g306_partyMapX, dungeonMan._g307_partyMapY); - break; - default: - break; + _vm->_g321_stopWaitingForPlayerInput = true; + L1119_ps_Champion = _vm->_championMan->_gK71_champions; + for (AL1118_ui_ChampionIndex = k0_ChampionFirst; AL1118_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL1118_ui_ChampionIndex++) { + _vm->_championMan->f325_decrementStamine(AL1118_ui_ChampionIndex, ((L1119_ps_Champion->_load * 3) / _vm->_championMan->f309_getMaximumLoad(L1119_ps_Champion)) + 1); /* BUG0_50 When a champion is brought back to life at a Vi Altar, his current stamina is lower than what it was before dying. Each time the party moves the current stamina of all champions is decreased, including for dead champions, by an amount that depends on the current load of the champion. For a dead champion the load before he died is used */ + L1119_ps_Champion++; } - - // MISSING CODE: Lots of code + AL1118_ui_MovementArrowIndex = cmdType - k3_CommandMoveForward; + L1120_ps_Box = &g463_BoxMovementArrows[AL1118_ui_MovementArrowIndex]; + warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable"); + L1123_B_StairsSquare = (Square(AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(L1121_i_MapX = _vm->_dungeonMan->_g306_partyMapX, L1122_i_MapY = _vm->_dungeonMan->_g307_partyMapY).toByte()).getType() == k3_ElementTypeStairs); + if (L1123_B_StairsSquare && (AL1118_ui_MovementArrowIndex == 2)) { /* If moving backward while in stairs */ + f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp)); + return; + } + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(_vm->_dungeonMan->_g308_partyDir, g465_movementArrowToStepForwardCount[AL1118_ui_MovementArrowIndex], g466_movementArrowToSepRightCount[AL1118_ui_MovementArrowIndex], L1121_i_MapX, L1122_i_MapY); + L1116_i_SquareType = Square(AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(L1121_i_MapX, L1122_i_MapY).toByte()).getType(); + if (L1116_i_SquareType == k3_ElementTypeStairs) { + _vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0); + _vm->_dungeonMan->_g306_partyMapX = L1121_i_MapX; + _vm->_dungeonMan->_g307_partyMapY = L1122_i_MapY; + f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp)); + return; + } + L1117_B_MovementBlocked = false; + if (L1116_i_SquareType == k0_ElementTypeWall) { + L1117_B_MovementBlocked = true; + } else { + if (L1116_i_SquareType == k4_DoorElemType) { + L1117_B_MovementBlocked = Square(AL1115_ui_Square).getDoorState(); + L1117_B_MovementBlocked = (L1117_B_MovementBlocked != k0_doorState_OPEN) && (L1117_B_MovementBlocked != k1_doorState_FOURTH) && (L1117_B_MovementBlocked != k5_doorState_DESTROYED); + } else { + if (L1116_i_SquareType == k6_ElementTypeFakeWall) { + L1117_B_MovementBlocked = (!getFlag(AL1115_ui_Square, k0x0004_FakeWallOpen) && !getFlag(AL1115_ui_Square, k0x0001_FakeWallImaginary)); + } + } + } + if (_vm->_championMan->_g305_partyChampionCount == 0) { + } else { + if (L1117_B_MovementBlocked) { + L1117_B_MovementBlocked = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1124_i_FirstDamagedChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(L1121_i_MapX, L1122_i_MapY, M21_normalizeModulo4(AL1118_ui_MovementArrowIndex += (_vm->_dungeonMan->_g308_partyDir + 2))), 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF); + if (L1124_i_FirstDamagedChampionIndex != (L1125_i_SecondDamagedChampionIndex = _vm->_championMan->f286_getTargetChampionIndex(L1121_i_MapX, L1122_i_MapY, returnNextVal(AL1118_ui_MovementArrowIndex)))) { + L1117_B_MovementBlocked |= _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF); + } + if (L1117_B_MovementBlocked) { + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + } else { + if (L1117_B_MovementBlocked = (_vm->_groupMan->f175_groupGetThing(L1121_i_MapX, L1122_i_MapY) != Thing::_endOfList)) { + _vm->_groupMan->f209_processEvents29to41(L1121_i_MapX, L1122_i_MapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0); + } + } + } + if (L1117_B_MovementBlocked) { + f357_discardAllInput(); + _vm->_g321_stopWaitingForPlayerInput = false; + return; + } + if (L1123_B_StairsSquare) { + _vm->_movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, L1121_i_MapX, L1122_i_MapY); + } else { + _vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1121_i_MapX, L1122_i_MapY); + } + AL1115_ui_Ticks = 1; + L1119_ps_Champion = _vm->_championMan->_gK71_champions; + for (AL1118_ui_ChampionIndex = k0_ChampionFirst; AL1118_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL1118_ui_ChampionIndex++) { + if (L1119_ps_Champion->_currHealth) { + warning(false, "possibly dangerous cast to uint16"); + AL1115_ui_Ticks = MAX(AL1115_ui_Ticks, (uint16)_vm->_championMan->f310_getMovementTicks(L1119_ps_Champion)); + } + L1119_ps_Champion++; + } + _vm->_g310_disabledMovementTicks = AL1115_ui_Ticks; + _vm->_g311_projectileDisableMovementTicks = 0; } bool EventManager::f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY) { @@ -1052,4 +1135,11 @@ void EventManager::f357_discardAllInput() { _commandQueue.clear(); } +void EventManager::f364_commandTakeStairs(bool stairsGoDown) { + _vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0); + _vm->_g327_newPartyMapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g309_partyMapIndex, stairsGoDown ? -1 : 1, &_vm->_dungeonMan->_g306_partyMapX, &_vm->_dungeonMan->_g307_partyMapY); + _vm->_dungeonMan->f173_setCurrentMap(_vm->_g327_newPartyMapIndex); + _vm->_championMan->f284_setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY)); + _vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex); +} } // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index eafb64ee1a..2c61d3e7ce 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -296,6 +296,8 @@ public: bool f360_hasPendingClick(Common::Point &point, MouseButton button); // @ F0360_COMMAND_ProcessPendingClick void f379_drawSleepScreen(); // @ F0379_COMMAND_DrawSleepScreen void f357_discardAllInput(); // @ F0357_COMMAND_DiscardAllInput + void f364_commandTakeStairs(bool stairsGoDown);// @ F0364_COMMAND_TakeStairs + }; } -- cgit v1.2.3 From 1baf135c2f3ea0214f539242935aa8a8d0705f1d Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 13:12:40 +0200 Subject: DM: Add missing code to command turn party --- engines/dm/eventman.cpp | 25 ++++++++++++------------ engines/dm/gfx.cpp | 52 ++++++++++++++++++++++++------------------------- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index f57f98688e..4f3ffc5e74 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -649,19 +649,20 @@ void EventManager::f380_processCommandQueue() { } void EventManager::f365_commandTurnParty(CommandType cmdType) { - _vm->_g321_stopWaitingForPlayerInput = true; - - // MISSING CODE: highlight turn left/right buttons - - // MISSING CODE: processing stairs - - // MISSING CODE: process sensors - - // DUMMY CODE: should call F0284_CHAMPION_SetPartyDirection instead - direction &partyDir = _vm->_dungeonMan->_g308_partyDir; - (cmdType == k1_CommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir); + uint16 L1114_ui_Square; - // MISSING CODE: process sensors + _vm->_g321_stopWaitingForPlayerInput = true; + if (cmdType == k1_CommandTurnLeft) { + warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable"); + } else { + } + if (Square(L1114_ui_Square = _vm->_dungeonMan->f151_getSquare(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY).toByte()).getType() == k3_ElementTypeStairs) { + f364_commandTakeStairs(getFlag(L1114_ui_Square, k0x0004_StairsUp)); + return; + } + _vm->_movsens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, false); + _vm->_championMan->f284_setPartyDirection(M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + ((cmdType == k2_CommandTurnRight) ? 1 : 3))); + _vm->_movsens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, true); } void EventManager::f366_commandMoveParty(CommandType cmdType) { diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index bf07cd655a..853571873a 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1376,44 +1376,44 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIndex) { static byte g200_palChangesDoorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 0, 130}; // @ G0200_auc_Graphic558_PaletteChanges_DoorOrnament_D3 static byte g201PalChangesDoorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0201_auc_Graphic558_PaletteChanges_DoorOrnament_D2 +#define AP0120_i_Height doorOrnOrdinal +#define AP0121_i_ByteWidth viewDoorOrnIndex + int16 L0104_i_NativeBitmapIndex; + int16 coordSetGreenToad; + uint16* coordSetOrangeElk; + byte* L0107_puc_Multiple; +#define AL0107_puc_Bitmap L0107_puc_Multiple + byte* L0108_puc_Bitmap_Native; -#define height doorOrnOrdinal -#define byteWidth viewDoorOrnIndex - if (doorOrnOrdinal) { doorOrnOrdinal--; - int16 nativeBitmapIndex = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex]; - int16 coordSetGreenToad = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]; - uint16 *coordSetOrangeElk = g207_doorOrnCoordSets[coordSetGreenToad][viewDoorOrnIndex]; - byte *bitmap = nullptr; + L0104_i_NativeBitmapIndex = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex]; + coordSetOrangeElk = &g207_doorOrnCoordSets[coordSetGreenToad = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]][viewDoorOrnIndex][0]; if (viewDoorOrnIndex == k2_ViewDoorOrnament_D1LCR) { - bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); - byteWidth = 48; - height = 88; + AL0107_puc_Bitmap = f489_getNativeBitmapOrGraphic(L0104_i_NativeBitmapIndex); + AP0121_i_ByteWidth = k48_byteWidth; + AP0120_i_Height = 88; } else { if (!f491_isDerivedBitmapInCache(doorOrnOrdinal = k68_DerivedBitmapFirstDoorOrnament_D3 + (doorOrnOrdinal * 2) + viewDoorOrnIndex)) { - uint16 *coordSetRedEagle = g207_doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR]; - byte* bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); - f129_blitToBitmapShrinkWithPalChange(bitmapNative, - f492_getDerivedBitmap(doorOrnOrdinal), - coordSetRedEagle[4] << 1, coordSetRedEagle[5], - coordSetOrangeElk[2] - coordSetOrangeElk[0] + 1, - coordSetOrangeElk[5], - (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2); + uint16 *coordSetRedEagle = &g207_doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR][0]; + L0108_puc_Bitmap_Native = f489_getNativeBitmapOrGraphic(L0104_i_NativeBitmapIndex); + f129_blitToBitmapShrinkWithPalChange(L0108_puc_Bitmap_Native, f492_getDerivedBitmap(doorOrnOrdinal), coordSetRedEagle[4] << 1, coordSetRedEagle[5], coordSetOrangeElk[1] - coordSetOrangeElk[0] + 1, coordSetOrangeElk[5], (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2); f493_addDerivedBitmap(doorOrnOrdinal); } - bitmap = f492_getDerivedBitmap(doorOrnOrdinal); + AL0107_puc_Bitmap = f492_getDerivedBitmap(doorOrnOrdinal); if (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) { - byteWidth = 24; - height = 41; + AP0121_i_ByteWidth = k24_byteWidth; + AP0120_i_Height = 41; } else { - byteWidth = 32; - height = 61; + AP0121_i_ByteWidth = k32_byteWidth; + AP0120_i_Height = 61; } } - f132_blitToBitmap(bitmap, _g74_tmpBitmap, - *(Box *)coordSetOrangeElk, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height); + { + Box box(coordSetOrangeElk[0], coordSetOrangeElk[1], coordSetOrangeElk[2], coordSetOrangeElk[3]); + f132_blitToBitmap(AL0107_puc_Bitmap, _g74_tmpBitmap, box, 0, 0, coordSetOrangeElk[4], AP0121_i_ByteWidth, k9_ColorGold, coordSetOrangeElk[5], AP0120_i_Height); + } } } @@ -1448,7 +1448,7 @@ void DisplayMan::f21_blitToScreen(byte *bitmap, int16* box, int16 byteWidth, Col f21_blitToScreen(bitmap, &actualBox, byteWidth, transparent, height); } -void DisplayMan::f21_blitToScreen(byte* bitmap, Box* box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal) { +void DisplayMan::f21_blitToScreen(byte* bitmap, Box* box, int16 byteWidth, Color transparent, int16 height) { _g578_useByteBoxCoordinates = false; f132_blitToBitmap(bitmap, _g348_bitmapScreen, *box, 0, 0, byteWidth, k112_byteWidthViewport, transparent, height, k136_heightViewport); } -- cgit v1.2.3 From 9d1afe3022c607a47f73033371411b259114609d Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 13:40:14 +0200 Subject: DM: Fix broken display of the leftmost champion --- engines/dm/champion.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 6973d0fe73..4a1508fb84 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1592,8 +1592,8 @@ void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { } AL0864_i_ChampionIconIndex = M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir); if (getFlag(L0862_ui_ChampionAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL0864_i_ChampionIconIndex))) { - _vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], g46_ChampionColor[champIndex]); - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex << 2], M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen); + _vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex], g46_ChampionColor[champIndex]); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex], _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen); } if (getFlag(L0862_ui_ChampionAttributes, k0x0800_ChampionAttributePanel) && L0863_B_IsInventoryChampion) { if (_vm->_g333_pressingMouth) { -- cgit v1.2.3 From 8c7760bd610173740e623eeac02bf0728488b1c4 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 14:33:25 +0200 Subject: DM: Add F0239_TIMELINE_ExtractFirstEvent --- engines/dm/dm.cpp | 3 +- engines/dm/dungeonman.h | 1 + engines/dm/timeline.cpp | 130 ++++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/timeline.h | 3 ++ 4 files changed, 135 insertions(+), 2 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index fa94f258c4..86e7000498 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -335,8 +335,7 @@ T0002002: _g327_newPartyMapIndex = kM1_mapIndexNone; _eventMan->f357_discardAllInput(); } - - warning(false, "MISSING CODE: F0261_TIMELINE_Process_CPSEF"); + _timeline->f261_processTimeline(); if (_g327_newPartyMapIndex != kM1_mapIndexNone) goto T0002002; diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 0b01a44a99..a5c6ae2415 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -527,6 +527,7 @@ public: explicit Explosion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {} Thing getNextThing() { return _nextThing; } + Thing setNextThing(Thing val) { return _nextThing = val; } uint16 getType() { return _attributes & 0x7F; } uint16 setType(uint16 val) { _attributes = (_attributes & ~0x7F) | (val & 0x7F); return (val & 0x7F); } uint16 getAttack() { return (_attributes >> 8) & 0xFF; } diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 8b26210017..8f071574a5 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -27,6 +27,8 @@ #include "timeline.h" #include "dungeonman.h" +#include "champion.h" +#include "inventory.h" namespace DM { @@ -208,4 +210,132 @@ uint16 Timeline::f238_addEventGetEventIndex(TimelineEvent* event) { return L0590_ui_NewEventIndex; } +void Timeline::f261_processTimeline() { + uint16 L0680_ui_Multiple; +#define AL0680_ui_EventType L0680_ui_Multiple +#define AL0680_ui_ChampionIndex L0680_ui_Multiple + TimelineEvent* L0681_ps_Event; + TimelineEvent L0682_s_Event; + + + while (f240_isFirstEventExpiered()) { + L0681_ps_Event = &L0682_s_Event; + f239_timelineExtractFirstEvent(L0681_ps_Event); + _vm->_dungeonMan->f173_setCurrentMap(M29_map(L0682_s_Event._mapTime)); + AL0680_ui_EventType = L0682_s_Event._type; + if ((AL0680_ui_EventType > (k29_TMEventTypeGroupReactionDangerOnSquare - 1)) && (AL0680_ui_EventType < (k41_TMEventTypeUpdateBehaviour_3 + 1))) { + //F0209_GROUP_ProcessEvents29to41(L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, AL0680_ui_EventType, L0682_s_Event._C._ticks); + } else { + switch (AL0680_ui_EventType) { + case k48_TMEventTypeMoveProjectileIgnoreImpacts: + case k49_TMEventTypeMoveProjectile: + //F0219_PROJECTILE_ProcessEvents48To49_Projectile(L0681_ps_Event); + break; + case k1_TMEventTypeDoorAnimation: + //F0241_TIMELINE_ProcessEvent1_DoorAnimation(L0681_ps_Event); + break; + case k25_TMEventTypeExplosion: + //F0220_EXPLOSION_ProcessEvent25_Explosion(L0681_ps_Event); + break; + case k7_TMEventTypeFakeWall: + //F0242_TIMELINE_ProcessEvent7_Square_FakeWall(L0681_ps_Event); + break; + case k2_TMEventTypeDoorDestruction: + //F0243_TIMELINE_ProcessEvent2_DoorDestruction(L0681_ps_Event); + break; + case k10_TMEventTypeDoor: + //F0244_TIMELINE_ProcessEvent10_Square_Door(L0681_ps_Event); + break; + case k9_TMEventTypePit: + //F0251_TIMELINE_ProcessEvent9_Square_Pit(L0681_ps_Event); + break; + case k8_TMEventTypeTeleporter: + //F0250_TIMELINE_ProcessEvent8_Square_Teleporter(L0681_ps_Event); + break; + case k6_TMEventTypeWall: + //F0248_TIMELINE_ProcessEvent6_Square_Wall(L0681_ps_Event); + break; + case k5_TMEventTypeCorridor: + //F0245_TIMELINE_ProcessEvent5_Square_Corridor(L0681_ps_Event); + break; + case k60_TMEventTypeMoveGroupSilent: + case k61_TMEventTypeMoveGroupAudible: + //F0252_TIMELINE_ProcessEvents60to61_MoveGroup(L0681_ps_Event); + break; + case k65_TMEventTypeEnableGroupGenerator: + //F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator(L0681_ps_Event); + break; + case k20_TMEventTypePlaySound: + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + break; + case k24_TMEventTypeRemoveFluxcage: + if (!_vm->_g302_gameWon) { + _vm->_dungeonMan->f164_unlinkThingFromList(Thing(L0682_s_Event._C._slot), Thing(0), L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY); + L0681_ps_Event = (TimelineEvent*)_vm->_dungeonMan->f156_getThingData(Thing(L0682_s_Event._C._slot)); + ((Explosion*)L0681_ps_Event)->setNextThing(Thing::_none); + } + break; + case k11_TMEventTypeEnableChampionAction: + //F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction(L0682_s_Event._priority); + if (L0682_s_Event._B._slotOrdinal) { + //F0259_TIMELINE_ProcessEvent11Part2_MoveWeaponFromQuiverToSlot(L0682_s_Event._priority, _vm->M1_ordinalToIndex(L0682_s_Event._B._slotOrdinal)); + } + goto T0261048; + case k12_TMEventTypeHideDamageReceived: + //F0254_TIMELINE_ProcessEvent12_HideDamageReceived(L0682_s_Event._priority); + break; + case k70_TMEventTypeLight: + _vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex); + //F0257_TIMELINE_ProcessEvent70_Light(L0681_ps_Event); + _vm->_inventoryMan->f337_setDungeonViewPalette(); + break; + case k71_TMEventTypeInvisibility: + _vm->_championMan->_g407_party._event71Count_Invisibility--; + break; + case k72_TMEventTypeChampionShield: + _vm->_championMan->_gK71_champions[L0682_s_Event._priority]._shieldDefense -= L0682_s_Event._B._defense; + setFlag(_vm->_championMan->_gK71_champions[L0682_s_Event._priority]._attributes, k0x1000_ChampionAttributeStatusBox); +T0261048: + _vm->_championMan->f292_drawChampionState((ChampionIndex)L0682_s_Event._priority); + break; + case k73_TMEventTypeThievesEye: + _vm->_championMan->_g407_party._event73Count_ThievesEye--; + break; + case k74_TMEventTypePartyShield: + _vm->_championMan->_g407_party._shieldDefense -= L0682_s_Event._B._defense; +T0261053: + //F0260_TIMELINE_RefreshAllChampionStatusBoxes(); + break; + case k77_TMEventTypeSpellShield: + _vm->_championMan->_g407_party._spellShieldDefense -= L0682_s_Event._B._defense; + goto T0261053; + case k78_TMEventTypeFireShield: + _vm->_championMan->_g407_party._fireShieldDefense -= L0682_s_Event._B._defense; + goto T0261053; + case k75_TMEventTypePoisonChampion: + _vm->_championMan->_gK71_champions[AL0680_ui_ChampionIndex = L0682_s_Event._priority]._poisonEventCount--; + _vm->_championMan->f322_championPoison(AL0680_ui_ChampionIndex, L0682_s_Event._B._attack); + break; + case k13_TMEventTypeViAltarRebirth: + //F0255_TIMELINE_ProcessEvent13_ViAltarRebirth(L0681_ps_Event); + break; + case k79_TMEventTypeFootprints: + _vm->_championMan->_g407_party._event79Count_Footprints--; + } + } + _vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex); + } +} + +bool Timeline::f240_isFirstEventExpiered() { + return (_vm->_timeline->_g372_eventCount && (M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime)); +} + +void Timeline::f239_timelineExtractFirstEvent(TimelineEvent* event) { + uint16 L0592_ui_EventIndex; + + *event = _vm->_timeline->_g370_events[L0592_ui_EventIndex = _vm->_timeline->_g371_timeline[0]]; + f237_deleteEvent(L0592_ui_EventIndex); +} + } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index b77c0d1081..b5728a0d95 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -159,6 +159,9 @@ public: bool f234_isEventABeforeB(TimelineEvent *eventA, TimelineEvent *eventB); // @ F0234_TIMELINE_IsEventABeforeEventB uint16 f235_getIndex(uint16 eventIndex); // @ F0235_TIMELINE_GetIndex uint16 f238_addEventGetEventIndex(TimelineEvent *event); // @ F0238_TIMELINE_AddEvent_GetEventIndex_CPSE + void f261_processTimeline(); // @ F0261_TIMELINE_Process_CPSEF + bool f240_isFirstEventExpiered(); // @ F0240_TIMELINE_IsFirstEventExpired_CPSE + void f239_timelineExtractFirstEvent(TimelineEvent *event); // @ F0239_TIMELINE_ExtractFirstEvent }; -- cgit v1.2.3 From dd3f12c7d5b85cb8bd6644a8c9de9fe49ca4166a Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 14:55:56 +0200 Subject: DM: Complete main gameloop --- engines/dm/dm.cpp | 24 +++++++++++++++++++----- engines/dm/inventory.cpp | 19 +++++++++++++++++++ engines/dm/inventory.h | 2 ++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 86e7000498..fd3c30ec1c 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -378,13 +378,27 @@ T0002002: _g311_projectileDisableMovementTicks--; _g321_stopWaitingForPlayerInput = false; - //do { - _eventMan->processInput(); - _eventMan->f380_processCommandQueue(); - //} while (!_g321_stopWaitingForPlayerInput /*|| !_g301_gameTimeTicking */); + do { + _eventMan->processInput(); + + if (_g332_stopPressingEye) { + _g331_pressingEye = false; + _g332_stopPressingEye = false; + _inventoryMan->f353_drawStopPressingEye(); + } else if (_g334_stopPressingMouth) { + _g333_pressingMouth = false; + _g334_stopPressingMouth = false; + _inventoryMan->f350_drawStopPressingMouth(); + } + + _eventMan->f380_processCommandQueue(); + _displayMan->updateScreen(); + // if (!_vm->_g321_stopWaitingForPlayerInput) { + warning(false, "MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); + // } + } while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking); - _displayMan->updateScreen(); _system->delayMillis(18); } } diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 41e325aaa8..3d61270dc8 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -733,4 +733,23 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() { L1091_i_Y += 7; } } + +void InventoryMan::f350_drawStopPressingMouth() { + _vm->_inventoryMan->f347_drawPanel(); + _vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView); + warning(false, "Ignored code: G0587_i_HideMousePointerRequestCount"); + _vm->_eventMan->f77_hideMouse(); +} + +void InventoryMan::f353_drawStopPressingEye() { + Thing L1100_T_LeaderHandObject; + + _vm->_inventoryMan->f332_drawIconToViewport(k202_IconIndiceEyeNotLooking, 12, 13); + _vm->_inventoryMan->f347_drawPanel(); + _vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView); + if ((L1100_T_LeaderHandObject = _vm->_championMan->_g414_leaderHandObject) != Thing::_none) { + _vm->_objectMan->f34_drawLeaderObjectName(L1100_T_LeaderHandObject); + } + _vm->_eventMan->f77_hideMouse(); +} } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 93bb17fbe6..106e4cd24d 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -81,6 +81,8 @@ public: void f337_setDungeonViewPalette(); // @ F0337_INVENTORY_SetDungeonViewPalette void f338_decreaseTorchesLightPower(); // @ F0338_INVENTORY_DecreaseTorchesLightPower_CPSE void f351_drawChampionSkillsAndStatistics(); // @ F0351_INVENTORY_DrawChampionSkillsAndStatistics + void f350_drawStopPressingMouth(); // @ F0350_INVENTORY_DrawStopPressingMouth + void f353_drawStopPressingEye();// @ F0353_INVENTORY_DrawStopPressingEye }; -- cgit v1.2.3 From 12f06fd1d9460524ba8e9307a89edc1454516c27 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 15:20:00 +0200 Subject: DM: Add f219_processEvents48To49_projectile --- engines/dm/dm.cpp | 2 +- engines/dm/projexpl.cpp | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/projexpl.h | 12 +++++-- engines/dm/timeline.cpp | 6 ++-- 4 files changed, 100 insertions(+), 6 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index fd3c30ec1c..8a49b23e87 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -365,7 +365,7 @@ T0002002: _g313_gameTime++; if (!(_g313_gameTime & 511)) - //_inventoryMan->f338_decreaseTorchesLightPower(); + _inventoryMan->f338_decreaseTorchesLightPower(); if (_g310_disabledMovementTicks) { _g310_disabledMovementTicks--; } diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index 94d9d21847..53b3f3afef 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -414,4 +414,90 @@ void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, in } L0480_ps_Projectile->_nextThing = Thing::_none; } + +void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) { + TimelineEvent* L0519_ps_Event; + Projectile* L0520_ps_Projectile; + Thing L0515_T_ProjectileThingNewCell; + uint16 L0516_ui_Multiple; +#define AL0516_ui_StepEnergy L0516_ui_Multiple +#define AL0516_ui_Square L0516_ui_Multiple + Thing L0521_T_ProjectileThing; + uint16 L0517_ui_ProjectileDirection; + bool L0522_B_ProjectileMovesToOtherSquare; + int16 L0523_i_DestinationMapX; + int16 L0524_i_DestinationMapY; + uint16 L0518_ui_Cell; + int16 L0525_i_SourceMapX; + int16 L0526_i_SourceMapY; + TimelineEvent L0527_s_Event; + + + L0527_s_Event = *event; + L0519_ps_Event = &L0527_s_Event; + L0520_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(L0521_T_ProjectileThing = L0515_T_ProjectileThingNewCell = Thing(L0519_ps_Event->_B._slot)); + L0523_i_DestinationMapX = L0519_ps_Event->_C._projectile.getMapX(); + L0524_i_DestinationMapY = L0519_ps_Event->_C._projectile.getMapY(); + if (L0519_ps_Event->_type == k48_TMEventTypeMoveProjectileIgnoreImpacts) { + L0519_ps_Event->_type = k49_TMEventTypeMoveProjectile; + } else { + L0518_ui_Cell = (L0515_T_ProjectileThingNewCell).getCell(); + if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0523_i_DestinationMapX == _vm->_dungeonMan->_g306_partyMapX) && (L0524_i_DestinationMapY == _vm->_dungeonMan->_g307_partyMapY) && f217_projectileHasImpactOccurred(kM2_ChampionElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) { + return; + } + if ((_vm->_groupMan->f175_groupGetThing(L0523_i_DestinationMapX, L0524_i_DestinationMapY) != Thing::_endOfList) && f217_projectileHasImpactOccurred(kM1_CreatureElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) { + return; + } + if (L0520_ps_Projectile->_kineticEnergy <= (AL0516_ui_StepEnergy = L0519_ps_Event->_C._projectile.getStepEnergy())) { + _vm->_dungeonMan->f164_unlinkThingFromList(L0515_T_ProjectileThingNewCell = L0521_T_ProjectileThing, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY); + f215_projectileDelete(L0515_T_ProjectileThingNewCell, NULL, L0523_i_DestinationMapX, L0524_i_DestinationMapY); + return; + } + L0520_ps_Projectile->_kineticEnergy -= AL0516_ui_StepEnergy; + if (L0520_ps_Projectile->_attack < AL0516_ui_StepEnergy) { + L0520_ps_Projectile->_attack = 0; + } else { + L0520_ps_Projectile->_attack -= AL0516_ui_StepEnergy; + } + } + if (L0522_B_ProjectileMovesToOtherSquare = ((L0517_ui_ProjectileDirection = L0519_ps_Event->_C._projectile.getDir()) == (L0518_ui_Cell = (L0515_T_ProjectileThingNewCell = Thing(L0519_ps_Event->_B._slot)).getCell())) || (returnNextVal(L0517_ui_ProjectileDirection) == L0518_ui_Cell)) { + L0525_i_SourceMapX = L0523_i_DestinationMapX; + L0526_i_SourceMapY = L0524_i_DestinationMapY; + L0523_i_DestinationMapX += _vm->_dirIntoStepCountEast[L0517_ui_ProjectileDirection], L0524_i_DestinationMapY += _vm->_dirIntoStepCountNorth[L0517_ui_ProjectileDirection]; + if ((Square(AL0516_ui_Square = _vm->_dungeonMan->f151_getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY).toByte()).getType() == k0_ElementTypeWall) || + ((Square(AL0516_ui_Square).getType() == k6_ElementTypeFakeWall) && !getFlag(AL0516_ui_Square, (k0x0001_FakeWallImaginary | k0x0004_FakeWallOpen))) || + ((Square(AL0516_ui_Square).getType() == k3_ElementTypeStairs) && (Square(_vm->_dungeonMan->_g271_currMapData[L0525_i_SourceMapX][L0526_i_SourceMapY]).getType() == k3_ElementTypeStairs))) { + if (f217_projectileHasImpactOccurred(Square(AL0516_ui_Square).getType(), L0525_i_SourceMapX, L0526_i_SourceMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) { + return; + } + } + } + if ((L0517_ui_ProjectileDirection & 0x0001) == (L0518_ui_Cell & 0x0001)) { + L0518_ui_Cell--; + } else { + L0518_ui_Cell++; + } + L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, L0518_ui_Cell &= 0x0003); + if (L0522_B_ProjectileMovesToOtherSquare) { + _vm->_movsens->f267_getMoveResult(L0515_T_ProjectileThingNewCell, L0525_i_SourceMapX, L0526_i_SourceMapY, L0523_i_DestinationMapX, L0524_i_DestinationMapY); + L0519_ps_Event->_C._projectile.setMapX(_vm->_movsens->_g397_moveResultMapX); + L0519_ps_Event->_C._projectile.setMapY(_vm->_movsens->_g398_moveResultMapY); + L0519_ps_Event->_C._projectile.setDir((direction)_vm->_movsens->_g400_moveResultDir); + L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_movsens->_g401_moveResultCell); + M31_setMap(L0519_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex); + } else { + if ((Square(_vm->_dungeonMan->f151_getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY)).getType() == k4_DoorElemType) && f217_projectileHasImpactOccurred(k4_DoorElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) { + return; + } + _vm->_dungeonMan->f164_unlinkThingFromList(L0515_T_ProjectileThingNewCell, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY); + _vm->_dungeonMan->f163_linkThingToList(L0515_T_ProjectileThingNewCell, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY); + } + L0519_ps_Event->_mapTime += (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) ? 1 : 3; + //Strangerke: CHECKME: Maybe we should keep that piece of code too as it sounds like it's fixing a weird behavior of projectiles on different maps +#ifdef COMPILE42_CSB20EN_CSB21EN /* CHANGE7_20_IMPROVEMENT Projectiles now move at the same speed on all maps instead of moving slower on maps other than the party map */ + L0519_ps_Event->Map_Time++; +#endif + L0519_ps_Event->_B._slot = L0515_T_ProjectileThingNewCell.toUint16(); + L0520_ps_Projectile->_eventIndex = _vm->_timeline->f238_addEventGetEventIndex(L0519_ps_Event); +} } diff --git a/engines/dm/projexpl.h b/engines/dm/projexpl.h index 32829f15af..125bd8e30f 100644 --- a/engines/dm/projexpl.h +++ b/engines/dm/projexpl.h @@ -30,6 +30,8 @@ #include "dm.h" +namespace DM { + #define k0_outcomeKilledNoCreaturesInGroup 0 // @ C0_OUTCOME_KILLED_NO_CREATURES_IN_GROUP #define k1_outcomeKilledSomeCreaturesInGroup 1 // @ C1_OUTCOME_KILLED_SOME_CREATURES_IN_GROUP #define k2_outcomeKilledAllCreaturesInGroup 2 // @ C2_OUTCOME_KILLED_ALL_CREATURES_IN_GROUP @@ -70,10 +72,12 @@ #define k33_soundMOVE_SKELETON 33 // @ C33_SOUND_MOVE_SKELETON -namespace DM { - class Projectile; +#define M31_setMap(map_time, map) ((map_time) = (((map_time) & 0x00FFFFFF) | (((int32)(map)) << 24))) - class ProjExpl { +class TimelineEvent; +class Projectile; + +class ProjExpl { DMEngine *_vm; public: int16 _g364_creatureDamageOutcome; // @ G0364_i_CreatureDamageOutcome @@ -94,6 +98,8 @@ public: int16 f218_projectileGetImpactCount(int16 impactType, int16 mapX, int16 mapY, int16 cell); // @ F0218_PROJECTILE_GetImpactCount void f214_projectileDeleteEvent(Thing thing); // @ F0214_PROJECTILE_DeleteEvent void f215_projectileDelete(Thing projectileThing, Thing *groupSlot, int16 mapX, int16 mapY); // @ F0215_PROJECTILE_Delete + void f219_processEvents48To49_projectile(TimelineEvent *event); // @ F0219_PROJECTILE_ProcessEvents48To49_Projectile + }; } diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 8f071574a5..c98338cb94 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -29,6 +29,8 @@ #include "dungeonman.h" #include "champion.h" #include "inventory.h" +#include "group.h" +#include "projexpl.h" namespace DM { @@ -224,12 +226,12 @@ void Timeline::f261_processTimeline() { _vm->_dungeonMan->f173_setCurrentMap(M29_map(L0682_s_Event._mapTime)); AL0680_ui_EventType = L0682_s_Event._type; if ((AL0680_ui_EventType > (k29_TMEventTypeGroupReactionDangerOnSquare - 1)) && (AL0680_ui_EventType < (k41_TMEventTypeUpdateBehaviour_3 + 1))) { - //F0209_GROUP_ProcessEvents29to41(L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, AL0680_ui_EventType, L0682_s_Event._C._ticks); + _vm->_groupMan->f209_processEvents29to41(L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, AL0680_ui_EventType, L0682_s_Event._C._ticks); } else { switch (AL0680_ui_EventType) { case k48_TMEventTypeMoveProjectileIgnoreImpacts: case k49_TMEventTypeMoveProjectile: - //F0219_PROJECTILE_ProcessEvents48To49_Projectile(L0681_ps_Event); + _vm->_projexpl->f219_processEvents48To49_projectile(L0681_ps_Event); break; case k1_TMEventTypeDoorAnimation: //F0241_TIMELINE_ProcessEvent1_DoorAnimation(L0681_ps_Event); -- cgit v1.2.3 From 953f7909fcc1c3b5f699bd9add53ec0a2640e00f Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 15:38:25 +0200 Subject: DM: Add f241_timelineProcessEvent1_doorAnimation --- engines/dm/dungeonman.h | 3 +- engines/dm/group.cpp | 2 +- engines/dm/timeline.cpp | 75 +++++++++++++++++++++++++++++++++++++++++++++++-- engines/dm/timeline.h | 1 + 4 files changed, 76 insertions(+), 5 deletions(-) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index a5c6ae2415..2763906d5d 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -204,8 +204,7 @@ public: uint16 M59_getWariness() { return (_properties >> 12) & 0xF; } uint16 M60_getFireResistance() { return (_resistances >> 4) & 0xF; } uint16 M61_poisonResistance() { return (_resistances >> 8) & 0xF; } - uint16 M51_height() { return (_attributes >> 7) & 0x3; } - + static uint16 M51_height(uint16 attrib) { return (attrib >> 7) & 0x3; } uint16 M54_getSightRange() { return (_ranges) & 0xF; } uint16 M55_getSmellRange() { return (_ranges >> 8) & 0xF; } uint16 M56_getAttackRange() { return (_ranges >> 12) & 0xF; } diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index ffd466f6b6..a39065bbba 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -1109,7 +1109,7 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i } if (L0431_i_SquareType == k4_DoorElemType) { L0432_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->f157_getSquareFirstThingData(L0428_i_MapX, L0429_i_MapY); - if (((Square(L0430_ui_Square).getDoorState()) > (((Door *)L0432_ps_Teleporter)->opensVertically() ? creatureInfo->M51_height() : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) { + if (((Square(L0430_ui_Square).getDoorState()) > (((Door *)L0432_ps_Teleporter)->opensVertically() ? CreatureInfo::M51_height(creatureInfo->_attributes) : 1)) && ((Square(L0430_ui_Square).getDoorState()) != k5_doorState_DESTROYED) && !getFlag(creatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) { _g389_groupMovementBlockedByDoor = true; return false; } diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index c98338cb94..2bb578e126 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -234,7 +234,7 @@ void Timeline::f261_processTimeline() { _vm->_projexpl->f219_processEvents48To49_projectile(L0681_ps_Event); break; case k1_TMEventTypeDoorAnimation: - //F0241_TIMELINE_ProcessEvent1_DoorAnimation(L0681_ps_Event); + f241_timelineProcessEvent1_doorAnimation(L0681_ps_Event); break; case k25_TMEventTypeExplosion: //F0220_EXPLOSION_ProcessEvent25_Explosion(L0681_ps_Event); @@ -330,7 +330,8 @@ T0261053: } bool Timeline::f240_isFirstEventExpiered() { - return (_vm->_timeline->_g372_eventCount && (M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime)); + warning(false, "possibly dangerous cast to int32"); + return (_vm->_timeline->_g372_eventCount && ((int32)M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime)); } void Timeline::f239_timelineExtractFirstEvent(TimelineEvent* event) { @@ -340,4 +341,74 @@ void Timeline::f239_timelineExtractFirstEvent(TimelineEvent* event) { f237_deleteEvent(L0592_ui_EventIndex); } +void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) { + uint16 L0593_ui_MapX; + uint16 L0594_ui_MapY; + int16 L0595_i_Effect; + int16 L0596_i_DoorState; + Square* L0597_puc_Square; + Door* L0598_ps_Door; + Thing L0599_T_GroupThing; + uint16 L0600_ui_CreatureAttributes; + uint16 L0602_ui_Multiple; +#define AL0602_ui_VerticalDoor L0602_ui_Multiple +#define AL0602_ui_Height L0602_ui_Multiple + + L0597_puc_Square = (Square*)&_vm->_dungeonMan->_g271_currMapData[L0593_ui_MapX = event->_B._location._mapX][L0594_ui_MapY = event->_B._location._mapY]; + if ((L0596_i_DoorState = Square(*L0597_puc_Square).getDoorState()) == k5_doorState_DESTROYED) { + return; + } + event->_mapTime++; + L0595_i_Effect = event->_C.A._effect; + if (L0595_i_Effect == k1_SensorEffClear) { + L0598_ps_Door = (Door*)_vm->_dungeonMan->f157_getSquareFirstThingData(L0593_ui_MapX, L0594_ui_MapY); + AL0602_ui_VerticalDoor = L0598_ps_Door->opensVertically(); + if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0593_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0594_ui_MapY == _vm->_dungeonMan->_g307_partyMapY) && (L0596_i_DoorState != k0_doorState_OPEN)) { + if (_vm->_championMan->_g305_partyChampionCount > 0) { + L0597_puc_Square->setDoorState(k0_doorState_OPEN); + + // Strangerke + // Original bug fixed - A closing horizontal door wounds champions to the head instead of to the hands. Missing parenthesis in the condition cause all doors to wound the head in addition to the torso + // See BUG0_78 + if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(5, k0x0008_ChampionWoundTorso | (AL0602_ui_VerticalDoor ? k0x0004_ChampionWoundHead : k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand), k2_attackType_SELF)) { + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + } + event->_mapTime++; + _vm->_timeline->f238_addEventGetEventIndex(event); + return; + } + if (((L0599_T_GroupThing = _vm->_groupMan->f175_groupGetThing(L0593_ui_MapX, L0594_ui_MapY)) != Thing::_endOfList) && !getFlag(L0600_ui_CreatureAttributes = _vm->_dungeonMan->f144_getCreatureAttributes(L0599_T_GroupThing), k0x0040_MaskCreatureInfo_nonMaterial)) { + if (L0596_i_DoorState >= (AL0602_ui_Height ? CreatureInfo::M51_height(L0600_ui_CreatureAttributes) : 1)) { /* Creature height or 1 */ + if (_vm->_groupMan->f191_getDamageAllCreaturesOutcome((Group*)_vm->_dungeonMan->f156_getThingData(L0599_T_GroupThing), L0593_ui_MapX, L0594_ui_MapY, 5, true) != k2_outcomeKilledAllCreaturesInGroup) { + _vm->_groupMan->f209_processEvents29to41(L0593_ui_MapX, L0594_ui_MapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0); + } + L0596_i_DoorState = (L0596_i_DoorState == k0_doorState_OPEN) ? k0_doorState_OPEN : (L0596_i_DoorState - 1); + L0597_puc_Square->setDoorState(L0596_i_DoorState); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + event->_mapTime++; + _vm->_timeline->f238_addEventGetEventIndex(event); + return; + } + } + } + if (((L0595_i_Effect == k0_SensorEffSet) && (L0596_i_DoorState == k0_doorState_OPEN)) || ((L0595_i_Effect == k1_SensorEffClear) && (L0596_i_DoorState == k4_doorState_CLOSED))) { + goto T0241020_Return; + } + L0596_i_DoorState += (L0595_i_Effect == k0_SensorEffSet) ? -1 : 1; + L0597_puc_Square->setDoorState(L0596_i_DoorState); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + if (L0595_i_Effect == k0_SensorEffSet) { + if (L0596_i_DoorState == k0_doorState_OPEN) { + return; + } + } else { + if (L0596_i_DoorState == k4_doorState_CLOSED) { + return; + } + } + _vm->_timeline->f238_addEventGetEventIndex(event); +T0241020_Return: + ; +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index b5728a0d95..7e94ed7543 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -162,6 +162,7 @@ public: void f261_processTimeline(); // @ F0261_TIMELINE_Process_CPSEF bool f240_isFirstEventExpiered(); // @ F0240_TIMELINE_IsFirstEventExpired_CPSE void f239_timelineExtractFirstEvent(TimelineEvent *event); // @ F0239_TIMELINE_ExtractFirstEvent + void f241_timelineProcessEvent1_doorAnimation(TimelineEvent *event); // @ F0241_TIMELINE_ProcessEvent1_DoorAnimation }; -- cgit v1.2.3 From cc5f1ab478e21d99ac3edeba621fea73bf591ea5 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 16:00:53 +0200 Subject: DM: Add f220_explosionProcessEvent25_explosion --- engines/dm/TODOs/todo.txt | 3 ++ engines/dm/dm.h | 2 +- engines/dm/projexpl.cpp | 92 +++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/projexpl.h | 2 +- engines/dm/timeline.cpp | 2 +- 5 files changed, 98 insertions(+), 3 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 1d08b44ca4..78a5e9cd80 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -6,6 +6,7 @@ Bugs: Logic: When object are put on the right side of the current square, they disappear + Drawing door ornaments segfaults when going back to the start @@ -19,4 +20,6 @@ Todo: Double check strcat, strstr usages, I might have messed them up in many places I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions +Finish stuff: + f261_processTimeline diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 1b4850a849..5b8061c809 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -81,8 +81,8 @@ enum ThingType { class Thing { - uint16 _data; public: + uint16 _data; static const Thing _none; // @ C0xFFFF_THING_NONE static const Thing _endOfList; // @ C0xFFFE_THING_ENDOFLIST static const Thing _firstExplosion; // @ C0xFF80_THING_FIRST_EXPLOSION diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index 53b3f3afef..e8464aab8d 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -500,4 +500,96 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) { L0519_ps_Event->_B._slot = L0515_T_ProjectileThingNewCell.toUint16(); L0520_ps_Projectile->_eventIndex = _vm->_timeline->f238_addEventGetEventIndex(L0519_ps_Event); } + +void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) { + Explosion* L0532_ps_Explosion; + Group* L0533_ps_Group; + CreatureInfo* L0534_ps_CreatureInfo; + uint16 L0528_ui_MapX; + uint16 L0529_ui_MapY; + int16 L0530_i_Attack; + int16 L0531_i_Multiple; +#define AL0531_i_SquareType L0531_i_Multiple +#define AL0531_i_CreatureCount L0531_i_Multiple + Thing L0535_T_GroupThing; + Thing L0536_T_ExplosionThing; + uint16 L0537_ui_Multiple; +#define AL0537_ui_CreatureType L0537_ui_Multiple +#define AL0537_ui_NonMaterialAdditionalAttack L0537_ui_Multiple + bool L0538_B_ExplosionOnPartySquare; + TimelineEvent L0539_s_Event; + + L0528_ui_MapX = event->_B._location._mapX; + L0529_ui_MapY = event->_B._location._mapY; + L0532_ps_Explosion = &((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[Thing((event->_C._slot)).getIndex()]; + AL0531_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[L0528_ui_MapX][L0529_ui_MapY]).getType(); + L0538_B_ExplosionOnPartySquare = (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0528_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0529_ui_MapY == _vm->_dungeonMan->_g307_partyMapY); + if ((L0535_T_GroupThing = _vm->_groupMan->f175_groupGetThing(L0528_ui_MapX, L0529_ui_MapY)) != Thing::_endOfList) { + L0533_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0535_T_GroupThing); + L0534_ps_CreatureInfo = &g243_CreatureInfo[AL0537_ui_CreatureType = L0533_ps_Group->_type]; + } + if ((L0536_T_ExplosionThing = Thing(Thing::_firstExplosion.toUint16() + L0532_ps_Explosion->getType())) == Thing::_explPoisonCloud) { + L0530_i_Attack = MAX(1, MIN(L0532_ps_Explosion->getAttack() >> 5, 4) + _vm->getRandomNumber(2)); /* Value between 1 and 5 */ + } else { + L0530_i_Attack = (L0532_ps_Explosion->getAttack() >> 1) + 1; + L0530_i_Attack += _vm->getRandomNumber(L0530_i_Attack) + 1; + } + + + switch (L0536_T_ExplosionThing.toUint16()) { + case 0xFF82: + if (!(L0530_i_Attack >>= 1)) + break; + case 0xFF80: + if (AL0531_i_SquareType == k4_DoorElemType) { + _vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true, 0); + } + break; + case 0xFF83: + if ((L0535_T_GroupThing != Thing::_endOfList) && getFlag(L0534_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial)) { + if ((AL0537_ui_CreatureType == k19_CreatureTypeMaterializerZytaz) && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) { /* ASSEMBLY_COMPILATION_DIFFERENCE jmp */ + L0530_i_Attack -= (AL0537_ui_NonMaterialAdditionalAttack = L0530_i_Attack >> 3); + AL0537_ui_NonMaterialAdditionalAttack <<= 1; + AL0537_ui_NonMaterialAdditionalAttack++; + AL0531_i_CreatureCount = L0533_ps_Group->getCount(); + do { + if (getFlag(_vm->_groupMan->_g375_activeGroups[L0533_ps_Group->getActiveGroupIndex()]._aspect[AL0531_i_CreatureCount], k0x0080_MaskActiveGroupIsAttacking)) { /* Materializer / Zytaz can only be damaged while they are attacking */ + _vm->_groupMan->f190_groupGetDamageCreatureOutcome(L0533_ps_Group, AL0531_i_CreatureCount, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack + _vm->getRandomNumber(AL0537_ui_NonMaterialAdditionalAttack) + _vm->getRandomNumber(4), true); + } + } while (--AL0531_i_CreatureCount >= 0); + } else { + _vm->_groupMan->f191_getDamageAllCreaturesOutcome(L0533_ps_Group, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true); + } + } + break; + case 0xFFE4: + L0532_ps_Explosion->setType(L0532_ps_Explosion->getType() + 1); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + goto T0220026; + case 0xFFA8: + if (L0532_ps_Explosion->getAttack() > 55) { + L0532_ps_Explosion->setAttack(L0532_ps_Explosion->getAttack() - 40); + goto T0220026; + } + break; + case 0xFF87: + if (L0538_B_ExplosionOnPartySquare) { + _vm->_championMan->f324_damageAll_getDamagedChampionCount(L0530_i_Attack, k0x0000_ChampionWoundNone, k0_attackType_NORMAL); + } else { + if ((L0535_T_GroupThing != Thing::_endOfList) && (L0530_i_Attack = _vm->_groupMan->f192_groupGetResistanceAdjustedPoisonAttack(AL0537_ui_CreatureType, L0530_i_Attack)) && (_vm->_groupMan->f191_getDamageAllCreaturesOutcome(L0533_ps_Group, L0528_ui_MapX, L0529_ui_MapY, L0530_i_Attack, true) != k2_outcomeKilledAllCreaturesInGroup) && (L0530_i_Attack > 2)) { + _vm->_groupMan->f209_processEvents29to41(L0528_ui_MapX, L0529_ui_MapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0); + } + } + if (L0532_ps_Explosion->getAttack() >= 6) { + L0532_ps_Explosion->setAttack(L0532_ps_Explosion->getAttack() - 3); +T0220026: + L0539_s_Event = *event; + L0539_s_Event._mapTime++; + _vm->_timeline->f238_addEventGetEventIndex(&L0539_s_Event); + return; + } + } + _vm->_dungeonMan->f164_unlinkThingFromList(Thing(event->_C._slot), Thing(0), L0528_ui_MapX, L0529_ui_MapY); + L0532_ps_Explosion->setNextThing(Thing::_none); +} } diff --git a/engines/dm/projexpl.h b/engines/dm/projexpl.h index 125bd8e30f..d0e030f719 100644 --- a/engines/dm/projexpl.h +++ b/engines/dm/projexpl.h @@ -99,7 +99,7 @@ public: void f214_projectileDeleteEvent(Thing thing); // @ F0214_PROJECTILE_DeleteEvent void f215_projectileDelete(Thing projectileThing, Thing *groupSlot, int16 mapX, int16 mapY); // @ F0215_PROJECTILE_Delete void f219_processEvents48To49_projectile(TimelineEvent *event); // @ F0219_PROJECTILE_ProcessEvents48To49_Projectile - + void f220_explosionProcessEvent25_explosion(TimelineEvent *event); // @ F0220_EXPLOSION_ProcessEvent25_Explosion }; } diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 2bb578e126..55a80cf915 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -237,7 +237,7 @@ void Timeline::f261_processTimeline() { f241_timelineProcessEvent1_doorAnimation(L0681_ps_Event); break; case k25_TMEventTypeExplosion: - //F0220_EXPLOSION_ProcessEvent25_Explosion(L0681_ps_Event); + _vm->_projexpl->f220_explosionProcessEvent25_explosion(L0681_ps_Event); break; case k7_TMEventTypeFakeWall: //F0242_TIMELINE_ProcessEvent7_Square_FakeWall(L0681_ps_Event); -- cgit v1.2.3 From 12dff65535144968005e1765b235ffc0b9408177 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 16:12:12 +0200 Subject: DM: Add f242_timelineProcessEvent7_squareFakewall --- engines/dm/timeline.cpp | 32 +++++++++++++++++++++++++++++++- engines/dm/timeline.h | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 55a80cf915..c8a310379b 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -240,7 +240,7 @@ void Timeline::f261_processTimeline() { _vm->_projexpl->f220_explosionProcessEvent25_explosion(L0681_ps_Event); break; case k7_TMEventTypeFakeWall: - //F0242_TIMELINE_ProcessEvent7_Square_FakeWall(L0681_ps_Event); + f242_timelineProcessEvent7_squareFakewall(L0681_ps_Event); break; case k2_TMEventTypeDoorDestruction: //F0243_TIMELINE_ProcessEvent2_DoorDestruction(L0681_ps_Event); @@ -411,4 +411,34 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) { T0241020_Return: ; } + +void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) { + uint16 L0603_ui_MapX; + uint16 L0604_ui_MapY; + int16 L0605_i_Effect; + Thing L0606_T_Thing; + Square* L0607_puc_Square; + + + L0607_puc_Square = (Square*)&_vm->_dungeonMan->_g271_currMapData[L0603_ui_MapX = event->_B._location._mapX][L0604_ui_MapY = event->_B._location._mapY]; + L0605_i_Effect = event->_C.A._effect; + if (L0605_i_Effect == k2_SensorEffToggle) { + L0605_i_Effect = L0607_puc_Square->get(k0x0004_FakeWallOpen) ? k1_SensorEffClear : k0_SensorEffSet; + } + if (L0605_i_Effect == k1_SensorEffClear) { + if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0603_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0604_ui_MapY == _vm->_dungeonMan->_g307_partyMapY)) { + event->_mapTime++; + _vm->_timeline->f238_addEventGetEventIndex(event); + } else { + if (((L0606_T_Thing = _vm->_groupMan->f175_groupGetThing(L0603_ui_MapX, L0604_ui_MapY)) != Thing::_endOfList) && !getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(L0606_T_Thing), k0x0040_MaskCreatureInfo_nonMaterial)) { + event->_mapTime++; + _vm->_timeline->f238_addEventGetEventIndex(event); + } else { + L0607_puc_Square->set(k0x0004_FakeWallOpen); + } + } + } else { + L0607_puc_Square->set(k0x0004_FakeWallOpen); + } +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index 7e94ed7543..b34a98b53d 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -163,6 +163,7 @@ public: bool f240_isFirstEventExpiered(); // @ F0240_TIMELINE_IsFirstEventExpired_CPSE void f239_timelineExtractFirstEvent(TimelineEvent *event); // @ F0239_TIMELINE_ExtractFirstEvent void f241_timelineProcessEvent1_doorAnimation(TimelineEvent *event); // @ F0241_TIMELINE_ProcessEvent1_DoorAnimation + void f242_timelineProcessEvent7_squareFakewall(TimelineEvent *event); // @ F0242_TIMELINE_ProcessEvent7_Square_FakeWall }; -- cgit v1.2.3 From d1f0281e9d870b5caf8be492868be20519928df3 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 16:15:23 +0200 Subject: DM: Add f243_timelineProcessEvent2_doorDestruction --- engines/dm/timeline.cpp | 9 ++++++++- engines/dm/timeline.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index c8a310379b..073eeb044c 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -243,7 +243,7 @@ void Timeline::f261_processTimeline() { f242_timelineProcessEvent7_squareFakewall(L0681_ps_Event); break; case k2_TMEventTypeDoorDestruction: - //F0243_TIMELINE_ProcessEvent2_DoorDestruction(L0681_ps_Event); + f243_timelineProcessEvent2_doorDestruction(L0681_ps_Event); break; case k10_TMEventTypeDoor: //F0244_TIMELINE_ProcessEvent10_Square_Door(L0681_ps_Event); @@ -441,4 +441,11 @@ void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) { L0607_puc_Square->set(k0x0004_FakeWallOpen); } } + +void Timeline::f243_timelineProcessEvent2_doorDestruction(TimelineEvent* event) { + Square* L0608_puc_Square; + + L0608_puc_Square = (Square*)&_vm->_dungeonMan->_g271_currMapData[event->_B._location._mapX][event->_B._location._mapY]; + L0608_puc_Square->set(k5_doorState_DESTROYED); +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index b34a98b53d..aeb9cc7b00 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -164,6 +164,7 @@ public: void f239_timelineExtractFirstEvent(TimelineEvent *event); // @ F0239_TIMELINE_ExtractFirstEvent void f241_timelineProcessEvent1_doorAnimation(TimelineEvent *event); // @ F0241_TIMELINE_ProcessEvent1_DoorAnimation void f242_timelineProcessEvent7_squareFakewall(TimelineEvent *event); // @ F0242_TIMELINE_ProcessEvent7_Square_FakeWall + void f243_timelineProcessEvent2_doorDestruction(TimelineEvent *event); // @ F0243_TIMELINE_ProcessEvent2_DoorDestruction }; -- cgit v1.2.3 From ad11a4f48ce9fbc3547a69870ba7a08dbeff2c08 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 16:18:39 +0200 Subject: DM: Add f244_timelineProcessEvent10_squareDoor --- engines/dm/timeline.cpp | 26 +++++++++++++++++++++++++- engines/dm/timeline.h | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 073eeb044c..ed3b33093b 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -246,7 +246,7 @@ void Timeline::f261_processTimeline() { f243_timelineProcessEvent2_doorDestruction(L0681_ps_Event); break; case k10_TMEventTypeDoor: - //F0244_TIMELINE_ProcessEvent10_Square_Door(L0681_ps_Event); + f244_timelineProcessEvent10_squareDoor(L0681_ps_Event); break; case k9_TMEventTypePit: //F0251_TIMELINE_ProcessEvent9_Square_Pit(L0681_ps_Event); @@ -448,4 +448,28 @@ void Timeline::f243_timelineProcessEvent2_doorDestruction(TimelineEvent* event) L0608_puc_Square = (Square*)&_vm->_dungeonMan->_g271_currMapData[event->_B._location._mapX][event->_B._location._mapY]; L0608_puc_Square->set(k5_doorState_DESTROYED); } + +void Timeline::f244_timelineProcessEvent10_squareDoor(TimelineEvent* event) { + int16 L0609_i_DoorState; + + + if ((L0609_i_DoorState = Square(_vm->_dungeonMan->_g271_currMapData[event->_B._location._mapX][event->_B._location._mapY]).getDoorState()) == k5_doorState_DESTROYED) { + return; + } + if (event->_C.A._effect == k2_SensorEffToggle) { + event->_C.A._effect = (L0609_i_DoorState == k0_doorState_OPEN) ? k1_SensorEffClear : k0_SensorEffSet; + } else { + if (event->_C.A._effect == k0_SensorEffSet) { + if (L0609_i_DoorState == k0_doorState_OPEN) { + return; + } + } else { + if (L0609_i_DoorState == k4_doorState_CLOSED) { + return; + } + } + } + event->_type = k1_TMEventTypeDoorAnimation; + _vm->_timeline->f238_addEventGetEventIndex(event); +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index aeb9cc7b00..533a317368 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -165,6 +165,7 @@ public: void f241_timelineProcessEvent1_doorAnimation(TimelineEvent *event); // @ F0241_TIMELINE_ProcessEvent1_DoorAnimation void f242_timelineProcessEvent7_squareFakewall(TimelineEvent *event); // @ F0242_TIMELINE_ProcessEvent7_Square_FakeWall void f243_timelineProcessEvent2_doorDestruction(TimelineEvent *event); // @ F0243_TIMELINE_ProcessEvent2_DoorDestruction + void f244_timelineProcessEvent10_squareDoor(TimelineEvent *event); // @ F0244_TIMELINE_ProcessEvent10_Square_Door }; -- cgit v1.2.3 From 81a8c8cf742314d12850163ff7ffba48f1837bac Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 16:20:55 +0200 Subject: DM: Clear some warnings --- engines/dm/projexpl.cpp | 10 +++++----- engines/dm/timeline.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index e8464aab8d..7d99b97648 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -428,8 +428,8 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) { int16 L0523_i_DestinationMapX; int16 L0524_i_DestinationMapY; uint16 L0518_ui_Cell; - int16 L0525_i_SourceMapX; - int16 L0526_i_SourceMapY; + int16 L0525_i_SourceMapX = -1; + int16 L0526_i_SourceMapY = -1; TimelineEvent L0527_s_Event; @@ -503,8 +503,8 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) { void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) { Explosion* L0532_ps_Explosion; - Group* L0533_ps_Group; - CreatureInfo* L0534_ps_CreatureInfo; + Group* L0533_ps_Group = nullptr; + CreatureInfo* L0534_ps_CreatureInfo = nullptr; uint16 L0528_ui_MapX; uint16 L0529_ui_MapY; int16 L0530_i_Attack; @@ -513,7 +513,7 @@ void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) { #define AL0531_i_CreatureCount L0531_i_Multiple Thing L0535_T_GroupThing; Thing L0536_T_ExplosionThing; - uint16 L0537_ui_Multiple; + uint16 L0537_ui_Multiple = 0; #define AL0537_ui_CreatureType L0537_ui_Multiple #define AL0537_ui_NonMaterialAdditionalAttack L0537_ui_Multiple bool L0538_B_ExplosionOnPartySquare; diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index ed3b33093b..2e2a249c17 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -330,8 +330,8 @@ T0261053: } bool Timeline::f240_isFirstEventExpiered() { - warning(false, "possibly dangerous cast to int32"); - return (_vm->_timeline->_g372_eventCount && ((int32)M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime)); + warning(false, "possibly dangerous cast to uint32"); + return (_vm->_timeline->_g372_eventCount && ((uint32)M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime)); } void Timeline::f239_timelineExtractFirstEvent(TimelineEvent* event) { -- cgit v1.2.3 From f6dea6c73e064d69d9fdc64c9dedb9959e004385 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 16:38:15 +0200 Subject: DM: Add f251_timelineProcessEvent9_squarePit --- engines/dm/timeline.cpp | 92 +++++++++++++++++++++++++++++++++++++++++++++---- engines/dm/timeline.h | 2 ++ 2 files changed, 87 insertions(+), 7 deletions(-) diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 2e2a249c17..76582af49b 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -31,6 +31,7 @@ #include "inventory.h" #include "group.h" #include "projexpl.h" +#include "movesens.h" namespace DM { @@ -249,7 +250,7 @@ void Timeline::f261_processTimeline() { f244_timelineProcessEvent10_squareDoor(L0681_ps_Event); break; case k9_TMEventTypePit: - //F0251_TIMELINE_ProcessEvent9_Square_Pit(L0681_ps_Event); + f251_timelineProcessEvent9_squarePit(L0681_ps_Event); break; case k8_TMEventTypeTeleporter: //F0250_TIMELINE_ProcessEvent8_Square_Teleporter(L0681_ps_Event); @@ -417,13 +418,13 @@ void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) { uint16 L0604_ui_MapY; int16 L0605_i_Effect; Thing L0606_T_Thing; - Square* L0607_puc_Square; + byte* L0607_puc_Square; - L0607_puc_Square = (Square*)&_vm->_dungeonMan->_g271_currMapData[L0603_ui_MapX = event->_B._location._mapX][L0604_ui_MapY = event->_B._location._mapY]; + L0607_puc_Square = &_vm->_dungeonMan->_g271_currMapData[L0603_ui_MapX = event->_B._location._mapX][L0604_ui_MapY = event->_B._location._mapY]; L0605_i_Effect = event->_C.A._effect; if (L0605_i_Effect == k2_SensorEffToggle) { - L0605_i_Effect = L0607_puc_Square->get(k0x0004_FakeWallOpen) ? k1_SensorEffClear : k0_SensorEffSet; + L0605_i_Effect = getFlag(*L0607_puc_Square, k0x0004_FakeWallOpen) ? k1_SensorEffClear : k0_SensorEffSet; } if (L0605_i_Effect == k1_SensorEffClear) { if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0603_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0604_ui_MapY == _vm->_dungeonMan->_g307_partyMapY)) { @@ -434,11 +435,11 @@ void Timeline::f242_timelineProcessEvent7_squareFakewall(TimelineEvent* event) { event->_mapTime++; _vm->_timeline->f238_addEventGetEventIndex(event); } else { - L0607_puc_Square->set(k0x0004_FakeWallOpen); + clearFlag(*L0607_puc_Square, k0x0004_FakeWallOpen); } } } else { - L0607_puc_Square->set(k0x0004_FakeWallOpen); + setFlag(*L0607_puc_Square, k0x0004_FakeWallOpen); } } @@ -446,7 +447,7 @@ void Timeline::f243_timelineProcessEvent2_doorDestruction(TimelineEvent* event) Square* L0608_puc_Square; L0608_puc_Square = (Square*)&_vm->_dungeonMan->_g271_currMapData[event->_B._location._mapX][event->_B._location._mapY]; - L0608_puc_Square->set(k5_doorState_DESTROYED); + L0608_puc_Square->setDoorState(k5_doorState_DESTROYED); } void Timeline::f244_timelineProcessEvent10_squareDoor(TimelineEvent* event) { @@ -472,4 +473,81 @@ void Timeline::f244_timelineProcessEvent10_squareDoor(TimelineEvent* event) { event->_type = k1_TMEventTypeDoorAnimation; _vm->_timeline->f238_addEventGetEventIndex(event); } + +void Timeline::f251_timelineProcessEvent9_squarePit(TimelineEvent* event) { + uint16 L0653_ui_MapX; + uint16 L0654_ui_MapY; + byte* L0655_puc_Square; + + + L0655_puc_Square = &_vm->_dungeonMan->_g271_currMapData[L0653_ui_MapX = event->_B._location._mapX][L0654_ui_MapY = event->_B._location._mapY]; + if (event->_C.A._effect == k2_SensorEffToggle) { + event->_C.A._effect = getFlag(*L0655_puc_Square, k0x0008_PitOpen) ? k1_SensorEffClear : k0_SensorEffSet; + } + if (event->_C.A._effect == k0_SensorEffSet) { + setFlag(*L0655_puc_Square, k0x0008_PitOpen); + f249_moveTeleporterOrPitSquareThings(L0653_ui_MapX, L0654_ui_MapY); + } else { + clearFlag(*L0655_puc_Square, k0x0008_PitOpen); + } +} + +void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) { + uint16 L0644_ui_Multiple; +#define AL0644_ui_ThingType L0644_ui_Multiple +#define AL0644_ui_EventIndex L0644_ui_Multiple + Thing L0645_T_Thing; + Projectile* L0646_ps_Projectile; + TimelineEvent* L0647_ps_Event; + Thing L0648_T_NextThing; + int16 L0649_i_ThingsToMoveCount; + + + if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX == _vm->_dungeonMan->_g306_partyMapX) && (mapY == _vm->_dungeonMan->_g307_partyMapY)) { + _vm->_movsens->f267_getMoveResult(Thing::_party, mapX, mapY, mapX, mapY); + _vm->_championMan->f296_drawChangedObjectIcons(); + } + if ((L0645_T_Thing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) != Thing::_endOfList) { + _vm->_movsens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY); + } + L0645_T_Thing = _vm->_dungeonMan->f162_getSquareFirstObject(mapX, mapY); + L0648_T_NextThing = L0645_T_Thing; + L0649_i_ThingsToMoveCount = 0; + while (L0645_T_Thing != Thing::_endOfList) { + if (L0645_T_Thing.getType() > k4_GroupThingType) { + L0649_i_ThingsToMoveCount++; + } + L0645_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0645_T_Thing); + } + L0645_T_Thing = L0648_T_NextThing; + while ((L0645_T_Thing != Thing::_endOfList) && L0649_i_ThingsToMoveCount) { + L0649_i_ThingsToMoveCount--; + L0648_T_NextThing = _vm->_dungeonMan->f159_getNextThing(L0645_T_Thing); + AL0644_ui_ThingType = L0645_T_Thing.getType(); + if (AL0644_ui_ThingType > k4_GroupThingType) { + _vm->_movsens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY); + } + if (AL0644_ui_ThingType == k14_ProjectileThingType) { + L0646_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(L0645_T_Thing); + L0647_ps_Event = &_vm->_timeline->_g370_events[L0646_ps_Projectile->_eventIndex]; + L0647_ps_Event->_C._projectile.setMapX(_vm->_movsens->_g397_moveResultMapX); + L0647_ps_Event->_C._projectile.setMapY(_vm->_movsens->_g398_moveResultMapY); + L0647_ps_Event->_C._projectile.setDir((direction)_vm->_movsens->_g400_moveResultDir); + L0647_ps_Event->_B._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_movsens->_g401_moveResultCell).toUint16(); + M31_setMap(L0647_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex); + } else { + if (AL0644_ui_ThingType == k15_ExplosionThingType) { + for (AL0644_ui_EventIndex = 0, L0647_ps_Event = _vm->_timeline->_g370_events; AL0644_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0647_ps_Event++, AL0644_ui_EventIndex++) { + if ((L0647_ps_Event->_type== k25_TMEventTypeExplosion) && (L0647_ps_Event->_C._slot == L0645_T_Thing.toUint16())) { /* BUG0_23 A Fluxcage explosion remains on a square forever. If you open a pit or teleporter on a square where there is a Fluxcage explosion, the Fluxcage explosion is moved but the associated event is not updated (because Fluxcage explosions do not use k25_TMEventTypeExplosion but rather k24_TMEventTypeRemoveFluxcage) causing the Fluxcage explosion to remain in the dungeon forever on its destination square. When the k24_TMEventTypeRemoveFluxcage expires the explosion thing is not removed, but it is marked as unused. Consequently, any objects placed on the Fluxcage square after it was moved but before it expires become orphans upon expiration. After expiration, any object placed on the fluxcage square is cloned when picked up */ + L0647_ps_Event->_B._location._mapX = _vm->_movsens->_g397_moveResultMapX; + L0647_ps_Event->_B._location._mapY = _vm->_movsens->_g398_moveResultMapY; + L0647_ps_Event->_C._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_movsens->_g401_moveResultCell).toUint16(); + M31_setMap(L0647_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex); + } + } + } + } + L0645_T_Thing = L0648_T_NextThing; + } +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index 533a317368..b6c728fabb 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -166,6 +166,8 @@ public: void f242_timelineProcessEvent7_squareFakewall(TimelineEvent *event); // @ F0242_TIMELINE_ProcessEvent7_Square_FakeWall void f243_timelineProcessEvent2_doorDestruction(TimelineEvent *event); // @ F0243_TIMELINE_ProcessEvent2_DoorDestruction void f244_timelineProcessEvent10_squareDoor(TimelineEvent *event); // @ F0244_TIMELINE_ProcessEvent10_Square_Door + void f251_timelineProcessEvent9_squarePit(TimelineEvent *event); // @ F0251_TIMELINE_ProcessEvent9_Square_Pit + void f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY); // @ F0249_TIMELINE_MoveTeleporterOrPitSquareThings }; -- cgit v1.2.3 From d77ffceff9cc8266c9fea4ab33c90b5c78341ec7 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 16:41:23 +0200 Subject: DM: Add f250_timelineProcessEvent8_squareTeleporter --- engines/dm/timeline.cpp | 22 ++++++++++++++++++++-- engines/dm/timeline.h | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 76582af49b..5b2d137d83 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -253,7 +253,7 @@ void Timeline::f261_processTimeline() { f251_timelineProcessEvent9_squarePit(L0681_ps_Event); break; case k8_TMEventTypeTeleporter: - //F0250_TIMELINE_ProcessEvent8_Square_Teleporter(L0681_ps_Event); + f250_timelineProcessEvent8_squareTeleporter(L0681_ps_Event); break; case k6_TMEventTypeWall: //F0248_TIMELINE_ProcessEvent6_Square_Wall(L0681_ps_Event); @@ -538,7 +538,7 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) { } else { if (AL0644_ui_ThingType == k15_ExplosionThingType) { for (AL0644_ui_EventIndex = 0, L0647_ps_Event = _vm->_timeline->_g370_events; AL0644_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0647_ps_Event++, AL0644_ui_EventIndex++) { - if ((L0647_ps_Event->_type== k25_TMEventTypeExplosion) && (L0647_ps_Event->_C._slot == L0645_T_Thing.toUint16())) { /* BUG0_23 A Fluxcage explosion remains on a square forever. If you open a pit or teleporter on a square where there is a Fluxcage explosion, the Fluxcage explosion is moved but the associated event is not updated (because Fluxcage explosions do not use k25_TMEventTypeExplosion but rather k24_TMEventTypeRemoveFluxcage) causing the Fluxcage explosion to remain in the dungeon forever on its destination square. When the k24_TMEventTypeRemoveFluxcage expires the explosion thing is not removed, but it is marked as unused. Consequently, any objects placed on the Fluxcage square after it was moved but before it expires become orphans upon expiration. After expiration, any object placed on the fluxcage square is cloned when picked up */ + if ((L0647_ps_Event->_type == k25_TMEventTypeExplosion) && (L0647_ps_Event->_C._slot == L0645_T_Thing.toUint16())) { /* BUG0_23 A Fluxcage explosion remains on a square forever. If you open a pit or teleporter on a square where there is a Fluxcage explosion, the Fluxcage explosion is moved but the associated event is not updated (because Fluxcage explosions do not use k25_TMEventTypeExplosion but rather k24_TMEventTypeRemoveFluxcage) causing the Fluxcage explosion to remain in the dungeon forever on its destination square. When the k24_TMEventTypeRemoveFluxcage expires the explosion thing is not removed, but it is marked as unused. Consequently, any objects placed on the Fluxcage square after it was moved but before it expires become orphans upon expiration. After expiration, any object placed on the fluxcage square is cloned when picked up */ L0647_ps_Event->_B._location._mapX = _vm->_movsens->_g397_moveResultMapX; L0647_ps_Event->_B._location._mapY = _vm->_movsens->_g398_moveResultMapY; L0647_ps_Event->_C._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_movsens->_g401_moveResultCell).toUint16(); @@ -550,4 +550,22 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) { L0645_T_Thing = L0648_T_NextThing; } } + +void Timeline::f250_timelineProcessEvent8_squareTeleporter(TimelineEvent* event) { + uint16 L0650_ui_MapX; + uint16 L0651_ui_MapY; + byte* L0652_puc_Square; + + + L0652_puc_Square = &_vm->_dungeonMan->_g271_currMapData[L0650_ui_MapX = event->_B._location._mapX][L0651_ui_MapY = event->_B._location._mapY]; + if (event->_C.A._effect == k2_SensorEffToggle) { + event->_C.A._effect = getFlag(*L0652_puc_Square, k0x0008_TeleporterOpen) ? k1_SensorEffClear : k0_SensorEffSet; + } + if (event->_C.A._effect == k0_SensorEffSet) { + setFlag(*L0652_puc_Square, k0x0008_TeleporterOpen); + f249_moveTeleporterOrPitSquareThings(L0650_ui_MapX, L0651_ui_MapY); + } else { + clearFlag(*L0652_puc_Square, k0x0008_TeleporterOpen); + } +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index b6c728fabb..a0d2877704 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -168,6 +168,7 @@ public: void f244_timelineProcessEvent10_squareDoor(TimelineEvent *event); // @ F0244_TIMELINE_ProcessEvent10_Square_Door void f251_timelineProcessEvent9_squarePit(TimelineEvent *event); // @ F0251_TIMELINE_ProcessEvent9_Square_Pit void f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY); // @ F0249_TIMELINE_MoveTeleporterOrPitSquareThings + void f250_timelineProcessEvent8_squareTeleporter(TimelineEvent *event); // @ F0250_TIMELINE_ProcessEvent8_Square_Teleporter }; -- cgit v1.2.3 From 536e9c1bb9e603e420843647a092b50f7668a996 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 11 Jul 2016 17:06:24 +0200 Subject: DM: Add f248_timelineProcessEvent6_squareWall --- engines/dm/champion.cpp | 2 +- engines/dm/dm.cpp | 4 +- engines/dm/dm.h | 2 +- engines/dm/dungeonman.h | 13 ++-- engines/dm/timeline.cpp | 175 +++++++++++++++++++++++++++++++++++++++++++++++- engines/dm/timeline.h | 6 +- 6 files changed, 190 insertions(+), 12 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 4a1508fb84..a9684111b0 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -820,7 +820,7 @@ uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion* champ, uint16 stat void ChampionMan::f314_wakeUp() { _vm->_g321_stopWaitingForPlayerInput = true; _g300_partyIsSleeping = false; - _vm->waitMs(10); + _vm->f22_delay(10); _vm->_displayMan->f98_drawFloorAndCeiling(); _vm->_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface; _vm->_eventMan->_g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 8a49b23e87..932de5a60c 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -199,8 +199,8 @@ DMEngine::~DMEngine() { DebugMan.clearAllDebugChannels(); } -void DMEngine::waitMs(uint16 ms) { - _system->delayMillis(ms * 20); +void DMEngine::f22_delay(uint16 verticalBlank) { + _system->delayMillis(verticalBlank * 20); // Google says most Amiga games had a refreshrate of 50 hz } uint16 DMEngine::f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2) { diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 5b8061c809..1e1fc6a53c 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -184,7 +184,7 @@ public: explicit DMEngine(OSystem *syst); ~DMEngine(); - void waitMs(uint16 ms); + void f22_delay(uint16 ms); // @ F0022_MAIN_Delay uint16 f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2); // @ F0030_MAIN_GetScaledProduct uint16 getRandomNumber(uint32 max) { return _rnd->getRandomNumber(max - 1); } int16 M1_ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 2763906d5d..e0a1d8ff50 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -260,6 +260,7 @@ public: Thing getNextThing() { return _nextThing; } uint16 getWordOffset() { return _textDataRef >> 3; } bool isVisible() { return _textDataRef & 1; } + void setVisible(bool visible) { _textDataRef = (_textDataRef & ~1) | (visible ? 1 : 0); } }; // @ TEXTSTRING enum SensorActionType { @@ -306,8 +307,8 @@ enum SensorType { class Sensor { Thing _nextThing; uint16 _datAndType; - uint16 _attributes; - uint16 _action; + uint16 _attributes; // A + uint16 _action; // B public: explicit Sensor(uint16 *rawDat) : _nextThing(rawDat[0]), _datAndType(rawDat[1]), _attributes(rawDat[2]), _action(rawDat[3]) {} @@ -315,8 +316,8 @@ public: void setNextThing(Thing thing) { _nextThing = thing; } SensorType getType() { return (SensorType)(_datAndType & 0x7F); } // @ M39_TYPE uint16 getData() { return _datAndType >> 7; } // @ M40_DATA - uint16 getDataMask1() { return (_datAndType >> 7) & 0xF; } // @ M42_MASK1 - uint16 getDataMask2() { return (_datAndType >> 11) & 0xF; } // @ M43_MASK2 + static uint16 getDataMask1(uint16 data) { return (data >> 7) & 0xF; } // @ M42_MASK1 + static uint16 getDataMask2(uint16 data) { return (data >> 11) & 0xF; } // @ M43_MASK2 void setData(int16 dat) { _datAndType = (_datAndType & 0x7F) | (dat << 7); } // @ M41_SET_DATA void setTypeDisabled() { _datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED @@ -333,6 +334,8 @@ public: uint16 getTargetMapY() { return (_action >> 11); } uint16 getTargetMapX() { return (_action >> 6) & 0x1F; } direction getTargetCell() { return (direction)((_action >> 4) & 3); } + uint16 M47_kineticEnergy() { return (_action & 0xFF); }// @ M47_KINETIC_ENERGY + uint16 M48_stepEnergy() { return (_action >> 8) & 0xFF; }// @ M48_STEP_ENERGY uint16 M49_localEffect() { return (_action >> 4); } @@ -652,7 +655,7 @@ class DungeonMan { int16 f170_getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal void f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir, - int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals + int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals public: diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 5b2d137d83..524b5a5050 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -256,7 +256,7 @@ void Timeline::f261_processTimeline() { f250_timelineProcessEvent8_squareTeleporter(L0681_ps_Event); break; case k6_TMEventTypeWall: - //F0248_TIMELINE_ProcessEvent6_Square_Wall(L0681_ps_Event); + f248_timelineProcessEvent6_squareWall(L0681_ps_Event); break; case k5_TMEventTypeCorridor: //F0245_TIMELINE_ProcessEvent5_Square_Corridor(L0681_ps_Event); @@ -568,4 +568,177 @@ void Timeline::f250_timelineProcessEvent8_squareTeleporter(TimelineEvent* event) clearFlag(*L0652_puc_Square, k0x0008_TeleporterOpen); } } + +void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) { + Thing L0634_T_Thing; + int16 L0635_i_ThingType; + int16 L0636_i_Multiple; +#define AL0636_B_TriggerSetEffect L0636_i_Multiple +#define AL0636_i_BitMask L0636_i_Multiple + uint16 L0637_ui_SensorData; + Sensor* L0638_ps_Sensor; + TextString* L0639_ps_TextString; + uint16 L0640_ui_SensorType; + int16 L0641_i_MapX; + int16 L0642_i_MapY; + uint16 L0643_ui_Cell; + + + L0634_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0641_i_MapX = event->_B._location._mapX, L0642_i_MapY = event->_B._location._mapY); + L0643_ui_Cell = event->_C.A._cell; + while (L0634_T_Thing != Thing::_endOfList) { + if (((L0635_i_ThingType = L0634_T_Thing.getType()) == k2_TextstringType) && (L0634_T_Thing.getCell() == event->_C.A._cell)) { + L0639_ps_TextString = (TextString*)_vm->_dungeonMan->f156_getThingData(L0634_T_Thing); + if (event->_C.A._effect == k2_SensorEffToggle) { + L0639_ps_TextString->setVisible(!L0639_ps_TextString->isVisible()); + } else { + L0639_ps_TextString->setVisible(event->_C.A._effect == k0_SensorEffSet); + } + } else { + if (L0635_i_ThingType == k3_SensorThingType) { + L0638_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0634_T_Thing); + L0640_ui_SensorType = L0638_ps_Sensor->getType(); + L0637_ui_SensorData = L0638_ps_Sensor->getData(); + if (L0640_ui_SensorType == k6_SensorWallCountdown) { + if (L0637_ui_SensorData > 0) { + if (event->_C.A._effect == k0_SensorEffSet) { + if (L0637_ui_SensorData < 511) { + L0637_ui_SensorData++; + } + } else { + L0637_ui_SensorData--; + } + L0638_ps_Sensor->setData(L0637_ui_SensorData); + if (L0638_ps_Sensor->getEffectA() == k3_SensorEffHold) { + AL0636_B_TriggerSetEffect = ((L0637_ui_SensorData == 0) != L0638_ps_Sensor->getRevertEffectA()); + _vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell); + } else { + if (L0637_ui_SensorData == 0) { + _vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell); + } + } + } + } else { + if (L0640_ui_SensorType == k5_SensorWallAndOrGate) { + AL0636_i_BitMask = 1 << (event->_C.A._cell); + if (event->_C.A._effect == k2_SensorEffToggle) { + if (getFlag(L0637_ui_SensorData, AL0636_i_BitMask)) { + clearFlag(L0637_ui_SensorData, AL0636_i_BitMask); + } else { + setFlag(L0637_ui_SensorData, AL0636_i_BitMask); + } + } else { + if (event->_C.A._effect) { + clearFlag(L0637_ui_SensorData, AL0636_i_BitMask); + } else { + setFlag(L0637_ui_SensorData, AL0636_i_BitMask); + } + } + L0638_ps_Sensor->setData(L0637_ui_SensorData); + AL0636_B_TriggerSetEffect = (Sensor::getDataMask1(L0637_ui_SensorData) == Sensor::getDataMask2(L0637_ui_SensorData)) != L0638_ps_Sensor->getRevertEffectA(); + if (L0638_ps_Sensor->getEffectA() == k3_SensorEffHold) { + _vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell); + } else { + if (AL0636_B_TriggerSetEffect) { + _vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell); + } + } + } else { + if ((((L0640_ui_SensorType >= k7_SensorWallSingleProjLauncherNewObj) && (L0640_ui_SensorType <= k10_SensorWallDoubleProjLauncherExplosion)) || (L0640_ui_SensorType == k14_SensorWallSingleProjLauncherSquareObj) || (L0640_ui_SensorType == k15_SensorWallDoubleProjLauncherSquareObj)) && (L0634_T_Thing.getCell() == event->_C.A._cell)) { + f247_triggerProjectileLauncher(L0638_ps_Sensor, event); + if (L0638_ps_Sensor->getOnlyOnce()) { + L0638_ps_Sensor->setTypeDisabled(); + } + } else { + if (L0640_ui_SensorType == k18_SensorWallEndGame) { + _vm->f22_delay(60 * L0638_ps_Sensor->getValue()); + _vm->_g524_restartGameAllowed = false; + _vm->_g302_gameWon = true; + warning(false, "MISSING CODE: F0444_STARTEND_Endgame"); + } + } + } + } + } + } + L0634_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0634_T_Thing); + } + _vm->_movsens->f271_processRotationEffect(); +} + +void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* event) { + Thing L0622_T_FirstProjectileAssociatedThing; + Thing L0623_T_SecondProjectileAssociatedThing; + uint16 L0624_ui_Cell; + int16 L0625_i_SensorType; + int16 L0626_i_MapX; + int16 L0627_i_MapY; + uint16 L0628_ui_ProjectileCell; + int16 L0629_i_SensorData; + int16 L0630_i_KineticEnergy; + int16 L0631_i_StepEnergy; + bool L0632_B_LaunchSingleProjectile; + uint16 L0633_ui_ThingCell; + + + L0626_i_MapX = event->_B._location._mapX; + L0627_i_MapY = event->_B._location._mapY; + L0624_ui_Cell = event->_C.A._cell; + L0628_ui_ProjectileCell = returnOppositeDir((direction)L0624_ui_Cell); + L0625_i_SensorType = sensor->getType(); + L0629_i_SensorData = sensor->getData(); + L0630_i_KineticEnergy = sensor->M47_kineticEnergy(); + L0631_i_StepEnergy = sensor->M48_stepEnergy(); + L0632_B_LaunchSingleProjectile = (L0625_i_SensorType == k7_SensorWallSingleProjLauncherNewObj) || + (L0625_i_SensorType == k8_SensorWallSingleProjLauncherExplosion) || + (L0625_i_SensorType == k14_SensorWallSingleProjLauncherSquareObj); + if ((L0625_i_SensorType == k8_SensorWallSingleProjLauncherExplosion) || (L0625_i_SensorType == k10_SensorWallDoubleProjLauncherExplosion)) { + L0622_T_FirstProjectileAssociatedThing = L0623_T_SecondProjectileAssociatedThing = Thing(L0629_i_SensorData + Thing::_firstExplosion.toUint16()); + } else { + if ((L0625_i_SensorType == k14_SensorWallSingleProjLauncherSquareObj) || (L0625_i_SensorType == k15_SensorWallDoubleProjLauncherSquareObj)) { + L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->f161_getSquareFirstThing(L0626_i_MapX, L0627_i_MapY); + while (L0622_T_FirstProjectileAssociatedThing != Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList. If there are no more objects on the square then this loop may return an undefined value, this can crash the game. In the original DM and CSB dungeons, the number of times that these sensors are triggered is always controlled to be equal to the number of available objects (with a countdown sensor or a number of once only sensors) */ + L0633_ui_ThingCell = L0622_T_FirstProjectileAssociatedThing.getCell(); + if ((L0622_T_FirstProjectileAssociatedThing.getType() > k3_SensorThingType) && ((L0633_ui_ThingCell == L0624_ui_Cell) || (L0633_ui_ThingCell == returnNextVal(L0624_ui_Cell)))) + break; + L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->f159_getNextThing(L0622_T_FirstProjectileAssociatedThing); + } + if (L0622_T_FirstProjectileAssociatedThing == Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList */ + return; + } + _vm->_dungeonMan->f164_unlinkThingFromList(L0622_T_FirstProjectileAssociatedThing, Thing(0), L0626_i_MapX, L0627_i_MapY); /* The object is removed without triggering any sensor effects */ + if (!L0632_B_LaunchSingleProjectile) { + L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->f161_getSquareFirstThing(L0626_i_MapX, L0627_i_MapY); + while (L0623_T_SecondProjectileAssociatedThing != Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList. If there are no more objects on the square then this loop may return an undefined value, this can crash the game */ + L0633_ui_ThingCell = L0623_T_SecondProjectileAssociatedThing.getCell(); + if ((L0623_T_SecondProjectileAssociatedThing.getType() > k3_SensorThingType) && ((L0633_ui_ThingCell == L0624_ui_Cell) || (L0633_ui_ThingCell == returnNextVal(L0624_ui_Cell)))) + break; + L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->f159_getNextThing(L0623_T_SecondProjectileAssociatedThing); + } + if (L0623_T_SecondProjectileAssociatedThing == Thing::_none) { /* BUG0_19 The game crashes when an object launcher sensor is triggered. Thing::_none should be Thing::_endOfList */ + L0632_B_LaunchSingleProjectile = true; + } else { + _vm->_dungeonMan->f164_unlinkThingFromList(L0623_T_SecondProjectileAssociatedThing, Thing(0), L0626_i_MapX, L0627_i_MapY); /* The object is removed without triggering any sensor effects */ + } + } + } else { + if ((L0622_T_FirstProjectileAssociatedThing = _vm->_dungeonMan->f167_getObjForProjectileLaucherOrObjGen(L0629_i_SensorData)) == Thing::_none) { + return; + } + if (!L0632_B_LaunchSingleProjectile && ((L0623_T_SecondProjectileAssociatedThing = _vm->_dungeonMan->f167_getObjForProjectileLaucherOrObjGen(L0629_i_SensorData)) == Thing::_none)) { + L0632_B_LaunchSingleProjectile = true; + } + } + } + if (L0632_B_LaunchSingleProjectile) { + L0628_ui_ProjectileCell = M21_normalizeModulo4(L0628_ui_ProjectileCell + _vm->getRandomNumber(2)); + } + L0626_i_MapX += _vm->_dirIntoStepCountEast[L0624_ui_Cell], L0627_i_MapY += _vm->_dirIntoStepCountNorth[L0624_ui_Cell]; /* BUG0_20 The game crashes if the launcher sensor is on a map boundary and shoots in a direction outside the map */ + _vm->_projexpl->_g365_createLanucherProjectile = true; + _vm->_projexpl->f212_projectileCreate(L0622_T_FirstProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, L0628_ui_ProjectileCell, (direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy); + if (!L0632_B_LaunchSingleProjectile) { + _vm->_projexpl->f212_projectileCreate(L0623_T_SecondProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, returnNextVal(L0628_ui_ProjectileCell), (direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy); + } + _vm->_projexpl->_g365_createLanucherProjectile = false; +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index a0d2877704..a11b26c297 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -31,8 +31,9 @@ #include "dm.h" namespace DM { + class Sensor; -/* Event types */ + /* Event types */ enum TimelineEventType { /* Used when a creature in a group was damaged or killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by = 3, Fluxcages */ kM3_TMEventTypeCreateReactionEvent29DangerOnSquare = -3, // @ CM3_EVENT_CREATE_REACTION_EVENT_29_DANGER_ON_SQUARE @@ -169,7 +170,8 @@ public: void f251_timelineProcessEvent9_squarePit(TimelineEvent *event); // @ F0251_TIMELINE_ProcessEvent9_Square_Pit void f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY); // @ F0249_TIMELINE_MoveTeleporterOrPitSquareThings void f250_timelineProcessEvent8_squareTeleporter(TimelineEvent *event); // @ F0250_TIMELINE_ProcessEvent8_Square_Teleporter - + void f248_timelineProcessEvent6_squareWall(TimelineEvent *event); // @ F0248_TIMELINE_ProcessEvent6_Square_Wall + void f247_triggerProjectileLauncher(Sensor *sensor, TimelineEvent *event); // @ F0247_TIMELINE_TriggerProjectileLauncher }; -- cgit v1.2.3 From 8ae94ec075278b2f7b77b0232400fb9a9a579581 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jul 2016 23:20:21 +0200 Subject: DM: Refactor f111 and f112 --- engines/dm/gfx.cpp | 57 +++++++++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 853571873a..f05a8ca7bb 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1376,33 +1376,30 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIndex) { static byte g200_palChangesDoorOrn_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 20, 0, 130}; // @ G0200_auc_Graphic558_PaletteChanges_DoorOrnament_D3 static byte g201PalChangesDoorOrn_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 90, 100, 110, 120, 130, 140, 150}; // @ G0201_auc_Graphic558_PaletteChanges_DoorOrnament_D2 -#define AP0120_i_Height doorOrnOrdinal -#define AP0121_i_ByteWidth viewDoorOrnIndex - int16 L0104_i_NativeBitmapIndex; - int16 coordSetGreenToad; - uint16* coordSetOrangeElk; - byte* L0107_puc_Multiple; -#define AL0107_puc_Bitmap L0107_puc_Multiple - byte* L0108_puc_Bitmap_Native; - - - if (doorOrnOrdinal) { - doorOrnOrdinal--; - L0104_i_NativeBitmapIndex = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex]; - coordSetOrangeElk = &g207_doorOrnCoordSets[coordSetGreenToad = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]][viewDoorOrnIndex][0]; - if (viewDoorOrnIndex == k2_ViewDoorOrnament_D1LCR) { + + int16 AP0120_i_Height = doorOrnOrdinal; + int16 AP0121_i_ByteWidth = viewDoorOrnIndex; + + if (AP0120_i_Height) { + AP0120_i_Height--; + int16 L0104_i_NativeBitmapIndex = _g103_currMapDoorOrnInfo[AP0120_i_Height][k0_NativeBitmapIndex]; + int16 coordSetGreenToad = _g103_currMapDoorOrnInfo[AP0120_i_Height][k1_CoordinateSet]; + uint16 *coordSetOrangeElk = &g207_doorOrnCoordSets[coordSetGreenToad][AP0121_i_ByteWidth][0]; + byte *AL0107_puc_Bitmap; + if (AP0121_i_ByteWidth == k2_ViewDoorOrnament_D1LCR) { AL0107_puc_Bitmap = f489_getNativeBitmapOrGraphic(L0104_i_NativeBitmapIndex); AP0121_i_ByteWidth = k48_byteWidth; AP0120_i_Height = 88; } else { - if (!f491_isDerivedBitmapInCache(doorOrnOrdinal = k68_DerivedBitmapFirstDoorOrnament_D3 + (doorOrnOrdinal * 2) + viewDoorOrnIndex)) { + AP0120_i_Height = k68_DerivedBitmapFirstDoorOrnament_D3 + (AP0120_i_Height * 2) + AP0121_i_ByteWidth; + if (!f491_isDerivedBitmapInCache(AP0120_i_Height)) { uint16 *coordSetRedEagle = &g207_doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR][0]; - L0108_puc_Bitmap_Native = f489_getNativeBitmapOrGraphic(L0104_i_NativeBitmapIndex); - f129_blitToBitmapShrinkWithPalChange(L0108_puc_Bitmap_Native, f492_getDerivedBitmap(doorOrnOrdinal), coordSetRedEagle[4] << 1, coordSetRedEagle[5], coordSetOrangeElk[1] - coordSetOrangeElk[0] + 1, coordSetOrangeElk[5], (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2); - f493_addDerivedBitmap(doorOrnOrdinal); + byte *L0108_puc_Bitmap_Native = f489_getNativeBitmapOrGraphic(L0104_i_NativeBitmapIndex); + f129_blitToBitmapShrinkWithPalChange(L0108_puc_Bitmap_Native, f492_getDerivedBitmap(AP0120_i_Height), coordSetRedEagle[4] << 1, coordSetRedEagle[5], coordSetOrangeElk[1] - coordSetOrangeElk[0] + 1, coordSetOrangeElk[5], (AP0121_i_ByteWidth == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2); + f493_addDerivedBitmap(AP0120_i_Height); } - AL0107_puc_Bitmap = f492_getDerivedBitmap(doorOrnOrdinal); - if (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) { + AL0107_puc_Bitmap = f492_getDerivedBitmap(AP0120_i_Height); + if (AP0121_i_ByteWidth == k0_ViewDoorOrnament_D3LCR) { AP0121_i_ByteWidth = k24_byteWidth; AP0120_i_Height = 41; } else { @@ -1410,22 +1407,20 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn AP0120_i_Height = 61; } } - { - Box box(coordSetOrangeElk[0], coordSetOrangeElk[1], coordSetOrangeElk[2], coordSetOrangeElk[3]); - f132_blitToBitmap(AL0107_puc_Bitmap, _g74_tmpBitmap, box, 0, 0, coordSetOrangeElk[4], AP0121_i_ByteWidth, k9_ColorGold, coordSetOrangeElk[5], AP0120_i_Height); - } + + Box box(coordSetOrangeElk[0], coordSetOrangeElk[1], coordSetOrangeElk[2], coordSetOrangeElk[3]); + f132_blitToBitmap(AL0107_puc_Bitmap, _g74_tmpBitmap, box, 0, 0, coordSetOrangeElk[4], AP0121_i_ByteWidth, k9_ColorGold, coordSetOrangeElk[5], AP0120_i_Height); } } void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame* frame, int16 mapX, int16 mapY, bool flipHorizontal) { - int16 L0117_i_Multiple; -#define AL0117_i_MapIndex L0117_i_Multiple -#define AL0117_i_Square L0117_i_Multiple + int16 AL0117_i_MapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g272_currMapIndex, -1, &mapX, &mapY); + if (AL0117_i_MapIndex < 0) + return; - if (((AL0117_i_MapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g272_currMapIndex, -1, &mapX, &mapY)) >= 0) && - (Square(AL0117_i_Square = _vm->_dungeonMan->_g279_dungeonMapData[AL0117_i_MapIndex][mapX][mapY]).getType() == k2_ElementTypePit) && - getFlag(AL0117_i_Square, k0x0008_PitOpen)) { + int16 AL0117_i_Square = _vm->_dungeonMan->_g279_dungeonMapData[AL0117_i_MapIndex][mapX][mapY]; + if ((Square(AL0117_i_Square).getType() == k2_ElementTypePit) && getFlag(AL0117_i_Square, k0x0008_PitOpen)) { if (flipHorizontal) { _vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(nativeBitmapIndex, *frame); } else { -- cgit v1.2.3 From e8342f2d2abe58f03788c6db3302f6b29ac1bfe4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Jul 2016 23:46:52 +0200 Subject: DM: Fix a bug in drawPanelObject, fix some casts formatting --- engines/dm/inventory.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 3d61270dc8..a0c6e57e9c 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -438,7 +438,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) { if (thingType == k7_ScrollThingType) { f341_drawPanelScroll((Scroll*)rawThingPtr); } else if (thingType == k9_ContainerThingType) { - f333_openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye); + f333_openAndDrawChest(thingToDraw, (Container *)rawThingPtr, pressingEye); } else { IconIndice iconIndex = objMan.f33_getIconIndex(thingToDraw); dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k20_PanelEmptyIndice), dispMan._g296_bitmapViewport, @@ -449,7 +449,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) { char *descString = nullptr; char str[40]; if (iconIndex == k147_IconIndiceJunkChampionBones) { - strcpy(str, champMan._gK71_champions[((Junk*)rawThingPtr)->getChargeCount()]._name); // TODO: localization + strcpy(str, champMan._gK71_champions[((Junk *)rawThingPtr)->getChargeCount()]._name); // TODO: localization strcat(str, " "); // TODO: localization strcat(str, objMan._g352_objectNames[iconIndex]); // TODO: localization @@ -457,7 +457,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) { } else if ((thingType == k8_PotionThingType) && (iconIndex != k163_IconIndicePotionWaterFlask) && (champMan.f303_getSkillLevel((ChampionIndex)_vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) { - str[0] = '_' + ((Potion*)rawThingPtr)->getPower() / 40; + str[0] = '_' + ((Potion *)rawThingPtr)->getPower() / 40; str[1] = ' '; str[2] = '\0'; strcat(str, objMan._g352_objectNames[iconIndex]); @@ -478,7 +478,7 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) { switch (thingType) { case k5_WeaponThingType: { potentialAttribMask = k0x0008_DescriptionMaskCursed | k0x0002_DescriptionMaskPoisoned | k0x0004_DescriptionMaskBroken; - Weapon *weapon = (Weapon*)rawThingPtr; + Weapon *weapon = (Weapon *)rawThingPtr; actualAttribMask = (weapon->getCursed() << 3) | (weapon->getPoisoned() << 1) | (weapon->getBroken() << 2); if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit) @@ -489,18 +489,18 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) { } case k6_ArmourThingType: { potentialAttribMask = k0x0008_DescriptionMaskCursed | k0x0004_DescriptionMaskBroken; - Armour *armour = (Armour*)rawThingPtr; + Armour *armour = (Armour *)rawThingPtr; actualAttribMask = (armour->getCursed() << 3) | (armour->getBroken() << 2); break; } case k8_PotionThingType: { - actualAttribMask = k0x0001_DescriptionMaskConsumable; - Potion *potion = (Potion*)rawThingPtr; + potentialAttribMask = k0x0001_DescriptionMaskConsumable; + Potion *potion = (Potion *)rawThingPtr; actualAttribMask = g237_ObjectInfo[k2_ObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots(); break; } case k10_JunkThingType: { - Junk *junk = (Junk*)rawThingPtr; + Junk *junk = (Junk *)rawThingPtr; if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) { potentialAttribMask = 0; switch (junk->getChargeCount()) { -- cgit v1.2.3 From 9aa6c28fabd95d3aeaf5840386fb5d3327247d62 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 12 Jul 2016 07:56:59 +0200 Subject: DM: Add f245_timlineProcessEvent5_squareCorridor --- engines/dm/dungeonman.h | 4 ++- engines/dm/group.cpp | 43 ++++++++++++++++++++++++++++ engines/dm/group.h | 2 ++ engines/dm/timeline.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++++++- engines/dm/timeline.h | 1 + 5 files changed, 124 insertions(+), 2 deletions(-) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index e0a1d8ff50..049c8eae6f 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -336,7 +336,9 @@ public: direction getTargetCell() { return (direction)((_action >> 4) & 3); } uint16 M47_kineticEnergy() { return (_action & 0xFF); }// @ M47_KINETIC_ENERGY uint16 M48_stepEnergy() { return (_action >> 8) & 0xFF; }// @ M48_STEP_ENERGY - uint16 M49_localEffect() { return (_action >> 4); } + uint16 M49_localEffect() { return _action; } // @ M49_LOCAL_EFFECT + uint16 M45_healthMultiplier() { return (_action & 0xF); } // @ M45_HEALTH_MULTIPLIER + uint16 M46_ticks() { return (_action >> 4) & 0xFFF; } // @ M46_TICKS // some macros missing, i got bored diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index a39065bbba..73c21198ac 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -1766,4 +1766,47 @@ void GroupMan::f195_addAllActiveGroups() { } } } + +Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY) { + Thing L0349_T_GroupThing; + uint16 L0350_ui_BaseHealth; + uint16 L0351_ui_Cell = 0; + uint16 L0352_ui_GroupCells = 0; + Group* L0353_ps_Group; + CreatureInfo* L0354_ps_CreatureInfo; + bool L0355_B_SeveralCreaturesInGroup; + + + if (((_g377_currActiveGroupCount >= (_vm->_groupMan->_g376_maxActiveGroupCount - 5)) && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) || ((L0349_T_GroupThing = _vm->_dungeonMan->f166_getUnusedThing(k4_GroupThingType)) == Thing::_none)) { + return Thing::_none; + } + L0353_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0349_T_GroupThing); + L0353_ps_Group->_slot = Thing::_endOfList; + L0353_ps_Group->setDoNotDiscard(false); + L0353_ps_Group->setDir(dir); + L0353_ps_Group->setCount(creatureCount); + if (L0355_B_SeveralCreaturesInGroup = creatureCount) { + L0351_ui_Cell = _vm->getRandomNumber(4); + } else { + L0352_ui_GroupCells = k255_CreatureTypeSingleCenteredCreature; + } + L0354_ps_CreatureInfo = &g243_CreatureInfo[L0353_ps_Group->_type = creatureType]; + L0350_ui_BaseHealth = L0354_ps_CreatureInfo->_baseHealth; + do { + L0353_ps_Group->_health[creatureCount] = (L0350_ui_BaseHealth * healthMultiplier) + _vm->getRandomNumber((L0350_ui_BaseHealth >> 2) + 1); + if (L0355_B_SeveralCreaturesInGroup) { + L0352_ui_GroupCells = f178_getGroupValueUpdatedWithCreatureValue(L0352_ui_GroupCells, creatureCount, L0351_ui_Cell++); + if (getFlag(L0354_ps_CreatureInfo->_attributes, k0x0003_MaskCreatureInfo_size) == k1_MaskCreatureSizeHalf) { + L0351_ui_Cell++; + } + L0351_ui_Cell &= 0x0003; + } + } while (creatureCount--); + L0353_ps_Group->_cells = L0352_ui_GroupCells; + if (_vm->_movsens->f267_getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */ + return Thing::_none; + } + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + return L0349_T_GroupThing; +} } diff --git a/engines/dm/group.h b/engines/dm/group.h index ca7cb527ed..6153d514d2 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -133,6 +133,7 @@ public: direction getDir() { return (direction)((_flags >> 8) & 0x3); } void setDir(uint16 val) { _flags = (_flags & ~(0x3 << 8)) | ((val & 0x3) << 8); } uint16 getDoNotDiscard() { return (_flags >> 10) & 0x1; } + void setDoNotDiscard(bool val) { _flags = (_flags & ~(1 << 10)) | ((val & 1) << 10); } }; // @ GROUP #define k0_behavior_WANDER 0 // @ C0_BEHAVIOR_WANDER @@ -233,6 +234,7 @@ public: void f184_removeActiveGroup(uint16 activeGroupIndex); // @ F0184_GROUP_RemoveActiveGroup void f194_removeAllActiveGroups(); // @ F0194_GROUP_RemoveAllActiveGroups void f195_addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups + Thing f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 524b5a5050..17376485c5 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -32,6 +32,7 @@ #include "group.h" #include "projexpl.h" #include "movesens.h" +#include "text.h" namespace DM { @@ -259,7 +260,7 @@ void Timeline::f261_processTimeline() { f248_timelineProcessEvent6_squareWall(L0681_ps_Event); break; case k5_TMEventTypeCorridor: - //F0245_TIMELINE_ProcessEvent5_Square_Corridor(L0681_ps_Event); + f245_timlineProcessEvent5_squareCorridor(L0681_ps_Event); break; case k60_TMEventTypeMoveGroupSilent: case k61_TMEventTypeMoveGroupAudible: @@ -741,4 +742,77 @@ void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* eve } _vm->_projexpl->_g365_createLanucherProjectile = false; } + +void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) { +#define k0x0008_randomizeGeneratedCreatureCount 0x0008 // @ MASK0x0008_RANDOMIZE_GENERATED_CREATURE_COUNT +#define k0x0007_generatedCreatureCount 0x0007 // @ MASK0x0007_GENERATED_CREATURE_COUNT + + int16 L0610_i_ThingType; + bool L0611_B_TextCurrentlyVisible; + int16 L0612_i_CreatureCount; + Thing L0613_T_Thing; + Sensor* L0614_ps_Sensor; + TextString* L0615_ps_TextString; + uint16 L0616_ui_MapX; + uint16 L0617_ui_MapY; + uint16 L0618_ui_Multiple; +#define AL0618_ui_HealthMultiplier L0618_ui_Multiple +#define AL0618_ui_Ticks L0618_ui_Multiple + TimelineEvent L0619_s_Event; + + + L0613_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0616_ui_MapX = event->_B._location._mapX, L0617_ui_MapY = event->_B._location._mapY); + while (L0613_T_Thing != Thing::_endOfList) { + if ((L0610_i_ThingType = L0613_T_Thing.getType()) == k2_TextstringType) { + L0615_ps_TextString = (TextString*)_vm->_dungeonMan->f156_getThingData(L0613_T_Thing); + L0611_B_TextCurrentlyVisible = L0615_ps_TextString->isVisible(); + if (event->_C.A._effect == k2_SensorEffToggle) { + L0615_ps_TextString->setVisible(!L0611_B_TextCurrentlyVisible); + } else { + L0615_ps_TextString->setVisible((event->_C.A._effect == k0_SensorEffSet)); + } + if (!L0611_B_TextCurrentlyVisible && L0615_ps_TextString->isVisible() && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0616_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0617_ui_MapY == _vm->_dungeonMan->_g307_partyMapY)) { + _vm->_dungeonMan->f168_decodeText(_vm->_g353_stringBuildBuffer, L0613_T_Thing, k1_TextTypeMessage); + _vm->_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, _vm->_g353_stringBuildBuffer); + } + } else { + if (L0610_i_ThingType == k3_SensorThingType) { + L0614_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0613_T_Thing); + if (L0614_ps_Sensor->getType() == k6_SensorFloorGroupGenerator) { + L0612_i_CreatureCount = L0614_ps_Sensor->getValue(); + if (getFlag(L0612_i_CreatureCount, k0x0008_randomizeGeneratedCreatureCount)) { + L0612_i_CreatureCount = _vm->getRandomNumber(getFlag(L0612_i_CreatureCount, k0x0007_generatedCreatureCount)); + } else { + L0612_i_CreatureCount--; + } + if ((AL0618_ui_HealthMultiplier = L0614_ps_Sensor->M45_healthMultiplier()) == 0) { + AL0618_ui_HealthMultiplier = _vm->_dungeonMan->_g269_currMap->_difficulty; + } + _vm->_groupMan->f185_groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY); + if (L0614_ps_Sensor->getAudibleA()) { + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + if (L0614_ps_Sensor->getOnlyOnce()) { + L0614_ps_Sensor->setTypeDisabled(); + } else { + if ((AL0618_ui_Ticks = L0614_ps_Sensor->M46_ticks()) != 0) { + L0614_ps_Sensor->setTypeDisabled(); + if (AL0618_ui_Ticks > 127) { + AL0618_ui_Ticks = (AL0618_ui_Ticks - 126) << 6; + } + L0619_s_Event._type = k65_TMEventTypeEnableGroupGenerator; + M33_setMapAndTime(L0619_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + AL0618_ui_Ticks); + L0619_s_Event._priority = 0; + L0619_s_Event._B._location._mapX = L0616_ui_MapX; + L0619_s_Event._B._location._mapY = L0617_ui_MapY; + L0619_s_Event._B._location._mapY = L0617_ui_MapY; + _vm->_timeline->f238_addEventGetEventIndex(&L0619_s_Event); + } + } + } + } + } + L0613_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0613_T_Thing); + } +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index a11b26c297..3e5cbcdf65 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -172,6 +172,7 @@ public: void f250_timelineProcessEvent8_squareTeleporter(TimelineEvent *event); // @ F0250_TIMELINE_ProcessEvent8_Square_Teleporter void f248_timelineProcessEvent6_squareWall(TimelineEvent *event); // @ F0248_TIMELINE_ProcessEvent6_Square_Wall void f247_triggerProjectileLauncher(Sensor *sensor, TimelineEvent *event); // @ F0247_TIMELINE_TriggerProjectileLauncher + void f245_timlineProcessEvent5_squareCorridor(TimelineEvent *event); // @ F0245_TIMELINE_ProcessEvent5_Square_Corridor }; -- cgit v1.2.3 From 278e0b6647bd9cc46818771da86a2fadb30cd123 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 12 Jul 2016 08:04:06 +0200 Subject: DM: Add f252_timelineProcessEvents60to61_moveGroup --- engines/dm/group.cpp | 8 ++++++++ engines/dm/group.h | 6 +----- engines/dm/timeline.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++++- engines/dm/timeline.h | 1 + 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 73c21198ac..49ac924333 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -1809,4 +1809,12 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); return L0349_T_GroupThing; } + +bool GroupMan::f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY) { + int16 L0544_i_SquareType; + + return (((L0544_i_SquareType = Square(_vm->_dungeonMan->f151_getSquare(mapX, mapY)).getType()) == k1_CorridorElemType) + || (L0544_i_SquareType == k5_ElementTypeTeleporter) || (L0544_i_SquareType == k2_ElementTypePit) || (L0544_i_SquareType == k4_DoorElemType)); +} + } diff --git a/engines/dm/group.h b/engines/dm/group.h index 6153d514d2..242e52768d 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -235,11 +235,7 @@ public: void f194_removeAllActiveGroups(); // @ F0194_GROUP_RemoveAllActiveGroups void f195_addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups Thing f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated - - - - - + bool f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY); // @ F0223_GROUP_IsSquareACorridorTeleporterPitOrDoor }; diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 17376485c5..2bb96e0c42 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -264,7 +264,7 @@ void Timeline::f261_processTimeline() { break; case k60_TMEventTypeMoveGroupSilent: case k61_TMEventTypeMoveGroupAudible: - //F0252_TIMELINE_ProcessEvents60to61_MoveGroup(L0681_ps_Event); + f252_timelineProcessEvents60to61_moveGroup(L0681_ps_Event); break; case k65_TMEventTypeEnableGroupGenerator: //F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator(L0681_ps_Event); @@ -815,4 +815,48 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) { L0613_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0613_T_Thing); } } + +void Timeline::f252_timelineProcessEvents60to61_moveGroup(TimelineEvent* event) { + uint16 L0656_ui_MapX; + uint16 L0657_ui_MapY; + Group* L0658_ps_Group; + bool L0659_B_RandomDirectionMoveRetried; + + + L0659_B_RandomDirectionMoveRetried = false; + L0656_ui_MapX = event->_B._location._mapX; + L0657_ui_MapY = event->_B._location._mapY; + L0657_ui_MapY = event->_B._location._mapY; +T0252001: + if (((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) || (L0656_ui_MapX != _vm->_dungeonMan->_g306_partyMapX) || (L0657_ui_MapY != _vm->_dungeonMan->_g307_partyMapY)) && (_vm->_groupMan->f175_groupGetThing(L0656_ui_MapX, L0657_ui_MapY) == Thing::_endOfList)) { /* BUG0_24 Lord Chaos may teleport into one of the Black Flames and become invisible until the Black Flame is killed. In this case, _vm->_groupMan->f175_groupGetThing returns the Black Flame thing and the Lord Chaos thing is not moved into the dungeon until the Black Flame is killed */ + if (event->_type == k61_TMEventTypeMoveGroupAudible) { + warning(false, "F0064_SOUND_RequestPlay_CPSD"); + } + _vm->_movsens->f267_getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, L0656_ui_MapX, L0657_ui_MapY); + } else { + if (!L0659_B_RandomDirectionMoveRetried) { + L0659_B_RandomDirectionMoveRetried = true; + L0658_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(Thing(event->_C._slot)); + if ((L0658_ps_Group->_type == k23_CreatureTypeLordChaos) && !_vm->getRandomNumber(4)) { + switch (_vm->getRandomNumber(4)) { + case 0: + L0656_ui_MapX--; + break; + case 1: + L0656_ui_MapX++; + break; + case 2: + L0657_ui_MapY--; + break; + case 3: + L0657_ui_MapY++; + } + if (_vm->_groupMan->f223_isSquareACorridorTeleporterPitOrDoor(L0656_ui_MapX, L0657_ui_MapY)) + goto T0252001; + } + } + event->_mapTime += 5; + _vm->_timeline->f238_addEventGetEventIndex(event); + } +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index 3e5cbcdf65..c56db55dfd 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -173,6 +173,7 @@ public: void f248_timelineProcessEvent6_squareWall(TimelineEvent *event); // @ F0248_TIMELINE_ProcessEvent6_Square_Wall void f247_triggerProjectileLauncher(Sensor *sensor, TimelineEvent *event); // @ F0247_TIMELINE_TriggerProjectileLauncher void f245_timlineProcessEvent5_squareCorridor(TimelineEvent *event); // @ F0245_TIMELINE_ProcessEvent5_Square_Corridor + void f252_timelineProcessEvents60to61_moveGroup(TimelineEvent *event); // @ F0252_TIMELINE_ProcessEvents60to61_MoveGroup }; -- cgit v1.2.3 From 3b917d35c4dfc962aeb4786bd84fc54bdee3f24e Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 12 Jul 2016 08:08:57 +0200 Subject: DM: Add f246_timelineProcesEvent65_enableGroupGenerator --- engines/dm/dungeonman.h | 2 +- engines/dm/timeline.cpp | 20 +++++++++++++++++++- engines/dm/timeline.h | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 049c8eae6f..2a6a8b72f8 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -340,8 +340,8 @@ public: uint16 M45_healthMultiplier() { return (_action & 0xF); } // @ M45_HEALTH_MULTIPLIER uint16 M46_ticks() { return (_action >> 4) & 0xFFF; } // @ M46_TICKS + void setDatAndTypeWithOr(uint16 val) { _datAndType |= val; } - // some macros missing, i got bored }; // @ SENSOR diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 2bb96e0c42..a34fc4921d 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -267,7 +267,7 @@ void Timeline::f261_processTimeline() { f252_timelineProcessEvents60to61_moveGroup(L0681_ps_Event); break; case k65_TMEventTypeEnableGroupGenerator: - //F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator(L0681_ps_Event); + f246_timelineProcesEvent65_enableGroupGenerator(L0681_ps_Event); break; case k20_TMEventTypePlaySound: warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); @@ -859,4 +859,22 @@ T0252001: _vm->_timeline->f238_addEventGetEventIndex(event); } } + +void Timeline::f246_timelineProcesEvent65_enableGroupGenerator(TimelineEvent* event) { + Thing L0620_T_Thing; + Sensor* L0621_ps_Sensor; + + L0620_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(event->_B._location._mapX, event->_B._location._mapY); + L0620_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(event->_B._location._mapX, event->_B._location._mapY); + while (L0620_T_Thing != Thing::_none) { + if ((L0620_T_Thing.getType()) == k3_SensorThingType) { + L0621_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0620_T_Thing); + if (L0621_ps_Sensor->getType() == k0_SensorDisabled) { + L0621_ps_Sensor->setDatAndTypeWithOr(k6_SensorFloorGroupGenerator); + return; + } + } + L0620_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0620_T_Thing); + } +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index c56db55dfd..02e13a5e95 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -174,6 +174,7 @@ public: void f247_triggerProjectileLauncher(Sensor *sensor, TimelineEvent *event); // @ F0247_TIMELINE_TriggerProjectileLauncher void f245_timlineProcessEvent5_squareCorridor(TimelineEvent *event); // @ F0245_TIMELINE_ProcessEvent5_Square_Corridor void f252_timelineProcessEvents60to61_moveGroup(TimelineEvent *event); // @ F0252_TIMELINE_ProcessEvents60to61_MoveGroup + void f246_timelineProcesEvent65_enableGroupGenerator(TimelineEvent *event); // @ F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator }; -- cgit v1.2.3 From 4818eaaf55bb40164fd3d0ca00dbbaa09a7e789d Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 12 Jul 2016 08:18:25 +0200 Subject: DM: Add f253_timelineProcessEvent11Part1_enableChampionAction --- engines/dm/champion.cpp | 26 +++++++++++++++++ engines/dm/champion.h | 3 +- engines/dm/timeline.cpp | 77 ++++++++++++++++++++++++++++++++++++++++++++++++- engines/dm/timeline.h | 3 ++ 4 files changed, 107 insertions(+), 2 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index a9684111b0..a84ccb811d 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1163,6 +1163,32 @@ int16 ChampionMan::f310_getMovementTicks(Champion* champ) { return L0933_i_Ticks; } +bool ChampionMan::f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex, uint16 ammunitionSlotIndex) { + Champion* L0874_ps_Champion; + WeaponInfo* L0875_ps_WeaponInfo; + Thing L0878_T_Thing; + int16 L0879_i_WeaponClass; + + L0874_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + L0878_T_Thing = L0874_ps_Champion->_slots[weaponSlotIndex]; + if (L0878_T_Thing.getType() != k5_WeaponThingType) { + return false; + } + L0875_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0878_T_Thing); + if ((L0875_ps_WeaponInfo->_class >= k16_WeaponClassFirstBow) && (L0875_ps_WeaponInfo->_class <= k31_WeaponClassLastBow)) { + L0879_i_WeaponClass = k10_WeaponClassBowAmmunition; + } else { + if ((L0875_ps_WeaponInfo->_class >= k32_WeaponClassFirstSling) && (L0875_ps_WeaponInfo->_class <= k47_WeaponClassLastSling)) { + L0879_i_WeaponClass = k11_WeaponClassSlingAmmunition; + } else { + return false; + } + } + L0878_T_Thing = L0874_ps_Champion->_slots[ammunitionSlotIndex]; + L0875_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0878_T_Thing); + return ((L0878_T_Thing.getType() == k5_WeaponThingType) && (L0875_ps_WeaponInfo->_class == L0879_i_WeaponClass)); +} + ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) { for (uint16 i = 0; i < _g305_partyChampionCount; ++i) { if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 16c53c8c58..17686f91f9 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -521,7 +521,8 @@ public: void f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount); // @ F0317_CHAMPION_AddScentStrength void f297_putObjectInLeaderHand(Thing thing, bool setMousePointer); // @ F0297_CHAMPION_PutObjectInLeaderHand int16 f310_getMovementTicks(Champion *champ); // @ F0310_CHAMPION_GetMovementTicks - + bool f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex, + uint16 ammunitionSlotIndex); // @ F0294_CHAMPION_IsAmmunitionCompatibleWithWeapon diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index a34fc4921d..85aadcbb67 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -37,6 +37,52 @@ namespace DM { +signed char g495_actionDefense[44] = { // @ G0495_ac_Graphic560_ActionDefense + 0, /* N */ + 36, /* BLOCK */ + 0, /* CHOP */ + 0, /* X */ + -4, /* BLOW HORN */ + -10, /* FLIP */ + -10, /* PUNCH */ + -5, /* KICK */ + 4, /* WAR CRY */ + -20, /* STAB */ + -15, /* CLIMB DOWN */ + -10, /* FREEZE LIFE */ + 16, /* HIT */ + 5, /* SWING */ + -15, /* STAB */ + -17, /* THRUST */ + -5, /* JAB */ + 29, /* PARRY */ + 10, /* HACK */ + -10, /* BERZERK */ + -7, /* FIREBALL */ + -7, /* DISPELL */ + -7, /* CONFUSE */ + -7, /* LIGHTNING */ + -7, /* DISRUPT */ + -5, /* MELEE */ + -15, /* X */ + -9, /* INVOKE */ + 4, /* SLASH */ + 0, /* CLEAVE */ + 0, /* BASH */ + 5, /* STUN */ + -15, /* SHOOT */ + -7, /* SPELLSHIELD */ + -7, /* FIRESHIELD */ + 8, /* FLUXCAGE */ + -20, /* HEAL */ + -5, /* CALM */ + 0, /* LIGHT */ + -15, /* WINDOW */ + -7, /* SPIT */ + -4, /* BRANDISH */ + 0, /* THROW */ + 8}; /* FUSE */ + Timeline::Timeline(DMEngine* vm) : _vm(vm) { _g369_eventMaxCount = 0; _g370_events = nullptr; @@ -280,7 +326,7 @@ void Timeline::f261_processTimeline() { } break; case k11_TMEventTypeEnableChampionAction: - //F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction(L0682_s_Event._priority); + f253_timelineProcessEvent11Part1_enableChampionAction(L0682_s_Event._priority); if (L0682_s_Event._B._slotOrdinal) { //F0259_TIMELINE_ProcessEvent11Part2_MoveWeaponFromQuiverToSlot(L0682_s_Event._priority, _vm->M1_ordinalToIndex(L0682_s_Event._B._slotOrdinal)); } @@ -877,4 +923,33 @@ void Timeline::f246_timelineProcesEvent65_enableGroupGenerator(TimelineEvent* ev L0620_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0620_T_Thing); } } + +void Timeline::f253_timelineProcessEvent11Part1_enableChampionAction(uint16 champIndex) { + int16 L0660_i_SlotIndex; + int16 L0661_i_QuiverSlotIndex; + Champion* L0662_ps_Champion; + + L0662_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + L0662_ps_Champion->_enableActionEventIndex = -1; + clearFlag(L0662_ps_Champion->_attributes, k0x0008_ChampionAttributeDisableAction); + if (L0662_ps_Champion->_actionIndex != k255_ChampionActionNone) { + L0662_ps_Champion->_actionDefense -= g495_actionDefense[L0662_ps_Champion->_actionDefense]; + } + if (L0662_ps_Champion->_currHealth) { + if ((L0662_ps_Champion->_actionIndex == k32_ChampionActionShoot) && (L0662_ps_Champion->_slots[k0_ChampionSlotReadyHand] == Thing::_none)) { + if (_vm->_championMan->f294_isAmmunitionCompatibleWithWeapon(champIndex, k1_ChampionSlotActionHand, L0660_i_SlotIndex = k12_ChampionSlotQuiverLine_1_1)) { +T0253002: + _vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, L0660_i_SlotIndex), k0_ChampionSlotReadyHand); + } else { + for (L0661_i_QuiverSlotIndex = 0; L0661_i_QuiverSlotIndex < 3; L0661_i_QuiverSlotIndex++) { + if (_vm->_championMan->f294_isAmmunitionCompatibleWithWeapon(champIndex, k1_ChampionSlotActionHand, L0660_i_SlotIndex = L0661_i_QuiverSlotIndex + k7_ChampionSlotQuiverLine_2_1)) + goto T0253002; + } + } + } + setFlag(L0662_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand); + _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); + } + L0662_ps_Champion->_actionIndex = k255_ChampionActionNone; +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index 02e13a5e95..f6f61ee808 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -94,6 +94,8 @@ k82_TMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP k83_TMEventTypeMagicMap_C83 = 83 // @ C83_EVENT_MAGIC_MAP }; +extern signed char g495_actionDefense[44]; + class TimelineEvent { public: int32 _mapTime; @@ -175,6 +177,7 @@ public: void f245_timlineProcessEvent5_squareCorridor(TimelineEvent *event); // @ F0245_TIMELINE_ProcessEvent5_Square_Corridor void f252_timelineProcessEvents60to61_moveGroup(TimelineEvent *event); // @ F0252_TIMELINE_ProcessEvents60to61_MoveGroup void f246_timelineProcesEvent65_enableGroupGenerator(TimelineEvent *event); // @ F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator + void f253_timelineProcessEvent11Part1_enableChampionAction(uint16 champIndex); // @ F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction }; -- cgit v1.2.3 From c62029211dbd377b240bce8687175a5ed40cd8da Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 12 Jul 2016 08:27:57 +0200 Subject: DM: Add f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot --- engines/dm/timeline.cpp | 28 +++++++++++++++++++++++++++- engines/dm/timeline.h | 5 +++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 85aadcbb67..f8725a2ded 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -328,7 +328,7 @@ void Timeline::f261_processTimeline() { case k11_TMEventTypeEnableChampionAction: f253_timelineProcessEvent11Part1_enableChampionAction(L0682_s_Event._priority); if (L0682_s_Event._B._slotOrdinal) { - //F0259_TIMELINE_ProcessEvent11Part2_MoveWeaponFromQuiverToSlot(L0682_s_Event._priority, _vm->M1_ordinalToIndex(L0682_s_Event._B._slotOrdinal)); + f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(L0682_s_Event._priority, _vm->M1_ordinalToIndex(L0682_s_Event._B._slotOrdinal)); } goto T0261048; case k12_TMEventTypeHideDamageReceived: @@ -952,4 +952,30 @@ T0253002: } L0662_ps_Champion->_actionIndex = k255_ChampionActionNone; } + +void Timeline::f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(uint16 champIndex, uint16 slotIndex) { + uint16 L0677_ui_SlotIndex; + Champion* L0678_ps_Champion; + + L0678_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + if (L0678_ps_Champion->_slots[slotIndex] != Thing::_none) { + return; + } + if (f258_timelineHasWeaponMovedSlot(champIndex, L0678_ps_Champion, k12_ChampionSlotQuiverLine_1_1, slotIndex)) { + return; + } + for (L0677_ui_SlotIndex = k7_ChampionSlotQuiverLine_2_1; L0677_ui_SlotIndex <= k9_ChampionSlotQuiverLine_2_2; L0677_ui_SlotIndex++) { + if (f258_timelineHasWeaponMovedSlot(champIndex, L0678_ps_Champion, L0677_ui_SlotIndex, slotIndex)) + break; + } +} + +bool Timeline::f258_timelineHasWeaponMovedSlot(int16 champIndex, Champion* champ, uint16 sourceSlotIndex, int16 destSlotIndex) { + if (Thing(champ->_slots[sourceSlotIndex]).getType() == k5_WeaponThingType) { + _vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, sourceSlotIndex), + (ChampionSlot)destSlotIndex); + return true; + } + return false; +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index f6f61ee808..021889dbfb 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -31,6 +31,7 @@ #include "dm.h" namespace DM { + class Champion; class Sensor; /* Event types */ @@ -178,6 +179,10 @@ public: void f252_timelineProcessEvents60to61_moveGroup(TimelineEvent *event); // @ F0252_TIMELINE_ProcessEvents60to61_MoveGroup void f246_timelineProcesEvent65_enableGroupGenerator(TimelineEvent *event); // @ F0246_TIMELINE_ProcessEvent65_EnableGroupGenerator void f253_timelineProcessEvent11Part1_enableChampionAction(uint16 champIndex); // @ F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction + void f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(uint16 champIndex, + uint16 slotIndex);// @ F0259_TIMELINE_ProcessEvent11Part2_MoveWeaponFromQuiverToSlot + bool f258_timelineHasWeaponMovedSlot(int16 champIndex, Champion *champ, + uint16 sourceSlotIndex, int16 destSlotIndex); // @ F0258_TIMELINE_HasWeaponMovedToSlot }; -- cgit v1.2.3 From 639fd36f38742669a03814e034bf4dce981d2fea Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 12 Jul 2016 08:31:10 +0200 Subject: DM: Add f254_timelineProcessEvent12_hideDamageReceived --- engines/dm/timeline.cpp | 24 ++++++++++++++++++++++-- engines/dm/timeline.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index f8725a2ded..0f36220406 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -33,6 +33,7 @@ #include "projexpl.h" #include "movesens.h" #include "text.h" +#include "eventman.h" namespace DM { @@ -332,7 +333,7 @@ void Timeline::f261_processTimeline() { } goto T0261048; case k12_TMEventTypeHideDamageReceived: - //F0254_TIMELINE_ProcessEvent12_HideDamageReceived(L0682_s_Event._priority); + f254_timelineProcessEvent12_hideDamageReceived(L0682_s_Event._priority); break; case k70_TMEventTypeLight: _vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex); @@ -973,9 +974,28 @@ void Timeline::f259_timelineProcessEvent11Part2_moveWeaponFromQuiverToSlot(uint1 bool Timeline::f258_timelineHasWeaponMovedSlot(int16 champIndex, Champion* champ, uint16 sourceSlotIndex, int16 destSlotIndex) { if (Thing(champ->_slots[sourceSlotIndex]).getType() == k5_WeaponThingType) { _vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, sourceSlotIndex), - (ChampionSlot)destSlotIndex); + (ChampionSlot)destSlotIndex); return true; } return false; } + +void Timeline::f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex) { + Champion* L0663_ps_Champion; + + + L0663_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + L0663_ps_Champion->_hideDamageReceivedIndex = -1; + if (!L0663_ps_Champion->_currHealth) { + return; + } + if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) { + _vm->_eventMan->f78_showMouse(); + _vm->_inventoryMan->f354_drawStatusBoxPortrait((ChampionIndex)champIndex); + _vm->_eventMan->f77_hideMouse(); + } else { + setFlag(L0663_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle); + _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); + } +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index 021889dbfb..636d62db4f 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -183,6 +183,7 @@ public: uint16 slotIndex);// @ F0259_TIMELINE_ProcessEvent11Part2_MoveWeaponFromQuiverToSlot bool f258_timelineHasWeaponMovedSlot(int16 champIndex, Champion *champ, uint16 sourceSlotIndex, int16 destSlotIndex); // @ F0258_TIMELINE_HasWeaponMovedToSlot + void f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex); // @ F0254_TIMELINE_ProcessEvent12_HideDamageReceived }; -- cgit v1.2.3 From f7e4486d84929b85cc5c82c6a6366eb37f5766de Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 12 Jul 2016 08:33:45 +0200 Subject: DM: Add f257_timelineProcessEvent70_light --- engines/dm/timeline.cpp | 33 ++++++++++++++++++++++++++++++++- engines/dm/timeline.h | 1 + 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 0f36220406..8141280f63 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -337,7 +337,7 @@ void Timeline::f261_processTimeline() { break; case k70_TMEventTypeLight: _vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex); - //F0257_TIMELINE_ProcessEvent70_Light(L0681_ps_Event); + f257_timelineProcessEvent70_light(L0681_ps_Event); _vm->_inventoryMan->f337_setDungeonViewPalette(); break; case k71_TMEventTypeInvisibility: @@ -998,4 +998,35 @@ void Timeline::f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex) _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); } } + +void Timeline::f257_timelineProcessEvent70_light(TimelineEvent* event) { + int16 L0673_i_WeakerLightPower; + int16 L0674_i_Multiple; +#define AL0674_i_LightPower L0674_i_Multiple +#define AL0674_i_LightAmount L0674_i_Multiple + bool L0675_B_NegativeLightPower; + TimelineEvent L0676_s_Event; + + + if ((AL0674_i_LightPower = event->_B._lightPower) == 0) { + return; + } + if (L0675_B_NegativeLightPower = (AL0674_i_LightPower < 0)) { + AL0674_i_LightPower = -AL0674_i_LightPower; + } + L0673_i_WeakerLightPower = AL0674_i_LightPower - 1; + AL0674_i_LightAmount = g39_LightPowerToLightAmount[AL0674_i_LightPower] - g39_LightPowerToLightAmount[L0673_i_WeakerLightPower]; + if (L0675_B_NegativeLightPower) { + AL0674_i_LightAmount = -AL0674_i_LightAmount; + L0673_i_WeakerLightPower = -L0673_i_WeakerLightPower; + } + _vm->_championMan->_g407_party._magicalLightAmount += AL0674_i_LightAmount; + if (L0673_i_WeakerLightPower) { + L0676_s_Event._type = k70_TMEventTypeLight; + L0676_s_Event._B._lightPower = L0673_i_WeakerLightPower; + M33_setMapAndTime(L0676_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 4); + L0676_s_Event._priority = 0; + _vm->_timeline->f238_addEventGetEventIndex(&L0676_s_Event); + } +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index 636d62db4f..ed0a5abce3 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -184,6 +184,7 @@ public: bool f258_timelineHasWeaponMovedSlot(int16 champIndex, Champion *champ, uint16 sourceSlotIndex, int16 destSlotIndex); // @ F0258_TIMELINE_HasWeaponMovedToSlot void f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex); // @ F0254_TIMELINE_ProcessEvent12_HideDamageReceived + void f257_timelineProcessEvent70_light(TimelineEvent *event); // @ F0257_TIMELINE_ProcessEvent70_Light }; -- cgit v1.2.3 From 800100e2bc0a325f81bebc8993e95ded17c6fb76 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 12 Jul 2016 08:36:53 +0200 Subject: DM: Add f260_timelineRefreshAllChampionStatusBoxes --- engines/dm/champion.cpp | 7 +++++++ engines/dm/champion.h | 1 + engines/dm/timeline.cpp | 11 ++++++++++- engines/dm/timeline.h | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index a84ccb811d..1fd31eaa43 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1189,6 +1189,13 @@ bool ChampionMan::f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint1 return ((L0878_T_Thing.getType() == k5_WeaponThingType) && (L0875_ps_WeaponInfo->_class == L0879_i_WeaponClass)); } +void ChampionMan::f293_drawAllChampionStates() { + int16 L0873_i_ChampionIndex; + for (L0873_i_ChampionIndex = k0_ChampionFirst; L0873_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0873_i_ChampionIndex++) { + _vm->_championMan->f292_drawChampionState((ChampionIndex)L0873_i_ChampionIndex); + } +} + ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) { for (uint16 i = 0; i < _g305_partyChampionCount; ++i) { if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 17686f91f9..35aaff6d6b 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -523,6 +523,7 @@ public: int16 f310_getMovementTicks(Champion *champ); // @ F0310_CHAMPION_GetMovementTicks bool f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex, uint16 ammunitionSlotIndex); // @ F0294_CHAMPION_IsAmmunitionCompatibleWithWeapon + void f293_drawAllChampionStates(); // @ F0293_CHAMPION_DrawAllChampionStates diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 8141280f63..717870f704 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -355,7 +355,7 @@ T0261048: case k74_TMEventTypePartyShield: _vm->_championMan->_g407_party._shieldDefense -= L0682_s_Event._B._defense; T0261053: - //F0260_TIMELINE_RefreshAllChampionStatusBoxes(); + f260_timelineRefreshAllChampionStatusBoxes(); break; case k77_TMEventTypeSpellShield: _vm->_championMan->_g407_party._spellShieldDefense -= L0682_s_Event._B._defense; @@ -1029,4 +1029,13 @@ void Timeline::f257_timelineProcessEvent70_light(TimelineEvent* event) { _vm->_timeline->f238_addEventGetEventIndex(&L0676_s_Event); } } + +void Timeline::f260_timelineRefreshAllChampionStatusBoxes() { + uint16 L0679_ui_ChampionIndex; + + for (L0679_ui_ChampionIndex = k0_ChampionFirst; L0679_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0679_ui_ChampionIndex++) { + setFlag(_vm->_championMan->_gK71_champions[L0679_ui_ChampionIndex]._attributes, k0x1000_ChampionAttributeStatusBox); + } + _vm->_championMan->f293_drawAllChampionStates(); +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index ed0a5abce3..253bf812ec 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -185,6 +185,7 @@ public: uint16 sourceSlotIndex, int16 destSlotIndex); // @ F0258_TIMELINE_HasWeaponMovedToSlot void f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex); // @ F0254_TIMELINE_ProcessEvent12_HideDamageReceived void f257_timelineProcessEvent70_light(TimelineEvent *event); // @ F0257_TIMELINE_ProcessEvent70_Light + void f260_timelineRefreshAllChampionStatusBoxes(); // @ F0260_TIMELINE_RefreshAllChampionStatusBoxes }; -- cgit v1.2.3 From 3e40cc46e3de279f83ef4037ad3462b24eb395fd Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 12 Jul 2016 08:44:15 +0200 Subject: DM: Add f255_timelineProcessEvent13_ViAltarRebirth --- engines/dm/champion.cpp | 22 +++++++++++++++++++++ engines/dm/champion.h | 1 + engines/dm/dungeonman.h | 1 + engines/dm/timeline.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++++- engines/dm/timeline.h | 1 + 5 files changed, 75 insertions(+), 1 deletion(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 1fd31eaa43..443b7646ae 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1196,6 +1196,28 @@ void ChampionMan::f293_drawAllChampionStates() { } } +void ChampionMan::f283_viAltarRebirth(uint16 champIndex) { + uint16 L0831_ui_Multiple; +#define AL0831_ui_Cell L0831_ui_Multiple +#define AL0831_ui_MaximumHealth L0831_ui_Multiple + Champion* L0832_ps_Champion; + + L0832_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + if (_vm->_championMan->f285_getIndexInCell(L0832_ps_Champion->_cell) != kM1_ChampionNone) { + AL0831_ui_Cell = k0_CellNorthWest; + while (_vm->_championMan->f285_getIndexInCell(AL0831_ui_Cell) != kM1_ChampionNone) { + AL0831_ui_Cell++; + } + L0832_ps_Champion->_cell = (ViewCell)AL0831_ui_Cell; + } + AL0831_ui_MaximumHealth = L0832_ps_Champion->_maxHealth; + L0832_ps_Champion->_currHealth = (L0832_ps_Champion->_maxHealth = MAX(25, AL0831_ui_MaximumHealth - (AL0831_ui_MaximumHealth >> 6) - 1)) >> 1; + _vm->_menuMan->f393_drawSpellAreaControls(_vm->_championMan->_g514_magicCasterChampionIndex); + L0832_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir; + setFlag(L0832_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon); + _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); +} + ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) { for (uint16 i = 0; i < _g305_partyChampionCount; ++i) { if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 35aaff6d6b..7d78789ae5 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -524,6 +524,7 @@ public: bool f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex, uint16 ammunitionSlotIndex); // @ F0294_CHAMPION_IsAmmunitionCompatibleWithWeapon void f293_drawAllChampionStates(); // @ F0293_CHAMPION_DrawAllChampionStates + void f283_viAltarRebirth(uint16 champIndex); // @ F0283_CHAMPION_ViAltarRebirth diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 2a6a8b72f8..ca01034d96 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -493,6 +493,7 @@ public: uint16 getDoNotDiscard() { return (_attributes >> 7) & 1; } Thing getNextThing() { return _nextThing; } + void setNextThing(Thing thing) { _nextThing = thing; } }; // @ JUNK #define kM1_soundModeDoNotPlaySound -1 // @ CM1_MODE_DO_NOT_PLAY_SOUND diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 717870f704..55c1e4bb66 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -34,6 +34,7 @@ #include "movesens.h" #include "text.h" #include "eventman.h" +#include "objectman.h" namespace DM { @@ -368,7 +369,7 @@ T0261053: _vm->_championMan->f322_championPoison(AL0680_ui_ChampionIndex, L0682_s_Event._B._attack); break; case k13_TMEventTypeViAltarRebirth: - //F0255_TIMELINE_ProcessEvent13_ViAltarRebirth(L0681_ps_Event); + f255_timelineProcessEvent13_ViAltarRebirth(L0681_ps_Event); break; case k79_TMEventTypeFootprints: _vm->_championMan->_g407_party._event79Count_Footprints--; @@ -1038,4 +1039,52 @@ void Timeline::f260_timelineRefreshAllChampionStatusBoxes() { } _vm->_championMan->f293_drawAllChampionStates(); } + +void Timeline::f255_timelineProcessEvent13_ViAltarRebirth(TimelineEvent* event) { + int16 L0664_i_MapX; + int16 L0665_i_MapY; + uint16 L0666_ui_Cell; + Thing L0667_T_Thing; + Junk* L0668_ps_Junk; + int16 L0669_i_IconIndex; + uint16 L0670_ui_Step; + uint16 L0671_ui_ChampionIndex; + + + L0664_i_MapX = event->_B._location._mapX; + L0665_i_MapY = event->_B._location._mapY; + L0665_i_MapY = event->_B._location._mapY; + L0666_ui_Cell = event->_C.A._cell; + L0671_ui_ChampionIndex = event->_priority; + switch (L0670_ui_Step = event->_C.A._effect) { /* Rebirth is a 3 steps process (Step 2 -> Step 1 -> Step 0). Step is stored in the Effect value of the event */ + case 2: + _vm->_projexpl->f213_explosionCreate(Thing::_explRebirthStep1, 0, L0664_i_MapX, L0665_i_MapY, L0666_ui_Cell); + event->_mapTime += 5; +T0255002: + L0670_ui_Step--; + event->_C.A._effect = L0670_ui_Step; + _vm->_timeline->f238_addEventGetEventIndex(event); + break; + case 1: + L0667_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0664_i_MapX, L0665_i_MapY); + while (L0667_T_Thing != Thing::_endOfList) { + if ((L0667_T_Thing.getCell() == L0666_ui_Cell) && (L0667_T_Thing.getType() == k10_JunkThingType)) { + L0669_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0667_T_Thing); + if (L0669_i_IconIndex == k147_IconIndiceJunkChampionBones) { + L0668_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0667_T_Thing); + if (L0668_ps_Junk->getChargeCount() == L0671_ui_ChampionIndex) { + _vm->_dungeonMan->f164_unlinkThingFromList(L0667_T_Thing, Thing(0), L0664_i_MapX, L0665_i_MapY); /* BUG0_25 When a champion dies, no bones object is created so it is not possible to bring the champion back to life at an altar of Vi. Each time a champion is brought back to life, the bones object is removed from the dungeon but it is not marked as unused and thus becomes an orphan. After a large number of champion deaths, all JUNK things are exhausted and the game cannot create any more. This also affects the creation of JUNK things dropped by some creatures when they die (Screamer, Rockpile, Magenta Worm, Pain Rat, Red Dragon) */ + L0668_ps_Junk->setNextThing(Thing::_none); + event->_mapTime += 1; + goto T0255002; + } + } + } + L0667_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0667_T_Thing); + } + break; + case 0: + _vm->_championMan->f283_viAltarRebirth(event->_priority); + } +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index 253bf812ec..49a7ca4477 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -186,6 +186,7 @@ public: void f254_timelineProcessEvent12_hideDamageReceived(uint16 champIndex); // @ F0254_TIMELINE_ProcessEvent12_HideDamageReceived void f257_timelineProcessEvent70_light(TimelineEvent *event); // @ F0257_TIMELINE_ProcessEvent70_Light void f260_timelineRefreshAllChampionStatusBoxes(); // @ F0260_TIMELINE_RefreshAllChampionStatusBoxes + void f255_timelineProcessEvent13_ViAltarRebirth(TimelineEvent *event); // @ F0255_TIMELINE_ProcessEvent13_ViAltarRebirth }; -- cgit v1.2.3 From 0f76448e5794bea0097f1c806c67623093c79cf8 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 12 Jul 2016 08:53:34 +0200 Subject: DM: Fix up main loop --- engines/dm/dm.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 932de5a60c..dbf7a9577a 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -324,8 +324,6 @@ void DMEngine::f2_gameloop() { _dungeonMan->_g306_partyMapX = 10; _dungeonMan->_g307_partyMapY = 4; _dungeonMan->_g308_partyDir = kDirNorth; - warning(false, "DUMMY CODE: setting InventoryMan::_g432_inventoryChampionOrdinal to zero"); - _inventoryMan->_g432_inventoryChampionOrdinal = 0; while (true) { if (_g327_newPartyMapIndex != kM1_mapIndexNone) { @@ -359,23 +357,32 @@ T0002002: _eventMan->f77_hideMouse(); } } - + // F0363_COMMAND_HighlightBoxDisable(); + // F0065_SOUND_PlayPendingSound_CPSD(); + // F0320_CHAMPION_ApplyAndDrawPendingDamageAndWounds if (_championMan->_g303_partyDead) break; _g313_gameTime++; if (!(_g313_gameTime & 511)) _inventoryMan->f338_decreaseTorchesLightPower(); - if (_g310_disabledMovementTicks) { - _g310_disabledMovementTicks--; - } - if (_championMan->_g407_party._freezeLifeTicks) { + + if (_g310_disabledMovementTicks) + _g310_disabledMovementTicks--; + + if (_championMan->_g407_party._freezeLifeTicks) _championMan->_g407_party._freezeLifeTicks -= 1; - } + _menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived(); - if (_g311_projectileDisableMovementTicks) - _g311_projectileDisableMovementTicks--; + // if (!((int)_vm->_g313_gameTime & (_vm->_championMan->_g300_partyIsSleeping ? 15 : 63))) { + // F0331_CHAMPION_ApplyTimeEffects_CPSF(); + // } + + if (_g310_disabledMovementTicks) + _g310_disabledMovementTicks--; + + // F0044_TEXT_MESSAGEAREA_ClearExpiredRows(); _g321_stopWaitingForPlayerInput = false; @@ -395,7 +402,7 @@ T0002002: _eventMan->f380_processCommandQueue(); _displayMan->updateScreen(); // if (!_vm->_g321_stopWaitingForPlayerInput) { - warning(false, "MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); + // F0363_COMMAND_HighlightBoxDisable(); // } } while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking); -- cgit v1.2.3 From 42cbf35b0bbe821b7127a0a883b4248c4da9f90a Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 12 Jul 2016 11:30:25 +0200 Subject: DM: Clean up f380_processCommandQueue, add _g318_waitForInputMaxVerticalBlankCount --- engines/dm/TODOs/todo.txt | 7 +- engines/dm/champion.cpp | 1 + engines/dm/dm.cpp | 4 +- engines/dm/dm.h | 5 ++ engines/dm/eventman.cpp | 182 ++++++++++++++++++++++++++++++++++++++++------ 5 files changed, 175 insertions(+), 24 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 78a5e9cd80..26aa3335b0 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -21,5 +21,8 @@ Todo: I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions Finish stuff: - f261_processTimeline - + f380_processCommandQueue + Missing main loop methods + F0577_VBLANK_Handler, if enought time passes, takes the player's chance to act + - TODO: implement it + - NOTE: _g318_waitForInputMaxVerticalBlankCount is already included in the engine diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 443b7646ae..3745924a3e 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -820,6 +820,7 @@ uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion* champ, uint16 stat void ChampionMan::f314_wakeUp() { _vm->_g321_stopWaitingForPlayerInput = true; _g300_partyIsSleeping = false; + _vm->_g318_waitForInputMaxVerticalBlankCount = 10; _vm->f22_delay(10); _vm->_displayMan->f98_drawFloorAndCeiling(); _vm->_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index dbf7a9577a..194bfa2a8a 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -168,6 +168,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _g310_disabledMovementTicks = 0; _g313_gameTime = 0; _g353_stringBuildBuffer[0] = '\0'; + _g318_waitForInputMaxVerticalBlankCount = 0; debug("DMEngine::DMEngine"); @@ -320,11 +321,12 @@ Common::Error DMEngine::run() { } void DMEngine::f2_gameloop() { - warning(false, "DUMMY CODE SETTING PARTY POS AND DIRECTION"); + warning(false, "DUMMY CODE: SETTING PARTY POS AND DIRECTION"); _dungeonMan->_g306_partyMapX = 10; _dungeonMan->_g307_partyMapY = 4; _dungeonMan->_g308_partyDir = kDirNorth; + _g318_waitForInputMaxVerticalBlankCount = 10; while (true) { if (_g327_newPartyMapIndex != kM1_mapIndexNone) { T0002002: diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 1e1fc6a53c..dce88f17f8 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -172,6 +172,10 @@ inline T f26_getBoundedValue(T min, T val, T max) { #define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember)) +#define k0_modeLoadSavedGame 0 // @ C000_MODE_LOAD_SAVED_GAME +#define k1_modeLoadDungeon 1 // @ C001_MODE_LOAD_DUNGEON +#define k99_modeWaitingOnEntrance 99 // @ C099_MODE_WAITING_ON_ENTRANCE +#define k202_modeEntranceDrawCredits 202 // @ C202_MODE_ENTRANCE_DRAW_CREDITS class DMEngine : public Engine { void f462_startGame(); // @ F0462_START_StartGame_CPSF @@ -234,6 +238,7 @@ public: int8 _dirIntoStepCountNorth[4]; // @ G0234_ai_Graphic559_DirectionToStepNorthCount uint32 _g313_gameTime; // @ G0313_ul_GameTime char _g353_stringBuildBuffer[128]; // @ G0353_ac_StringBuildBuffer + int16 _g318_waitForInputMaxVerticalBlankCount; // @ G0318_i_WaitForInputMaximumVerticalBlankCount }; class Console : public GUI::Debugger { diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 4f3ffc5e74..9045c624fd 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -613,39 +613,179 @@ CommandType EventManager::f358_getCommandTypeFromMouseInput(MouseInput *input, C void EventManager::f380_processCommandQueue() { - _g435_isCommandQueueLocked = true; - if (_commandQueue.empty()) { - _g435_isCommandQueueLocked = false; - f360_processPendingClick(); + int16 AL1159_i_ChampionIndex; + CommandType cmdType; + int16 L1161_i_CommandX; + int16 L1162_i_CommandY; + static KeyboardInput* G0481_ps_PrimaryKeyboardInputBackup; + static KeyboardInput* G0482_ps_SecondaryKeyboardInputBackup; + static MouseInput* G0483_ps_PrimaryMouseInputBackup; + static MouseInput* G0484_ps_SecondaryMouseInputBackup; + + + _vm->_eventMan->_g435_isCommandQueueLocked = true; + if (_commandQueue.empty()) { /* If the command queue is empty */ + _vm->_eventMan->_g435_isCommandQueueLocked = false; + _vm->_eventMan->f360_processPendingClick(); return; } Command cmd = _commandQueue.pop(); - - int16 commandX = cmd._pos.x; - int16 commandY = cmd._pos.y; - - _g435_isCommandQueueLocked = false; - f360_processPendingClick(); - - if ((cmd._type == k2_CommandTurnRight) || (cmd._type == k1_CommandTurnLeft)) { - f365_commandTurnParty(cmd._type); + cmdType = cmd._type; + if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft) && (_vm->_g310_disabledMovementTicks || (_vm->_g311_projectileDisableMovementTicks && (_vm->_g312_lastProjectileDisabledMovementDirection == (M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + cmdType - k3_CommandMoveForward)))))) { /* If movement is disabled */ + _vm->_eventMan->_g435_isCommandQueueLocked = false; + _vm->_eventMan->f360_processPendingClick(); + return; + } + L1161_i_CommandX = cmd._pos.x; + L1162_i_CommandY = cmd._pos.y; + _vm->_eventMan->_g435_isCommandQueueLocked = false; + _vm->_eventMan->f360_processPendingClick(); + if ((cmdType == k2_CommandTurnRight) || (cmdType == k1_CommandTurnLeft)) { + _vm->_eventMan->f365_commandTurnParty(cmdType); + return; + } + if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft)) { + _vm->_eventMan->f366_commandMoveParty(cmdType); + return; + } + if ((cmdType >= k12_CommandClickInChampion_0_StatusBox) && (cmdType <= k15_CommandClickInChampion_3_StatusBox)) { + if (((AL1159_i_ChampionIndex = cmdType - k12_CommandClickInChampion_0_StatusBox) < _vm->_championMan->_g305_partyChampionCount) && !_vm->_championMan->_g299_candidateChampionOrdinal) { + warning(false, "MISSING CODE: F0367_COMMAND_ProcessTypes12To27_ClickInChampionStatusBox(AL1159_i_ChampionIndex, L1161_i_CommandX, L1162_i_CommandY);"); + } + return; + } + if ((cmdType >= k125_CommandClickOnChamptionIcon_Top_Left) && (cmdType <= k128_CommandClickOnChamptionIcon_Lower_Left)) { + warning(false, "MISSING CODE: F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon(cmdType - k125_CommandClickOnChamptionIcon_Top_Left);"); + return; + } + if ((cmdType >= k28_CommandClickOnSlotBoxInventoryReadyHand) && (cmdType < (k65_CommandClickOnSlotBoxChest_8 + 1))) { + if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) { + warning(false, "MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox(cmdType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);"); + } + return; + } + if ((cmdType >= k7_CommandToggleInventoryChampion_0) && (cmdType <= k11_CommandCloseInventory)) { + if ((((AL1159_i_ChampionIndex = cmdType - k7_CommandToggleInventoryChampion_0) == k4_ChampionCloseInventory) || (AL1159_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount)) && !_vm->_championMan->_g299_candidateChampionOrdinal) { + _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)AL1159_i_ChampionIndex); + } + return; + } + if (cmdType == k83_CommandToggleInventoryLeader) { + if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) { + _vm->_inventoryMan->f355_toggleInventory(_vm->_championMan->_g411_leaderIndex); + } + return; + } + if (cmdType == k100_CommandClickInSpellArea) { + if ((!_vm->_championMan->_g299_candidateChampionOrdinal) && (_vm->_championMan->_g514_magicCasterChampionIndex != kM1_ChampionNone)) { + warning(false, "MISSING CODE: F0370_COMMAND_ProcessType100_ClickInSpellArea(L1161_i_CommandX, L1162_i_CommandY);"); + } + return; + } + if (cmdType == k111_CommandClickInActionArea) { + if (!_vm->_championMan->_g299_candidateChampionOrdinal) { + warning(false, "MISSING CODE: F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE(L1161_i_CommandX, L1162_i_CommandY);"); + } + return; + } + if (cmdType == k70_CommandClickOnMouth) { + warning(false, "MISSING CODE: F0349_INVENTORY_ProcessCommand70_ClickOnMouth();"); + return; + } + if (cmdType == k71_CommandClickOnEye) { + warning(false, "MISSING CODE: F0352_INVENTORY_ProcessCommand71_ClickOnEye();"); + return; + } + if (cmdType == k80_CommandClickInDungeonView) { + _vm->_eventMan->f377_commandProcessType80ClickInDungeonView(L1161_i_CommandX, L1162_i_CommandY); + return; + } + if (cmdType == k81_CommandClickInPanel) { + _vm->_eventMan->f378_commandProcess81ClickInPanel(L1161_i_CommandX, L1162_i_CommandY); return; } - if ((cmd._type >= k3_CommandMoveForward) && (cmd._type <= k6_CommandMoveLeft)) { - f366_commandMoveParty(cmd._type); + if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) { return; } - if (cmd._type == k80_CommandClickInDungeonView) { - f377_commandProcessType80ClickInDungeonView(commandX, commandY); + if (cmdType == k145_CommandSleep) { + if (!_vm->_championMan->_g299_candidateChampionOrdinal) { + if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) { + _vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory); + } + _vm->_menuMan->f456_drawDisabledMenu(); + _vm->_championMan->_g300_partyIsSleeping = true; + warning(false, "MISSING CODE: F0379_COMMAND_DrawSleepScreen();"); + _vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame); + _vm->_g318_waitForInputMaxVerticalBlankCount = 0; + _vm->_eventMan->_g441_primaryMouseInput = g450_PrimaryMouseInput_PartySleeping; + _vm->_eventMan->_g442_secondaryMouseInput = 0; + _g443_primaryKeyboardInput = g460_primaryKeyboardInput_partySleeping; + _g444_secondaryKeyboardInput = nullptr; + f357_discardAllInput(); + } + return; } - if (cmd._type == k81_CommandClickInPanel) { - f378_commandProcess81ClickInPanel(commandX, commandY); + if (cmdType == k146_CommandWakeUp) { + _vm->_championMan->f314_wakeUp(); + return; + } + if (cmdType == k140_CommandSaveGame) { + if ((_vm->_championMan->_g305_partyChampionCount > 0) && !_vm->_championMan->_g299_candidateChampionOrdinal) { + warning(false, "MISSING CODE: F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF();"); + } + return; + } + if (cmdType == k147_CommandFreezeGame) { + _vm->_g301_gameTimeTicking = false; + _vm->_menuMan->f456_drawDisabledMenu(); + _vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 224, 136); + // TODO: localization + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 81, 69, k4_ColorCyan, k0_ColorBlack, + "GAME FROZEN", k136_heightViewport); + _vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame); + G0483_ps_PrimaryMouseInputBackup = _vm->_eventMan->_g441_primaryMouseInput; + G0484_ps_SecondaryMouseInputBackup = _vm->_eventMan->_g442_secondaryMouseInput; + G0481_ps_PrimaryKeyboardInputBackup = _g443_primaryKeyboardInput; + G0482_ps_SecondaryKeyboardInputBackup = _g444_secondaryKeyboardInput; + _vm->_eventMan->_g441_primaryMouseInput = g451_PrimaryMouseInput_FrozenGame; + _vm->_eventMan->_g442_secondaryMouseInput = 0; + _g443_primaryKeyboardInput = g461_primaryKeyboardInput_frozenGame; + _g444_secondaryKeyboardInput = nullptr; + f357_discardAllInput(); + return; + } + if (cmdType == k148_CommandUnfreezeGame) { + _vm->_g301_gameTimeTicking = true; + _vm->_menuMan->f457_drawEnabledMenus(); + _vm->_eventMan->_g441_primaryMouseInput = G0483_ps_PrimaryMouseInputBackup; + _vm->_eventMan->_g442_secondaryMouseInput = G0484_ps_SecondaryMouseInputBackup; + _g443_primaryKeyboardInput = G0481_ps_PrimaryKeyboardInputBackup; + _g444_secondaryKeyboardInput = G0482_ps_SecondaryKeyboardInputBackup; + f357_discardAllInput(); + return; + } + if (cmdType == k200_CommandEntranceEnterDungeon) { + _vm->_g298_newGame = k1_modeLoadDungeon; + return; + } + if (cmdType == k201_CommandEntranceResume) { + _vm->_g298_newGame = k0_modeLoadSavedGame; + return; + } + if (cmdType == k202_CommandEntranceDrawCredits) { + warning(false, "MISSING CODE: F0442_STARTEND_ProcessCommand202_EntranceDrawCredits()"); + return; + } + if ((cmdType >= k210_CommandClickOnDialogChoice_1) && (cmdType <= k213_CommandClickOnDialogChoice_4)) { + warning(false, "MISSING CODE:G0335_ui_SelectedDialogChoice = cmdType - (k210_CommandClickOnDialogChoice_1 - 1);"); + return; + } + if (cmdType == k215_CommandRestartGame) { + _vm->_g523_restartGameRequest = true; } - - // MISSING CODE: the rest of the function } void EventManager::f365_commandTurnParty(CommandType cmdType) { -- cgit v1.2.3 From 4d3c9d99f169efb3991866318d04a644b5de0217 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 12 Jul 2016 12:05:20 +0200 Subject: DM: Add f367_commandProcessTypes12to27_clickInChampionStatusBox --- engines/dm/TODOs/todo.txt | 7 ++-- engines/dm/champion.cpp | 88 +++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/champion.h | 2 +- engines/dm/dungeonman.cpp | 54 +++++++++++++++-------------- engines/dm/eventman.cpp | 19 +++++++++- engines/dm/eventman.h | 2 ++ 6 files changed, 142 insertions(+), 30 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 26aa3335b0..4839d2d781 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -8,8 +8,10 @@ Bugs: When object are put on the right side of the current square, they disappear Drawing door ornaments segfaults when going back to the start - - +Possible bugs: + - k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON + - possible garbage value return in f140_getObjectWeight + Todo: Add wiki entry for DM Rename GraphicIndice enum entires and have their name include GraphicIndice @@ -26,3 +28,4 @@ Finish stuff: F0577_VBLANK_Handler, if enought time passes, takes the player's chance to act - TODO: implement it - NOTE: _g318_waitForInputMaxVerticalBlankCount is already included in the engine + diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 3745924a3e..fdbdc0914c 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -39,6 +39,47 @@ namespace DM { +uint16 g38_slotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks + /* 30 for champion inventory, 8 for chest */ + 0xFFFF, /* Ready Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Action Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0x0002, /* Head Head */ + 0x0008, /* Torso Torso */ + 0x0010, /* Legs Legs */ + 0x0020, /* Feet Feet */ + 0x0100, /* Pouch 2 Pouch */ + 0x0080, /* Quiver Line2 1 Quiver 2 */ + 0x0080, /* Quiver Line1 2 Quiver 2 */ + 0x0080, /* Quiver Line2 2 Quiver 2 */ + 0x0004, /* Neck Neck */ + 0x0100, /* Pouch 1 Pouch */ + 0x0040, /* Quiver Line1 1 Quiver 1 */ + 0xFFFF, /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0xFFFF, /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ + 0x0400, /* Chest 1 Chest */ + 0x0400, /* Chest 2 Chest */ + 0x0400, /* Chest 3 Chest */ + 0x0400, /* Chest 4 Chest */ + 0x0400, /* Chest 5 Chest */ + 0x0400, /* Chest 6 Chest */ + 0x0400, /* Chest 7 Chest */ + 0x0400}; /* Chest 8 Chest */ + const char *g417_baseSkillName[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"}; Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth @@ -1219,6 +1260,53 @@ void ChampionMan::f283_viAltarRebirth(uint16 champIndex) { _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); } +void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) { + uint16 L0903_ui_ChampionIndex; + uint16 L0904_ui_SlotIndex; + Thing L0905_T_LeaderHandObject; + Thing L0906_T_SlotThing; + + + if (slotBoxIndex < k8_SlotBoxInventoryFirstSlot) { + if (_vm->_championMan->_g299_candidateChampionOrdinal) { + return; + } + L0903_ui_ChampionIndex = slotBoxIndex >> 1; + if ((L0903_ui_ChampionIndex >= _vm->_championMan->_g305_partyChampionCount) || (_vm->M0_indexToOrdinal(L0903_ui_ChampionIndex) == (int)_vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_vm->_championMan->_gK71_champions[L0903_ui_ChampionIndex]._currHealth) { + return; + } + L0904_ui_SlotIndex = _vm->_championMan->M70_handSlotIndex(slotBoxIndex); + } else { + L0903_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal); + L0904_ui_SlotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot; + } + L0905_T_LeaderHandObject = _vm->_championMan->_g414_leaderHandObject; + if (L0904_ui_SlotIndex >= k30_ChampionSlotChest_1) { + L0906_T_SlotThing = _vm->_inventoryMan->_g425_chestSlots[L0904_ui_SlotIndex - k30_ChampionSlotChest_1]; + } else { + L0906_T_SlotThing = _vm->_championMan->_gK71_champions[L0903_ui_ChampionIndex]._slots[L0904_ui_SlotIndex]; + } + if ((L0906_T_SlotThing == Thing::_none) && (L0905_T_LeaderHandObject == Thing::_none)) { + return; + } + if ((L0905_T_LeaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0905_T_LeaderHandObject)]._allowedSlots & g38_slotMasks[L0904_ui_SlotIndex]))) { + return; + } + _vm->_eventMan->f78_showMouse(); + if (L0905_T_LeaderHandObject != Thing::_none) { + f298_getObjectRemovedFromLeaderHand(); + } + if (L0906_T_SlotThing != Thing::_none) { + f300_getObjectRemovedFromSlot(L0903_ui_ChampionIndex, L0904_ui_SlotIndex); + f297_putObjectInLeaderHand(L0906_T_SlotThing, false); + } + if (L0905_T_LeaderHandObject != Thing::_none) { + _vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0903_ui_ChampionIndex, L0905_T_LeaderHandObject, (ChampionSlot)L0904_ui_SlotIndex); + } + _vm->_championMan->f292_drawChampionState((ChampionIndex)L0903_ui_ChampionIndex); + _vm->_eventMan->f77_hideMouse(); +} + ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) { for (uint16 i = 0; i < _g305_partyChampionCount; ++i) { if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 7d78789ae5..37ca363e50 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -525,7 +525,7 @@ public: uint16 ammunitionSlotIndex); // @ F0294_CHAMPION_IsAmmunitionCompatibleWithWeapon void f293_drawAllChampionStates(); // @ F0293_CHAMPION_DrawAllChampionStates void f283_viAltarRebirth(uint16 champIndex); // @ F0283_CHAMPION_ViAltarRebirth - + void f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex); // @ F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 8100139581..d88363a0b3 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1251,44 +1251,46 @@ uint16 DungeonMan::f140_getObjectWeight(Thing thing) { 2, 0, 8 }; + Junk* junk; + uint16 weight; + if (thing == Thing::_none) return 0; + + junk = (Junk*)f156_getThingData(thing); switch (thing.getType()) { case k5_WeaponThingType: - return g238_WeaponInfo[Weapon(f156_getThingData(thing)).getType()]._weight; + weight = g238_WeaponInfo[((Weapon*)junk)->getType()]._weight; + break; case k6_ArmourThingType: - return g239_ArmourInfo[Armour(f156_getThingData(thing)).getType()]._weight; - case k10_JunkThingType: { - Junk junk(f156_getThingData(thing)); - uint16 weight = g241_junkInfo[junk.getType()]; - if (junk.getType() == k1_JunkTypeWaterskin) - weight += junk.getChargeCount() * 2; - return weight; - } - case k9_ContainerThingType: { - uint16 weight = 50; - Container container(f156_getThingData(thing)); - Thing slotThing = container.getSlot(); - while (slotThing != Thing::_endOfList) { - weight += f140_getObjectWeight(slotThing); - slotThing = f159_getNextThing(slotThing); + weight = g239_ArmourInfo[((Armour*)junk)->getType()]._weight; + break; + case k10_JunkThingType: + weight = g241_junkInfo[junk->getType()]; + if (junk->getType() == k1_JunkTypeWaterskin) { + weight += junk->getChargeCount() << 1; } - return weight; - } + break; + case k9_ContainerThingType: + weight = 50; + thing = ((Container*)junk)->getSlot(); + while (thing != Thing::_endOfList) { + weight += f140_getObjectWeight(thing); + thing = f159_getNextThing(thing); + } + break; case k8_PotionThingType: - if (Junk(f156_getThingData(thing)).getType() == k20_PotionTypeEmptyFlask) { - return 1; + if (((Potion*)junk)->getType() == k20_PotionTypeEmptyFlask) { + weight = 1; } else { - return 3; + weight = 3; } - case k7_ScrollThingType: - return 1; - default: break; + case k7_ScrollThingType: + weight = 1; } - assert(false); // this should never be taken - return 0; // dummy + return weight; // this is garbage if none of the branches were taken } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 9045c624fd..c19ed70c7a 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -651,7 +651,7 @@ void EventManager::f380_processCommandQueue() { } if ((cmdType >= k12_CommandClickInChampion_0_StatusBox) && (cmdType <= k15_CommandClickInChampion_3_StatusBox)) { if (((AL1159_i_ChampionIndex = cmdType - k12_CommandClickInChampion_0_StatusBox) < _vm->_championMan->_g305_partyChampionCount) && !_vm->_championMan->_g299_candidateChampionOrdinal) { - warning(false, "MISSING CODE: F0367_COMMAND_ProcessTypes12To27_ClickInChampionStatusBox(AL1159_i_ChampionIndex, L1161_i_CommandX, L1162_i_CommandY);"); + f367_commandProcessTypes12to27_clickInChampionStatusBox(AL1159_i_ChampionIndex, L1161_i_CommandX, L1162_i_CommandY); } return; } @@ -1283,4 +1283,21 @@ void EventManager::f364_commandTakeStairs(bool stairsGoDown) { _vm->_championMan->f284_setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY)); _vm->_dungeonMan->f173_setCurrentMap(_vm->_dungeonMan->_g309_partyMapIndex); } + +void EventManager::f367_commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX, int16 posY) { + uint16 L1126_ui_Command; + + if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) { + _vm->_eventMan->f368_commandSetLeader((ChampionIndex)champIndex); + } else { + L1126_ui_Command = _vm->_eventMan->f358_getCommandTypeFromMouseInput(g455_MouseInput_ChampionNamesHands, Common::Point(posX, posY), k1_LeftMouseButton); + if ((L1126_ui_Command >= k16_CommandSetLeaderChampion_0) && (L1126_ui_Command <= k19_CommandSetLeaderChampion_3)) { + _vm->_eventMan->f368_commandSetLeader((ChampionIndex)(L1126_ui_Command - k16_CommandSetLeaderChampion_0)); + } else { + if ((L1126_ui_Command >= k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand) && (L1126_ui_Command <= k27_CommandClickOnSlotBoxChampion_3_StatusBoxActionHand)) { + _vm->_championMan->f302_processCommands28to65_clickOnSlotBox(L1126_ui_Command - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand); + } + } + } +} } // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index 2c61d3e7ce..fb983bfaad 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -297,6 +297,8 @@ public: void f379_drawSleepScreen(); // @ F0379_COMMAND_DrawSleepScreen void f357_discardAllInput(); // @ F0357_COMMAND_DiscardAllInput void f364_commandTakeStairs(bool stairsGoDown);// @ F0364_COMMAND_TakeStairs + void f367_commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX, + int16 posY); // @ F0367_COMMAND_ProcessTypes12To27_ClickInChampionStatusBox }; -- cgit v1.2.3 From 0f107cead2b59c9e67fc50996df49d4e86918f48 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 12 Jul 2016 12:26:22 +0200 Subject: DM: Add f70_mouseProcessCommands125To128_clickOnChampionIcon --- engines/dm/eventman.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++- engines/dm/eventman.h | 1 + 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index c19ed70c7a..f74c8067af 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -656,7 +656,7 @@ void EventManager::f380_processCommandQueue() { return; } if ((cmdType >= k125_CommandClickOnChamptionIcon_Top_Left) && (cmdType <= k128_CommandClickOnChamptionIcon_Lower_Left)) { - warning(false, "MISSING CODE: F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon(cmdType - k125_CommandClickOnChamptionIcon_Top_Left);"); + f70_mouseProcessCommands125To128_clickOnChampionIcon(cmdType - k125_CommandClickOnChamptionIcon_Top_Left); return; } if ((cmdType >= k28_CommandClickOnSlotBoxInventoryReadyHand) && (cmdType < (k65_CommandClickOnSlotBoxChest_8 + 1))) { @@ -1300,4 +1300,63 @@ void EventManager::f367_commandProcessTypes12to27_clickInChampionStatusBox(uint1 } } } + +void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex) { + static Box G0621_s_Box_MousePointer_ChampionIconShadow = Box(2, 20, 2, 15); + static Box G0622_s_Box_MousePointer_ChampionIcon = Box(0, 18, 0, 13); + static byte G0045_auc_Graphic562_PaletteChanges_MousePointerIconShadow[16] = {0, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, 120, 120, 120}; + + uint16 L0052_ui_ChampionIconIndex; + int16 L0053_i_ChampionIndex; + int16 L0054_i_ChampionIndex; + Box* L0055_pi_ChampionIconBox; + register unsigned char* L0056_puc_Bitmap; + + + _gK100_preventBuildPointerScreenArea = true; + if (!_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) { + if (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir)) == kM1_ChampionNone) { + _gK100_preventBuildPointerScreenArea = false; + return; + } + _vm->_eventMan->_g598_mousePointerBitmapUpdated = true; + _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = true; + _vm->_displayMan->_g578_useByteBoxCoordinates = false; + L0056_puc_Bitmap = _gK190_mousePointerTempBuffer; + memset(L0056_puc_Bitmap, 0, 32 * 18); + L0055_pi_ChampionIconBox = &g54_BoxChampionIcons[champIconIndex]; + + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, L0056_puc_Bitmap, G0621_s_Box_MousePointer_ChampionIconShadow, L0055_pi_ChampionIconBox->_x1, L0055_pi_ChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18); + + _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(L0056_puc_Bitmap, _g613_mousePointerOriginalColorsChampionIcon, 32, 18, 32, 18, G0045_auc_Graphic562_PaletteChanges_MousePointerIconShadow); + + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, _g613_mousePointerOriginalColorsChampionIcon, G0622_s_Box_MousePointer_ChampionIcon, L0055_pi_ChampionIconBox->_x1, L0055_pi_ChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18); + + _vm->_displayMan->D24_fillScreenBox(*L0055_pi_ChampionIconBox, k0_ColorBlack); + _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(champIconIndex); + } else { + _vm->_eventMan->_g598_mousePointerBitmapUpdated = true; + L0052_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap); + _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone); + L0054_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(L0052_ui_ChampionIconIndex + _vm->_dungeonMan->_g308_partyDir)); + if (L0052_ui_ChampionIconIndex == champIconIndex) { + setFlag(_vm->_championMan->_gK71_champions[L0054_i_ChampionIndex]._attributes, k0x0400_ChampionAttributeIcon); + _vm->_championMan->f292_drawChampionState((ChampionIndex)L0054_i_ChampionIndex); + } else { + L0053_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir)); + if (L0053_i_ChampionIndex >= 0) { + _vm->_championMan->_gK71_champions[L0053_i_ChampionIndex]._cell = (ViewCell)M21_normalizeModulo4(L0052_ui_ChampionIconIndex + _vm->_dungeonMan->_g308_partyDir); + setFlag(_vm->_championMan->_gK71_champions[L0053_i_ChampionIndex]._attributes, k0x0400_ChampionAttributeIcon); + _vm->_championMan->f292_drawChampionState((ChampionIndex)L0053_i_ChampionIndex); + } else { + _vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[L0052_ui_ChampionIconIndex], k0_ColorBlack); + } + _vm->_championMan->_gK71_champions[L0054_i_ChampionIndex]._cell = (ViewCell)M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir); + setFlag(_vm->_championMan->_gK71_champions[L0054_i_ChampionIndex]._attributes, k0x0400_ChampionAttributeIcon); + _vm->_championMan->f292_drawChampionState((ChampionIndex)L0054_i_ChampionIndex); + } + } + _gK100_preventBuildPointerScreenArea = false; + f73_buildpointerScreenArea(_mousePos.x, _mousePos.y); +} } // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index fb983bfaad..742582652c 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -299,6 +299,7 @@ public: void f364_commandTakeStairs(bool stairsGoDown);// @ F0364_COMMAND_TakeStairs void f367_commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX, int16 posY); // @ F0367_COMMAND_ProcessTypes12To27_ClickInChampionStatusBox + void f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex); // @ F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon }; -- cgit v1.2.3 From 1e8dfd7bb6b86ce5d4d2827bf692b217afbb07b1 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 12 Jul 2016 14:38:52 +0200 Subject: DM: Add f370_commandProcessType100_clickInSpellArea --- engines/dm/champion.cpp | 30 +++- engines/dm/champion.h | 53 +++++- engines/dm/dungeonman.cpp | 2 +- engines/dm/dungeonman.h | 1 + engines/dm/eventman.cpp | 112 ++++++++++++- engines/dm/eventman.h | 2 + engines/dm/inventory.cpp | 27 ++- engines/dm/menus.cpp | 411 ++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/menus.h | 12 ++ engines/dm/movesens.cpp | 5 +- 10 files changed, 635 insertions(+), 20 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index fdbdc0914c..906c95bf47 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1298,7 +1298,7 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) } if (L0906_T_SlotThing != Thing::_none) { f300_getObjectRemovedFromSlot(L0903_ui_ChampionIndex, L0904_ui_SlotIndex); - f297_putObjectInLeaderHand(L0906_T_SlotThing, false); + f297_putObjectInLeaderHand(L0906_T_SlotThing, false); } if (L0905_T_LeaderHandObject != Thing::_none) { _vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0903_ui_ChampionIndex, L0905_T_LeaderHandObject, (ChampionSlot)L0904_ui_SlotIndex); @@ -1307,6 +1307,34 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) _vm->_eventMan->f77_hideMouse(); } +bool ChampionMan::f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount) { + int16 L0991_i_StepEnergy; + Champion* L0992_ps_Champion; + + L0992_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + if (L0992_ps_Champion->_currMana < requiredManaAmount) { + return false; + } + L0992_ps_Champion->_currMana -= requiredManaAmount; + setFlag(L0992_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); + L0991_i_StepEnergy = 10 - MIN(8, L0992_ps_Champion->_maxMana >> 3); + if (kineticEnergy < (L0991_i_StepEnergy << 2)) { + kineticEnergy += 3; + L0991_i_StepEnergy--; + } + f326_championShootProjectile(L0992_ps_Champion, thing, kineticEnergy, 90, L0991_i_StepEnergy); + return true; // fix BUG_01 +} + +void ChampionMan::f326_championShootProjectile(Champion* champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy) { + uint16 L0990_ui_Direction; + + L0990_ui_Direction = champ->_dir; + _vm->_projexpl->f212_projectileCreate(thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, M21_normalizeModulo4((((champ->_cell - L0990_ui_Direction + 1) & 0x0002) >> 1) + L0990_ui_Direction), (direction)L0990_ui_Direction, kineticEnergy, attack, stepEnergy); + _vm->_g311_projectileDisableMovementTicks = 4; + _vm->_g312_lastProjectileDisabledMovementDirection = L0990_ui_Direction; +} + ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) { for (uint16 i = 0; i < _g305_partyChampionCount; ++i) { if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 37ca363e50..2bae7c5947 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -448,7 +448,53 @@ public: #define k0x8000_maskUseSharpDefense 0x8000 // @ MASK0x8000_USE_SHARP_DEFENSE #define k0x8000_mergeCycles 0x8000 // @ MASK0x8000_MERGE_CYCLES -extern const char *g417_baseSkillName[4]; +// TODO: localization +extern const char *g417_baseSkillName[4]; // @ G0417_apc_BaseSkillNames + +#define k0_spellCastFailure 0 // @ C0_SPELL_CAST_FAILURE +#define k1_spellCastSuccess 1 // @ C1_SPELL_CAST_SUCCESS +#define k3_spellCastFailureNeedsFlask 3 // @ C3_SPELL_CAST_FAILURE_NEEDS_FLASK + +#define k0_failureNeedsMorePractice 0 // @ C00_FAILURE_NEEDS_MORE_PRACTICE +#define k1_failureMeaninglessSpell 1 // @ C01_FAILURE_MEANINGLESS_SPELL +#define k10_failureNeedsFlaskInHand 10 // @ C10_FAILURE_NEEDS_FLASK_IN_HAND +#define k11_failureNeedsMagicMapInHand 11 // @ C11_FAILURE_NEEDS_MAGIC_MAP_IN_HAND + +#define k1_spellKindPotion 1 // @ C1_SPELL_KIND_POTION +#define k2_spellKindProjectile 2 // @ C2_SPELL_KIND_PROJECTILE +#define k3_spellKindOther 3 // @ C3_SPELL_KIND_OTHER +#define k4_spellKindMagicMap 4 // @ C4_SPELL_KIND_MAGIC_MAP + +#define k4_spellType_projectileOpenDoor 4 // @ C4_SPELL_TYPE_PROJECTILE_OPEN_DOOR +#define k0_spellType_otherLight 0 // @ C0_SPELL_TYPE_OTHER_LIGHT +#define k1_spellType_otherDarkness 1 // @ C1_SPELL_TYPE_OTHER_DARKNESS +#define k2_spellType_otherThievesEye 2 // @ C2_SPELL_TYPE_OTHER_THIEVES_EYE +#define k3_spellType_otherInvisibility 3 // @ C3_SPELL_TYPE_OTHER_INVISIBILITY +#define k4_spellType_otherPartyShield 4 // @ C4_SPELL_TYPE_OTHER_PARTY_SHIELD +#define k5_spellType_otherMagicTorch 5 // @ C5_SPELL_TYPE_OTHER_MAGIC_TORCH +#define k6_spellType_otherFootprints 6 // @ C6_SPELL_TYPE_OTHER_FOOTPRINTS +#define k7_spellType_otherZokathra 7 // @ C7_SPELL_TYPE_OTHER_ZOKATHRA +#define k8_spellType_otherFireshield 8 // @ C8_SPELL_TYPE_OTHER_FIRESHIELD +#define k0_spellType_magicMap0 0 // @ C0_SPELL_TYPE_MAGIC_MAP +#define k1_spellType_magicMap1 1 // @ C1_SPELL_TYPE_MAGIC_MAP +#define k2_spellType_magicMap2 2 // @ C2_SPELL_TYPE_MAGIC_MAP +#define k3_spellType_magicMap3 3 // @ C3_SPELL_TYPE_MAGIC_MAP + +class Spell { +public: + Spell() {} + Spell(int32 symbols, byte baseSkillReq, byte skillIndex, uint16 attributes) + : _symbols(symbols), _baseRequiredSkillLevel(baseSkillReq), _skillIndex(skillIndex), _attributes(attributes) {} + + int32 _symbols; /* Most significant byte: 0 (spell definition does not include power symbol) / not 0 (spell definition includes power symbol) */ + byte _baseRequiredSkillLevel; + byte _skillIndex; + uint16 _attributes; /* Bits 15-10: Duration, Bits 9-4: Type, Bits 3-0: Kind */ + + uint16 M67_spellKind() { return _attributes & 0xF; } // @ M67_SPELL_KIND + uint16 M68_spellType() { return (_attributes >> 4) & 0x3F; } // @ M68_SPELL_TYPE + uint16 M69_spellDurration() { return (_attributes >> 10) & 0x3F; } // @ M69_SPELL_DURATION +}; // @ SPELL class ChampionMan { DMEngine *_vm; @@ -526,8 +572,9 @@ public: void f293_drawAllChampionStates(); // @ F0293_CHAMPION_DrawAllChampionStates void f283_viAltarRebirth(uint16 champIndex); // @ F0283_CHAMPION_ViAltarRebirth void f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex); // @ F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox - - + bool f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount); // @ F0327_CHAMPION_IsProjectileSpellCast + void f326_championShootProjectile(Champion *champ, Thing thing, int16 kineticEnergy, + int16 attack, int16 stepEnergy); // @ F0326_CHAMPION_ShootProjectile }; diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index d88363a0b3..7d916196b4 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1252,7 +1252,7 @@ uint16 DungeonMan::f140_getObjectWeight(Thing thing) { }; Junk* junk; - uint16 weight; + uint16 weight = (uint16)-1; // initialization is not present in original if (thing == Thing::_none) return 0; diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index ca01034d96..305a9219d9 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -452,6 +452,7 @@ public: void setType(PotionType val) { _attributes = (_attributes & ~(0x7F << 8)) | ((val & 0x7F) << 8); } Thing getNextThing() { return _nextThing; } uint16 getPower() { return _attributes & 0xFF; } + void setPower(uint16 val) { _attributes = (_attributes & ~0xFF) | (val & 0xFF); } uint16 getDoNotDiscard() { return (_attributes >> 15) & 1; } }; // @ POTION diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index f74c8067af..6be06e6040 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -661,7 +661,7 @@ void EventManager::f380_processCommandQueue() { } if ((cmdType >= k28_CommandClickOnSlotBoxInventoryReadyHand) && (cmdType < (k65_CommandClickOnSlotBoxChest_8 + 1))) { if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) { - warning(false, "MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox(cmdType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);"); + _vm->_championMan->f302_processCommands28to65_clickOnSlotBox(cmdType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand); } return; } @@ -679,7 +679,7 @@ void EventManager::f380_processCommandQueue() { } if (cmdType == k100_CommandClickInSpellArea) { if ((!_vm->_championMan->_g299_candidateChampionOrdinal) && (_vm->_championMan->_g514_magicCasterChampionIndex != kM1_ChampionNone)) { - warning(false, "MISSING CODE: F0370_COMMAND_ProcessType100_ClickInSpellArea(L1161_i_CommandX, L1162_i_CommandY);"); + f370_commandProcessType100_clickInSpellArea(L1161_i_CommandX, L1162_i_CommandY); } return; } @@ -1304,7 +1304,7 @@ void EventManager::f367_commandProcessTypes12to27_clickInChampionStatusBox(uint1 void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex) { static Box G0621_s_Box_MousePointer_ChampionIconShadow = Box(2, 20, 2, 15); static Box G0622_s_Box_MousePointer_ChampionIcon = Box(0, 18, 0, 13); - static byte G0045_auc_Graphic562_PaletteChanges_MousePointerIconShadow[16] = {0, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, 120, 120, 120}; + static byte G0045_auc_Graphic562_PaletteChanges_MousePointerIconShadow[16] = {0, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, 120, 120, 120}; uint16 L0052_ui_ChampionIconIndex; int16 L0053_i_ChampionIndex; @@ -1359,4 +1359,110 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c _gK100_preventBuildPointerScreenArea = false; f73_buildpointerScreenArea(_mousePos.x, _mousePos.y); } + +void EventManager::f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY) { + int16 L1132_i_Command; + int16 L1133_i_ChampionIndex; + + + L1133_i_ChampionIndex = kM1_ChampionNone; + if (posY <= 48) { + switch (_vm->_championMan->_g514_magicCasterChampionIndex) { + case 0: + if ((posX >= 280) && (posX <= 291)) { + L1133_i_ChampionIndex = 1; + } else { + if ((posX >= 294) && (posX <= 305)) { + L1133_i_ChampionIndex = 2; + } else { + if (posX >= 308) { + L1133_i_ChampionIndex = 3; + } + } + } + break; + case 1: + if ((posX >= 233) && (posX <= 244)) { + L1133_i_ChampionIndex = 0; + } else { + if ((posX >= 294) && (posX <= 305)) { + L1133_i_ChampionIndex = 2; + } else { + if (posX >= 308) { + L1133_i_ChampionIndex = 3; + } + } + } + break; + case 2: + if ((posX >= 233) && (posX <= 244)) { + L1133_i_ChampionIndex = 0; + } else { + if ((posX >= 247) && (posX <= 258)) { + L1133_i_ChampionIndex = 1; + } else { + if (posX >= 308) { + L1133_i_ChampionIndex = 3; + } + } + } + break; + case 3: + if ((posX >= 247) && (posX <= 258)) { + L1133_i_ChampionIndex = 1; + } else { + if ((posX >= 261) && (posX <= 272)) { + L1133_i_ChampionIndex = 2; + } else { + if (posX <= 244) { + L1133_i_ChampionIndex = 0; + } + } + } + } + if ((L1133_i_ChampionIndex != kM1_ChampionNone) && (L1133_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount)) { + _vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(L1133_i_ChampionIndex); + } + return; + } + L1132_i_Command = _vm->_eventMan->f358_getCommandTypeFromMouseInput(g454_MouseInput_SpellArea, Common::Point(posX, posY), k1_LeftMouseButton); + if (L1132_i_Command != k0_CommandNone) { + f369_commandProcessTypes101To108_clickInSpellSymbolsArea((CommandType)L1132_i_Command); + } +} + +void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType) { + static Box G0464_as_Graphic561_Box_SpellSymbolsAndDelete[7] = { + /* { X1, X2, Y1, Y2 } */ + Box(235, 247, 51, 61), /* Symbol 1 */ + Box(249, 261, 51, 61), /* Symbol 2 */ + Box(263, 275, 51, 61), /* Symbol 3 */ + Box(277, 289, 51, 61), /* Symbol 4 */ + Box(291, 303, 51, 61), /* Symbol 5 */ + Box(305, 317, 51, 61), /* Symbol 6 */ + Box(305, 318, 63, 73)}; /* Delete */ + + uint16 L1130_ui_SymbolIndex; + Box* L1131_ps_Box; + + + if (cmdType == k108_CommandClickInSpeallAreaCastSpell) { + if (_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex]._symbols[0] == '\0') { + return; + } + warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable"); + _vm->_g321_stopWaitingForPlayerInput = _vm->_menuMan->f408_getClickOnSpellCastResult(); + return; + } + L1130_ui_SymbolIndex = cmdType - k101_CommandClickInSpellAreaSymbol_1; + L1131_ps_Box = &G0464_as_Graphic561_Box_SpellSymbolsAndDelete[L1130_ui_SymbolIndex]; + warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable"); + _vm->f22_delay(1); + warning(false, "MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); + if (L1130_ui_SymbolIndex < 6) { + _vm->_menuMan->f399_addChampionSymbol(L1130_ui_SymbolIndex); + } else { + _vm->_menuMan->f400_deleteChampionSymbol(); + } +} } // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index 742582652c..7ad24a7e88 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -300,6 +300,8 @@ public: void f367_commandProcessTypes12to27_clickInChampionStatusBox(uint16 champIndex, int16 posX, int16 posY); // @ F0367_COMMAND_ProcessTypes12To27_ClickInChampionStatusBox void f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex); // @ F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon + void f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY); // @ F0370_COMMAND_ProcessType100_ClickInSpellArea + void f369_commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType); // @ F0369_COMMAND_ProcessTypes101To108_ClickInSpellSymbolsArea_CPSE }; diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index a0c6e57e9c..1a15d44d30 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -675,6 +675,24 @@ void InventoryMan::f338_decreaseTorchesLightPower() { } void InventoryMan::f351_drawChampionSkillsAndStatistics() { + // TODO: localization + static char* G0428_apc_SkillLevelNames[15] = { + "NEOPHYTE", + "NOVICE", + "APPRENTICE", + "JOURNEYMAN", + "CRAFTSMAN", + "ARTISAN", + "ADEPT", + "EXPERT", + "` MASTER", + "a MASTER", + "b MASTER", + "c MASTER", + "d MASTER", + "e MASTER", + "ARCHMASTER"}; + uint16 L1090_ui_Multiple; #define AL1090_ui_SkillIndex L1090_ui_Multiple #define AL1090_ui_StatisticIndex L1090_ui_Multiple @@ -699,16 +717,9 @@ void InventoryMan::f351_drawChampionSkillsAndStatistics() { AL1092_i_SkillLevel = MIN((uint16)16, _vm->_championMan->f303_getSkillLevel(L1093_ui_ChampionIndex, AL1090_ui_SkillIndex | k0x8000_IgnoreTemporaryExperience)); if (AL1092_i_SkillLevel == 1) continue; -#ifdef COMPILE17_DM10aEN_DM10bEN_DM11EN_DM12EN_CSB20EN_CSB21EN_DMDEMO20EN_DM20EN_DM21EN_DM22EN /* CHANGE4_00_LOCALIZATION Translation to German language */ strcpy(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]); strcat(L1097_ac_String, " "); - strcat(L1097_ac_String, G0417_apc_BaseSkillNames[AL1090_ui_SkillIndex]); -#endif -#ifdef COMPILE36_DM12GE_DM13aFR_DM13bFR_DM20GE_DM20FR_DM22GE /* CHANGE4_00_LOCALIZATION Translation to German language */ - strcpy(L1097_ac_String, G0417_apc_BaseSkillNames[AL1090_ui_SkillIndex]); - strcat(L1097_ac_String, " "); - strcat(L1097_ac_String, G0428_apc_SkillLevelNames[AL1092_i_SkillLevel - 2]); -#endif + strcat(L1097_ac_String, g417_baseSkillName[AL1090_ui_SkillIndex]); _vm->_textMan->f52_printToViewport(108, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String); L1091_i_Y += 7; } diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index d63cab0012..d35ec7553a 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -33,6 +33,8 @@ #include "inventory.h" #include "text.h" #include "eventman.h" +#include "timeline.h" +#include "movesens.h" namespace DM { @@ -402,4 +404,413 @@ void MenuMan::f457_drawEnabledMenus() { } } +int16 MenuMan::f408_getClickOnSpellCastResult() { + int16 L1259_i_SpellCastResult; + Champion* L1260_ps_Champion; + + + L1260_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex]; + _vm->_eventMan->f78_showMouse(); + warning(false, "MISSING CODE: F0363_COMMAND_HighlightBoxDisable"); + if ((L1259_i_SpellCastResult = f412_getChampionSpellCastResult(_vm->_championMan->_g514_magicCasterChampionIndex)) != k3_spellCastFailureNeedsFlask) { + L1260_ps_Champion->_symbols[0] = '\0'; + f397_drawAvailableSymbols(L1260_ps_Champion->_symbolStep = 0); + f398_drawChampionSymbols(L1260_ps_Champion); + } else { + L1259_i_SpellCastResult = k0_spellCastFailure; + } + _vm->_eventMan->f77_hideMouse(); + return L1259_i_SpellCastResult; +} + +int16 MenuMan::f412_getChampionSpellCastResult(uint16 champIndex) { + uint16 L1267_ui_Multiple; +#define AL1267_ui_SkillLevel L1267_ui_Multiple +#define AL1267_ui_LightPower L1267_ui_Multiple +#define AL1267_ui_SpellPower L1267_ui_Multiple +#define AL1267_ui_Ticks L1267_ui_Multiple + int16 L1268_i_PowerSymbolOrdinal; + uint16 L1269_ui_Multiple; +#define AL1269_ui_RequiredSkillLevel L1269_ui_Multiple +#define AL1269_ui_EmptyFlaskWeight L1269_ui_Multiple +#define AL1269_ui_Ticks L1269_ui_Multiple + Champion* L1270_ps_Champion; + Spell* L1271_ps_Spell; + Thing L1272_T_Object; + uint16 L1273_ui_Experience; + int16 L1274_i_MissingSkillLevelCount; + Potion* L1275_ps_Potion; + TimelineEvent L1276_s_Event; + Junk* L1277_ps_Junk; + + + if (champIndex >= _vm->_championMan->_g305_partyChampionCount) { + return k0_spellCastFailure; + } + L1270_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + if (!(L1270_ps_Champion->_currHealth)) { + return k0_spellCastFailure; + } + if ((L1271_ps_Spell = f409_getSpellFromSymbols((unsigned char *)L1270_ps_Champion->_symbols)) == 0) { + f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k1_spellCastSuccess, 0); + return k0_spellCastFailure; + } + L1268_i_PowerSymbolOrdinal = L1270_ps_Champion->_symbols[0] - '_'; /* Values 1 to 6 */ + L1273_ui_Experience = _vm->getRandomNumber(8) + ((AL1269_ui_RequiredSkillLevel = L1271_ps_Spell->_baseRequiredSkillLevel + L1268_i_PowerSymbolOrdinal) << 4) + ((_vm->M1_ordinalToIndex(L1268_i_PowerSymbolOrdinal) * L1271_ps_Spell->_baseRequiredSkillLevel) << 3) + (AL1269_ui_RequiredSkillLevel * AL1269_ui_RequiredSkillLevel); + AL1267_ui_SkillLevel = _vm->_championMan->f303_getSkillLevel(champIndex, L1271_ps_Spell->_skillIndex); + if (AL1267_ui_SkillLevel < AL1269_ui_RequiredSkillLevel) { + L1274_i_MissingSkillLevelCount = AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel; + while (L1274_i_MissingSkillLevelCount--) { + if (_vm->getRandomNumber(128) > MIN(L1270_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + 15, 115)) { + _vm->_championMan->f304_addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience >> (AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel)); + f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k0_failureNeedsMorePractice, L1271_ps_Spell->_skillIndex); + return k0_spellCastFailure; + } + } + } + switch (L1271_ps_Spell->M67_spellKind()) { + case k1_spellKindPotion: + if ((L1275_ps_Potion = f411_getEmptyFlaskInHand(L1270_ps_Champion, &L1272_T_Object)) == NULL) { + f410_menusPrintSpellFailureMessage(L1270_ps_Champion, k10_failureNeedsFlaskInHand, 0); + return k3_spellCastFailureNeedsFlask; + } + AL1269_ui_EmptyFlaskWeight = _vm->_dungeonMan->f140_getObjectWeight(L1272_T_Object); + L1275_ps_Potion->setType((PotionType)L1271_ps_Spell->M68_spellType()); + L1275_ps_Potion->setPower(_vm->getRandomNumber(16) + (L1268_i_PowerSymbolOrdinal * 40)); + L1270_ps_Champion->_load += _vm->_dungeonMan->f140_getObjectWeight(L1272_T_Object) - AL1269_ui_EmptyFlaskWeight; + _vm->_championMan->f296_drawChangedObjectIcons(); + if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)) { + setFlag(L1270_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad); + _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); + } + break; + case k2_spellKindProjectile: + if (L1270_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) { + L1270_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir; + setFlag(L1270_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon); + _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); + } + if (L1271_ps_Spell->M68_spellType() == k4_spellType_projectileOpenDoor) { + AL1267_ui_SkillLevel <<= 1; + } + _vm->_championMan->f327_isProjectileSpellCast(champIndex, Thing(L1271_ps_Spell->M68_spellType() + Thing::_firstExplosion.toUint16()), f26_getBoundedValue(21, (L1268_i_PowerSymbolOrdinal + 2) * (4 + (AL1267_ui_SkillLevel << 1)), 255), 0); + break; + case k3_spellKindOther: + L1276_s_Event._priority = 0; + AL1267_ui_SpellPower = (L1268_i_PowerSymbolOrdinal + 1) << 2; + switch (L1271_ps_Spell->M68_spellType()) { + case k0_spellType_otherLight: + AL1269_ui_Ticks = 10000 + ((AL1267_ui_SpellPower - 8) << 9); + AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 1); + AL1267_ui_LightPower--; + goto T0412019; + case k5_spellType_otherMagicTorch: + AL1269_ui_Ticks = 2000 + ((AL1267_ui_SpellPower - 3) << 7); + AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2); + AL1267_ui_LightPower++; +T0412019: + _vm->_championMan->_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[AL1267_ui_LightPower]; + f404_createEvent70_light(-AL1267_ui_LightPower, AL1269_ui_Ticks); + break; + case k1_spellType_otherDarkness: + AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2); + _vm->_championMan->_g407_party._magicalLightAmount -= g39_LightPowerToLightAmount[AL1267_ui_LightPower]; + f404_createEvent70_light(AL1267_ui_LightPower, 98); + break; + case k2_spellType_otherThievesEye: + L1276_s_Event._type = k73_TMEventTypeThievesEye; + _vm->_championMan->_g407_party._event73Count_ThievesEye++; + AL1267_ui_SpellPower = (AL1267_ui_SpellPower >> 1); + goto T0412032; + case k3_spellType_otherInvisibility: + L1276_s_Event._type = k71_TMEventTypeInvisibility; + _vm->_championMan->_g407_party._event71Count_Invisibility++; + goto T0412033; + case k4_spellType_otherPartyShield: + L1276_s_Event._type = k74_TMEventTypePartyShield; + L1276_s_Event._B._defense = AL1267_ui_SpellPower; + if (_vm->_championMan->_g407_party._shieldDefense > 50) { + L1276_s_Event._B._defense >>= 2; + } + _vm->_championMan->_g407_party._shieldDefense += L1276_s_Event._B._defense; + _vm->_timeline->f260_timelineRefreshAllChampionStatusBoxes(); + goto T0412032; + case k6_spellType_otherFootprints: + L1276_s_Event._type = k79_TMEventTypeFootprints; + _vm->_championMan->_g407_party._event79Count_Footprints++; + _vm->_championMan->_g407_party._firstScentIndex = _vm->_championMan->_g407_party._scentCount; + if (L1268_i_PowerSymbolOrdinal < 3) { + _vm->_championMan->_g407_party._lastScentIndex = _vm->_championMan->_g407_party._firstScentIndex; + } else { + _vm->_championMan->_g407_party._lastScentIndex = 0; + } +T0412032: + AL1267_ui_Ticks = AL1267_ui_SpellPower * AL1267_ui_SpellPower; +T0412033: + M33_setMapAndTime(L1276_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + AL1267_ui_Ticks); + _vm->_timeline->f238_addEventGetEventIndex(&L1276_s_Event); + break; + case k7_spellType_otherZokathra: + if ((L1272_T_Object = _vm->_dungeonMan->f166_getUnusedThing(k10_JunkThingType)) == Thing::_none) + break; + L1277_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1272_T_Object); + L1277_ps_Junk->setType(k51_JunkTypeZokathra); + ChampionSlot AL1267_ui_SlotIndex; + if (L1270_ps_Champion->_slots[k0_ChampionSlotReadyHand] == Thing::_none) { + AL1267_ui_SlotIndex = k0_ChampionSlotReadyHand; + } else { + if (L1270_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) { + AL1267_ui_SlotIndex = k1_ChampionSlotActionHand; + } else { + AL1267_ui_SlotIndex = kM1_ChampionSlotLeaderHand; + } + } + if ((AL1267_ui_SlotIndex == k0_ChampionSlotReadyHand) || (AL1267_ui_SlotIndex == k1_ChampionSlotActionHand)) { + _vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, L1272_T_Object, AL1267_ui_SlotIndex); + _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); + } else { + _vm->_movsens->f267_getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); + } + break; + case k8_spellType_otherFireshield: + f403_isPartySpellOrFireShieldSuccessful(L1270_ps_Champion, false, (AL1267_ui_SpellPower * AL1267_ui_SpellPower) + 100, false); + } + } + _vm->_championMan->f304_addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience); + _vm->_championMan->f330_disableAction(champIndex, L1271_ps_Spell->M69_spellDurration()); + return k1_spellCastSuccess; +} + +Spell* MenuMan::f409_getSpellFromSymbols(byte* symbols) { + static Spell G0487_as_Graphic560_Spells[25] = { + /* { Symbols, BaseRequiredSkillLevel, SkillIndex, Attributes } */ + Spell(0x00666F00, 2, 15, 0x7843), + Spell(0x00667073, 1, 18, 0x4863), + Spell(0x00686D77, 3, 17, 0xB433), + Spell(0x00686C00, 3, 19, 0x6C72), + Spell(0x00686D76, 3, 18, 0x8423), + Spell(0x00686E76, 4, 17, 0x7822), + Spell(0x00686F76, 4, 17, 0x5803), + Spell(0x00690000, 1, 16, 0x3C53), + Spell(0x00696F00, 3, 16, 0xA802), + Spell(0x00697072, 4, 13, 0x3C71), + Spell(0x00697075, 4, 15, 0x7083), + Spell(0x006A6D00, 1, 18, 0x5032), + Spell(0x006A6C00, 1, 19, 0x4062), + Spell(0x006A6F77, 1, 15, 0x3013), + Spell(0x006B0000, 1, 17, 0x3C42), + Spell(0x00667000, 2, 15, 0x64C1), + Spell(0x00660000, 2, 13, 0x3CB1), + Spell(0x00667074, 4, 13, 0x3C81), + Spell(0x00667075, 4, 13, 0x3C91), + Spell(0x00670000, 1, 13, 0x80E1), + Spell(0x00677000, 1, 13, 0x68A1), + Spell(0x00687073, 4, 13, 0x3C61), + Spell(0x006B7076, 3, 2, 0xFCD1), + Spell(0x006B6C00, 2, 19, 0x7831), + Spell(0x006B6E76, 0, 3, 0x3C73)}; + + + int32 L1261_l_Symbols; + int16 L1262_i_Multiple; +#define AL1262_i_BitShiftCount L1262_i_Multiple +#define AL1262_i_SpellIndex L1262_i_Multiple + Spell* L1263_ps_Spell; + + + if (*(symbols + 1)) { + AL1262_i_BitShiftCount = 24; + L1261_l_Symbols = 0; + do { + L1261_l_Symbols |= (long)*symbols++ << AL1262_i_BitShiftCount; + } while (*symbols && ((AL1262_i_BitShiftCount -= 8) >= 0)); + L1263_ps_Spell = G0487_as_Graphic560_Spells; + AL1262_i_SpellIndex = 25; + while (AL1262_i_SpellIndex--) { + if (L1263_ps_Spell->_symbols & 0xFF000000) { /* If byte 1 of spell is not 0 then the spell includes the power symbol */ + if (L1261_l_Symbols == L1263_ps_Spell->_symbols) { /* Compare champion symbols, including power symbol, with spell (never used with actual spells) */ + return L1263_ps_Spell; + } + } else { + if ((L1261_l_Symbols & 0x00FFFFFF) == L1263_ps_Spell->_symbols) { /* Compare champion symbols, except power symbol, with spell */ + return L1263_ps_Spell; + } + } + L1263_ps_Spell++; + } + } + return NULL; +} + +void MenuMan::f410_menusPrintSpellFailureMessage(Champion* champ, uint16 failureType, uint16 skillIndex) { + char* L1264_pc_Message = nullptr; + + if (skillIndex > k3_ChampionSkillWizard) { + skillIndex = (skillIndex - 4) / 4; + } + _vm->_textMan->f51_messageAreaPrintLineFeed(); + _vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, champ->_name); + switch (failureType) { + case k0_failureNeedsMorePractice: + // TODO: localization + _vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, " NEEDS MORE PRACTICE WITH THIS "); + _vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, g417_baseSkillName[skillIndex]); + L1264_pc_Message = " SPELL."; + break; + case k1_failureMeaninglessSpell: + L1264_pc_Message = " MUMBLES A MEANINGLESS SPELL."; // TODO: localization + break; + case k10_failureNeedsFlaskInHand: + L1264_pc_Message = " NEEDS AN EMPTY FLASK IN HAND FOR POTION."; // TODO: localization + break; + } + _vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, L1264_pc_Message); +} + +Potion* MenuMan::f411_getEmptyFlaskInHand(Champion* champ, Thing* potionThing) { + Thing L1265_T_Thing; + int16 L1266_i_SlotIndex; + + for (L1266_i_SlotIndex = k2_ChampionSlotHead; --L1266_i_SlotIndex >= k0_ChampionSlotReadyHand; ) { + if (((L1265_T_Thing = champ->_slots[L1266_i_SlotIndex]) != Thing::_none) && (_vm->_objectMan->f33_getIconIndex(L1265_T_Thing) == k195_IconIndicePotionEmptyFlask)) { + *potionThing = L1265_T_Thing; + return (Potion*)_vm->_dungeonMan->f156_getThingData(L1265_T_Thing); + } + } + return nullptr; +} + +void MenuMan::f404_createEvent70_light(int16 lightPower, int16 ticks) { + TimelineEvent L1241_s_Event; + + L1241_s_Event._type = k70_TMEventTypeLight; + L1241_s_Event._B._lightPower = lightPower; + M33_setMapAndTime(L1241_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + ticks); + L1241_s_Event._priority = 0; + _vm->_timeline->f238_addEventGetEventIndex(&L1241_s_Event); + _vm->_inventoryMan->f337_setDungeonViewPalette(); +} + +bool MenuMan::f403_isPartySpellOrFireShieldSuccessful(Champion* champ, bool spellShield, uint16 ticks, bool useMana) { + bool L1239_B_IsPartySpellOrFireShieldSuccessful; + TimelineEvent L1240_s_Event; + + + L1239_B_IsPartySpellOrFireShieldSuccessful = true; + if (useMana) { + if (champ->_currMana == 0) { + return false; + } + if (champ->_currMana < 4) { + ticks >>= 1; + champ->_currMana = 0; + L1239_B_IsPartySpellOrFireShieldSuccessful = false; + } else { + champ->_currMana -= 4; + } + } + L1240_s_Event._B._defense = ticks >> 5; + if (spellShield) { + L1240_s_Event._type = k77_TMEventTypeSpellShield; + if (_vm->_championMan->_g407_party._spellShieldDefense > 50) { + L1240_s_Event._B._defense >>= 2; + } + _vm->_championMan->_g407_party._spellShieldDefense += L1240_s_Event._B._defense; + } else { + L1240_s_Event._type = k78_TMEventTypeFireShield; + if (_vm->_championMan->_g407_party._fireShieldDefense > 50) { + L1240_s_Event._B._defense >>= 2; + } + _vm->_championMan->_g407_party._fireShieldDefense += L1240_s_Event._B._defense; + } + L1240_s_Event._priority = 0; + M33_setMapAndTime(L1240_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + ticks); + _vm->_timeline->f238_addEventGetEventIndex(&L1240_s_Event); + _vm->_timeline->f260_timelineRefreshAllChampionStatusBoxes(); + return L1239_B_IsPartySpellOrFireShieldSuccessful; +} + +void MenuMan::f397_drawAvailableSymbols(uint16 symbolStep) { + uint16 L1214_ui_Counter; + int16 L1215_i_X; + char L1216_c_Character; + char L1217_ac_String[2]; + + L1217_ac_String[1] = '\0'; + L1216_c_Character = 96 + 6 * symbolStep; + L1215_i_X = 225; + for (L1214_ui_Counter = 0; L1214_ui_Counter < 6; L1214_ui_Counter++) { + L1217_ac_String[0] = L1216_c_Character++; + _vm->_textMan->f53_printToLogicalScreen(L1215_i_X += 14, 58, k4_ColorCyan, k0_ColorBlack, L1217_ac_String); + } +} + +void MenuMan::f398_drawChampionSymbols(Champion* champ) { + uint16 L1218_ui_SymbolIndex; + int16 L1219_i_X; + uint16 L1220_ui_SymbolCount; + char L1221_ac_String[2]; + + + L1220_ui_SymbolCount = strlen(champ->_symbols); + L1219_i_X = 232; + L1221_ac_String[1] = '\0'; + for (L1218_ui_SymbolIndex = 0; L1218_ui_SymbolIndex < 4; L1218_ui_SymbolIndex++) { + if (L1218_ui_SymbolIndex >= L1220_ui_SymbolCount) { + L1221_ac_String[0] = ' '; + } else { + L1221_ac_String[0] = champ->_symbols[L1218_ui_SymbolIndex]; + } + _vm->_textMan->f53_printToLogicalScreen(L1219_i_X += 9, 70, k4_ColorCyan, k0_ColorBlack, L1221_ac_String); + } +} + +void MenuMan::f399_addChampionSymbol(int16 symbolIndex) { + static byte G0485_aauc_Graphic560_SymbolBaseManaCost[4][6] = { + {1, 2, 3, 4, 5, 6}, /* Power 1 */ + {2, 3, 4, 5, 6, 7}, /* Power 2 */ + {4, 5, 6, 7, 7, 9}, /* Power 3 */ + {2, 2, 3, 4, 6, 7}}; /* Power 4 */ + static byte G0486_auc_Graphic560_SymbolManaCostMultiplier[6] = {8, 12, 16, 20, 24, 28}; + + uint16 L1222_ui_SymbolStep; + uint16 L1223_ui_ManaCost; + uint16 L1224_ui_SymbolIndex; + Champion* L1225_ps_Champion; + + L1225_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex]; + L1222_ui_SymbolStep = L1225_ps_Champion->_symbolStep; + L1223_ui_ManaCost = G0485_aauc_Graphic560_SymbolBaseManaCost[L1222_ui_SymbolStep][symbolIndex]; + if (L1222_ui_SymbolStep) { + L1223_ui_ManaCost = (L1223_ui_ManaCost * G0486_auc_Graphic560_SymbolManaCostMultiplier[L1224_ui_SymbolIndex = L1225_ps_Champion->_symbols[0] - 96]) >> 3; + } + if (L1223_ui_ManaCost <= L1225_ps_Champion->_currMana) { + L1225_ps_Champion->_currMana -= L1223_ui_ManaCost; + setFlag(L1225_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); + L1225_ps_Champion->_symbols[L1222_ui_SymbolStep] = 96 + (L1222_ui_SymbolStep * 6) + symbolIndex; + L1225_ps_Champion->_symbols[L1222_ui_SymbolStep + 1] = '\0'; + L1225_ps_Champion->_symbolStep = L1222_ui_SymbolStep = returnNextVal(L1222_ui_SymbolStep); + _vm->_eventMan->f78_showMouse(); + f397_drawAvailableSymbols(L1222_ui_SymbolStep); + f398_drawChampionSymbols(L1225_ps_Champion); + _vm->_championMan->f292_drawChampionState(_vm->_championMan->_g514_magicCasterChampionIndex); + _vm->_eventMan->f77_hideMouse(); + } +} + +void MenuMan::f400_deleteChampionSymbol() { + int16 L1226_ui_SymbolStep; + Champion* L1228_ps_Champion; + + L1228_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex]; + if (!strlen(L1228_ps_Champion->_symbols)) { + return; + } + L1228_ps_Champion->_symbolStep = L1226_ui_SymbolStep = returnPrevVal(L1228_ps_Champion->_symbolStep); + L1228_ps_Champion->_symbols[L1226_ui_SymbolStep] = '\0'; + _vm->_eventMan->f78_showMouse(); + f397_drawAvailableSymbols(L1226_ui_SymbolStep); + f398_drawChampionSymbols(L1228_ps_Champion); + _vm->_eventMan->f77_hideMouse(); +} } diff --git a/engines/dm/menus.h b/engines/dm/menus.h index 9c93fd00a7..0aabcab3f0 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -30,6 +30,7 @@ #include "dm.h" #include "champion.h" +#include "dungeonman.h" namespace DM { @@ -73,6 +74,17 @@ public: void f392_buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine void f394_setMagicCasterAndDrawSpellArea(int16 champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea void f457_drawEnabledMenus(); // @ F0457_START_DrawEnabledMenus_CPSF + int16 f408_getClickOnSpellCastResult(); // @ F0408_MENUS_GetClickOnSpellCastResult + int16 f412_getChampionSpellCastResult(uint16 champIndex); // @ F0412_MENUS_GetChampionSpellCastResult + Spell *f409_getSpellFromSymbols(byte *symbols); // @ F0409_MENUS_GetSpellFromSymbols + void f410_menusPrintSpellFailureMessage(Champion *champ, uint16 failureType, uint16 skillIndex); // @ F0410_MENUS_PrintSpellFailureMessage + Potion *f411_getEmptyFlaskInHand(Champion *champ, Thing *potionThing); // @ F0411_MENUS_GetEmptyFlaskInHand + void f404_createEvent70_light(int16 lightPower, int16 ticks); // @ F0404_MENUS_CreateEvent70_Light + bool f403_isPartySpellOrFireShieldSuccessful(Champion *champ, bool spellShield, uint16 ticks, bool useMana); // @ F0403_MENUS_IsPartySpellOrFireShieldSuccessful + void f397_drawAvailableSymbols(uint16 symbolStep); // @ F0397_MENUS_DrawAvailableSymbols + void f398_drawChampionSymbols(Champion *champ); // @ F0398_MENUS_DrawChampionSymbols + void f399_addChampionSymbol(int16 symbolIndex); // @ F0399_MENUS_AddChampionSymbol + void f400_deleteChampionSymbol(); // @ F0400_MENUS_DeleteChampionSymbol }; } diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index f154053b87..6cb159a205 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -845,10 +845,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m goto T0276079; break; case k5_SensorFloorPartyOnStairs: - // Strangerke: Only present in v2.1, but it fixes a bug so we'll keep it. -#ifdef COMPILE52_CSB21EN /* CHANGE8_05_FIX The wrong variable is replaced by the correct variable in the condition. The test should not be on L0771_ui_ThingType but on L0767_i_ThingType */ - if ((L0767_i_ThingType != kM1_PartyThingType) || (M34_SQUARE_TYPE(L0777_ui_Square) != k3_ElementTypeStairs)) -#endif + if ((L0767_i_ThingType != kM1_PartyThingType) || (Square(L0777_ui_Square).getType() != k3_ElementTypeStairs)) goto T0276079; break; case k6_SensorFloorGroupGenerator: -- cgit v1.2.3 From b4bebaa845ecd729576e143818fcc7b378262b5b Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 13 Jul 2016 15:01:00 +0200 Subject: DM: Add f371_commandProcessType111To115_ClickInActionArea and it's dependencies --- engines/dm/TODOs/todo.txt | 4 +- engines/dm/champion.cpp | 2 +- engines/dm/dungeonman.cpp | 2 +- engines/dm/dungeonman.h | 3 + engines/dm/eventman.cpp | 41 ++- engines/dm/eventman.h | 1 + engines/dm/group.cpp | 240 +++++++++++++ engines/dm/group.h | 10 +- engines/dm/menus.cpp | 864 ++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/menus.h | 31 ++ engines/dm/movesens.cpp | 2 +- engines/dm/timeline.h | 2 +- 12 files changed, 1194 insertions(+), 8 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 4839d2d781..9137975b9f 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -6,7 +6,9 @@ Bugs: Logic: When object are put on the right side of the current square, they disappear - Drawing door ornaments segfaults when going back to the start + Drawing door ornaments segfaults when going back to the start + !! It seems that that deleted events' _type fields are not getting set to 0, when looking for available slots, the code looks for events with 0 _type fields, + this results in segfaults Possible bugs: - k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 906c95bf47..b9c286ac92 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1059,7 +1059,7 @@ bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) { if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage)) { return true; } - register unsigned char* L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck]; + unsigned char* L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck]; AP0646_ui_IsLucky = (_vm->getRandomNumber(L0928_puc_Statistic[k1_ChampionStatCurrent]) > percentage); L0928_puc_Statistic[k1_ChampionStatCurrent] = f26_getBoundedValue((int32)L0928_puc_Statistic[k2_ChampionStatMinimum], (int32)L0928_puc_Statistic[k1_ChampionStatCurrent] + (AP0646_ui_IsLucky ? -2 : 2), (int32)L0928_puc_Statistic[k0_ChampionStatMaximum]); return AP0646_ui_IsLucky; diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 7d916196b4..3d1f931edb 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -795,7 +795,7 @@ Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 st int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) { uint16 L0260_ui_ThingIndex; int16 L0261_i_MapY; - register unsigned char* L0262_puc_Square; + unsigned char* L0262_puc_Square; L0262_puc_Square = _vm->_dungeonMan->_g271_currMapData[mapX]; diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 305a9219d9..515ef93413 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -379,6 +379,7 @@ public: uint16 getChargeCount() { return (_desc >> 10) & 0xF; } uint16 setChargeCount(uint16 val) { _desc = (_desc & ~(0xF << 10)) | ((val & 0xF) << 10); return (val & 0xF); } Thing getNextThing() { return _nextThing; } + void setNextThing(Thing val) { _nextThing = val; } uint16 getCursed() { return (_desc >> 8) & 1; } void setCursed(uint16 val) { _desc = (_desc & ~(1 << 8)) | ((val & 1) << 8); } uint16 getPoisoned() { return (_desc >> 9) & 1; } @@ -405,6 +406,8 @@ public: uint16 getCursed() { return (_attributes >> 8) & 1; } uint16 getBroken() { return (_attributes >> 13) & 1; } uint16 getDoNotDiscard() { return (_attributes >> 7) & 1; } + uint16 getChargeCount() { return (_attributes >> 9) & 0xF; } + void setChargeCount(uint16 val) { _attributes = (_attributes & ~(0xF << 9)) | ((val & 0xF) << 9); } }; // @ ARMOUR class Scroll { diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 6be06e6040..b1ffe30af6 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -685,7 +685,7 @@ void EventManager::f380_processCommandQueue() { } if (cmdType == k111_CommandClickInActionArea) { if (!_vm->_championMan->_g299_candidateChampionOrdinal) { - warning(false, "MISSING CODE: F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE(L1161_i_CommandX, L1162_i_CommandY);"); + f371_commandProcessType111To115_ClickInActionArea(L1161_i_CommandX, L1162_i_CommandY); } return; } @@ -1310,7 +1310,7 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c int16 L0053_i_ChampionIndex; int16 L0054_i_ChampionIndex; Box* L0055_pi_ChampionIconBox; - register unsigned char* L0056_puc_Bitmap; + byte* L0056_puc_Bitmap; _gK100_preventBuildPointerScreenArea = true; @@ -1465,4 +1465,41 @@ void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(Comm _vm->_menuMan->f400_deleteChampionSymbol(); } } + +void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY) { + uint16 L1134_ui_Command; + + + if (_vm->_championMan->_g506_actingChampionOrdinal) { + L1134_ui_Command = _vm->_eventMan->f358_getCommandTypeFromMouseInput(g452_MouseInput_ActionAreaNames, Common::Point(posX, posY), k1_LeftMouseButton); + if (L1134_ui_Command != k0_CommandNone) { + if (L1134_ui_Command == k112_CommandClickInActionAreaPass) { + warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable"); + _vm->_menuMan->f391_didClickTriggerAction(-1); + } else { + if ((L1134_ui_Command - k112_CommandClickInActionAreaPass) <= _vm->_menuMan->_g507_actionCount) { + if (L1134_ui_Command == k113_CommandClickInActionAreaAction_0) { + warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable"); + } else { + if (L1134_ui_Command == k114_CommandClickInActionAreaAction_1) { + warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable"); + } else { + warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable"); + } + } + _vm->_g321_stopWaitingForPlayerInput = _vm->_menuMan->f391_didClickTriggerAction(L1134_ui_Command - k113_CommandClickInActionAreaAction_0); + } + } + } + } else { + if (_vm->_menuMan->_g509_actionAreaContainsIcons) { + L1134_ui_Command = _vm->_eventMan->f358_getCommandTypeFromMouseInput(g453_MouseInput_ActionAreaIcons, Common::Point(posX, posY), k1_LeftMouseButton); + if (L1134_ui_Command != k0_CommandNone) { + if ((L1134_ui_Command = L1134_ui_Command - k116_CommandClickInActionAreaChampion_0_Action) < _vm->_championMan->_g305_partyChampionCount) { + _vm->_menuMan->f389_processCommands116To119_setActingChampion(L1134_ui_Command); + } + } + } + } +} } // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index 7ad24a7e88..24fca0f261 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -302,6 +302,7 @@ public: void f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex); // @ F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon void f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY); // @ F0370_COMMAND_ProcessType100_ClickInSpellArea void f369_commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType); // @ F0369_COMMAND_ProcessTypes101To108_ClickInSpellSymbolsArea_CPSE + void f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY); // @ F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE }; diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 49ac924333..617735e6b6 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -31,6 +31,8 @@ #include "movesens.h" #include "projexpl.h" #include "timeline.h" +#include "objectman.h" +#include "menus.h" namespace DM { @@ -1817,4 +1819,242 @@ bool GroupMan::f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY) || (L0544_i_SquareType == k5_ElementTypeTeleporter) || (L0544_i_SquareType == k2_ElementTypePit) || (L0544_i_SquareType == k4_DoorElemType)); } +int16 GroupMan::f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 partyY, uint16 champCell) { + uint16 L0321_ui_Counter; + int16 L0322_i_CreatureOrdinal; + Thing L0323_T_GroupThing; + Group* L0324_ps_Group; + signed char L0325_auc_OrderedCellsToAttack[4]; + + + if ((L0323_T_GroupThing = _vm->_groupMan->f175_groupGetThing(groupX, groupY)) == Thing::_endOfList) { + return 0; + } + L0324_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0323_T_GroupThing); + f229_setOrderedCellsToAttack(L0325_auc_OrderedCellsToAttack, groupX, groupY, partyX, partyY, champCell); + L0321_ui_Counter = 0; + for (;;) { /*_Infinite loop_*/ + if (L0322_i_CreatureOrdinal = _vm->_groupMan->f176_getCreatureOrdinalInCell(L0324_ps_Group, L0325_auc_OrderedCellsToAttack[L0321_ui_Counter])) { + return L0322_i_CreatureOrdinal; + } + L0321_ui_Counter++; + } +} + +int16 GroupMan::f231_getMeleeActionDamage(Champion* champ, int16 champIndex, Group* group, int16 creatureIndex, int16 mapX, int16 mapXóY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex) { + int16 L0565_i_Damage = 0; + int16 L0566_i_Damage = 0; + int16 L0567_i_DoubledMapDifficulty; + int16 L0568_i_Defense; + int16 L0569_i_Outcome; + bool L0570_B_ActionHitsNonMaterialCreatures; + int16 L0571_i_ActionHandObjectIconIndex; + CreatureInfo* L0572_ps_CreatureInfo; + + if (champIndex >= _vm->_championMan->_g305_partyChampionCount) { + return 0; + } + if (!champ->_currHealth) { + return 0; + } + L0567_i_DoubledMapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty << 1; + L0572_ps_CreatureInfo = &g243_CreatureInfo[group->_type]; + L0571_i_ActionHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]); + if (L0570_B_ActionHitsNonMaterialCreatures = getFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures)) { + clearFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures); + } + if ((!getFlag(L0572_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) || L0570_B_ActionHitsNonMaterialCreatures) && + ((_vm->_championMan->f311_getDexterity(champ) > (_vm->getRandomNumber(32) + L0572_ps_CreatureInfo->_dexterity + L0567_i_DoubledMapDifficulty - 16)) || + (!_vm->getRandomNumber(4)) || + (_vm->_championMan->f308_isLucky(champ, 75 - actionHitProbability)))) { + if (!(L0565_i_Damage = _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand))) { + goto T0231009; + } + L0565_i_Damage += _vm->getRandomNumber((L0565_i_Damage >> 1) + 1); + L0565_i_Damage = ((long)L0565_i_Damage * (long)actionDamageFactor) >> 5; + L0568_i_Defense = _vm->getRandomNumber(32) + L0572_ps_CreatureInfo->_defense + L0567_i_DoubledMapDifficulty; + if (L0571_i_ActionHandObjectIconIndex == k39_IconIndiceWeaponDiamondEdge) { + L0568_i_Defense -= L0568_i_Defense >> 2; + } else { + if (L0571_i_ActionHandObjectIconIndex == k43_IconIndiceWeaponHardcleaveExecutioner) { + L0568_i_Defense -= L0568_i_Defense >> 3; + } + } + if ((L0566_i_Damage = L0565_i_Damage = _vm->getRandomNumber(32) + L0565_i_Damage - L0568_i_Defense) <= 1) { +T0231009: + if (!(L0565_i_Damage = _vm->getRandomNumber(4))) { + goto T0231015; + } + L0565_i_Damage++; + if (((L0566_i_Damage += _vm->getRandomNumber(16)) > 0) || (_vm->getRandomNumber(2))) { + L0565_i_Damage += _vm->getRandomNumber(4); + if (!_vm->getRandomNumber(4)) { + L0565_i_Damage += MAX(0, L0566_i_Damage + _vm->getRandomNumber(16)); + } + } + } + L0565_i_Damage >>= 1; + L0565_i_Damage += _vm->getRandomNumber(L0565_i_Damage) + _vm->getRandomNumber(4); + L0565_i_Damage += _vm->getRandomNumber(L0565_i_Damage); + L0565_i_Damage >>= 2; + L0565_i_Damage += _vm->getRandomNumber(4) + 1; + if ((L0571_i_ActionHandObjectIconIndex == k40_IconIndiceWeaponVorpalBlade) && !getFlag(L0572_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) && !(L0565_i_Damage >>= 1)) + goto T0231015; + if (_vm->getRandomNumber(64) < _vm->_championMan->f303_getSkillLevel(champIndex, skillIndex)) { + L0565_i_Damage += L0565_i_Damage + 10; + } + L0569_i_Outcome = f190_groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapXóY, L0565_i_Damage, true); + _vm->_championMan->f304_addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * L0572_ps_CreatureInfo->M58_getExperience() >> 4) + 3); + _vm->_championMan->f325_decrementStamine(champIndex, _vm->getRandomNumber(4) + 4); + goto T0231016; + } +T0231015: + L0565_i_Damage = 0; + L0569_i_Outcome = k0_outcomeKilledNoCreaturesInGroup; + _vm->_championMan->f325_decrementStamine(champIndex, _vm->getRandomNumber(2) + 2); +T0231016: + _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); + if (L0569_i_Outcome != k2_outcomeKilledAllCreaturesInGroup) { + f209_processEvents29to41(mapX, mapXóY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0); + } + return L0565_i_Damage; +} + +void GroupMan::f224_fluxCageAction(int16 mapX, int16 mapY) { + Thing L0545_T_Thing; + int16 L0546_i_Multiple; +#define AL0546_i_SquareType L0546_i_Multiple +#define AL0546_i_FluxcageCount L0546_i_Multiple + TimelineEvent L0547_s_Event; + + + if (((AL0546_i_SquareType = _vm->_dungeonMan->f151_getSquare(mapX, mapY).getType()) == k0_ElementTypeWall) || (AL0546_i_SquareType == k3_ElementTypeStairs)) { + return; + } + if ((L0545_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType)) == Thing::_none) { + return; + } + _vm->_dungeonMan->f163_linkThingToList(L0545_T_Thing, Thing(0), mapX, mapY); + (((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[L0545_T_Thing.getIndex()]).setType(k50_ExplosionType_Fluxcage); + M33_setMapAndTime(L0547_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + 100); + L0547_s_Event._type = k24_TMEventTypeRemoveFluxcage; + L0547_s_Event._priority = 0; + L0547_s_Event._C._slot = L0545_T_Thing.toUint16(); + L0547_s_Event._B._location._mapX = mapX; + L0547_s_Event._B._location._mapY = mapY; + L0547_s_Event._B._location._mapY = mapY; + _vm->_timeline->f238_addEventGetEventIndex(&L0547_s_Event); + if (f222_isLordChaosOnSquare(mapX, mapY - 1)) { + mapY--; + AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX + 1, mapY); + goto T0224005; + } + if (f222_isLordChaosOnSquare(mapX - 1, mapY)) { + mapX--; + AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX, mapY + 1); +T0224005: + AL0546_i_FluxcageCount += f221_isFluxcageOnSquare(mapX, mapY - 1) + f221_isFluxcageOnSquare(mapX - 1, mapY); + } else { + if (f222_isLordChaosOnSquare(mapX + 1, mapY)) { + mapX++; + AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX, mapY - 1); + goto T0224008; + } + if (f222_isLordChaosOnSquare(mapX, mapY + 1)) { + mapY++; + AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX - 1, mapY); +T0224008: + AL0546_i_FluxcageCount += f221_isFluxcageOnSquare(mapX, mapY + 1) + f221_isFluxcageOnSquare(mapX + 1, mapY); + } else { + AL0546_i_FluxcageCount = 0; + } + } + if (AL0546_i_FluxcageCount == 2) { + f209_processEvents29to41(mapX, mapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0); + } +} + +uint16 GroupMan::f222_isLordChaosOnSquare(int16 mapX, int16 mapY) { + Thing L0542_T_Thing; + Group* L0543_ps_Group; + + if ((L0542_T_Thing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) { + return 0; + } + L0543_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0542_T_Thing); + if (L0543_ps_Group->_type == k23_CreatureTypeLordChaos) { + return L0542_T_Thing.toUint16(); + } + return 0; +} + +bool GroupMan::f221_isFluxcageOnSquare(int16 mapX, int16 mapY) { + Thing L0540_T_Thing; + int16 L0541_i_SquareType; + + if (((L0541_i_SquareType = _vm->_dungeonMan->f151_getSquare(mapX, mapY).getType()) == k0_ElementTypeWall) || (L0541_i_SquareType == k3_ElementTypeStairs)) { + return false; + } + L0540_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY); + while (L0540_T_Thing != Thing::_endOfList) { + if ((L0540_T_Thing.getType() == k15_ExplosionThingType) && (((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[L0540_T_Thing.getIndex()].getType() == k50_ExplosionType_Fluxcage)) { + return true; + } + L0540_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0540_T_Thing); + } + return false; +} + +void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) { + int16 L0548_i_MapX; + int16 L0549_i_MapY; + uint16 L0551_ui_FluxcageCount; + uint16 L0552_ui_FluxcageIndex; + uint16 L0553_ui_Counter; + bool L0554_aB_Fluxcages[4]; + Thing L0555_T_LordChaosThing; + + if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight)) { + return; + } + + _vm->_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, 255, mapX, mapY, k255_CreatureTypeSingleCenteredCreature); /* BUG0_17 The game crashes after the Fuse action is performed while looking at a wall on a map boundary. An explosion thing is created on the square in front of the party but there is no check to ensure the square coordinates are in the map bounds. This corrupts a memory location and leads to a game crash */ + if ((L0555_T_LordChaosThing = Thing(f222_isLordChaosOnSquare(mapX, mapY))).toUint16()) { + L0551_ui_FluxcageCount = (L0554_aB_Fluxcages[0] = f221_isFluxcageOnSquare(mapX - 1, mapY)) + + (L0554_aB_Fluxcages[1] = f221_isFluxcageOnSquare(mapX + 1, mapY)) + + (L0554_aB_Fluxcages[2] = f221_isFluxcageOnSquare(mapX, mapY - 1)) + + (L0554_aB_Fluxcages[3] = f221_isFluxcageOnSquare(mapX, mapY + 1)); + while (L0551_ui_FluxcageCount++ < 4) { + L0548_i_MapX = mapX; + L0549_i_MapY = mapY; + L0552_ui_FluxcageIndex = _vm->getRandomNumber(4); + for (L0553_ui_Counter = 5; --L0553_ui_Counter; L0552_ui_FluxcageIndex = returnNextVal(L0552_ui_FluxcageIndex)) { + if (!L0554_aB_Fluxcages[L0552_ui_FluxcageIndex]) { + L0554_aB_Fluxcages[L0552_ui_FluxcageIndex] = true; + switch (L0552_ui_FluxcageIndex) { + case 0: + L0548_i_MapX--; + break; + case 1: + L0548_i_MapX++; + break; + case 2: + L0549_i_MapY--; + break; + case 3: + L0549_i_MapY++; + } + break; + } + } + if (f223_isSquareACorridorTeleporterPitOrDoor(L0548_i_MapX, L0549_i_MapY)) { + if (!_vm->_movsens->f267_getMoveResult(L0555_T_LordChaosThing, mapX, mapY, L0548_i_MapX, L0549_i_MapY)) { + f180_startWanedring(L0548_i_MapX, L0549_i_MapY); + } + return; + } + } + warning(false, "F0446_STARTEND_FuseSequence()"); + } +} } diff --git a/engines/dm/group.h b/engines/dm/group.h index 242e52768d..fd7d98afe7 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -32,6 +32,7 @@ #include "dm.h" namespace DM { + class Champion; class TimelineEvent; class CreatureInfo; @@ -236,7 +237,14 @@ public: void f195_addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups Thing f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated bool f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY); // @ F0223_GROUP_IsSquareACorridorTeleporterPitOrDoor - + int16 f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 paryY, + uint16 champCell); // @ F0177_GROUP_GetMeleeTargetCreatureOrdinal + int16 f231_getMeleeActionDamage(Champion *champ, int16 champIndex, Group *group, int16 creatureIndex, + int16 mapX, int16 mapXóY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex); // @ F0231_GROUP_GetMeleeActionDamage + void f224_fluxCageAction(int16 mapX, int16 mapY); // @ F0224_GROUP_FluxCageAction + uint16 f222_isLordChaosOnSquare(int16 mapX, int16 mapY); // @ F0222_GROUP_IsLordChaosOnSquare + bool f221_isFluxcageOnSquare(int16 mapX, int16 mapY); // @ F0221_GROUP_IsFluxcageOnSquare + void f225_fuseAction(uint16 mapX, uint16 mapY); // @ F0225_GROUP_FuseAction }; diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index d35ec7553a..06a286c65e 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -35,10 +35,59 @@ #include "eventman.h" #include "timeline.h" #include "movesens.h" +#include "group.h" +#include "projexpl.h" namespace DM { +unsigned char g496_ActionSkillIndex[44] = { // @ G0496_auc_Graphic560_ActionSkillIndex + 0, /* N */ + 7, /* BLOCK */ + 6, /* CHOP */ + 0, /* X */ + 14, /* BLOW HORN */ + 12, /* FLIP */ + 9, /* PUNCH */ + 9, /* KICK */ + 7, /* WAR CRY Atari ST Versions 1.0 1987-12-08 1987-12-11 1.1: 14 */ + 9, /* STAB */ + 8, /* CLIMB DOWN */ + 14, /* FREEZE LIFE */ + 9, /* HIT */ + 4, /* SWING */ + 5, /* STAB */ + 5, /* THRUST */ + 5, /* JAB */ + 7, /* PARRY */ + 4, /* HACK */ + 4, /* BERZERK */ + 16, /* FIREBALL */ + 17, /* DISPELL */ + 14, /* CONFUSE */ + 17, /* LIGHTNING */ + 17, /* DISRUPT */ + 6, /* MELEE */ + 8, /* X */ + 3, /* INVOKE */ + 4, /* SLASH */ + 4, /* CLEAVE */ + 6, /* BASH */ + 6, /* STUN */ + 11, /* SHOOT */ + 15, /* SPELLSHIELD */ + 15, /* FIRESHIELD */ + 3, /* FLUXCAGE */ + 13, /* HEAL */ + 14, /* CALM */ + 17, /* LIGHT */ + 18, /* WINDOW */ + 16, /* SPIT */ + 14, /* BRANDISH */ + 10, /* THROW */ + 3}; /* FUSE */ + + Box g499_BoxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu Box g500_BoxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu Box g501_BoxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu @@ -56,6 +105,8 @@ MenuMan::MenuMan(DMEngine *vm) : _vm(vm) { _g513_actionDamage = 0; _g713_actionList.resetToZero(); _gK72_bitmapSpellAreaLine = new byte[96 * 12]; + _g517_actionTargetGroupThing = Thing(0); + _g507_actionCount = 0; } MenuMan::~MenuMan() { @@ -813,4 +864,817 @@ void MenuMan::f400_deleteChampionSymbol() { f398_drawChampionSymbols(L1228_ps_Champion); _vm->_eventMan->f77_hideMouse(); } + +bool MenuMan::f391_didClickTriggerAction(int16 actionListIndex) { + uint16 L1196_ui_ChampionIndex; + uint16 L1197_ui_ActionIndex; + bool L1198_B_ClickTriggeredAction; + Champion* L1199_ps_Champion; + + + if (!_vm->_championMan->_g506_actingChampionOrdinal || (actionListIndex != -1 && (_vm->_menuMan->_g713_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone))) + return false; + + L1199_ps_Champion = &_vm->_championMan->_gK71_champions[L1196_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)]; + if (actionListIndex == -1) { + warning(false, "possible bug in f391_didClickTriggerAction"); + // L1198_B_ClickTriggeredAction is set to -1 since booleans are stored in int16 in the original + L1198_B_ClickTriggeredAction = true; + } else { + L1197_ui_ActionIndex = _vm->_menuMan->_g713_actionList._actionIndices[actionListIndex]; + L1199_ps_Champion->_actionDefense += g495_actionDefense[L1197_ui_ActionIndex]; /* BUG0_54 The defense modifier of an action is permanent. + Each action has an associated defense modifier value and a number of ticks while the champion cannot perform another action because the action icon is grayed out. If an action has a non zero defense modifier and a zero value for the number of ticks then the defense modifier is applied but it is never removed. This causes no issue in the original games because there are no actions in this case but it may occur in a version where data is customized. This statement should only be executed if the value for the action in G0491_auc_Graphic560_ActionDisabledTicks is not 0 otherwise the action is not disabled at the end of F0407_MENUS_IsActionPerformed and thus not enabled later in F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction where the defense modifier is also removed */ + setFlag(L1199_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); + L1198_B_ClickTriggeredAction = f407_isActionPerformed(L1196_ui_ChampionIndex, L1197_ui_ActionIndex); + L1199_ps_Champion->_actionIndex = (ChampionAction)L1197_ui_ActionIndex; + } + _vm->_menuMan->f388_clearActingChampion(); + return L1198_B_ClickTriggeredAction; +} + +bool MenuMan::f407_isActionPerformed(uint16 champIndex, int16 actionIndex) { + static unsigned char G0491_auc_Graphic560_ActionDisabledTicks[44] = { + 0, /* N */ + 6, /* BLOCK */ + 8, /* CHOP */ + 0, /* X */ + 6, /* BLOW HORN */ + 3, /* FLIP */ + 1, /* PUNCH */ + 5, /* KICK */ + 3, /* WAR CRY */ + 5, /* STAB */ + 35, /* CLIMB DOWN */ + 20, /* FREEZE LIFE */ + 4, /* HIT */ + 6, /* SWING */ + 10, /* STAB */ + 16, /* THRUST */ + 2, /* JAB */ + 18, /* PARRY */ + 8, /* HACK */ + 30, /* BERZERK */ + 42, /* FIREBALL */ + 31, /* DISPELL */ + 10, /* CONFUSE */ + 38, /* LIGHTNING */ + 9, /* DISRUPT */ + 20, /* MELEE */ + 10, /* X */ + 16, /* INVOKE */ + 4, /* SLASH */ + 12, /* CLEAVE */ + 20, /* BASH */ + 7, /* STUN */ + 14, /* SHOOT */ + 30, /* SPELLSHIELD */ + 35, /* FIRESHIELD */ + 2, /* FLUXCAGE */ + 19, /* HEAL */ + 9, /* CALM */ + 10, /* LIGHT */ + 15, /* WINDOW */ + 22, /* SPIT */ + 10, /* BRANDISH */ + 0, /* THROW */ + 2}; /* FUSE */ + static unsigned char G0494_auc_Graphic560_ActionStamina[44] = { + 0, /* N */ + 4, /* BLOCK */ + 10, /* CHOP */ + 0, /* X */ + 1, /* BLOW HORN */ + 0, /* FLIP */ + 1, /* PUNCH */ + 3, /* KICK */ + 1, /* WAR CRY */ + 3, /* STAB */ + 40, /* CLIMB DOWN */ + 3, /* FREEZE LIFE */ + 3, /* HIT */ + 2, /* SWING */ + 4, /* STAB */ + 17, /* THRUST */ + 3, /* JAB */ + 1, /* PARRY */ + 6, /* HACK */ + 40, /* BERZERK */ + 5, /* FIREBALL */ + 2, /* DISPELL */ + 2, /* CONFUSE */ + 4, /* LIGHTNING */ + 5, /* DISRUPT */ + 25, /* MELEE */ + 1, /* X */ + 2, /* INVOKE */ + 2, /* SLASH */ + 10, /* CLEAVE */ + 9, /* BASH */ + 2, /* STUN */ + 3, /* SHOOT */ + 1, /* SPELLSHIELD */ + 2, /* FIRESHIELD */ + 6, /* FLUXCAGE */ + 1, /* HEAL */ + 1, /* CALM */ + 3, /* LIGHT */ + 2, /* WINDOW */ + 3, /* SPIT */ + 2, /* BRANDISH */ + 0, /* THROW */ + 2}; /* FUSE */ + unsigned char G0497_auc_Graphic560_ActionExperienceGain[44] = { + 0, /* N */ + 8, /* BLOCK */ + 10, /* CHOP */ + 0, /* X */ + 0, /* BLOW HORN */ + 0, /* FLIP */ + 8, /* PUNCH */ + 13, /* KICK */ + 7, /* WAR CRY */ + 15, /* STAB */ + 15, /* CLIMB DOWN */ + 22, /* FREEZE LIFE */ + 10, /* HIT */ + 6, /* SWING */ + 12, /* STAB */ + 19, /* THRUST */ + 11, /* JAB */ + 17, /* PARRY */ + 9, /* HACK */ + 40, /* BERZERK */ + 35, /* FIREBALL */ + 25, /* DISPELL */ + 0, /* CONFUSE */ + 30, /* LIGHTNING */ + 10, /* DISRUPT */ + 24, /* MELEE */ + 0, /* X */ + 25, /* INVOKE */ + 9, /* SLASH */ + 12, /* CLEAVE */ + 11, /* BASH */ + 10, /* STUN */ + 20, /* SHOOT Atari ST Versions 1.0 1987-12-08 1987-12-11: 9 */ + 20, /* SPELLSHIELD */ + 20, /* FIRESHIELD */ + 12, /* FLUXCAGE */ + 0, /* HEAL */ + 0, /* CALM */ + 20, /* LIGHT */ + 30, /* WINDOW */ + 25, /* SPIT */ + 0, /* BRANDISH */ + 5, /* THROW */ + 1}; /* FUSE */ + uint16 L1244_ui_Multiple; +#define AL1244_ui_TargetSquare L1244_ui_Multiple +#define AL1244_ui_HealingAmount L1244_ui_Multiple +#define AL1244_ui_ManaCost L1244_ui_Multiple + int16 L1245_i_Multiple; +#define AL1245_T_ExplosionThing L1245_i_Multiple +#define AL1245_B_ActionPerformed L1245_i_Multiple + int16 L1246_i_Multiple; +#define AL1246_i_RequiredManaAmount L1246_i_Multiple +#define AL1246_i_ActionHandWeaponClass L1246_i_Multiple +#define AL1246_i_StepEnergy L1246_i_Multiple +#define AL1246_i_HealingCapability L1246_i_Multiple +#define AL1246_i_Ticks L1246_i_Multiple + Champion* L1247_ps_Champion; + Weapon* L1248_ps_Weapon; + uint16 L1249_ui_ActionDisabledTicks; + int16 L1250_i_Multiple; +#define AL1250_i_KineticEnergy L1250_i_Multiple +#define AL1250_i_ReadyHandWeaponClass L1250_i_Multiple +#define AL1250_i_MissingHealth L1250_i_Multiple +#define AL1250_i_HealingAmount L1250_i_Multiple + int16 L1251_i_MapX; + int16 L1252_i_MapY; + int16 L1253_i_ActionStamina; + int16 L1254_i_ActionSkillIndex; + int16 L1255_i_ActionExperienceGain; + WeaponInfo* L1256_ps_WeaponInfoActionHand; + WeaponInfo* L1257_ps_WeaponInfoReadyHand; + TimelineEvent L1258_s_Event; + + + if (champIndex >= _vm->_championMan->_g305_partyChampionCount) { + return false; + } + L1247_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + L1248_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L1247_ps_Champion->_slots[k1_ChampionSlotActionHand]); + if (!L1247_ps_Champion->_currHealth) { + return false; + } + L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX; + L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY; + L1251_i_MapX += _vm->_dirIntoStepCountEast[L1247_ps_Champion->_dir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[L1247_ps_Champion->_dir]; + _g517_actionTargetGroupThing = _vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY); + L1249_ui_ActionDisabledTicks = G0491_auc_Graphic560_ActionDisabledTicks[actionIndex]; + L1254_i_ActionSkillIndex = g496_ActionSkillIndex[actionIndex]; + L1253_i_ActionStamina = G0494_auc_Graphic560_ActionStamina[actionIndex] + _vm->getRandomNumber(2); + L1255_i_ActionExperienceGain = G0497_auc_Graphic560_ActionExperienceGain[actionIndex]; + AL1244_ui_TargetSquare = _vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).toByte(); + AL1245_B_ActionPerformed = true; + if (((L1254_i_ActionSkillIndex >= k16_ChampionSkillFire) && (L1254_i_ActionSkillIndex <= k19_ChampionSkillWater)) || (L1254_i_ActionSkillIndex == k3_ChampionSkillWizard)) { + AL1246_i_RequiredManaAmount = 7 - MIN((uint16)6, _vm->_championMan->f303_getSkillLevel(champIndex, L1254_i_ActionSkillIndex)); + } + switch (actionIndex) { + case k23_ChampionActionLightning: + AL1250_i_KineticEnergy = 180; + AL1245_T_ExplosionThing = Thing::_explLightningBolt.toUint16(); + goto T0407014; + case k21_ChampionActionDispel: + AL1250_i_KineticEnergy = 150; + AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16(); + goto T0407014; + case k20_ChampionActionFireball: + AL1250_i_KineticEnergy = 150; + goto T0407013; + case k40_ChampionActionSpit: + AL1250_i_KineticEnergy = 250; +T0407013: + AL1245_T_ExplosionThing = Thing::_explFireBall.toUint16(); +T0407014: + f406_setChampionDirectionToPartyDirection(L1247_ps_Champion); + if (L1247_ps_Champion->_currMana < AL1246_i_RequiredManaAmount) { + AL1250_i_KineticEnergy = MAX(2, L1247_ps_Champion->_currMana * AL1250_i_KineticEnergy / AL1246_i_RequiredManaAmount); + AL1246_i_RequiredManaAmount = L1247_ps_Champion->_currMana; + } + if (!(AL1245_B_ActionPerformed = _vm->_championMan->f327_isProjectileSpellCast(champIndex, Thing(AL1245_T_ExplosionThing), AL1250_i_KineticEnergy, AL1246_i_RequiredManaAmount))) { + L1255_i_ActionExperienceGain >>= 1; + } + f405_decrementCharges(L1247_ps_Champion); + break; + case k30_ChampionActionBash: + case k18_ChampionActionHack: + case k19_ChampionActionBerzerk: + case k7_ChampionActionKick: + case k13_ChampionActionSwing: + case k2_ChampionActionChop: + if ((Square(AL1244_ui_TargetSquare).getType() == k4_DoorElemType) && (Square(AL1244_ui_TargetSquare).getDoorState() == k4_doorState_CLOSED)) { + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + L1249_ui_ActionDisabledTicks = 6; + _vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand), false, 2); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + break; + } + case k24_ChampionActionDisrupt: + case k16_ChampionActionJab: + case k17_ChampionActionParry: + case k14_ChampionActionStab_C014: + case k9_ChampionActionStab_C009: + case k31_ChampionActionStun: + case k15_ChampionActionThrust: + case k25_ChampionActionMelee: + case k28_ChampionActionSlash: + case k29_ChampionActionCleave: + case k6_ChampionActionPunch: + if (!(AL1245_B_ActionPerformed = f402_isMeleeActionPerformed(champIndex, L1247_ps_Champion, actionIndex, L1251_i_MapX, L1252_i_MapY, L1254_i_ActionSkillIndex))) { + L1255_i_ActionExperienceGain >>= 1; + L1249_ui_ActionDisabledTicks >>= 1; + } + break; + case k22_ChampionActionConfuse: + f405_decrementCharges(L1247_ps_Champion); + case k8_ChampionActionWarCry: + case k37_ChampionActionCalm: + case k41_ChampionActionBrandish: + case k4_ChampionActionBlowHorn: + if (actionIndex == k8_ChampionActionWarCry) { + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + if (actionIndex == k4_ChampionActionBlowHorn) { + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + AL1245_B_ActionPerformed = f401_isGroupFrightenedByAction(champIndex, actionIndex, L1251_i_MapX, L1252_i_MapY); + break; + case k32_ChampionActionShoot: + if (Thing(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType) + goto T0407032; + L1256_ps_WeaponInfoActionHand = &g238_WeaponInfo[L1248_ps_Weapon->getType()]; + L1257_ps_WeaponInfoReadyHand = _vm->_dungeonMan->f158_getWeaponInfo(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]); + AL1246_i_ActionHandWeaponClass = L1256_ps_WeaponInfoActionHand->_class; + AL1250_i_ReadyHandWeaponClass = L1257_ps_WeaponInfoReadyHand->_class; + if ((AL1246_i_ActionHandWeaponClass >= k16_WeaponClassFirstBow) && (AL1246_i_ActionHandWeaponClass <= k31_WeaponClassLastBow)) { + if (AL1250_i_ReadyHandWeaponClass != k10_WeaponClassBowAmmunition) + goto T0407032; + AL1246_i_StepEnergy -= k16_WeaponClassFirstBow; + } else { + if ((AL1246_i_ActionHandWeaponClass >= k32_WeaponClassFirstSling) && (AL1246_i_ActionHandWeaponClass <= k47_WeaponClassLastSling)) { + if (AL1250_i_ReadyHandWeaponClass != k11_WeaponClassSlingAmmunition) { +T0407032: + _vm->_menuMan->_g513_actionDamage = kM2_damageNoAmmunition; + L1255_i_ActionExperienceGain = 0; + AL1245_B_ActionPerformed = false; + break; + } + AL1246_i_StepEnergy -= k32_WeaponClassFirstSling; + } + } + f406_setChampionDirectionToPartyDirection(L1247_ps_Champion); + { // so gotos won't skip init + Thing AL1250_T_Object = _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand); + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->_championMan->f326_championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->f303_getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy); + } + break; + case k5_ChampionActionFlip: + // TODO: localization + if (_vm->getRandomNumber(2)) { + f381_printMessageAfterReplacements("IT COMES UP HEADS."); + } else { + f381_printMessageAfterReplacements("IT COMES UP TAILS."); + } + break; + case k33_ChampionActionSpellshield: + case k34_ChampionActionFireshield: + if (!f403_isPartySpellOrFireShieldSuccessful(L1247_ps_Champion, actionIndex == k33_ChampionActionSpellshield, 280, true)) { + L1255_i_ActionExperienceGain >>= 2; + L1249_ui_ActionDisabledTicks >>= 1; + } else { + f405_decrementCharges(L1247_ps_Champion); + } + break; + case k27_ChampionActionInvoke: + AL1250_i_KineticEnergy = _vm->getRandomNumber(128) + 100; + switch (_vm->getRandomNumber(6)) { + case 0: + AL1245_T_ExplosionThing = Thing::_explPoisonBolt.toUint16(); + goto T0407014; + case 1: + AL1245_T_ExplosionThing = Thing::_explPoisonCloud.toUint16(); + goto T0407014; + case 2: + AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16(); + goto T0407014; + default: + goto T0407013; + } + case k35_ChampionActionFluxcage: + f406_setChampionDirectionToPartyDirection(L1247_ps_Champion); + _vm->_groupMan->f224_fluxCageAction(L1251_i_MapX, L1252_i_MapY); + break; + case k43_ChampionActionFuse: + f406_setChampionDirectionToPartyDirection(L1247_ps_Champion); + L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX; + L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY; + L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir]; + _vm->_groupMan->f225_fuseAction(L1251_i_MapX, L1252_i_MapY); + break; + case k36_ChampionActionHeal: + /* CHANGE2_17_IMPROVEMENT Heal action is much more effective + Heal cycles occur as long as the champion has missing health and enough mana. Cycle count = Min(Current Mana / 2, Missing health / Min(10, Heal skill level)) + Healing amount is Min(Missing health, Min(10, Heal skill level)) * heal cycle count + Mana cost is 2 * heal cycle count + Experience gain is 2 + 2 * heal cycle count */ + if (((AL1250_i_MissingHealth = L1247_ps_Champion->_maxHealth - L1247_ps_Champion->_currHealth) > 0) && L1247_ps_Champion->_currMana) { + AL1246_i_HealingCapability = MIN((uint16)10, _vm->_championMan->f303_getSkillLevel(champIndex, k13_ChampionSkillHeal)); + L1255_i_ActionExperienceGain = 2; + do { + AL1244_ui_HealingAmount = MIN(AL1250_i_MissingHealth, AL1246_i_HealingCapability); + L1247_ps_Champion->_currHealth += AL1244_ui_HealingAmount; + L1255_i_ActionExperienceGain += 2; + } while (((L1247_ps_Champion->_currMana = L1247_ps_Champion->_currMana - 2) > 0) && (AL1250_i_MissingHealth = AL1250_i_MissingHealth - AL1244_ui_HealingAmount)); + if (L1247_ps_Champion->_currMana < 0) { + L1247_ps_Champion->_currMana = 0; + } + setFlag(L1247_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); + AL1245_B_ActionPerformed = true; + } + break; + case k39_ChampionActionWindow: + AL1246_i_Ticks = _vm->getRandomNumber(_vm->_championMan->f303_getSkillLevel(champIndex, L1254_i_ActionSkillIndex) + 8) + 5; + L1258_s_Event._priority = 0; + L1258_s_Event._type = k73_TMEventTypeThievesEye; + M33_setMapAndTime(L1258_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + AL1246_i_Ticks); + _vm->_timeline->f238_addEventGetEventIndex(&L1258_s_Event); + _vm->_championMan->_g407_party._event73Count_ThievesEye++; + goto T0407076; + case k10_ChampionActionClimbDown: + L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX; + L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY; + L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir]; + /* CHANGE6_00_FIX The presence of a group over the pit is checked so that you cannot climb down a pit with the rope if there is a group levitating over it */ + if ((_vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_ElementTypePit) && (_vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) { + /* BUG0_77 The party moves forward when using the rope in front of a closed pit. The engine does not check whether the pit is open before moving the party over the pit. This is not consistent with the behavior when using the rope in front of a corridor where nothing happens */ + _vm->_movsens->_g402_useRopeToClimbDownPit = true; + _vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1251_i_MapX, L1252_i_MapY); + _vm->_movsens->_g402_useRopeToClimbDownPit = false; + } else { + L1249_ui_ActionDisabledTicks = 0; + } + break; + case k11_ChampionActionFreezeLife: + if (L1248_ps_Weapon->getType() == k42_JunkTypeMagicalBoxBlue) { + AL1246_i_Ticks = 30; + goto T0407071; + } + if (L1248_ps_Weapon->getType() == k43_JunkTypeMagicalBoxGreen) { + AL1246_i_Ticks = 125; +T0407071: + _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand); + L1248_ps_Weapon->setNextThing(Thing::_none); + } else { + AL1246_i_Ticks = 70; + f405_decrementCharges(L1247_ps_Champion); + } + _vm->_championMan->_g407_party._freezeLifeTicks = MIN(200, _vm->_championMan->_g407_party._freezeLifeTicks + AL1246_i_Ticks); + break; + case k38_ChampionActionLight: + _vm->_championMan->_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2]; + f404_createEvent70_light(-2, 2500); +T0407076: + f405_decrementCharges(L1247_ps_Champion); + break; + case k42_ChampionActionThrow: + f406_setChampionDirectionToPartyDirection(L1247_ps_Champion); + if (AL1245_B_ActionPerformed = _vm->_championMan->f328_isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_g308_partyDir)) || (L1247_ps_Champion->_cell == returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)))) { + _vm->_timeline->_g370_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->M0_indexToOrdinal(k1_ChampionSlotActionHand); + } + } + if (L1249_ui_ActionDisabledTicks) { + _vm->_championMan->f330_disableAction(champIndex, L1249_ui_ActionDisabledTicks); + } + if (L1253_i_ActionStamina) { + _vm->_championMan->f325_decrementStamine(champIndex, L1253_i_ActionStamina); + } + if (L1255_i_ActionExperienceGain) { + _vm->_championMan->f304_addSkillExperience(champIndex, L1254_i_ActionSkillIndex, L1255_i_ActionExperienceGain); + } + _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); + return AL1245_B_ActionPerformed; +} + +void MenuMan::f406_setChampionDirectionToPartyDirection(Champion* champ) { + if (champ->_dir != _vm->_dungeonMan->_g308_partyDir) { + champ->_dir = _vm->_dungeonMan->_g308_partyDir; + setFlag(champ->_attributes, k0x0400_ChampionAttributeIcon); + } +} + +void MenuMan::f405_decrementCharges(Champion* champ) { + Thing L1242_T_Thing; + Junk* L1243_ps_Junk; + + L1243_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1242_T_Thing = champ->_slots[k1_ChampionSlotActionHand]); + switch (L1242_T_Thing.getType()) { + case k5_WeaponThingType: + if (((Weapon*)L1243_ps_Junk)->getChargeCount()) { + ((Weapon*)L1243_ps_Junk)->setChargeCount(((Weapon*)L1243_ps_Junk)->getChargeCount() - 1); + } + break; + case k6_ArmourThingType: + if (((Armour*)L1243_ps_Junk)->getChargeCount()) { + ((Armour*)L1243_ps_Junk)->setChargeCount(((Armour*)L1243_ps_Junk)->getChargeCount() - 1); + } + break; + case k10_JunkThingType: + if (L1243_ps_Junk->getChargeCount()) { + L1243_ps_Junk->setChargeCount(L1243_ps_Junk->getChargeCount() - 1); + } + } + _vm->_championMan->f296_drawChangedObjectIcons(); +} + +bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 actionIndex, int16 targetMapX, int16 targetMapY, int16 skillIndex) { + static unsigned char G0492_auc_Graphic560_ActionDamageFactor[44] = { + 0, /* N */ + 15, /* BLOCK */ + 48, /* CHOP */ + 0, /* X */ + 0, /* BLOW HORN */ + 0, /* FLIP */ + 32, /* PUNCH */ + 48, /* KICK */ + 0, /* WAR CRY */ + 48, /* STAB */ + 0, /* CLIMB DOWN */ + 0, /* FREEZE LIFE */ + 20, /* HIT */ + 16, /* SWING */ + 60, /* STAB */ + 66, /* THRUST */ + 8, /* JAB */ + 8, /* PARRY */ + 25, /* HACK */ + 96, /* BERZERK */ + 0, /* FIREBALL */ + 0, /* DISPELL */ + 0, /* CONFUSE */ + 0, /* LIGHTNING */ + 55, /* DISRUPT */ + 60, /* MELEE */ + 0, /* X */ + 0, /* INVOKE */ + 16, /* SLASH */ + 48, /* CLEAVE */ + 50, /* BASH */ + 16, /* STUN */ + 0, /* SHOOT */ + 0, /* SPELLSHIELD */ + 0, /* FIRESHIELD */ + 0, /* FLUXCAGE */ + 0, /* HEAL */ + 0, /* CALM */ + 0, /* LIGHT */ + 0, /* WINDOW */ + 0, /* SPIT */ + 0, /* BRANDISH */ + 0, /* THROW */ + 0}; /* FUSE */ + static unsigned char G0493_auc_Graphic560_ActionHitProbability[44] = { + 0, /* N */ + 22, /* BLOCK */ + 48, /* CHOP */ + 0, /* X */ + 0, /* BLOW HORN */ + 0, /* FLIP */ + 38, /* PUNCH */ + 28, /* KICK */ + 0, /* WAR CRY */ + 30, /* STAB */ + 0, /* CLIMB DOWN */ + 0, /* FREEZE LIFE */ + 20, /* HIT */ + 32, /* SWING */ + 42, /* STAB */ + 57, /* THRUST */ + 70, /* JAB */ + 18, /* PARRY */ + 27, /* HACK */ + 46, /* BERZERK */ + 0, /* FIREBALL */ + 0, /* DISPELL */ + 0, /* CONFUSE */ + 0, /* LIGHTNING */ + 46, /* DISRUPT */ + 64, /* MELEE */ + 0, /* X */ + 0, /* INVOKE */ + 26, /* SLASH */ + 40, /* CLEAVE */ + 32, /* BASH */ + 50, /* STUN */ + 0, /* SHOOT */ + 0, /* SPELLSHIELD */ + 0, /* FIRESHIELD */ + 0, /* FLUXCAGE */ + 0, /* HEAL */ + 0, /* CALM */ + 0, /* LIGHT */ + 0, /* WINDOW */ + 0, /* SPIT */ + 0, /* BRANDISH */ + 0, /* THROW */ + 0}; /* FUSE */ + + uint16 L1236_ui_Multiple; +#define AL1236_ui_ChampionCell L1236_ui_Multiple +#define AL1236_ui_ActionDamageFactor L1236_ui_Multiple + uint16 L1237_ui_Multiple; +#define AL1237_ui_Direction L1237_ui_Multiple +#define AL1237_ui_CellDelta L1237_ui_Multiple +#define AL1237_ui_ActionHitProbability L1237_ui_Multiple + int16 L1238_i_CreatureOrdinal; + + + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + if (_g517_actionTargetGroupThing == Thing::_endOfList) + goto T0402010; + if (L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, AL1236_ui_ChampionCell = champ->_cell)) { + switch (M21_normalizeModulo4(AL1236_ui_ChampionCell + 4 - champ->_dir)) { + case k2_ViewCellBackRight: /* Champion is on the back right of the square and tries to attack a creature in the front right of its square */ + AL1237_ui_CellDelta = 3; + goto T0402005; + case k3_ViewCellBackLeft: /* Champion is on the back left of the square and tries to attack a creature in the front left of its square */ + AL1237_ui_CellDelta = 1; +T0402005: /* Check if there is another champion in front */ + if (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL1236_ui_ChampionCell + AL1237_ui_CellDelta)) != kM1_ChampionNone) { + _vm->_menuMan->_g513_actionDamage = kM1_damageCantReach; + goto T0402010; + } + } + if ((actionIndex == k24_ChampionActionDisrupt) && !getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(_g517_actionTargetGroupThing), k0x0040_MaskCreatureInfo_nonMaterial)) + goto T0402010; + AL1237_ui_ActionHitProbability = G0493_auc_Graphic560_ActionHitProbability[actionIndex]; + AL1236_ui_ActionDamageFactor = G0492_auc_Graphic560_ActionDamageFactor[actionIndex]; + if ((_vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) { + setFlag(AL1237_ui_ActionHitProbability, k0x8000_hitNonMaterialCreatures); + } + _vm->_menuMan->_g513_actionDamage = _vm->_groupMan->f231_getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing), _vm->M1_ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex); + return true; + } +T0402010: + return false; +} + +bool MenuMan::f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY) { + int16 L1229_i_FrightAmount = 0; + uint16 L1230_ui_FearResistance; + uint16 L1231_ui_Experience = 0; + bool L1232_B_IsGroupFrightenedByAction; + Group* L1233_ps_Group; + CreatureInfo* L1234_ps_CreatureInfo; + ActiveGroup* L1235_ps_ActiveGroup; + + + L1232_B_IsGroupFrightenedByAction = false; + if (_g517_actionTargetGroupThing == Thing::_endOfList) + goto T0401016; + switch (actionIndex) { + case k8_ChampionActionWarCry: + L1229_i_FrightAmount = 3; + L1231_ui_Experience = 12; /* War Cry gives experience in priest skill k14_ChampionSkillInfluence below. The War Cry action also has an experience gain of 7 defined in G0497_auc_Graphic560_ActionExperienceGain in the same skill (versions 1.1 and below) or in the fighter skill k7_ChampionSkillParry (versions 1.2 and above). In versions 1.2 and above, this is the only action that gives experience in two skills */ + break; + case k37_ChampionActionCalm: + L1229_i_FrightAmount = 7; + L1231_ui_Experience = 35; + break; + case k41_ChampionActionBrandish: + L1229_i_FrightAmount = 6; + L1231_ui_Experience = 30; + break; + case k4_ChampionActionBlowHorn: + L1229_i_FrightAmount = 6; + L1231_ui_Experience = 20; + break; + case k22_ChampionActionConfuse: + L1229_i_FrightAmount = 12; + L1231_ui_Experience = 45; + } + L1229_i_FrightAmount += _vm->_championMan->f303_getSkillLevel(champIndex, k14_ChampionSkillInfluence); + L1233_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing); + L1234_ps_CreatureInfo = &g243_CreatureInfo[L1233_ps_Group->_type]; + if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->M57_getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) { + L1231_ui_Experience >>= 1; + } else { + L1235_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[L1233_ps_Group->getActiveGroupIndex()]; + if (L1233_ps_Group->getBehaviour() == k6_behavior_ATTACK) { + _vm->_groupMan->f182_stopAttacking(L1235_ps_ActiveGroup, mapX, mapY); + _vm->_groupMan->f180_startWanedring(mapX, mapY); + } + L1233_ps_Group->setBehaviour(k5_behavior_FLEE); + L1235_ps_ActiveGroup->_delayFleeingFromTarget = ((16 - L1230_ui_FearResistance) << 2) / L1234_ps_CreatureInfo->_movementTicks; + L1232_B_IsGroupFrightenedByAction = true; + } + _vm->_championMan->f304_addSkillExperience(champIndex, k14_ChampionSkillInfluence, L1231_ui_Experience); +T0401016: + return L1232_B_IsGroupFrightenedByAction; +} + +void MenuMan::f381_printMessageAfterReplacements(char* str) { + char* L1164_pc_Character; + char* L1165_pc_ReplacementString; + char L1166_ac_OutputString[128]; + + + L1164_pc_Character = L1166_ac_OutputString; + *L1164_pc_Character++ = '\n'; /* New line */ + do { + if (*str == '@') { + str++; + if (*(L1164_pc_Character - 1) != '\n') { /* New line */ + *L1164_pc_Character++ = ' '; + } + switch (*str) { + case 'p': /* '@p' in the source string is replaced by the champion name followed by a space */ + L1165_pc_ReplacementString = _vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)]._name; + } + *L1164_pc_Character = '\0'; + strcat(L1166_ac_OutputString, L1165_pc_ReplacementString); + L1164_pc_Character += strlen(L1165_pc_ReplacementString); + *L1164_pc_Character++ = ' '; + } else { + *L1164_pc_Character++ = *str; + } + } while (*str++); + *L1164_pc_Character = '\0'; + if (L1166_ac_OutputString[1]) { /* If the string is not empty (the first character is a new line \n) */ + _vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, L1166_ac_OutputString); + } +} + +void MenuMan::f389_processCommands116To119_setActingChampion(uint16 champIndex) { + static ActionSet G0489_as_Graphic560_ActionSets[44] = { + /* { ActionIndices[0], ActionIndices[1], ActionIndices[2], ActionProperties[0], ActionProperties[1], Useless } */ + ActionSet(255, 255, 255, 0x00, 0x00), + ActionSet(27, 43, 35, 0x00, 0x00), + ActionSet(6, 7, 8, 0x00, 0x00), + ActionSet(0, 0, 0, 0x00, 0x00), + ActionSet(0, 0, 0, 0x00, 0x00), + ActionSet(13, 255, 255, 0x00, 0x00), + ActionSet(13, 20, 255, 0x87, 0x00), + ActionSet(13, 23, 255, 0x83, 0x00), + ActionSet(28, 41, 22, 0x02, 0x83), + ActionSet(16, 2, 23, 0x00, 0x84), + ActionSet(2, 25, 20, 0x02, 0x86), + ActionSet(17, 41, 34, 0x03, 0x05), + ActionSet(42, 9, 28, 0x00, 0x02), + ActionSet(13, 17, 2, 0x02, 0x03), + ActionSet(16, 17, 15, 0x01, 0x05), + ActionSet(28, 17, 25, 0x01, 0x05), + ActionSet(2, 25, 15, 0x05, 0x06), + ActionSet(9, 2, 29, 0x02, 0x05), + ActionSet(16, 29, 24, 0x02, 0x04), + ActionSet(13, 15, 19, 0x05, 0x07), + ActionSet(13, 2, 25, 0x00, 0x05), + ActionSet(2, 29, 19, 0x03, 0x08), + ActionSet(13, 30, 31, 0x02, 0x04), + ActionSet(13, 31, 25, 0x03, 0x06), + ActionSet(42, 30, 255, 0x00, 0x00), + ActionSet(0, 0, 0, 0x00, 0x00), + ActionSet(42, 9, 255, 0x00, 0x00), + ActionSet(32, 255, 255, 0x00, 0x00), + ActionSet(37, 33, 36, 0x82, 0x03), + ActionSet(37, 33, 34, 0x83, 0x84), + ActionSet(17, 38, 21, 0x80, 0x83), + ActionSet(13, 21, 34, 0x83, 0x84), + ActionSet(36, 37, 41, 0x02, 0x03), + ActionSet(13, 23, 39, 0x82, 0x84), + ActionSet(13, 17, 40, 0x00, 0x83), + ActionSet(17, 36, 38, 0x03, 0x84), + ActionSet(4, 255, 255, 0x00, 0x00), + ActionSet(5, 255, 255, 0x00, 0x00), + ActionSet(11, 255, 255, 0x00, 0x00), + ActionSet(10, 255, 255, 0x00, 0x00), + ActionSet(42, 9, 255, 0x00, 0x00), + ActionSet(1, 12, 255, 0x02, 0x00), + ActionSet(42, 255, 255, 0x00, 0x00), + ActionSet(6, 11, 255, 0x80, 0x00)}; + uint16 L1188_ui_ActionSetIndex; + Thing L1189_T_Thing; + Champion* L1190_ps_Champion; + ActionSet* L1191_ps_ActionSet; + + + L1190_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + if (getFlag(L1190_ps_Champion->_attributes, k0x0008_ChampionAttributeDisableAction) || !L1190_ps_Champion->_currHealth) { + return; + } + if ((L1189_T_Thing = L1190_ps_Champion->_slots[k1_ChampionSlotActionHand]) == Thing::_none) { + L1188_ui_ActionSetIndex = 2; /* Actions Punck, Kick and War Cry */ + } else { + if ((L1188_ui_ActionSetIndex = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) { + return; + } + } + L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex]; + _vm->_championMan->_g506_actingChampionOrdinal = _vm->M0_indexToOrdinal(champIndex); + f383_setActionList(L1191_ps_ActionSet); + _vm->_menuMan->_g509_actionAreaContainsIcons = false; + setFlag(L1190_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand); + _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); + _vm->_menuMan->f387_drawActionArea(); + _vm->_menuMan->f387_drawActionArea(); +} + +void MenuMan::f383_setActionList(ActionSet* actionSet) { + +#define k0x0080_actionRequiresCharge 0x0080 // @ MASK0x0080_ACTION_REQUIRES_CHARGE + + uint16 L1169_ui_ActionListIndex; + uint16 L1170_ui_NextAvailableActionListIndex; + uint16 L1171_ui_ActionIndex; + uint16 L1172_ui_MinimumSkillLevel; + + _vm->_menuMan->_g713_actionList._actionIndices[0] = (ChampionAction)actionSet->_actionIndices[0]; + _vm->_menuMan->_g713_actionList._minimumSkillLevel[0] = 1; + L1170_ui_NextAvailableActionListIndex = 1; + for (L1169_ui_ActionListIndex = 1; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) { + if ((L1171_ui_ActionIndex = actionSet->_actionIndices[L1169_ui_ActionListIndex]) == k255_ChampionActionNone) + continue; + if (getFlag(L1172_ui_MinimumSkillLevel = actionSet->_actionProperties[L1169_ui_ActionListIndex - 1], k0x0080_actionRequiresCharge) && !f382_getActionObjectChargeCount()) + continue; + clearFlag(L1172_ui_MinimumSkillLevel, k0x0080_actionRequiresCharge); + if (_vm->_championMan->f303_getSkillLevel(_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal), g496_ActionSkillIndex[L1171_ui_ActionIndex]) >= L1172_ui_MinimumSkillLevel) { + _vm->_menuMan->_g713_actionList._actionIndices[L1170_ui_NextAvailableActionListIndex] = (ChampionAction)L1171_ui_ActionIndex; + _vm->_menuMan->_g713_actionList._minimumSkillLevel[L1170_ui_NextAvailableActionListIndex] = L1172_ui_MinimumSkillLevel; + L1170_ui_NextAvailableActionListIndex++; + } + } + _g507_actionCount = L1170_ui_NextAvailableActionListIndex; + for (L1169_ui_ActionListIndex = L1170_ui_NextAvailableActionListIndex; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) { + _vm->_menuMan->_g713_actionList._actionIndices[L1169_ui_ActionListIndex] = k255_ChampionActionNone; + } +} + +int16 MenuMan::f382_getActionObjectChargeCount() { + Thing L1167_T_Thing; + Junk* L1168_ps_Junk; + + + L1168_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1167_T_Thing = _vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]); + switch (L1167_T_Thing.getType()) { + case k5_WeaponThingType: + return ((Weapon*)L1168_ps_Junk)->getChargeCount(); + case k6_ArmourThingType: + return ((Armour*)L1168_ps_Junk)->getChargeCount(); + case k10_JunkThingType: + return L1168_ps_Junk->getChargeCount(); + default: + return 1; + } +} } diff --git a/engines/dm/menus.h b/engines/dm/menus.h index 0aabcab3f0..f0a1c2bf58 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -34,6 +34,11 @@ namespace DM { +#define kM1_damageCantReach -1 // @ CM1_DAMAGE_CANT_REACH +#define kM2_damageNoAmmunition -2 // @ CM2_DAMAGE_NO_AMMUNITION + +#define k0x8000_hitNonMaterialCreatures 0x8000 // @ MASK0x8000_HIT_NON_MATERIAL_CREATURES + extern Box g1_BoxActionArea; // @ G0001_s_Graphic562_Box_ActionArea extern Box g0_BoxSpellArea; // @ G0000_s_Graphic562_Box_SpellArea @@ -50,6 +55,19 @@ public: } }; // @ ACTION_LIST +class ActionSet { +public: + byte _actionIndices[3]; /* 1 byte of padding inserted by compiler on Atari ST, not on Amiga */ + byte _actionProperties[2]; /* Bit 7: requires charge, Bit 6-0: minimum skill level */ + ActionSet(byte a1, byte a2, byte a3, byte b1, byte b2) { + _actionIndices[0] = a1; + _actionIndices[1] = a2; + _actionIndices[2] = a3; + _actionProperties[0] = b1; + _actionProperties[1] = b2; + } +}; // @ ACTION_SET + class MenuMan { DMEngine *_vm; public: @@ -61,6 +79,8 @@ public: int16 _g513_actionDamage; // @ G0513_i_ActionDamage ActionList _g713_actionList; // @ G0713_s_ActionList byte *_gK72_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine + Thing _g517_actionTargetGroupThing; // @ G0517_T_ActionTargetGroupThing + uint16 _g507_actionCount; // @ G0507_ui_ActionCount void f388_clearActingChampion(); // @ F0388_MENUS_ClearActingChampion void f386_drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon @@ -85,6 +105,17 @@ public: void f398_drawChampionSymbols(Champion *champ); // @ F0398_MENUS_DrawChampionSymbols void f399_addChampionSymbol(int16 symbolIndex); // @ F0399_MENUS_AddChampionSymbol void f400_deleteChampionSymbol(); // @ F0400_MENUS_DeleteChampionSymbol + bool f391_didClickTriggerAction(int16 actionListIndex); // @ F0391_MENUS_DidClickTriggerAction + bool f407_isActionPerformed(uint16 champIndex, int16 actionIndex); // @ F0407_MENUS_IsActionPerformed + void f406_setChampionDirectionToPartyDirection(Champion *champ); // @ F0406_MENUS_SetChampionDirectionToPartyDirection + void f405_decrementCharges(Champion *champ); // @ F0405_MENUS_DecrementCharges + bool f402_isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 actionIndex, int16 targetMapX, + int16 targetMapY, int16 skillIndex); // @ F0402_MENUS_IsMeleeActionPerformed + bool f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY); // @ F0401_MENUS_IsGroupFrightenedByAction + void f381_printMessageAfterReplacements(char *str); // @ F0381_MENUS_PrintMessageAfterReplacements + void f389_processCommands116To119_setActingChampion(uint16 champIndex); // @ F0389_MENUS_ProcessCommands116To119_SetActingChampion + void f383_setActionList(ActionSet *actionSet); // @ F0383_MENUS_SetActionList + int16 f382_getActionObjectChargeCount(); // @ F0382_MENUS_GetActionObjectChargeCount }; } diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 6cb159a205..34e83ca262 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -963,7 +963,7 @@ void MovesensMan::f272_sensorTriggerEffect(Sensor* sensor, int16 effect, int16 m int16 L0736_i_TargetMapX; int16 L0737_i_TargetMapY; - register long L0738_l_Time; + int32 L0738_l_Time; uint16 L0739_ui_SquareType; uint16 L0740_ui_TargetCell; diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index 49a7ca4477..08c6ce1c5f 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -95,7 +95,7 @@ k82_TMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP k83_TMEventTypeMagicMap_C83 = 83 // @ C83_EVENT_MAGIC_MAP }; -extern signed char g495_actionDefense[44]; +extern signed char g495_actionDefense[44]; // @ G0495_ac_Graphic560_ActionDefense class TimelineEvent { public: -- cgit v1.2.3 From 5602d07f966ed16c5c74d014fe596ef15bcf825d Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 13 Jul 2016 17:34:05 +0200 Subject: DM: Fix Timeline _g370_events initialization --- engines/dm/TODOs/todo.txt | 3 +-- engines/dm/timeline.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 9137975b9f..d8821e6015 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -7,8 +7,7 @@ Bugs: Logic: When object are put on the right side of the current square, they disappear Drawing door ornaments segfaults when going back to the start - !! It seems that that deleted events' _type fields are not getting set to 0, when looking for available slots, the code looks for events with 0 _type fields, - this results in segfaults + Possible bugs: - k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 55c1e4bb66..3858ad512e 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -103,7 +103,7 @@ void Timeline::f233_initTimeline() { _g371_timeline = new uint16[_g369_eventMaxCount]; if (_vm->_g298_newGame) { for (int16 i = 0; i < _g369_eventMaxCount; ++i) - _g370_events->_type = k0_TMEventTypeNone; + _g370_events[i]._type = k0_TMEventTypeNone; _g372_eventCount = 0; _g373_firstUnusedEventIndex = 0; } -- cgit v1.2.3 From b092e74be9c275db8adb04a98c5146a6923e4f43 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 13 Jul 2016 17:49:49 +0200 Subject: DM: Fix broken ChampionMan::f303_getSkillLevel --- engines/dm/champion.cpp | 80 ++++++++++++++++++++++++------------------------- engines/dm/champion.h | 2 +- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b9c286ac92..52be549f61 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1922,62 +1922,62 @@ void ChampionMan::f281_renameChampion(Champion* champ) { } } -uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, int16 skillIndex) { - if (_g300_partyIsSleeping) +uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) { + if (_vm->_championMan->_g300_partyIsSleeping) { return 1; - - bool ignoreTempExp = skillIndex & k0x8000_IgnoreTemporaryExperience; - bool ignoreObjModifiers = skillIndex & k0x4000_IgnoreObjectModifiers; - skillIndex = (ChampionSkill)(skillIndex & ~(ignoreTempExp | ignoreObjModifiers)); - Champion *champ = &_gK71_champions[champIndex]; - Skill *skill = &champ->getSkill((ChampionSkill)skillIndex); - int32 experience = skill->_experience; - - if (!ignoreTempExp) - experience += skill->_temporaryExperience; - - if (skillIndex > k3_ChampionSkillWizard) { // hidden skill - skill = &champ->getSkill((ChampionSkill)((skillIndex - k4_ChampionSkillSwing) / 4)); - experience += skill->_experience; // add exp to the base skill - if (!ignoreTempExp) - experience += skill->_temporaryExperience; - - experience /= 2; // halve the exp to get avarage of base skill + hidden skill exp } - + bool ignoreTmpExp = getFlag(skillIndex, k0x8000_IgnoreTemporaryExperience); + bool ignoreObjModifiers = getFlag(skillIndex, k0x4000_IgnoreObjectModifiers); + clearFlag(skillIndex, k0x8000_IgnoreTemporaryExperience | k0x4000_IgnoreObjectModifiers); + Champion *champ = &_vm->_championMan->_gK71_champions[champIndex]; + Skill *skill = &champ->_skills[skillIndex]; + int32 exp = skill->_experience; + if (!ignoreTmpExp) { + exp += skill->_temporaryExperience; + } + if (skillIndex > k3_ChampionSkillWizard) { /* Hidden skill */ + skill = &champ->_skills[(skillIndex - k4_ChampionSkillSwing) >> 2]; + exp += skill->_experience; /* Add experience in the base skill */ + if (!ignoreTmpExp) { + exp += skill->_temporaryExperience; + } + exp >>= 1; /* Halve experience to get average of base skill + hidden skill experience */ + } int16 skillLevel = 1; - while (experience >= 500) { - experience /= 2; + while (exp >= 500) { + exp >>= 1; skillLevel++; } - if (!ignoreObjModifiers) { - IconIndice actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->getSlot(k1_ChampionSlotActionHand)); - if (actionHandIconIndex == k27_IconIndiceWeaponTheFirestaff) { + int16 actionHandIconIndex; + if ((actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand])) == k27_IconIndiceWeaponTheFirestaff) { skillLevel++; - } else if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete) { - skillLevel += 2; + } else { + if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete) { + skillLevel += 2; + } } - - IconIndice neckIconIndice = _vm->_objectMan->f33_getIconIndex(champ->getSlot(k10_ChampionSlotNeck)); + int16 neckIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k10_ChampionSlotNeck]); switch (skillIndex) { case k3_ChampionSkillWizard: - if (neckIconIndice == k124_IconIndiceJunkPendantFeral) - skillLevel++; + if (neckIconIndex == k124_IconIndiceJunkPendantFeral) { + skillLevel += 1; + } break; case k15_ChampionSkillDefend: - if (neckIconIndice == k121_IconIndiceJunkEkkhardCross) - skillLevel++; + if (neckIconIndex == k121_IconIndiceJunkEkkhardCross) { + skillLevel += 1; + } break; case k13_ChampionSkillHeal: - // these two are not cummulative - if ((neckIconIndice == k120_IconIndiceJunkGemOfAges) || (neckIconIndice == k66_IconIndiceWeaponSceptreOfLyf)) - skillLevel++; + if ((neckIconIndex == k120_IconIndiceJunkGemOfAges) || (actionHandIconIndex == k66_IconIndiceWeaponSceptreOfLyf)) { /* The skill modifiers of these two objects are not cumulative */ + skillLevel += 1; + } break; case k14_ChampionSkillInfluence: - if (neckIconIndice == k122_IconIndiceJunkMoonstone) - skillLevel++; - break; + if (neckIconIndex == k122_IconIndiceJunkMoonstone) { + skillLevel += 1; + } } } return skillLevel; diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 2bae7c5947..5d98ecbd41 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -536,7 +536,7 @@ public: void f290_drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues void f291_drawSlot(uint16 champIndex, int16 slotIndex); // @ F0291_CHAMPION_DrawSlot void f281_renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename - uint16 f303_getSkillLevel(int16 champIndex, int16 skillIndex);// @ F0303_CHAMPION_GetSkillLevel + uint16 f303_getSkillLevel(int16 champIndex, uint16 skillIndex);// @ F0303_CHAMPION_GetSkillLevel Common::String f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger void f299_applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics -- cgit v1.2.3 From 75fe72b27cd2a76a2ecee8f0476a9ef089e6d857 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 13 Jul 2016 19:12:55 +0200 Subject: DM: Add input timeout and fix movement after throwing a projectile --- engines/dm/dm.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 194bfa2a8a..6a50e3eade 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -369,9 +369,6 @@ T0002002: if (!(_g313_gameTime & 511)) _inventoryMan->f338_decreaseTorchesLightPower(); - if (_g310_disabledMovementTicks) - _g310_disabledMovementTicks--; - if (_championMan->_g407_party._freezeLifeTicks) _championMan->_g407_party._freezeLifeTicks -= 1; @@ -384,10 +381,12 @@ T0002002: if (_g310_disabledMovementTicks) _g310_disabledMovementTicks--; - // F0044_TEXT_MESSAGEAREA_ClearExpiredRows(); + if (_g311_projectileDisableMovementTicks) + _g311_projectileDisableMovementTicks--; + // F0044_TEXT_MESSAGEAREA_ClearExpiredRows(); _g321_stopWaitingForPlayerInput = false; - + uint16 vblankCounter = 0; do { _eventMan->processInput(); @@ -406,9 +405,12 @@ T0002002: // if (!_vm->_g321_stopWaitingForPlayerInput) { // F0363_COMMAND_HighlightBoxDisable(); // } - } while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking); - _system->delayMillis(18); + _system->delayMillis(2); + if (++vblankCounter >= _g318_waitForInputMaxVerticalBlankCount * 5) + _g321_stopWaitingForPlayerInput = true; + + } while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking); } } -- cgit v1.2.3 From 3a654ff91e8548caf4365c657d5110b9d4a36c3e Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 13 Jul 2016 19:51:14 +0200 Subject: DM: Add ChampionMan::f320_applyAndDrawPendingDamageAndWounds() --- engines/dm/champion.cpp | 219 ++++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/champion.h | 5 +- engines/dm/dm.cpp | 2 +- engines/dm/dungeonman.h | 1 + engines/dm/eventman.cpp | 7 +- engines/dm/eventman.h | 2 + engines/dm/gfx.h | 2 + 7 files changed, 235 insertions(+), 3 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 52be549f61..b9bb5e3d2c 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -35,6 +35,7 @@ #include "timeline.h" #include "projexpl.h" #include "group.h" +#include "movesens.h" namespace DM { @@ -1335,6 +1336,224 @@ void ChampionMan::f326_championShootProjectile(Champion* champ, Thing thing, int _vm->_g312_lastProjectileDisabledMovementDirection = L0990_ui_Direction; } +void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() { + uint16 L0967_ui_ChampionIndex; + uint16 L0968_ui_PendingDamage; + int16 L0969_i_Multiple; +#define AL0969_i_Health L0969_i_Multiple +#define AL0969_i_X L0969_i_Multiple +#define AL0969_i_EventIndex L0969_i_Multiple + int16 L0970_i_PendingWounds; + Champion* L0971_ps_Champion; + TimelineEvent* L0972_ps_Event; + int16 L0973_i_Y; + TimelineEvent L0974_s_Event; + Box L0975_s_Box; + + + L0971_ps_Champion = _vm->_championMan->_gK71_champions; + for (L0967_ui_ChampionIndex = k0_ChampionFirst; L0967_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0967_ui_ChampionIndex++, L0971_ps_Champion++) { + setFlag(L0971_ps_Champion->_wounds, L0970_i_PendingWounds = _g410_championPendingWounds[L0967_ui_ChampionIndex]); + _g410_championPendingWounds[L0967_ui_ChampionIndex] = 0; + if (!(L0968_ui_PendingDamage = _g409_championPendingDamage[L0967_ui_ChampionIndex])) + continue; + _g409_championPendingDamage[L0967_ui_ChampionIndex] = 0; + if (!(AL0969_i_Health = L0971_ps_Champion->_currHealth)) + continue; + if ((AL0969_i_Health = AL0969_i_Health - L0968_ui_PendingDamage) <= 0) { + _vm->_championMan->f319_championKill(L0967_ui_ChampionIndex); + } else { + L0971_ps_Champion->_currHealth = AL0969_i_Health; + setFlag(L0971_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); + if (L0970_i_PendingWounds) { + setFlag(L0971_ps_Champion->_attributes, k0x2000_ChampionAttributeWounds); + } + AL0969_i_X = L0967_ui_ChampionIndex * k69_ChampionStatusBoxSpacing; + L0975_s_Box._y1 = 0; + _vm->_eventMan->f78_showMouse(); + if (_vm->M0_indexToOrdinal(L0967_ui_ChampionIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) { + L0975_s_Box._y2 = 28; + L0975_s_Box._x2 = (L0975_s_Box._x1 = AL0969_i_X + 7) + 31; /* Box is over the champion portrait in the status box */ + _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k16_damageToChampionBig), &L0975_s_Box, k16_byteWidth, k10_ColorFlesh, 29); + if (L0968_ui_PendingDamage < 10) { /* 1 digit */ + AL0969_i_X += 21; + } else { + if (L0968_ui_PendingDamage < 100) { /* 2 digits */ + AL0969_i_X += 18; + } else { /* 3 digits */ + AL0969_i_X += 15; + } + } + L0973_i_Y = 16; + } else { + L0975_s_Box._y2 = 6; + L0975_s_Box._x2 = (L0975_s_Box._x1 = AL0969_i_X) + 47; /* Box is over the champion name in the status box */ + _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k15_damageToChampionSmallIndice), &L0975_s_Box, k24_byteWidth, k10_ColorFlesh, 7); + if (L0968_ui_PendingDamage < 10) { /* 1 digit */ + AL0969_i_X += 19; + } else { + if (L0968_ui_PendingDamage < 100) { /* 2 digits */ + AL0969_i_X += 16; + } else { /* 3 digits */ + AL0969_i_X += 13; + } + } + L0973_i_Y = 5; + } + _vm->_textMan->f53_printToLogicalScreen(AL0969_i_X, L0973_i_Y, k15_ColorWhite, k8_ColorRed, _vm->_championMan->f288_getStringFromInteger(L0968_ui_PendingDamage, false, 3).c_str()); + if ((AL0969_i_EventIndex = L0971_ps_Champion->_hideDamageReceivedIndex) == -1) { + L0974_s_Event._type = k12_TMEventTypeHideDamageReceived; + M33_setMapAndTime(L0974_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5); + L0974_s_Event._priority = L0967_ui_ChampionIndex; + L0971_ps_Champion->_hideDamageReceivedIndex = _vm->_timeline->f238_addEventGetEventIndex(&L0974_s_Event); + } else { + L0972_ps_Event = &_vm->_timeline->_g370_events[AL0969_i_EventIndex]; + M33_setMapAndTime(L0972_ps_Event->_mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5); + _vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(AL0969_i_EventIndex)); + } + _vm->_championMan->f292_drawChampionState((ChampionIndex)L0967_ui_ChampionIndex); + _vm->_eventMan->f77_hideMouse(); + } + } +} + +void ChampionMan::f319_championKill(uint16 champIndex) { + uint16 L0962_ui_Multiple = 0; +#define AL0962_ui_Cell L0962_ui_Multiple +#define AL0962_ui_ChampionIconIndex L0962_ui_Multiple + int16 L0963_i_AliveChampionIndex; + Thing L0964_T_Thing; + Champion* L0965_ps_Champion; + Junk* L0966_ps_Junk; + + + L0965_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; + L0965_ps_Champion->_currHealth = 0; + setFlag(L0965_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox); + if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) { + if (_vm->_g331_pressingEye) { + _vm->_g331_pressingEye = false; + _vm->_eventMan->_g597_ignoreMouseMovements = false; + if (!_vm->_championMan->_g415_leaderEmptyHanded) { + _vm->_objectMan->f34_drawLeaderObjectName(_vm->_championMan->_g414_leaderHandObject); + } + _vm->_eventMan->_g587_hideMousePointerRequestCount = 1; + _vm->_eventMan->f77_hideMouse(); + } else { + if (_vm->_g333_pressingMouth) { + _vm->_g333_pressingMouth = false; + _vm->_eventMan->_g597_ignoreMouseMovements = false; + _vm->_eventMan->_g587_hideMousePointerRequestCount = 1; + _vm->_eventMan->f77_hideMouse(); + } + } + _vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory); + } + f318_dropAllObjects(champIndex); + L0964_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k0x8000_championBones | k10_JunkThingType); + if (L0964_T_Thing == Thing::_none) { + } else { + L0966_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0964_T_Thing); + L0966_ps_Junk->setType(k5_JunkTypeBones); + L0966_ps_Junk->setDoNotDiscard(true); + L0966_ps_Junk->setChargeCount(champIndex); + AL0962_ui_Cell = L0965_ps_Champion->_cell; + _vm->_movsens->f267_getMoveResult(M15_thingWithNewCell(L0964_T_Thing, AL0962_ui_Cell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); + } + L0965_ps_Champion->_symbolStep = 0; + L0965_ps_Champion->_symbols[0] = '\0'; + L0965_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir; + L0965_ps_Champion->_maximumDamageReceived = 0; + AL0962_ui_ChampionIconIndex = _vm->_championMan->M26_championIconIndex(AL0962_ui_Cell, _vm->_dungeonMan->_g308_partyDir); + if (_vm->M0_indexToOrdinal(AL0962_ui_ChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) { + _vm->_eventMan->_g598_mousePointerBitmapUpdated = true; + _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone); + warning(false, "IGNORED CODE:G0592_B_BuildMousePointerScreenAreaRequested = true"); + } + if (L0965_ps_Champion->_poisonEventCount) { + f323_unpoison(champIndex); + } + _vm->_displayMan->_g578_useByteBoxCoordinates = false; + _vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0962_ui_ChampionIconIndex << 2], k0_ColorBlack); + _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); + for (L0963_i_AliveChampionIndex = k0_ChampionFirst, L0965_ps_Champion = _vm->_championMan->_gK71_champions; L0963_i_AliveChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0963_i_AliveChampionIndex++, L0965_ps_Champion++) { + if (L0965_ps_Champion->_currHealth) + break; + } + if (L0963_i_AliveChampionIndex == _vm->_championMan->_g305_partyChampionCount) { /* BUG0_43 The game does not end if the last living champion in the party is killed while looking at a candidate champion in a portrait. The condition to end the game when the whole party is killed is not true because the code considers the candidate champion as alive (in the loop above) */ + _vm->_championMan->_g303_partyDead = true; + return; + } + if (champIndex == _vm->_championMan->_g411_leaderIndex) { + _vm->_eventMan->f368_commandSetLeader((ChampionIndex)L0963_i_AliveChampionIndex); + } + if (champIndex == _vm->_championMan->_g514_magicCasterChampionIndex) { + _vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(L0963_i_AliveChampionIndex); + } else { + _vm->_menuMan->f393_drawSpellAreaControls(_vm->_championMan->_g514_magicCasterChampionIndex); + } +} + +void ChampionMan::f318_dropAllObjects(uint16 champIndex) { + static int16 G0057_ai_Graphic562_SlotDropOrder[30] = { + k5_ChampionSlotFeet, + k4_ChampionSlotLegs, + k9_ChampionSlotQuiverLine_2_2, + k8_ChampionSlotQuiverLine_1_2, + k7_ChampionSlotQuiverLine_2_1, + k12_ChampionSlotQuiverLine_1_1, + k6_ChampionSlotPouch_2, + k11_ChampionSlotPouch_1, + k3_ChampionSlotTorso, + k13_ChampionSlotBackpackLine_1_1, + k14_ChampionSlotBackpackLine_2_2, + k15_ChampionSlotBackpackLine_2_3, + k16_ChampionSlotBackpackLine_2_4, + k17_ChampionSlotBackpackLine_2_5, + k18_ChampionSlotBackpackLine_2_6, + k19_ChampionSlotBackpackLine_2_7, + k20_ChampionSlotBackpackLine_2_8, + k21_ChampionSlotBackpackLine_2_9, + k22_ChampionSlotBackpackLine_1_2, + k23_ChampionSlotBackpackLine_1_3, + k24_ChampionSlotBackpackLine_1_4, + k25_ChampionSlotBackpackLine_1_5, + k26_ChampionSlotBackpackLine_1_6, + k27_ChampionSlotBackpackLine_1_7, + k28_ChampionSlotBackpackLine_1_8, + k29_ChampionSlotBackpackLine_1_9, + k10_ChampionSlotNeck, + k2_ChampionSlotHead, + k0_ChampionSlotReadyHand, + k1_ChampionSlotActionHand}; + + uint16 L0959_ui_Cell; + Thing L0960_T_Thing; + uint16 L0961_ui_SlotIndex; + + L0959_ui_Cell = _vm->_championMan->_gK71_champions[champIndex]._cell; + for (L0961_ui_SlotIndex = k0_ChampionSlotReadyHand; L0961_ui_SlotIndex < k30_ChampionSlotChest_1; L0961_ui_SlotIndex++) { + if ((L0960_T_Thing = f300_getObjectRemovedFromSlot(champIndex, G0057_ai_Graphic562_SlotDropOrder[L0961_ui_SlotIndex])) != Thing::_none) { + _vm->_movsens->f267_getMoveResult(M15_thingWithNewCell(L0960_T_Thing, L0959_ui_Cell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); + } + } +} + +void ChampionMan::f323_unpoison(int16 champIndex) { + int16 L0982_i_EventIndex; + TimelineEvent* L0983_ps_Event; + + if (champIndex == kM1_ChampionNone) { + return; + } + for (L0982_i_EventIndex = 0, L0983_ps_Event = _vm->_timeline->_g370_events; L0982_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0983_ps_Event++, L0982_i_EventIndex++) { + if ((L0983_ps_Event->_type== k75_TMEventTypePoisonChampion) && (L0983_ps_Event->_priority == champIndex)) { + _vm->_timeline->f237_deleteEvent(L0982_i_EventIndex); + } + } + _vm->_championMan->_gK71_champions[champIndex]._poisonEventCount = 0; +} + ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) { for (uint16 i = 0; i < _g305_partyChampionCount; ++i) { if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 5d98ecbd41..2bb23809a0 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -575,7 +575,10 @@ public: bool f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount); // @ F0327_CHAMPION_IsProjectileSpellCast void f326_championShootProjectile(Champion *champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy); // @ F0326_CHAMPION_ShootProjectile - + void f320_applyAndDrawPendingDamageAndWounds(); // @ F0320_CHAMPION_ApplyAndDrawPendingDamageAndWounds + void f319_championKill(uint16 champIndex); // @ F0319_CHAMPION_Kill + void f318_dropAllObjects(uint16 champIndex); // @ F0318_CHAMPION_DropAllObjects + void f323_unpoison(int16 champIndex); // @ F0323_CHAMPION_Unpoison }; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 6a50e3eade..317508a9f8 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -361,7 +361,7 @@ T0002002: } // F0363_COMMAND_HighlightBoxDisable(); // F0065_SOUND_PlayPendingSound_CPSD(); - // F0320_CHAMPION_ApplyAndDrawPendingDamageAndWounds + _championMan->f320_applyAndDrawPendingDamageAndWounds(); if (_championMan->_g303_partyDead) break; _g313_gameTime++; diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 515ef93413..a9bc369efe 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -495,6 +495,7 @@ public: uint16 getChargeCount() { return (_attributes >> 14) & 0x3; } void setChargeCount(uint16 val) { _attributes = (_attributes & ~(0x3 << 14)) | ((val & 0x3) << 14); } uint16 getDoNotDiscard() { return (_attributes >> 7) & 1; } + void setDoNotDiscard(uint16 val) { _attributes = (_attributes & ~(1 << 7)) | ((val & 1) << 7); } Thing getNextThing() { return _nextThing; } void setNextThing(Thing thing) { _nextThing = thing; } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index b1ffe30af6..5fe80e2eda 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -355,6 +355,8 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) { _gK100_preventBuildPointerScreenArea = false; _g443_primaryKeyboardInput = nullptr; _g444_secondaryKeyboardInput = nullptr; + _g597_ignoreMouseMovements = false; + _g587_hideMousePointerRequestCount = 0; } EventManager::~EventManager() { @@ -518,10 +520,12 @@ void EventManager::f69_setMousePointer() { } void EventManager::f78_showMouse() { + //if(_g587_hideMousePointerRequestCount++ == 0) CursorMan.showMouse(true); } void EventManager::f77_hideMouse() { + // if(_g587_hideMousePointerRequestCount-- == 1) // CursorMan.showMouse(false); } @@ -564,7 +568,8 @@ void EventManager::processInput() { } case Common::EVENT_MOUSEMOVE: - _mousePos = event.mouse; + if (!_g597_ignoreMouseMovements) + _mousePos = event.mouse; break; case Common::EVENT_LBUTTONDOWN: case Common::EVENT_RBUTTONDOWN: diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index 24fca0f261..0a77cf8064 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -268,6 +268,8 @@ public: uint16 _g599_useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap KeyboardInput *_g443_primaryKeyboardInput; // @ G0443_ps_PrimaryKeyboardInput KeyboardInput *_g444_secondaryKeyboardInput; // @ G0444_ps_SecondaryKeyboardInput + bool _g597_ignoreMouseMovements;// @ G0597_B_IgnoreMouseMovements + int16 _g587_hideMousePointerRequestCount; // @ G0587_i_HideMousePointerRequestCount void initMouse(); void f67_setMousePointerToNormal(int16 mousePointer); // @ F0067_MOUSE_SetPointerToNormal diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 2ca77b99d1..d1cc5b77cd 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -207,6 +207,8 @@ enum GraphicIndice { k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA k11_MenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES k13_MovementArrowsIndice = 13, // @ C013_GRAPHIC_MOVEMENT_ARROWS + k15_damageToChampionSmallIndice = 15, // @ C015_GRAPHIC_DAMAGE_TO_CHAMPION_SMALL + k16_damageToChampionBig = 16, // @ C016_GRAPHIC_DAMAGE_TO_CHAMPION_BIG k17_InventoryGraphicIndice = 17, // @ C017_GRAPHIC_INVENTORY k18_ArrowForChestContentIndice = 18, // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT k19_EyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION -- cgit v1.2.3 From 3f01beea8aff2177c90dda0a5195f7c348e71baa Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 14 Jul 2016 14:13:41 +0200 Subject: DM: Add ChampionMan::f331_applyTimeEffects --- engines/dm/champion.cpp | 154 +++++++++++++++++++++++++++++++++++++++++++++++- engines/dm/champion.h | 1 + engines/dm/dm.cpp | 6 +- 3 files changed, 157 insertions(+), 4 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b9bb5e3d2c..717e182b62 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1547,13 +1547,165 @@ void ChampionMan::f323_unpoison(int16 champIndex) { return; } for (L0982_i_EventIndex = 0, L0983_ps_Event = _vm->_timeline->_g370_events; L0982_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0983_ps_Event++, L0982_i_EventIndex++) { - if ((L0983_ps_Event->_type== k75_TMEventTypePoisonChampion) && (L0983_ps_Event->_priority == champIndex)) { + if ((L0983_ps_Event->_type == k75_TMEventTypePoisonChampion) && (L0983_ps_Event->_priority == champIndex)) { _vm->_timeline->f237_deleteEvent(L0982_i_EventIndex); } } _vm->_championMan->_gK71_champions[champIndex]._poisonEventCount = 0; } +void ChampionMan::f331_applyTimeEffects() { + uint16 L1006_ui_Multiple; +#define AL1006_ui_GameTime L1006_ui_Multiple +#define AL1006_ui_ChampionIndex L1006_ui_Multiple + uint16 L1007_ui_Multiple; +#define AL1007_ui_ScentIndex L1007_ui_Multiple +#define AL1007_ui_ManaGain L1007_ui_Multiple +#define AL1007_ui_StaminaGainCycleCount L1007_ui_Multiple +#define AL1007_ui_StatisticIndex L1007_ui_Multiple + uint16 L1008_ui_Multiple; +#define AL1008_ui_WizardSkillLevel L1008_ui_Multiple +#define AL1008_ui_Delay L1008_ui_Multiple +#define AL1008_ui_StaminaAboveHalf L1008_ui_Multiple +#define AL1008_ui_StatisticMaximum L1008_ui_Multiple + int16 L1009_i_Multiple; +#define AL1009_i_SkillIndex L1009_i_Multiple +#define AL1009_i_StaminaMagnitude L1009_i_Multiple +#define AL1009_i_StaminaLoss L1009_i_Multiple + Champion* L1010_ps_Champion; + unsigned char* L1011_puc_Statistic; + uint16 L1012_ui_TimeCriteria; + int16 L1013_i_Multiple; +#define AL1013_i_StaminaAmount L1013_i_Multiple +#define AL1013_i_HealthGain L1013_i_Multiple + Scent L1014_s_Scent; + + + if (!_vm->_championMan->_g305_partyChampionCount) { + return; + } + L1014_s_Scent.setMapX(_vm->_dungeonMan->_g306_partyMapX); + L1014_s_Scent.setMapY(_vm->_dungeonMan->_g307_partyMapY); + L1014_s_Scent.setMapIndex(_vm->_dungeonMan->_g309_partyMapIndex); + AL1007_ui_ScentIndex = 0; + while ((int16)AL1007_ui_ScentIndex < (int16)(_vm->_championMan->_g407_party._scentCount - 1)) { + if (&_vm->_championMan->_g407_party._scents[AL1007_ui_ScentIndex] != &L1014_s_Scent) { + if (!(_vm->_championMan->_g407_party._scentStrengths[AL1007_ui_ScentIndex] = MAX(0, _vm->_championMan->_g407_party._scentStrengths[AL1007_ui_ScentIndex] - 1)) && !AL1007_ui_ScentIndex) { + f316_deleteScent(0); + continue; + } + } + AL1007_ui_ScentIndex++; + } + AL1006_ui_GameTime = _vm->_g313_gameTime; + L1012_ui_TimeCriteria = (((AL1006_ui_GameTime & 0x0080) + ((AL1006_ui_GameTime & 0x0100) >> 2)) + ((AL1006_ui_GameTime & 0x0040) << 2)) >> 2; + for (AL1006_ui_ChampionIndex = k0_ChampionFirst, L1010_ps_Champion = _vm->_championMan->_gK71_champions; AL1006_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL1006_ui_ChampionIndex++, L1010_ps_Champion++) { + if (L1010_ps_Champion->_currHealth && (_vm->M0_indexToOrdinal(AL1006_ui_ChampionIndex) != _vm->_championMan->_g299_candidateChampionOrdinal)) { + if ((L1010_ps_Champion->_currMana < L1010_ps_Champion->_maxMana) && (L1012_ui_TimeCriteria < (L1010_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + (AL1008_ui_WizardSkillLevel = _vm->_championMan->f303_getSkillLevel(AL1006_ui_ChampionIndex, k3_ChampionSkillWizard) + _vm->_championMan->f303_getSkillLevel(AL1006_ui_ChampionIndex, k2_ChampionSkillPriest))))) { + AL1007_ui_ManaGain = L1010_ps_Champion->_maxMana / 40; + if (_vm->_championMan->_g300_partyIsSleeping) { + AL1007_ui_ManaGain = AL1007_ui_ManaGain << 1; + } + AL1007_ui_ManaGain++; + f325_decrementStamine(AL1006_ui_ChampionIndex, AL1007_ui_ManaGain * MAX(7, 16 - AL1008_ui_WizardSkillLevel)); + L1010_ps_Champion->_currMana += MIN(AL1007_ui_ManaGain, (uint16)(L1010_ps_Champion->_maxMana - L1010_ps_Champion->_currMana)); + } else { + if (L1010_ps_Champion->_currMana > L1010_ps_Champion->_maxMana) { + L1010_ps_Champion->_currMana--; + } + } + for (AL1009_i_SkillIndex = k19_ChampionSkillWater; AL1009_i_SkillIndex >= k0_ChampionSkillFighter; AL1009_i_SkillIndex--) { + if (L1010_ps_Champion->_skills[AL1009_i_SkillIndex]._temporaryExperience > 0) { + L1010_ps_Champion->_skills[AL1009_i_SkillIndex]._temporaryExperience--; + } + } + AL1007_ui_StaminaGainCycleCount = 4; + AL1009_i_StaminaMagnitude = L1010_ps_Champion->_maxStamina; + while (L1010_ps_Champion->_currStamina < (AL1009_i_StaminaMagnitude >>= 1)) { + AL1007_ui_StaminaGainCycleCount += 2; + } + AL1009_i_StaminaLoss = 0; + AL1013_i_StaminaAmount = f26_getBoundedValue(1, (L1010_ps_Champion->_maxStamina >> 8) - 1, 6); + if (_vm->_championMan->_g300_partyIsSleeping) { + AL1013_i_StaminaAmount <<= 1; + } + if ((AL1008_ui_Delay = (_vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime)) > 80) { + AL1013_i_StaminaAmount++; + if (AL1008_ui_Delay > 250) { + AL1013_i_StaminaAmount++; + } + } + do { + AL1008_ui_StaminaAboveHalf = (AL1007_ui_StaminaGainCycleCount <= 4); + if (L1010_ps_Champion->_food < -512) { + if (AL1008_ui_StaminaAboveHalf) { + AL1009_i_StaminaLoss += AL1013_i_StaminaAmount; + L1010_ps_Champion->_food -= 2; + } + } else { + if (L1010_ps_Champion->_food >= 0) { + AL1009_i_StaminaLoss -= AL1013_i_StaminaAmount; + } + L1010_ps_Champion->_food -= AL1008_ui_StaminaAboveHalf ? 2 : AL1007_ui_StaminaGainCycleCount >> 1; + } + if (L1010_ps_Champion->_water < -512) { + if (AL1008_ui_StaminaAboveHalf) { + AL1009_i_StaminaLoss += AL1013_i_StaminaAmount; + L1010_ps_Champion->_water -= 1; + } + } else { + if (L1010_ps_Champion->_water >= 0) { + AL1009_i_StaminaLoss -= AL1013_i_StaminaAmount; + } + L1010_ps_Champion->_water -= AL1008_ui_StaminaAboveHalf ? 1 : AL1007_ui_StaminaGainCycleCount >> 2; + } + } while (--AL1007_ui_StaminaGainCycleCount && ((L1010_ps_Champion->_currStamina - AL1009_i_StaminaLoss) < L1010_ps_Champion->_maxStamina)); + f325_decrementStamine(AL1006_ui_ChampionIndex, AL1009_i_StaminaLoss); + if (L1010_ps_Champion->_food < -1024) { + L1010_ps_Champion->_food = -1024; + } + if (L1010_ps_Champion->_water < -1024) { + L1010_ps_Champion->_water = -1024; + } + if ((L1010_ps_Champion->_currHealth < L1010_ps_Champion->_maxHealth) && (L1010_ps_Champion->_currStamina >= (L1010_ps_Champion->_maxStamina >> 2)) && (L1012_ui_TimeCriteria < (L1010_ps_Champion->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] + 12))) { + AL1013_i_HealthGain = (L1010_ps_Champion->_maxHealth >> 7) + 1; + if (_vm->_championMan->_g300_partyIsSleeping) { + AL1013_i_HealthGain <<= 1; + } + if (_vm->_objectMan->f33_getIconIndex(L1010_ps_Champion->_slots[k10_ChampionSlotNeck]) == k121_IconIndiceJunkEkkhardCross) { + AL1013_i_HealthGain += (AL1013_i_HealthGain >> 1) + 1; + } + L1010_ps_Champion->_currHealth += MIN(AL1013_i_HealthGain, (int16)(L1010_ps_Champion->_maxHealth - L1010_ps_Champion->_currHealth)); + } + if (!((int)_vm->_g313_gameTime & (_vm->_championMan->_g300_partyIsSleeping ? 63 : 255))) { + for (AL1007_ui_StatisticIndex = k0_ChampionStatLuck; AL1007_ui_StatisticIndex <= k6_ChampionStatAntifire; AL1007_ui_StatisticIndex++) { + L1011_puc_Statistic = L1010_ps_Champion->_statistics[AL1007_ui_StatisticIndex]; + AL1008_ui_StatisticMaximum = L1011_puc_Statistic[k0_ChampionStatMaximum]; + if (L1011_puc_Statistic[k1_ChampionStatCurrent] < AL1008_ui_StatisticMaximum) { + L1011_puc_Statistic[k1_ChampionStatCurrent]++; + } else { + if (L1011_puc_Statistic[k1_ChampionStatCurrent] > AL1008_ui_StatisticMaximum) { + L1011_puc_Statistic[k1_ChampionStatCurrent] -= L1011_puc_Statistic[k1_ChampionStatCurrent] / AL1008_ui_StatisticMaximum; + } + } + } + } + if (!_vm->_championMan->_g300_partyIsSleeping && (L1010_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime < (_vm->_g313_gameTime - 60))) { + L1010_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir; + L1010_ps_Champion->_maximumDamageReceived = 0; + setFlag(L1010_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon); + } + setFlag(L1010_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); + if (_vm->M0_indexToOrdinal(AL1006_ui_ChampionIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) { + if (_vm->_g333_pressingMouth || _vm->_g331_pressingEye || (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) { + setFlag(L1010_ps_Champion->_attributes, k0x0800_ChampionAttributePanel); + } + } + } + } + f293_drawAllChampionStates(); +} + ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) { for (uint16 i = 0; i < _g305_partyChampionCount; ++i) { if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 2bb23809a0..d4491d50c8 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -579,6 +579,7 @@ public: void f319_championKill(uint16 champIndex); // @ F0319_CHAMPION_Kill void f318_dropAllObjects(uint16 champIndex); // @ F0318_CHAMPION_DropAllObjects void f323_unpoison(int16 champIndex); // @ F0323_CHAMPION_Unpoison + void f331_applyTimeEffects(); // @ F0331_CHAMPION_ApplyTimeEffects_CPSF }; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 317508a9f8..2bd4a2e753 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -374,9 +374,9 @@ T0002002: _menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived(); - // if (!((int)_vm->_g313_gameTime & (_vm->_championMan->_g300_partyIsSleeping ? 15 : 63))) { - // F0331_CHAMPION_ApplyTimeEffects_CPSF(); - // } + if (!((int32)_g313_gameTime & (_championMan->_g300_partyIsSleeping ? 15 : 63))) { + _championMan->f331_applyTimeEffects(); + } if (_g310_disabledMovementTicks) _g310_disabledMovementTicks--; -- cgit v1.2.3 From 78cf0030e3545eabe254a9643c1c9570d5e1068d Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 14 Jul 2016 15:53:07 +0200 Subject: DM: Fix missing messages at the bottom of the screen --- engines/dm/TODOs/todo.txt | 5 ++--- engines/dm/dm.cpp | 2 +- engines/dm/text.cpp | 30 ++++++++++++++++++++++++++---- engines/dm/text.h | 4 ++-- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index d8821e6015..70c000870e 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -7,6 +7,8 @@ Bugs: Logic: When object are put on the right side of the current square, they disappear Drawing door ornaments segfaults when going back to the start + Stepping onto the plate next doesn't open the grated gate on the 0th level + Walking into walls corrupts memory Possible bugs: @@ -26,7 +28,4 @@ Todo: Finish stuff: f380_processCommandQueue Missing main loop methods - F0577_VBLANK_Handler, if enought time passes, takes the player's chance to act - - TODO: implement it - - NOTE: _g318_waitForInputMaxVerticalBlankCount is already included in the engine diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 2bd4a2e753..b3018bafe5 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -384,7 +384,7 @@ T0002002: if (_g311_projectileDisableMovementTicks) _g311_projectileDisableMovementTicks--; - // F0044_TEXT_MESSAGEAREA_ClearExpiredRows(); + _textMan->f44_messageAreaClearExpiredRows(); _g321_stopWaitingForPlayerInput = false; uint16 vblankCounter = 0; do { diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index eff2447343..993cc8e27f 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -45,10 +45,12 @@ TextMan::~TextMan() { #define k5_LetterWidth 5 #define k6_LetterHeight 6 -void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, uint16 destX, uint16 destY, +void TextMan::f40_printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int16 destX, int16 destY, Color textColor, Color bgColor, const char* text, uint16 destHeight) { - destX -= 1; // fixes missalignment, to be checked - destY -= 4; // fixes missalignment, to be checked + if ((destX -= 1) < 0) // fixes missalignment, to be checked + destX = 0; + if ((destY -= 4) < 0) // fixes missalignment, to be checked + destY = 0; uint16 destPixelWidth = destByteWidth * 2; @@ -155,7 +157,7 @@ void TextMan::f46_messageAreaPrintString(Color color, const char* string) { L0030_i_StringLength = strlen(string); warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling"); if (true) { // there is a test here with F0561_SCROLLER_IsTextScrolling - _vm->_textMan->f53_printToLogicalScreen(_g359_messageAreaCursorColumn * 6, (_g358_messageAreaCursorRow * 7) + 177, color, k0_ColorBlack, string); + _vm->_textMan->f53_printToLogicalScreen(_g359_messageAreaCursorColumn * 6, (_g358_messageAreaCursorRow * 7 - 6) + 177, color, k0_ColorBlack, string); } else { f40_printTextToBitmap(_g356_bitmapMessageAreaNewRow, k160_byteWidthScreen, _g359_messageAreaCursorColumn * 6, 5, color, k0_ColorBlack, string, 7); warning(false, "MISSING CODE: F0561_SCROLLER_IsTextScrolling"); @@ -163,6 +165,7 @@ void TextMan::f46_messageAreaPrintString(Color color, const char* string) { } _g359_messageAreaCursorColumn += L0030_i_StringLength; _g360_messageAreaRowExpirationTime[_g358_messageAreaCursorRow] = _vm->_g313_gameTime + 200; + } void TextMan::f54_textInitialize() { @@ -189,4 +192,23 @@ void TextMan::f42_messageAreaMoveCursor(int16 column, int16 row) { } _g358_messageAreaCursorRow = row; } + +void TextMan::f44_messageAreaClearExpiredRows() { + uint16 L0026_ui_RowIndex; + int32 L0027_l_ExpirationTime; + Box L0028_s_Box; + + _vm->_displayMan->_g578_useByteBoxCoordinates = false; + L0028_s_Box._x1 = 0; + L0028_s_Box._x2 = 319; + for (L0026_ui_RowIndex = 0; L0026_ui_RowIndex < 4; L0026_ui_RowIndex++) { + L0027_l_ExpirationTime = _g360_messageAreaRowExpirationTime[L0026_ui_RowIndex]; + if ((L0027_l_ExpirationTime == -1) || (L0027_l_ExpirationTime > _vm->_g313_gameTime)) + continue; + L0028_s_Box._y2 = (L0028_s_Box._y1 = 172 + (L0026_ui_RowIndex * 7)) + 6; + warning(false, "MISSING CODE:F0561_SCROLLER_IsTextScrolling(&K0060_s_TextScroller, true);"); + _vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g348_bitmapScreen, L0028_s_Box, k0_ColorBlack, k160_byteWidthScreen, k200_heightScreen); + _g360_messageAreaRowExpirationTime[L0026_ui_RowIndex] = -1; + } +} } diff --git a/engines/dm/text.h b/engines/dm/text.h index ce38c55cbf..c07b8f2491 100644 --- a/engines/dm/text.h +++ b/engines/dm/text.h @@ -42,7 +42,7 @@ class TextMan { public: explicit TextMan(DMEngine *vm); ~TextMan(); - void f40_printTextToBitmap(byte *destBitmap, uint16 destByteWidth, uint16 destX, uint16 destY, + void f40_printTextToBitmap(byte *destBitmap, uint16 destByteWidth, int16 destX, int16 destY, Color textColor, Color bgColor, const char *text, uint16 destHeight); // @ F0040_TEXT_Print void f53_printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text); // @ F0053_TEXT_PrintToLogicalScreen void f52_printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor = k12_ColorDarkestGray); // @ F0052_TEXT_PrintToViewport @@ -54,7 +54,7 @@ public: void f46_messageAreaPrintString(Color color, const char* string);// @ F0046_TEXT_MESSAGEAREA_PrintString void f54_textInitialize(); // @ F0054_TEXT_Initialize void f42_messageAreaMoveCursor(int16 column, int16 row); // @ F0042_TEXT_MESSAGEAREA_MoveCursor - + void f44_messageAreaClearExpiredRows(); // @ F0044_TEXT_MESSAGEAREA_ClearExpiredRows }; -- cgit v1.2.3 From 9f9ac99b3198c09e58767ab2fe3eb71d03a5647e Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 14 Jul 2016 16:32:00 +0200 Subject: DM: Fix broken damage display --- engines/dm/TODOs/todo.txt | 2 +- engines/dm/gfx.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 70c000870e..47416c58df 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -8,7 +8,7 @@ Bugs: When object are put on the right side of the current square, they disappear Drawing door ornaments segfaults when going back to the start Stepping onto the plate next doesn't open the grated gate on the 0th level - Walking into walls corrupts memory + Damage to a champion's health is not getting reflected in the bar graphs, only when opening the inventory (maybe health is not getting set correctly) Possible bugs: diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index f05a8ca7bb..5efb3f05ac 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1445,7 +1445,7 @@ void DisplayMan::f21_blitToScreen(byte *bitmap, int16* box, int16 byteWidth, Col void DisplayMan::f21_blitToScreen(byte* bitmap, Box* box, int16 byteWidth, Color transparent, int16 height) { _g578_useByteBoxCoordinates = false; - f132_blitToBitmap(bitmap, _g348_bitmapScreen, *box, 0, 0, byteWidth, k112_byteWidthViewport, transparent, height, k136_heightViewport); + f132_blitToBitmap(bitmap, _g348_bitmapScreen, *box, 0, 0, byteWidth, k160_byteWidthScreen, transparent, height, k200_heightScreen); } void DisplayMan::f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f) { -- cgit v1.2.3 From 665ea3beff7be4d9240ff89b671d8e77038a0990 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 14 Jul 2016 17:04:53 +0200 Subject: DM: Fix champion bar graphs --- engines/dm/TODOs/todo.txt | 2 -- engines/dm/champion.cpp | 60 +++++++++++++++++++++++------------------------ 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 47416c58df..229ed8cb55 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -8,8 +8,6 @@ Bugs: When object are put on the right side of the current square, they disappear Drawing door ornaments segfaults when going back to the start Stepping onto the plate next doesn't open the grated gate on the 0th level - Damage to a champion's health is not getting reflected in the bar graphs, only when opening the inventory (maybe health is not getting set correctly) - Possible bugs: - k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 717e182b62..1590699e64 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1905,57 +1905,57 @@ T0280048: } void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) { - - Champion *curChampion = &_gK71_champions[champIndex]; - int16 barGraphIndex = 0; - int16 barGraphHeightArray[3]; - - if (curChampion->_currHealth > 0) { - uint32 barGraphHeight = (((uint32)(curChampion->_currHealth) << 10) * 25) / curChampion->_maxHealth; - if (barGraphHeight & 0x3FF) { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; + int16 barGraphHeights[3]; + Champion *champ = &_vm->_championMan->_gK71_champions[champIndex]; + int16 AL0842_i_BarGraphIndex = 0; + if (champ->_currHealth > 0) { + int32 barGraphHeight = (((int32)champ->_currHealth << 10) * 25) / champ->_maxHealth; + if (barGraphHeight & 0x000003FF) { + barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10) + 1; } else { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); + barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10); } } else { - barGraphHeightArray[barGraphIndex++] = 0; + barGraphHeights[AL0842_i_BarGraphIndex++] = 0; } - - if (curChampion->_currStamina > 0) { - uint32 barGraphHeight = (((uint32)(curChampion->_currStamina) << 10) * 25) / curChampion->_maxStamina; - if (barGraphHeight & 0x3FF) { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; + if (champ->_currStamina > 0) { + int32 barGraphHeight = (((int32)champ->_currStamina << 10) * 25) / champ->_maxStamina; + if (barGraphHeight & 0x000003FF) { + barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10) + 1; } else { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); + barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10); } } else { - barGraphHeightArray[barGraphIndex++] = 0; + barGraphHeights[AL0842_i_BarGraphIndex++] = 0; } - - if (curChampion->_currMana > 0) { - uint32 barGraphHeight = (((uint32)(curChampion->_currMana) << 10) * 25) / curChampion->_maxMana; - if (barGraphHeight & 0x3FF) { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10) + 1; + if (champ->_currMana > 0) { + if (champ->_currMana > champ->_maxMana) { + barGraphHeights[AL0842_i_BarGraphIndex] = 25; } else { - barGraphHeightArray[barGraphIndex++] = (barGraphHeight >> 10); + int32 barGraphHeight = (((int32)champ->_currMana << 10) * 25) / champ->_maxMana; + if (barGraphHeight & 0x000003FF) { + barGraphHeights[AL0842_i_BarGraphIndex] = (barGraphHeight >> 10) + 1; + } else { + barGraphHeights[AL0842_i_BarGraphIndex] = (barGraphHeight >> 10); + } } } else { - barGraphHeightArray[barGraphIndex++] = 0; + barGraphHeights[AL0842_i_BarGraphIndex] = 0; } _vm->_eventMan->f78_showMouse(); + // Strangerke - TO CHECK: if portraits, maybe the old (assembly) code is required for older versions Box box; box._x1 = champIndex * k69_ChampionStatusBoxSpacing + 46; box._x2 = box._x1 + 3; box._y1 = 2; box._y2 = 26; - - for (int16 AL_0_barGraphIndex = 0; AL_0_barGraphIndex < 3; AL_0_barGraphIndex++) { - int16 barGraphHeight = barGraphHeightArray[AL_0_barGraphIndex]; + for (int16 barGraphIndex = 0; barGraphIndex < 3; barGraphIndex++) { + int16 barGraphHeight = barGraphHeights[barGraphIndex]; if (barGraphHeight < 25) { box._y1 = 2; - box._y1 = 27 - barGraphHeight; - _vm->_displayMan->D24_fillScreenBox(box, g46_ChampionColor[champIndex]); + box._y2 = 27 - barGraphHeight; + _vm->_displayMan->D24_fillScreenBox(box, k12_ColorDarkestGray); } if (barGraphHeight) { box._y1 = 27 - barGraphHeight; -- cgit v1.2.3 From d7c7f110c1f63ec91c0837e09e9a614b6eee3cb2 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 14 Jul 2016 19:44:58 +0200 Subject: DM: Fix pressure plate on level 0 --- engines/dm/TODOs/todo.txt | 2 +- engines/dm/dm.cpp | 6 +++--- engines/dm/dungeonman.h | 2 +- engines/dm/movesens.cpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 229ed8cb55..71b8aa191b 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -7,7 +7,7 @@ Bugs: Logic: When object are put on the right side of the current square, they disappear Drawing door ornaments segfaults when going back to the start - Stepping onto the plate next doesn't open the grated gate on the 0th level + Placing one of the play icons from the top right corner into one of the champions' hands will crash the engine Possible bugs: - k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index b3018bafe5..526b60e5f1 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -322,9 +322,9 @@ Common::Error DMEngine::run() { void DMEngine::f2_gameloop() { warning(false, "DUMMY CODE: SETTING PARTY POS AND DIRECTION"); - _dungeonMan->_g306_partyMapX = 10; - _dungeonMan->_g307_partyMapY = 4; - _dungeonMan->_g308_partyDir = kDirNorth; + _dungeonMan->_g306_partyMapX = 9; + _dungeonMan->_g307_partyMapY = 9; + _dungeonMan->_g308_partyDir = kDirWest; _g318_waitForInputMaxVerticalBlankCount = 10; while (true) { diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index a9bc369efe..1a91d5d61e 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -315,7 +315,7 @@ public: Thing getNextThing() { return _nextThing; } void setNextThing(Thing thing) { _nextThing = thing; } SensorType getType() { return (SensorType)(_datAndType & 0x7F); } // @ M39_TYPE - uint16 getData() { return _datAndType >> 7; } // @ M40_DATA + uint16 getData() { return (_datAndType >> 7) & 0x1FF; } // @ M40_DATA static uint16 getDataMask1(uint16 data) { return (data >> 7) & 0xF; } // @ M42_MASK1 static uint16 getDataMask2(uint16 data) { return (data >> 11) & 0xF; } // @ M43_MASK2 void setData(int16 dat) { _datAndType = (_datAndType & 0x7F) | (dat << 7); } // @ M41_SET_DATA diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 34e83ca262..65742e6dbb 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -748,7 +748,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m int16 L0767_i_ThingType; bool L0768_B_TriggerSensor; Sensor* L0769_ps_Sensor; - uint16 L0770_ui_SensorTriggeredCell; + int16 L0770_ui_SensorTriggeredCell; uint16 L0771_ui_ThingType; bool L0772_B_SquareContainsObject; bool L0773_B_SquareContainsGroup; @@ -773,7 +773,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m if (Square(L0777_ui_Square = _vm->_dungeonMan->_g271_currMapData[mapX][mapY]).getType() == k0_ElementTypeWall) { L0770_ui_SensorTriggeredCell = thing.getCell(); } else { - L0770_ui_SensorTriggeredCell = (uint16)kM1_CellAny; // this will wrap around + L0770_ui_SensorTriggeredCell = kM1_CellAny; // this will wrap around } L0772_B_SquareContainsObject = L0773_B_SquareContainsGroup = L0775_B_SquareContainsThingOfSameType = L0776_B_SquareContainsThingOfDifferentType = false; L0766_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY); -- cgit v1.2.3 From 247b9210e1280aef243000b954e880054b4cfaa0 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 14 Jul 2016 20:23:09 +0200 Subject: DM: Some refactoring --- engines/dm/TODOs/todo.txt | 5 +++++ engines/dm/champion.cpp | 48 ++++++++++++++++++++++------------------------- engines/dm/objectman.cpp | 19 +++++++++---------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 71b8aa191b..5dd2caf8bf 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -8,6 +8,11 @@ Bugs: When object are put on the right side of the current square, they disappear Drawing door ornaments segfaults when going back to the start Placing one of the play icons from the top right corner into one of the champions' hands will crash the engine + Sometimes putting stuff in the player's hand segfaults + Footprints are everywhere + Object display is a bit mixed up with regards to which cell is it drawn in + Taking the stairs teleports the player to the wrong position + Possible bugs: - k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 1590699e64..7b2dc00ce6 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1162,8 +1162,6 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) } _g415_leaderEmptyHanded = false; _vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer); - - _vm->_eventMan->f78_showMouse(); _vm->_objectMan->f34_drawLeaderObjectName(thing); if (setMousePointer) { @@ -1262,49 +1260,47 @@ void ChampionMan::f283_viAltarRebirth(uint16 champIndex) { } void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) { - uint16 L0903_ui_ChampionIndex; - uint16 L0904_ui_SlotIndex; - Thing L0905_T_LeaderHandObject; - Thing L0906_T_SlotThing; - + uint16 champIndex; + uint16 slotIndex; if (slotBoxIndex < k8_SlotBoxInventoryFirstSlot) { - if (_vm->_championMan->_g299_candidateChampionOrdinal) { + if (_g299_candidateChampionOrdinal) { return; } - L0903_ui_ChampionIndex = slotBoxIndex >> 1; - if ((L0903_ui_ChampionIndex >= _vm->_championMan->_g305_partyChampionCount) || (_vm->M0_indexToOrdinal(L0903_ui_ChampionIndex) == (int)_vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_vm->_championMan->_gK71_champions[L0903_ui_ChampionIndex]._currHealth) { + champIndex = slotBoxIndex >> 1; + if ((champIndex >= _g305_partyChampionCount) || (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_gK71_champions[champIndex]._currHealth) { return; } - L0904_ui_SlotIndex = _vm->_championMan->M70_handSlotIndex(slotBoxIndex); + slotIndex = M70_handSlotIndex(slotBoxIndex); } else { - L0903_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal); - L0904_ui_SlotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot; + champIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal); + slotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot; } - L0905_T_LeaderHandObject = _vm->_championMan->_g414_leaderHandObject; - if (L0904_ui_SlotIndex >= k30_ChampionSlotChest_1) { - L0906_T_SlotThing = _vm->_inventoryMan->_g425_chestSlots[L0904_ui_SlotIndex - k30_ChampionSlotChest_1]; + Thing leaderHandObject = _g414_leaderHandObject; + Thing slotThing; + if (slotIndex >= k30_ChampionSlotChest_1) { + slotThing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1]; } else { - L0906_T_SlotThing = _vm->_championMan->_gK71_champions[L0903_ui_ChampionIndex]._slots[L0904_ui_SlotIndex]; + slotThing = _gK71_champions[champIndex]._slots[slotIndex]; } - if ((L0906_T_SlotThing == Thing::_none) && (L0905_T_LeaderHandObject == Thing::_none)) { + if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none)) { return; } - if ((L0905_T_LeaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0905_T_LeaderHandObject)]._allowedSlots & g38_slotMasks[L0904_ui_SlotIndex]))) { + if ((leaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & g38_slotMasks[slotIndex]))) { return; } _vm->_eventMan->f78_showMouse(); - if (L0905_T_LeaderHandObject != Thing::_none) { + if (leaderHandObject != Thing::_none) { f298_getObjectRemovedFromLeaderHand(); } - if (L0906_T_SlotThing != Thing::_none) { - f300_getObjectRemovedFromSlot(L0903_ui_ChampionIndex, L0904_ui_SlotIndex); - f297_putObjectInLeaderHand(L0906_T_SlotThing, false); + if (slotThing != Thing::_none) { + f300_getObjectRemovedFromSlot(champIndex, slotIndex); + f297_putObjectInLeaderHand(slotThing, false); } - if (L0905_T_LeaderHandObject != Thing::_none) { - _vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0903_ui_ChampionIndex, L0905_T_LeaderHandObject, (ChampionSlot)L0904_ui_SlotIndex); + if (leaderHandObject != Thing::_none) { + f301_addObjectInSlot((ChampionIndex)champIndex, leaderHandObject, (ChampionSlot) slotIndex); } - _vm->_championMan->f292_drawChampionState((ChampionIndex)L0903_ui_ChampionIndex); + f292_drawChampionState((ChampionIndex)champIndex); _vm->_eventMan->f77_hideMouse(); } diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index ea07c582bf..40c650b0f8 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -236,19 +236,18 @@ void ObjectMan::f38_drawIconInSlotBox(uint16 slotBoxIndex, int16 iconIndex) { #define k14_ObjectNameMaximumLength 14 // @ C014_OBJECT_NAME_MAXIMUM_LENGTH void ObjectMan::f34_drawLeaderObjectName(Thing thing) { - IconIndice iconIndex = f33_getIconIndex(thing); - char *objName; - char objectNameBuffer[16]; - if (iconIndex == k147_IconIndiceJunkChampionBones) { + char* objectName = nullptr; + int16 L0007_i_IconIndex = _vm->_objectMan->f33_getIconIndex(thing); + if (L0007_i_IconIndex == k147_IconIndiceJunkChampionBones) { Junk *junk = (Junk*)_vm->_dungeonMan->f156_getThingData(thing); - strcpy(objectNameBuffer, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name); - strcat(objectNameBuffer, _g352_objectNames[iconIndex]); - objName = objectNameBuffer; + char champBonesName[16]; + strcpy(champBonesName, _vm->_championMan->_gK71_champions[junk->getChargeCount()]._name); + strcat(champBonesName, _vm->_objectMan->_g352_objectNames[L0007_i_IconIndex]); + objectName = champBonesName; } else { - objName = _g352_objectNames[iconIndex]; + objectName = _vm->_objectMan->_g352_objectNames[L0007_i_IconIndex]; } - _vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, 233, 37, - k4_ColorCyan, k0_ColorBlack, objName, k14_ObjectNameMaximumLength, k200_heightScreen); + _vm->_textMan->f41_printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, 233, 37, k4_ColorCyan, k0_ColorBlack, objectName, k14_ObjectNameMaximumLength, k200_heightScreen); } IconIndice ObjectMan::f39_getIconIndexInSlotBox(uint16 slotBoxIndex) { -- cgit v1.2.3 From ac1b49496d13f173bc08274808b1c1878e743a11 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 15 Jul 2016 16:15:48 +0200 Subject: DM: Fix setting _g309_partyMapIndex when moving between levels --- engines/dm/TODOs/todo.txt | 2 +- engines/dm/dungeonman.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 5dd2caf8bf..d49ec2209f 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -11,7 +11,7 @@ Bugs: Sometimes putting stuff in the player's hand segfaults Footprints are everywhere Object display is a bit mixed up with regards to which cell is it drawn in - Taking the stairs teleports the player to the wrong position + Activegroup index segfaults when aknig the stairs Possible bugs: diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 3d1f931edb..063ccd0388 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -735,7 +735,7 @@ void DungeonMan::f173_setCurrentMap(uint16 mapIndex) { } void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) { - f173_setCurrentMap(mapIndex); + f173_setCurrentMap(_g309_partyMapIndex = mapIndex); byte *metaMapData = _g271_currMapData[_g273_currMapWidth - 1] + _g274_currMapHeight; _vm->_displayMan->_g264_currMapAllowedCreatureTypes = metaMapData; -- cgit v1.2.3 From bd9fa3eb87a08dd7ba6387ac7c2d911a040cd9c4 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 18 Jul 2016 18:23:30 +0200 Subject: DM: Engine now correctly set's the activeGroupIndex of groups --- engines/dm/TODOs/todo.txt | 2 +- engines/dm/dungeonman.cpp | 13 +++++-------- engines/dm/group.cpp | 13 ++++++------- engines/dm/group.h | 3 +-- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index d49ec2209f..4aa4d36360 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -11,7 +11,7 @@ Bugs: Sometimes putting stuff in the player's hand segfaults Footprints are everywhere Object display is a bit mixed up with regards to which cell is it drawn in - Activegroup index segfaults when aknig the stairs + The last resurrected character can't have stuff in their left hand, segfaults if I try to put stuff into it Possible bugs: diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 063ccd0388..956232bcd7 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1396,19 +1396,16 @@ int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDe int16 targetMapIndex; - if (_vm->_dungeonMan->_g309_partyMapIndex == k255_mapIndexEntrance) { + if (_g309_partyMapIndex == k255_mapIndexEntrance) { return kM1_mapIndexNone; } - map = _vm->_dungeonMan->_g277_dungeonMaps + mapIndex; + map = _g277_dungeonMaps + mapIndex; newMapX = map->_offsetMapX + *mapX; newMapY = map->_offsetMapY + *mapY; newLevel = map->_level + levelDelta; - map = _vm->_dungeonMan->_g277_dungeonMaps; - for (targetMapIndex = 0; targetMapIndex < _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount; targetMapIndex++) { - if ((map->_level == newLevel) - && (newMapX >= (offset = map->_offsetMapX)) - && (newMapX <= (offset + map->_width)) - && (newMapY >= (offset = map->_offsetMapY)) && (newMapY <= (offset + map->_height))) { + map = _g277_dungeonMaps; + for (targetMapIndex = 0; targetMapIndex < _g278_dungeonFileHeader._mapCount; targetMapIndex++) { + if ((map->_level == newLevel) && (newMapX >= (offset = map->_offsetMapX)) && (newMapX <= (offset + map->_width)) && (newMapY >= (offset = map->_offsetMapY)) && (newMapY <= (offset + map->_height))) { *mapY = newMapY - offset; *mapX = newMapX - map->_offsetMapX; return targetMapIndex; diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 617735e6b6..edb6056aff 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -1691,17 +1691,16 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) { L0344_i_ActiveGroupIndex = 0; while (L0341_ps_ActiveGroup->_groupThingIndex >= 0) { if (++L0344_i_ActiveGroupIndex >= _vm->_groupMan->_g376_maxActiveGroupCount) { - return; /* BUG0_11 Data corruption in memory. Each group located on the same map as the party has additional associated data but there is only provision for 60 instances (_vm->_groupMan->_g376_maxActiveGroupCount). If there are more groups at the same time then some of them do not get their instance and when the game accesses this information it will corrupt other data in memory (either the instance of another group, parts of the timeline or events). This situation cannot occur in the original Dungeon Master and Chaos Strikes Back dungeons for the following reasons (but it may occur in custom dungeons if they are not designed carefully): there is no map with already more than 60 groups in the original dungeons and none of the following 3 possible ways to move a group into a map can increase the number of instances above the maximum of 60: - - A group generator sensor is triggered: the game never generates a group on the party map if there are less than 5 instances available. This limits the actual number of groups on a map to 55 in most cases. - - A group falls through a pit from the map above (the creature type must be allowed on the target map): a group will never willingly move to an open pit square. It may move to a closed pit square and fall if the pit is then open (either automatically or triggered by the party on the map below). There are no such pits in the original dungeons. - - A group is teleported from another map (the creature type must be allowed on the target map): in the original dungeons, all teleporters whose scope include groups and target another map are either inaccessible to groups or the groups are not allowed on the target map. The only exception is for some Gigglers in the Chaos Strikes Back dungeon but there are not enough to use the 5 reserved instances. - - This code returns immediately if all ACTIVE_GROUP entries are already in use, which avoids an out of bounds access into _vm->_groupMan->_g375_activeGroups below (through L0341_ps_ActiveGroup). However in this case the specified group ends up without an associated ACTIVE_GROUP structure which is assumed everywhere in the code to be present for groups on the same map as the party. If there are more than 60 groups on the party map at any given time then this will corrupt memory (in _vm->_timeline->_g370_events and _vm->_timeline->_g371_timeline allocated in _vm->_timeline->f233_initTimeline before _vm->_groupMan->_g375_activeGroups) because of read and write operations at incorrect memory addresses (the 'Cells' value of the GROUP will be used as an index in _vm->_groupMan->_g375_activeGroups even though that value was not replaced by the index of an ACTIVE_GROUP in this function) */ + return; } L0341_ps_ActiveGroup++; } _g377_currActiveGroupCount++; - L0340_ps_Group = ((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType()); + + warning(false, "Code differs from the original in GroupMan::f183_addActiveGroup"); + //L0340_ps_Group = ((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType()); + L0340_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(f175_groupGetThing(mapX, mapY)); + L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells; L0340_ps_Group->getActiveGroupIndex() = L0344_i_ActiveGroupIndex; L0341_ps_ActiveGroup->_priorMapX = L0341_ps_ActiveGroup->_homeMapX = mapX; diff --git a/engines/dm/group.h b/engines/dm/group.h index fd7d98afe7..6578a20851 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -114,7 +114,6 @@ public: uint16 _type; uint16 _cells; uint16 _health[4]; -private: uint16 _flags; public: explicit Group(uint16 *rawDat) : _nextThing(rawDat[0]), _slot(rawDat[1]), _type(rawDat[2]), @@ -125,7 +124,7 @@ public: _health[3] = rawDat[7]; } - byte &getActiveGroupIndex() { return *(byte*)&_cells; } + uint16 &getActiveGroupIndex() { return _cells; } uint16 getBehaviour() { return _flags & 0xF; } uint16 setBehaviour(uint16 val) { _flags = (_flags & ~0xF) | (val & 0xF); return (val & 0xF); } -- cgit v1.2.3 From 11704d0c509c1fc5af73c22bd64be60572ff4b8c Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 19 Jul 2016 18:04:14 +0200 Subject: DM: Add savegame functions --- engines/dm/champion.cpp | 66 ++++++++++++++++++++- engines/dm/champion.h | 1 + engines/dm/dm.cpp | 9 +-- engines/dm/dm.h | 17 +++++- engines/dm/dungeonman.h | 2 +- engines/dm/group.cpp | 22 ++++++- engines/dm/group.h | 3 +- engines/dm/loadsave.cpp | 148 ++++++++++++++++++++++++++++++++++++++++++------ engines/dm/loadsave.h | 6 +- engines/dm/timeline.cpp | 19 +++++++ engines/dm/timeline.h | 2 + 11 files changed, 261 insertions(+), 34 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 7b2dc00ce6..f22d4dd605 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1295,10 +1295,10 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) } if (slotThing != Thing::_none) { f300_getObjectRemovedFromSlot(champIndex, slotIndex); - f297_putObjectInLeaderHand(slotThing, false); + f297_putObjectInLeaderHand(slotThing, false); } if (leaderHandObject != Thing::_none) { - f301_addObjectInSlot((ChampionIndex)champIndex, leaderHandObject, (ChampionSlot) slotIndex); + f301_addObjectInSlot((ChampionIndex)champIndex, leaderHandObject, (ChampionSlot)slotIndex); } f292_drawChampionState((ChampionIndex)champIndex); _vm->_eventMan->f77_hideMouse(); @@ -1702,6 +1702,68 @@ void ChampionMan::f331_applyTimeEffects() { f293_drawAllChampionStates(); } +void ChampionMan::save2_PartyPart(Common::OutSaveFile* file) { + for (uint16 i = 0; i < 4; ++i) { + Champion *champ = &_gK71_champions[i]; + file->writeUint16BE(champ->_attributes); + file->writeUint16BE(champ->_wounds); + for (uint16 y = 0; y < 7; ++y) + for (uint16 x = 0; x < 3; ++x) + file->writeByte(champ->_statistics[y][x]); + for (uint16 j = 0; j < 30; ++j) + file->writeUint16BE(champ->_slots[j].toUint16()); + for (uint16 j = 0; j < 20; ++j) { + file->writeSint16BE(champ->_skills[j]._temporaryExperience); + file->writeSint32BE(champ->_skills[j]._experience); + } + for (uint16 j = 0; j < 8; ++j) + file->writeByte(champ->_name[j]); + for (uint16 j = 0; j < 20; ++j) + file->writeByte(champ->_title[j]); + file->writeUint16BE(champ->_dir); + file->writeUint16BE(champ->_cell); + file->writeUint16BE(champ->_actionIndex); + file->writeUint16BE(champ->_symbolStep); + for(uint16 j = 0; j < 5; ++j) + file->writeByte(champ->_symbols[j]); + file->writeUint16BE(champ->_directionMaximumDamageReceived); + file->writeUint16BE(champ->_maximumDamageReceived); + file->writeUint16BE(champ->_poisonEventCount); + file->writeSint16BE(champ->_enableActionEventIndex); + file->writeSint16BE(champ->_hideDamageReceivedIndex); + file->writeSint16BE(champ->_currHealth); + file->writeSint16BE(champ->_maxHealth); + file->writeSint16BE(champ->_currStamina); + file->writeSint16BE(champ->_maxStamina); + file->writeSint16BE(champ->_currMana); + file->writeSint16BE(champ->_maxMana); + file->writeSint16BE(champ->_actionDefense); + file->writeSint16BE(champ->_food); + file->writeSint16BE(champ->_water); + file->writeUint16BE(champ->_load); + file->writeSint16BE(champ->_shieldDefense); + for (uint16 j = 0; j < 928; ++j) + file->writeByte(champ->_portrait[j]); + } + + Party &party = _g407_party; + file->writeSint16BE(party._magicalLightAmount); + file->writeByte(party._event73Count_ThievesEye); + file->writeByte(party._event79Count_Footprints); + file->writeSint16BE(party._shieldDefense); + file->writeSint16BE(party._fireShieldDefense); + file->writeSint16BE(party._spellShieldDefense); + file->writeByte(party._scentCount); + file->writeByte(party._freezeLifeTicks); + file->writeByte(party._firstScentIndex); + file->writeByte(party._lastScentIndex); + for(uint16 i = 0; i < 24; ++i) + file->writeUint16BE(party._scents[i].toUint16()); + for (uint16 i = 0; i < 24; ++i) + file->writeByte(party._scentStrengths[i]); + file->writeByte(party._event71Count_Invisibility); +} + ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) { for (uint16 i = 0; i < _g305_partyChampionCount; ++i) { if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index d4491d50c8..85afd6f6f9 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -580,6 +580,7 @@ public: void f318_dropAllObjects(uint16 champIndex); // @ F0318_CHAMPION_DropAllObjects void f323_unpoison(int16 champIndex); // @ F0323_CHAMPION_Unpoison void f331_applyTimeEffects(); // @ F0331_CHAMPION_ApplyTimeEffects_CPSF + void save2_PartyPart(Common::OutSaveFile *file); }; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 526b60e5f1..d401c7bbe6 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -140,7 +140,6 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _eventMan = nullptr; _menuMan = nullptr; _championMan = nullptr; - _loadsaveMan = nullptr; _objectMan = nullptr; _inventoryMan = nullptr; _textMan = nullptr; @@ -149,6 +148,10 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _timeline = nullptr; _projexpl = nullptr; + _g528_saveFormat = 0; + _g527_platform = 0; + _g526_dungeonId = 0; + _g298_newGame = false; _g523_restartGameRequest = false; _g321_stopWaitingForPlayerInput = true; @@ -187,7 +190,6 @@ DMEngine::~DMEngine() { delete _eventMan; delete _menuMan; delete _championMan; - delete _loadsaveMan; delete _objectMan; delete _inventoryMan; delete _textMan; @@ -220,7 +222,7 @@ void DMEngine::f463_initializeGame() { _objectMan->loadObjectNames(); _eventMan->initMouse(); //F0441_STARTEND_ProcessEntrance(); - while (_loadsaveMan->f435_loadgame() != k1_LoadgameSuccess) { + while (f435_loadgame() != k1_LoadgameSuccess) { warning(false, "TODO: F0441_STARTEND_ProcessEntrance"); } //F0396_MENUS_LoadSpellAreaLinesBitmap() is not needed, every bitmap has been loaded @@ -301,7 +303,6 @@ Common::Error DMEngine::run() { _eventMan = new EventManager(this); _menuMan = new MenuMan(this); _championMan = new ChampionMan(this); - _loadsaveMan = new LoadsaveMan(this); _objectMan = new ObjectMan(this); _inventoryMan = new InventoryMan(this); _textMan = new TextMan(this); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index dce88f17f8..dfc7b4c01c 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -31,6 +31,8 @@ #include "common/random.h" #include "engines/engine.h" #include "gui/debugger.h" +#include "common/savefile.h" +#include "common/str.h" namespace DM { @@ -41,7 +43,6 @@ class DungeonMan; class EventManager; class MenuMan; class ChampionMan; -class LoadsaveMan; class ObjectMan; class InventoryMan; class TextMan; @@ -50,6 +51,7 @@ class GroupMan; class Timeline; class ProjExpl; + void warning(bool repeat, const char *s, ...); enum direction { @@ -177,6 +179,11 @@ inline T f26_getBoundedValue(T min, T val, T max) { #define k99_modeWaitingOnEntrance 99 // @ C099_MODE_WAITING_ON_ENTRANCE #define k202_modeEntranceDrawCredits 202 // @ C202_MODE_ENTRANCE_DRAW_CREDITS +enum LoadgameResponse { + kM1_LoadgameFailure = -1, // @ CM1_LOAD_GAME_FAILURE + k1_LoadgameSuccess = 1// @ C01_LOAD_GAME_SUCCESS +}; + class DMEngine : public Engine { void f462_startGame(); // @ F0462_START_StartGame_CPSF void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE @@ -184,6 +191,8 @@ class DMEngine : public Engine { void f448_initMemoryManager(); // @ F0448_STARTUP1_InitializeMemoryManager_CPSADEF void f2_gameloop(); // @ F0002_MAIN_GameLoop_CPSDF void initArrays(); + Common::String getSavefileName(uint16 slot); + void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName); public: explicit DMEngine(OSystem *syst); ~DMEngine(); @@ -195,8 +204,13 @@ public: int16 M0_indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL void f19_displayErrorAndStop(int16 errorIndex); // @ F0019_MAIN_DisplayErrorAndStop virtual Common::Error run(); // @ main + void f433_processCommand140_saveGame(uint16 slot, const Common::String desc); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF + LoadgameResponse f435_loadgame(); // @ F0435_STARTEND_LoadGame_CPSF private: + int16 _g528_saveFormat; // @ G0528_i_Format + int16 _g527_platform; // @ G0527_i_Platform + uint16 _g526_dungeonId; // @ G0526_ui_DungeonID Console *_console; public: Common::RandomSource *_rnd; @@ -205,7 +219,6 @@ public: EventManager *_eventMan; MenuMan *_menuMan; ChampionMan *_championMan; - LoadsaveMan *_loadsaveMan; ObjectMan *_objectMan; InventoryMan *_inventoryMan; TextMan *_textMan; diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 1a91d5d61e..b3e4194249 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -604,7 +604,7 @@ public: }; // wrapper for bytes which are used as squares struct DungeonFileHeader { - uint16 _dungeonId; // @ G0526_ui_DungeonID + uint16 _dungeonId; // equal to dungeonId uint16 _ornamentRandomSeed; uint32 _rawMapDataSize; diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index edb6056aff..5961f7cb92 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -1691,7 +1691,7 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) { L0344_i_ActiveGroupIndex = 0; while (L0341_ps_ActiveGroup->_groupThingIndex >= 0) { if (++L0344_i_ActiveGroupIndex >= _vm->_groupMan->_g376_maxActiveGroupCount) { - return; + return; } L0341_ps_ActiveGroup++; } @@ -2056,4 +2056,24 @@ void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) { warning(false, "F0446_STARTEND_FuseSequence()"); } } + +void GroupMan::save1_ActiveGroupPart(Common::OutSaveFile* file) { + for (uint16 i = 0; i < _g376_maxActiveGroupCount; ++i) { + ActiveGroup *group = &_g375_activeGroups[i]; + file->writeUint16BE(group->_groupThingIndex); + file->writeUint16BE(group->_directions); + file->writeByte(group->_cells); + file->writeByte(group->_lastMoveTime); + file->writeByte(group->_delayFleeingFromTarget); + file->writeByte(group->_targetMapX); + file->writeByte(group->_targetMapY); + file->writeByte(group->_priorMapX); + file->writeByte(group->_priorMapY); + file->writeByte(group->_homeMapX); + file->writeByte(group->_homeMapY); + for (uint16 j = 0; j < 4; ++j) + file->writeByte(group->_aspect[j]); + } +} + } diff --git a/engines/dm/group.h b/engines/dm/group.h index 6578a20851..2ad2d8dd1d 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -92,7 +92,7 @@ enum CreatureType { class ActiveGroup { public: - int _groupThingIndex; + int16 _groupThingIndex; direction _directions; byte _cells; byte _lastMoveTime; @@ -244,6 +244,7 @@ public: uint16 f222_isLordChaosOnSquare(int16 mapX, int16 mapY); // @ F0222_GROUP_IsLordChaosOnSquare bool f221_isFluxcageOnSquare(int16 mapX, int16 mapY); // @ F0221_GROUP_IsFluxcageOnSquare void f225_fuseAction(uint16 mapX, uint16 mapY); // @ F0225_GROUP_FuseAction + void save1_ActiveGroupPart(Common::OutSaveFile *file); }; diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 81a914c040..9d705ef8e5 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -24,39 +24,45 @@ * Based on the Reverse Engineering work of Christophe Fontanel, * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) */ +#include "common/system.h" +#include "common/savefile.h" +#include "graphics/thumbnail.h" -#include "loadsave.h" +#include "dm.h" #include "dungeonman.h" -#include "champion.h" -#include "group.h" #include "timeline.h" - +#include "group.h" +#include "champion.h" +#include "menus.h" +#include "eventman.h" +#include "projexpl.h" namespace DM { - -LoadsaveMan::LoadsaveMan(DMEngine *vm) : _vm(vm) {} - - -LoadgameResponse LoadsaveMan::f435_loadgame() { - bool newGame = _vm->_g298_newGame; - ChampionMan &cm = *_vm->_championMan; - +#define C2_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST 2 +#define C3_PLATFORM_AMIGA 3 +#define C10_DUNGEON_DM 10 +LoadgameResponse DMEngine::f435_loadgame() { + bool newGame = _g298_newGame; + ChampionMan &cm = *_championMan; + _g528_saveFormat = C2_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST; + _g527_platform = C3_PLATFORM_AMIGA; + _g526_dungeonId = C10_DUNGEON_DM; if (newGame) { - _vm->_g524_restartGameAllowed = false; + _g524_restartGameAllowed = false; cm._g305_partyChampionCount = 0; cm._g414_leaderHandObject = Thing::_none; - _vm->_g525_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536); + _g525_gameId = _rnd->getRandomNumber(65536) * _rnd->getRandomNumber(65536); } else { assert(false); // MISSING CODE: load game } - _vm->_dungeonMan->f434_loadDungeonFile(); + _dungeonMan->f434_loadDungeonFile(); if (newGame) { - _vm->_timeline->f233_initTimeline(); - _vm->_groupMan->f196_initActiveGroups(); + _timeline->f233_initTimeline(); + _groupMan->f196_initActiveGroups(); } else { assert(false); // MISSING CODE: load game @@ -65,4 +71,110 @@ LoadgameResponse LoadsaveMan::f435_loadgame() { return k1_LoadgameSuccess; } -} \ No newline at end of file + +void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String desc) { + char *message = nullptr; + + _menuMan->f456_drawDisabledMenu(); + _eventMan->f78_showMouse(); + + // do { + // ask the play what he wants + // while + + // F0427_DIALOG_Draw(0, G0551_pc_SAVINGGAME, 0, 0, 0, 0, false, false, false); + + uint16 champHandObjWeight; + if (!_championMan->_g415_leaderEmptyHanded) { + champHandObjWeight = _dungeonMan->f140_getObjectWeight(_championMan->_g414_leaderHandObject); + _championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load -= champHandObjWeight; + } + + + Common::String savefileName = getSavefileName(slot); + Common::SaveFileManager *saveFileManager = _system->getSavefileManager(); + Common::OutSaveFile *file = saveFileManager->openForSaving(savefileName); + + if (!file) + return; // TODO: silent fail + + writeSaveGameHeader(file, desc); + + // write C0_SAVE_PART_GLOBAL_DATA part + file->writeUint32BE(_g313_gameTime); + //L1348_s_GlobalData.LastRandomNumber = G0349_ul_LastRandomNumber; + file->writeUint16BE(_championMan->_g305_partyChampionCount); + file->writeSint16BE(_dungeonMan->_g306_partyMapX); + file->writeSint16BE(_dungeonMan->_g307_partyMapY); + file->writeUint16BE(_dungeonMan->_g308_partyDir); + file->writeByte(_dungeonMan->_g309_partyMapIndex); + file->writeSint16BE(_championMan->_g411_leaderIndex); + file->writeSint16BE(_championMan->_g514_magicCasterChampionIndex); + file->writeUint16BE(_timeline->_g372_eventCount); + file->writeUint16BE(_timeline->_g373_firstUnusedEventIndex); + file->writeUint16BE(_timeline->_g369_eventMaxCount); + file->writeUint16BE(_groupMan->_g377_currActiveGroupCount); + file->writeSint32BE(_projexpl->_g361_lastCreatureAttackTime); + file->writeSint32BE(_projexpl->_g362_lastPartyMovementTime); + file->writeSint16BE(_g310_disabledMovementTicks); + file->writeSint16BE(_g311_projectileDisableMovementTicks); + file->writeSint16BE(_g312_lastProjectileDisabledMovementDirection); + file->writeUint16BE(_championMan->_g414_leaderHandObject.toUint16()); + file->writeUint16BE(_groupMan->_g376_maxActiveGroupCount); + + // write C1_SAVE_PART_ACTIVE_GROUP part + _groupMan->save1_ActiveGroupPart(file); + // write C2_SAVE_PART_PARTY part + _championMan->save2_PartyPart(file); + // write C3_SAVE_PART_EVENTS part + _timeline->save3_eventsPart(file); + // write C4_SAVE_PART_TIMELINE part + _timeline->save4_timelinePart(file); + + file->writeSint32BE(_g525_gameId); + file->writeSint16BE(_g528_saveFormat); + file->writeSint16BE(_g527_platform); + file->writeUint16BE(_g526_dungeonId); + + warning(false, "MISSING CODE in save game"); + + file->flush(); + file->finalize(); + delete file; +} + +Common::String DMEngine::getSavefileName(uint16 slot) { + return Common::String::format("%s.%03u", _targetName.c_str(), slot); +} + +#define SAVEGAME_ID MKTAG('D', 'M', 'D', 'M') +#define SAVEGAME_VERSION 1 + +void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::String& saveName) { + out->writeUint32BE(SAVEGAME_ID); + + // Write version + out->writeByte(SAVEGAME_VERSION); + + // Write savegame name + out->writeString(saveName); + out->writeByte(0); + + // Save the game thumbnail + Graphics::saveThumbnail(*out); + + // Creation date/time + TimeDate curTime; + _system->getTimeAndDate(curTime); + + uint32 saveDate = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF); + uint16 saveTime = ((curTime.tm_hour & 0xFF) << 8) | ((curTime.tm_min) & 0xFF); + uint32 playTime = getTotalPlayTime() / 1000; + + out->writeUint32BE(saveDate); + out->writeUint16BE(saveTime); + out->writeUint32BE(playTime); +} + + +} diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h index c45b111ac9..85ed8a01da 100644 --- a/engines/dm/loadsave.h +++ b/engines/dm/loadsave.h @@ -32,17 +32,13 @@ namespace DM { -enum LoadgameResponse { - kM1_LoadgameFailure = -1, // @ CM1_LOAD_GAME_FAILURE - k1_LoadgameSuccess = 1// @ C01_LOAD_GAME_SUCCESS -}; +; class LoadsaveMan { DMEngine *_vm; public: explicit LoadsaveMan(DMEngine *vm); - LoadgameResponse f435_loadgame(); // @ F0435_STARTEND_LoadGame_CPSF }; } diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 3858ad512e..afeb577eeb 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -1087,4 +1087,23 @@ T0255002: _vm->_championMan->f283_viAltarRebirth(event->_priority); } } + +void Timeline::save3_eventsPart(Common::OutSaveFile* file) { + for (uint16 i = 0; i < _g369_eventMaxCount; ++i) { + TimelineEvent *event = &_g370_events[i]; + file->writeSint32BE(event->_mapTime); + file->writeByte(event->_type); + file->writeByte(event->_priority); + file->writeByte(event->_B._location._mapX); // writing bytes of the union I think should preserve the union's identity + file->writeByte(event->_B._location._mapY); + file->writeUint16BE(event->_C.A._cell); // writing bytes of the union I think should preserve the union's identity + file->writeUint16BE(event->_C.A._effect); + } +} + +void Timeline::save4_timelinePart(Common::OutSaveFile* file) { + for (uint16 i = 0; i < _g369_eventMaxCount; ++i) + file->writeUint16BE(_g371_timeline[i]); +} + } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index 08c6ce1c5f..8f68c35fe2 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -187,6 +187,8 @@ public: void f257_timelineProcessEvent70_light(TimelineEvent *event); // @ F0257_TIMELINE_ProcessEvent70_Light void f260_timelineRefreshAllChampionStatusBoxes(); // @ F0260_TIMELINE_RefreshAllChampionStatusBoxes void f255_timelineProcessEvent13_ViAltarRebirth(TimelineEvent *event); // @ F0255_TIMELINE_ProcessEvent13_ViAltarRebirth + void save3_eventsPart(Common::OutSaveFile *file); + void save4_timelinePart(Common::OutSaveFile *file); }; -- cgit v1.2.3 From aacecd6c06b08c719077130cfd113f302b51923b Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 20 Jul 2016 16:42:37 +0200 Subject: DM: Add entrance processing --- engines/dm/TODOs/todo.txt | 1 + engines/dm/detection.cpp | 2 +- engines/dm/dm.cpp | 112 +++++++++++++++++++++++++++++++++++++++++++++- engines/dm/dm.h | 9 +++- engines/dm/eventman.cpp | 1 + engines/dm/gfx.cpp | 15 ++++--- engines/dm/gfx.h | 4 ++ engines/dm/loadsave.cpp | 1 - 8 files changed, 133 insertions(+), 12 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 4aa4d36360..d4162722e9 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -31,4 +31,5 @@ Todo: Finish stuff: f380_processCommandQueue Missing main loop methods + Save file f433_processCommand140_saveGame fails silently diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp index 1d31a7459d..7d1c463045 100644 --- a/engines/dm/detection.cpp +++ b/engines/dm/detection.cpp @@ -83,7 +83,7 @@ public: } virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { return gameDescriptions; } - virtual bool hasFeature(MetaEngineFeature f) const { return false; } + virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { if(desc) *engine = new DM::DMEngine(syst); diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index d401c7bbe6..2861cf1243 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -172,6 +172,9 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _g313_gameTime = 0; _g353_stringBuildBuffer[0] = '\0'; _g318_waitForInputMaxVerticalBlankCount = 0; + for (uint16 i = 0; i < 10; ++i) + _g562_entranceDoorAnimSteps[i] = nullptr; + _g564_interfaceCredits = nullptr; debug("DMEngine::DMEngine"); @@ -202,6 +205,12 @@ DMEngine::~DMEngine() { DebugMan.clearAllDebugChannels(); } +bool DMEngine::hasFeature(EngineFeature f) const { + return + (f == kSupportsSavingDuringRuntime) || + (f == kSupportsLoadingDuringRuntime); +} + void DMEngine::f22_delay(uint16 verticalBlank) { _system->delayMillis(verticalBlank * 20); // Google says most Amiga games had a refreshrate of 50 hz } @@ -221,9 +230,9 @@ void DMEngine::f463_initializeGame() { _textMan->f54_textInitialize(); _objectMan->loadObjectNames(); _eventMan->initMouse(); - //F0441_STARTEND_ProcessEntrance(); + f441_processEntrance(); while (f435_loadgame() != k1_LoadgameSuccess) { - warning(false, "TODO: F0441_STARTEND_ProcessEntrance"); + f441_processEntrance(); } //F0396_MENUS_LoadSpellAreaLinesBitmap() is not needed, every bitmap has been loaded @@ -423,4 +432,103 @@ int16 DMEngine::M0_indexToOrdinal(int16 val) { return val + 1; } + +void DMEngine::f441_processEntrance() { + uint16 L1402_ui_AnimationStep; + Box L1405_s_Box; + + _eventMan->_g441_primaryMouseInput = g445_PrimaryMouseInput_Entrance; + _eventMan->_g442_secondaryMouseInput = nullptr; + _eventMan->_g443_primaryKeyboardInput = nullptr; + _eventMan->_g444_secondaryKeyboardInput = nullptr; + _g562_entranceDoorAnimSteps[0] = new byte[128 * 161 * 12]; + for (L1402_ui_AnimationStep = 1; L1402_ui_AnimationStep < 8; L1402_ui_AnimationStep++) { + _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep] = _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep - 1] + 128 * 161; + } + _g562_entranceDoorAnimSteps[8] = _g562_entranceDoorAnimSteps[7] + 128 * 161; + _g562_entranceDoorAnimSteps[9] = _g562_entranceDoorAnimSteps[8] + 128 * 161 * 2; + + _displayMan->f466_loadIntoBitmap(k3_entranceRightDoorGraphicIndice, _g562_entranceDoorAnimSteps[4]); + _displayMan->f466_loadIntoBitmap(k2_entranceLeftDoorGraphicIndice, _g562_entranceDoorAnimSteps[0]); + _g564_interfaceCredits = _displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice); + _displayMan->_g578_useByteBoxCoordinates = false; + L1405_s_Box._x1 = 0; + L1405_s_Box._x2 = 100; + L1405_s_Box._y1 = 0; + L1405_s_Box._y2 = 160; + for (L1402_ui_AnimationStep = 1; L1402_ui_AnimationStep < 4; L1402_ui_AnimationStep++) { + _displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[0], _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep], L1405_s_Box, L1402_ui_AnimationStep << 2, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161); + L1405_s_Box._x2 -= 4; + } + L1405_s_Box._x2 = 127; + for (L1402_ui_AnimationStep = 5; L1402_ui_AnimationStep < 8; L1402_ui_AnimationStep++) { + L1405_s_Box._x1 += 4; + _displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[4], _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep], L1405_s_Box, 0, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161); + } + do { + f439_drawEntrance(); + //_eventMan->f77_hideMouse(); + //_eventMan->f77_hideMouse(); + _eventMan->f78_showMouse(); + _eventMan->f357_discardAllInput(); + _g298_newGame = k99_modeWaitingOnEntrance; + do { + _eventMan->processInput(); + _eventMan->f380_processCommandQueue(); + _displayMan->updateScreen(); + } while (_g298_newGame == k99_modeWaitingOnEntrance); + } while (_g298_newGame == k202_CommandEntranceDrawCredits); + //Strangerke: CHECKME: Earlier versions were using G0566_puc_Graphic534_Sound01Switch + warning(false, "MISSING CODE: F0060_SOUND_Play"); + f22_delay(20); + _eventMan->f78_showMouse(); + if (_g298_newGame) { + warning(false, "MISSING CODE: F0438_STARTEND_OpenEntranceDoors();"); + } + delete[] _g562_entranceDoorAnimSteps[0]; + for (uint16 i = 0; i < 10; ++i) + _g562_entranceDoorAnimSteps[i] = nullptr; +} + + +void DMEngine::f439_drawEntrance() { + static Box K0079_s_Box_Entrance_DoorsUpperHalf = {0, 231, 0, 80}; + static Box K0152_s_Box_Entrance_DoorsLowerHalf = {0, 231, 81, 160}; + static Box G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft = {0, 104, 30, 190}; + static Box G0011_s_Graphic562_Box_Entrance_ClosedDoorRight = {105, 231, 30, 190}; + + uint16 L1397_ui_ColumnIndex; + byte* L1398_apuc_MicroDungeonCurrentMapData[32]; + Square L1399_auc_MicroDungeonSquares[25]; + + _dungeonMan->_g309_partyMapIndex = k255_mapIndexEntrance; + _displayMan->_g297_drawFloorAndCeilingRequested = true; + _dungeonMan->_g273_currMapWidth = 5; + _dungeonMan->_g274_currMapHeight = 5; + _dungeonMan->_g271_currMapData = L1398_apuc_MicroDungeonCurrentMapData; + + Map map; // uninitialized, won't be used + _dungeonMan->_g269_currMap = ↦ + for (uint16 i = 0; i < 25; ++i) + L1399_auc_MicroDungeonSquares[i] = Square(k0_ElementTypeWall, 0); + for (L1397_ui_ColumnIndex = 0; L1397_ui_ColumnIndex < 5; L1397_ui_ColumnIndex++) { + L1398_apuc_MicroDungeonCurrentMapData[L1397_ui_ColumnIndex] = (byte*)&L1399_auc_MicroDungeonSquares[L1397_ui_ColumnIndex * 5]; + L1399_auc_MicroDungeonSquares[L1397_ui_ColumnIndex + 10] = Square(k1_CorridorElemType, 0); + } + L1399_auc_MicroDungeonSquares[7] = Square(k1_CorridorElemType, 0); + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(G0345_aui_BlankBuffer);"); + + // note, a global variable is used here in the original + _displayMan->f466_loadIntoBitmap(k4_entranceGraphicIndice, _displayMan->_g348_bitmapScreen); + _displayMan->f128_drawDungeon(kDirSouth, 2, 0); + warning(false, "IGNORED CODE: G0324_B_DrawViewportRequested = false;"); + + _displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], K0079_s_Box_Entrance_DoorsUpperHalf, 0, 30, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161); + _displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], K0152_s_Box_Entrance_DoorsLowerHalf, 0, 111, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161); + + _displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[0], &G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft, k64_byteWidth, kM1_ColorNoTransparency, 161); + _displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[4], &G0011_s_Graphic562_Box_Entrance_ClosedDoorRight, k64_byteWidth, kM1_ColorNoTransparency, 161); + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(g20_PalEntrance);"); +} + } // End of namespace DM diff --git a/engines/dm/dm.h b/engines/dm/dm.h index dfc7b4c01c..cbc0bd35e0 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -193,11 +193,13 @@ class DMEngine : public Engine { void initArrays(); Common::String getSavefileName(uint16 slot); void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName); + void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance public: explicit DMEngine(OSystem *syst); ~DMEngine(); + virtual bool hasFeature(EngineFeature f) const; - void f22_delay(uint16 ms); // @ F0022_MAIN_Delay + void f22_delay(uint16 verticalBlank); // @ F0022_MAIN_Delay uint16 f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2); // @ F0030_MAIN_GetScaledProduct uint16 getRandomNumber(uint32 max) { return _rnd->getRandomNumber(max - 1); } int16 M1_ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX @@ -206,12 +208,15 @@ public: virtual Common::Error run(); // @ main void f433_processCommand140_saveGame(uint16 slot, const Common::String desc); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF LoadgameResponse f435_loadgame(); // @ F0435_STARTEND_LoadGame_CPSF + void f441_processEntrance(); // @ F0441_STARTEND_ProcessEntrance private: int16 _g528_saveFormat; // @ G0528_i_Format int16 _g527_platform; // @ G0527_i_Platform uint16 _g526_dungeonId; // @ G0526_ui_DungeonID Console *_console; + byte *_g562_entranceDoorAnimSteps[10]; // @ G0562_apuc_Bitmap_EntranceDoorAnimationSteps + byte *_g564_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits public: Common::RandomSource *_rnd; DisplayMan *_displayMan; @@ -228,7 +233,7 @@ public: ProjExpl *_projexpl; - bool _g298_newGame; // @ G0298_B_NewGame + int16 _g298_newGame; // @ G0298_B_NewGame bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested bool _g321_stopWaitingForPlayerInput; // @ G0321_B_StopWaitingForPlayerInput diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 5fe80e2eda..6e868f73de 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -740,6 +740,7 @@ void EventManager::f380_processCommandQueue() { if (cmdType == k140_CommandSaveGame) { if ((_vm->_championMan->_g305_partyChampionCount > 0) && !_vm->_championMan->_g299_candidateChampionOrdinal) { warning(false, "MISSING CODE: F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF();"); + _vm->f433_processCommand140_saveGame(1, "Nice save:)"); } return; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 5efb3f05ac..dae340085f 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -772,6 +772,8 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) { delete[] _g348_bitmapScreen; _g348_bitmapScreen = new byte[_screenWidth * _screenHeight]; fillScreen(k0_ColorBlack); + + _g74_tmpBitmap = new byte[_screenWidth * _screenHeight]; } void DisplayMan::f479_loadGraphics() { @@ -2248,11 +2250,13 @@ void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) { f126_drawSquareD0R(dir, tmpPosX, tmpPosY); f127_drawSquareD0C(dir, posX, posY); - _g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native; - _g699_bitmapWallSet_Wall_D2LCR = _g96_bitmapWall_D2LCR_Native; - _g700_bitmapWallSet_Wall_D1LCR = _g97_bitmapWall_D1LCR_Native; - _g701_bitmapWallSet_Wall_D0L = _g98_bitmapWall_D0L_Native; - _g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native; + if (_g76_useFlippedWallAndFootprintsBitmap) { + _g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native; + _g699_bitmapWallSet_Wall_D2LCR = _g96_bitmapWall_D2LCR_Native; + _g700_bitmapWallSet_Wall_D1LCR = _g97_bitmapWall_D1LCR_Native; + _g701_bitmapWallSet_Wall_D0L = _g98_bitmapWall_D0L_Native; + _g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native; + } f97_drawViewport((_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0); if (_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) @@ -2320,7 +2324,6 @@ void DisplayMan::f96_loadCurrentMapGraphics() { f95_loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet); { - _g74_tmpBitmap = new byte[_screenWidth * _screenHeight]; _g578_useByteBoxCoordinates = true; f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap, diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index d1cc5b77cd..2a18b39b39 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -202,6 +202,10 @@ enum ViewCell { }; enum GraphicIndice { + k2_entranceLeftDoorGraphicIndice = 2, // @ C002_GRAPHIC_ENTRANCE_LEFT_DOOR + k3_entranceRightDoorGraphicIndice = 3, // @ C003_GRAPHIC_ENTRANCE_RIGHT_DOOR + k4_entranceGraphicIndice = 4, // @ C004_GRAPHIC_ENTRANCE + k5_creditsGraphicIndice = 5, // @ C005_GRAPHIC_CREDITS k8_StatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION k9_MenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 9d705ef8e5..28b57f2651 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -176,5 +176,4 @@ void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::Strin out->writeUint32BE(playTime); } - } -- cgit v1.2.3 From e8249722455321a67ee5edf831be1c6bb76a8b65 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 20 Jul 2016 16:54:09 +0200 Subject: DM: Fix activeGroup removal --- engines/dm/group.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 5961f7cb92..e59a6e7846 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -1699,6 +1699,7 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) { warning(false, "Code differs from the original in GroupMan::f183_addActiveGroup"); //L0340_ps_Group = ((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType]) + (L0341_ps_ActiveGroup->_groupThingIndex = (thing).getType()); + L0341_ps_ActiveGroup->_groupThingIndex = thing.getType(); L0340_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(f175_groupGetThing(mapX, mapY)); L0341_ps_ActiveGroup->_cells = L0340_ps_Group->_cells; -- cgit v1.2.3 From aa92c3ba2067a011743ddfbb4db8d2376e92aceb Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 21 Jul 2016 18:04:09 +0200 Subject: DM: Fix footprints everywhere --- engines/dm/champion.h | 7 ++++++- engines/dm/eventman.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 85afd6f6f9..15a07bebe7 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -55,6 +55,7 @@ public: void setMapX(uint16 val) { _scent = (_scent & ~0x1F) & (val & 0x1F); } void setMapY(uint16 val) { _scent = (_scent & ~(0x1F << 5)) & (val & 0x1F); } void setMapIndex(uint16 val) { _scent = (_scent & ~(0x1F << 10)) & (val & 0x3F); } + void setVal(uint16 val) { _scent = val; } uint16 toUint16() { return _scent; } }; // @ SCENT @@ -90,8 +91,12 @@ public: _scentCount = 0; _freezeLifeTicks = 0; _firstScentIndex = 0; - for (int16 i = 0; i < 24; ++i) + + _lastScentIndex = 0; + for (int16 i = 0; i < 24; ++i) { + _scents[i].setVal(0); _scentStrengths[i] = 0; + } _event71Count_Invisibility = 0; } }; // @ PARTY diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 6e868f73de..d6790b4fcf 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -747,7 +747,7 @@ void EventManager::f380_processCommandQueue() { if (cmdType == k147_CommandFreezeGame) { _vm->_g301_gameTimeTicking = false; _vm->_menuMan->f456_drawDisabledMenu(); - _vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 224, 136); + _vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 112, 136); // TODO: localization _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 81, 69, k4_ColorCyan, k0_ColorBlack, "GAME FROZEN", k136_heightViewport); -- cgit v1.2.3 From ee3973aa153f5fba6485515cf1f51c1659fd31c4 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 22 Jul 2016 21:33:45 +0200 Subject: DM: Add code for loading the save files --- engines/dm/champion.cpp | 66 ++++++++++++++++++++++- engines/dm/champion.h | 1 + engines/dm/dm.cpp | 13 ++--- engines/dm/dm.h | 12 ++++- engines/dm/group.cpp | 18 +++++++ engines/dm/group.h | 1 + engines/dm/loadsave.cpp | 140 ++++++++++++++++++++++++++++++++++++++++++------ engines/dm/timeline.cpp | 18 +++++++ engines/dm/timeline.h | 2 + 9 files changed, 244 insertions(+), 27 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index f22d4dd605..aac5584777 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1724,7 +1724,7 @@ void ChampionMan::save2_PartyPart(Common::OutSaveFile* file) { file->writeUint16BE(champ->_cell); file->writeUint16BE(champ->_actionIndex); file->writeUint16BE(champ->_symbolStep); - for(uint16 j = 0; j < 5; ++j) + for (uint16 j = 0; j < 5; ++j) file->writeByte(champ->_symbols[j]); file->writeUint16BE(champ->_directionMaximumDamageReceived); file->writeUint16BE(champ->_maximumDamageReceived); @@ -1757,13 +1757,75 @@ void ChampionMan::save2_PartyPart(Common::OutSaveFile* file) { file->writeByte(party._freezeLifeTicks); file->writeByte(party._firstScentIndex); file->writeByte(party._lastScentIndex); - for(uint16 i = 0; i < 24; ++i) + for (uint16 i = 0; i < 24; ++i) file->writeUint16BE(party._scents[i].toUint16()); for (uint16 i = 0; i < 24; ++i) file->writeByte(party._scentStrengths[i]); file->writeByte(party._event71Count_Invisibility); } +void ChampionMan::load2_PartyPart(Common::InSaveFile* file) { + for (uint16 i = 0; i < 4; ++i) { + Champion *champ = &_gK71_champions[i]; + champ->_attributes = file->readUint16BE(); + champ->_wounds = file->readUint16BE(); + for (uint16 y = 0; y < 7; ++y) + for (uint16 x = 0; x < 3; ++x) + champ->_statistics[y][x] = file->readByte(); + for (uint16 j = 0; j < 30; ++j) + champ->_slots[j] = Thing(file->readUint16BE()); + for (uint16 j = 0; j < 20; ++j) { + champ->_skills[j]._temporaryExperience = file->readSint16BE(); + champ->_skills[j]._experience = file->readSint32BE(); + } + for (uint16 j = 0; j < 8; ++j) + champ->_name[j] = file->readByte(); + for (uint16 j = 0; j < 20; ++j) + champ->_title[j] = file->readByte(); + champ->_dir = (direction)file->readUint16BE(); + champ->_cell = (ViewCell)file->readUint16BE(); + champ->_actionIndex = (ChampionAction)file->readUint16BE(); + champ->_symbolStep = file->readUint16BE(); + for (uint16 j = 0; j < 5; ++j) + champ->_symbols[j] = file->readByte(); + champ->_directionMaximumDamageReceived = file->readUint16BE(); + champ->_maximumDamageReceived = file->readUint16BE(); + champ->_poisonEventCount = file->readUint16BE(); + champ->_enableActionEventIndex = file->readSint16BE(); + champ->_hideDamageReceivedIndex = file->readSint16BE(); + champ->_currHealth = file->readSint16BE(); + champ->_maxHealth = file->readSint16BE(); + champ->_currStamina = file->readSint16BE(); + champ->_maxStamina = file->readSint16BE(); + champ->_currMana = file->readSint16BE(); + champ->_maxMana = file->readSint16BE(); + champ->_actionDefense = file->readSint16BE(); + champ->_food = file->readSint16BE(); + champ->_water = file->readSint16BE(); + champ->_load = file->readUint16BE(); + champ->_shieldDefense = file->readSint16BE(); + for (uint16 j = 0; j < 928; ++j) + champ->_portrait[j] = file->readByte(); + } + + Party &party = _g407_party; + party._magicalLightAmount = file->readSint16BE(); + party._event73Count_ThievesEye = file->readByte(); + party._event79Count_Footprints = file->readByte(); + party._shieldDefense = file->readSint16BE(); + party._fireShieldDefense = file->readSint16BE(); + party._spellShieldDefense = file->readSint16BE(); + party._scentCount = file->readByte(); + party._freezeLifeTicks = file->readByte(); + party._firstScentIndex = file->readByte(); + party._lastScentIndex = file->readByte(); + for (uint16 i = 0; i < 24; ++i) + party._scents[i] = Scent(file->readUint16BE()); + for (uint16 i = 0; i < 24; ++i) + party._scentStrengths[i] = file->readByte(); + party._event71Count_Invisibility = file->readByte(); +} + ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) { for (uint16 i = 0; i < _g305_partyChampionCount; ++i) { if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth) diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 15a07bebe7..17d8831179 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -586,6 +586,7 @@ public: void f323_unpoison(int16 champIndex); // @ F0323_CHAMPION_Unpoison void f331_applyTimeEffects(); // @ F0331_CHAMPION_ApplyTimeEffects_CPSF void save2_PartyPart(Common::OutSaveFile *file); + void load2_PartyPart(Common::InSaveFile* file); }; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 2861cf1243..0aade77684 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -177,9 +177,6 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _g564_interfaceCredits = nullptr; debug("DMEngine::DMEngine"); - - warning(false, "DUMMY CODE: setting _g298_newGame to true, should be in processEntrance"); - _g298_newGame = true; } DMEngine::~DMEngine() { @@ -222,7 +219,7 @@ uint16 DMEngine::f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2) { void DMEngine::f463_initializeGame() { _displayMan->f479_loadGraphics(); _displayMan->f460_initializeGraphicData(); - // DUMMY CODE: next line + warning(false, "Dummy code in f463_initializeGame, setting palette"); _displayMan->loadPalette(g21_PalDungeonView[0]); _displayMan->f94_loadFloorSet(k0_FloorSetStone); _displayMan->f95_loadWallSet(k0_WallSetStone); @@ -231,12 +228,11 @@ void DMEngine::f463_initializeGame() { _objectMan->loadObjectNames(); _eventMan->initMouse(); f441_processEntrance(); - while (f435_loadgame() != k1_LoadgameSuccess) { + while (f435_loadgame(1) != k1_LoadgameSuccess) { f441_processEntrance(); } //F0396_MENUS_LoadSpellAreaLinesBitmap() is not needed, every bitmap has been loaded - // There was some memory wizardy for the Amiga platform, I skipped that part _displayMan->f461_allocateFlippedWallBitmaps(); @@ -321,7 +317,7 @@ Common::Error DMEngine::run() { _projexpl = new ProjExpl(this); _displayMan->setUpScreens(320, 200); - f463_initializeGame(); // @ F0463_START_InitializeGame_CPSADEF + f463_initializeGame(); while (true) { f2_gameloop(); warning(false, "TODO: F0444_STARTEND_Endgame(G0303_B_PartyDead);"); @@ -490,7 +486,6 @@ void DMEngine::f441_processEntrance() { _g562_entranceDoorAnimSteps[i] = nullptr; } - void DMEngine::f439_drawEntrance() { static Box K0079_s_Box_Entrance_DoorsUpperHalf = {0, 231, 0, 80}; static Box K0152_s_Box_Entrance_DoorsLowerHalf = {0, 231, 81, 160}; @@ -508,7 +503,7 @@ void DMEngine::f439_drawEntrance() { _dungeonMan->_g271_currMapData = L1398_apuc_MicroDungeonCurrentMapData; Map map; // uninitialized, won't be used - _dungeonMan->_g269_currMap = ↦ + _dungeonMan->_g269_currMap = ↦ for (uint16 i = 0; i < 25; ++i) L1399_auc_MicroDungeonSquares[i] = Square(k0_ElementTypeWall, 0); for (L1397_ui_ColumnIndex = 0; L1397_ui_ColumnIndex < 5; L1397_ui_ColumnIndex++) { diff --git a/engines/dm/dm.h b/engines/dm/dm.h index cbc0bd35e0..279144bc4d 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -33,6 +33,8 @@ #include "gui/debugger.h" #include "common/savefile.h" #include "common/str.h" +#include "engines/savestate.h" + namespace DM { @@ -184,6 +186,13 @@ enum LoadgameResponse { k1_LoadgameSuccess = 1// @ C01_LOAD_GAME_SUCCESS }; + +struct SaveGameHeader { + byte _version; + SaveStateDescriptor _descr; +}; + + class DMEngine : public Engine { void f462_startGame(); // @ F0462_START_StartGame_CPSF void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE @@ -193,6 +202,7 @@ class DMEngine : public Engine { void initArrays(); Common::String getSavefileName(uint16 slot); void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName); + bool readSaveGameHeader(Common::InSaveFile *file, SaveGameHeader *header); void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance public: explicit DMEngine(OSystem *syst); @@ -207,7 +217,7 @@ public: void f19_displayErrorAndStop(int16 errorIndex); // @ F0019_MAIN_DisplayErrorAndStop virtual Common::Error run(); // @ main void f433_processCommand140_saveGame(uint16 slot, const Common::String desc); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF - LoadgameResponse f435_loadgame(); // @ F0435_STARTEND_LoadGame_CPSF + LoadgameResponse f435_loadgame(int16 slot); // @ F0435_STARTEND_LoadGame_CPSF void f441_processEntrance(); // @ F0441_STARTEND_ProcessEntrance private: diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index e59a6e7846..6f6991e4b5 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -2077,4 +2077,22 @@ void GroupMan::save1_ActiveGroupPart(Common::OutSaveFile* file) { } } +void GroupMan::load1_ActiveGroupPart(Common::InSaveFile* file) { + for (uint16 i = 0; i < _g376_maxActiveGroupCount; ++i) { + ActiveGroup *group = &_g375_activeGroups[i]; + group->_groupThingIndex = file->readUint16BE(); + group->_directions = (direction)file->readUint16BE(); + group->_cells = file->readByte(); + group->_lastMoveTime = file->readByte(); + group->_delayFleeingFromTarget = file->readByte(); + group->_targetMapX = file->readByte(); + group->_targetMapY = file->readByte(); + group->_priorMapX = file->readByte(); + group->_priorMapY = file->readByte(); + group->_homeMapX = file->readByte(); + group->_homeMapY = file->readByte(); + for (uint16 j = 0; j < 4; ++j) + group->_aspect[j] = file->readByte(); + } +} } diff --git a/engines/dm/group.h b/engines/dm/group.h index 2ad2d8dd1d..699f195aa9 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -245,6 +245,7 @@ public: bool f221_isFluxcageOnSquare(int16 mapX, int16 mapY); // @ F0221_GROUP_IsFluxcageOnSquare void f225_fuseAction(uint16 mapX, uint16 mapY); // @ F0225_GROUP_FuseAction void save1_ActiveGroupPart(Common::OutSaveFile *file); + void load1_ActiveGroupPart(Common::InSaveFile* file); }; diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 28b57f2651..9b50351376 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -42,32 +42,96 @@ namespace DM { #define C2_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST 2 #define C3_PLATFORM_AMIGA 3 #define C10_DUNGEON_DM 10 -LoadgameResponse DMEngine::f435_loadgame() { - bool newGame = _g298_newGame; - ChampionMan &cm = *_championMan; +LoadgameResponse DMEngine::f435_loadgame(int16 slot) { + Common::String fileName; + Common::SaveFileManager *saveFileManager = nullptr; + Common::InSaveFile *file = nullptr; + + if (!_g298_newGame) { + fileName = getSavefileName(slot); + saveFileManager = _system->getSavefileManager(); + file = saveFileManager->openForLoading(fileName); + } + _g528_saveFormat = C2_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST; _g527_platform = C3_PLATFORM_AMIGA; _g526_dungeonId = C10_DUNGEON_DM; - if (newGame) { + if (_g298_newGame) { + //L1366_B_FadePalette = !F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn(C0_DO_NOT_FORCE_DIALOG_DM_CSB, true); +T0435002: _g524_restartGameAllowed = false; - cm._g305_partyChampionCount = 0; - cm._g414_leaderHandObject = Thing::_none; - _g525_gameId = _rnd->getRandomNumber(65536) * _rnd->getRandomNumber(65536); + _championMan->_g305_partyChampionCount = 0; + _championMan->_g414_leaderHandObject = Thing::_none; + _g525_gameId = ((int32)getRandomNumber(65536)) * getRandomNumber(65536); } else { - assert(false); - // MISSING CODE: load game - } - _dungeonMan->f434_loadDungeonFile(); + warning(false, "MISSING CODE: missing check for matching _g525_gameId in f435_loadgame"); + /*if (_vm->_g523_restartGameRequest && (L1372_s_SaveHeader.GameID != _vm->_g525_gameId)) { + L1367_pc_Message = G0546_pc_THATSNOTTHESAMEGAME; + goto T0435004; + }*/ + + SaveGameHeader header; + readSaveGameHeader(file, &header); + + warning(false, "MISSING CODE: missing check for matching format and platform in save in f435_loadgame"); + + _g313_gameTime = file->readUint32BE(); + // G0349_ul_LastRandomNumber = L1371_s_GlobalData.LastRandomNumber; + _championMan->_g305_partyChampionCount = file->readUint16BE(); + _dungeonMan->_g306_partyMapX = file->readSint16BE(); + _dungeonMan->_g307_partyMapY = file->readSint16BE(); + _dungeonMan->_g308_partyDir = (direction)file->readUint16BE(); + _dungeonMan->_g309_partyMapIndex = file->readByte(); + _championMan->_g411_leaderIndex = (ChampionIndex)file->readSint16BE(); + _championMan->_g514_magicCasterChampionIndex = (ChampionIndex)file->readSint16BE(); + _timeline->_g372_eventCount = file->readUint16BE(); + _timeline->_g373_firstUnusedEventIndex = file->readUint16BE(); + _timeline->_g369_eventMaxCount = file->readUint16BE(); + _groupMan->_g377_currActiveGroupCount = file->readUint16BE(); + _projexpl->_g361_lastCreatureAttackTime = file->readSint32BE(); + _projexpl->_g362_lastPartyMovementTime = file->readSint32BE(); + _g310_disabledMovementTicks = file->readSint16BE(); + _g311_projectileDisableMovementTicks = file->readSint16BE(); + _g312_lastProjectileDisabledMovementDirection = file->readSint16BE(); + _championMan->_g414_leaderHandObject = Thing(file->readUint16BE()); + _groupMan->_g376_maxActiveGroupCount = file->readUint16BE(); + if (!_g523_restartGameRequest) { + _timeline->f233_initTimeline(); + _groupMan->f196_initActiveGroups(); + } - if (newGame) { + _groupMan->load1_ActiveGroupPart(file); + _championMan->load2_PartyPart(file); + _timeline->load3_eventsPart(file); + _timeline->load4_timelinePart(file); + + _g525_gameId = file->readSint32BE(); + } + + _dungeonMan->f434_loadDungeonFile(); + if (_g298_newGame) { _timeline->f233_initTimeline(); _groupMan->f196_initActiveGroups(); + warning(false, "MISSING CODE: missing fadePlette stuff in f435_loadgame on newGame"); + /* + if (L1366_B_FadePalette) { + F0436_STARTEND_FadeToPalette(G0345_aui_BlankBuffer); + D26_WaitForVerticalBlank(); + D18_FillScreenBlack(); + F0436_STARTEND_FadeToPalette(_vm->_displayMan->_g347_paletteTopAndBottomScreen); + }*/ } else { - assert(false); - // MISSING CODE: load game + _g528_saveFormat = file->readSint16BE(); + _g527_platform = file->readSint16BE(); + _g526_dungeonId = file->readUint16BE(); + + _g524_restartGameAllowed = true; + warning(false, "MISSING CDOE: F0427_DIALOG_Draw in f435_loadgame"); } - cm._g303_partyDead = false; + _championMan->_g303_partyDead = false; + + delete file; return k1_LoadgameSuccess; } @@ -176,4 +240,50 @@ void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::Strin out->writeUint32BE(playTime); } + +bool DMEngine::readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header) { + uint32 id = in->readUint32BE(); + + // Check if it's a valid ScummVM savegame + if (id != SAVEGAME_ID) + return false; + + // Read in the version + header->_version = in->readByte(); + + // Check that the save version isn't newer than this binary + if (header->_version > SAVEGAME_VERSION) + return false; + + // Read in the save name + Common::String saveName; + char ch; + while ((ch = (char)in->readByte()) != '\0') + saveName += ch; + header->_descr.setDescription(saveName); + + // Get the thumbnail + header->_descr.setThumbnail(Graphics::loadThumbnail(*in)); + + uint32 saveDate = in->readUint32BE(); + uint16 saveTime = in->readUint16BE(); + uint32 playTime = in->readUint32BE(); + + int day = (saveDate >> 24) & 0xFF; + int month = (saveDate >> 16) & 0xFF; + int year = saveDate & 0xFFFF; + header->_descr.setSaveDate(year, month, day); + + int hour = (saveTime >> 8) & 0xFF; + int minutes = saveTime & 0xFF; + header->_descr.setSaveTime(hour, minutes); + + header->_descr.setPlayTime(playTime * 1000); + if (g_engine) + g_engine->setTotalPlayTime(playTime * 1000); + + return true; } + +} + diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index afeb577eeb..37eb880690 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -1106,4 +1106,22 @@ void Timeline::save4_timelinePart(Common::OutSaveFile* file) { file->writeUint16BE(_g371_timeline[i]); } +void Timeline::load3_eventsPart(Common::InSaveFile* file) { + for (uint16 i = 0; i < _g369_eventMaxCount; ++i) { + TimelineEvent *event = &_g370_events[i]; + event->_mapTime = file->readSint32BE(); + event->_type = file->readByte(); + event->_priority = file->readByte(); + event->_B._location._mapX = file->readByte(); + event->_B._location._mapY = file->readByte(); + event->_C.A._cell = file->readUint16BE(); + event->_C.A._effect = file->readUint16BE(); + } +} + +void Timeline::load4_timelinePart(Common::InSaveFile* file) { + for (uint16 i = 0; i < _g369_eventMaxCount; ++i) + _g371_timeline[i] = file->readUint16BE(); +} + } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index 8f68c35fe2..2d722d5569 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -189,6 +189,8 @@ public: void f255_timelineProcessEvent13_ViAltarRebirth(TimelineEvent *event); // @ F0255_TIMELINE_ProcessEvent13_ViAltarRebirth void save3_eventsPart(Common::OutSaveFile *file); void save4_timelinePart(Common::OutSaveFile *file); + void load3_eventsPart(Common::InSaveFile* file); + void load4_timelinePart(Common::InSaveFile* file); }; -- cgit v1.2.3 From 0f02cc5b0210e6cdc460770d6493a7eb675ce04e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Jul 2016 09:32:38 +0200 Subject: DM: Fix compilation using MSVC9 --- engines/dm/dm.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 0aade77684..92cb402a3a 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -487,10 +487,10 @@ void DMEngine::f441_processEntrance() { } void DMEngine::f439_drawEntrance() { - static Box K0079_s_Box_Entrance_DoorsUpperHalf = {0, 231, 0, 80}; - static Box K0152_s_Box_Entrance_DoorsLowerHalf = {0, 231, 81, 160}; - static Box G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft = {0, 104, 30, 190}; - static Box G0011_s_Graphic562_Box_Entrance_ClosedDoorRight = {105, 231, 30, 190}; + static Box K0079_s_Box_Entrance_DoorsUpperHalf = Box(0, 231, 0, 80); + static Box K0152_s_Box_Entrance_DoorsLowerHalf = Box(0, 231, 81, 160); + static Box G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft = Box(0, 104, 30, 190); + static Box G0011_s_Graphic562_Box_Entrance_ClosedDoorRight = Box(105, 231, 30, 190); uint16 L1397_ui_ColumnIndex; byte* L1398_apuc_MicroDungeonCurrentMapData[32]; -- cgit v1.2.3 From 877b1b051b746c44baec9f4b2114d9aedc1e07a9 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Jul 2016 09:33:23 +0200 Subject: DM: Remove a broken character in the definition of f231_getMeleeActionDamage --- engines/dm/group.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/dm/group.h b/engines/dm/group.h index 699f195aa9..1447783ffc 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -239,7 +239,7 @@ public: int16 f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 paryY, uint16 champCell); // @ F0177_GROUP_GetMeleeTargetCreatureOrdinal int16 f231_getMeleeActionDamage(Champion *champ, int16 champIndex, Group *group, int16 creatureIndex, - int16 mapX, int16 mapXóY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex); // @ F0231_GROUP_GetMeleeActionDamage + int16 mapX, int16 mapY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex); // @ F0231_GROUP_GetMeleeActionDamage void f224_fluxCageAction(int16 mapX, int16 mapY); // @ F0224_GROUP_FluxCageAction uint16 f222_isLordChaosOnSquare(int16 mapX, int16 mapY); // @ F0222_GROUP_IsLordChaosOnSquare bool f221_isFluxcageOnSquare(int16 mapX, int16 mapY); // @ F0221_GROUP_IsFluxcageOnSquare -- cgit v1.2.3 From 33aac99beeca9f101857aab326a4fc3e0647dc66 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Jul 2016 09:34:11 +0200 Subject: DM: Reduce the scope of a couple of variables --- engines/dm/champion.cpp | 6 ++---- engines/dm/inventory.cpp | 22 +++++++--------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index aac5584777..464aee72ee 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1420,8 +1420,6 @@ void ChampionMan::f319_championKill(uint16 champIndex) { int16 L0963_i_AliveChampionIndex; Thing L0964_T_Thing; Champion* L0965_ps_Champion; - Junk* L0966_ps_Junk; - L0965_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; L0965_ps_Champion->_currHealth = 0; @@ -1449,7 +1447,7 @@ void ChampionMan::f319_championKill(uint16 champIndex) { L0964_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k0x8000_championBones | k10_JunkThingType); if (L0964_T_Thing == Thing::_none) { } else { - L0966_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0964_T_Thing); + Junk* L0966_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0964_T_Thing); L0966_ps_Junk->setType(k5_JunkTypeBones); L0966_ps_Junk->setDoNotDiscard(true); L0966_ps_Junk->setChargeCount(champIndex); @@ -1686,7 +1684,7 @@ void ChampionMan::f331_applyTimeEffects() { } } } - if (!_vm->_championMan->_g300_partyIsSleeping && (L1010_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime < (_vm->_g313_gameTime - 60))) { + if (!_vm->_championMan->_g300_partyIsSleeping && (L1010_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < (int32)_vm->_g313_gameTime)) { L1010_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir; L1010_ps_Champion->_maximumDamageReceived = 0; setFlag(L1010_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon); diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 1a15d44d30..c33524ab6f 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -566,7 +566,6 @@ void InventoryMan::f337_setDungeonViewPalette() { uint16 L1044_ui_Multiple; #define AL1044_T_Thing L1044_ui_Multiple #define AL1044_ui_TorchLightPower L1044_ui_Multiple - int16 L1045_ai_TorchesLightPower[8]; int16 g40_palIndexToLightAmmount[6] = {99, 75, 50, 25, 1, 0}; // @ G0040_ai_Graphic562_PaletteIndexToLightAmount @@ -576,6 +575,7 @@ void InventoryMan::f337_setDungeonViewPalette() { /* Get torch light power from both hands of each champion in the party */ int16 L1038_i_Counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */ Champion *L1043_ps_Champion = _vm->_championMan->_gK71_champions; + int16 L1045_ai_TorchesLightPower[8]; AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower; while (L1038_i_Counter--) { AL1039_ui_SlotIndex = k1_ChampionSlotActionHand + 1; @@ -638,26 +638,18 @@ void InventoryMan::f337_setDungeonViewPalette() { } void InventoryMan::f338_decreaseTorchesLightPower() { - int16 L1046_i_ChampionCount; - int16 L1047_i_SlotIndex; - bool L1048_B_TorchChargeCountChanged; - int16 L1049_i_IconIndex; - Champion* L1050_ps_Champion; - Weapon* L1051_ps_Weapon; - - - L1048_B_TorchChargeCountChanged = false; - L1046_i_ChampionCount = _vm->_championMan->_g305_partyChampionCount; + bool L1048_B_TorchChargeCountChanged = false; + int16 L1046_i_ChampionCount = _vm->_championMan->_g305_partyChampionCount; if (_vm->_championMan->_g299_candidateChampionOrdinal) { L1046_i_ChampionCount--; } - L1050_ps_Champion = _vm->_championMan->_gK71_champions; + Champion *L1050_ps_Champion = _vm->_championMan->_gK71_champions; while (L1046_i_ChampionCount--) { - L1047_i_SlotIndex = k1_ChampionSlotActionHand + 1; + int16 L1047_i_SlotIndex = k1_ChampionSlotActionHand + 1; while (L1047_i_SlotIndex--) { - L1049_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L1050_ps_Champion->_slots[L1047_i_SlotIndex]); + int16 L1049_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L1050_ps_Champion->_slots[L1047_i_SlotIndex]); if ((L1049_i_IconIndex >= k4_IconIndiceWeaponTorchUnlit) && (L1049_i_IconIndex <= k7_IconIndiceWeaponTorchLit)) { - L1051_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L1050_ps_Champion->_slots[L1047_i_SlotIndex]); + Weapon *L1051_ps_Weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(L1050_ps_Champion->_slots[L1047_i_SlotIndex]); if (L1051_ps_Weapon->getChargeCount()) { if (L1051_ps_Weapon->setChargeCount(L1051_ps_Weapon->getChargeCount() - 1) == 0) { L1051_ps_Weapon->setDoNotDiscard(false); -- cgit v1.2.3 From 185588f098d3982399c74729ad731a68fa1c2454 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Jul 2016 09:45:59 +0200 Subject: DM: Silent some CppCheck warnings in eventman.cpp --- engines/dm/eventman.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index d6790b4fcf..dadc931264 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -1312,13 +1312,6 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c static Box G0622_s_Box_MousePointer_ChampionIcon = Box(0, 18, 0, 13); static byte G0045_auc_Graphic562_PaletteChanges_MousePointerIconShadow[16] = {0, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 0, 120, 120, 120}; - uint16 L0052_ui_ChampionIconIndex; - int16 L0053_i_ChampionIndex; - int16 L0054_i_ChampionIndex; - Box* L0055_pi_ChampionIconBox; - byte* L0056_puc_Bitmap; - - _gK100_preventBuildPointerScreenArea = true; if (!_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) { if (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir)) == kM1_ChampionNone) { @@ -1328,9 +1321,9 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c _vm->_eventMan->_g598_mousePointerBitmapUpdated = true; _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = true; _vm->_displayMan->_g578_useByteBoxCoordinates = false; - L0056_puc_Bitmap = _gK190_mousePointerTempBuffer; + byte *L0056_puc_Bitmap = _gK190_mousePointerTempBuffer; memset(L0056_puc_Bitmap, 0, 32 * 18); - L0055_pi_ChampionIconBox = &g54_BoxChampionIcons[champIconIndex]; + Box *L0055_pi_ChampionIconBox = &g54_BoxChampionIcons[champIconIndex]; _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g348_bitmapScreen, L0056_puc_Bitmap, G0621_s_Box_MousePointer_ChampionIconShadow, L0055_pi_ChampionIconBox->_x1, L0055_pi_ChampionIconBox->_y1, k160_byteWidthScreen, k16_byteWidth, k0_ColorBlack, 200, 18); @@ -1342,14 +1335,14 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(champIconIndex); } else { _vm->_eventMan->_g598_mousePointerBitmapUpdated = true; - L0052_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap); + uint16 L0052_ui_ChampionIconIndex = _vm->M1_ordinalToIndex(_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap); _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone); - L0054_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(L0052_ui_ChampionIconIndex + _vm->_dungeonMan->_g308_partyDir)); + int16 L0054_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(L0052_ui_ChampionIconIndex + _vm->_dungeonMan->_g308_partyDir)); if (L0052_ui_ChampionIconIndex == champIconIndex) { setFlag(_vm->_championMan->_gK71_champions[L0054_i_ChampionIndex]._attributes, k0x0400_ChampionAttributeIcon); _vm->_championMan->f292_drawChampionState((ChampionIndex)L0054_i_ChampionIndex); } else { - L0053_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir)); + int16 L0053_i_ChampionIndex = _vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(champIconIndex + _vm->_dungeonMan->_g308_partyDir)); if (L0053_i_ChampionIndex >= 0) { _vm->_championMan->_gK71_champions[L0053_i_ChampionIndex]._cell = (ViewCell)M21_normalizeModulo4(L0052_ui_ChampionIconIndex + _vm->_dungeonMan->_g308_partyDir); setFlag(_vm->_championMan->_gK71_champions[L0053_i_ChampionIndex]._attributes, k0x0400_ChampionAttributeIcon); -- cgit v1.2.3 From c15c5a16f4a5df540b599ff7270f01829d5041fd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Jul 2016 09:48:39 +0200 Subject: DM: Remove broken characters in f231_getMeleeActionDamage body --- engines/dm/group.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 6f6991e4b5..e132685e6f 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -1841,7 +1841,7 @@ int16 GroupMan::f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, i } } -int16 GroupMan::f231_getMeleeActionDamage(Champion* champ, int16 champIndex, Group* group, int16 creatureIndex, int16 mapX, int16 mapXóY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex) { +int16 GroupMan::f231_getMeleeActionDamage(Champion* champ, int16 champIndex, Group* group, int16 creatureIndex, int16 mapX, int16 mapY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex) { int16 L0565_i_Damage = 0; int16 L0566_i_Damage = 0; int16 L0567_i_DoubledMapDifficulty; @@ -1903,7 +1903,7 @@ T0231009: if (_vm->getRandomNumber(64) < _vm->_championMan->f303_getSkillLevel(champIndex, skillIndex)) { L0565_i_Damage += L0565_i_Damage + 10; } - L0569_i_Outcome = f190_groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapXóY, L0565_i_Damage, true); + L0569_i_Outcome = f190_groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapY, L0565_i_Damage, true); _vm->_championMan->f304_addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * L0572_ps_CreatureInfo->M58_getExperience() >> 4) + 3); _vm->_championMan->f325_decrementStamine(champIndex, _vm->getRandomNumber(4) + 4); goto T0231016; @@ -1915,7 +1915,7 @@ T0231015: T0231016: _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); if (L0569_i_Outcome != k2_outcomeKilledAllCreaturesInGroup) { - f209_processEvents29to41(mapX, mapXóY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0); + f209_processEvents29to41(mapX, mapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0); } return L0565_i_Damage; } -- cgit v1.2.3 From 2f3c9b7c7862d2c424a43d805f791b1176867eaf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Jul 2016 10:03:40 +0200 Subject: DM: Remove variable redefinition in f337_setDungeonViewPalette, reduce some scopes --- engines/dm/inventory.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index c33524ab6f..86b78bdb2b 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -552,22 +552,10 @@ void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) { f335_drawPanelObjectDescriptionString(str); } f339_drawPanelArrowOrEye(pressingEye); - } void InventoryMan::f337_setDungeonViewPalette() { - uint16 L1039_ui_Multiple; -#define AL1039_ui_SlotIndex L1039_ui_Multiple -#define AL1039_ui_PaletteIndex L1039_ui_Multiple -#define AL1039_ui_Counter L1039_ui_Multiple - int16* L1040_pi_Multiple; -#define AL1040_pi_TorchLightPower L1040_pi_Multiple -#define AL1040_pi_LightAmount L1040_pi_Multiple - uint16 L1044_ui_Multiple; -#define AL1044_T_Thing L1044_ui_Multiple -#define AL1044_ui_TorchLightPower L1044_ui_Multiple - - int16 g40_palIndexToLightAmmount[6] = {99, 75, 50, 25, 1, 0}; // @ G0040_ai_Graphic562_PaletteIndexToLightAmount + static const int16 g40_palIndexToLightAmmount[6] = {99, 75, 50, 25, 1, 0}; // @ G0040_ai_Graphic562_PaletteIndexToLightAmount if (_vm->_dungeonMan->_g269_currMap->_difficulty == 0) { _vm->_displayMan->_g304_dungeonViewPaletteIndex = 0; /* Brightest color palette index */ @@ -576,12 +564,13 @@ void InventoryMan::f337_setDungeonViewPalette() { int16 L1038_i_Counter = 4; /* BUG0_01 Coding error without consequence. The hands of four champions are inspected even if there are less champions in the party. No consequence as the data in unused champions is set to 0 and _vm->_objectMan->f32_getObjectType then returns -1 */ Champion *L1043_ps_Champion = _vm->_championMan->_gK71_champions; int16 L1045_ai_TorchesLightPower[8]; - AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower; + int16 *AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower; while (L1038_i_Counter--) { - AL1039_ui_SlotIndex = k1_ChampionSlotActionHand + 1; + uint16 AL1039_ui_SlotIndex = k1_ChampionSlotActionHand + 1; while (AL1039_ui_SlotIndex--) { - if ((_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16())) >= k4_IconIndiceWeaponTorchUnlit) && - (_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16())) <= k7_IconIndiceWeaponTorchLit)) { + uint16 AL1044_T_Thing = L1043_ps_Champion->_slots[AL1039_ui_SlotIndex].toUint16(); + if ((_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing)) >= k4_IconIndiceWeaponTorchUnlit) && + (_vm->_objectMan->f32_getObjectType(Thing(AL1044_T_Thing)) <= k7_IconIndiceWeaponTorchLit)) { Weapon *L1042_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(Thing(AL1044_T_Thing)); *AL1040_pi_TorchLightPower = L1042_ps_Weapon->getChargeCount(); } else { @@ -593,13 +582,13 @@ void InventoryMan::f337_setDungeonViewPalette() { } /* Sort torch light power values so that the four highest values are in the first four entries in the array L1045_ai_TorchesLightPower in decreasing order. The last four entries contain the smallest values but they are not sorted */ AL1040_pi_TorchLightPower = L1045_ai_TorchesLightPower; - AL1039_ui_Counter = 0; + int16 AL1039_ui_Counter = 0; while (AL1039_ui_Counter != 4) { L1038_i_Counter = 7 - AL1039_ui_Counter; int16 *L1041_pi_TorchLightPower = &L1045_ai_TorchesLightPower[AL1039_ui_Counter + 1]; while (L1038_i_Counter--) { if (*L1041_pi_TorchLightPower > *AL1040_pi_TorchLightPower) { - AL1044_ui_TorchLightPower = *L1041_pi_TorchLightPower; + int16 AL1044_ui_TorchLightPower = *L1041_pi_TorchLightPower; *L1041_pi_TorchLightPower = *AL1040_pi_TorchLightPower; *AL1040_pi_TorchLightPower = AL1044_ui_TorchLightPower; } @@ -622,7 +611,8 @@ void InventoryMan::f337_setDungeonViewPalette() { } L1036_i_TotalLightAmount += _vm->_championMan->_g407_party._magicalLightAmount; /* Select palette corresponding to the total light amount */ - AL1040_pi_LightAmount = g40_palIndexToLightAmmount; + const int16 *AL1040_pi_LightAmount = g40_palIndexToLightAmmount; + int16 AL1039_ui_PaletteIndex; if (L1036_i_TotalLightAmount > 0) { AL1039_ui_PaletteIndex = 0; /* Brightest color palette index */ while (*AL1040_pi_LightAmount++ > L1036_i_TotalLightAmount) { -- cgit v1.2.3 From ebd672770ada3685c2e84299368c9586d944ba2a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Jul 2016 12:54:25 +0200 Subject: DM: Properly stub f064_SOUND_RequestPlay_CPSD --- engines/dm/champion.cpp | 2 +- engines/dm/dm.h | 2 ++ engines/dm/eventman.cpp | 4 ++-- engines/dm/group.cpp | 22 ++++++++++++---------- engines/dm/menus.cpp | 13 ++++++------- engines/dm/movesens.cpp | 12 ++++++------ engines/dm/projexpl.cpp | 8 ++++---- engines/dm/text.h | 2 -- engines/dm/timeline.cpp | 13 +++++++------ 9 files changed, 40 insertions(+), 38 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 464aee72ee..8c3aacd447 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -199,7 +199,7 @@ bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 return false; } } - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); f325_decrementStamine(champIndex, f305_getThrowingStaminaCost(L0996_T_Thing)); f330_disableAction(champIndex, 4); AL0994_i_Experience = 8; diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 279144bc4d..128dfaf8e4 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -220,6 +220,8 @@ public: LoadgameResponse f435_loadgame(int16 slot); // @ F0435_STARTEND_LoadGame_CPSF void f441_processEntrance(); // @ F0441_STARTEND_ProcessEntrance + void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode) { warning(true, "STUB: f064_SOUND_RequestPlay_CPSD"); } + private: int16 _g528_saveFormat; // @ G0528_i_Format int16 _g527_platform; // @ G0527_i_Platform diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index dadc931264..946c1fb989 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -891,7 +891,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) { L1117_B_MovementBlocked |= _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF); } if (L1117_B_MovementBlocked) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, L1121_i_MapX, L1122_i_MapY, k0_soundModePlayImmediately); } } else { if (L1117_B_MovementBlocked = (_vm->_groupMan->f175_groupGetThing(L1121_i_MapX, L1122_i_MapY) != Thing::_endOfList)) { @@ -1027,7 +1027,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16 L1151_ps_Junk = (Junk*)_vm->_dungeonMan->f157_getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY); if ((((Door*)L1151_ps_Junk)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) { _vm->_g321_stopWaitingForPlayerInput = true; - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); _vm->_movsens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1); return; } diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index e132685e6f..05f4b5a654 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -147,7 +147,7 @@ void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThin _vm->_movsens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY); } while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList); if (mode >= k0_soundModePlayImmediately) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(L0371_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode); } } } @@ -229,11 +229,11 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX L0359_pui_FixedPossessions = g253FixedPossessionCreature_24RedDragon; } uint16 L0356_ui_FixedPossession; + bool L0362_B_WeaponDropped = false; while (L0356_ui_FixedPossession = *L0359_pui_FixedPossessions++) { if (getFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) && _vm->getRandomNumber(2)) continue; int16 L0357_i_ThingType; - bool L0362_B_WeaponDropped = false; if (clearFlag(L0356_ui_FixedPossession, k0x8000_randomDrop) >= k127_ObjectInfoIndexFirstJunk) { L0357_i_ThingType = k10_JunkThingType; L0356_ui_FixedPossession -= k127_ObjectInfoIndexFirstJunk; @@ -258,7 +258,7 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell); _vm->_movsens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY); } - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(L0362_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode); } int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) { @@ -890,7 +890,7 @@ T0209089_DoubleSquareMove: AL0450_i_DestinationMapX = eventMapX; AL0451_i_DestinationMapY = eventMapY; AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2; - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY, k1_soundModePlayIfPrioritized); goto T0209061_MoveGroup; } } @@ -1271,7 +1271,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) { if (_vm->getRandomNumber(2)) { toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized); } } else { if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) { @@ -1293,7 +1293,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); L1635_ui_SoundIndex = _vm->_movsens->f514_getSound(k13_CreatureTypeCouatl); if (L1635_ui_SoundIndex <= k34_D13_soundCount) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(L1635_ui_SoundIndex, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized); } } } else { @@ -1418,6 +1418,8 @@ bool GroupMan::f204_isArchenemyDoubleMovementPossible(CreatureInfo *info, int16 } bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 creatureIndex) { + static const uint8 G0244_auc_Graphic559_CreatureAttackSounds[11] = { 3, 7, 14, 15, 19, 21, 29, 30, 31, 4, 16 }; /* Atari ST: { 3, 7, 14, 15, 19, 21, 4, 16 } */ + uint16 L0437_ui_Multiple; #define AL0437_ui_CreatureType L0437_ui_Multiple #define AL0437_T_Thing L0437_ui_Multiple @@ -1486,7 +1488,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui AL0440_i_KineticEnergy = (L0441_ps_CreatureInfo->_attack >> 2) + 1; AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy); AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy); - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, mapX, mapY, k0_soundModePlayImmediately); _vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8); } else { if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) { @@ -1514,7 +1516,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui } } if (AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(G0244_auc_Graphic559_CreatureAttackSounds[--AL0440_i_AttackSoundOrdinal], mapX, mapY, k1_soundModePlayIfPrioritized); } return true; } @@ -1637,7 +1639,7 @@ int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) { AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1; } if (AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType)) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k09_soundCHAMPION_0_DAMAGED + champIndex, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater); if ((AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack) && _vm->getRandomNumber(2) && ((AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack)) >= 0)) { _vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack); } @@ -1808,7 +1810,7 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie if (_vm->_movsens->f267_getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */ return Thing::_none; } - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, mapX, mapY, k1_soundModePlayIfPrioritized); return L0349_T_GroupThing; } diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 06a286c65e..146a75e919 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -1114,10 +1114,10 @@ T0407014: case k13_ChampionActionSwing: case k2_ChampionActionChop: if ((Square(AL1244_ui_TargetSquare).getType() == k4_DoorElemType) && (Square(AL1244_ui_TargetSquare).getDoorState() == k4_doorState_CLOSED)) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); L1249_ui_ActionDisabledTicks = 6; _vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand), false, 2); - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater); break; } case k24_ChampionActionDisrupt: @@ -1143,10 +1143,10 @@ T0407014: case k41_ChampionActionBrandish: case k4_ChampionActionBlowHorn: if (actionIndex == k8_ChampionActionWarCry) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k28_soundWAR_CRY, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately); } if (actionIndex == k4_ChampionActionBlowHorn) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k25_soundBLOW_HORN, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately); } AL1245_B_ActionPerformed = f401_isGroupFrightenedByAction(champIndex, actionIndex, L1251_i_MapX, L1252_i_MapY); break; @@ -1176,7 +1176,7 @@ T0407032: f406_setChampionDirectionToPartyDirection(L1247_ps_Champion); { // so gotos won't skip init Thing AL1250_T_Object = _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand); - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); _vm->_championMan->f326_championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->f303_getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy); } break; @@ -1439,8 +1439,7 @@ bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int #define AL1237_ui_ActionHitProbability L1237_ui_Multiple int16 L1238_i_CreatureOrdinal; - - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); if (_g517_actionTargetGroupThing == Thing::_endOfList) goto T0402010; if (L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, AL1236_ui_ChampionCell = champ->_cell)) { diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 65742e6dbb..75413800c6 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -181,7 +181,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui if (!L0753_B_DoNotTriggerSensor) { L0759_B_AtLeastOneSensorWasTriggered = true; if (L0755_ps_Sensor->getAudibleA()) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); } if (!_vm->_championMan->_g415_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) { L0754_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0761_T_LeaderHandObject); @@ -296,7 +296,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 _vm->_dungeonMan->_g306_partyMapX = destMapX; _vm->_dungeonMan->_g307_partyMapY = destMapY; if (L0712_ps_Teleporter->isAudible()) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately); } L0723_B_DrawDungeonViewWhileFalling = true; if (L0712_ps_Teleporter->getAbsoluteRotation()) { @@ -307,7 +307,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 } else { if (L0710_i_ThingType == k4_GroupThingType) { if (L0712_ps_Teleporter->isAudible()) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, destMapX, destMapY, k1_soundModePlayIfPrioritized); } L0720_ui_MoveGroupResult = f262_getTeleporterRotatedGroupResult(L0712_ps_Teleporter, thing, L0714_ui_MapIndexSource); } else { @@ -349,7 +349,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 } } else { if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF)) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately); } } } @@ -477,7 +477,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 } L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[thing.getIndex()]._type); if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(L1638_ui_MovementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized); } if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != _vm->_dungeonMan->_g309_partyMapIndex)) { /* If the group leaves the party map */ _vm->_groupMan->f184_removeActiveGroup(AL0708_i_ActiveGroupIndex); @@ -896,7 +896,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m goto T0276079; } if (L0769_ps_Sensor->getAudibleA()) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized); } f272_sensorTriggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around goto T0276079; diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index 7d99b97648..8996693f4b 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -230,7 +230,7 @@ T0217004: AL0507_ui_SoundIndex = k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM; } } - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(AL0507_ui_SoundIndex, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY, k1_soundModePlayIfPrioritized); } T0217044: if (L0509_B_RemovePotion) { @@ -321,10 +321,10 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC L0470_ps_Explosion->setType(explThing.toUint16() - Thing::_firstExplosion.toUint16()); L0470_ps_Explosion->setAttack(attack); if (explThing.toUint16() < Thing::_explHarmNonMaterial.toUint16()) { - warning(false, "MISING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD((attack > 80) ? k05_soundSTRONG_EXPLOSION : k20_soundWEAK_EXPLOSION, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized); } else { if (explThing != Thing::_explSmoke) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized); } } _vm->_dungeonMan->f163_linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY); @@ -564,7 +564,7 @@ void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) { break; case 0xFFE4: L0532_ps_Explosion->setType(L0532_ps_Explosion->getType() + 1); - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k05_soundSTRONG_EXPLOSION, L0528_ui_MapX, L0529_ui_MapY, k1_soundModePlayIfPrioritized); goto T0220026; case 0xFFA8: if (L0532_ps_Explosion->getAttack() > 55) { diff --git a/engines/dm/text.h b/engines/dm/text.h index c07b8f2491..e0f5e7a73c 100644 --- a/engines/dm/text.h +++ b/engines/dm/text.h @@ -56,9 +56,7 @@ public: void f42_messageAreaMoveCursor(int16 column, int16 row); // @ F0042_TEXT_MESSAGEAREA_MoveCursor void f44_messageAreaClearExpiredRows(); // @ F0044_TEXT_MESSAGEAREA_ClearExpiredRows - }; } - #endif diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 37eb880690..09e31bf935 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -318,7 +318,7 @@ void Timeline::f261_processTimeline() { f246_timelineProcesEvent65_enableGroupGenerator(L0681_ps_Event); break; case k20_TMEventTypePlaySound: - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(L0682_s_Event._C._soundIndex, L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, k1_soundModePlayIfPrioritized); break; case k24_TMEventTypeRemoveFluxcage: if (!_vm->_g302_gameWon) { @@ -421,7 +421,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) { // Original bug fixed - A closing horizontal door wounds champions to the head instead of to the hands. Missing parenthesis in the condition cause all doors to wound the head in addition to the torso // See BUG0_78 if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(5, k0x0008_ChampionWoundTorso | (AL0602_ui_VerticalDoor ? k0x0004_ChampionWoundHead : k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand), k2_attackType_SELF)) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized); } } event->_mapTime++; @@ -435,7 +435,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) { } L0596_i_DoorState = (L0596_i_DoorState == k0_doorState_OPEN) ? k0_doorState_OPEN : (L0596_i_DoorState - 1); L0597_puc_Square->setDoorState(L0596_i_DoorState); - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized); event->_mapTime++; _vm->_timeline->f238_addEventGetEventIndex(event); return; @@ -447,7 +447,8 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) { } L0596_i_DoorState += (L0595_i_Effect == k0_SensorEffSet) ? -1 : 1; L0597_puc_Square->setDoorState(L0596_i_DoorState); - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k02_soundDOOR_RATTLE, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized); + if (L0595_i_Effect == k0_SensorEffSet) { if (L0596_i_DoorState == k0_doorState_OPEN) { return; @@ -838,7 +839,7 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) { } _vm->_groupMan->f185_groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY); if (L0614_ps_Sensor->getAudibleA()) { - warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0616_ui_MapX, L0617_ui_MapY, k1_soundModePlayIfPrioritized); } if (L0614_ps_Sensor->getOnlyOnce()) { L0614_ps_Sensor->setTypeDisabled(); @@ -878,7 +879,7 @@ void Timeline::f252_timelineProcessEvents60to61_moveGroup(TimelineEvent* event) T0252001: if (((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) || (L0656_ui_MapX != _vm->_dungeonMan->_g306_partyMapX) || (L0657_ui_MapY != _vm->_dungeonMan->_g307_partyMapY)) && (_vm->_groupMan->f175_groupGetThing(L0656_ui_MapX, L0657_ui_MapY) == Thing::_endOfList)) { /* BUG0_24 Lord Chaos may teleport into one of the Black Flames and become invisible until the Black Flame is killed. In this case, _vm->_groupMan->f175_groupGetThing returns the Black Flame thing and the Lord Chaos thing is not moved into the dungeon until the Black Flame is killed */ if (event->_type == k61_TMEventTypeMoveGroupAudible) { - warning(false, "F0064_SOUND_RequestPlay_CPSD"); + _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0656_ui_MapX, L0657_ui_MapY, k1_soundModePlayIfPrioritized); } _vm->_movsens->f267_getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, L0656_ui_MapX, L0657_ui_MapY); } else { -- cgit v1.2.3 From 5418c2288b9a8e34f528f0d6f59dec5e7b959e5f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Jul 2016 16:27:31 +0200 Subject: DM: Fix some more CppCheck warnings --- engines/dm/menus.cpp | 19 ++++++------------- engines/dm/movesens.cpp | 17 ++++++++++------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 146a75e919..f2c372cf26 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -659,24 +659,17 @@ Spell* MenuMan::f409_getSpellFromSymbols(byte* symbols) { Spell(0x00687073, 4, 13, 0x3C61), Spell(0x006B7076, 3, 2, 0xFCD1), Spell(0x006B6C00, 2, 19, 0x7831), - Spell(0x006B6E76, 0, 3, 0x3C73)}; - - - int32 L1261_l_Symbols; - int16 L1262_i_Multiple; -#define AL1262_i_BitShiftCount L1262_i_Multiple -#define AL1262_i_SpellIndex L1262_i_Multiple - Spell* L1263_ps_Spell; - + Spell(0x006B6E76, 0, 3, 0x3C73) + }; if (*(symbols + 1)) { - AL1262_i_BitShiftCount = 24; - L1261_l_Symbols = 0; + int16 AL1262_i_BitShiftCount = 24; + int32 L1261_l_Symbols = 0; do { L1261_l_Symbols |= (long)*symbols++ << AL1262_i_BitShiftCount; } while (*symbols && ((AL1262_i_BitShiftCount -= 8) >= 0)); - L1263_ps_Spell = G0487_as_Graphic560_Spells; - AL1262_i_SpellIndex = 25; + Spell *L1263_ps_Spell = G0487_as_Graphic560_Spells; + int16 AL1262_i_SpellIndex = 25; while (AL1262_i_SpellIndex--) { if (L1263_ps_Spell->_symbols & 0xFF000000) { /* If byte 1 of spell is not 0 then the spell includes the power symbol */ if (L1261_l_Symbols == L1263_ps_Spell->_symbols) { /* Compare champion symbols, including power symbol, with spell (never used with actual spells) */ diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 75413800c6..d8337bc807 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -232,17 +232,12 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 uint16 L1638_ui_MovementSoundIndex; L0710_i_ThingType = kM1_PartyThingType; - bool L0713_B_ThingLevitates = false; L0719_i_TraversedPitCount = 0; L0720_ui_MoveGroupResult = 0; - bool L0721_B_GroupOnPartyMap = false; - bool L0722_B_FallKilledGroup = false; - bool L0723_B_DrawDungeonViewWhileFalling = false; - bool L0724_B_DestinationIsTeleporterTarget = false; - bool L0725_B_PartySquare = false; - bool L0726_B_Audible = false; uint16 L0717_ui_ThingCell = 0; + + bool L0713_B_ThingLevitates = false; if (thing != Thing::_party) { L0710_i_ThingType = thing.getType(); L0717_ui_ThingCell = thing.getCell(); @@ -254,12 +249,20 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 return true; /* The specified group thing cannot be moved because it was killed by a projectile impact */ } } + uint16 L0714_ui_MapIndexSource = 0; uint16 L0715_ui_MapIndexDestination = 0; + bool L0721_B_GroupOnPartyMap = false; + bool L0725_B_PartySquare = false; + bool L0726_B_Audible = false; + if (destMapX >= 0) { L0714_ui_MapIndexSource = L0715_ui_MapIndexDestination = _vm->_dungeonMan->_g272_currMapIndex; L0721_B_GroupOnPartyMap = (L0714_ui_MapIndexSource == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX >= 0); uint16 L0716_ui_Direction = 0; + bool L0722_B_FallKilledGroup = false; + bool L0723_B_DrawDungeonViewWhileFalling = false; + bool L0724_B_DestinationIsTeleporterTarget = false; if (thing == Thing::_party) { _vm->_dungeonMan->_g306_partyMapX = destMapX; _vm->_dungeonMan->_g307_partyMapY = destMapY; -- cgit v1.2.3 From 5cef0e66be1a905d35f09d2984d0ce743eb0bfd0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Jul 2016 19:05:25 +0200 Subject: DM: Light refactoring and renaming of local variables in f328_isObjectThrown --- engines/dm/champion.cpp | 90 ++++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 49 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 8c3aacd447..8925187e4a 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -164,62 +164,55 @@ bool ChampionMan::f329_isLeaderHandObjectThrown(int16 side) { } bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side) { - int16 L0993_i_KineticEnergy; - int16 L0994_i_Multiple; -#define AL0994_i_Experience L0994_i_Multiple -#define AL0994_i_Attack L0994_i_Multiple - int16 L0995_i_Multiple; -#define AL0995_i_WeaponKineticEnergy L0995_i_Multiple -#define AL0995_i_SkillLevel L0995_i_Multiple -#define AL0995_i_StepEnergy L0995_i_Multiple - Thing L0996_T_Thing; - Champion* L0997_ps_Champion = nullptr; - WeaponInfo* L0998_ps_WeaponInfo; - Thing L0999_T_ActionHandThing; - bool L1000_B_ThrowingLeaderHandObject; - - - L1000_B_ThrowingLeaderHandObject = false; + bool throwingLeaderHandObjectFl = false; + Thing curThing; + Champion *curChampion = nullptr; + Thing actionHandThing; + if (slotIndex < 0) { /* Throw object in leader hand, which is temporarily placed in action hand */ - if (_g415_leaderEmptyHanded) { + if (_g415_leaderEmptyHanded) return false; - } - L0996_T_Thing = f298_getObjectRemovedFromLeaderHand(); - L0997_ps_Champion = &_gK71_champions[champIndex]; - L0999_T_ActionHandThing = L0997_ps_Champion->getSlot(k1_ChampionSlotActionHand); - L0997_ps_Champion->setSlot(k1_ChampionSlotActionHand, L0996_T_Thing); + + curThing = f298_getObjectRemovedFromLeaderHand(); + curChampion = &_gK71_champions[champIndex]; + actionHandThing = curChampion->getSlot(k1_ChampionSlotActionHand); + curChampion->setSlot(k1_ChampionSlotActionHand, curThing); slotIndex = k1_ChampionSlotActionHand; - L1000_B_ThrowingLeaderHandObject = true; + throwingLeaderHandObjectFl = true; } - L0993_i_KineticEnergy = f312_getStrength(champIndex, slotIndex); - if (L1000_B_ThrowingLeaderHandObject) { - L0997_ps_Champion->setSlot((ChampionSlot)slotIndex, L0999_T_ActionHandThing); + + int16 kineticEnergy = f312_getStrength(champIndex, slotIndex); + if (throwingLeaderHandObjectFl) { + // In this case, curChampion and actionHandThing are set. + curChampion->setSlot((ChampionSlot)slotIndex, actionHandThing); } else { - if ((L0996_T_Thing = f300_getObjectRemovedFromSlot(champIndex, slotIndex)) == Thing::_none) { + curThing = f300_getObjectRemovedFromSlot(champIndex, slotIndex); + if (curThing == Thing::_none) return false; - } } + _vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); - f325_decrementStamine(champIndex, f305_getThrowingStaminaCost(L0996_T_Thing)); + f325_decrementStamine(champIndex, f305_getThrowingStaminaCost(curThing)); f330_disableAction(champIndex, 4); - AL0994_i_Experience = 8; - AL0995_i_WeaponKineticEnergy = 1; - if (L0996_T_Thing.getType() == k5_WeaponThingType) { - AL0994_i_Experience += 4; - L0998_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0996_T_Thing); - if (L0998_ps_WeaponInfo->_class <= k12_WeaponClassPoisinDart) { - AL0994_i_Experience += (AL0995_i_WeaponKineticEnergy = L0998_ps_WeaponInfo->_kineticEnergy) >> 2; - } - } - f304_addSkillExperience(champIndex, k10_ChampionSkillThrow, AL0994_i_Experience); - L0993_i_KineticEnergy += AL0995_i_WeaponKineticEnergy; - AL0995_i_SkillLevel = f303_getSkillLevel((ChampionIndex)champIndex, k10_ChampionSkillThrow); - L0993_i_KineticEnergy += _vm->_rnd->getRandomNumber(16) + (L0993_i_KineticEnergy >> 1) + AL0995_i_SkillLevel; - AL0994_i_Attack = f26_getBoundedValue((uint16)40, (uint16)((AL0995_i_SkillLevel << 3) + _vm->_rnd->getRandomNumber(31)), (uint16)200); - AL0995_i_StepEnergy = MAX(5, 11 - AL0995_i_SkillLevel); - _vm->_projexpl->f212_projectileCreate(L0996_T_Thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, + int16 experience = 8; + int16 weaponKineticEnergy = 1; + if (curThing.getType() == k5_WeaponThingType) { + experience += 4; + WeaponInfo *curWeapon = _vm->_dungeonMan->f158_getWeaponInfo(curThing); + if (curWeapon->_class <= k12_WeaponClassPoisinDart) { + weaponKineticEnergy = curWeapon->_kineticEnergy; + experience += weaponKineticEnergy >> 2; + } + } + f304_addSkillExperience(champIndex, k10_ChampionSkillThrow, experience); + kineticEnergy += weaponKineticEnergy; + int16 skillLevel = f303_getSkillLevel((ChampionIndex)champIndex, k10_ChampionSkillThrow); + kineticEnergy += _vm->_rnd->getRandomNumber(16) + (kineticEnergy >> 1) + skillLevel; + int16 attack = f26_getBoundedValue((uint16)40, (uint16)((skillLevel << 3) + _vm->_rnd->getRandomNumber(31)), (uint16)200); + int16 stepEnergy = MAX(5, 11 - skillLevel); + _vm->_projexpl->f212_projectileCreate(curThing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side), - _vm->_dungeonMan->_g308_partyDir, L0993_i_KineticEnergy, AL0994_i_Attack, AL0995_i_StepEnergy); + _vm->_dungeonMan->_g308_partyDir, kineticEnergy, attack, stepEnergy); _vm->_g311_projectileDisableMovementTicks = 4; _vm->_g312_lastProjectileDisabledMovementDirection = _vm->_dungeonMan->_g308_partyDir; f292_drawChampionState((ChampionIndex)champIndex); @@ -255,9 +248,8 @@ uint16 ChampionMan::M70_handSlotIndex(uint16 slotBoxIndex) { } Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) { - using namespace Common; - String valToStr = String::format("%d", val); - String result; + Common::String valToStr = Common::String::format("%d", val); + Common::String result; for (int16 i = 0, end = paddingCharCount - valToStr.size(); i < end; ++i) result += ' '; -- cgit v1.2.3 From 9d5b3f53c8fac7db5530f3c0a5a4ab0987859a2e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Jul 2016 19:07:39 +0200 Subject: DM: Fix a bug in f288_getStringFromInteger --- engines/dm/champion.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 8925187e4a..b44a808c19 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -250,8 +250,11 @@ uint16 ChampionMan::M70_handSlotIndex(uint16 slotBoxIndex) { Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) { Common::String valToStr = Common::String::format("%d", val); Common::String result; - for (int16 i = 0, end = paddingCharCount - valToStr.size(); i < end; ++i) - result += ' '; + + if (padding) { + for (int16 i = 0, end = paddingCharCount - valToStr.size(); i < end; ++i) + result += ' '; + } return result += valToStr; } -- cgit v1.2.3 From a46d815617606ee5bd3d468b679f04d33e2207b7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Jul 2016 19:39:47 +0200 Subject: DM: Refactor f299_applyModifiersToStatistics, remove a GOTO. --- engines/dm/champion.cpp | 225 +++++++++++++++++++++++++----------------------- 1 file changed, 118 insertions(+), 107 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b44a808c19..a7c6ce54ac 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -260,128 +260,140 @@ Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding, } void ChampionMan::f299_applyModifiersToStatistics(Champion* champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) { - int16 statIndex; + int16 statIndex = k0_ChampionStatLuck; int16 modifier = 0; ThingType thingType = thing.getType(); - if (((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType)) - && (slotIndex >= k0_ChampionSlotReadyHand) - && (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) { - Weapon *weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(thing); - Armour *armour = (Armour *)_vm->_dungeonMan->f156_getThingData(thing); - if (((thingType == k5_WeaponThingType) && weapon->getCursed()) - || ((thingType == k6_ArmourThingType) && armour->getCursed())) { + + bool cursed = false; + if ( ((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType)) + && (slotIndex >= k0_ChampionSlotReadyHand) && (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) { + if (thingType == k5_WeaponThingType) { + Weapon *weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(thing); + cursed = weapon->getCursed(); + } else { + // k6_ArmourThingType + Armour *armour = (Armour *)_vm->_dungeonMan->f156_getThingData(thing); + cursed = armour->getCursed(); + } + + if (cursed) { statIndex = k0_ChampionStatLuck; modifier = -3; - goto T0299044_ApplyModifier; } } - statIndex = (ChampionStatisticType)thingType; // variable sharing + if (!cursed) { + statIndex = (ChampionStatisticType)thingType; // variable sharing - if ((iconIndex == k137_IconIndiceJunkRabbitsFoot) && (slotIndex < k30_ChampionSlotChest_1)) { - statIndex = k0_ChampionStatLuck; - modifier = 10; - } else if (slotIndex == k1_ChampionSlotActionHand) { - - if (iconIndex == k45_IconIndiceWeaponMaceOfOrder) { - statIndex = k1_ChampionStatStrength; - modifier = 5; - } else { - - statIndex = k8_ChampionStatMana; - if ((iconIndex >= k20_IconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= k22_IconIndiceWeaponStaffOfClawsFull)) { - modifier = 4; - } else if ((iconIndex >= k58_IconIndiceWeaponStaff) && (iconIndex <= k66_IconIndiceWeaponSceptreOfLyf)) { - switch (iconIndex) { - case k58_IconIndiceWeaponStaff: - modifier = 2; - break; - case k59_IconIndiceWeaponWand: - modifier = 1; - break; - case k60_IconIndiceWeaponTeowand: - modifier = 6; - break; - case k61_IconIndiceWeaponYewStaff: - modifier = 4; - break; - case k62_IconIndiceWeaponStaffOfManarStaffOfIrra: - modifier = 10; - break; - case k63_IconIndiceWeaponSnakeStaffCrossOfNeta: - modifier = 8; - break; - case k64_IconIndiceWeaponTheConduitSerpentStaff: - modifier = 16; - break; - case k65_IconIndiceWeaponDragonSpit: - modifier = 7; - break; - case k66_IconIndiceWeaponSceptreOfLyf: - modifier = 5; - break; - } + if ((iconIndex == k137_IconIndiceJunkRabbitsFoot) && (slotIndex < k30_ChampionSlotChest_1)) { + statIndex = k0_ChampionStatLuck; + modifier = 10; + } else if (slotIndex == k1_ChampionSlotActionHand) { + if (iconIndex == k45_IconIndiceWeaponMaceOfOrder) { + statIndex = k1_ChampionStatStrength; + modifier = 5; } else { - switch (iconIndex) { - case k38_IconIndiceWeaponDeltaSideSplitter: - modifier = 1; - break; - case k41_IconIndiceWeaponTheInquisitorDragonFang: - modifier = 2; - break; - case k40_IconIndiceWeaponVorpalBlade: + statIndex = k8_ChampionStatMana; + if ((iconIndex >= k20_IconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= k22_IconIndiceWeaponStaffOfClawsFull)) { modifier = 4; - break; + } else { + switch (iconIndex) { + case k38_IconIndiceWeaponDeltaSideSplitter: + modifier = 1; + break; + case k41_IconIndiceWeaponTheInquisitorDragonFang: + modifier = 2; + break; + case k40_IconIndiceWeaponVorpalBlade: + modifier = 4; + break; + case k58_IconIndiceWeaponStaff: + modifier = 2; + break; + case k59_IconIndiceWeaponWand: + modifier = 1; + break; + case k60_IconIndiceWeaponTeowand: + modifier = 6; + break; + case k61_IconIndiceWeaponYewStaff: + modifier = 4; + break; + case k62_IconIndiceWeaponStaffOfManarStaffOfIrra: + modifier = 10; + break; + case k63_IconIndiceWeaponSnakeStaffCrossOfNeta: + modifier = 8; + break; + case k64_IconIndiceWeaponTheConduitSerpentStaff: + modifier = 16; + break; + case k65_IconIndiceWeaponDragonSpit: + modifier = 7; + break; + case k66_IconIndiceWeaponSceptreOfLyf: + modifier = 5; + break; + default: + break; + } } - } // end of else - - } - - } else if (slotIndex == k4_ChampionSlotLegs) { - - if (iconIndex == k142_IconIndiceArmourPowertowers) { - statIndex = k1_ChampionStatStrength; - modifier = 10; - } - - } else if (slotIndex == k2_ChampionSlotHead) { - - if (iconIndex == k104_IconIndiceArmourCrownOfNerra) { - statIndex = k3_ChampionStatWisdom; - modifier = 10; - } else if (iconIndex == k140_IconIndiceArmourDexhelm) { - statIndex = k2_ChampionStatDexterity; - modifier = 10; - } - - } else if (slotIndex == k3_ChampionSlotTorso) { - - if (iconIndex == k141_IconIndiceArmourFlamebain) { - statIndex = k6_ChampionStatAntifire; - modifier = 12; - } else if (iconIndex == k81_IconIndiceArmourCloakOfNight) { - statIndex = k2_ChampionStatDexterity; - modifier = 8; - } - - } else if (slotIndex == k10_ChampionSlotNeck) { - - if ((iconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (iconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) { - statIndex = k5_ChampionStatAntimagic; - modifier = 15; - } else if (iconIndex == k81_IconIndiceArmourCloakOfNight) { - statIndex = k2_ChampionStatDexterity; - modifier = 8; - } else if (iconIndex == k122_IconIndiceJunkMoonstone) { - statIndex = k8_ChampionStatMana; - modifier = 3; + } + } else if (slotIndex == k4_ChampionSlotLegs) { + if (iconIndex == k142_IconIndiceArmourPowertowers) { + statIndex = k1_ChampionStatStrength; + modifier = 10; + } + } else if (slotIndex == k2_ChampionSlotHead) { + switch (iconIndex) { + case k104_IconIndiceArmourCrownOfNerra: + statIndex = k3_ChampionStatWisdom; + modifier = 10; + break; + case k140_IconIndiceArmourDexhelm: + statIndex = k2_ChampionStatDexterity; + modifier = 10; + break; + default: + break; + } + } else if (slotIndex == k3_ChampionSlotTorso) { + switch (iconIndex) { + case k141_IconIndiceArmourFlamebain: + statIndex = k6_ChampionStatAntifire; + modifier = 12; + break; + case k81_IconIndiceArmourCloakOfNight: + statIndex = k2_ChampionStatDexterity; + modifier = 8; + break; + default: + break; + } + } else if (slotIndex == k10_ChampionSlotNeck) { + switch (iconIndex) { + case k10_IconIndiceJunkJewelSymalUnequipped: + case k11_IconIndiceJunkJewelSymalEquipped: + statIndex = k5_ChampionStatAntimagic; + modifier = 15; + break; + case k81_IconIndiceArmourCloakOfNight: + statIndex = k2_ChampionStatDexterity; + modifier = 8; + break; + case k122_IconIndiceJunkMoonstone: + statIndex = k8_ChampionStatMana; + modifier = 3; + break; + default: + break; + } } - } -T0299044_ApplyModifier: if (modifier) { modifier *= modifierFactor; + //statIndex is set when modifier is set if (statIndex == k8_ChampionStatMana) { champ->_maxMana += modifier; } else if (statIndex < k6_ChampionStatAntifire + 1) { @@ -390,7 +402,6 @@ T0299044_ApplyModifier: } } } - } bool ChampionMan::f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) { -- cgit v1.2.3 From 18ea37f5fb28df27826f10e3d0f003e593f661b0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 24 Jul 2016 19:21:45 +0200 Subject: DM: Some renaming in f298_getObjectRemovedFromLeaderHand, refactor f312_getStrength --- engines/dm/champion.cpp | 89 ++++++++++++++++++++----------------------------- 1 file changed, 37 insertions(+), 52 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index a7c6ce54ac..6b431265d3 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -259,7 +259,7 @@ Common::String ChampionMan::f288_getStringFromInteger(uint16 val, bool padding, return result += valToStr; } -void ChampionMan::f299_applyModifiersToStatistics(Champion* champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) { +void ChampionMan::f299_applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) { int16 statIndex = k0_ChampionStatLuck; int16 modifier = 0; ThingType thingType = thing.getType(); @@ -518,7 +518,6 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch uint16 *rawObjPtr = dunMan.f156_getThingData(thing); if (slotIndex < k2_ChampionSlotHead) { - if (slotIndex == k1_ChampionSlotActionHand) { champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true); if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)) @@ -538,9 +537,7 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch ((iconIndex == k144_IconIndiceContainerChestClosed) || ((iconIndex >= k30_IconIndiceScrollOpen) && (iconIndex <= k31_IconIndiceScrollClosed)))) { champ->setAttributeFlag(k0x0800_ChampionAttributePanel, true); } - } else if (slotIndex == k10_ChampionSlotNeck) { - if ((iconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (iconIndex <= k13_IconIndiceJunkIllumuletEquipped)) { ((Junk *)rawObjPtr)->setChargeCount(1); _g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2]; @@ -550,7 +547,6 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch ((Junk *)rawObjPtr)->setChargeCount(1); iconIndex = (IconIndice)(iconIndex + 1); } - } f291_drawSlot(champIndex, slotIndex); @@ -567,7 +563,7 @@ int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) { searchedScent.setMapY(mapY); searchedScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); uint16 searchedScentRedEagle = searchedScent.toUint16(); - Scent* scent = &_g407_party._scents[scentIndex--]; + Scent *scent = &_g407_party._scents[scentIndex--]; do { if ((*(--scent)).toUint16() == searchedScentRedEagle) { return _vm->M0_indexToOrdinal(scentIndex); @@ -578,11 +574,10 @@ int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) { } Thing ChampionMan::f298_getObjectRemovedFromLeaderHand() { - Thing L0890_T_LeaderHandObject; - - _g415_leaderEmptyHanded = true; - if ((L0890_T_LeaderHandObject = _g414_leaderHandObject) != Thing::_none) { + Thing leaderHandObject = _g414_leaderHandObject; + + if (leaderHandObject != Thing::_none) { _g414_leaderHandObject = Thing::_none; _g413_leaderHandObjectIconIndex = kM1_IconIndiceNone; _vm->_eventMan->f78_showMouse(); @@ -590,69 +585,59 @@ Thing ChampionMan::f298_getObjectRemovedFromLeaderHand() { _vm->_eventMan->f69_setMousePointer(); _vm->_eventMan->f77_hideMouse(); if (_g411_leaderIndex != kM1_ChampionNone) { - _gK71_champions[_g411_leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(L0890_T_LeaderHandObject); + _gK71_champions[_g411_leaderIndex]._load -= _vm->_dungeonMan->f140_getObjectWeight(leaderHandObject); setFlag(_gK71_champions[_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad); f292_drawChampionState(_g411_leaderIndex); } } - return L0890_T_LeaderHandObject; + return leaderHandObject; } uint16 ChampionMan::f312_getStrength(int16 champIndex, int16 slotIndex) { - int16 L0935_i_Strength; - uint16 L0936_ui_Multiple; -#define AL0936_ui_ObjectWeight L0936_ui_Multiple -#define AL0936_ui_SkillLevel L0936_ui_Multiple - uint16 L0937_ui_Multiple; -#define AL0937_ui_OneSixteenthMaximumLoad L0937_ui_Multiple -#define AL0937_ui_Class L0937_ui_Multiple - Thing L0938_T_Thing; - Champion* L0939_ps_Champion; - WeaponInfo* L0940_ps_WeaponInfo; - int16 L0941_i_LoadThreshold; - - - L0939_ps_Champion = &_gK71_champions[champIndex]; - L0935_i_Strength = _vm->_rnd->getRandomNumber(15) + L0939_ps_Champion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent]; - L0938_T_Thing = L0939_ps_Champion->_slots[slotIndex]; - if ((AL0936_ui_ObjectWeight = _vm->_dungeonMan->f140_getObjectWeight(L0938_T_Thing)) <= (AL0937_ui_OneSixteenthMaximumLoad = f309_getMaximumLoad(L0939_ps_Champion) >> 4)) { - L0935_i_Strength += AL0936_ui_ObjectWeight - 12; + Champion *curChampion = &_gK71_champions[champIndex]; + int16 strength = _vm->_rnd->getRandomNumber(15) + curChampion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent]; + Thing curThing = curChampion->_slots[slotIndex]; + uint16 objectWeight = _vm->_dungeonMan->f140_getObjectWeight(curThing); + uint16 oneSixteenthMaximumLoad = f309_getMaximumLoad(curChampion) >> 4; + + if (objectWeight <= oneSixteenthMaximumLoad) { + strength += objectWeight - 12; } else { - if (AL0936_ui_ObjectWeight <= (L0941_i_LoadThreshold = AL0937_ui_OneSixteenthMaximumLoad + ((AL0937_ui_OneSixteenthMaximumLoad - 12) >> 1))) { - L0935_i_Strength += (AL0936_ui_ObjectWeight - AL0937_ui_OneSixteenthMaximumLoad) >> 1; + int16 loadThreshold = oneSixteenthMaximumLoad + ((oneSixteenthMaximumLoad - 12) >> 1); + if (objectWeight <= loadThreshold) { + strength += (objectWeight - oneSixteenthMaximumLoad) >> 1; } else { - L0935_i_Strength -= (AL0936_ui_ObjectWeight - L0941_i_LoadThreshold) << 1; + strength -= (objectWeight - loadThreshold) << 1; } } - if (L0938_T_Thing.getType() == k5_WeaponThingType) { - L0940_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0938_T_Thing); - L0935_i_Strength += L0940_ps_WeaponInfo->_strength; - AL0936_ui_SkillLevel = 0; - AL0937_ui_Class = L0940_ps_WeaponInfo->_class; - if ((AL0937_ui_Class == k0_WeaponClassSwingWeapon) || (AL0937_ui_Class == k2_WeaponClassDaggerAndAxes)) { - AL0936_ui_SkillLevel = f303_getSkillLevel(champIndex, k4_ChampionSkillSwing); + if (curThing.getType() == k5_WeaponThingType) { + WeaponInfo *weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing); + strength += weaponInfo->_strength; + uint16 skillLevel = 0; + uint16 weaponClass = weaponInfo->_class; + if ((weaponClass == k0_WeaponClassSwingWeapon) || (weaponClass == k2_WeaponClassDaggerAndAxes)) { + skillLevel = f303_getSkillLevel(champIndex, k4_ChampionSkillSwing); } - if ((AL0937_ui_Class != k0_WeaponClassSwingWeapon) && (AL0937_ui_Class < k16_WeaponClassFirstBow)) { - AL0936_ui_SkillLevel += f303_getSkillLevel(champIndex, k10_ChampionSkillThrow); + if ((weaponClass != k0_WeaponClassSwingWeapon) && (weaponClass < k16_WeaponClassFirstBow)) { + skillLevel += f303_getSkillLevel(champIndex, k10_ChampionSkillThrow); } - if ((AL0937_ui_Class >= k16_WeaponClassFirstBow) && (AL0937_ui_Class < k112_WeaponClassFirstMagicWeapon)) { - AL0936_ui_SkillLevel += f303_getSkillLevel(champIndex, k11_ChampionSkillShoot); + if ((weaponClass >= k16_WeaponClassFirstBow) && (weaponClass < k112_WeaponClassFirstMagicWeapon)) { + skillLevel += f303_getSkillLevel(champIndex, k11_ChampionSkillShoot); } - L0935_i_Strength += AL0936_ui_SkillLevel << 1; + strength += skillLevel << 1; } - L0935_i_Strength = f306_getStaminaAdjustedValue(L0939_ps_Champion, L0935_i_Strength); - if (getFlag(L0939_ps_Champion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? k0x0001_ChampionWoundReadHand : k0x0002_ChampionWoundActionHand)) { - L0935_i_Strength >>= 1; + strength = f306_getStaminaAdjustedValue(curChampion, strength); + if (getFlag(curChampion->_wounds, (slotIndex == k0_ChampionSlotReadyHand) ? k0x0001_ChampionWoundReadHand : k0x0002_ChampionWoundActionHand)) { + strength >>= 1; } - MAX(1, 2); - return f26_getBoundedValue(0, L0935_i_Strength >> 1, 100); + return f26_getBoundedValue(0, strength >> 1, 100); } Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) { Thing L0894_T_Thing; int16 L0895_i_IconIndex; - Champion* L0896_ps_Champion; - Weapon* L0897_ps_Weapon; + Champion *L0896_ps_Champion; + Weapon *L0897_ps_Weapon; bool L0898_B_IsInventoryChampion; -- cgit v1.2.3 From 9d0541035bca7f1cf2ef420200f13cd6109e7f5e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 24 Jul 2016 19:56:07 +0200 Subject: DM: Rename f325_decrementStamina, refactor f300_getObjectRemovedFromSlot and f325_decrementStamina Also remove a couple of GOTOs in f321_addPendingDamageAndWounds_getDamage --- engines/dm/champion.cpp | 131 ++++++++++++++++++++++++------------------------ engines/dm/champion.h | 2 +- engines/dm/eventman.cpp | 2 +- engines/dm/group.cpp | 4 +- engines/dm/menus.cpp | 2 +- engines/dm/movesens.cpp | 2 +- 6 files changed, 72 insertions(+), 71 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 6b431265d3..181850f995 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -192,7 +192,7 @@ bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 } _vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); - f325_decrementStamine(champIndex, f305_getThrowingStaminaCost(curThing)); + f325_decrementStamina(champIndex, f305_getThrowingStaminaCost(curThing)); f330_disableAction(champIndex, 4); int16 experience = 8; int16 weaponKineticEnergy = 1; @@ -634,93 +634,93 @@ uint16 ChampionMan::f312_getStrength(int16 champIndex, int16 slotIndex) { } Thing ChampionMan::f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) { - Thing L0894_T_Thing; - int16 L0895_i_IconIndex; - Champion *L0896_ps_Champion; - Weapon *L0897_ps_Weapon; - bool L0898_B_IsInventoryChampion; - + Champion *curChampion = &_gK71_champions[champIndex]; + Thing curThing; - L0896_ps_Champion = &_gK71_champions[champIndex]; if (slotIndex >= k30_ChampionSlotChest_1) { - L0894_T_Thing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1]; + curThing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1]; _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1] = Thing::_none; } else { - L0894_T_Thing = L0896_ps_Champion->_slots[slotIndex]; - L0896_ps_Champion->_slots[slotIndex] = Thing::_none; + curThing = curChampion->_slots[slotIndex]; + curChampion->_slots[slotIndex] = Thing::_none; } - if (L0894_T_Thing == Thing::_none) { + + if (curThing == Thing::_none) return Thing::_none; - } - L0898_B_IsInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal); - L0895_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L0894_T_Thing); - f299_applyModifiersToStatistics(L0896_ps_Champion, slotIndex, L0895_i_IconIndex, -1, L0894_T_Thing); /* Remove objet modifiers */ - L0897_ps_Weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(L0894_T_Thing); + + bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal); + int16 curIconIndex = _vm->_objectMan->f33_getIconIndex(curThing); + // Remove object modifiers + f299_applyModifiersToStatistics(curChampion, slotIndex, curIconIndex, -1, curThing); + + Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(curThing); if (slotIndex == k10_ChampionSlotNeck) { - if ((L0895_i_IconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (L0895_i_IconIndex <= k13_IconIndiceJunkIllumuletEquipped)) { - ((Junk *)L0897_ps_Weapon)->setChargeCount(0); + if ((curIconIndex >= k12_IconIndiceJunkIllumuletUnequipped) && (curIconIndex <= k13_IconIndiceJunkIllumuletEquipped)) { + ((Junk *)curWeapon)->setChargeCount(0); _g407_party._magicalLightAmount -= g39_LightPowerToLightAmount[2]; _vm->_inventoryMan->f337_setDungeonViewPalette(); - } else { - if ((L0895_i_IconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (L0895_i_IconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) { - ((Junk *)L0897_ps_Weapon)->setChargeCount(0); - } + } else if ((curIconIndex >= k10_IconIndiceJunkJewelSymalUnequipped) && (curIconIndex <= k11_IconIndiceJunkJewelSymalEquipped)) { + ((Junk *)curWeapon)->setChargeCount(0); } } + f291_drawSlot(champIndex, slotIndex); - if (L0898_B_IsInventoryChampion) { - setFlag(L0896_ps_Champion->_attributes, k0x4000_ChampionAttributeViewport); - } + if (isInventoryChampion) + setFlag(curChampion->_attributes, k0x4000_ChampionAttributeViewport); + if (slotIndex < k2_ChampionSlotHead) { if (slotIndex == k1_ChampionSlotActionHand) { - setFlag(L0896_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand); - if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)) { + setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand); + if (_g506_actingChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)) _vm->_menuMan->f388_clearActingChampion(); - } - if ((L0895_i_IconIndex >= k30_IconIndiceScrollOpen) && (L0895_i_IconIndex <= k31_IconIndiceScrollClosed)) { - ((Scroll *)L0897_ps_Weapon)->setClosed(true); + + if ((curIconIndex >= k30_IconIndiceScrollOpen) && (curIconIndex <= k31_IconIndiceScrollClosed)) { + ((Scroll *)curWeapon)->setClosed(true); f296_drawChangedObjectIcons(); } } - if ((L0895_i_IconIndex >= k4_IconIndiceWeaponTorchUnlit) && (L0895_i_IconIndex <= k7_IconIndiceWeaponTorchLit)) { - L0897_ps_Weapon->setLit(false); + + if ((curIconIndex >= k4_IconIndiceWeaponTorchUnlit) && (curIconIndex <= k7_IconIndiceWeaponTorchLit)) { + curWeapon->setLit(false); _vm->_inventoryMan->f337_setDungeonViewPalette(); f296_drawChangedObjectIcons(); } - if (L0898_B_IsInventoryChampion && (slotIndex == k1_ChampionSlotActionHand)) { - if (L0895_i_IconIndex == k144_IconIndiceContainerChestClosed) { + + if (isInventoryChampion && (slotIndex == k1_ChampionSlotActionHand)) { + switch (curIconIndex) { + case k144_IconIndiceContainerChestClosed: _vm->_inventoryMan->f334_closeChest(); - goto T0300011; - } - if ((L0895_i_IconIndex >= k30_IconIndiceScrollOpen) && (L0895_i_IconIndex <= k31_IconIndiceScrollClosed)) { -T0300011: - setFlag(L0896_ps_Champion->_attributes, k0x0800_ChampionAttributePanel); + // No break on purpose + case k30_IconIndiceScrollOpen: + case k31_IconIndiceScrollClosed: + setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel); + break; + default: + break; } } } - L0896_ps_Champion->_load -= _vm->_dungeonMan->f140_getObjectWeight(L0894_T_Thing); - setFlag(L0896_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad); - return L0894_T_Thing; + curChampion->_load -= _vm->_dungeonMan->f140_getObjectWeight(curThing); + setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad); + return curThing; } -void ChampionMan::f325_decrementStamine(int16 championIndex, int16 decrement) { - int16 L0988_i_Stamina; - Champion* L0989_ps_Champion; +void ChampionMan::f325_decrementStamina(int16 championIndex, int16 decrement) { + if (championIndex == kM1_ChampionNone) + return; + Champion *curChampion = &_gK71_champions[championIndex]; + curChampion->_currStamina -= decrement; - if (championIndex == kM1_ChampionNone) { - return; + int16 stamina = curChampion->_currStamina; + if (stamina <= 0) { + curChampion->_currStamina = 0; + f321_addPendingDamageAndWounds_getDamage(championIndex, (-stamina) >> 1, k0x0000_ChampionWoundNone, k0_attackType_NORMAL); + } else if (stamina > curChampion->_maxStamina) { + curChampion->_currStamina = curChampion->_maxStamina; } - L0989_ps_Champion = &_gK71_champions[championIndex]; - if ((L0988_i_Stamina = (L0989_ps_Champion->_currStamina -= decrement)) <= 0) { - L0989_ps_Champion->_currStamina = 0; - f321_addPendingDamageAndWounds_getDamage(championIndex, (-L0988_i_Stamina) >> 1, k0x0000_ChampionWoundNone, k0_attackType_NORMAL); - } else { - if (L0988_i_Stamina > L0989_ps_Champion->_maxStamina) { - L0989_ps_Champion->_currStamina = L0989_ps_Champion->_maxStamina; - } - } - setFlag(L0989_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics); + + setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad | k0x0100_ChampionAttributeStatistics); } int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, uint16 attackType) { @@ -736,10 +736,9 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in return 0; L0979_ps_Champion = &_gK71_champions[champIndex]; - if (!L0979_ps_Champion->_currHealth) { -T0321004: + if (!L0979_ps_Champion->_currHealth) return 0; - } + if (attackType != k0_attackType_NORMAL) { for (L0978_ui_WoundCount = 0, AL0976_i_WoundIndex = k0_ChampionSlotReadyHand, L0977_ui_Defense = 0; AL0976_i_WoundIndex <= k5_ChampionSlotFeet; AL0976_i_WoundIndex++) { if (allowedWounds & (1 << AL0976_i_WoundIndex)) { @@ -774,7 +773,8 @@ T0321004: ; } if (attack <= 0) - goto T0321004; + return 0; + attack = _vm->f30_getScaledProduct(attack, 6, 130 - L0977_ui_Defense); /* BUG0_44 A champion may take much more damage than expected after a Black Flame attack or an impact with a Fireball projectile. If the party has a fire shield defense value higher than the fire attack value then the resulting intermediary @@ -782,7 +782,8 @@ T0321004: high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE and if attack is negative before calling F0030_MAIN_GetScaledProduct */ T0321024: if (attack <= 0) - goto T0321004; + return 0; + if (attack > (AL0976_i_AdjustedAttack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k4_ChampionStatVitality, _vm->_rnd->getRandomNumber(127) + 10))) { /* BUG0_45 This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the probability of being wounded. However if it was fixed, the behavior would be the opposite of what it should: the higher the vitality of a champion, the lower the result of F0307_CHAMPION_GetStatisticAdjustedAttack and the more likely the champion could get wounded (because of more iterations in the loop below) */ do { setFlag(*(uint16 *)&_g410_championPendingWounds[champIndex], (1 << _vm->_rnd->getRandomNumber(7)) & allowedWounds); @@ -1592,7 +1593,7 @@ void ChampionMan::f331_applyTimeEffects() { AL1007_ui_ManaGain = AL1007_ui_ManaGain << 1; } AL1007_ui_ManaGain++; - f325_decrementStamine(AL1006_ui_ChampionIndex, AL1007_ui_ManaGain * MAX(7, 16 - AL1008_ui_WizardSkillLevel)); + f325_decrementStamina(AL1006_ui_ChampionIndex, AL1007_ui_ManaGain * MAX(7, 16 - AL1008_ui_WizardSkillLevel)); L1010_ps_Champion->_currMana += MIN(AL1007_ui_ManaGain, (uint16)(L1010_ps_Champion->_maxMana - L1010_ps_Champion->_currMana)); } else { if (L1010_ps_Champion->_currMana > L1010_ps_Champion->_maxMana) { @@ -1645,7 +1646,7 @@ void ChampionMan::f331_applyTimeEffects() { L1010_ps_Champion->_water -= AL1008_ui_StaminaAboveHalf ? 1 : AL1007_ui_StaminaGainCycleCount >> 2; } } while (--AL1007_ui_StaminaGainCycleCount && ((L1010_ps_Champion->_currStamina - AL1009_i_StaminaLoss) < L1010_ps_Champion->_maxStamina)); - f325_decrementStamine(AL1006_ui_ChampionIndex, AL1009_i_StaminaLoss); + f325_decrementStamina(AL1006_ui_ChampionIndex, AL1009_i_StaminaLoss); if (L1010_ps_Champion->_food < -1024) { L1010_ps_Champion->_food = -1024; } diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 17d8831179..e2956c1364 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -552,7 +552,7 @@ public: Thing f298_getObjectRemovedFromLeaderHand(); // @ F0298_CHAMPION_GetObjectRemovedFromLeaderHand uint16 f312_getStrength(int16 champIndex, int16 slotIndex); // @ F0312_CHAMPION_GetStrength Thing f300_getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex); // @ F0300_CHAMPION_GetObjectRemovedFromSlot - void f325_decrementStamine(int16 championIndex, int16 decrement); // @ F0325_CHAMPION_DecrementStamina + void f325_decrementStamina(int16 championIndex, int16 decrement); // @ F0325_CHAMPION_DecrementStamina int16 f321_addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, uint16 attackType); // @ F0321_CHAMPION_AddPendingDamageAndWounds_GetDamage int16 f313_getWoundDefense(int16 champIndex, uint16 woundIndex); // @ F0313_CHAMPION_GetWoundDefense diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 946c1fb989..8851e28dcb 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -850,7 +850,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) { _vm->_g321_stopWaitingForPlayerInput = true; L1119_ps_Champion = _vm->_championMan->_gK71_champions; for (AL1118_ui_ChampionIndex = k0_ChampionFirst; AL1118_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL1118_ui_ChampionIndex++) { - _vm->_championMan->f325_decrementStamine(AL1118_ui_ChampionIndex, ((L1119_ps_Champion->_load * 3) / _vm->_championMan->f309_getMaximumLoad(L1119_ps_Champion)) + 1); /* BUG0_50 When a champion is brought back to life at a Vi Altar, his current stamina is lower than what it was before dying. Each time the party moves the current stamina of all champions is decreased, including for dead champions, by an amount that depends on the current load of the champion. For a dead champion the load before he died is used */ + _vm->_championMan->f325_decrementStamina(AL1118_ui_ChampionIndex, ((L1119_ps_Champion->_load * 3) / _vm->_championMan->f309_getMaximumLoad(L1119_ps_Champion)) + 1); /* BUG0_50 When a champion is brought back to life at a Vi Altar, his current stamina is lower than what it was before dying. Each time the party moves the current stamina of all champions is decreased, including for dead champions, by an amount that depends on the current load of the champion. For a dead champion the load before he died is used */ L1119_ps_Champion++; } AL1118_ui_MovementArrowIndex = cmdType - k3_CommandMoveForward; diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 05f4b5a654..2bb694816e 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -1907,13 +1907,13 @@ T0231009: } L0569_i_Outcome = f190_groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapY, L0565_i_Damage, true); _vm->_championMan->f304_addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * L0572_ps_CreatureInfo->M58_getExperience() >> 4) + 3); - _vm->_championMan->f325_decrementStamine(champIndex, _vm->getRandomNumber(4) + 4); + _vm->_championMan->f325_decrementStamina(champIndex, _vm->getRandomNumber(4) + 4); goto T0231016; } T0231015: L0565_i_Damage = 0; L0569_i_Outcome = k0_outcomeKilledNoCreaturesInGroup; - _vm->_championMan->f325_decrementStamine(champIndex, _vm->getRandomNumber(2) + 2); + _vm->_championMan->f325_decrementStamina(champIndex, _vm->getRandomNumber(2) + 2); T0231016: _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); if (L0569_i_Outcome != k2_outcomeKilledAllCreaturesInGroup) { diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index f2c372cf26..5a4c8742c7 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -1291,7 +1291,7 @@ T0407076: _vm->_championMan->f330_disableAction(champIndex, L1249_ui_ActionDisabledTicks); } if (L1253_i_ActionStamina) { - _vm->_championMan->f325_decrementStamine(champIndex, L1253_i_ActionStamina); + _vm->_championMan->f325_decrementStamina(champIndex, L1253_i_ActionStamina); } if (L1255_i_ActionExperienceGain) { _vm->_championMan->f304_addSkillExperience(champIndex, L1254_i_ActionSkillIndex, L1255_i_ActionExperienceGain); diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index d8337bc807..6e53b7e509 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -347,7 +347,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 if (_g402_useRopeToClimbDownPit) { for (AL0709_i_ChampionIndex = k0_ChampionFirst, L0711_ps_Champion = _vm->_championMan->_gK71_champions; AL0709_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL0709_i_ChampionIndex++, L0711_ps_Champion++) { if (L0711_ps_Champion->_currHealth) { - _vm->_championMan->f325_decrementStamine(AL0709_i_ChampionIndex, ((L0711_ps_Champion->_load * 25) / _vm->_championMan->f309_getMaximumLoad(L0711_ps_Champion)) + 1); + _vm->_championMan->f325_decrementStamina(AL0709_i_ChampionIndex, ((L0711_ps_Champion->_load * 25) / _vm->_championMan->f309_getMaximumLoad(L0711_ps_Champion)) + 1); } } } else { -- cgit v1.2.3 From 9b12ddd6a9c8e9666287914c216b2ae0fcd6c86d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 24 Jul 2016 21:18:10 +0200 Subject: DM: Some refactoring in f321_addPendingDamageAndWounds_getDamage --- engines/dm/champion.cpp | 87 +++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 181850f995..1aef47d315 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -724,81 +724,90 @@ void ChampionMan::f325_decrementStamina(int16 championIndex, int16 decrement) { } int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, uint16 attackType) { - int16 L0976_i_Multiple; -#define AL0976_i_WoundIndex L0976_i_Multiple -#define AL0976_i_WisdomFactor L0976_i_Multiple -#define AL0976_i_AdjustedAttack L0976_i_Multiple - uint16 L0977_ui_Defense; - uint16 L0978_ui_WoundCount; - Champion* L0979_ps_Champion; - if (attack <= 0) return 0; - L0979_ps_Champion = &_gK71_champions[champIndex]; - if (!L0979_ps_Champion->_currHealth) + Champion *curChampion = &_gK71_champions[champIndex]; + if (!curChampion->_currHealth) return 0; if (attackType != k0_attackType_NORMAL) { - for (L0978_ui_WoundCount = 0, AL0976_i_WoundIndex = k0_ChampionSlotReadyHand, L0977_ui_Defense = 0; AL0976_i_WoundIndex <= k5_ChampionSlotFeet; AL0976_i_WoundIndex++) { - if (allowedWounds & (1 << AL0976_i_WoundIndex)) { - L0978_ui_WoundCount++; - L0977_ui_Defense += f313_getWoundDefense(champIndex, AL0976_i_WoundIndex | ((attackType == k4_attackType_SHARP) ? k0x8000_maskUseSharpDefense : k0x0000_maskDoNotUseSharpDefense)); + uint16 defense = 0; + uint16 woundCount = 0; + for (int16 woundIndex = k0_ChampionSlotReadyHand; woundIndex <= k5_ChampionSlotFeet; woundIndex++) { + if (allowedWounds & (1 << woundIndex)) { + woundCount++; + defense += f313_getWoundDefense(champIndex, woundIndex | ((attackType == k4_attackType_SHARP) ? k0x8000_maskUseSharpDefense : k0x0000_maskDoNotUseSharpDefense)); } } - if (L0978_ui_WoundCount) { - L0977_ui_Defense /= L0978_ui_WoundCount; - } + if (woundCount) + defense /= woundCount; + switch (attackType) { - case k6_attackType_PSYCHIC: - if ((AL0976_i_WisdomFactor = 115 - L0979_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent]) <= 0) { - attack = 0; - } else { - attack = _vm->f30_getScaledProduct(attack, 6, AL0976_i_WisdomFactor); + case k6_attackType_PSYCHIC: + { + int16 wisdomFactor = 115 - curChampion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent]; + if (wisdomFactor <= 0) { + attack = 0; + } else { + attack = _vm->f30_getScaledProduct(attack, 6, wisdomFactor); + } } goto T0321024; case k5_attackType_MAGIC: - attack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k5_ChampionStatAntimagic, attack); + attack = f307_getStatisticAdjustedAttack(curChampion, k5_ChampionStatAntimagic, attack); attack -= _g407_party._spellShieldDefense; goto T0321024; case k1_attackType_FIRE: - attack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k6_ChampionStatAntifire, attack); + attack = f307_getStatisticAdjustedAttack(curChampion, k6_ChampionStatAntifire, attack); attack -= _g407_party._fireShieldDefense; break; case k2_attackType_SELF: - L0977_ui_Defense >>= 1; - case k3_attackType_BLUNT: - case k4_attackType_SHARP: - case k7_attackType_LIGHTNING: - ; + defense >>= 1; + break; + default: + break; } + if (attack <= 0) return 0; - attack = _vm->f30_getScaledProduct(attack, 6, 130 - L0977_ui_Defense); - /* BUG0_44 A champion may take much more damage than expected after a Black Flame attack or an impact - with a Fireball projectile. If the party has a fire shield defense value higher than the fire attack value then the resulting intermediary - attack value is negative and damage should be 0. However, the negative value is still used for further computations and the result may be a very - high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE and if attack is negative before calling F0030_MAIN_GetScaledProduct */ + attack = _vm->f30_getScaledProduct(attack, 6, 130 - defense); + /* BUG0_44 + A champion may take much more damage than expected after a Black Flame attack or an impact + with a Fireball projectile. If the party has a fire shield defense value higher than the fire + attack value then the resulting intermediary attack value is negative and damage should be 0. + However, the negative value is still used for further computations and the result may be a very + high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE + and if attack is negative before calling F0030_MAIN_GetScaledProduct + */ T0321024: if (attack <= 0) return 0; - if (attack > (AL0976_i_AdjustedAttack = f307_getStatisticAdjustedAttack(L0979_ps_Champion, k4_ChampionStatVitality, _vm->_rnd->getRandomNumber(127) + 10))) { /* BUG0_45 This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the probability of being wounded. However if it was fixed, the behavior would be the opposite of what it should: the higher the vitality of a champion, the lower the result of F0307_CHAMPION_GetStatisticAdjustedAttack and the more likely the champion could get wounded (because of more iterations in the loop below) */ + int16 adjustedAttack = f307_getStatisticAdjustedAttack(curChampion, k4_ChampionStatVitality, _vm->_rnd->getRandomNumber(127) + 10); + if (attack > adjustedAttack) { + /* BUG0_45 + This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the + probability of being wounded. However if it was fixed, the behavior would be the opposite + of what it should: the higher the vitality of a champion, the lower the result of + F0307_CHAMPION_GetStatisticAdjustedAttack and the more likely the champion could get + wounded (because of more iterations in the loop below) + */ do { setFlag(*(uint16 *)&_g410_championPendingWounds[champIndex], (1 << _vm->_rnd->getRandomNumber(7)) & allowedWounds); - } while ((attack > (AL0976_i_AdjustedAttack <<= 1)) && AL0976_i_AdjustedAttack); + } while ((attack > (adjustedAttack <<= 1)) && adjustedAttack); } - if (_g300_partyIsSleeping) { + + if (_g300_partyIsSleeping) f314_wakeUp(); - } } _g409_championPendingDamage[champIndex] += attack; return attack; } int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) { - static byte g50_woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor + static const byte g50_woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor int16 L0942_i_Multiple; #define AL0942_i_SlotIndex L0942_i_Multiple -- cgit v1.2.3 From eab5879ef57e2d6d614bb198c2dfbc7a7ca5582e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 24 Jul 2016 23:57:47 +0200 Subject: DM: Get rid of a GOTO in f321_addPendingDamageAndWounds_getDamage --- engines/dm/champion.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 1aef47d315..20e76c934a 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -731,6 +731,7 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in if (!curChampion->_currHealth) return 0; + bool skipScaling = false; if (attackType != k0_attackType_NORMAL) { uint16 defense = 0; uint16 woundCount = 0; @@ -752,12 +753,15 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in } else { attack = _vm->f30_getScaledProduct(attack, 6, wisdomFactor); } + + skipScaling = true; } - goto T0321024; + break; case k5_attackType_MAGIC: attack = f307_getStatisticAdjustedAttack(curChampion, k5_ChampionStatAntimagic, attack); attack -= _g407_party._spellShieldDefense; - goto T0321024; + skipScaling = true; + break; case k1_attackType_FIRE: attack = f307_getStatisticAdjustedAttack(curChampion, k6_ChampionStatAntifire, attack); attack -= _g407_party._fireShieldDefense; @@ -769,10 +773,12 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in break; } - if (attack <= 0) - return 0; + if (!skipScaling) { + if (attack <= 0) + return 0; - attack = _vm->f30_getScaledProduct(attack, 6, 130 - defense); + attack = _vm->f30_getScaledProduct(attack, 6, 130 - defense); + } /* BUG0_44 A champion may take much more damage than expected after a Black Flame attack or an impact with a Fireball projectile. If the party has a fire shield defense value higher than the fire @@ -781,7 +787,7 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE and if attack is negative before calling F0030_MAIN_GetScaledProduct */ -T0321024: + if (attack <= 0) return 0; -- cgit v1.2.3 From 76667176f432fac51ff4e72de4b22a04df28f0e0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2016 00:20:23 +0200 Subject: DM: Refactor f313_getWoundDefense --- engines/dm/champion.cpp | 70 +++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 20e76c934a..512acecb6b 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -813,48 +813,44 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in } int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) { - static const byte g50_woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor + static const byte woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor - int16 L0942_i_Multiple; -#define AL0942_i_SlotIndex L0942_i_Multiple -#define AL0942_i_WoundDefense L0942_i_Multiple - uint16 L0943_ui_ArmourShieldDefense; - bool L0944_B_UseSharpDefense; - Thing L0945_T_Thing; - Champion* L0946_ps_Champion; - ArmourInfo* L0947_ps_ArmourInfo; - - - L0946_ps_Champion = &_gK71_champions[champIndex]; - if (L0944_B_UseSharpDefense = getFlag(woundIndex, k0x8000_maskUseSharpDefense)) { + Champion *curChampion = &_gK71_champions[champIndex]; + bool useSharpDefense = getFlag(woundIndex, k0x8000_maskUseSharpDefense); + if (useSharpDefense) clearFlag(woundIndex, k0x8000_maskUseSharpDefense); - } - for (L0943_ui_ArmourShieldDefense = 0, AL0942_i_SlotIndex = k0_ChampionSlotReadyHand; AL0942_i_SlotIndex <= k1_ChampionSlotActionHand; AL0942_i_SlotIndex++) { - L0945_T_Thing = L0946_ps_Champion->_slots[AL0942_i_SlotIndex]; - if (L0945_T_Thing.getType() == k6_ArmourThingType) { - L0947_ps_ArmourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing); - L0947_ps_ArmourInfo = &g239_ArmourInfo[((Armour *)L0947_ps_ArmourInfo)->getType()]; - if (getFlag(L0947_ps_ArmourInfo->_attributes, k0x0080_ArmourAttributeIsAShield)) { - L0943_ui_ArmourShieldDefense += ((f312_getStrength(champIndex, AL0942_i_SlotIndex) + _vm->_dungeonMan->f143_getArmourDefense(L0947_ps_ArmourInfo, L0944_B_UseSharpDefense)) * g50_woundDefenseFactor[woundIndex]) >> ((AL0942_i_SlotIndex == woundIndex) ? 4 : 5); - } + + uint16 armorShieldDefense = 0; + for (int16 slotIndex = k0_ChampionSlotReadyHand; slotIndex <= k1_ChampionSlotActionHand; slotIndex++) { + Thing curThing = curChampion->_slots[slotIndex]; + if (curThing.getType() == k6_ArmourThingType) { + ArmourInfo *armorInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing); + armorInfo = &g239_ArmourInfo[((Armour *)armorInfo)->getType()]; + if (getFlag(armorInfo->_attributes, k0x0080_ArmourAttributeIsAShield)) + armorShieldDefense += ((f312_getStrength(champIndex, slotIndex) + _vm->_dungeonMan->f143_getArmourDefense(armorInfo, useSharpDefense)) * woundDefenseFactor[woundIndex]) >> ((slotIndex == woundIndex) ? 4 : 5); } } - AL0942_i_WoundDefense = _vm->getRandomNumber((L0946_ps_Champion->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] >> 3) + 1); - if (L0944_B_UseSharpDefense) { - AL0942_i_WoundDefense >>= 1; - } - AL0942_i_WoundDefense += L0946_ps_Champion->_actionDefense + L0946_ps_Champion->_shieldDefense + _g407_party._shieldDefense + L0943_ui_ArmourShieldDefense; - if ((woundIndex > k1_ChampionSlotActionHand) && ((L0945_T_Thing = L0946_ps_Champion->_slots[woundIndex]).getType() == k6_ArmourThingType)) { - L0947_ps_ArmourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(L0945_T_Thing); - AL0942_i_WoundDefense += _vm->_dungeonMan->f143_getArmourDefense(&g239_ArmourInfo[((Armour *)L0947_ps_ArmourInfo)->getType()], L0944_B_UseSharpDefense); - } - if (getFlag(L0946_ps_Champion->_wounds, 1 << woundIndex)) { - AL0942_i_WoundDefense -= 8 + _vm->getRandomNumber(4); - } - if (_g300_partyIsSleeping) { - AL0942_i_WoundDefense >>= 1; + + int16 woundDefense = _vm->getRandomNumber((curChampion->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] >> 3) + 1); + if (useSharpDefense) + woundDefense >>= 1; + + woundDefense += curChampion->_actionDefense + curChampion->_shieldDefense + _g407_party._shieldDefense + armorShieldDefense; + if (woundIndex > k1_ChampionSlotActionHand) { + Thing curThing = curChampion->_slots[woundIndex]; + if (curThing.getType() == k6_ArmourThingType) { + ArmourInfo *armourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing); + woundDefense += _vm->_dungeonMan->f143_getArmourDefense(&g239_ArmourInfo[((Armour *)armourInfo)->getType()], useSharpDefense); + } } - return f26_getBoundedValue(0, AL0942_i_WoundDefense >> 1, 100); + + if (getFlag(curChampion->_wounds, 1 << woundIndex)) + woundDefense -= 8 + _vm->getRandomNumber(4); + + if (_g300_partyIsSleeping) + woundDefense >>= 1; + + return f26_getBoundedValue(0, woundDefense >> 1, 100); } uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion* champ, uint16 statIndex, uint16 attack) { -- cgit v1.2.3 From 710464c5d23f9ef51f0a932ef6c61c1594cbb2c7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2016 00:37:44 +0200 Subject: DM: Refactor f307_getStatisticAdjustedAttack, f305_getThrowingStaminaCost and f330_disableAction --- engines/dm/champion.cpp | 72 +++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 512acecb6b..297605a282 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -853,13 +853,20 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) { return f26_getBoundedValue(0, woundDefense >> 1, 100); } -uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion* champ, uint16 statIndex, uint16 attack) { - int16 L0927_i_Factor; - - if ((L0927_i_Factor = 170 - champ->_statistics[statIndex][k1_ChampionStatCurrent]) < 16) { /* BUG0_41 The Antifire and Antimagic statistics are completely ignored. The Vitality statistic is ignored against poison and to determine the probability of being wounded. Vitality is still used normally to compute the defense against wounds and the speed of health regeneration. A bug in the Megamax C compiler produces wrong machine code for this statement. It always returns 0 for the current statistic value so that L0927_i_Factor = 170 in all cases */ +uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack) { + int16 factor = 170 - champ->_statistics[statIndex][k1_ChampionStatCurrent]; + + /* BUG0_41 + The Antifire and Antimagic statistics are completely ignored. The Vitality statistic is ignored + against poison and to determine the probability of being wounded. Vitality is still used normally + to compute the defense against wounds and the speed of health regeneration. A bug in the Megamax C + compiler produces wrong machine code for this statement. It always returns 0 for the current statistic + value so that factor = 170 in all cases + */ + if (factor < 16) return attack >> 3; - } - return _vm->f30_getScaledProduct(attack, 7, L0927_i_Factor); + + return _vm->f30_getScaledProduct(attack, 7, factor); } void ChampionMan::f314_wakeUp() { @@ -877,44 +884,39 @@ void ChampionMan::f314_wakeUp() { } int16 ChampionMan::f305_getThrowingStaminaCost(Thing thing) { - int16 L0923_i_Weight; - int16 L0924_i_StaminaCost; + int16 weight = _vm->_dungeonMan->f140_getObjectWeight(thing) >> 1; + int16 staminaCost = f26_getBoundedValue(1, weight, 10); + while ((weight -= 10) > 0) + staminaCost += weight >> 1; - L0924_i_StaminaCost = f26_getBoundedValue((int16)1, L0923_i_Weight = _vm->_dungeonMan->f140_getObjectWeight(thing) >> 1, (int16)10); - while ((L0923_i_Weight -= 10) > 0) { - L0924_i_StaminaCost += L0923_i_Weight >> 1; - } - return L0924_i_StaminaCost; + return staminaCost; } void ChampionMan::f330_disableAction(uint16 champIndex, uint16 ticks) { - int32 L1001_l_UpdatedEnableActionEventTime; - int32 L1002_l_CurrentEnableActionEventTime; - int16 L1003_i_EventIndex; - Champion* L1004_ps_Champion; - TimelineEvent L1005_s_Event; - - - L1004_ps_Champion = &_gK71_champions[champIndex]; - L1001_l_UpdatedEnableActionEventTime = _vm->_g313_gameTime + ticks; - L1005_s_Event._type = k11_TMEventTypeEnableChampionAction; - L1005_s_Event._priority = champIndex; - L1005_s_Event._B._slotOrdinal = 0; - if ((L1003_i_EventIndex = L1004_ps_Champion->_enableActionEventIndex) >= 0) { - L1002_l_CurrentEnableActionEventTime = M30_time(_vm->_timeline->_g370_events[L1003_i_EventIndex]._mapTime); - if (L1001_l_UpdatedEnableActionEventTime >= L1002_l_CurrentEnableActionEventTime) { - L1001_l_UpdatedEnableActionEventTime += (L1002_l_CurrentEnableActionEventTime - _vm->_g313_gameTime) >> 1; + Champion *curChampion = &_gK71_champions[champIndex]; + int32 updatedEnableActionEventTime = _vm->_g313_gameTime + ticks; + + TimelineEvent curEvent; + curEvent._type = k11_TMEventTypeEnableChampionAction; + curEvent._priority = champIndex; + curEvent._B._slotOrdinal = 0; + + int16 eventIndex = curChampion->_enableActionEventIndex; + if (eventIndex >= 0) { + int32 currentEnableActionEventTime = M30_time(_vm->_timeline->_g370_events[eventIndex]._mapTime); + if (updatedEnableActionEventTime >= currentEnableActionEventTime) { + updatedEnableActionEventTime += (currentEnableActionEventTime - _vm->_g313_gameTime) >> 1; } else { - L1001_l_UpdatedEnableActionEventTime = L1002_l_CurrentEnableActionEventTime + (ticks >> 1); + updatedEnableActionEventTime = currentEnableActionEventTime + (ticks >> 1); } - _vm->_timeline->f237_deleteEvent(L1003_i_EventIndex); + _vm->_timeline->f237_deleteEvent(eventIndex); } else { - setFlag(L1004_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x0008_ChampionAttributeDisableAction); + setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x0008_ChampionAttributeDisableAction); f292_drawChampionState((ChampionIndex)champIndex); } - M33_setMapAndTime(L1005_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, L1001_l_UpdatedEnableActionEventTime); - L1004_ps_Champion->_enableActionEventIndex = _vm->_timeline->f238_addEventGetEventIndex(&L1005_s_Event); + M33_setMapAndTime(curEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, updatedEnableActionEventTime); + curChampion->_enableActionEventIndex = _vm->_timeline->f238_addEventGetEventIndex(&curEvent); } void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) { @@ -933,7 +935,7 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, int16 L0922_i_BaseSkillLevel; - warning(false, "potaneitally dangerous cast of uint32 below"); + warning(false, "Potentially dangerous cast of uint32 below"); if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && ((uint32)_vm->_projexpl->_g361_lastCreatureAttackTime < (_vm->_g313_gameTime - 150))) { exp >>= 1; } -- cgit v1.2.3 From 831eca5c42b375870b1d6063a43c7f9cbf7df3ce Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2016 08:43:19 +0200 Subject: DM: Refactor f304_addSkillExperience, change _g313_gameTime to int32 --- engines/dm/champion.cpp | 161 +++++++++++++++++++++++------------------------- engines/dm/dm.cpp | 2 +- engines/dm/dm.h | 2 +- engines/dm/group.cpp | 7 +-- engines/dm/loadsave.cpp | 4 +- 5 files changed, 84 insertions(+), 92 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 297605a282..6c3b33142a 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -920,104 +920,97 @@ void ChampionMan::f330_disableAction(uint16 champIndex, uint16 ticks) { } void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) { -#define AP0638_ui_SkillLevelAfter exp -#define AP0638_ui_ChampionColor exp - uint16 L0915_ui_Multiple; -#define AL0915_ui_MapDifficulty L0915_ui_Multiple -#define AL0915_ui_SkillLevelBefore L0915_ui_Multiple -#define AL0915_ui_VitalityAmount L0915_ui_Multiple -#define AL0915_ui_StaminaAmount L0915_ui_Multiple - uint16 L0916_ui_BaseSkillIndex; - Skill* L0918_ps_Skill; - Champion* L0919_ps_Champion; - int16 L0920_i_MinorStatisticIncrease; - int16 L0921_i_MajorStatisticIncrease; - int16 L0922_i_BaseSkillLevel; - - - warning(false, "Potentially dangerous cast of uint32 below"); - if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && ((uint32)_vm->_projexpl->_g361_lastCreatureAttackTime < (_vm->_g313_gameTime - 150))) { + if ((skillIndex >= k4_ChampionSkillSwing) && (skillIndex <= k11_ChampionSkillShoot) && (_vm->_projexpl->_g361_lastCreatureAttackTime < _vm->_g313_gameTime - 150)) exp >>= 1; - } + if (exp) { - if (AL0915_ui_MapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty) { - exp *= AL0915_ui_MapDifficulty; - } - L0919_ps_Champion = &_gK71_champions[champIndex]; - if (skillIndex >= k4_ChampionSkillSwing) { - L0916_ui_BaseSkillIndex = (skillIndex - k4_ChampionSkillSwing) >> 2; - } else { - L0916_ui_BaseSkillIndex = skillIndex; - } - AL0915_ui_SkillLevelBefore = f303_getSkillLevel(champIndex, L0916_ui_BaseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience)); - warning(false, "potentially dangerous cast of uint32 below"); - if ((skillIndex >= k4_ChampionSkillSwing) && ((uint32)_vm->_projexpl->_g361_lastCreatureAttackTime > (_vm->_g313_gameTime - 25))) { + if (_vm->_dungeonMan->_g269_currMap->_difficulty) + exp *= _vm->_dungeonMan->_g269_currMap->_difficulty; + + Champion *curChampion = &_gK71_champions[champIndex]; + uint16 baseSkillIndex; + if (skillIndex >= k4_ChampionSkillSwing) + baseSkillIndex = (skillIndex - k4_ChampionSkillSwing) >> 2; + else + baseSkillIndex = skillIndex; + + uint16 skillLevelBefore = f303_getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience)); + + if ((skillIndex >= k4_ChampionSkillSwing) && (_vm->_projexpl->_g361_lastCreatureAttackTime > _vm->_g313_gameTime - 25)) exp <<= 1; - } - L0918_ps_Skill = &L0919_ps_Champion->_skills[skillIndex]; - L0918_ps_Skill->_experience += exp; - if (L0918_ps_Skill->_temporaryExperience < 32000) { - L0918_ps_Skill->_temporaryExperience += f26_getBoundedValue(1, exp >> 3, 100); - } - L0918_ps_Skill = &L0919_ps_Champion->_skills[L0916_ui_BaseSkillIndex]; - if (skillIndex >= k4_ChampionSkillSwing) { - L0918_ps_Skill->_experience += exp; - } - AP0638_ui_SkillLevelAfter = f303_getSkillLevel(champIndex, L0916_ui_BaseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience)); - if (AP0638_ui_SkillLevelAfter > AL0915_ui_SkillLevelBefore) { - L0922_i_BaseSkillLevel = AP0638_ui_SkillLevelAfter; - L0920_i_MinorStatisticIncrease = _vm->getRandomNumber(2); - L0921_i_MajorStatisticIncrease = 1 + _vm->getRandomNumber(2); - AL0915_ui_VitalityAmount = _vm->getRandomNumber(2); /* For Priest skill, the amount is 0 or 1 for all skill levels */ - if (L0916_ui_BaseSkillIndex != k2_ChampionSkillPriest) { - AL0915_ui_VitalityAmount &= AP0638_ui_SkillLevelAfter; /* For non Priest skills the amount is 0 for even skill levels. The amount is 0 or 1 for odd skill levels */ + + Skill *curSkill = &curChampion->_skills[skillIndex]; + curSkill->_experience += exp; + if (curSkill->_temporaryExperience < 32000) + curSkill->_temporaryExperience += f26_getBoundedValue(1, exp >> 3, 100); + + curSkill = &curChampion->_skills[baseSkillIndex]; + if (skillIndex >= k4_ChampionSkillSwing) + curSkill->_experience += exp; + + uint16 skillLevelAfter = f303_getSkillLevel(champIndex, baseSkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience)); + if (skillLevelAfter > skillLevelBefore) { + int16 newBaseSkillLevel = skillLevelAfter; + int16 minorStatIncrease = _vm->getRandomNumber(2); + int16 majorStatIncrease = 1 + _vm->getRandomNumber(2); + uint16 vitalityAmount = _vm->getRandomNumber(2); /* For Priest skill, the amount is 0 or 1 for all skill levels */ + if (baseSkillIndex != k2_ChampionSkillPriest) { + vitalityAmount &= skillLevelAfter; /* For non Priest skills the amount is 0 for even skill levels. The amount is 0 or 1 for odd skill levels */ } - L0919_ps_Champion->_statistics[k4_ChampionStatVitality][k0_ChampionStatMaximum] += AL0915_ui_VitalityAmount; - AL0915_ui_StaminaAmount = L0919_ps_Champion->_maxStamina; - L0919_ps_Champion->_statistics[k6_ChampionStatAntifire][k0_ChampionStatMaximum] += _vm->getRandomNumber(2) & ~AP0638_ui_SkillLevelAfter; /* The amount is 0 for odd skill levels. The amount is 0 or 1 for even skill levels */ - switch (L0916_ui_BaseSkillIndex) { + curChampion->_statistics[k4_ChampionStatVitality][k0_ChampionStatMaximum] += vitalityAmount; + uint16 staminaAmount = curChampion->_maxStamina; + curChampion->_statistics[k6_ChampionStatAntifire][k0_ChampionStatMaximum] += _vm->getRandomNumber(2) & ~skillLevelAfter; /* The amount is 0 for odd skill levels. The amount is 0 or 1 for even skill levels */ + bool increaseManaFl = false; + switch (baseSkillIndex) { case k0_ChampionSkillFighter: - AL0915_ui_StaminaAmount >>= 4; - AP0638_ui_SkillLevelAfter *= 3; - L0919_ps_Champion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += L0921_i_MajorStatisticIncrease; - L0919_ps_Champion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += L0920_i_MinorStatisticIncrease; + staminaAmount >>= 4; + skillLevelAfter *= 3; + curChampion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += majorStatIncrease; + curChampion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += minorStatIncrease; break; case k1_ChampionSkillNinja: - AL0915_ui_StaminaAmount /= 21; - AP0638_ui_SkillLevelAfter <<= 1; - L0919_ps_Champion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += L0920_i_MinorStatisticIncrease; - L0919_ps_Champion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += L0921_i_MajorStatisticIncrease; + staminaAmount /= 21; + skillLevelAfter <<= 1; + curChampion->_statistics[k1_ChampionStatStrength][k0_ChampionStatMaximum] += minorStatIncrease; + curChampion->_statistics[k2_ChampionStatDexterity][k0_ChampionStatMaximum] += majorStatIncrease; break; case k3_ChampionSkillWizard: - AL0915_ui_StaminaAmount >>= 5; - L0919_ps_Champion->_maxMana += AP0638_ui_SkillLevelAfter + (AP0638_ui_SkillLevelAfter >> 1); - L0919_ps_Champion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += L0921_i_MajorStatisticIncrease; - goto T0304016; + staminaAmount >>= 5; + curChampion->_maxMana += skillLevelAfter + (skillLevelAfter >> 1); + curChampion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += majorStatIncrease; + increaseManaFl = true; + break; case k2_ChampionSkillPriest: - AL0915_ui_StaminaAmount /= 25; - L0919_ps_Champion->_maxMana += AP0638_ui_SkillLevelAfter; - AP0638_ui_SkillLevelAfter += (AP0638_ui_SkillLevelAfter + 1) >> 1; - L0919_ps_Champion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += L0920_i_MinorStatisticIncrease; -T0304016: - if ((L0919_ps_Champion->_maxMana += MIN(_vm->getRandomNumber(4), (uint16)(L0922_i_BaseSkillLevel - 1))) > 900) { - L0919_ps_Champion->_maxMana = 900; - } - L0919_ps_Champion->_statistics[k5_ChampionStatAntimagic][k0_ChampionStatMaximum] += _vm->getRandomNumber(3); - } - if ((L0919_ps_Champion->_maxHealth += AP0638_ui_SkillLevelAfter + _vm->getRandomNumber((AP0638_ui_SkillLevelAfter >> 1) + 1)) > 999) { - L0919_ps_Champion->_maxHealth = 999; + staminaAmount /= 25; + curChampion->_maxMana += skillLevelAfter; + skillLevelAfter += (skillLevelAfter + 1) >> 1; + curChampion->_statistics[k3_ChampionStatWisdom][k0_ChampionStatMaximum] += minorStatIncrease; + increaseManaFl = true; + break; + default: + break; } - if ((L0919_ps_Champion->_maxStamina += AL0915_ui_StaminaAmount + _vm->getRandomNumber((AL0915_ui_StaminaAmount >> 1) + 1)) > 9999) { - L0919_ps_Champion->_maxStamina = 9999; + if (increaseManaFl) { + if ((curChampion->_maxMana += MIN(_vm->getRandomNumber(4), (uint16)(newBaseSkillLevel - 1))) > 900) + curChampion->_maxMana = 900; + curChampion->_statistics[k5_ChampionStatAntimagic][k0_ChampionStatMaximum] += _vm->getRandomNumber(3); } - setFlag(L0919_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); + + if ((curChampion->_maxHealth += skillLevelAfter + _vm->getRandomNumber((skillLevelAfter >> 1) + 1)) > 999) + curChampion->_maxHealth = 999; + + if ((curChampion->_maxStamina += staminaAmount + _vm->getRandomNumber((staminaAmount >> 1) + 1)) > 9999) + curChampion->_maxStamina = 9999; + + setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics); f292_drawChampionState((ChampionIndex)champIndex); _vm->_textMan->f51_messageAreaPrintLineFeed(); - _vm->_textMan->f47_messageAreaPrintMessage((Color)(AP0638_ui_ChampionColor = g46_ChampionColor[champIndex]), L0919_ps_Champion->_name); + Color curChampionColor = g46_ChampionColor[champIndex]; + _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, curChampion->_name); // TODO: localization - _vm->_textMan->f47_messageAreaPrintMessage((Color)AP0638_ui_ChampionColor, " JUST GAINED A "); - _vm->_textMan->f47_messageAreaPrintMessage((Color)AP0638_ui_ChampionColor, g417_baseSkillName[L0916_ui_BaseSkillIndex]); - _vm->_textMan->f47_messageAreaPrintMessage((Color)AP0638_ui_ChampionColor, " LEVEL!"); + _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " JUST GAINED A "); + _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, g417_baseSkillName[baseSkillIndex]); + _vm->_textMan->f47_messageAreaPrintMessage(curChampionColor, " LEVEL!"); } } } @@ -1689,7 +1682,7 @@ void ChampionMan::f331_applyTimeEffects() { } } } - if (!_vm->_championMan->_g300_partyIsSleeping && (L1010_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < (int32)_vm->_g313_gameTime)) { + if (!_vm->_championMan->_g300_partyIsSleeping && (L1010_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_g313_gameTime)) { L1010_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir; L1010_ps_Champion->_maximumDamageReceived = 0; setFlag(L1010_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon); diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 92cb402a3a..55a2b6e055 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -380,7 +380,7 @@ T0002002: _menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived(); - if (!((int32)_g313_gameTime & (_championMan->_g300_partyIsSleeping ? 15 : 63))) { + if (!(_g313_gameTime & (_championMan->_g300_partyIsSleeping ? 15 : 63))) { _championMan->f331_applyTimeEffects(); } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 128dfaf8e4..1b1f8a7af2 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -266,7 +266,7 @@ public: int8 _dirIntoStepCountEast[4]; // @ G0233_ai_Graphic559_DirectionToStepEastCount int8 _dirIntoStepCountNorth[4]; // @ G0234_ai_Graphic559_DirectionToStepNorthCount - uint32 _g313_gameTime; // @ G0313_ul_GameTime + int32 _g313_gameTime; // @ G0313_ul_GameTime char _g353_stringBuildBuffer[128]; // @ G0353_ac_StringBuildBuffer int16 _g318_waitForInputMaxVerticalBlankCount; // @ G0318_i_WaitForInputMaximumVerticalBlankCount }; diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 2bb694816e..235bfe40b6 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -1316,12 +1316,11 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 creatureIndex, bool twoHalfSquareSizedCreatures) { uint16 L0435_ui_GroupDirections; - static long G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; /* These two variables are used to prevent setting direction of half square sized creatures twice at the same game time */ + static int32 G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime; /* These two variables are used to prevent setting direction of half square sized creatures twice at the same game time */ static ActiveGroup *G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup; - - warning(false, "potentially dangerous cast to uint32 below"); - if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == (uint32)G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) { + warning(false, "TODO: Move G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime to GroupMan so it's properly initialized"); + if (twoHalfSquareSizedCreatures && (_vm->_g313_gameTime == G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime) && (activeGroup == G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup)) { return; } if (M21_normalizeModulo4(_vm->_groupMan->M50_getCreatureValue(L0435_ui_GroupDirections = activeGroup->_directions, creatureIndex) - dir) == 2) { /* If current and new direction are opposites then change direction only one step at a time */ diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 9b50351376..19df8bf80f 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -76,7 +76,7 @@ T0435002: warning(false, "MISSING CODE: missing check for matching format and platform in save in f435_loadgame"); - _g313_gameTime = file->readUint32BE(); + _g313_gameTime = file->readSint32BE(); // G0349_ul_LastRandomNumber = L1371_s_GlobalData.LastRandomNumber; _championMan->_g305_partyChampionCount = file->readUint16BE(); _dungeonMan->_g306_partyMapX = file->readSint16BE(); @@ -165,7 +165,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String writeSaveGameHeader(file, desc); // write C0_SAVE_PART_GLOBAL_DATA part - file->writeUint32BE(_g313_gameTime); + file->writeSint32BE(_g313_gameTime); //L1348_s_GlobalData.LastRandomNumber = G0349_ul_LastRandomNumber; file->writeUint16BE(_championMan->_g305_partyChampionCount); file->writeSint16BE(_dungeonMan->_g306_partyMapX); -- cgit v1.2.3 From d5d41f455935af876815d003f5aa3684ccd50df1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2016 09:01:01 +0200 Subject: DM: Refactor f324_damageAll_getDamagedChampionCount, f286_getTargetChampionIndex, f311_getDexterity and f308_isLucky --- engines/dm/champion.cpp | 58 ++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 6c3b33142a..6bc4e707d7 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1016,52 +1016,50 @@ void ChampionMan::f304_addSkillExperience(uint16 champIndex, uint16 skillIndex, } int16 ChampionMan::f324_damageAll_getDamagedChampionCount(uint16 attack, int16 wounds, int16 attackType) { - int16 L0984_i_ChampionIndex; - int16 L0985_i_RandomAttack; - int16 L0986_i_DamagedChampionCount; + int16 randomMax = (attack >> 3) + 1; + uint16 reducedAttack = attack - randomMax; + randomMax <<= 1; - attack -= (L0985_i_RandomAttack = (attack >> 3) + 1); - L0985_i_RandomAttack <<= 1; - for (L0986_i_DamagedChampionCount = 0, L0984_i_ChampionIndex = k0_ChampionFirst; L0984_i_ChampionIndex < _g305_partyChampionCount; L0984_i_ChampionIndex++) { - if (f321_addPendingDamageAndWounds_getDamage(L0984_i_ChampionIndex, MAX(1, attack + _vm->getRandomNumber(L0985_i_RandomAttack)), wounds, attackType)) { /* Actual attack is attack +/- (attack / 8) */ - L0986_i_DamagedChampionCount++; - } + int16 damagedChampionCount = 0; + for (int16 championIndex = k0_ChampionFirst; championIndex < _g305_partyChampionCount; championIndex++) { + // Actual attack is attack +/- (attack / 8) + if (f321_addPendingDamageAndWounds_getDamage(championIndex, MAX(1, reducedAttack + _vm->getRandomNumber(randomMax)), wounds, attackType)) + damagedChampionCount++; } - return L0986_i_DamagedChampionCount; + + return damagedChampionCount; } int16 ChampionMan::f286_getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell) { if (_g305_partyChampionCount && (M38_distance(mapX, mapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY) <= 1)) { - signed char L0840_auc_OrderedCellsToAttack[4]; - _vm->_groupMan->f229_setOrderedCellsToAttack(L0840_auc_OrderedCellsToAttack, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, mapX, mapY, cell); - for (uint16 L0838_ui_Counter = 0; L0838_ui_Counter < 4; L0838_ui_Counter++) { - int16 L0839_i_ChampionIndex = f285_getIndexInCell(L0840_auc_OrderedCellsToAttack[L0838_ui_Counter]); - if (L0839_i_ChampionIndex >= 0) - return L0839_i_ChampionIndex; + signed char orderedCellsToAttack[4]; + _vm->_groupMan->f229_setOrderedCellsToAttack(orderedCellsToAttack, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, mapX, mapY, cell); + for (uint16 i = 0; i < 4; i++) { + int16 championIndex = f285_getIndexInCell(orderedCellsToAttack[i]); + if (championIndex >= 0) + return championIndex; } } return kM1_ChampionNone; } int16 ChampionMan::f311_getDexterity(Champion* champ) { - int16 L0934_i_Dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent]; - L0934_i_Dexterity -= ((int32)(L0934_i_Dexterity >> 1) * (int32)champ->_load) / f309_getMaximumLoad(champ); - if (_g300_partyIsSleeping) { - L0934_i_Dexterity >>= 1; - } - return f26_getBoundedValue(1 + _vm->getRandomNumber(8), L0934_i_Dexterity >> 1, 100 - _vm->getRandomNumber(8)); + int16 dexterity = _vm->getRandomNumber(8) + champ->_statistics[k2_ChampionStatDexterity][k1_ChampionStatCurrent]; + dexterity -= ((int32)(dexterity >> 1) * (int32)champ->_load) / f309_getMaximumLoad(champ); + if (_g300_partyIsSleeping) + dexterity >>= 1; + + return f26_getBoundedValue(1 + _vm->getRandomNumber(8), dexterity >> 1, 100 - _vm->getRandomNumber(8)); } bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) { -#define AP0646_ui_IsLucky percentage - - if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage)) { + if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage)) return true; - } - unsigned char* L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck]; - AP0646_ui_IsLucky = (_vm->getRandomNumber(L0928_puc_Statistic[k1_ChampionStatCurrent]) > percentage); - L0928_puc_Statistic[k1_ChampionStatCurrent] = f26_getBoundedValue((int32)L0928_puc_Statistic[k2_ChampionStatMinimum], (int32)L0928_puc_Statistic[k1_ChampionStatCurrent] + (AP0646_ui_IsLucky ? -2 : 2), (int32)L0928_puc_Statistic[k0_ChampionStatMaximum]); - return AP0646_ui_IsLucky; + + unsigned char* curStat = champ->_statistics[k0_ChampionStatLuck]; + bool isLucky = (_vm->getRandomNumber(curStat[k1_ChampionStatCurrent]) > percentage); + curStat[k1_ChampionStatCurrent] = f26_getBoundedValue(curStat[k2_ChampionStatMinimum], curStat[k1_ChampionStatCurrent] + (isLucky ? -2 : 2), curStat[k0_ChampionStatMaximum]); + return isLucky; } void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) { -- cgit v1.2.3 From af84d233d0d97f11d8d7241e4ed4a751ed6c5a64 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2016 12:14:38 +0200 Subject: DM: Refactor f322_championPoison, f284_setPartyDirection, f316_deleteScent, f317_addScentStrength, f310_getMovementTicks and f294_isAmmunitionCompatibleWithWeapon --- engines/dm/champion.cpp | 201 ++++++++++++++++++++++++------------------------ engines/dm/dm.h | 4 +- engines/dm/dungeonman.h | 1 + engines/dm/loadsave.cpp | 2 +- engines/dm/movesens.cpp | 1 - engines/dm/timeline.h | 2 +- 6 files changed, 106 insertions(+), 105 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 6bc4e707d7..c7592310cc 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1056,7 +1056,7 @@ bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) { if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage)) return true; - unsigned char* curStat = champ->_statistics[k0_ChampionStatLuck]; + unsigned char *curStat = champ->_statistics[k0_ChampionStatLuck]; bool isLucky = (_vm->getRandomNumber(curStat[k1_ChampionStatCurrent]) > percentage); curStat[k1_ChampionStatCurrent] = f26_getBoundedValue(curStat[k2_ChampionStatMinimum], curStat[k1_ChampionStatCurrent] + (isLucky ? -2 : 2), curStat[k0_ChampionStatMaximum]); return isLucky; @@ -1066,105 +1066,106 @@ void ChampionMan::f322_championPoison(int16 champIndex, uint16 attack) { if ((champIndex == kM1_ChampionNone) || (_vm->M0_indexToOrdinal(champIndex) == _g299_candidateChampionOrdinal)) return; - Champion* L0981_ps_Champion = &_gK71_champions[champIndex]; + Champion *curChampion = &_gK71_champions[champIndex]; f321_addPendingDamageAndWounds_getDamage(champIndex, MAX(1, attack >> 6), k0x0000_ChampionWoundNone, k0_attackType_NORMAL); - setFlag(L0981_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); + setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics); if ((_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) && (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) { - setFlag(L0981_ps_Champion->_attributes, k0x0800_ChampionAttributePanel); + setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel); } + if (--attack) { - L0981_ps_Champion->_poisonEventCount++; - TimelineEvent L0980_s_Event; - L0980_s_Event._type = k75_TMEventTypePoisonChampion; - L0980_s_Event._priority = champIndex; - M33_setMapAndTime(L0980_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 36); - L0980_s_Event._B._attack = attack; - _vm->_timeline->f238_addEventGetEventIndex(&L0980_s_Event); + curChampion->_poisonEventCount++; + TimelineEvent newEvent; + newEvent._type = k75_TMEventTypePoisonChampion; + newEvent._priority = champIndex; + M33_setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 36); + newEvent._B._attack = attack; + _vm->_timeline->f238_addEventGetEventIndex(&newEvent); } + f292_drawChampionState((ChampionIndex)champIndex); } void ChampionMan::f284_setPartyDirection(int16 dir) { - int16 L0833_i_ChampionIndex; - int16 L0834_i_Delta; - Champion* L0835_ps_Champion; - - - if (dir == _vm->_dungeonMan->_g308_partyDir) { + if (dir == _vm->_dungeonMan->_g308_partyDir) return; - } - if ((L0834_i_Delta = dir - _vm->_dungeonMan->_g308_partyDir) < 0) { + + int16 L0834_i_Delta = dir - _vm->_dungeonMan->_g308_partyDir; + if (L0834_i_Delta < 0) L0834_i_Delta += 4; + + Champion *curChampion = _gK71_champions; + for (int16 i = k0_ChampionFirst; i < _g305_partyChampionCount; i++) { + curChampion->_cell = (ViewCell)M21_normalizeModulo4(curChampion->_cell + L0834_i_Delta); + curChampion->_dir = (direction)M21_normalizeModulo4(curChampion->_dir + L0834_i_Delta); + curChampion++; } - L0835_ps_Champion = _gK71_champions; - for (L0833_i_ChampionIndex = k0_ChampionFirst; L0833_i_ChampionIndex < _g305_partyChampionCount; L0833_i_ChampionIndex++) { - L0835_ps_Champion->_cell = (ViewCell)M21_normalizeModulo4(L0835_ps_Champion->_cell + L0834_i_Delta); - L0835_ps_Champion->_dir = (direction)M21_normalizeModulo4(L0835_ps_Champion->_dir + L0834_i_Delta); - L0835_ps_Champion++; - } + _vm->_dungeonMan->_g308_partyDir = (direction)dir; f296_drawChangedObjectIcons(); } void ChampionMan::f316_deleteScent(uint16 scentIndex) { - uint16 L0953_ui_Count; + uint16 count = --_g407_party._scentCount - scentIndex; - if (L0953_ui_Count = --_g407_party._scentCount - scentIndex) { - for (uint16 i = 0; i < L0953_ui_Count; ++i) { + if (count) { + for (uint16 i = 0; i < count; ++i) { _g407_party._scents[scentIndex + i] = _g407_party._scents[scentIndex + i + 1]; _g407_party._scentStrengths[scentIndex + i] = _g407_party._scentStrengths[scentIndex + i + 1]; } } - if (scentIndex < _g407_party._firstScentIndex) { + + if (scentIndex < _g407_party._firstScentIndex) _g407_party._firstScentIndex--; - } - if (scentIndex < _g407_party._lastScentIndex) { + + if (scentIndex < _g407_party._lastScentIndex) _g407_party._lastScentIndex--; - } } void ChampionMan::f317_addScentStrength(int16 mapX, int16 mapY, int32 cycleCount) { - int16 L0954_i_ScentIndex = _vm->_championMan->_g407_party._scentCount; - if (L0954_i_ScentIndex) { - bool L0955_B_Merge = getFlag(cycleCount, k0x8000_mergeCycles); - if (L0955_B_Merge) { + int16 scentIndex = _vm->_championMan->_g407_party._scentCount; + if (scentIndex) { + bool mergeFl = getFlag(cycleCount, k0x8000_mergeCycles); + if (mergeFl) clearFlag(cycleCount, k0x8000_mergeCycles); - } - Scent L0958_s_Scent; /* BUG0_00 Useless code */ - L0958_s_Scent.setMapX(mapX); /* BUG0_00 Useless code */ - L0958_s_Scent.setMapY(mapY); /* BUG0_00 Useless code */ - L0958_s_Scent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */ - Scent* L0957_ps_Scent = _vm->_championMan->_g407_party._scents; /* BUG0_00 Useless code */ - bool L0956_B_CycleCountDefined = false; - while (L0954_i_ScentIndex--) { - if (&*L0957_ps_Scent++ == &L0958_s_Scent) { - if (!L0956_B_CycleCountDefined) { - L0956_B_CycleCountDefined = true; - if (L0955_B_Merge) { - cycleCount = MAX((int32)_g407_party._scentStrengths[L0954_i_ScentIndex], cycleCount); + + Scent newScent; /* BUG0_00 Useless code */ + newScent.setMapX(mapX); /* BUG0_00 Useless code */ + newScent.setMapY(mapY); /* BUG0_00 Useless code */ + newScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex); /* BUG0_00 Useless code */ + + Scent *curScent = _vm->_championMan->_g407_party._scents; /* BUG0_00 Useless code */ + bool cycleCountDefined = false; + while (scentIndex--) { + if (&*curScent++ == &newScent) { + if (!cycleCountDefined) { + cycleCountDefined = true; + if (mergeFl) { + cycleCount = MAX(_g407_party._scentStrengths[scentIndex], cycleCount); } else { - cycleCount = MIN(80, _g407_party._scentStrengths[L0954_i_ScentIndex] + cycleCount); + cycleCount = MIN(80, _g407_party._scentStrengths[scentIndex] + cycleCount); } } - _g407_party._scentStrengths[L0954_i_ScentIndex] = cycleCount; + _g407_party._scentStrengths[scentIndex] = cycleCount; } } } } void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) { - if (thing == Thing::_none) { + if (thing == Thing::_none) return; - } + _g415_leaderEmptyHanded = false; _vm->_objectMan->f36_extractIconFromBitmap(_g413_leaderHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(_g414_leaderHandObject = thing), _vm->_objectMan->_g412_objectIconForMousePointer); _vm->_eventMan->f78_showMouse(); _vm->_objectMan->f34_drawLeaderObjectName(thing); - if (setMousePointer) { + + if (setMousePointer) _vm->_g325_setMousePointerToObjectInMainLoop = true; - } else { + else _vm->_eventMan->f68_setPointerToObject(_vm->_objectMan->_g412_objectIconForMousePointer); - } + _vm->_eventMan->f77_hideMouse(); if (_g411_leaderIndex != kM1_ChampionNone) { _gK71_champions[_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(thing); @@ -1173,57 +1174,57 @@ void ChampionMan::f297_putObjectInLeaderHand(Thing thing, bool setMousePointer) } } -int16 ChampionMan::f310_getMovementTicks(Champion* champ) { - uint16 L0931_ui_Multiple; -#define AL0931_ui_Load L0931_ui_Multiple -#define AL0931_ui_WoundTicks L0931_ui_Multiple - uint16 L0932_ui_MaximumLoad; - int16 L0933_i_Ticks; - +int16 ChampionMan::f310_getMovementTicks(Champion *champ) { + uint16 maximumLoad = _vm->_championMan->f309_getMaximumLoad(champ); + uint16 curLoad = champ->_load; + uint16 woundTicks; + int16 ticks; + /* BUG0_72 - Fixed + The party moves very slowly even though no champion 'Load' value is drawn in red. + When the Load of a champion has exactly the maximum value he can carry then the Load + is drawn in yellow but the speed is the same as when the champion is overloaded + (when the Load is drawn in red). The comparison operator should be >= instead of > + */ + if (maximumLoad >= curLoad) { + ticks = 2; + if (((int32)curLoad << 3) > ((int32)maximumLoad * 5)) + ticks++; - if ((L0932_ui_MaximumLoad = _vm->_championMan->f309_getMaximumLoad(champ)) > (AL0931_ui_Load = champ->_load)) { /* BUG0_72 The party moves very slowly even though no champion 'Load' value is drawn in red. When the Load of a champion has exactly the maximum value he can carry then the Load is drawn in yellow but the speed is the same as when the champion is overloaded (when the Load is drawn in red). The comparison operator should be >= instead of > */ - L0933_i_Ticks = 2; - if (((int32)AL0931_ui_Load << 3) > ((int32)L0932_ui_MaximumLoad * 5)) { - L0933_i_Ticks++; - } - AL0931_ui_WoundTicks = 1; + woundTicks = 1; } else { - L0933_i_Ticks = 4 + (((AL0931_ui_Load - L0932_ui_MaximumLoad) << 2) / L0932_ui_MaximumLoad); - AL0931_ui_WoundTicks = 2; + ticks = 4 + (((curLoad - maximumLoad) << 2) / maximumLoad); + woundTicks = 2; } - if (getFlag(champ->_wounds, k0x0020_ChampionWoundFeet)) { - L0933_i_Ticks += AL0931_ui_WoundTicks; - } - if (_vm->_objectMan->f33_getIconIndex(champ->_slots[k5_ChampionSlotFeet]) == k194_IconIndiceArmourBootOfSpeed) { - L0933_i_Ticks--; - } - return L0933_i_Ticks; + + if (getFlag(champ->_wounds, k0x0020_ChampionWoundFeet)) + ticks += woundTicks; + + if (_vm->_objectMan->f33_getIconIndex(champ->_slots[k5_ChampionSlotFeet]) == k194_IconIndiceArmourBootOfSpeed) + ticks--; + + return ticks; } bool ChampionMan::f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex, uint16 ammunitionSlotIndex) { - Champion* L0874_ps_Champion; - WeaponInfo* L0875_ps_WeaponInfo; - Thing L0878_T_Thing; - int16 L0879_i_WeaponClass; - - L0874_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; - L0878_T_Thing = L0874_ps_Champion->_slots[weaponSlotIndex]; - if (L0878_T_Thing.getType() != k5_WeaponThingType) { + Champion *curChampion = &_vm->_championMan->_gK71_champions[champIndex]; + Thing curThing = curChampion->_slots[weaponSlotIndex]; + if (curThing.getType() != k5_WeaponThingType) return false; - } - L0875_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0878_T_Thing); - if ((L0875_ps_WeaponInfo->_class >= k16_WeaponClassFirstBow) && (L0875_ps_WeaponInfo->_class <= k31_WeaponClassLastBow)) { - L0879_i_WeaponClass = k10_WeaponClassBowAmmunition; - } else { - if ((L0875_ps_WeaponInfo->_class >= k32_WeaponClassFirstSling) && (L0875_ps_WeaponInfo->_class <= k47_WeaponClassLastSling)) { - L0879_i_WeaponClass = k11_WeaponClassSlingAmmunition; - } else { - return false; - } - } - L0878_T_Thing = L0874_ps_Champion->_slots[ammunitionSlotIndex]; - L0875_ps_WeaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(L0878_T_Thing); - return ((L0878_T_Thing.getType() == k5_WeaponThingType) && (L0875_ps_WeaponInfo->_class == L0879_i_WeaponClass)); + + WeaponInfo *weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing); + int16 weaponClass = kM1_WeaponClassNone; + + if ((weaponInfo->_class >= k16_WeaponClassFirstBow) && (weaponInfo->_class <= k31_WeaponClassLastBow)) + weaponClass = k10_WeaponClassBowAmmunition; + else if ((weaponInfo->_class >= k32_WeaponClassFirstSling) && (weaponInfo->_class <= k47_WeaponClassLastSling)) + weaponClass = k11_WeaponClassSlingAmmunition; + + if (weaponClass == kM1_WeaponClassNone) + return false; + + curThing = curChampion->_slots[ammunitionSlotIndex]; + weaponInfo = _vm->_dungeonMan->f158_getWeaponInfo(curThing); + return ((curThing.getType() == k5_WeaponThingType) && (weaponInfo->_class == weaponClass)); } void ChampionMan::f293_drawAllChampionStates() { diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 1b1f8a7af2..653afb581f 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -168,10 +168,10 @@ enum { - +//TODO: Directly use CLIP template inline T f26_getBoundedValue(T min, T val, T max) { - return MIN(MAX(min, val), max); + return CLIP(min, val, max); } // @ F0026_MAIN_GetBoundedValue #define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember)) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index b3e4194249..16af8b31cb 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -116,6 +116,7 @@ public: extern ArmourInfo g239_ArmourInfo[58]; // G0239_as_Graphic559_ArmourInfo +#define kM1_WeaponClassNone -1 /* Class 0: SWING weapons */ #define k0_WeaponClassSwingWeapon 0 // @ C000_CLASS_SWING_WEAPON /* Class 1 to 15: THROW weapons */ diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 19df8bf80f..3a075bd4f7 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -143,7 +143,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String _eventMan->f78_showMouse(); // do { - // ask the play what he wants + // ask the player what he wants // while // F0427_DIALOG_Draw(0, G0551_pc_SAVINGGAME, 0, 0, 0, 0, false, false, false); diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 6e53b7e509..89b369386a 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -629,7 +629,6 @@ T0266017_CheckProjectileImpacts: void MovesensMan::f268_addEvent(byte type, byte mapX, byte mapY, byte cell, byte effect, int32 time) { TimelineEvent L0729_s_Event; - M33_setMapAndTime(L0729_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, time); L0729_s_Event._type = type; L0729_s_Event._priority = 0; diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index 2d722d5569..bb9b781d91 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -101,7 +101,7 @@ class TimelineEvent { public: int32 _mapTime; byte _type; - byte _priority; + byte _priority; // CHECKME: byte? or int16? Inconsistency in the code uint16 getTypePriority() { return (_type << 8) + _priority; } -- cgit v1.2.3 From 02c8f286e79cbcf4e3b6ad383567c3ac08d4fe1c Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 25 Jul 2016 13:25:51 +0200 Subject: DM: Fix segfault with resume game --- engines/dm/loadsave.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 3a075bd4f7..138f9fd7ed 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -58,7 +58,6 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) { _g526_dungeonId = C10_DUNGEON_DM; if (_g298_newGame) { //L1366_B_FadePalette = !F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn(C0_DO_NOT_FORCE_DIALOG_DM_CSB, true); -T0435002: _g524_restartGameAllowed = false; _championMan->_g305_partyChampionCount = 0; _championMan->_g414_leaderHandObject = Thing::_none; @@ -70,6 +69,9 @@ T0435002: goto T0435004; }*/ + warning(false, "DUMMY CODE in f435_loadgame setting _g298_newGame to k1_modeLoadDungeon"); + _g298_newGame = k1_modeLoadDungeon; + SaveGameHeader header; readSaveGameHeader(file, &header); -- cgit v1.2.3 From e8bdaee8bf1404f42203c69def0a1f834f2ad386 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 25 Jul 2016 16:27:24 +0200 Subject: DM: Add DialogMan --- engines/dm/dialog.cpp | 36 ++++++++++++++++++++++++++++++++++++ engines/dm/dialog.h | 39 +++++++++++++++++++++++++++++++++++++++ engines/dm/dm.cpp | 4 ++++ engines/dm/dm.h | 2 ++ engines/dm/dungeonman.cpp | 3 ++- engines/dm/module.mk | 1 + 6 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 engines/dm/dialog.cpp create mode 100644 engines/dm/dialog.h diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp new file mode 100644 index 0000000000..87bf7d5705 --- /dev/null +++ b/engines/dm/dialog.cpp @@ -0,0 +1,36 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + +#include "dialog.h" + + +namespace DM { + +DialogMan::DialogMan(DMEngine* vm): _vm(vm) {} + + +} \ No newline at end of file diff --git a/engines/dm/dialog.h b/engines/dm/dialog.h new file mode 100644 index 0000000000..1cd5a6f441 --- /dev/null +++ b/engines/dm/dialog.h @@ -0,0 +1,39 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + +#include "dm.h" + + +namespace DM { + +class DialogMan { + DMEngine *_vm; +public: + explicit DialogMan(DMEngine *vm); +}; + +} \ No newline at end of file diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 55a2b6e055..e7bb4a704d 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -54,6 +54,7 @@ #include "group.h" #include "timeline.h" #include "projexpl.h" +#include "dialog.h" namespace DM { void warning(bool repeat, const char* s, ...) { @@ -147,6 +148,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _groupMan = nullptr; _timeline = nullptr; _projexpl = nullptr; + _displayMan = nullptr; _g528_saveFormat = 0; _g527_platform = 0; @@ -197,6 +199,7 @@ DMEngine::~DMEngine() { delete _groupMan; delete _timeline; delete _projexpl; + delete _dialog; // clear debug channels DebugMan.clearAllDebugChannels(); @@ -315,6 +318,7 @@ Common::Error DMEngine::run() { _groupMan = new GroupMan(this); _timeline = new Timeline(this); _projexpl = new ProjExpl(this); + _dialog = new DialogMan(this); _displayMan->setUpScreens(320, 200); f463_initializeGame(); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 653afb581f..4d48c94c83 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -52,6 +52,7 @@ class MovesensMan; class GroupMan; class Timeline; class ProjExpl; +class DialogMan; void warning(bool repeat, const char *s, ...); @@ -243,6 +244,7 @@ public: GroupMan *_groupMan; Timeline *_timeline; ProjExpl *_projexpl; + DialogMan *_dialog; int16 _g298_newGame; // @ G0298_B_NewGame diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 956232bcd7..6f13c9bf63 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -536,7 +536,8 @@ const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIR const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY void DungeonMan::f434_loadDungeonFile() { - if (_vm->_g298_newGame) + + if(!_rawDunFileData) f455_decompressDungeonFile(); Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO); diff --git a/engines/dm/module.mk b/engines/dm/module.mk index 50a8364cd4..75b4385421 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -31,6 +31,7 @@ MODULE := engines/dm MODULE_OBJS := \ champion.o \ detection.o \ + dialog.o \ dm.o \ dmglobals.o \ dungeonman.o \ -- cgit v1.2.3 From 63fc9fb27d684d69770cb626963d341c2f1aab77 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 25 Jul 2016 16:47:03 +0200 Subject: DM: Add f427_dialogDraw, f425_printCenteredChoice, f426_isMessageOnTwoLines --- engines/dm/dialog.cpp | 139 +++++++++++++++++++++++++++++++++++++++++++++++++- engines/dm/dialog.h | 4 ++ engines/dm/gfx.h | 1 + 3 files changed, 142 insertions(+), 2 deletions(-) diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp index 87bf7d5705..d9408fc37e 100644 --- a/engines/dm/dialog.cpp +++ b/engines/dm/dialog.cpp @@ -26,11 +26,146 @@ */ #include "dialog.h" +#include "gfx.h" +#include "text.h" +#include "eventman.h" namespace DM { -DialogMan::DialogMan(DMEngine* vm): _vm(vm) {} +DialogMan::DialogMan(DMEngine* vm) : _vm(vm) {} +void DialogMan::f427_dialogDraw(char* msg1, char* msg2, char* choice1, char* choice2, char* choice3, char* choice4, bool screenDialog, bool clearScreen, bool fading) { + static Box K0068_s_Box1 = {0, 223, 101, 125}; + static Box K0069_s_Box2 = {0, 223, 76, 100}; + static Box K0070_s_Box3 = {0, 223, 51, 75}; + static Box G0469_s_Graphic561_Box_Dialog2ChoicesPatch = {102, 122, 89, 125}; + static Box G0470_s_Graphic561_Box_Dialog4ChoicesPatch = {102, 122, 62, 97}; -} \ No newline at end of file + int16 L1308_i_X; + int16 L1309_i_Y; + int16 L1310_i_ChoiceCount; + char L1312_ac_StringPart1[70]; + char L1313_ac_StringPart2[70]; + Box L1314_s_Box; + + + _vm->_displayMan->f466_loadIntoBitmap(k0_dialogBoxGraphicIndice, _vm->_displayMan->_g296_bitmapViewport); + //Strangerke: the version should be replaced by a ScummVM/RogueVM (?) string + // TODO: replace with ScummVM version string + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 192, 7, k2_ColorLightGray, k1_ColorDarkGary, "V2.2", k136_heightViewport); + L1310_i_ChoiceCount = 1; + if (choice2 != nullptr) { + L1310_i_ChoiceCount++; + } + if (choice3 != nullptr) { + L1310_i_ChoiceCount++; + } + if (choice4 != nullptr) { + L1310_i_ChoiceCount++; + } + if (fading) { + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette in f427_dialogDraw"); + } + if (clearScreen) { + _vm->_displayMan->fillScreen(k0_ColorBlack); + } + _vm->_displayMan->_g578_useByteBoxCoordinates = false; + if (L1310_i_ChoiceCount == 1) { + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, K0068_s_Box1, 0, 64, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, K0069_s_Box2, 0, 39, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, K0070_s_Box3, 0, 14, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 114); + } else { + if (L1310_i_ChoiceCount == 2) { + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, G0469_s_Graphic561_Box_Dialog2ChoicesPatch, 102, 52, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 112, 114); + } else { + if (L1310_i_ChoiceCount == 3) { + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 59, 114); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 166, 114); + } else { + if (L1310_i_ChoiceCount == 4) { + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, G0470_s_Graphic561_Box_Dialog4ChoicesPatch, 102, 99, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 59, 77); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 166, 77); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 59, 114); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice4, 166, 114); + } + } + } + } + L1309_i_Y = 29; + if (msg1 != nullptr) { + if (f426_isMessageOnTwoLines(msg1, L1312_ac_StringPart1, L1313_ac_StringPart2)) { + L1309_i_Y = 21; + L1308_i_X = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k11_ColorYellow, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport); + L1309_i_Y += 8; + L1308_i_X = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k11_ColorYellow, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport); + L1309_i_Y += 8; + } else { + L1308_i_X = 113 - ((strlen(msg1) * 6) >> 1); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k11_ColorYellow, k5_ColorLightBrown, msg1, k136_heightViewport); + L1309_i_Y += 8; + } + } + if (msg2 != nullptr) { + if (f426_isMessageOnTwoLines(msg2, L1312_ac_StringPart1, L1313_ac_StringPart2)) { + L1308_i_X = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k9_ColorGold, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport); + L1309_i_Y += 8; + L1308_i_X = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k9_ColorGold, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport); + } else { + L1308_i_X = 113 - ((strlen(msg2) * 6) >> 1); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k9_ColorGold, k5_ColorLightBrown, msg2, k136_heightViewport); + } + } + if (screenDialog) { + L1314_s_Box._y1 = 33; + L1314_s_Box._y2 = 168; + L1314_s_Box._x1 = 47; + L1314_s_Box._x2 = 270; + _vm->_eventMan->f78_showMouse(); + _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->_g296_bitmapViewport, &L1314_s_Box, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport); + _vm->_eventMan->f77_hideMouse(); + } else { + _vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView); + _vm->f22_delay(1); + } + if (fading) { + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette in f427_dialogDraw"); + } + _vm->_displayMan->_g297_drawFloorAndCeilingRequested = true; +} + +void DialogMan::f425_printCenteredChoice(byte* bitmap, char* str, int16 posX, int16 posY) { + if (str) { + posX -= (strlen(str) * 6) >> 1; + _vm->_textMan->f40_printTextToBitmap(bitmap, k112_byteWidthViewport, posX, posY, k9_ColorGold, k5_ColorLightBrown, str, k136_heightViewport); + } +} + +bool DialogMan::f426_isMessageOnTwoLines(char* str, char* part1, char* part2) { + uint16 L1305_ui_StringLength; + uint16 L1306_ui_SplitPosition; + + + L1305_ui_StringLength = strlen(str); + if (L1305_ui_StringLength <= 30) { + return false; + } + strcpy(part1, str); + L1306_ui_SplitPosition = L1305_ui_StringLength >> 1; + while ((part1[L1306_ui_SplitPosition] != ' ') && L1306_ui_SplitPosition < L1305_ui_StringLength) { + L1306_ui_SplitPosition++; + } + part1[L1306_ui_SplitPosition] = '\0'; + strcpy(part2, &part1[L1306_ui_SplitPosition + 1]); + return true; +} +} diff --git a/engines/dm/dialog.h b/engines/dm/dialog.h index 1cd5a6f441..2dd3e5bd2a 100644 --- a/engines/dm/dialog.h +++ b/engines/dm/dialog.h @@ -34,6 +34,10 @@ class DialogMan { DMEngine *_vm; public: explicit DialogMan(DMEngine *vm); + void f427_dialogDraw(char *msg1, char *msg2, char *choice1, char *choice2, + char *choice3, char *choice4, bool screenDialog, bool clearScreen, bool fading); // @ F0427_DIALOG_Draw + void f425_printCenteredChoice(byte *bitmap, char *str, int16 posX, int16 posY); // @ F0425_DIALOG_PrintCenteredChoice + bool f426_isMessageOnTwoLines(char *str, char *part1, char *part2); // @ F0426_DIALOG_IsMessageOnTwoLines }; } \ No newline at end of file diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 2a18b39b39..1a1ad493e1 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -202,6 +202,7 @@ enum ViewCell { }; enum GraphicIndice { + k0_dialogBoxGraphicIndice = 0, // @ C000_GRAPHIC_DIALOG_BOX k2_entranceLeftDoorGraphicIndice = 2, // @ C002_GRAPHIC_ENTRANCE_LEFT_DOOR k3_entranceRightDoorGraphicIndice = 3, // @ C003_GRAPHIC_ENTRANCE_RIGHT_DOOR k4_entranceGraphicIndice = 4, // @ C004_GRAPHIC_ENTRANCE -- cgit v1.2.3 From b174331e71f4c63b2847762acddcf8d20a712cb8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2016 14:35:26 +0200 Subject: DM: refact f293_drawAllChampionStates, f283_viAltarRebirth, f327_isProjectileSpellCast and f326_championShootProjectile. Rename Direction. --- engines/dm/champion.cpp | 98 ++++++++++++++++++++++------------------------- engines/dm/champion.h | 4 +- engines/dm/dm.cpp | 10 ++--- engines/dm/dm.h | 10 ++--- engines/dm/dungeonman.cpp | 14 +++---- engines/dm/dungeonman.h | 16 ++++---- engines/dm/gfx.cpp | 30 +++++++-------- engines/dm/gfx.h | 28 +++++++------- engines/dm/group.cpp | 28 +++++++------- engines/dm/group.h | 6 +-- engines/dm/loadsave.cpp | 2 +- engines/dm/menus.cpp | 2 +- engines/dm/movesens.cpp | 2 +- engines/dm/projexpl.cpp | 4 +- engines/dm/projexpl.h | 2 +- engines/dm/timeline.cpp | 10 ++--- engines/dm/timeline.h | 4 +- 17 files changed, 132 insertions(+), 138 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index c7592310cc..3c0d08ac2c 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1097,11 +1097,11 @@ void ChampionMan::f284_setPartyDirection(int16 dir) { Champion *curChampion = _gK71_champions; for (int16 i = k0_ChampionFirst; i < _g305_partyChampionCount; i++) { curChampion->_cell = (ViewCell)M21_normalizeModulo4(curChampion->_cell + L0834_i_Delta); - curChampion->_dir = (direction)M21_normalizeModulo4(curChampion->_dir + L0834_i_Delta); + curChampion->_dir = (Direction)M21_normalizeModulo4(curChampion->_dir + L0834_i_Delta); curChampion++; } - _vm->_dungeonMan->_g308_partyDir = (direction)dir; + _vm->_dungeonMan->_g308_partyDir = (Direction)dir; f296_drawChangedObjectIcons(); } @@ -1228,31 +1228,26 @@ bool ChampionMan::f294_isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint1 } void ChampionMan::f293_drawAllChampionStates() { - int16 L0873_i_ChampionIndex; - for (L0873_i_ChampionIndex = k0_ChampionFirst; L0873_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0873_i_ChampionIndex++) { - _vm->_championMan->f292_drawChampionState((ChampionIndex)L0873_i_ChampionIndex); - } + for (int16 i = k0_ChampionFirst; i < _vm->_championMan->_g305_partyChampionCount; i++) + _vm->_championMan->f292_drawChampionState((ChampionIndex)i); } void ChampionMan::f283_viAltarRebirth(uint16 champIndex) { - uint16 L0831_ui_Multiple; -#define AL0831_ui_Cell L0831_ui_Multiple -#define AL0831_ui_MaximumHealth L0831_ui_Multiple - Champion* L0832_ps_Champion; + Champion *curChampion = &_vm->_championMan->_gK71_champions[champIndex]; + if (_vm->_championMan->f285_getIndexInCell(curChampion->_cell) != kM1_ChampionNone) { + uint16 numCell = k0_CellNorthWest; + while (_vm->_championMan->f285_getIndexInCell(numCell) != kM1_ChampionNone) + numCell++; - L0832_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; - if (_vm->_championMan->f285_getIndexInCell(L0832_ps_Champion->_cell) != kM1_ChampionNone) { - AL0831_ui_Cell = k0_CellNorthWest; - while (_vm->_championMan->f285_getIndexInCell(AL0831_ui_Cell) != kM1_ChampionNone) { - AL0831_ui_Cell++; - } - L0832_ps_Champion->_cell = (ViewCell)AL0831_ui_Cell; + curChampion->_cell = (ViewCell)numCell; } - AL0831_ui_MaximumHealth = L0832_ps_Champion->_maxHealth; - L0832_ps_Champion->_currHealth = (L0832_ps_Champion->_maxHealth = MAX(25, AL0831_ui_MaximumHealth - (AL0831_ui_MaximumHealth >> 6) - 1)) >> 1; + + uint16 maximumHealth = curChampion->_maxHealth; + curChampion->_maxHealth = MAX(25, maximumHealth - (maximumHealth >> 6) - 1); + curChampion->_currHealth = curChampion->_maxHealth >> 1; _vm->_menuMan->f393_drawSpellAreaControls(_vm->_championMan->_g514_magicCasterChampionIndex); - L0832_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir; - setFlag(L0832_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon); + curChampion->_dir = _vm->_dungeonMan->_g308_partyDir; + setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon); _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); } @@ -1261,18 +1256,19 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) uint16 slotIndex; if (slotBoxIndex < k8_SlotBoxInventoryFirstSlot) { - if (_g299_candidateChampionOrdinal) { + if (_g299_candidateChampionOrdinal) return; - } + champIndex = slotBoxIndex >> 1; - if ((champIndex >= _g305_partyChampionCount) || (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_gK71_champions[champIndex]._currHealth) { + if ((champIndex >= _g305_partyChampionCount) || (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) || !_gK71_champions[champIndex]._currHealth) return; - } + slotIndex = M70_handSlotIndex(slotBoxIndex); } else { champIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal); slotIndex = slotBoxIndex - k8_SlotBoxInventoryFirstSlot; } + Thing leaderHandObject = _g414_leaderHandObject; Thing slotThing; if (slotIndex >= k30_ChampionSlotChest_1) { @@ -1280,53 +1276,51 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) } else { slotThing = _gK71_champions[champIndex]._slots[slotIndex]; } - if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none)) { + + if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none)) return; - } - if ((leaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & g38_slotMasks[slotIndex]))) { + + if ((leaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & g38_slotMasks[slotIndex]))) return; - } + _vm->_eventMan->f78_showMouse(); - if (leaderHandObject != Thing::_none) { + if (leaderHandObject != Thing::_none) f298_getObjectRemovedFromLeaderHand(); - } + if (slotThing != Thing::_none) { f300_getObjectRemovedFromSlot(champIndex, slotIndex); f297_putObjectInLeaderHand(slotThing, false); } - if (leaderHandObject != Thing::_none) { + + if (leaderHandObject != Thing::_none) f301_addObjectInSlot((ChampionIndex)champIndex, leaderHandObject, (ChampionSlot)slotIndex); - } + f292_drawChampionState((ChampionIndex)champIndex); _vm->_eventMan->f77_hideMouse(); } bool ChampionMan::f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount) { - int16 L0991_i_StepEnergy; - Champion* L0992_ps_Champion; - - L0992_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; - if (L0992_ps_Champion->_currMana < requiredManaAmount) { + Champion *curChampion = &_vm->_championMan->_gK71_champions[champIndex]; + if (curChampion->_currMana < requiredManaAmount) return false; - } - L0992_ps_Champion->_currMana -= requiredManaAmount; - setFlag(L0992_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); - L0991_i_StepEnergy = 10 - MIN(8, L0992_ps_Champion->_maxMana >> 3); - if (kineticEnergy < (L0991_i_StepEnergy << 2)) { + + curChampion->_currMana -= requiredManaAmount; + setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics); + int16 stepEnergy = 10 - MIN(8, curChampion->_maxMana >> 3); + if (kineticEnergy < (stepEnergy << 2)) { kineticEnergy += 3; - L0991_i_StepEnergy--; + stepEnergy--; } - f326_championShootProjectile(L0992_ps_Champion, thing, kineticEnergy, 90, L0991_i_StepEnergy); + + f326_championShootProjectile(curChampion, thing, kineticEnergy, 90, stepEnergy); return true; // fix BUG_01 } void ChampionMan::f326_championShootProjectile(Champion* champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy) { - uint16 L0990_ui_Direction; - - L0990_ui_Direction = champ->_dir; - _vm->_projexpl->f212_projectileCreate(thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, M21_normalizeModulo4((((champ->_cell - L0990_ui_Direction + 1) & 0x0002) >> 1) + L0990_ui_Direction), (direction)L0990_ui_Direction, kineticEnergy, attack, stepEnergy); + Direction newDirection = champ->_dir; + _vm->_projexpl->f212_projectileCreate(thing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, M21_normalizeModulo4((((champ->_cell - newDirection + 1) & 0x0002) >> 1) + newDirection), newDirection, kineticEnergy, attack, stepEnergy); _vm->_g311_projectileDisableMovementTicks = 4; - _vm->_g312_lastProjectileDisabledMovementDirection = L0990_ui_Direction; + _vm->_g312_lastProjectileDisabledMovementDirection = newDirection; } void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() { @@ -1777,7 +1771,7 @@ void ChampionMan::load2_PartyPart(Common::InSaveFile* file) { champ->_name[j] = file->readByte(); for (uint16 j = 0; j < 20; ++j) champ->_title[j] = file->readByte(); - champ->_dir = (direction)file->readUint16BE(); + champ->_dir = (Direction)file->readUint16BE(); champ->_cell = (ViewCell)file->readUint16BE(); champ->_actionIndex = (ChampionAction)file->readUint16BE(); champ->_symbolStep = file->readUint16BE(); @@ -2282,7 +2276,7 @@ T0292042: _vm->_eventMan->f77_hideMouse(); } -uint16 ChampionMan::M26_championIconIndex(int16 val, direction dir) { +uint16 ChampionMan::M26_championIconIndex(int16 val, Direction dir) { return ((val + 4 - dir) & 0x3); } diff --git a/engines/dm/champion.h b/engines/dm/champion.h index e2956c1364..04ab76988f 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -370,7 +370,7 @@ public: Skill _skills[20]; char _name[8]; char _title[20]; - direction _dir; + Direction _dir; ViewCell _cell; ChampionAction _actionIndex; uint16 _symbolStep; @@ -537,7 +537,7 @@ public: uint16 f306_getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue uint16 f309_getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad void f292_drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState - uint16 M26_championIconIndex(int16 val, direction dir); // @ M26_CHAMPION_ICON_INDEX + uint16 M26_championIconIndex(int16 val, Direction dir); // @ M26_CHAMPION_ICON_INDEX void f290_drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues void f291_drawSlot(uint16 champIndex, int16 slotIndex); // @ F0291_CHAMPION_DrawSlot void f281_renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index e7bb4a704d..5d003b7373 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -76,19 +76,19 @@ void warning(bool repeat, const char* s, ...) { } } -void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } -void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); } -direction returnOppositeDir(direction dir) { return (direction)((dir + 2) & 3); } +void turnDirRight(Direction &dir) { dir = (Direction)((dir + 1) & 3); } +void turnDirLeft(Direction &dir) { dir = (Direction)((dir - 1) & 3); } +Direction returnOppositeDir(Direction dir) { return (Direction)((dir + 2) & 3); } uint16 returnPrevVal(uint16 val) { - return (direction)((val + 3) & 3); + return (Direction)((val + 3) & 3); } uint16 returnNextVal(uint16 val) { return (val + 1) & 0x3; } -bool isOrientedWestEast(direction dir) { return dir & 1; } +bool isOrientedWestEast(Direction dir) { return dir & 1; } uint16 toggleFlag(uint16& val, uint16 mask) { return val ^= mask; diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 4d48c94c83..c1881a0638 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -57,7 +57,7 @@ class DialogMan; void warning(bool repeat, const char *s, ...); -enum direction { +enum Direction { kDirNorth = 0, kDirEast = 1, kDirSouth = 2, @@ -122,12 +122,12 @@ public: -void turnDirRight(direction &dir); -void turnDirLeft(direction &dir); -direction returnOppositeDir(direction dir); // @ M18_OPPOSITE +void turnDirRight(Direction &dir); +void turnDirLeft(Direction &dir); +Direction returnOppositeDir(Direction dir); // @ M18_OPPOSITE uint16 returnPrevVal(uint16 val); // @ M19_PREVIOUS uint16 returnNextVal(uint16 val); // @ M17_NEXT -bool isOrientedWestEast(direction dir); // @ M16_IS_ORIENTED_WEST_EAST +bool isOrientedWestEast(Direction dir); // @ M16_IS_ORIENTED_WEST_EAST #define setFlag(val, mask) ((val) |= (mask)) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 6f13c9bf63..e01a154dc3 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -363,7 +363,7 @@ CreatureInfo g243_CreatureInfo[k27_CreatureTypeCount] = { // @ G0243_as_Graphic5 {25, 0, 0x38AA, 0x0000, 12, 22, 255, 180, 210, 0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}, {26, 0, 0x38AA, 0x0000, 12, 22, 255, 180, 210, 0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}}; -void DungeonMan::f150_mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) { +void DungeonMan::f150_mapCoordsAfterRelMovement(Direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) { posX += _vm->_dirIntoStepCountEast[dir] * stepsForward; posY += _vm->_dirIntoStepCountNorth[dir] * stepsForward; turnDirRight(dir); @@ -385,7 +385,7 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine) { for (uint16 i = 0; i < 16; ++i) _g284_thingData[i] = nullptr; _g279_dungeonMapData = nullptr; - _g308_partyDir = (direction)0; + _g308_partyDir = (Direction)0; _g306_partyMapX = 0; _g307_partyMapY = 0; _g309_partyMapIndex = 0; @@ -549,7 +549,7 @@ void DungeonMan::f434_loadDungeonFile() { dunDataStream.readByte(); // discard 1 byte _g278_dungeonFileHeader._textDataWordCount = dunDataStream.readUint16BE(); uint16 partyPosition = dunDataStream.readUint16BE(); - _g278_dungeonFileHeader._partyStartDir = (direction)((partyPosition >> 10) & 3); + _g278_dungeonFileHeader._partyStartDir = (Direction)((partyPosition >> 10) & 3); _g278_dungeonFileHeader._partyStartPosY = (partyPosition >> 5) & 0x1F; _g278_dungeonFileHeader._partyStartPosX = (partyPosition >> 0) & 0x1F; _g278_dungeonFileHeader._squareFirstThingCount = dunDataStream.readUint16BE(); @@ -788,7 +788,7 @@ Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) { return Square(k0_ElementTypeWall, 0); } -Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { +Square DungeonMan::f152_getRelSquare(Direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { f150_mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY); return f151_getSquare(posX, posY); } @@ -822,7 +822,7 @@ Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) { // TODO: produce more GOTOs -void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) { // complete, except where marked +void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, int16 mapY) { // complete, except where marked #define thingType dir byte L0307_uc_Multiple; #define square L0307_uc_Multiple @@ -928,7 +928,7 @@ different sides of the wall, the same text is drawn on each affected side */ T0172029_Teleporter: footprintsAllowed = true; T0172030_Pit: - while ((thing != Thing::_endOfList) && ((thingType = (direction)thing.getType()) <= k3_SensorThingType)) { + while ((thing != Thing::_endOfList) && ((thingType = (Direction)thing.getType()) <= k3_SensorThingType)) { if (thingType == k3_SensorThingType) { sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(thing); aspectArray[k4_FloorOrnOrdAspect] = sensor->getOrnOrdinal(); @@ -1554,7 +1554,7 @@ void DungeonMan::f146_setGroupCells(Group* group, uint16 cells, uint16 mapIndex) void DungeonMan::f148_setGroupDirections(Group* group, int16 dir, uint16 mapIndex) { if (mapIndex == _vm->_dungeonMan->_g309_partyMapIndex) { - _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (direction)dir; + _vm->_groupMan->_g375_activeGroups[group->getActiveGroupIndex()]._directions = (Direction)dir; } else { group->setDir(M21_normalizeModulo4(dir)); } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 16af8b31cb..95f8a1abf4 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -244,7 +244,7 @@ public: bool isAudible() { return (_attributes >> 15) & 1; } TeleporterScope getScope() { return (TeleporterScope)((_attributes >> 13) & 1); } bool getAbsoluteRotation() { return (_attributes >> 12) & 1; } - direction getRotation() { return (direction)((_attributes >> 10) & 1); } + Direction getRotation() { return (Direction)((_attributes >> 10) & 1); } byte getTargetMapY() { return (_attributes >> 5) & 0xF; } byte getTargetMapX() { return _attributes & 0xF; } uint16 getTargetMapIndex() { return _destMapIndex >> 8; } @@ -334,7 +334,7 @@ public: uint16 getTargetMapY() { return (_action >> 11); } uint16 getTargetMapX() { return (_action >> 6) & 0x1F; } - direction getTargetCell() { return (direction)((_action >> 4) & 3); } + Direction getTargetCell() { return (Direction)((_action >> 4) & 3); } uint16 M47_kineticEnergy() { return (_action & 0xFF); }// @ M47_KINETIC_ENERGY uint16 M48_stepEnergy() { return (_action >> 8) & 0xFF; }// @ M48_STEP_ENERGY uint16 M49_localEffect() { return _action; } // @ M49_LOCAL_EFFECT @@ -611,7 +611,7 @@ struct DungeonFileHeader { uint32 _rawMapDataSize; uint8 _mapCount; uint16 _textDataWordCount; - direction _partyStartDir; // @ InitialPartyLocation + Direction _partyStartDir; // @ InitialPartyLocation uint16 _partyStartPosX, _partyStartPosY; uint16 _squareFirstThingCount; // @ SquareFirstThingCount uint16 _thingCounts[16]; // @ ThingCount[16] @@ -656,7 +656,7 @@ class DungeonMan { DungeonMan(const DungeonMan &other); // no implementation on purpose void operator=(const DungeonMan &rhs); // no implementation on purpose - Square f152_getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare + Square f152_getRelSquare(Direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare void f455_decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon @@ -683,11 +683,11 @@ public: void f174_setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap bool f149_isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove - void f150_mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement - SquareType f153_getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { + void f150_mapCoordsAfterRelMovement(Direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement + SquareType f153_getRelSquareType(Direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { return Square(f152_getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType(); } // @ F0153_DUNGEON_GetRelativeSquareType - void f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect + void f172_setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect void f168_decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText Thing f166_getUnusedThing(uint16 thingType); // @ F0166_DUNGEON_GetUnusedThing @@ -725,7 +725,7 @@ public: byte ***_g279_dungeonMapData; // @ G0279_pppuc_DungeonMapData - direction _g308_partyDir; // @ G0308_i_PartyDirection + Direction _g308_partyDir; // @ G0308_i_PartyDirection int16 _g306_partyMapX; // @ G0306_i_PartyMapX int16 _g307_partyMapY; // @ G0307_i_PartyMapY uint8 _g309_partyMapIndex; // @ G0309_i_PartyMapIndex diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index dae340085f..d264bf1c79 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1462,7 +1462,7 @@ void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) { // NOTE: has been screened for missing code -void DisplayMan::f116_drawSquareD3L(direction dir, int16 posX, int16 posY) { +void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) { static DoorFrames g179_doorFrame_D3L = DoorFrames( // @ G0179_s_Graphic558_Frames_Door_D3L /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ Frame(24, 71, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ @@ -1527,7 +1527,7 @@ T0116017_orangeElk: } } -void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) { +void DisplayMan::f117_drawSquareD3R(Direction dir, int16 posX, int16 posY) { static DoorFrames g181_doorFrame_D3R = DoorFrames( // @ G0181_s_Graphic558_Frames_Door_D3R /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ Frame(150, 197, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ @@ -1598,7 +1598,7 @@ T0117018: } } -void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) { +void DisplayMan::f118_drawSquareD3C(Direction dir, int16 posX, int16 posY) { static DoorFrames g180_doorFrame_D3C = DoorFrames( // @ G0180_s_Graphic558_Frames_Door_D3C /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ Frame(88, 135, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ @@ -1662,7 +1662,7 @@ T0118028: } } -void DisplayMan::f119_drawSquareD2L(direction dir, int16 posX, int16 posY) { +void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) { static DoorFrames g182_doorFrame_D2L = DoorFrames( // @ G0182_s_Graphic558_Frames_Door_D2L /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ Frame(0, 63, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ @@ -1728,7 +1728,7 @@ T0119020: } } -void DisplayMan::f120_drawSquareD2R(direction dir, int16 posX, int16 posY) { +void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) { static DoorFrames g184_doorFrame_D2R = DoorFrames( // @ G0184_s_Graphic558_Frames_Door_D2R /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ Frame(160, 223, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ @@ -1796,7 +1796,7 @@ T0120029: } } -void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) { +void DisplayMan::f121_drawSquareD2C(Direction dir, int16 posX, int16 posY) { static DoorFrames g183_doorFrame_D2C = DoorFrames( // @ G0183_s_Graphic558_Frames_Door_D2C /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ Frame(80, 143, 24, 82, 32, 61, 0, 0), /* Closed Or Destroyed */ @@ -1862,7 +1862,7 @@ T0121016: } } -void DisplayMan::f122_drawSquareD1L(direction dir, int16 posX, int16 posY) { +void DisplayMan::f122_drawSquareD1L(Direction dir, int16 posX, int16 posY) { static DoorFrames g185_doorFrame_D1L = DoorFrames( // @ G0185_s_Graphic558_Frames_Door_D1L /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ Frame(0, 31, 17, 102, 48, 88, 64, 0), /* Closed Or Destroyed */ @@ -1929,7 +1929,7 @@ T0122021: } } -void DisplayMan::f123_drawSquareD1R(direction dir, int16 posX, int16 posY) { +void DisplayMan::f123_drawSquareD1R(Direction dir, int16 posX, int16 posY) { static DoorFrames g187_doorFrame_D1R = DoorFrames( // @ G0187_s_Graphic558_Frames_Door_D1R /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ Frame(192, 223, 17, 102, 48, 88, 0, 0), /* Closed Or Destroyed */ @@ -1995,7 +1995,7 @@ T0123021: f113_drawField(&g188_FieldAspects[k8_ViewSquare_D1R], g163_FrameWalls[k8_ViewSquare_D1R]._box); } } -void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) { +void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) { static Box g107_BoxThievesEyeVisibleArea(0, 95, 0, 94); // @ G0107_s_Graphic558_Box_ThievesEye_VisibleArea int16 order; int16 squareAspect[5]; @@ -2075,7 +2075,7 @@ T0124018: } } -void DisplayMan::f125_drawSquareD0L(direction dir, int16 posX, int16 posY) { +void DisplayMan::f125_drawSquareD0L(Direction dir, int16 posX, int16 posY) { uint16 squareAspect[5]; _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); switch (squareAspect[0]) { @@ -2091,7 +2091,7 @@ void DisplayMan::f125_drawSquareD0L(direction dir, int16 posX, int16 posY) { } } -void DisplayMan::f126_drawSquareD0R(direction dir, int16 posX, int16 posY) { +void DisplayMan::f126_drawSquareD0R(Direction dir, int16 posX, int16 posY) { int16 squareAspect[5]; @@ -2118,7 +2118,7 @@ void DisplayMan::f126_drawSquareD0R(direction dir, int16 posX, int16 posY) { } } -void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) { +void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) { static Box g108_BoxThievesEyeHoleInDoorFrame(0, 31, 19, 113); // @ G0108_s_Graphic558_Box_ThievesEye_HoleInDoorFrame int16 squareAspect[5]; @@ -2155,7 +2155,7 @@ void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) { } } -void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) { +void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) { loadPalette(g20_PalEntrance); // dummy code @@ -2878,7 +2878,7 @@ int16 g225_CenteredExplosionCoordinates[15][2] = { // @ G0225_aai_Graphic558_Cen #define k0x0080_BlitDoNotUseMask 0x0080 // @ MASK0x0080_DO_NOT_USE_MASK -void DisplayMan::f115_cthulhu(Thing thingParam, direction directionParam, int16 mapXpos, +void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals) { DungeonMan &dunMan = *_vm->_dungeonMan; @@ -3460,7 +3460,7 @@ continue; projectileBitmapIndexData = 0; flipVertical = flipHorizontal = false; } else { - if (isOrientedWestEast((direction)(projectileDirection = _vm->_timeline->_g370_events[projectile->_eventIndex]._C._projectile.getDir())) + if (isOrientedWestEast((Direction)(projectileDirection = _vm->_timeline->_g370_events[projectile->_eventIndex]._C._projectile.getDir())) != isOrientedWestEast(directionParam)) { if (projectileAspectType == k2_ProjectileAspectHasRotation) { projectileBitmapIndexData = 1; diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 1a1ad493e1..3af375d493 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -530,18 +530,18 @@ class DisplayMan { void f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap void f100_drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap void f101_drawWallSetBitmapWithoutTransparency(byte *bitmap, Frame &f); // @ F0101_DUNGEONVIEW_DrawWallSetBitmapWithoutTransparency - void f116_drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L - void f117_drawSquareD3R(direction dir, int16 posX, int16 posY); // @ F0117_DUNGEONVIEW_DrawSquareD3R - void f118_drawSquareD3C(direction dir, int16 posX, int16 posY); // @ F0118_DUNGEONVIEW_DrawSquareD3C_CPSF - void f119_drawSquareD2L(direction dir, int16 posX, int16 posY); // @ F0119_DUNGEONVIEW_DrawSquareD2L - void f120_drawSquareD2R(direction dir, int16 posX, int16 posY); // @ F0120_DUNGEONVIEW_DrawSquareD2R_CPSF - void f121_drawSquareD2C(direction dir, int16 posX, int16 posY); // @ F0121_DUNGEONVIEW_DrawSquareD2C - void f122_drawSquareD1L(direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1L - void f123_drawSquareD1R(direction dir, int16 posX, int16 posY); // @ F0123_DUNGEONVIEW_DrawSquareD1R - void f124_drawSquareD1C(direction dir, int16 posX, int16 posY); // @ F0124_DUNGEONVIEW_DrawSquareD1C - void f125_drawSquareD0L(direction dir, int16 posX, int16 posY); // @ F0125_DUNGEONVIEW_DrawSquareD0L - void f126_drawSquareD0R(direction dir, int16 posX, int16 posY); // @ F0126_DUNGEONVIEW_DrawSquareD0R - void f127_drawSquareD0C(direction dir, int16 posX, int16 posY); // @ F0127_DUNGEONVIEW_DrawSquareD0C + void f116_drawSquareD3L(Direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L + void f117_drawSquareD3R(Direction dir, int16 posX, int16 posY); // @ F0117_DUNGEONVIEW_DrawSquareD3R + void f118_drawSquareD3C(Direction dir, int16 posX, int16 posY); // @ F0118_DUNGEONVIEW_DrawSquareD3C_CPSF + void f119_drawSquareD2L(Direction dir, int16 posX, int16 posY); // @ F0119_DUNGEONVIEW_DrawSquareD2L + void f120_drawSquareD2R(Direction dir, int16 posX, int16 posY); // @ F0120_DUNGEONVIEW_DrawSquareD2R_CPSF + void f121_drawSquareD2C(Direction dir, int16 posX, int16 posY); // @ F0121_DUNGEONVIEW_DrawSquareD2C + void f122_drawSquareD1L(Direction dir, int16 posX, int16 posY); // @ F0122_DUNGEONVIEW_DrawSquareD1L + void f123_drawSquareD1R(Direction dir, int16 posX, int16 posY); // @ F0123_DUNGEONVIEW_DrawSquareD1R + void f124_drawSquareD1C(Direction dir, int16 posX, int16 posY); // @ F0124_DUNGEONVIEW_DrawSquareD1C + void f125_drawSquareD0L(Direction dir, int16 posX, int16 posY); // @ F0125_DUNGEONVIEW_DrawSquareD0L + void f126_drawSquareD0R(Direction dir, int16 posX, int16 posY); // @ F0126_DUNGEONVIEW_DrawSquareD0R + void f127_drawSquareD0C(Direction dir, int16 posX, int16 posY); // @ F0127_DUNGEONVIEW_DrawSquareD0C void f93_applyCreatureReplColors(int replacedColor, int replacementColor); // @ F0093_DUNGEONVIEW_ApplyCreatureReplacementColors @@ -680,7 +680,7 @@ public: void D24_fillScreenBox(Box &box, Color color); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox /* Expects inclusive boundaries in box */ void f135_fillBoxBitmap(byte *destBitmap, Box &box, Color color, int16 byteWidth, int16 height); // @ F0135_VIDEO_FillBox - void f128_drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF + void f128_drawDungeon(Direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void f98_drawFloorAndCeiling(); // @ F0098_DUNGEONVIEW_DrawFloorAndCeiling void updateScreen(); void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport @@ -692,7 +692,7 @@ public: int16 f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale); // @ F0459_START_GetScaledBitmapByteCount int16 M78_getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION - void f115_cthulhu(Thing thingParam, direction directionParam, + void f115_cthulhu(Thing thingParam, Direction directionParam, int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF uint16 M77_getNormalizedByteWidth(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 235bfe40b6..ec2090cc6e 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -873,8 +873,8 @@ T0209084_SingleSquareMoveTowardParty: T0209085_SingleSquareMove: if (f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls) || f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty, L0456_B_AllowMovementOverImaginaryPitsAndFakeWalls && _vm->getRandomNumber(2)) || - f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction), false) || - (!_vm->getRandomNumber(4) && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty), false))) { + f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)AL0446_i_Direction), false) || + (!_vm->getRandomNumber(4) && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)L0454_i_PrimaryDirectionToOrFromParty), false))) { AL0450_i_DestinationMapX = eventMapX; AL0451_i_DestinationMapY = eventMapY; AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction]; @@ -885,8 +885,8 @@ T0209089_DoubleSquareMove: f203_getFirstPossibleMovementDirOrdinal(&L0448_s_CreatureInfo, eventMapX, eventMapY, false); /* BUG0_00 Useless code. Returned value is ignored. When Lord Chaos teleports two squares away the ability to move to the first square is ignored which means Lord Chaos can teleport through walls or any other obstacle */ if (f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = L0454_i_PrimaryDirectionToOrFromParty) || f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = _vm->_projexpl->_g363_secondaryDirToOrFromParty) || - (_g386_fluxCageCount && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)AL0446_i_Direction))) || - ((_g386_fluxCageCount >= 2) && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((direction)L0454_i_PrimaryDirectionToOrFromParty)))) { + (_g386_fluxCageCount && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)AL0446_i_Direction))) || + ((_g386_fluxCageCount >= 2) && f204_isArchenemyDoubleMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction = returnOppositeDir((Direction)L0454_i_PrimaryDirectionToOrFromParty)))) { AL0450_i_DestinationMapX = eventMapX; AL0451_i_DestinationMapY = eventMapY; AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2; @@ -925,8 +925,8 @@ T0209096_SetBehavior0_Wander: AL0451_i_TargetMapY = L0445_ps_ActiveGroup->_targetMapY; } /* Try and flee from the party (opposite direction) */ - L0454_i_PrimaryDirectionToOrFromParty = returnOppositeDir((direction)f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY)); - _vm->_projexpl->_g363_secondaryDirToOrFromParty = returnOppositeDir((direction)_vm->_projexpl->_g363_secondaryDirToOrFromParty); + L0454_i_PrimaryDirectionToOrFromParty = returnOppositeDir((Direction)f228_getDirsWhereDestIsVisibleFromSource(eventMapX, eventMapY, AL0450_i_TargetMapX, AL0451_i_TargetMapY)); + _vm->_projexpl->_g363_secondaryDirToOrFromParty = returnOppositeDir((Direction)_vm->_projexpl->_g363_secondaryDirToOrFromParty); L0461_i_MovementTicks -= (L0461_i_MovementTicks >> 2); goto T0209085_SingleSquareMove; } @@ -996,7 +996,7 @@ T0209096_SetBehavior0_Wander: AL0446_i_Cell++; } if (!_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = M21_normalizeModulo4(AL0446_i_Cell)) || - (_vm->getRandomNumber(2) && !_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */ + (_vm->getRandomNumber(2) && !_vm->_groupMan->f176_getCreatureOrdinalInCell(L0444_ps_Group, AL0446_i_Cell = returnOppositeDir((Direction)AL0446_i_Cell)))) { /* If the selected cell (or the opposite cell) is not already occupied by a creature */ if (_vm->_projexpl->f218_projectileGetImpactCount(kM1_CreatureElemType, eventMapX, eventMapY, L0445_ps_ActiveGroup->_cells) && (_vm->_projexpl->_g364_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)) /* BUG0_70 A projectile impact on a creature may be ignored. The function F0218_PROJECTILE_GetImpactCount to detect projectile impacts when a quarter square sized creature moves inside a group (to another cell on the same square) may fail if there are several creatures in the group because the function expects a single cell index for its last parameter. The function should be called once for each cell where there is a creature */ goto T0209139_Return; if (_vm->_projexpl->_g364_creatureDamageOutcome != k1_outcomeKilledSomeCreaturesInGroup) { @@ -1072,7 +1072,7 @@ bool GroupMan::f202_isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, i if (creatureInfo->_movementTicks == k255_immobile) { return false; } - _vm->_dungeonMan->f150_mapCoordsAfterRelMovement((direction)dir, 1, 0, mapX, mapY); + _vm->_dungeonMan->f150_mapCoordsAfterRelMovement((Direction)dir, 1, 0, mapX, mapY); L0428_i_MapX = mapX; L0429_i_MapY = mapY; if (_g387_groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter = @@ -1333,7 +1333,7 @@ void GroupMan::f205_setDirection(ActiveGroup *activeGroup, int16 dir, int16 crea G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime = _vm->_g313_gameTime; G0396_ps_TwoHalfSquareSizedCreaturesGroupLastDirectionSetActiveGroup = activeGroup; } - activeGroup->_directions = (direction)L0435_ui_GroupDirections; + activeGroup->_directions = (Direction)L0435_ui_GroupDirections; } void GroupMan::f208_groupAddEvent(TimelineEvent *event, uint32 time) { @@ -1488,7 +1488,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy); AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy); _vm->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, mapX, mapY, k0_soundModePlayImmediately); - _vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8); + _vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (Direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8); } else { if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) { AL0439_i_ChampionIndex = _vm->getRandomNumber(4); @@ -1510,7 +1510,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui Champion *L0442_ps_Champion = &_vm->_championMan->_gK71_champions[AL0439_i_ChampionIndex]; if (AL0440_i_Damage > L0442_ps_Champion->_maximumDamageReceived) { L0442_ps_Champion->_maximumDamageReceived = AL0440_i_Damage; - L0442_ps_Champion->_directionMaximumDamageReceived = returnOppositeDir((direction)L0438_ui_PrimaryDirectionToParty); + L0442_ps_Champion->_directionMaximumDamageReceived = returnOppositeDir((Direction)L0438_ui_PrimaryDirectionToParty); } } } @@ -1710,7 +1710,7 @@ void GroupMan::f183_addActiveGroup(Thing thing, int16 mapX, int16 mapY) { L0341_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime - 127; L0339_ui_CreatureIndex = L0340_ps_Group->getCount(); do { - L0341_ps_ActiveGroup->_directions = (direction)f178_getGroupValueUpdatedWithCreatureValue(L0341_ps_ActiveGroup->_directions, L0339_ui_CreatureIndex, L0340_ps_Group->getDir()); + L0341_ps_ActiveGroup->_directions = (Direction)f178_getGroupValueUpdatedWithCreatureValue(L0341_ps_ActiveGroup->_directions, L0339_ui_CreatureIndex, L0340_ps_Group->getDir()); L0341_ps_ActiveGroup->_aspect[L0339_ui_CreatureIndex] = 0; } while (L0339_ui_CreatureIndex--); f179_getCreatureAspectUpdateTime(L0341_ps_ActiveGroup, kM1_wholeCreatureGroup, false); @@ -1770,7 +1770,7 @@ void GroupMan::f195_addAllActiveGroups() { } } -Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY) { +Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, Direction dir, int16 mapX, int16 mapY) { Thing L0349_T_GroupThing; uint16 L0350_ui_BaseHealth; uint16 L0351_ui_Cell = 0; @@ -2082,7 +2082,7 @@ void GroupMan::load1_ActiveGroupPart(Common::InSaveFile* file) { for (uint16 i = 0; i < _g376_maxActiveGroupCount; ++i) { ActiveGroup *group = &_g375_activeGroups[i]; group->_groupThingIndex = file->readUint16BE(); - group->_directions = (direction)file->readUint16BE(); + group->_directions = (Direction)file->readUint16BE(); group->_cells = file->readByte(); group->_lastMoveTime = file->readByte(); group->_delayFleeingFromTarget = file->readByte(); diff --git a/engines/dm/group.h b/engines/dm/group.h index 1447783ffc..5194b907fd 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -93,7 +93,7 @@ enum CreatureType { class ActiveGroup { public: int16 _groupThingIndex; - direction _directions; + Direction _directions; byte _cells; byte _lastMoveTime; byte _delayFleeingFromTarget; @@ -130,7 +130,7 @@ public: uint16 setBehaviour(uint16 val) { _flags = (_flags & ~0xF) | (val & 0xF); return (val & 0xF); } uint16 getCount() { return (_flags >> 5) & 0x3; } void setCount(uint16 val) { _flags = (_flags & ~(0x3 << 5)) | ((val & 0x3) << 5); } - direction getDir() { return (direction)((_flags >> 8) & 0x3); } + Direction getDir() { return (Direction)((_flags >> 8) & 0x3); } void setDir(uint16 val) { _flags = (_flags & ~(0x3 << 8)) | ((val & 0x3) << 8); } uint16 getDoNotDiscard() { return (_flags >> 10) & 0x1; } void setDoNotDiscard(bool val) { _flags = (_flags & ~(1 << 10)) | ((val & 1) << 10); } @@ -234,7 +234,7 @@ public: void f184_removeActiveGroup(uint16 activeGroupIndex); // @ F0184_GROUP_RemoveActiveGroup void f194_removeAllActiveGroups(); // @ F0194_GROUP_RemoveAllActiveGroups void f195_addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups - Thing f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated + Thing f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, Direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated bool f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY); // @ F0223_GROUP_IsSquareACorridorTeleporterPitOrDoor int16 f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 paryY, uint16 champCell); // @ F0177_GROUP_GetMeleeTargetCreatureOrdinal diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 138f9fd7ed..a19cef20b9 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -83,7 +83,7 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) { _championMan->_g305_partyChampionCount = file->readUint16BE(); _dungeonMan->_g306_partyMapX = file->readSint16BE(); _dungeonMan->_g307_partyMapY = file->readSint16BE(); - _dungeonMan->_g308_partyDir = (direction)file->readUint16BE(); + _dungeonMan->_g308_partyDir = (Direction)file->readUint16BE(); _dungeonMan->_g309_partyMapIndex = file->readByte(); _championMan->_g411_leaderIndex = (ChampionIndex)file->readSint16BE(); _championMan->_g514_magicCasterChampionIndex = (ChampionIndex)file->readSint16BE(); diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 5a4c8742c7..54ce632590 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -215,7 +215,7 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() { && (champ->_maximumDamageReceived) && (champ->_dir != champ->_directionMaximumDamageReceived)) { - champ->_dir = (direction)champ->_directionMaximumDamageReceived; + champ->_dir = (Direction)champ->_directionMaximumDamageReceived; champ->setAttributeFlag(k0x0400_ChampionAttributeIcon, true); champMan.f292_drawChampionState((ChampionIndex)champIndex); } diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 89b369386a..1011b4240c 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -377,7 +377,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 } L0716_ui_Direction = _vm->_dungeonMan->f155_getStairsExitDirection(destMapX, destMapY); destMapX += _vm->_dirIntoStepCountEast[L0716_ui_Direction], destMapY += _vm->_dirIntoStepCountNorth[L0716_ui_Direction]; - L0716_ui_Direction = returnOppositeDir((direction)L0716_ui_Direction); + L0716_ui_Direction = returnOppositeDir((Direction)L0716_ui_Direction); AL0727_ui_ThingCell = thing.getCell(); AL0727_ui_ThingCell = M21_normalizeModulo4((((AL0727_ui_ThingCell - L0716_ui_Direction + 1) & 0x0002) >> 1) + L0716_ui_Direction); thing = M15_thingWithNewCell(thing, AL0727_ui_ThingCell); diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index 8996693f4b..06ba83afd8 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -45,7 +45,7 @@ ProjExpl::ProjExpl(DMEngine* vm) : _vm(vm) { _g362_lastPartyMovementTime = 0; } -void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, direction dir, byte kineticEnergy, byte attack, byte stepEnergy) { +void ProjExpl::f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, Direction dir, byte kineticEnergy, byte attack, byte stepEnergy) { Thing L0466_T_ProjectileThing; Projectile* L0467_ps_Projectile; TimelineEvent L0468_s_Event; @@ -482,7 +482,7 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) { _vm->_movsens->f267_getMoveResult(L0515_T_ProjectileThingNewCell, L0525_i_SourceMapX, L0526_i_SourceMapY, L0523_i_DestinationMapX, L0524_i_DestinationMapY); L0519_ps_Event->_C._projectile.setMapX(_vm->_movsens->_g397_moveResultMapX); L0519_ps_Event->_C._projectile.setMapY(_vm->_movsens->_g398_moveResultMapY); - L0519_ps_Event->_C._projectile.setDir((direction)_vm->_movsens->_g400_moveResultDir); + L0519_ps_Event->_C._projectile.setDir((Direction)_vm->_movsens->_g400_moveResultDir); L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_movsens->_g401_moveResultCell); M31_setMap(L0519_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex); } else { diff --git a/engines/dm/projexpl.h b/engines/dm/projexpl.h index d0e030f719..0d6f3b66c0 100644 --- a/engines/dm/projexpl.h +++ b/engines/dm/projexpl.h @@ -88,7 +88,7 @@ public: int16 _g367_projectileAttackType; // @ G0367_i_ProjectileAttackType int32 _g362_lastPartyMovementTime; // @ G0362_l_LastPartyMovementTime explicit ProjExpl(DMEngine *vm); - void f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, direction dir, + void f212_projectileCreate(Thing thing, int16 mapX, int16 mapY, uint16 cell, Direction dir, byte kineticEnergy, byte attack, byte stepEnergy); // @ F0212_PROJECTILE_Create bool f217_projectileHasImpactOccurred(int16 impactType, int16 mapXCombo, int16 mapYCombo, int16 cell, Thing projectileThing); // @ F0217_PROJECTILE_HasImpactOccured diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 09e31bf935..33bfc61555 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -582,7 +582,7 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) { L0647_ps_Event = &_vm->_timeline->_g370_events[L0646_ps_Projectile->_eventIndex]; L0647_ps_Event->_C._projectile.setMapX(_vm->_movsens->_g397_moveResultMapX); L0647_ps_Event->_C._projectile.setMapY(_vm->_movsens->_g398_moveResultMapY); - L0647_ps_Event->_C._projectile.setDir((direction)_vm->_movsens->_g400_moveResultDir); + L0647_ps_Event->_C._projectile.setDir((Direction)_vm->_movsens->_g400_moveResultDir); L0647_ps_Event->_B._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_movsens->_g401_moveResultCell).toUint16(); M31_setMap(L0647_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex); } else { @@ -734,7 +734,7 @@ void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* eve L0626_i_MapX = event->_B._location._mapX; L0627_i_MapY = event->_B._location._mapY; L0624_ui_Cell = event->_C.A._cell; - L0628_ui_ProjectileCell = returnOppositeDir((direction)L0624_ui_Cell); + L0628_ui_ProjectileCell = returnOppositeDir((Direction)L0624_ui_Cell); L0625_i_SensorType = sensor->getType(); L0629_i_SensorData = sensor->getData(); L0630_i_KineticEnergy = sensor->M47_kineticEnergy(); @@ -785,9 +785,9 @@ void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* eve } L0626_i_MapX += _vm->_dirIntoStepCountEast[L0624_ui_Cell], L0627_i_MapY += _vm->_dirIntoStepCountNorth[L0624_ui_Cell]; /* BUG0_20 The game crashes if the launcher sensor is on a map boundary and shoots in a direction outside the map */ _vm->_projexpl->_g365_createLanucherProjectile = true; - _vm->_projexpl->f212_projectileCreate(L0622_T_FirstProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, L0628_ui_ProjectileCell, (direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy); + _vm->_projexpl->f212_projectileCreate(L0622_T_FirstProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, L0628_ui_ProjectileCell, (Direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy); if (!L0632_B_LaunchSingleProjectile) { - _vm->_projexpl->f212_projectileCreate(L0623_T_SecondProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, returnNextVal(L0628_ui_ProjectileCell), (direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy); + _vm->_projexpl->f212_projectileCreate(L0623_T_SecondProjectileAssociatedThing, L0626_i_MapX, L0627_i_MapY, returnNextVal(L0628_ui_ProjectileCell), (Direction)L0624_ui_Cell, L0630_i_KineticEnergy, 100, L0631_i_StepEnergy); } _vm->_projexpl->_g365_createLanucherProjectile = false; } @@ -837,7 +837,7 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) { if ((AL0618_ui_HealthMultiplier = L0614_ps_Sensor->M45_healthMultiplier()) == 0) { AL0618_ui_HealthMultiplier = _vm->_dungeonMan->_g269_currMap->_difficulty; } - _vm->_groupMan->f185_groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY); + _vm->_groupMan->f185_groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (Direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY); if (L0614_ps_Sensor->getAudibleA()) { _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0616_ui_MapX, L0617_ui_MapY, k1_soundModePlayIfPrioritized); } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index bb9b781d91..ffc6cc7fed 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -131,11 +131,11 @@ public: public: uint16 getMapX() { return _backing & 0x1F; } uint16 getMapY() { return (_backing >> 5) & 0x1F; } - direction getDir() { return (direction)((_backing >> 10) & 0x3); } + Direction getDir() { return (Direction)((_backing >> 10) & 0x3); } uint16 getStepEnergy() { return (_backing >> 12) & 0xF; } void setMapX(uint16 val) { _backing = (_backing & ~0x1F) | (val & 0x1F); } void setMapY(uint16 val) { _backing = (_backing & ~(0x1F << 5)) | ((val & 0x1F) << 5); } - void setDir(direction val) { _backing = (_backing & ~(0x3 << 10)) | ((val & 0x3) << 10); } + void setDir(Direction val) { _backing = (_backing & ~(0x3 << 10)) | ((val & 0x3) << 10); } void setStepEnergy(uint16 val) { _backing = (_backing & ~(0xF << 12)) | ((val & 0xF) << 12); } } _projectile; -- cgit v1.2.3 From 58d82353442ff5cef4d17510a9610b87e5a0b9ee Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2016 15:53:22 +0200 Subject: DM: Refactor f320_applyAndDrawPendingDamageAndWounds --- engines/dm/champion.cpp | 132 ++++++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 3c0d08ac2c..3fdc9ec486 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1324,81 +1324,81 @@ void ChampionMan::f326_championShootProjectile(Champion* champ, Thing thing, int } void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() { - uint16 L0967_ui_ChampionIndex; - uint16 L0968_ui_PendingDamage; - int16 L0969_i_Multiple; -#define AL0969_i_Health L0969_i_Multiple -#define AL0969_i_X L0969_i_Multiple -#define AL0969_i_EventIndex L0969_i_Multiple - int16 L0970_i_PendingWounds; - Champion* L0971_ps_Champion; - TimelineEvent* L0972_ps_Event; - int16 L0973_i_Y; - TimelineEvent L0974_s_Event; - Box L0975_s_Box; - - - L0971_ps_Champion = _vm->_championMan->_gK71_champions; - for (L0967_ui_ChampionIndex = k0_ChampionFirst; L0967_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0967_ui_ChampionIndex++, L0971_ps_Champion++) { - setFlag(L0971_ps_Champion->_wounds, L0970_i_PendingWounds = _g410_championPendingWounds[L0967_ui_ChampionIndex]); - _g410_championPendingWounds[L0967_ui_ChampionIndex] = 0; - if (!(L0968_ui_PendingDamage = _g409_championPendingDamage[L0967_ui_ChampionIndex])) + Champion *championPtr = _vm->_championMan->_gK71_champions; + for (uint16 championIndex = k0_ChampionFirst; championIndex < _vm->_championMan->_g305_partyChampionCount; championIndex++, championPtr++) { + int16 pendingWounds = _g410_championPendingWounds[championIndex]; + setFlag(championPtr->_wounds, pendingWounds); + _g410_championPendingWounds[championIndex] = 0; + uint16 pendingDamage = _g409_championPendingDamage[championIndex]; + if (!pendingDamage) continue; - _g409_championPendingDamage[L0967_ui_ChampionIndex] = 0; - if (!(AL0969_i_Health = L0971_ps_Champion->_currHealth)) + + _g409_championPendingDamage[championIndex] = 0; + int16 curHealth = championPtr->_currHealth; + if (!curHealth) continue; - if ((AL0969_i_Health = AL0969_i_Health - L0968_ui_PendingDamage) <= 0) { - _vm->_championMan->f319_championKill(L0967_ui_ChampionIndex); + + curHealth -= pendingDamage; + if (curHealth <= 0) { + _vm->_championMan->f319_championKill(championIndex); } else { - L0971_ps_Champion->_currHealth = AL0969_i_Health; - setFlag(L0971_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); - if (L0970_i_PendingWounds) { - setFlag(L0971_ps_Champion->_attributes, k0x2000_ChampionAttributeWounds); + championPtr->_currHealth = curHealth; + setFlag(championPtr->_attributes, k0x0100_ChampionAttributeStatistics); + if (pendingWounds) { + setFlag(championPtr->_attributes, k0x2000_ChampionAttributeWounds); } - AL0969_i_X = L0967_ui_ChampionIndex * k69_ChampionStatusBoxSpacing; - L0975_s_Box._y1 = 0; + + int16 textPosX = championIndex * k69_ChampionStatusBoxSpacing; + int16 textPosY; + + Box blitBox; + blitBox._y1 = 0; _vm->_eventMan->f78_showMouse(); - if (_vm->M0_indexToOrdinal(L0967_ui_ChampionIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) { - L0975_s_Box._y2 = 28; - L0975_s_Box._x2 = (L0975_s_Box._x1 = AL0969_i_X + 7) + 31; /* Box is over the champion portrait in the status box */ - _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k16_damageToChampionBig), &L0975_s_Box, k16_byteWidth, k10_ColorFlesh, 29); - if (L0968_ui_PendingDamage < 10) { /* 1 digit */ - AL0969_i_X += 21; - } else { - if (L0968_ui_PendingDamage < 100) { /* 2 digits */ - AL0969_i_X += 18; - } else { /* 3 digits */ - AL0969_i_X += 15; - } - } - L0973_i_Y = 16; + + if (_vm->M0_indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) { + blitBox._y2 = 28; + blitBox._x1 = textPosX + 7; + blitBox._x2 = blitBox._x1 + 31; /* Box is over the champion portrait in the status box */ + _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k16_damageToChampionBig), &blitBox, k16_byteWidth, k10_ColorFlesh, 29); + // Check the number of digits and sets the position accordingly. + if (pendingDamage < 10) // 1 digit + textPosX += 21; + else if (pendingDamage < 100) // 2 digits + textPosX += 18; + else // 3 digits + textPosX += 15; + + textPosY = 16; } else { - L0975_s_Box._y2 = 6; - L0975_s_Box._x2 = (L0975_s_Box._x1 = AL0969_i_X) + 47; /* Box is over the champion name in the status box */ - _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k15_damageToChampionSmallIndice), &L0975_s_Box, k24_byteWidth, k10_ColorFlesh, 7); - if (L0968_ui_PendingDamage < 10) { /* 1 digit */ - AL0969_i_X += 19; - } else { - if (L0968_ui_PendingDamage < 100) { /* 2 digits */ - AL0969_i_X += 16; - } else { /* 3 digits */ - AL0969_i_X += 13; - } - } - L0973_i_Y = 5; + blitBox._y2 = 6; + blitBox._x1 = textPosX; + blitBox._x2 = blitBox._x1 + 47; /* Box is over the champion name in the status box */ + _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k15_damageToChampionSmallIndice), &blitBox, k24_byteWidth, k10_ColorFlesh, 7); + // Check the number of digits and sets the position accordingly. + if (pendingDamage < 10) // 1 digit + textPosX += 19; + else if (pendingDamage < 100) // 2 digits + textPosX += 16; + else //3 digits + textPosX += 13; + + textPosY = 5; } - _vm->_textMan->f53_printToLogicalScreen(AL0969_i_X, L0973_i_Y, k15_ColorWhite, k8_ColorRed, _vm->_championMan->f288_getStringFromInteger(L0968_ui_PendingDamage, false, 3).c_str()); - if ((AL0969_i_EventIndex = L0971_ps_Champion->_hideDamageReceivedIndex) == -1) { - L0974_s_Event._type = k12_TMEventTypeHideDamageReceived; - M33_setMapAndTime(L0974_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5); - L0974_s_Event._priority = L0967_ui_ChampionIndex; - L0971_ps_Champion->_hideDamageReceivedIndex = _vm->_timeline->f238_addEventGetEventIndex(&L0974_s_Event); + _vm->_textMan->f53_printToLogicalScreen(textPosX, textPosY, k15_ColorWhite, k8_ColorRed, _vm->_championMan->f288_getStringFromInteger(pendingDamage, false, 3).c_str()); + + int16 eventIndex = championPtr->_hideDamageReceivedIndex; + if (eventIndex == -1) { + TimelineEvent newEvent; + newEvent._type = k12_TMEventTypeHideDamageReceived; + M33_setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5); + newEvent._priority = championIndex; + championPtr->_hideDamageReceivedIndex = _vm->_timeline->f238_addEventGetEventIndex(&newEvent); } else { - L0972_ps_Event = &_vm->_timeline->_g370_events[AL0969_i_EventIndex]; - M33_setMapAndTime(L0972_ps_Event->_mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5); - _vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(AL0969_i_EventIndex)); + TimelineEvent *curEvent = &_vm->_timeline->_g370_events[eventIndex]; + M33_setMapAndTime(curEvent->_mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5); + _vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(eventIndex)); } - _vm->_championMan->f292_drawChampionState((ChampionIndex)L0967_ui_ChampionIndex); + _vm->_championMan->f292_drawChampionState((ChampionIndex)championIndex); _vm->_eventMan->f77_hideMouse(); } } -- cgit v1.2.3 From cdbbc15e5623f47a0e93e5d9113ac64b709cf6de Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2016 16:13:53 +0200 Subject: DM: Refactor f318_dropAllObjects, f319_championKill and f323_unpoison. Rename _moveSens --- engines/dm/champion.cpp | 114 +++++++++++++++++++++------------------------- engines/dm/dm.cpp | 10 ++-- engines/dm/dm.h | 2 +- engines/dm/dungeonman.cpp | 2 +- engines/dm/eventman.cpp | 22 ++++----- engines/dm/group.cpp | 24 +++++----- engines/dm/menus.cpp | 8 ++-- engines/dm/projexpl.cpp | 16 +++---- engines/dm/timeline.cpp | 36 +++++++-------- 9 files changed, 112 insertions(+), 122 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 3fdc9ec486..9b14993d8b 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1405,16 +1405,9 @@ void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() { } void ChampionMan::f319_championKill(uint16 champIndex) { - uint16 L0962_ui_Multiple = 0; -#define AL0962_ui_Cell L0962_ui_Multiple -#define AL0962_ui_ChampionIconIndex L0962_ui_Multiple - int16 L0963_i_AliveChampionIndex; - Thing L0964_T_Thing; - Champion* L0965_ps_Champion; - - L0965_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex]; - L0965_ps_Champion->_currHealth = 0; - setFlag(L0965_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox); + Champion *curChampion = &_vm->_championMan->_gK71_champions[champIndex]; + curChampion->_currHealth = 0; + setFlag(curChampion->_attributes, k0x1000_ChampionAttributeStatusBox); if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) { if (_vm->_g331_pressingEye) { _vm->_g331_pressingEye = false; @@ -1424,63 +1417,65 @@ void ChampionMan::f319_championKill(uint16 champIndex) { } _vm->_eventMan->_g587_hideMousePointerRequestCount = 1; _vm->_eventMan->f77_hideMouse(); - } else { - if (_vm->_g333_pressingMouth) { - _vm->_g333_pressingMouth = false; - _vm->_eventMan->_g597_ignoreMouseMovements = false; - _vm->_eventMan->_g587_hideMousePointerRequestCount = 1; - _vm->_eventMan->f77_hideMouse(); - } + } else if (_vm->_g333_pressingMouth) { + _vm->_g333_pressingMouth = false; + _vm->_eventMan->_g597_ignoreMouseMovements = false; + _vm->_eventMan->_g587_hideMousePointerRequestCount = 1; + _vm->_eventMan->f77_hideMouse(); } _vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory); } f318_dropAllObjects(champIndex); - L0964_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k0x8000_championBones | k10_JunkThingType); - if (L0964_T_Thing == Thing::_none) { - } else { - Junk* L0966_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0964_T_Thing); + Thing unusedThing = _vm->_dungeonMan->f166_getUnusedThing(k0x8000_championBones | k10_JunkThingType); + uint16 curCell = 0; + if (unusedThing != Thing::_none) { + Junk *L0966_ps_Junk = (Junk *)_vm->_dungeonMan->f156_getThingData(unusedThing); L0966_ps_Junk->setType(k5_JunkTypeBones); L0966_ps_Junk->setDoNotDiscard(true); L0966_ps_Junk->setChargeCount(champIndex); - AL0962_ui_Cell = L0965_ps_Champion->_cell; - _vm->_movsens->f267_getMoveResult(M15_thingWithNewCell(L0964_T_Thing, AL0962_ui_Cell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); - } - L0965_ps_Champion->_symbolStep = 0; - L0965_ps_Champion->_symbols[0] = '\0'; - L0965_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir; - L0965_ps_Champion->_maximumDamageReceived = 0; - AL0962_ui_ChampionIconIndex = _vm->_championMan->M26_championIconIndex(AL0962_ui_Cell, _vm->_dungeonMan->_g308_partyDir); - if (_vm->M0_indexToOrdinal(AL0962_ui_ChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) { + curCell = curChampion->_cell; + _vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(unusedThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); + } + curChampion->_symbolStep = 0; + curChampion->_symbols[0] = '\0'; + curChampion->_dir = _vm->_dungeonMan->_g308_partyDir; + curChampion->_maximumDamageReceived = 0; + uint16 curChampionIconIndex = _vm->_championMan->M26_championIconIndex(curCell, _vm->_dungeonMan->_g308_partyDir); + if (_vm->M0_indexToOrdinal(curChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) { _vm->_eventMan->_g598_mousePointerBitmapUpdated = true; _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone); warning(false, "IGNORED CODE:G0592_B_BuildMousePointerScreenAreaRequested = true"); } - if (L0965_ps_Champion->_poisonEventCount) { + + if (curChampion->_poisonEventCount) f323_unpoison(champIndex); - } + _vm->_displayMan->_g578_useByteBoxCoordinates = false; - _vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0962_ui_ChampionIconIndex << 2], k0_ColorBlack); + _vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[curChampionIconIndex << 2], k0_ColorBlack); _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); - for (L0963_i_AliveChampionIndex = k0_ChampionFirst, L0965_ps_Champion = _vm->_championMan->_gK71_champions; L0963_i_AliveChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0963_i_AliveChampionIndex++, L0965_ps_Champion++) { - if (L0965_ps_Champion->_currHealth) + + int16 aliveChampionIndex; + for (aliveChampionIndex = k0_ChampionFirst, curChampion = _vm->_championMan->_gK71_champions; aliveChampionIndex < _vm->_championMan->_g305_partyChampionCount; aliveChampionIndex++, curChampion++) { + if (curChampion->_currHealth) break; } - if (L0963_i_AliveChampionIndex == _vm->_championMan->_g305_partyChampionCount) { /* BUG0_43 The game does not end if the last living champion in the party is killed while looking at a candidate champion in a portrait. The condition to end the game when the whole party is killed is not true because the code considers the candidate champion as alive (in the loop above) */ + + if (aliveChampionIndex == _vm->_championMan->_g305_partyChampionCount) { /* BUG0_43 The game does not end if the last living champion in the party is killed while looking at a candidate champion in a portrait. The condition to end the game when the whole party is killed is not true because the code considers the candidate champion as alive (in the loop above) */ _vm->_championMan->_g303_partyDead = true; return; } - if (champIndex == _vm->_championMan->_g411_leaderIndex) { - _vm->_eventMan->f368_commandSetLeader((ChampionIndex)L0963_i_AliveChampionIndex); - } - if (champIndex == _vm->_championMan->_g514_magicCasterChampionIndex) { - _vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(L0963_i_AliveChampionIndex); - } else { + + if (champIndex == _vm->_championMan->_g411_leaderIndex) + _vm->_eventMan->f368_commandSetLeader((ChampionIndex)aliveChampionIndex); + + if (champIndex == _vm->_championMan->_g514_magicCasterChampionIndex) + _vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(aliveChampionIndex); + else _vm->_menuMan->f393_drawSpellAreaControls(_vm->_championMan->_g514_magicCasterChampionIndex); - } } void ChampionMan::f318_dropAllObjects(uint16 champIndex) { - static int16 G0057_ai_Graphic562_SlotDropOrder[30] = { + static const int16 slotDropOrder[30] = { k5_ChampionSlotFeet, k4_ChampionSlotLegs, k9_ChampionSlotQuiverLine_2_2, @@ -1510,31 +1505,26 @@ void ChampionMan::f318_dropAllObjects(uint16 champIndex) { k10_ChampionSlotNeck, k2_ChampionSlotHead, k0_ChampionSlotReadyHand, - k1_ChampionSlotActionHand}; - - uint16 L0959_ui_Cell; - Thing L0960_T_Thing; - uint16 L0961_ui_SlotIndex; + k1_ChampionSlotActionHand + }; - L0959_ui_Cell = _vm->_championMan->_gK71_champions[champIndex]._cell; - for (L0961_ui_SlotIndex = k0_ChampionSlotReadyHand; L0961_ui_SlotIndex < k30_ChampionSlotChest_1; L0961_ui_SlotIndex++) { - if ((L0960_T_Thing = f300_getObjectRemovedFromSlot(champIndex, G0057_ai_Graphic562_SlotDropOrder[L0961_ui_SlotIndex])) != Thing::_none) { - _vm->_movsens->f267_getMoveResult(M15_thingWithNewCell(L0960_T_Thing, L0959_ui_Cell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); + uint16 curCell = _vm->_championMan->_gK71_champions[champIndex]._cell; + for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) { + Thing curThing = f300_getObjectRemovedFromSlot(champIndex, slotDropOrder[slotIndex]); + if (curThing != Thing::_none) { + _vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); } } } void ChampionMan::f323_unpoison(int16 champIndex) { - int16 L0982_i_EventIndex; - TimelineEvent* L0983_ps_Event; - - if (champIndex == kM1_ChampionNone) { + if (champIndex == kM1_ChampionNone) return; - } - for (L0982_i_EventIndex = 0, L0983_ps_Event = _vm->_timeline->_g370_events; L0982_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0983_ps_Event++, L0982_i_EventIndex++) { - if ((L0983_ps_Event->_type == k75_TMEventTypePoisonChampion) && (L0983_ps_Event->_priority == champIndex)) { - _vm->_timeline->f237_deleteEvent(L0982_i_EventIndex); - } + + TimelineEvent *eventPtr = _vm->_timeline->_g370_events; + for (uint16 eventIndex = 0; eventIndex < _vm->_timeline->_g369_eventMaxCount; eventPtr++, eventIndex++) { + if ((eventPtr->_type == k75_TMEventTypePoisonChampion) && (eventPtr->_priority == champIndex)) + _vm->_timeline->f237_deleteEvent(eventIndex); } _vm->_championMan->_gK71_champions[champIndex]._poisonEventCount = 0; } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 5d003b7373..5671fc6fcf 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -144,7 +144,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _objectMan = nullptr; _inventoryMan = nullptr; _textMan = nullptr; - _movsens = nullptr; + _moveSens = nullptr; _groupMan = nullptr; _timeline = nullptr; _projexpl = nullptr; @@ -195,7 +195,7 @@ DMEngine::~DMEngine() { delete _objectMan; delete _inventoryMan; delete _textMan; - delete _movsens; + delete _moveSens; delete _groupMan; delete _timeline; delete _projexpl; @@ -241,7 +241,7 @@ void DMEngine::f463_initializeGame() { f462_startGame(); if (_g298_newGame) - _movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); + _moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); _eventMan->f78_showMouse(); _eventMan->f357_discardAllInput(); } @@ -314,7 +314,7 @@ Common::Error DMEngine::run() { _objectMan = new ObjectMan(this); _inventoryMan = new InventoryMan(this); _textMan = new TextMan(this); - _movsens = new MovesensMan(this); + _moveSens = new MovesensMan(this); _groupMan = new GroupMan(this); _timeline = new Timeline(this); _projexpl = new ProjExpl(this); @@ -341,7 +341,7 @@ void DMEngine::f2_gameloop() { if (_g327_newPartyMapIndex != kM1_mapIndexNone) { T0002002: f3_processNewPartyMap(_g327_newPartyMapIndex); - _movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); + _moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); _g327_newPartyMapIndex = kM1_mapIndexNone; _eventMan->f357_discardAllInput(); } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index c1881a0638..7d2f925120 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -240,7 +240,7 @@ public: ObjectMan *_objectMan; InventoryMan *_inventoryMan; TextMan *_textMan; - MovesensMan *_movsens; + MovesensMan *_moveSens; GroupMan *_groupMan; Timeline *_timeline; ProjExpl *_projexpl; diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index e01a154dc3..38658ce601 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -1509,7 +1509,7 @@ Thing DungeonMan::f165_getDiscardTHing(uint16 thingType) { continue; T0165026: _vm->_dungeonMan->f173_setCurrentMap(L0279_ui_MapIndex); - _vm->_movsens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0); + _vm->_moveSens->f267_getMoveResult(L0278_T_Thing, L0276_ui_MapX, L0277_ui_MapY, kM1_MapXNotOnASquare, 0); } _vm->_dungeonMan->f173_setCurrentMap(L0284_i_CurrentMapIndex); G0294_auc_LastDiscardedThingMapIndex[thingType] = L0279_ui_MapIndex; diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 8851e28dcb..7ccf647e7d 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -806,9 +806,9 @@ void EventManager::f365_commandTurnParty(CommandType cmdType) { f364_commandTakeStairs(getFlag(L1114_ui_Square, k0x0004_StairsUp)); return; } - _vm->_movsens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, false); + _vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, false); _vm->_championMan->f284_setPartyDirection(M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + ((cmdType == k2_CommandTurnRight) ? 1 : 3))); - _vm->_movsens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, true); + _vm->_moveSens->f276_sensorProcessThingAdditionOrRemoval(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, Thing::_party, true, true); } void EventManager::f366_commandMoveParty(CommandType cmdType) { @@ -864,7 +864,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) { _vm->_dungeonMan->f150_mapCoordsAfterRelMovement(_vm->_dungeonMan->_g308_partyDir, g465_movementArrowToStepForwardCount[AL1118_ui_MovementArrowIndex], g466_movementArrowToSepRightCount[AL1118_ui_MovementArrowIndex], L1121_i_MapX, L1122_i_MapY); L1116_i_SquareType = Square(AL1115_ui_Square = _vm->_dungeonMan->f151_getSquare(L1121_i_MapX, L1122_i_MapY).toByte()).getType(); if (L1116_i_SquareType == k3_ElementTypeStairs) { - _vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0); + _vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0); _vm->_dungeonMan->_g306_partyMapX = L1121_i_MapX; _vm->_dungeonMan->_g307_partyMapY = L1122_i_MapY; f364_commandTakeStairs(getFlag(AL1115_ui_Square, k0x0004_StairsUp)); @@ -905,9 +905,9 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) { return; } if (L1123_B_StairsSquare) { - _vm->_movsens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, L1121_i_MapX, L1122_i_MapY); + _vm->_moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, L1121_i_MapX, L1122_i_MapY); } else { - _vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1121_i_MapX, L1122_i_MapY); + _vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1121_i_MapX, L1122_i_MapY); } AL1115_ui_Ticks = 1; L1119_ps_Champion = _vm->_championMan->_gK71_champions; @@ -1003,7 +1003,7 @@ void EventManager::f372_commandProcessType80ClickInDungeonViewTouchFrontWall() { L1136_ui_MapY = _vm->_dungeonMan->_g307_partyMapY; L1135_ui_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1136_ui_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir]; if ((L1135_ui_MapX >= 0) && (L1135_ui_MapX < _vm->_dungeonMan->_g273_currMapWidth) && (L1136_ui_MapY >= 0) && (L1136_ui_MapY < _vm->_dungeonMan->_g274_currMapHeight)) { - _vm->_g321_stopWaitingForPlayerInput = _vm->_movsens->f275_sensorIsTriggeredByClickOnWall(L1135_ui_MapX, L1136_ui_MapY, returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)); + _vm->_g321_stopWaitingForPlayerInput = _vm->_moveSens->f275_sensorIsTriggeredByClickOnWall(L1135_ui_MapX, L1136_ui_MapY, returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)); } } @@ -1028,7 +1028,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16 if ((((Door*)L1151_ps_Junk)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) { _vm->_g321_stopWaitingForPlayerInput = true; _vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); - _vm->_movsens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1); + _vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1); return; } } else { @@ -1212,14 +1212,14 @@ void EventManager::f373_processType80_clickInDungeonView_grabLeaderHandObject(ui if (viewCell >= k2_ViewCellBackRight) { L1137_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1138_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir]; if (((L1139_T_Thing = _vm->_groupMan->f175_groupGetThing(L1137_i_MapX, L1138_i_MapY)) != Thing::_endOfList) && - !_vm->_movsens->f264_isLevitating(L1139_T_Thing) && + !_vm->_moveSens->f264_isLevitating(L1139_T_Thing) && _vm->_groupMan->f176_getCreatureOrdinalInCell((Group*)_vm->_dungeonMan->f156_getThingData(L1139_T_Thing), M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir))) { return; /* It is not possible to grab an object on floor if there is a non levitating creature on its cell */ } } L1139_T_Thing = _vm->_dungeonMan->_g292_pileTopObject[viewCell]; if (_vm->_objectMan->f33_getIconIndex(L1139_T_Thing) != kM1_IconIndiceNone) { - _vm->_movsens->f267_getMoveResult(L1139_T_Thing, L1137_i_MapX, L1138_i_MapY, kM1_MapXNotOnASquare, 0); + _vm->_moveSens->f267_getMoveResult(L1139_T_Thing, L1137_i_MapX, L1138_i_MapY, kM1_MapXNotOnASquare, 0); _vm->_championMan->f297_putObjectInLeaderHand(L1139_T_Thing, true); } _vm->_g321_stopWaitingForPlayerInput = true; @@ -1249,7 +1249,7 @@ void EventManager::f374_processType80_clickInDungeonViewDropLeaderHandObject(uin } L1145_ui_Cell = M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + viewCell); L1142_T_Thing = _vm->_championMan->f298_getObjectRemovedFromLeaderHand(); - _vm->_movsens->f267_getMoveResult(M15_thingWithNewCell(L1142_T_Thing, L1145_ui_Cell), kM1_MapXNotOnASquare, 0, L1140_i_MapX, L1141_i_MapY); + _vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(L1142_T_Thing, L1145_ui_Cell), kM1_MapXNotOnASquare, 0, L1140_i_MapX, L1141_i_MapY); if (L1146_B_DroppingIntoAnAlcove && _vm->_dungeonMan->_g287_isFacingViAltar && ((L1144_i_IconIndex = _vm->_objectMan->f33_getIconIndex(L1142_T_Thing)) == k147_IconIndiceJunkChampionBones)) { L1143_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1142_T_Thing); M33_setMapAndTime(L1147_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 1); @@ -1283,7 +1283,7 @@ void EventManager::f357_discardAllInput() { } void EventManager::f364_commandTakeStairs(bool stairsGoDown) { - _vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0); + _vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, kM1_MapXNotOnASquare, 0); _vm->_g327_newPartyMapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g309_partyMapIndex, stairsGoDown ? -1 : 1, &_vm->_dungeonMan->_g306_partyMapX, &_vm->_dungeonMan->_g307_partyMapY); _vm->_dungeonMan->f173_setCurrentMap(_vm->_g327_newPartyMapIndex); _vm->_championMan->f284_setPartyDirection(_vm->_dungeonMan->f155_getStairsExitDirection(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY)); diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index ec2090cc6e..1d8fc18d2f 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -144,7 +144,7 @@ void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThin if ((L0365_T_CurrentThing).getType() == k5_WeaponThingType) { L0371_B_WeaponDropped = true; } - _vm->_movsens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY); + _vm->_moveSens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY); } while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList); if (mode >= k0_soundModePlayImmediately) { _vm->f064_SOUND_RequestPlay_CPSD(L0371_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode); @@ -256,7 +256,7 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX L0360_ps_Weapon->setType(L0356_ui_FixedPossession); L0360_ps_Weapon->setCursed(L0361_B_Cursed); L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell); - _vm->_movsens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY); + _vm->_moveSens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY); } _vm->f064_SOUND_RequestPlay_CPSD(L0362_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode); } @@ -487,7 +487,7 @@ void GroupMan::f189_delete(int16 mapX, int16 mapY) { L0373_ps_Group = (Group *)_vm->_dungeonMan->f156_getThingData(L0372_T_GroupThing); for (uint16 i = 0; i < 4; ++i) L0373_ps_Group->_health[i] = 0; - _vm->_movsens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0); + _vm->_moveSens->f267_getMoveResult(L0372_T_GroupThing, mapX, mapY, kM1_MapXNotOnASquare, 0); L0373_ps_Group->_nextThing = Thing::_none; if (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) { _vm->_groupMan->_g375_activeGroups[L0373_ps_Group->getActiveGroupIndex()]._groupThingIndex = -1; @@ -625,10 +625,10 @@ void GroupMan::f209_processEvents29to41(int16 eventMapX, int16 eventMapY, int16 AL0450_i_DestinationMapX = eventMapX; AL0451_i_DestinationMapY = eventMapY; AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction], AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction]; - if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY)) + if (_vm->_moveSens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY)) goto T0209139_Return; - L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX; - L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY; + L0465_s_NextEvent._B._location._mapX = _vm->_moveSens->_g397_moveResultMapX; + L0465_s_NextEvent._B._location._mapY = _vm->_moveSens->_g398_moveResultMapY; } L0465_s_NextEvent._type = k37_TMEventTypeUpdateBehaviourGroup; AL0446_i_Ticks = MAX(ABS(_vm->_dungeonMan->_g272_currMapIndex - _vm->_dungeonMan->_g309_partyMapIndex) << 4, L0448_s_CreatureInfo._movementTicks << 1); @@ -797,10 +797,10 @@ T0209058_MoveInRandomDirection: && f202_isMovementPossible(&L0448_s_CreatureInfo, eventMapX, eventMapY, AL0446_i_Direction, false)) { T0209061_MoveGroup: if (L0453_B_NewGroupDirectionFound = ((AL0447_i_Ticks = (L0461_i_MovementTicks >> 1) - L0462_i_TicksSinceLastMove) <= 0)) { - if (_vm->_movsens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY)) + if (_vm->_moveSens->f267_getMoveResult(L0449_T_GroupThing, eventMapX, eventMapY, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY)) goto T0209139_Return; - L0465_s_NextEvent._B._location._mapX = _vm->_movsens->_g397_moveResultMapX; - L0465_s_NextEvent._B._location._mapY = _vm->_movsens->_g398_moveResultMapY;; + L0465_s_NextEvent._B._location._mapX = _vm->_moveSens->_g397_moveResultMapX; + L0465_s_NextEvent._B._location._mapY = _vm->_moveSens->_g398_moveResultMapY;; L0445_ps_ActiveGroup->_priorMapX = eventMapX; L0445_ps_ActiveGroup->_priorMapY = eventMapY; L0445_ps_ActiveGroup->_lastMoveTime = _vm->_g313_gameTime; @@ -1291,7 +1291,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 if (L0331_ui_CreatureType == k13_CreatureTypeCouatl) { if (_vm->getRandomNumber(2)) { toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); - L1635_ui_SoundIndex = _vm->_movsens->f514_getSound(k13_CreatureTypeCouatl); + L1635_ui_SoundIndex = _vm->_moveSens->f514_getSound(k13_CreatureTypeCouatl); if (L1635_ui_SoundIndex <= k34_D13_soundCount) { _vm->f064_SOUND_RequestPlay_CPSD(L1635_ui_SoundIndex, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized); } @@ -1806,7 +1806,7 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie } } while (creatureCount--); L0353_ps_Group->_cells = L0352_ui_GroupCells; - if (_vm->_movsens->f267_getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */ + if (_vm->_moveSens->f267_getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */ return Thing::_none; } _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, mapX, mapY, k1_soundModePlayIfPrioritized); @@ -2049,7 +2049,7 @@ void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) { } } if (f223_isSquareACorridorTeleporterPitOrDoor(L0548_i_MapX, L0549_i_MapY)) { - if (!_vm->_movsens->f267_getMoveResult(L0555_T_LordChaosThing, mapX, mapY, L0548_i_MapX, L0549_i_MapY)) { + if (!_vm->_moveSens->f267_getMoveResult(L0555_T_LordChaosThing, mapX, mapY, L0548_i_MapX, L0549_i_MapY)) { f180_startWanedring(L0548_i_MapX, L0549_i_MapY); } return; diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 54ce632590..b63717d265 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -620,7 +620,7 @@ T0412033: _vm->_championMan->f301_addObjectInSlot((ChampionIndex)champIndex, L1272_T_Object, AL1267_ui_SlotIndex); _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); } else { - _vm->_movsens->f267_getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); + _vm->_moveSens->f267_getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); } break; case k8_spellType_otherFireshield: @@ -1252,9 +1252,9 @@ T0407032: /* CHANGE6_00_FIX The presence of a group over the pit is checked so that you cannot climb down a pit with the rope if there is a group levitating over it */ if ((_vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_ElementTypePit) && (_vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) { /* BUG0_77 The party moves forward when using the rope in front of a closed pit. The engine does not check whether the pit is open before moving the party over the pit. This is not consistent with the behavior when using the rope in front of a corridor where nothing happens */ - _vm->_movsens->_g402_useRopeToClimbDownPit = true; - _vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1251_i_MapX, L1252_i_MapY); - _vm->_movsens->_g402_useRopeToClimbDownPit = false; + _vm->_moveSens->_g402_useRopeToClimbDownPit = true; + _vm->_moveSens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1251_i_MapX, L1252_i_MapY); + _vm->_moveSens->_g402_useRopeToClimbDownPit = false; } else { L1249_ui_ActionDisabledTicks = 0; } diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index 06ba83afd8..937e144e25 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -148,7 +148,7 @@ T0217004: L0494_ps_Door = (Door *)_vm->_dungeonMan->f157_getSquareFirstThingData(AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY); if ((AL0487_i_DoorState != k5_doorState_DESTROYED) && (L0486_T_ProjectileAssociatedThing == Thing::_explOpenDoor)) { if (L0494_ps_Door->hasButton()) { - _vm->_movsens->f268_addEvent(k10_TMEventTypeDoor, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1); + _vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, AP0454_i_ProjectileTargetMapX, AP0455_i_ProjectileTargetMapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1); } break; } @@ -409,7 +409,7 @@ void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, in _vm->_dungeonMan->f163_linkThingToList(L0479_T_Thing, L0478_T_PreviousThing, kM1_MapXNotOnASquare, 0); } } else { - _vm->_movsens->f267_getMoveResult(Thing((L0479_T_Thing).getTypeAndIndex() | getFlag(projectileThing.toUint16(), 0xC)), -2, 0, mapX, mapY); + _vm->_moveSens->f267_getMoveResult(Thing((L0479_T_Thing).getTypeAndIndex() | getFlag(projectileThing.toUint16(), 0xC)), -2, 0, mapX, mapY); } } L0480_ps_Projectile->_nextThing = Thing::_none; @@ -479,12 +479,12 @@ void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) { } L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, L0518_ui_Cell &= 0x0003); if (L0522_B_ProjectileMovesToOtherSquare) { - _vm->_movsens->f267_getMoveResult(L0515_T_ProjectileThingNewCell, L0525_i_SourceMapX, L0526_i_SourceMapY, L0523_i_DestinationMapX, L0524_i_DestinationMapY); - L0519_ps_Event->_C._projectile.setMapX(_vm->_movsens->_g397_moveResultMapX); - L0519_ps_Event->_C._projectile.setMapY(_vm->_movsens->_g398_moveResultMapY); - L0519_ps_Event->_C._projectile.setDir((Direction)_vm->_movsens->_g400_moveResultDir); - L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_movsens->_g401_moveResultCell); - M31_setMap(L0519_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex); + _vm->_moveSens->f267_getMoveResult(L0515_T_ProjectileThingNewCell, L0525_i_SourceMapX, L0526_i_SourceMapY, L0523_i_DestinationMapX, L0524_i_DestinationMapY); + L0519_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_g397_moveResultMapX); + L0519_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_g398_moveResultMapY); + L0519_ps_Event->_C._projectile.setDir((Direction)_vm->_moveSens->_g400_moveResultDir); + L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_moveSens->_g401_moveResultCell); + M31_setMap(L0519_ps_Event->_mapTime, _vm->_moveSens->_g399_moveResultMapIndex); } else { if ((Square(_vm->_dungeonMan->f151_getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY)).getType() == k4_DoorElemType) && f217_projectileHasImpactOccurred(k4_DoorElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) { return; diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 33bfc61555..8baddf0abf 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -554,11 +554,11 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) { if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (mapX == _vm->_dungeonMan->_g306_partyMapX) && (mapY == _vm->_dungeonMan->_g307_partyMapY)) { - _vm->_movsens->f267_getMoveResult(Thing::_party, mapX, mapY, mapX, mapY); + _vm->_moveSens->f267_getMoveResult(Thing::_party, mapX, mapY, mapX, mapY); _vm->_championMan->f296_drawChangedObjectIcons(); } if ((L0645_T_Thing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) != Thing::_endOfList) { - _vm->_movsens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY); + _vm->_moveSens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY); } L0645_T_Thing = _vm->_dungeonMan->f162_getSquareFirstObject(mapX, mapY); L0648_T_NextThing = L0645_T_Thing; @@ -575,24 +575,24 @@ void Timeline::f249_moveTeleporterOrPitSquareThings(uint16 mapX, uint16 mapY) { L0648_T_NextThing = _vm->_dungeonMan->f159_getNextThing(L0645_T_Thing); AL0644_ui_ThingType = L0645_T_Thing.getType(); if (AL0644_ui_ThingType > k4_GroupThingType) { - _vm->_movsens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY); + _vm->_moveSens->f267_getMoveResult(L0645_T_Thing, mapX, mapY, mapX, mapY); } if (AL0644_ui_ThingType == k14_ProjectileThingType) { L0646_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(L0645_T_Thing); L0647_ps_Event = &_vm->_timeline->_g370_events[L0646_ps_Projectile->_eventIndex]; - L0647_ps_Event->_C._projectile.setMapX(_vm->_movsens->_g397_moveResultMapX); - L0647_ps_Event->_C._projectile.setMapY(_vm->_movsens->_g398_moveResultMapY); - L0647_ps_Event->_C._projectile.setDir((Direction)_vm->_movsens->_g400_moveResultDir); - L0647_ps_Event->_B._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_movsens->_g401_moveResultCell).toUint16(); - M31_setMap(L0647_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex); + L0647_ps_Event->_C._projectile.setMapX(_vm->_moveSens->_g397_moveResultMapX); + L0647_ps_Event->_C._projectile.setMapY(_vm->_moveSens->_g398_moveResultMapY); + L0647_ps_Event->_C._projectile.setDir((Direction)_vm->_moveSens->_g400_moveResultDir); + L0647_ps_Event->_B._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_moveSens->_g401_moveResultCell).toUint16(); + M31_setMap(L0647_ps_Event->_mapTime, _vm->_moveSens->_g399_moveResultMapIndex); } else { if (AL0644_ui_ThingType == k15_ExplosionThingType) { for (AL0644_ui_EventIndex = 0, L0647_ps_Event = _vm->_timeline->_g370_events; AL0644_ui_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0647_ps_Event++, AL0644_ui_EventIndex++) { if ((L0647_ps_Event->_type == k25_TMEventTypeExplosion) && (L0647_ps_Event->_C._slot == L0645_T_Thing.toUint16())) { /* BUG0_23 A Fluxcage explosion remains on a square forever. If you open a pit or teleporter on a square where there is a Fluxcage explosion, the Fluxcage explosion is moved but the associated event is not updated (because Fluxcage explosions do not use k25_TMEventTypeExplosion but rather k24_TMEventTypeRemoveFluxcage) causing the Fluxcage explosion to remain in the dungeon forever on its destination square. When the k24_TMEventTypeRemoveFluxcage expires the explosion thing is not removed, but it is marked as unused. Consequently, any objects placed on the Fluxcage square after it was moved but before it expires become orphans upon expiration. After expiration, any object placed on the fluxcage square is cloned when picked up */ - L0647_ps_Event->_B._location._mapX = _vm->_movsens->_g397_moveResultMapX; - L0647_ps_Event->_B._location._mapY = _vm->_movsens->_g398_moveResultMapY; - L0647_ps_Event->_C._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_movsens->_g401_moveResultCell).toUint16(); - M31_setMap(L0647_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex); + L0647_ps_Event->_B._location._mapX = _vm->_moveSens->_g397_moveResultMapX; + L0647_ps_Event->_B._location._mapY = _vm->_moveSens->_g398_moveResultMapY; + L0647_ps_Event->_C._slot = M15_thingWithNewCell(L0645_T_Thing, _vm->_moveSens->_g401_moveResultCell).toUint16(); + M31_setMap(L0647_ps_Event->_mapTime, _vm->_moveSens->_g399_moveResultMapIndex); } } } @@ -661,10 +661,10 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) { L0638_ps_Sensor->setData(L0637_ui_SensorData); if (L0638_ps_Sensor->getEffectA() == k3_SensorEffHold) { AL0636_B_TriggerSetEffect = ((L0637_ui_SensorData == 0) != L0638_ps_Sensor->getRevertEffectA()); - _vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell); + _vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell); } else { if (L0637_ui_SensorData == 0) { - _vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell); + _vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell); } } } @@ -687,10 +687,10 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) { L0638_ps_Sensor->setData(L0637_ui_SensorData); AL0636_B_TriggerSetEffect = (Sensor::getDataMask1(L0637_ui_SensorData) == Sensor::getDataMask2(L0637_ui_SensorData)) != L0638_ps_Sensor->getRevertEffectA(); if (L0638_ps_Sensor->getEffectA() == k3_SensorEffHold) { - _vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell); + _vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, AL0636_B_TriggerSetEffect ? k0_SensorEffSet : k1_SensorEffClear, L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell); } else { if (AL0636_B_TriggerSetEffect) { - _vm->_movsens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell); + _vm->_moveSens->f272_sensorTriggerEffect(L0638_ps_Sensor, L0638_ps_Sensor->getEffectA(), L0641_i_MapX, L0642_i_MapY, L0643_ui_Cell); } } } else { @@ -713,7 +713,7 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) { } L0634_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0634_T_Thing); } - _vm->_movsens->f271_processRotationEffect(); + _vm->_moveSens->f271_processRotationEffect(); } void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* event) { @@ -881,7 +881,7 @@ T0252001: if (event->_type == k61_TMEventTypeMoveGroupAudible) { _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0656_ui_MapX, L0657_ui_MapY, k1_soundModePlayIfPrioritized); } - _vm->_movsens->f267_getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, L0656_ui_MapX, L0657_ui_MapY); + _vm->_moveSens->f267_getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, L0656_ui_MapX, L0657_ui_MapY); } else { if (!L0659_B_RandomDirectionMoveRetried) { L0659_B_RandomDirectionMoveRetried = true; -- cgit v1.2.3 From a21c6778314a17e56d9faf5c5d6693a63cc634e5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2016 16:17:50 +0200 Subject: DM: Remove useless cast and the associated obsolete comment --- engines/dm/timeline.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 8baddf0abf..33a99c9b2f 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -380,8 +380,7 @@ T0261053: } bool Timeline::f240_isFirstEventExpiered() { - warning(false, "possibly dangerous cast to uint32"); - return (_vm->_timeline->_g372_eventCount && ((uint32)M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime)); + return (_vm->_timeline->_g372_eventCount && (M30_time(_vm->_timeline->_g370_events[_vm->_timeline->_g371_timeline[0]]._mapTime) <= _vm->_g313_gameTime)); } void Timeline::f239_timelineExtractFirstEvent(TimelineEvent* event) { -- cgit v1.2.3 From e8e1a54ceadd1d02d860ef750f0b9a44db72e971 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2016 16:18:33 +0200 Subject: DM: Rename mapTime in dm.cpp --- engines/dm/dm.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 5671fc6fcf..cd69479961 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -102,16 +102,16 @@ uint16 M21_normalizeModulo4(uint16 val) { return val & 3; } -int32 M30_time(int32 map_time) { - return map_time & 0x00FFFFFF; +int32 M30_time(int32 mapTime) { + return mapTime & 0x00FFFFFF; } -int32 M33_setMapAndTime(int32 &map_time, uint32 map, uint32 time) { - return (map_time) = ((time) | (((long)(map)) << 24)); +int32 M33_setMapAndTime(int32 &mapTime, uint32 map, uint32 time) { + return (mapTime) = ((time) | (((long)(map)) << 24)); } -uint16 M29_map(int32 map_time) { - return ((uint16)((map_time) >> 24)); +uint16 M29_map(int32 mapTime) { + return ((uint16)((mapTime) >> 24)); } Thing M15_thingWithNewCell(Thing thing, int16 cell) { -- cgit v1.2.3 From e0219fd6f7f53c926ba8272b41ad9d00590d40ce Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2016 17:02:15 +0200 Subject: DM: Refactor f331_applyTimeEffects --- engines/dm/champion.cpp | 222 +++++++++++++++++++++--------------------------- 1 file changed, 97 insertions(+), 125 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 9b14993d8b..92f23ac210 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1511,9 +1511,8 @@ void ChampionMan::f318_dropAllObjects(uint16 champIndex) { uint16 curCell = _vm->_championMan->_gK71_champions[champIndex]._cell; for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) { Thing curThing = f300_getObjectRemovedFromSlot(champIndex, slotDropOrder[slotIndex]); - if (curThing != Thing::_none) { + if (curThing != Thing::_none) _vm->_moveSens->f267_getMoveResult(M15_thingWithNewCell(curThing, curCell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); - } } } @@ -1530,150 +1529,123 @@ void ChampionMan::f323_unpoison(int16 champIndex) { } void ChampionMan::f331_applyTimeEffects() { - uint16 L1006_ui_Multiple; -#define AL1006_ui_GameTime L1006_ui_Multiple -#define AL1006_ui_ChampionIndex L1006_ui_Multiple - uint16 L1007_ui_Multiple; -#define AL1007_ui_ScentIndex L1007_ui_Multiple -#define AL1007_ui_ManaGain L1007_ui_Multiple -#define AL1007_ui_StaminaGainCycleCount L1007_ui_Multiple -#define AL1007_ui_StatisticIndex L1007_ui_Multiple - uint16 L1008_ui_Multiple; -#define AL1008_ui_WizardSkillLevel L1008_ui_Multiple -#define AL1008_ui_Delay L1008_ui_Multiple -#define AL1008_ui_StaminaAboveHalf L1008_ui_Multiple -#define AL1008_ui_StatisticMaximum L1008_ui_Multiple - int16 L1009_i_Multiple; -#define AL1009_i_SkillIndex L1009_i_Multiple -#define AL1009_i_StaminaMagnitude L1009_i_Multiple -#define AL1009_i_StaminaLoss L1009_i_Multiple - Champion* L1010_ps_Champion; - unsigned char* L1011_puc_Statistic; - uint16 L1012_ui_TimeCriteria; - int16 L1013_i_Multiple; -#define AL1013_i_StaminaAmount L1013_i_Multiple -#define AL1013_i_HealthGain L1013_i_Multiple - Scent L1014_s_Scent; - - - if (!_vm->_championMan->_g305_partyChampionCount) { + if (!_vm->_championMan->_g305_partyChampionCount) return; - } - L1014_s_Scent.setMapX(_vm->_dungeonMan->_g306_partyMapX); - L1014_s_Scent.setMapY(_vm->_dungeonMan->_g307_partyMapY); - L1014_s_Scent.setMapIndex(_vm->_dungeonMan->_g309_partyMapIndex); - AL1007_ui_ScentIndex = 0; - while ((int16)AL1007_ui_ScentIndex < (int16)(_vm->_championMan->_g407_party._scentCount - 1)) { - if (&_vm->_championMan->_g407_party._scents[AL1007_ui_ScentIndex] != &L1014_s_Scent) { - if (!(_vm->_championMan->_g407_party._scentStrengths[AL1007_ui_ScentIndex] = MAX(0, _vm->_championMan->_g407_party._scentStrengths[AL1007_ui_ScentIndex] - 1)) && !AL1007_ui_ScentIndex) { + + Scent checkScent; + checkScent.setMapX(_vm->_dungeonMan->_g306_partyMapX); + checkScent.setMapY(_vm->_dungeonMan->_g307_partyMapY); + checkScent.setMapIndex(_vm->_dungeonMan->_g309_partyMapIndex); + + for (byte loopScentIndex = 0; loopScentIndex + 1 < _vm->_championMan->_g407_party._scentCount; loopScentIndex++) { + if (&_vm->_championMan->_g407_party._scents[loopScentIndex] != &checkScent) { + _vm->_championMan->_g407_party._scentStrengths[loopScentIndex] = MAX(0, _vm->_championMan->_g407_party._scentStrengths[loopScentIndex] - 1); + if (!_vm->_championMan->_g407_party._scentStrengths[loopScentIndex] && !loopScentIndex) { f316_deleteScent(0); continue; } } - AL1007_ui_ScentIndex++; } - AL1006_ui_GameTime = _vm->_g313_gameTime; - L1012_ui_TimeCriteria = (((AL1006_ui_GameTime & 0x0080) + ((AL1006_ui_GameTime & 0x0100) >> 2)) + ((AL1006_ui_GameTime & 0x0040) << 2)) >> 2; - for (AL1006_ui_ChampionIndex = k0_ChampionFirst, L1010_ps_Champion = _vm->_championMan->_gK71_champions; AL1006_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL1006_ui_ChampionIndex++, L1010_ps_Champion++) { - if (L1010_ps_Champion->_currHealth && (_vm->M0_indexToOrdinal(AL1006_ui_ChampionIndex) != _vm->_championMan->_g299_candidateChampionOrdinal)) { - if ((L1010_ps_Champion->_currMana < L1010_ps_Champion->_maxMana) && (L1012_ui_TimeCriteria < (L1010_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + (AL1008_ui_WizardSkillLevel = _vm->_championMan->f303_getSkillLevel(AL1006_ui_ChampionIndex, k3_ChampionSkillWizard) + _vm->_championMan->f303_getSkillLevel(AL1006_ui_ChampionIndex, k2_ChampionSkillPriest))))) { - AL1007_ui_ManaGain = L1010_ps_Champion->_maxMana / 40; - if (_vm->_championMan->_g300_partyIsSleeping) { - AL1007_ui_ManaGain = AL1007_ui_ManaGain << 1; - } - AL1007_ui_ManaGain++; - f325_decrementStamina(AL1006_ui_ChampionIndex, AL1007_ui_ManaGain * MAX(7, 16 - AL1008_ui_WizardSkillLevel)); - L1010_ps_Champion->_currMana += MIN(AL1007_ui_ManaGain, (uint16)(L1010_ps_Champion->_maxMana - L1010_ps_Champion->_currMana)); - } else { - if (L1010_ps_Champion->_currMana > L1010_ps_Champion->_maxMana) { - L1010_ps_Champion->_currMana--; - } - } - for (AL1009_i_SkillIndex = k19_ChampionSkillWater; AL1009_i_SkillIndex >= k0_ChampionSkillFighter; AL1009_i_SkillIndex--) { - if (L1010_ps_Champion->_skills[AL1009_i_SkillIndex]._temporaryExperience > 0) { - L1010_ps_Champion->_skills[AL1009_i_SkillIndex]._temporaryExperience--; - } - } - AL1007_ui_StaminaGainCycleCount = 4; - AL1009_i_StaminaMagnitude = L1010_ps_Champion->_maxStamina; - while (L1010_ps_Champion->_currStamina < (AL1009_i_StaminaMagnitude >>= 1)) { - AL1007_ui_StaminaGainCycleCount += 2; - } - AL1009_i_StaminaLoss = 0; - AL1013_i_StaminaAmount = f26_getBoundedValue(1, (L1010_ps_Champion->_maxStamina >> 8) - 1, 6); - if (_vm->_championMan->_g300_partyIsSleeping) { - AL1013_i_StaminaAmount <<= 1; + + uint16 gameTime = _vm->_g313_gameTime & 0xFFFF; + uint16 timeCriteria = (((gameTime & 0x0080) + ((gameTime & 0x0100) >> 2)) + ((gameTime & 0x0040) << 2)) >> 2; + Champion *championPtr = _vm->_championMan->_gK71_champions; + for (uint16 championIndex = k0_ChampionFirst; championIndex < _vm->_championMan->_g305_partyChampionCount; championIndex++, championPtr++) { + if (championPtr->_currHealth && (_vm->M0_indexToOrdinal(championIndex) != _vm->_championMan->_g299_candidateChampionOrdinal)) { + uint16 wizardSkillLevel = _vm->_championMan->f303_getSkillLevel(championIndex, k3_ChampionSkillWizard) + _vm->_championMan->f303_getSkillLevel(championIndex, k2_ChampionSkillPriest); + if ((championPtr->_currMana < championPtr->_maxMana) + && (timeCriteria < championPtr->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + wizardSkillLevel)) { + int16 manaGain = championPtr->_maxMana / 40; + if (_vm->_championMan->_g300_partyIsSleeping) + manaGain <<= 1; + + manaGain++; + f325_decrementStamina(championIndex, manaGain * MAX(7, 16 - wizardSkillLevel)); + championPtr->_currMana += MIN(manaGain, championPtr->_maxMana - championPtr->_currMana); + } else if (championPtr->_currMana > championPtr->_maxMana) + championPtr->_currMana--; + + for (int16 idx = k19_ChampionSkillWater; idx >= k0_ChampionSkillFighter; idx--) { + if (championPtr->_skills[idx]._temporaryExperience > 0) + championPtr->_skills[idx]._temporaryExperience--; } - if ((AL1008_ui_Delay = (_vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime)) > 80) { - AL1013_i_StaminaAmount++; - if (AL1008_ui_Delay > 250) { - AL1013_i_StaminaAmount++; - } + uint16 staminaGainCycleCount = 4; + int16 staminaMagnitude = championPtr->_maxStamina; + while (championPtr->_currStamina < (staminaMagnitude >>= 1)) + staminaGainCycleCount += 2; + + int16 staminaLoss = 0; + int16 staminaAmount = f26_getBoundedValue(1, (championPtr->_maxStamina >> 8) - 1, 6); + if (_vm->_championMan->_g300_partyIsSleeping) + staminaAmount <<= 1; + + int32 compDelay = _vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime; + if (compDelay > 80) { + staminaAmount++; + if (compDelay > 250) + staminaAmount++; } do { - AL1008_ui_StaminaAboveHalf = (AL1007_ui_StaminaGainCycleCount <= 4); - if (L1010_ps_Champion->_food < -512) { - if (AL1008_ui_StaminaAboveHalf) { - AL1009_i_StaminaLoss += AL1013_i_StaminaAmount; - L1010_ps_Champion->_food -= 2; + bool staminaAboveHalf = (staminaGainCycleCount <= 4); + if (championPtr->_food < -512) { + if (staminaAboveHalf) { + staminaLoss += staminaAmount; + championPtr->_food -= 2; } } else { - if (L1010_ps_Champion->_food >= 0) { - AL1009_i_StaminaLoss -= AL1013_i_StaminaAmount; - } - L1010_ps_Champion->_food -= AL1008_ui_StaminaAboveHalf ? 2 : AL1007_ui_StaminaGainCycleCount >> 1; + if (championPtr->_food >= 0) + staminaLoss -= staminaAmount; + + championPtr->_food -= staminaAboveHalf ? 2 : staminaGainCycleCount >> 1; } - if (L1010_ps_Champion->_water < -512) { - if (AL1008_ui_StaminaAboveHalf) { - AL1009_i_StaminaLoss += AL1013_i_StaminaAmount; - L1010_ps_Champion->_water -= 1; + if (championPtr->_water < -512) { + if (staminaAboveHalf) { + staminaLoss += staminaAmount; + championPtr->_water -= 1; } } else { - if (L1010_ps_Champion->_water >= 0) { - AL1009_i_StaminaLoss -= AL1013_i_StaminaAmount; - } - L1010_ps_Champion->_water -= AL1008_ui_StaminaAboveHalf ? 1 : AL1007_ui_StaminaGainCycleCount >> 2; - } - } while (--AL1007_ui_StaminaGainCycleCount && ((L1010_ps_Champion->_currStamina - AL1009_i_StaminaLoss) < L1010_ps_Champion->_maxStamina)); - f325_decrementStamina(AL1006_ui_ChampionIndex, AL1009_i_StaminaLoss); - if (L1010_ps_Champion->_food < -1024) { - L1010_ps_Champion->_food = -1024; - } - if (L1010_ps_Champion->_water < -1024) { - L1010_ps_Champion->_water = -1024; - } - if ((L1010_ps_Champion->_currHealth < L1010_ps_Champion->_maxHealth) && (L1010_ps_Champion->_currStamina >= (L1010_ps_Champion->_maxStamina >> 2)) && (L1012_ui_TimeCriteria < (L1010_ps_Champion->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] + 12))) { - AL1013_i_HealthGain = (L1010_ps_Champion->_maxHealth >> 7) + 1; - if (_vm->_championMan->_g300_partyIsSleeping) { - AL1013_i_HealthGain <<= 1; - } - if (_vm->_objectMan->f33_getIconIndex(L1010_ps_Champion->_slots[k10_ChampionSlotNeck]) == k121_IconIndiceJunkEkkhardCross) { - AL1013_i_HealthGain += (AL1013_i_HealthGain >> 1) + 1; + if (championPtr->_water >= 0) + staminaLoss -= staminaAmount; + + championPtr->_water -= staminaAboveHalf ? 1 : staminaGainCycleCount >> 2; } - L1010_ps_Champion->_currHealth += MIN(AL1013_i_HealthGain, (int16)(L1010_ps_Champion->_maxHealth - L1010_ps_Champion->_currHealth)); + } while (--staminaGainCycleCount && ((championPtr->_currStamina - staminaLoss) < championPtr->_maxStamina)); + f325_decrementStamina(championIndex, staminaLoss); + if (championPtr->_food < -1024) + championPtr->_food = -1024; + + if (championPtr->_water < -1024) + championPtr->_water = -1024; + + if ((championPtr->_currHealth < championPtr->_maxHealth) && (championPtr->_currStamina >= (championPtr->_maxStamina >> 2)) && (timeCriteria < (championPtr->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] + 12))) { + int16 healthGain = (championPtr->_maxHealth >> 7) + 1; + if (_vm->_championMan->_g300_partyIsSleeping) + healthGain <<= 1; + + if (_vm->_objectMan->f33_getIconIndex(championPtr->_slots[k10_ChampionSlotNeck]) == k121_IconIndiceJunkEkkhardCross) + healthGain += (healthGain >> 1) + 1; + + championPtr->_currHealth += MIN(healthGain, (int16)(championPtr->_maxHealth - championPtr->_currHealth)); } if (!((int)_vm->_g313_gameTime & (_vm->_championMan->_g300_partyIsSleeping ? 63 : 255))) { - for (AL1007_ui_StatisticIndex = k0_ChampionStatLuck; AL1007_ui_StatisticIndex <= k6_ChampionStatAntifire; AL1007_ui_StatisticIndex++) { - L1011_puc_Statistic = L1010_ps_Champion->_statistics[AL1007_ui_StatisticIndex]; - AL1008_ui_StatisticMaximum = L1011_puc_Statistic[k0_ChampionStatMaximum]; - if (L1011_puc_Statistic[k1_ChampionStatCurrent] < AL1008_ui_StatisticMaximum) { - L1011_puc_Statistic[k1_ChampionStatCurrent]++; - } else { - if (L1011_puc_Statistic[k1_ChampionStatCurrent] > AL1008_ui_StatisticMaximum) { - L1011_puc_Statistic[k1_ChampionStatCurrent] -= L1011_puc_Statistic[k1_ChampionStatCurrent] / AL1008_ui_StatisticMaximum; - } - } + for (uint16 i = k0_ChampionStatLuck; i <= k6_ChampionStatAntifire; i++) { + byte *curStatistic = championPtr->_statistics[i]; + uint16 statisticMaximum = curStatistic[k0_ChampionStatMaximum]; + if (curStatistic[k1_ChampionStatCurrent] < statisticMaximum) + curStatistic[k1_ChampionStatCurrent]++; + else if (curStatistic[k1_ChampionStatCurrent] > statisticMaximum) + curStatistic[k1_ChampionStatCurrent] -= curStatistic[k1_ChampionStatCurrent] / statisticMaximum; } } - if (!_vm->_championMan->_g300_partyIsSleeping && (L1010_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_g313_gameTime)) { - L1010_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir; - L1010_ps_Champion->_maximumDamageReceived = 0; - setFlag(L1010_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon); + if (!_vm->_championMan->_g300_partyIsSleeping && (championPtr->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime + 60 < _vm->_g313_gameTime)) { + championPtr->_dir = _vm->_dungeonMan->_g308_partyDir; + championPtr->_maximumDamageReceived = 0; + setFlag(championPtr->_attributes, k0x0400_ChampionAttributeIcon); } - setFlag(L1010_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); - if (_vm->M0_indexToOrdinal(AL1006_ui_ChampionIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) { + setFlag(championPtr->_attributes, k0x0100_ChampionAttributeStatistics); + if (_vm->M0_indexToOrdinal(championIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) { if (_vm->_g333_pressingMouth || _vm->_g331_pressingEye || (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) { - setFlag(L1010_ps_Champion->_attributes, k0x0800_ChampionAttributePanel); + setFlag(championPtr->_attributes, k0x0800_ChampionAttributePanel); } } } -- cgit v1.2.3 From 42f7f17c099312e45457432d68fc7e5424ed7ff5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2016 18:57:10 +0200 Subject: DM: Fix compilation on MSVC9 --- engines/dm/dialog.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp index d9408fc37e..71ff8dcf93 100644 --- a/engines/dm/dialog.cpp +++ b/engines/dm/dialog.cpp @@ -36,11 +36,11 @@ namespace DM { DialogMan::DialogMan(DMEngine* vm) : _vm(vm) {} void DialogMan::f427_dialogDraw(char* msg1, char* msg2, char* choice1, char* choice2, char* choice3, char* choice4, bool screenDialog, bool clearScreen, bool fading) { - static Box K0068_s_Box1 = {0, 223, 101, 125}; - static Box K0069_s_Box2 = {0, 223, 76, 100}; - static Box K0070_s_Box3 = {0, 223, 51, 75}; - static Box G0469_s_Graphic561_Box_Dialog2ChoicesPatch = {102, 122, 89, 125}; - static Box G0470_s_Graphic561_Box_Dialog4ChoicesPatch = {102, 122, 62, 97}; + static Box K0068_s_Box1 = Box(0, 223, 101, 125); + static Box K0069_s_Box2 = Box(0, 223, 76, 100); + static Box K0070_s_Box3 = Box(0, 223, 51, 75); + static Box G0469_s_Graphic561_Box_Dialog2ChoicesPatch = Box(102, 122, 89, 125); + static Box G0470_s_Graphic561_Box_Dialog4ChoicesPatch = Box(102, 122, 62, 97); int16 L1308_i_X; int16 L1309_i_Y; -- cgit v1.2.3 From afaaa4d58e8acfa6ad269223d5f8eca91447e0e4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Jul 2016 19:03:49 +0200 Subject: DM: Use error() in f278_resetDataToStartGame --- engines/dm/champion.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 92f23ac210..508605baea 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1787,10 +1787,8 @@ ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) { } void ChampionMan::f278_resetDataToStartGame() { - if (!_vm->_g298_newGame) { - warning(false, "MISSING CODE: stuff for resetting for loaded games"); - assert(false); - } + if (!_vm->_g298_newGame) + error("MISSING CODE: stuff for resetting for loaded games"); _g414_leaderHandObject = Thing::_none; _g413_leaderHandObjectIconIndex = kM1_IconIndiceNone; -- cgit v1.2.3 From 9fd7c561986357ea539391cb0d4be238b27ac96d Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 25 Jul 2016 19:30:11 +0200 Subject: DM: Finish f433_processCommand140_saveGame --- engines/dm/dungeonman.h | 2 ++ engines/dm/loadsave.cpp | 76 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 95f8a1abf4..34aef8d5c4 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -650,6 +650,8 @@ public: class Group; +extern byte g235_ThingDataWordCount[16]; + class DungeonMan { DMEngine *_vm; diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index a19cef20b9..86060d5c9b 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -139,6 +139,8 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) { void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String desc) { + warning(false, "DUMMY CODE in f433_processCommand140_saveGame, saveAndPlayChoice is always 0"); + int16 saveAndPlayChoice = 0; char *message = nullptr; _menuMan->f456_drawDisabledMenu(); @@ -150,7 +152,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String // F0427_DIALOG_Draw(0, G0551_pc_SAVINGGAME, 0, 0, 0, 0, false, false, false); - uint16 champHandObjWeight; + uint16 champHandObjWeight = 0; if (!_championMan->_g415_leaderEmptyHanded) { champHandObjWeight = _dungeonMan->f140_getObjectWeight(_championMan->_g414_leaderHandObject); _championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load -= champHandObjWeight; @@ -202,11 +204,81 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String file->writeSint16BE(_g527_platform); file->writeUint16BE(_g526_dungeonId); - warning(false, "MISSING CODE in save game"); + file->writeSint16BE(saveAndPlayChoice); + + // save _g278_dungeonFileHeader + { + DungeonFileHeader &header = _dungeonMan->_g278_dungeonFileHeader; + file->writeUint16BE(header._dungeonId); + file->writeUint16BE(header._ornamentRandomSeed); + file->writeUint32BE(header._rawMapDataSize); + file->writeByte(header._mapCount); + file->writeUint16BE(header._textDataWordCount); + file->writeUint16BE(header._partyStartDir); + file->writeUint16BE(header._partyStartPosX); + file->writeUint16BE(header._partyStartPosY); + file->writeUint16BE(header._squareFirstThingCount); + for (uint16 i = 0; i < 16; ++i) + file->writeUint16BE(header._thingCounts[i]); + } + + // save _g277_dungeonMaps + for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._mapCount; ++i) { + Map &map = _dungeonMan->_g277_dungeonMaps[i]; + file->writeUint32BE(map._rawDunDataOffset); + file->writeByte(map._offsetMapX); + file->writeByte(map._offsetMapY); + file->writeByte(map._level); + file->writeByte(map._width); + file->writeByte(map._height); + file->writeByte(map._wallOrnCount); + file->writeByte(map._randWallOrnCount); + file->writeByte(map._floorOrnCount); + file->writeByte(map._randFloorOrnCount); + file->writeByte(map._doorOrnCount); + file->writeByte(map._creatureTypeCount); + file->writeByte(map._difficulty); + file->writeSint16BE(map._floorSet); + file->writeSint16BE(map._wallSet); + file->writeByte(map._doorSet0); + file->writeByte(map._doorSet1); + } + +// save _g280_dungeonColumnsCumulativeSquareThingCount + for (uint16 i = 0; i < _dungeonMan->_g282_dungeonColumCount; ++i) + file->writeUint16BE(_dungeonMan->_g280_dungeonColumnsCumulativeSquareThingCount[i]); + + // save _g283_squareFirstThings + for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._squareFirstThingCount; ++i) + file->writeUint16BE(_dungeonMan->_g283_squareFirstThings[i].toUint16()); + + // save _g260_dungeonTextData + for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._textDataWordCount; ++i) + file->writeUint16BE(_dungeonMan->_g260_dungeonTextData[i]); + + // save _g284_thingData + for (uint16 thingIndex = 0; thingIndex < 16; ++thingIndex) + for (uint16 i = 0; i < g235_ThingDataWordCount[thingIndex] * _dungeonMan->_g278_dungeonFileHeader._thingCounts[thingIndex]; ++i) + file->writeUint16BE(_dungeonMan->_g284_thingData[thingIndex][i]); + + // save _g276_dungeonRawMapData + for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._rawMapDataSize; ++i) + file->writeByte(_dungeonMan->_g276_dungeonRawMapData[i]); file->flush(); file->finalize(); delete file; + + if (!saveAndPlayChoice) { + _eventMan->f77_hideMouse(); + warning(false, "MISSING CODE: F0444_STARTEND_Endgame"); + } + if (!_championMan->_g415_leaderEmptyHanded) { + _championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load += champHandObjWeight; + } + _g524_restartGameAllowed = true; + _menuMan->f457_drawEnabledMenus(); + _eventMan->f77_hideMouse(); } Common::String DMEngine::getSavefileName(uint16 slot) { -- cgit v1.2.3 From 715ef2d404994737f72de13fd4824ca1ec1708c1 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 26 Jul 2016 00:18:31 +0200 Subject: DM: Debug loading savegames, add missing save loading parts --- engines/dm/champion.cpp | 28 ++++++++- engines/dm/dm.cpp | 17 ++++-- engines/dm/dungeonman.cpp | 146 +++++++++++++++++++++++++--------------------- engines/dm/dungeonman.h | 10 +--- engines/dm/loadsave.cpp | 93 +++++++++++++++++------------ 5 files changed, 176 insertions(+), 118 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 508605baea..a9cfe7a2ef 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1787,8 +1787,32 @@ ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) { } void ChampionMan::f278_resetDataToStartGame() { - if (!_vm->_g298_newGame) - error("MISSING CODE: stuff for resetting for loaded games"); + if (!_vm->_g298_newGame) { + Thing L0787_T_Thing; + if ((L0787_T_Thing = _g414_leaderHandObject) == Thing::_none) { + _g415_leaderEmptyHanded = true; + _g413_leaderHandObjectIconIndex = kM1_IconIndiceNone; + _vm->_eventMan->f69_setMousePointer(); + } else { + f297_putObjectInLeaderHand(L0787_T_Thing, true); /* This call will add the weight of the leader hand object to the Load of the leader a first time */ + } + Champion *L0788_ps_Champion = _gK71_champions; + int16 L0785_i_ChampionIndex; + for (L0785_i_ChampionIndex = k0_ChampionFirst; L0785_i_ChampionIndex < _g305_partyChampionCount; L0785_i_ChampionIndex++, L0788_ps_Champion++) { + clearFlag(L0788_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand); + setFlag(L0788_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon); + } + f293_drawAllChampionStates(); + if ((L0785_i_ChampionIndex = _g411_leaderIndex) != kM1_ChampionNone) { + _g411_leaderIndex = kM1_ChampionNone; + _vm->_eventMan->f368_commandSetLeader((ChampionIndex)L0785_i_ChampionIndex); + } + if ((L0785_i_ChampionIndex = _g514_magicCasterChampionIndex) != kM1_ChampionNone) { + _g514_magicCasterChampionIndex = kM1_ChampionNone; + _vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(L0785_i_ChampionIndex); + } + return; + } _g414_leaderHandObject = Thing::_none; _g413_leaderHandObjectIconIndex = kM1_IconIndiceNone; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index cd69479961..dc778aa734 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -277,8 +277,11 @@ void DMEngine::f462_startGame() { f3_processNewPartyMap(_dungeonMan->_g309_partyMapIndex); if (!_g298_newGame) { - warning(false, "TODO: loading game"); - assert(false); + _displayMan->_g578_useByteBoxCoordinates = false; + f22_delay(1); + _displayMan->D24_fillScreenBox(g61_boxScreenTop, k0_ColorBlack); + _displayMan->D24_fillScreenBox(g62_boxScreenRight, k0_ColorBlack); + _displayMan->D24_fillScreenBox(g63_boxScreenBottom, k0_ColorBlack); } else { _displayMan->_g578_useByteBoxCoordinates = false; _displayMan->D24_fillScreenBox(g61_boxScreenTop, k0_ColorBlack); @@ -331,10 +334,12 @@ Common::Error DMEngine::run() { } void DMEngine::f2_gameloop() { - warning(false, "DUMMY CODE: SETTING PARTY POS AND DIRECTION"); - _dungeonMan->_g306_partyMapX = 9; - _dungeonMan->_g307_partyMapY = 9; - _dungeonMan->_g308_partyDir = kDirWest; + if (_g298_newGame) { + warning(false, "DUMMY CODE: SETTING PARTY POS AND DIRECTION"); + _dungeonMan->_g306_partyMapX = 9; + _dungeonMan->_g307_partyMapY = 9; + _dungeonMan->_g308_partyDir = kDirWest; + } _g318_waitForInputMaxVerticalBlankCount = 10; while (true) { diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 38658ce601..da7d2dafa0 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -421,6 +421,7 @@ DungeonMan::~DungeonMan() { for (uint16 i = 0; i < 16; ++i) { delete[] _g284_thingData[i]; } + delete[] _g276_dungeonRawMapData; } void DungeonMan::f455_decompressDungeonFile() { @@ -535,108 +536,119 @@ const Thing Thing::_explRebirthStep1(0xFFE4); // @ C0xFFE4_THING_EXPLOSION_REBIR const Thing Thing::_explRebirthStep2(0xFFE5); // @ C0xFFE5_THING_EXPLOSION_REBIRTH_STEP2 const Thing Thing::_party(0xFFFF); // @ C0xFFFF_THING_PARTY -void DungeonMan::f434_loadDungeonFile() { - - if(!_rawDunFileData) +void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) { + if (_vm->_g298_newGame) f455_decompressDungeonFile(); - Common::MemoryReadStream dunDataStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO); + + Common::ReadStream *dunDataStream = nullptr; + if (file) { // if loading a save + dunDataStream = file; + } else { // else read dungeon.dat + assert(_rawDunFileData && _rawDunFileDataSize); + dunDataStream = new Common::MemoryReadStream(_rawDunFileData, _rawDunFileDataSize, DisposeAfterUse::NO); + } // initialize _g278_dungeonFileHeader - _g278_dungeonFileHeader._dungeonId = _g278_dungeonFileHeader._ornamentRandomSeed = dunDataStream.readUint16BE(); - _g278_dungeonFileHeader._rawMapDataSize = dunDataStream.readUint16BE(); - _g278_dungeonFileHeader._mapCount = dunDataStream.readByte(); - dunDataStream.readByte(); // discard 1 byte - _g278_dungeonFileHeader._textDataWordCount = dunDataStream.readUint16BE(); - uint16 partyPosition = dunDataStream.readUint16BE(); - _g278_dungeonFileHeader._partyStartDir = (Direction)((partyPosition >> 10) & 3); - _g278_dungeonFileHeader._partyStartPosY = (partyPosition >> 5) & 0x1F; - _g278_dungeonFileHeader._partyStartPosX = (partyPosition >> 0) & 0x1F; - _g278_dungeonFileHeader._squareFirstThingCount = dunDataStream.readUint16BE(); + _g278_dungeonFileHeader._ornamentRandomSeed = dunDataStream->readUint16BE(); + _g278_dungeonFileHeader._rawMapDataSize = dunDataStream->readUint16BE(); + _g278_dungeonFileHeader._mapCount = dunDataStream->readByte(); + dunDataStream->readByte(); // discard 1 byte + _g278_dungeonFileHeader._textDataWordCount = dunDataStream->readUint16BE(); + _g278_dungeonFileHeader._partyStartLocation = dunDataStream->readUint16BE(); + _g278_dungeonFileHeader._squareFirstThingCount = dunDataStream->readUint16BE(); for (uint16 i = 0; i < k16_ThingTypeTotal; ++i) - _g278_dungeonFileHeader._thingCounts[i] = dunDataStream.readUint16BE(); + _g278_dungeonFileHeader._thingCounts[i] = dunDataStream->readUint16BE(); // init party position and mapindex if (_vm->_g298_newGame) { - _g308_partyDir = _g278_dungeonFileHeader._partyStartDir; - _g306_partyMapX = _g278_dungeonFileHeader._partyStartPosX; - _g307_partyMapY = _g278_dungeonFileHeader._partyStartPosY; + uint16 startLoc = _g278_dungeonFileHeader._partyStartLocation; + _g308_partyDir = (Direction)((startLoc >> 10) & 3); + _g306_partyMapX = startLoc & 0x1F; + _g307_partyMapY = (startLoc >> 5) & 0x1F; _g309_partyMapIndex = 0; } // load map data - delete[] _g277_dungeonMaps; - _g277_dungeonMaps = new Map[_g278_dungeonFileHeader._mapCount]; - for (uint16 i = 0; i < _g278_dungeonFileHeader._mapCount; ++i) { - _g277_dungeonMaps[i]._rawDunDataOffset = dunDataStream.readUint16BE(); - dunDataStream.readUint32BE(); // discard 4 bytes - _g277_dungeonMaps[i]._offsetMapX = dunDataStream.readByte(); - _g277_dungeonMaps[i]._offsetMapY = dunDataStream.readByte(); + if (!_vm->_g523_restartGameRequest) { + delete[] _g277_dungeonMaps; + _g277_dungeonMaps = new Map[_g278_dungeonFileHeader._mapCount]; + } - uint16 tmp = dunDataStream.readUint16BE(); + for (uint16 i = 0; i < _g278_dungeonFileHeader._mapCount; ++i) { + _g277_dungeonMaps[i]._rawDunDataOffset = dunDataStream->readUint16BE(); + dunDataStream->readUint32BE(); // discard 4 bytes + _g277_dungeonMaps[i]._offsetMapX = dunDataStream->readByte(); + _g277_dungeonMaps[i]._offsetMapY = dunDataStream->readByte(); + + uint16 tmp = dunDataStream->readUint16BE(); _g277_dungeonMaps[i]._height = tmp >> 11; _g277_dungeonMaps[i]._width = (tmp >> 6) & 0x1F; - _g277_dungeonMaps[i]._level = tmp & 0x1F; // Only used in DMII + _g277_dungeonMaps[i]._level = tmp & 0x3F; // Only used in DMII - tmp = dunDataStream.readUint16BE(); + tmp = dunDataStream->readUint16BE(); _g277_dungeonMaps[i]._randFloorOrnCount = tmp >> 12; _g277_dungeonMaps[i]._floorOrnCount = (tmp >> 8) & 0xF; _g277_dungeonMaps[i]._randWallOrnCount = (tmp >> 4) & 0xF; _g277_dungeonMaps[i]._wallOrnCount = tmp & 0xF; - tmp = dunDataStream.readUint16BE(); + tmp = dunDataStream->readUint16BE(); _g277_dungeonMaps[i]._difficulty = tmp >> 12; _g277_dungeonMaps[i]._creatureTypeCount = (tmp >> 4) & 0xF; _g277_dungeonMaps[i]._doorOrnCount = tmp & 0xF; - tmp = dunDataStream.readUint16BE(); + tmp = dunDataStream->readUint16BE(); _g277_dungeonMaps[i]._doorSet1 = (tmp >> 12) & 0xF; _g277_dungeonMaps[i]._doorSet0 = (tmp >> 8) & 0xF; _g277_dungeonMaps[i]._wallSet = (WallSet)((tmp >> 4) & 0xF); _g277_dungeonMaps[i]._floorSet = (FloorSet)(tmp & 0xF); } - // TODO: ??? is this - begin - delete[] _g281_dungeonMapsFirstColumnIndex; - _g281_dungeonMapsFirstColumnIndex = new uint16[_g278_dungeonFileHeader._mapCount]; + // load column stuff thingy + if (!_vm->_g523_restartGameRequest) { + delete[] _g281_dungeonMapsFirstColumnIndex; + _g281_dungeonMapsFirstColumnIndex = new uint16[_g278_dungeonFileHeader._mapCount]; + } uint16 columCount = 0; for (uint16 i = 0; i < _g278_dungeonFileHeader._mapCount; ++i) { _g281_dungeonMapsFirstColumnIndex[i] = columCount; columCount += _g277_dungeonMaps[i]._width + 1; } _g282_dungeonColumCount = columCount; - // TODO: ??? is this - end - uint32 actualSquareFirstThingCount = _g278_dungeonFileHeader._squareFirstThingCount; - if (_vm->_g298_newGame) // TODO: what purpose does this serve? + if (_vm->_g298_newGame) _g278_dungeonFileHeader._squareFirstThingCount += 300; - // TODO: ??? is this - begin - delete[] _g280_dungeonColumnsCumulativeSquareThingCount; - _g280_dungeonColumnsCumulativeSquareThingCount = new uint16[columCount]; + if (!_vm->_g523_restartGameRequest) { + delete[] _g280_dungeonColumnsCumulativeSquareThingCount; + _g280_dungeonColumnsCumulativeSquareThingCount = new uint16[columCount]; + } for (uint16 i = 0; i < columCount; ++i) - _g280_dungeonColumnsCumulativeSquareThingCount[i] = dunDataStream.readUint16BE(); - // TODO: ??? is this - end + _g280_dungeonColumnsCumulativeSquareThingCount[i] = dunDataStream->readUint16BE(); - // TODO: ??? is this - begin - delete[] _g283_squareFirstThings; - _g283_squareFirstThings = new Thing[_g278_dungeonFileHeader._squareFirstThingCount]; + + // load sqaure first things + if (!_vm->_g523_restartGameRequest) { + delete[] _g283_squareFirstThings; + _g283_squareFirstThings = new Thing[_g278_dungeonFileHeader._squareFirstThingCount]; + } for (uint16 i = 0; i < actualSquareFirstThingCount; ++i) - _g283_squareFirstThings[i].set(dunDataStream.readUint16BE()); + _g283_squareFirstThings[i].set(dunDataStream->readUint16BE()); if (_vm->_g298_newGame) for (uint16 i = 0; i < 300; ++i) _g283_squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none; - // TODO: ??? is this - end // load text data - delete[] _g260_dungeonTextData; - _g260_dungeonTextData = new uint16[_g278_dungeonFileHeader._textDataWordCount]; + if (!_vm->_g523_restartGameRequest) { + delete[] _g260_dungeonTextData; + _g260_dungeonTextData = new uint16[_g278_dungeonFileHeader._textDataWordCount]; + } for (uint16 i = 0; i < _g278_dungeonFileHeader._textDataWordCount; ++i) - _g260_dungeonTextData[i] = dunDataStream.readUint16BE(); + _g260_dungeonTextData[i] = dunDataStream->readUint16BE(); + - // TODO: ??? what this if (_vm->_g298_newGame) _vm->_timeline->_g369_eventMaxCount = 100; @@ -651,35 +663,26 @@ void DungeonMan::f434_loadDungeonFile() { if (thingStoreWordCount == 0) continue; - if (_g284_thingData[thingType]) { + if (!_vm->_g523_restartGameRequest) { delete[] _g284_thingData[thingType]; + _g284_thingData[thingType] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount]; } - _g284_thingData[thingType] = new uint16[_g278_dungeonFileHeader._thingCounts[thingType] * thingStoreWordCount]; - if (thingType == k4_GroupThingType) { + if ((thingType == k4_GroupThingType || thingType == k14_ProjectileThingType) && !file) { // !file because save files have diff. structure than dungeon.dat for (uint16 i = 0; i < thingCount; ++i) { uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount; for (uint16 j = 0; j < thingStoreWordCount; ++j) { if (j == 2 || j == 3) - nextSlot[j] = dunDataStream.readByte(); + nextSlot[j] = dunDataStream->readByte(); else - nextSlot[j] = dunDataStream.readUint16BE(); + nextSlot[j] = dunDataStream->readUint16BE(); } } - } else if (thingType == k14_ProjectileThingType) { - for (uint16 i = 0; i < thingCount; ++i) { - uint16 *nextSlot = _g284_thingData[thingType] + i * thingStoreWordCount; - nextSlot[0] = dunDataStream.readUint16BE(); - nextSlot[1] = dunDataStream.readUint16BE(); - nextSlot[2] = dunDataStream.readByte(); - nextSlot[3] = dunDataStream.readByte(); - nextSlot[4] = dunDataStream.readUint16BE(); - } } else { for (uint16 i = 0; i < thingCount; ++i) { uint16 *nextSlot = _g284_thingData[thingType] + i *thingStoreWordCount; for (uint16 j = 0; j < thingStoreWordCount; ++j) - nextSlot[j] = dunDataStream.readUint16BE(); + nextSlot[j] = dunDataStream->readUint16BE(); } } @@ -693,8 +696,13 @@ void DungeonMan::f434_loadDungeonFile() { } // load map data - if (!_vm->_g523_restartGameRequest) - _g276_dungeonRawMapData = _rawDunFileData + dunDataStream.pos(); + if (!_vm->_g523_restartGameRequest) { + delete[] _g276_dungeonRawMapData; + _g276_dungeonRawMapData = new byte[_g278_dungeonFileHeader._rawMapDataSize]; + } + + for (uint32 i = 0; i < _g278_dungeonFileHeader._rawMapDataSize; ++i) + _g276_dungeonRawMapData[i] = dunDataStream->readByte(); if (!_vm->_g523_restartGameRequest) { @@ -712,6 +720,10 @@ void DungeonMan::f434_loadDungeonFile() { } } } + + if (!file) { // this means that we created a new MemoryReadStream + delete file; + } // the deletion of the function parameter 'file' happens elsewhere } void DungeonMan::f173_setCurrentMap(uint16 mapIndex) { diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 34aef8d5c4..6fed1848a9 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -605,14 +605,11 @@ public: }; // wrapper for bytes which are used as squares struct DungeonFileHeader { - uint16 _dungeonId; - // equal to dungeonId uint16 _ornamentRandomSeed; - uint32 _rawMapDataSize; + uint16 _rawMapDataSize; uint8 _mapCount; uint16 _textDataWordCount; - Direction _partyStartDir; // @ InitialPartyLocation - uint16 _partyStartPosX, _partyStartPosY; + uint16 _partyStartLocation; uint16 _squareFirstThingCount; // @ SquareFirstThingCount uint16 _thingCounts[16]; // @ ThingCount[16] }; // @ DUNGEON_HEADER @@ -681,7 +678,7 @@ public: uint16 *f157_getSquareFirstThingData(int16 mapX, int16 mapY); // @ F0157_DUNGEON_GetSquareFirstThingData // TODO: this does stuff other than load the file! - void f434_loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC + void f434_loadDungeonFile(Common::InSaveFile *file); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC void f174_setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap bool f149_isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove @@ -740,7 +737,6 @@ public: Map *_g277_dungeonMaps; // @ G0277_ps_DungeonMaps - // does not have to be freed byte *_g276_dungeonRawMapData; // @ G0276_puc_DungeonRawMapData int16 _g265_currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 86060d5c9b..ddacff5785 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -42,11 +42,20 @@ namespace DM { #define C2_FORMAT_DM_AMIGA_2X_PC98_X68000_FM_TOWNS_CSB_ATARI_ST 2 #define C3_PLATFORM_AMIGA 3 #define C10_DUNGEON_DM 10 + LoadgameResponse DMEngine::f435_loadgame(int16 slot) { Common::String fileName; Common::SaveFileManager *saveFileManager = nullptr; Common::InSaveFile *file = nullptr; + struct { + int16 _g528_saveFormat = 0; + int16 saveAndPlayChoice = 0; + int32 _g525_gameId = 0; + int16 _g527_platform = 0; + uint16 _g526_dungeonId = 0; + } dmSaveHeader; + if (!_g298_newGame) { fileName = getSavefileName(slot); saveFileManager = _system->getSavefileManager(); @@ -69,8 +78,6 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) { goto T0435004; }*/ - warning(false, "DUMMY CODE in f435_loadgame setting _g298_newGame to k1_modeLoadDungeon"); - _g298_newGame = k1_modeLoadDungeon; SaveGameHeader header; readSaveGameHeader(file, &header); @@ -78,6 +85,14 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) { warning(false, "MISSING CODE: missing check for matching format and platform in save in f435_loadgame"); + dmSaveHeader._g528_saveFormat = file->readSint16BE(); + dmSaveHeader.saveAndPlayChoice = file->readSint16BE(); + dmSaveHeader._g525_gameId = file->readSint32BE(); + dmSaveHeader._g527_platform = file->readSint16BE(); + dmSaveHeader._g526_dungeonId = file->readUint16BE(); + + _g525_gameId = dmSaveHeader._g525_gameId; + _g313_gameTime = file->readSint32BE(); // G0349_ul_LastRandomNumber = L1371_s_GlobalData.LastRandomNumber; _championMan->_g305_partyChampionCount = file->readUint16BE(); @@ -108,10 +123,14 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) { _timeline->load3_eventsPart(file); _timeline->load4_timelinePart(file); - _g525_gameId = file->readSint32BE(); + // read sentinel + uint32 sentinel = file->readUint32BE(); + assert(sentinel == 0x6f85e3d3); } - _dungeonMan->f434_loadDungeonFile(); + _dungeonMan->f434_loadDungeonFile(file); + delete file; + if (_g298_newGame) { _timeline->f233_initTimeline(); _groupMan->f196_initActiveGroups(); @@ -124,16 +143,15 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) { F0436_STARTEND_FadeToPalette(_vm->_displayMan->_g347_paletteTopAndBottomScreen); }*/ } else { - _g528_saveFormat = file->readSint16BE(); - _g527_platform = file->readSint16BE(); - _g526_dungeonId = file->readUint16BE(); + _g528_saveFormat = dmSaveHeader._g528_saveFormat; + _g527_platform = dmSaveHeader._g527_platform; + _g526_dungeonId = dmSaveHeader._g526_dungeonId; - _g524_restartGameAllowed = true; + _g524_restartGameAllowed = true; warning(false, "MISSING CDOE: F0427_DIALOG_Draw in f435_loadgame"); } _championMan->_g303_partyDead = false; - delete file; return k1_LoadgameSuccess; } @@ -168,6 +186,12 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String writeSaveGameHeader(file, desc); + file->writeSint16BE(_g528_saveFormat); + file->writeSint16BE(saveAndPlayChoice); + file->writeSint32BE(_g525_gameId); + file->writeSint16BE(_g527_platform); + file->writeUint16BE(_g526_dungeonId); + // write C0_SAVE_PART_GLOBAL_DATA part file->writeSint32BE(_g313_gameTime); //L1348_s_GlobalData.LastRandomNumber = G0349_ul_LastRandomNumber; @@ -199,24 +223,18 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String // write C4_SAVE_PART_TIMELINE part _timeline->save4_timelinePart(file); - file->writeSint32BE(_g525_gameId); - file->writeSint16BE(_g528_saveFormat); - file->writeSint16BE(_g527_platform); - file->writeUint16BE(_g526_dungeonId); - - file->writeSint16BE(saveAndPlayChoice); + // write sentinel + file->writeUint32BE(0x6f85e3d3); // save _g278_dungeonFileHeader { DungeonFileHeader &header = _dungeonMan->_g278_dungeonFileHeader; - file->writeUint16BE(header._dungeonId); file->writeUint16BE(header._ornamentRandomSeed); - file->writeUint32BE(header._rawMapDataSize); + file->writeUint16BE(header._rawMapDataSize); file->writeByte(header._mapCount); + file->writeByte(0); // to match the structure of dungeon.dat, will be discarded file->writeUint16BE(header._textDataWordCount); - file->writeUint16BE(header._partyStartDir); - file->writeUint16BE(header._partyStartPosX); - file->writeUint16BE(header._partyStartPosY); + file->writeUint16BE(header._partyStartLocation); file->writeUint16BE(header._squareFirstThingCount); for (uint16 i = 0; i < 16; ++i) file->writeUint16BE(header._thingCounts[i]); @@ -225,23 +243,26 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String // save _g277_dungeonMaps for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._mapCount; ++i) { Map &map = _dungeonMan->_g277_dungeonMaps[i]; - file->writeUint32BE(map._rawDunDataOffset); + uint16 tmp; + + file->writeUint16BE(map._rawDunDataOffset); + file->writeUint32BE(0); // to match the structure of dungeon.dat, will be discarded file->writeByte(map._offsetMapX); file->writeByte(map._offsetMapY); - file->writeByte(map._level); - file->writeByte(map._width); - file->writeByte(map._height); - file->writeByte(map._wallOrnCount); - file->writeByte(map._randWallOrnCount); - file->writeByte(map._floorOrnCount); - file->writeByte(map._randFloorOrnCount); - file->writeByte(map._doorOrnCount); - file->writeByte(map._creatureTypeCount); - file->writeByte(map._difficulty); - file->writeSint16BE(map._floorSet); - file->writeSint16BE(map._wallSet); - file->writeByte(map._doorSet0); - file->writeByte(map._doorSet1); + + tmp = ((map._height & 0x1F) << 11) | ((map._width & 0x1F) << 6) | (map._level & 0x3F); + file->writeUint16BE(tmp); + + tmp = ((map._randFloorOrnCount & 0xF) << 12) | ((map._floorOrnCount & 0xF) << 8) + | ((map._randWallOrnCount & 0xF) << 4) | (map._wallOrnCount & 0xF); + file->writeUint16BE(tmp); + + tmp = ((map._difficulty & 0xF) << 12) | ((map._creatureTypeCount & 0xF) << 4) | (map._doorOrnCount & 0xF); + file->writeUint16BE(tmp); + + tmp = ((map._doorSet1 & 0xF) << 12) | ((map._doorSet0 & 0xF) << 8) + | ((map._wallSet & 0xF) << 4) | (map._floorSet & 0xF); + file->writeUint16BE(tmp); } // save _g280_dungeonColumnsCumulativeSquareThingCount @@ -262,7 +283,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String file->writeUint16BE(_dungeonMan->_g284_thingData[thingIndex][i]); // save _g276_dungeonRawMapData - for (uint16 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._rawMapDataSize; ++i) + for (uint32 i = 0; i < _dungeonMan->_g278_dungeonFileHeader._rawMapDataSize; ++i) file->writeByte(_dungeonMan->_g276_dungeonRawMapData[i]); file->flush(); -- cgit v1.2.3 From 4de7ff5703f9cff9df242aaabf6ac1d88ce4a5c2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 26 Jul 2016 00:13:06 +0200 Subject: DM: First pass of refactoring in f280_addCandidateChampionToParty --- engines/dm/champion.cpp | 240 ++++++++++++++++++++++-------------------------- 1 file changed, 111 insertions(+), 129 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index a9cfe7a2ef..3c8d3a5798 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1819,116 +1819,95 @@ void ChampionMan::f278_resetDataToStartGame() { _g415_leaderEmptyHanded = true; } - void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) { - Thing L0793_T_Thing; - uint16 L0794_ui_Multiple; -#define AL0794_ui_ViewCell L0794_ui_Multiple -#define AL0794_ui_SlotIndex L0794_ui_Multiple -#define AL0794_ui_CharacterIndex L0794_ui_Multiple -#define AL0794_ui_StatisticIndex L0794_ui_Multiple -#define AL0794_ui_SkillIndex L0794_ui_Multiple - int16 L0795_i_HiddenSkillIndex; - uint16 L0796_ui_Multiple; -#define AL0796_ui_Character L0796_ui_Multiple -#define AL0796_ui_SkillValue L0796_ui_Multiple -#define AL0796_ui_ThingType L0796_ui_Multiple - Champion* L0797_ps_Champion; - char* L0798_pc_Character; - uint16 L0799_ui_PreviousPartyChampionCount; - uint16 L0800_ui_Multiple; -#define AL0800_B_ChampionTitleCopied L0800_ui_Multiple -#define AL0800_ui_HiddenSkillCounter L0800_ui_Multiple - uint16 L0801_ui_SlotIndex; - int16 L0802_i_MapX; - int16 L0803_i_MapY; - uint16 L0804_ui_ChampionObjectsCell; - int16 L0805_i_ObjectAllowedSlots; - int32 L0806_l_BaseSkillExperience; - char L0807_ac_DecodedChampionText[77]; - - if (!_vm->_championMan->_g415_leaderEmptyHanded) { + if (!_vm->_championMan->_g415_leaderEmptyHanded) return; - } - if (_vm->_championMan->_g305_partyChampionCount == 4) { + + if (_vm->_championMan->_g305_partyChampionCount == 4) return; - } - L0797_ps_Champion = &_vm->_championMan->_gK71_champions[L0799_ui_PreviousPartyChampionCount = _vm->_championMan->_g305_partyChampionCount]; - L0797_ps_Champion->resetToZero(); + + uint16 previousPartyChampionCount = _vm->_championMan->_g305_partyChampionCount; + Champion *championPtr = &_vm->_championMan->_gK71_champions[previousPartyChampionCount]; + championPtr->resetToZero(); // Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portaits could be missing in the data) _vm->_displayMan->_g578_useByteBoxCoordinates = true; - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), L0797_ps_Champion->_portrait, gBoxChampionPortrait, _vm->_championMan->M27_getChampionPortraitX(championPortraitIndex), _vm->_championMan->M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency); - L0797_ps_Champion->_actionIndex = k255_ChampionActionNone; - L0797_ps_Champion->_enableActionEventIndex = -1; - L0797_ps_Champion->_hideDamageReceivedIndex = -1; - L0797_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir; - AL0794_ui_ViewCell = k0_ViewCellFronLeft; - while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone) { - AL0794_ui_ViewCell++; - } - L0797_ps_Champion->_cell = (ViewCell)M21_normalizeModulo4(AL0794_ui_ViewCell + _vm->_dungeonMan->_g308_partyDir); - L0797_ps_Champion->_attributes = k0x0400_ChampionAttributeIcon; - L0797_ps_Champion->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir; - L0797_ps_Champion->_food = 1500 + _vm->getRandomNumber(256); - L0797_ps_Champion->_water = 1500 + _vm->getRandomNumber(256); - for (AL0794_ui_SlotIndex = k0_ChampionSlotReadyHand; AL0794_ui_SlotIndex < k30_ChampionSlotChest_1; AL0794_ui_SlotIndex++) { - L0797_ps_Champion->_slots[AL0794_ui_SlotIndex] = Thing::_none; - } - L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); - while ((L0793_T_Thing.getType()) != k2_TextstringType) { - L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing); - } - _vm->_dungeonMan->f168_decodeText(L0798_pc_Character = L0807_ac_DecodedChampionText, L0793_T_Thing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible)); - AL0794_ui_CharacterIndex = 0; - while ((AL0796_ui_Character = *L0798_pc_Character++) != '\n') { /* New line */ - L0797_ps_Champion->_name[AL0794_ui_CharacterIndex++] = AL0796_ui_Character; - } - L0797_ps_Champion->_name[AL0794_ui_CharacterIndex] = '\0'; - AL0794_ui_CharacterIndex = 0; - AL0800_B_ChampionTitleCopied = false; + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, gBoxChampionPortrait, _vm->_championMan->M27_getChampionPortraitX(championPortraitIndex), _vm->_championMan->M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency); + championPtr->_actionIndex = k255_ChampionActionNone; + championPtr->_enableActionEventIndex = -1; + championPtr->_hideDamageReceivedIndex = -1; + championPtr->_dir = _vm->_dungeonMan->_g308_partyDir; + uint16 viewCell = k0_ViewCellFronLeft; + while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone) { + viewCell++; + } + championPtr->_cell = (ViewCell)M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir); + championPtr->_attributes = k0x0400_ChampionAttributeIcon; + championPtr->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir; + championPtr->_food = 1500 + _vm->getRandomNumber(256); + championPtr->_water = 1500 + _vm->getRandomNumber(256); + for (int16 slotIdx = k0_ChampionSlotReadyHand; slotIdx < k30_ChampionSlotChest_1; slotIdx++) + championPtr->_slots[slotIdx] = Thing::_none; + + Thing curThing = _vm->_dungeonMan->f161_getSquareFirstThing(_vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY); + while (curThing.getType() != k2_TextstringType) + curThing = _vm->_dungeonMan->f159_getNextThing(curThing); + + char L0807_ac_DecodedChampionText[77]; + char *decodedStringPtr = L0807_ac_DecodedChampionText; + _vm->_dungeonMan->f168_decodeText(decodedStringPtr, curThing, (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible)); + + uint16 charIdx = 0; + char tmpChar; + while ((tmpChar = *decodedStringPtr++) != '\n') { /* New line */ + championPtr->_name[charIdx++] = tmpChar; + } + + championPtr->_name[charIdx] = '\0'; + charIdx = 0; + bool championTitleCopiedFl = false; for (;;) { /*_Infinite loop_*/ - AL0796_ui_Character = *L0798_pc_Character++; - if (AL0796_ui_Character == '\n') { /* New line */ - if (AL0800_B_ChampionTitleCopied) + tmpChar = *decodedStringPtr++; + if (tmpChar == '\n') { /* New line */ + if (championTitleCopiedFl) break; - AL0800_B_ChampionTitleCopied = true; + championTitleCopiedFl = true; } else { - L0797_ps_Champion->_title[AL0794_ui_CharacterIndex++] = AL0796_ui_Character; - } - } - L0797_ps_Champion->_title[AL0794_ui_CharacterIndex] = '\0'; - if (*L0798_pc_Character++ == 'M') { - setFlag(L0797_ps_Champion->_attributes, k0x0010_ChampionAttributeMale); - } - L0798_pc_Character++; - L0797_ps_Champion->_currHealth = L0797_ps_Champion->_maxHealth = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4); - L0798_pc_Character += 4; - L0797_ps_Champion->_currStamina = L0797_ps_Champion->_maxStamina = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4); - L0798_pc_Character += 4; - L0797_ps_Champion->_currMana = L0797_ps_Champion->_maxMana = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 4); - L0798_pc_Character += 4; - L0798_pc_Character++; - for (AL0794_ui_StatisticIndex = k0_ChampionStatLuck; AL0794_ui_StatisticIndex <= k6_ChampionStatAntifire; AL0794_ui_StatisticIndex++) { - L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k2_ChampionStatMinimum] = 30; - L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k1_ChampionStatCurrent] = L0797_ps_Champion->_statistics[AL0794_ui_StatisticIndex][k0_ChampionStatMaximum] = _vm->_championMan->f279_getDecodedValue(L0798_pc_Character, 2); - L0798_pc_Character += 2; - } - L0797_ps_Champion->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10; - L0798_pc_Character++; - for (AL0794_ui_SkillIndex = k4_ChampionSkillSwing; AL0794_ui_SkillIndex <= k19_ChampionSkillWater; AL0794_ui_SkillIndex++) { - if ((AL0796_ui_SkillValue = *L0798_pc_Character++ - 'A') > 0) { - L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = 125L << AL0796_ui_SkillValue; - } - } - for (AL0794_ui_SkillIndex = k0_ChampionSkillFighter; AL0794_ui_SkillIndex <= k3_ChampionSkillWizard; AL0794_ui_SkillIndex++) { - L0806_l_BaseSkillExperience = 0; - L0795_i_HiddenSkillIndex = (AL0794_ui_SkillIndex + 1) << 2; - for (AL0800_ui_HiddenSkillCounter = 0; AL0800_ui_HiddenSkillCounter < 4; AL0800_ui_HiddenSkillCounter++) { - L0806_l_BaseSkillExperience += L0797_ps_Champion->_skills[L0795_i_HiddenSkillIndex + AL0800_ui_HiddenSkillCounter]._experience; - } - L0797_ps_Champion->_skills[AL0794_ui_SkillIndex]._experience = L0806_l_BaseSkillExperience; - } - _vm->_championMan->_g299_candidateChampionOrdinal = L0799_ui_PreviousPartyChampionCount + 1; + championPtr->_title[charIdx++] = tmpChar; + } + } + championPtr->_title[charIdx] = '\0'; + if (*decodedStringPtr++ == 'M') { + setFlag(championPtr->_attributes, k0x0010_ChampionAttributeMale); + } + decodedStringPtr++; + championPtr->_currHealth = championPtr->_maxHealth = _vm->_championMan->f279_getDecodedValue(decodedStringPtr, 4); + decodedStringPtr += 4; + championPtr->_currStamina = championPtr->_maxStamina = _vm->_championMan->f279_getDecodedValue(decodedStringPtr, 4); + decodedStringPtr += 4; + championPtr->_currMana = championPtr->_maxMana = _vm->_championMan->f279_getDecodedValue(decodedStringPtr, 4); + decodedStringPtr += 4; + decodedStringPtr++; + for (int16 statIdx = k0_ChampionStatLuck; statIdx <= k6_ChampionStatAntifire; statIdx++) { + championPtr->_statistics[statIdx][k2_ChampionStatMinimum] = 30; + championPtr->_statistics[statIdx][k1_ChampionStatCurrent] = championPtr->_statistics[statIdx][k0_ChampionStatMaximum] = _vm->_championMan->f279_getDecodedValue(decodedStringPtr, 2); + decodedStringPtr += 2; + } + championPtr->_statistics[k0_ChampionStatLuck][k2_ChampionStatMinimum] = 10; + decodedStringPtr++; + for (uint16 skillIdx = k4_ChampionSkillSwing; skillIdx <= k19_ChampionSkillWater; skillIdx++) { + int skillValue = *decodedStringPtr++ - 'A'; + if (skillValue > 0) + championPtr->_skills[skillIdx]._experience = 125L << skillValue; + } + for (uint16 skillIdx = k0_ChampionSkillFighter; skillIdx <= k3_ChampionSkillWizard; skillIdx++) { + int32 baseSkillExperience = 0; + int16 hiddenSkillIndex = (skillIdx + 1) << 2; + for (uint16 hiddenIdx = 0; hiddenIdx < 4; hiddenIdx++) + baseSkillExperience += championPtr->_skills[hiddenSkillIndex + hiddenIdx]._experience; + + championPtr->_skills[skillIdx]._experience = baseSkillExperience; + } + _vm->_championMan->_g299_candidateChampionOrdinal = previousPartyChampionCount + 1; if (++_vm->_championMan->_g305_partyChampionCount == 1) { _vm->_eventMan->f368_commandSetLeader(k0_ChampionFirst); _vm->_menuMan->_g508_refreshActionArea = true; @@ -1936,41 +1915,44 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) _vm->_menuMan->f388_clearActingChampion(); _vm->_menuMan->f386_drawActionIcon((ChampionIndex)(_vm->_championMan->_g305_partyChampionCount - 1)); } - L0802_i_MapX = _vm->_dungeonMan->_g306_partyMapX; - L0803_i_MapY = _vm->_dungeonMan->_g307_partyMapY; - L0804_ui_ChampionObjectsCell = returnOppositeDir(_vm->_dungeonMan->_g308_partyDir); - L0802_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L0803_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir]; - L0793_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0802_i_MapX, L0803_i_MapY); - AL0794_ui_SlotIndex = k13_ChampionSlotBackpackLine_1_1; - while (L0793_T_Thing != Thing::_endOfList) { - if (((AL0796_ui_ThingType = (L0793_T_Thing.getType())) > k3_SensorThingType) && ((L0793_T_Thing.getCell()) == L0804_ui_ChampionObjectsCell)) { - L0805_i_ObjectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L0793_T_Thing)]._allowedSlots; - switch (AL0796_ui_ThingType) { + + int16 curMapX = _vm->_dungeonMan->_g306_partyMapX; + int16 curMapY = _vm->_dungeonMan->_g307_partyMapY; + uint16 championObjectsCell = returnOppositeDir(_vm->_dungeonMan->_g308_partyDir); + curMapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], curMapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir]; + curThing = _vm->_dungeonMan->f161_getSquareFirstThing(curMapX, curMapY); + int16 slotIdx = k13_ChampionSlotBackpackLine_1_1; + while (curThing != Thing::_endOfList) { + ThingType thingType = curThing.getType(); + if ((thingType > k3_SensorThingType) && (curThing.getCell() == championObjectsCell)) { + int16 objectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(curThing)]._allowedSlots; + uint16 curSlotIndex; + switch (thingType) { case k6_ArmourThingType: - for (L0801_ui_SlotIndex = k2_ChampionSlotHead; L0801_ui_SlotIndex <= k5_ChampionSlotFeet; L0801_ui_SlotIndex++) { - if (L0805_i_ObjectAllowedSlots & gSlotMasks[L0801_ui_SlotIndex]) + for (curSlotIndex = k2_ChampionSlotHead; curSlotIndex <= k5_ChampionSlotFeet; curSlotIndex++) { + if (objectAllowedSlots & gSlotMasks[curSlotIndex]) goto T0280048; } - if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) { - L0801_ui_SlotIndex = k10_ChampionSlotNeck; + if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none)) { + curSlotIndex = k10_ChampionSlotNeck; } else { goto T0280046; } break; case k5_WeaponThingType: - if (L0797_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) { - L0801_ui_SlotIndex = k1_ChampionSlotActionHand; + if (championPtr->_slots[k1_ChampionSlotActionHand] == Thing::_none) { + curSlotIndex = k1_ChampionSlotActionHand; } else { goto T0280046; } break; case k7_ScrollThingType: case k8_PotionThingType: - if (L0797_ps_Champion->_slots[k11_ChampionSlotPouch_1] == Thing::_none) { - L0801_ui_SlotIndex = k11_ChampionSlotPouch_1; + if (championPtr->_slots[k11_ChampionSlotPouch_1] == Thing::_none) { + curSlotIndex = k11_ChampionSlotPouch_1; } else { - if (L0797_ps_Champion->_slots[k6_ChampionSlotPouch_2] == Thing::_none) { - L0801_ui_SlotIndex = k6_ChampionSlotPouch_2; + if (championPtr->_slots[k6_ChampionSlotPouch_2] == Thing::_none) { + curSlotIndex = k6_ChampionSlotPouch_2; } else { goto T0280046; } @@ -1979,21 +1961,21 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) case k9_ContainerThingType: case k10_JunkThingType: T0280046: - if ((L0805_i_ObjectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (L0797_ps_Champion->_slots[k10_ChampionSlotNeck] == Thing::_none)) { - L0801_ui_SlotIndex = k10_ChampionSlotNeck; + if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none)) { + curSlotIndex = k10_ChampionSlotNeck; } else { - L0801_ui_SlotIndex = AL0794_ui_SlotIndex++; + curSlotIndex = slotIdx++; } } T0280048: - if (L0797_ps_Champion->_slots[L0801_ui_SlotIndex] != Thing::_none) { + if (championPtr->_slots[curSlotIndex] != Thing::_none) { goto T0280046; } - _vm->_championMan->f301_addObjectInSlot((ChampionIndex)L0799_ui_PreviousPartyChampionCount, L0793_T_Thing, (ChampionSlot)L0801_ui_SlotIndex); + _vm->_championMan->f301_addObjectInSlot((ChampionIndex)previousPartyChampionCount, curThing, (ChampionSlot)curSlotIndex); } - L0793_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0793_T_Thing); + curThing = _vm->_dungeonMan->f159_getNextThing(curThing); } - _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)L0799_ui_PreviousPartyChampionCount); + _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)previousPartyChampionCount); _vm->_menuMan->f456_drawDisabledMenu();; } -- cgit v1.2.3 From 698eb12770eae71b2e0f14df36573bf86cb6b62e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 26 Jul 2016 09:57:39 +0200 Subject: DM: Rename a variable in f287_drawChampionBarGraphs --- engines/dm/champion.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 3c8d3a5798..5d1d664573 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1982,40 +1982,40 @@ T0280048: void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) { int16 barGraphHeights[3]; Champion *champ = &_vm->_championMan->_gK71_champions[champIndex]; - int16 AL0842_i_BarGraphIndex = 0; + int16 barGraphIdx = 0; if (champ->_currHealth > 0) { int32 barGraphHeight = (((int32)champ->_currHealth << 10) * 25) / champ->_maxHealth; if (barGraphHeight & 0x000003FF) { - barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10) + 1; + barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + 1; } else { - barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10); + barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10); } } else { - barGraphHeights[AL0842_i_BarGraphIndex++] = 0; + barGraphHeights[barGraphIdx++] = 0; } if (champ->_currStamina > 0) { int32 barGraphHeight = (((int32)champ->_currStamina << 10) * 25) / champ->_maxStamina; if (barGraphHeight & 0x000003FF) { - barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10) + 1; + barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + 1; } else { - barGraphHeights[AL0842_i_BarGraphIndex++] = (barGraphHeight >> 10); + barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10); } } else { - barGraphHeights[AL0842_i_BarGraphIndex++] = 0; + barGraphHeights[barGraphIdx++] = 0; } if (champ->_currMana > 0) { if (champ->_currMana > champ->_maxMana) { - barGraphHeights[AL0842_i_BarGraphIndex] = 25; + barGraphHeights[barGraphIdx] = 25; } else { int32 barGraphHeight = (((int32)champ->_currMana << 10) * 25) / champ->_maxMana; if (barGraphHeight & 0x000003FF) { - barGraphHeights[AL0842_i_BarGraphIndex] = (barGraphHeight >> 10) + 1; + barGraphHeights[barGraphIdx] = (barGraphHeight >> 10) + 1; } else { - barGraphHeights[AL0842_i_BarGraphIndex] = (barGraphHeight >> 10); + barGraphHeights[barGraphIdx] = (barGraphHeight >> 10); } } } else { - barGraphHeights[AL0842_i_BarGraphIndex] = 0; + barGraphHeights[barGraphIdx] = 0; } _vm->_eventMan->f78_showMouse(); -- cgit v1.2.3 From 133404c635620fcfb4a0e19c026e97217b4e1374 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 26 Jul 2016 10:37:12 +0200 Subject: DM: Fix compilation with MSVC9, some light renaming --- engines/dm/loadsave.cpp | 34 ++++++++++++++++++++-------------- engines/dm/loadsave.h | 2 -- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index ddacff5785..7440653b0c 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -49,13 +49,19 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) { Common::InSaveFile *file = nullptr; struct { - int16 _g528_saveFormat = 0; - int16 saveAndPlayChoice = 0; - int32 _g525_gameId = 0; - int16 _g527_platform = 0; - uint16 _g526_dungeonId = 0; + int16 _saveFormat; + int16 _saveAndPlayChoice; + int32 _gameId; + int16 _platform; + uint16 _dungeonId; } dmSaveHeader; + dmSaveHeader._saveFormat = 0; + dmSaveHeader._saveAndPlayChoice = 0; + dmSaveHeader._gameId = 0; + dmSaveHeader._platform = 0; + dmSaveHeader._dungeonId = 0; + if (!_g298_newGame) { fileName = getSavefileName(slot); saveFileManager = _system->getSavefileManager(); @@ -85,13 +91,13 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) { warning(false, "MISSING CODE: missing check for matching format and platform in save in f435_loadgame"); - dmSaveHeader._g528_saveFormat = file->readSint16BE(); - dmSaveHeader.saveAndPlayChoice = file->readSint16BE(); - dmSaveHeader._g525_gameId = file->readSint32BE(); - dmSaveHeader._g527_platform = file->readSint16BE(); - dmSaveHeader._g526_dungeonId = file->readUint16BE(); + dmSaveHeader._saveFormat = file->readSint16BE(); + dmSaveHeader._saveAndPlayChoice = file->readSint16BE(); + dmSaveHeader._gameId = file->readSint32BE(); + dmSaveHeader._platform = file->readSint16BE(); + dmSaveHeader._dungeonId = file->readUint16BE(); - _g525_gameId = dmSaveHeader._g525_gameId; + _g525_gameId = dmSaveHeader._gameId; _g313_gameTime = file->readSint32BE(); // G0349_ul_LastRandomNumber = L1371_s_GlobalData.LastRandomNumber; @@ -143,9 +149,9 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) { F0436_STARTEND_FadeToPalette(_vm->_displayMan->_g347_paletteTopAndBottomScreen); }*/ } else { - _g528_saveFormat = dmSaveHeader._g528_saveFormat; - _g527_platform = dmSaveHeader._g527_platform; - _g526_dungeonId = dmSaveHeader._g526_dungeonId; + _g528_saveFormat = dmSaveHeader._saveFormat; + _g527_platform = dmSaveHeader._platform; + _g526_dungeonId = dmSaveHeader._dungeonId; _g524_restartGameAllowed = true; warning(false, "MISSING CDOE: F0427_DIALOG_Draw in f435_loadgame"); diff --git a/engines/dm/loadsave.h b/engines/dm/loadsave.h index 85ed8a01da..a224966ff5 100644 --- a/engines/dm/loadsave.h +++ b/engines/dm/loadsave.h @@ -32,8 +32,6 @@ namespace DM { -; - class LoadsaveMan { DMEngine *_vm; public: -- cgit v1.2.3 From 4b066bf6f54bdb70738e3ce3afaff49556c77b28 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 26 Jul 2016 11:27:37 +0200 Subject: DM: Update todos --- engines/dm/TODOs/methodtree.txt | 2 ++ engines/dm/TODOs/todo.txt | 13 ++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index f790d50c6e..cbd8d1fbba 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -1,3 +1,5 @@ +# This file is obsolete + F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF F0113_DUNGEONVIEW_DrawField // stub method F0133_VIDEO_BlitBoxFilledWithMaskedBitmap // dummy diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index d4162722e9..e5cca0af12 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -9,23 +9,22 @@ Bugs: Drawing door ornaments segfaults when going back to the start Placing one of the play icons from the top right corner into one of the champions' hands will crash the engine Sometimes putting stuff in the player's hand segfaults - Footprints are everywhere Object display is a bit mixed up with regards to which cell is it drawn in - The last resurrected character can't have stuff in their left hand, segfaults if I try to put stuff into it + Method cthulu messes up the callstack Possible bugs: - k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON - possible garbage value return in f140_getObjectWeight + - After loading, creatures are in the wrong cells of a square + Todo: Add wiki entry for DM - Rename GraphicIndice enum entires and have their name include GraphicIndice + I forgot to add localization warnings - Attend to Arnaud's notes on github - Attend to sev's notes on github - Double check enums with hex literals, I think I screwed the regex when processing them - Double check strcat, strstr usages, I might have messed them up in many places + Double check enums with hex literals + Double check strcat, strstr usages I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions Finish stuff: -- cgit v1.2.3 From c8ab7843303710b8784a3a6525978fcbd1ea98f0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 26 Jul 2016 11:43:44 +0200 Subject: DM: Get rid of labels and GOTOs in f280_addCandidateChampionToParty --- engines/dm/champion.cpp | 72 ++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 5d1d664573..6695611286 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1928,48 +1928,60 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) int16 objectAllowedSlots = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(curThing)]._allowedSlots; uint16 curSlotIndex; switch (thingType) { - case k6_ArmourThingType: + case k6_ArmourThingType: { + bool skipCheck = false; for (curSlotIndex = k2_ChampionSlotHead; curSlotIndex <= k5_ChampionSlotFeet; curSlotIndex++) { - if (objectAllowedSlots & gSlotMasks[curSlotIndex]) - goto T0280048; + if (objectAllowedSlots & gSlotMasks[curSlotIndex]) { + skipCheck = true; + break; + } } - if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none)) { + + if (skipCheck) + break; + + if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none)) curSlotIndex = k10_ChampionSlotNeck; - } else { - goto T0280046; - } + else + curSlotIndex = slotIdx++; + break; + } case k5_WeaponThingType: - if (championPtr->_slots[k1_ChampionSlotActionHand] == Thing::_none) { + if (championPtr->_slots[k1_ChampionSlotActionHand] == Thing::_none) curSlotIndex = k1_ChampionSlotActionHand; - } else { - goto T0280046; - } + else if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none)) + curSlotIndex = k10_ChampionSlotNeck; + else + curSlotIndex = slotIdx++; break; case k7_ScrollThingType: case k8_PotionThingType: - if (championPtr->_slots[k11_ChampionSlotPouch_1] == Thing::_none) { + if (championPtr->_slots[k11_ChampionSlotPouch_1] == Thing::_none) curSlotIndex = k11_ChampionSlotPouch_1; - } else { - if (championPtr->_slots[k6_ChampionSlotPouch_2] == Thing::_none) { - curSlotIndex = k6_ChampionSlotPouch_2; - } else { - goto T0280046; - } - } + else if (championPtr->_slots[k6_ChampionSlotPouch_2] == Thing::_none) + curSlotIndex = k6_ChampionSlotPouch_2; + else if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none)) + curSlotIndex = k10_ChampionSlotNeck; + else + curSlotIndex = slotIdx++; break; case k9_ContainerThingType: case k10_JunkThingType: -T0280046: - if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none)) { + if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none)) curSlotIndex = k10_ChampionSlotNeck; - } else { + else curSlotIndex = slotIdx++; - } + + break; + default:break; } -T0280048: - if (championPtr->_slots[curSlotIndex] != Thing::_none) { - goto T0280046; + + while (championPtr->_slots[curSlotIndex] != Thing::_none) { + if ((objectAllowedSlots & gSlotMasks[k10_ChampionSlotNeck]) && (championPtr->_slots[k10_ChampionSlotNeck] == Thing::_none)) + curSlotIndex = k10_ChampionSlotNeck; + else + curSlotIndex = slotIdx++; } _vm->_championMan->f301_addObjectInSlot((ChampionIndex)previousPartyChampionCount, curThing, (ChampionSlot)curSlotIndex); } @@ -2059,12 +2071,12 @@ uint16 ChampionMan::f309_getMaximumLoad(Champion *champ) { uint16 maximumLoad = champ->getStatistic(k1_ChampionStatStrength, k1_ChampionStatCurrent) * 8 + 100; maximumLoad = f306_getStaminaAdjustedValue(champ, maximumLoad); int16 wounds = champ->getWounds(); - if (wounds) { + if (wounds) maximumLoad -= maximumLoad >> (champ->getWoundsFlag(k0x0010_ChampionWoundLegs) ? 2 : 3); - } - if (_vm->_objectMan->f33_getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots) { + + if (_vm->_objectMan->f33_getIconIndex(champ->getSlot(k5_ChampionSlotFeet)) == k119_IconIndiceArmourElvenBoots) maximumLoad += maximumLoad * 16; - } + maximumLoad += 9; maximumLoad -= maximumLoad % 10; return maximumLoad; -- cgit v1.2.3 From dfc2d7e769ef16db0a86b889e02b0fb6d37ccaf6 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 26 Jul 2016 13:13:38 +0200 Subject: DM: Fix broken champion action hand slots --- engines/dm/TODOs/todo.txt | 4 ++-- engines/dm/eventman.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index e5cca0af12..b2bac2aa71 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -3,12 +3,12 @@ Bugs: Broken colour palette Portraits, alcoves etc. look broken from afar Arrow and hand display is messed up + Items are displayed in the wrong cells + Levers look the same after pulling them Logic: When object are put on the right side of the current square, they disappear Drawing door ornaments segfaults when going back to the start - Placing one of the play icons from the top right corner into one of the champions' hands will crash the engine - Sometimes putting stuff in the player's hand segfaults Object display is a bit mixed up with regards to which cell is it drawn in Method cthulu messes up the callstack diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 7ccf647e7d..ec25758b24 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -1149,7 +1149,7 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat champ->resetSkillsToZero(); for (uint16 i = 0; i < 12; i++) { - uint16 statIndex = _vm->_rnd->getRandomNumber(7); + uint16 statIndex = _vm->getRandomNumber(7); champ->getStatistic((ChampionStatisticType)statIndex, k1_ChampionStatCurrent)++; // returns reference champ->getStatistic((ChampionStatisticType)statIndex, k0_ChampionStatMaximum)++; // returns reference } -- cgit v1.2.3 From f0a916197a6776ea5af733f2b0bdb2a0c731a19b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 26 Jul 2016 11:56:15 +0200 Subject: DM: Use ternary operator in f287_drawChampionBarGraphs to reduce code duplication --- engines/dm/champion.cpp | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 6695611286..4b9809dc21 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1974,7 +1974,8 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) curSlotIndex = slotIdx++; break; - default:break; + default: + break; } while (championPtr->_slots[curSlotIndex] != Thing::_none) { @@ -1997,34 +1998,22 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) { int16 barGraphIdx = 0; if (champ->_currHealth > 0) { int32 barGraphHeight = (((int32)champ->_currHealth << 10) * 25) / champ->_maxHealth; - if (barGraphHeight & 0x000003FF) { - barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + 1; - } else { - barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10); - } - } else { + barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + (barGraphHeight & 0x000003FF) ? 1 : 0; + } else barGraphHeights[barGraphIdx++] = 0; - } + if (champ->_currStamina > 0) { int32 barGraphHeight = (((int32)champ->_currStamina << 10) * 25) / champ->_maxStamina; - if (barGraphHeight & 0x000003FF) { - barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + 1; - } else { - barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10); - } - } else { + barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + (barGraphHeight & 0x000003FF) ? 1 : 0; + } else barGraphHeights[barGraphIdx++] = 0; - } + if (champ->_currMana > 0) { - if (champ->_currMana > champ->_maxMana) { + if (champ->_currMana > champ->_maxMana) barGraphHeights[barGraphIdx] = 25; - } else { + else { int32 barGraphHeight = (((int32)champ->_currMana << 10) * 25) / champ->_maxMana; - if (barGraphHeight & 0x000003FF) { - barGraphHeights[barGraphIdx] = (barGraphHeight >> 10) + 1; - } else { - barGraphHeights[barGraphIdx] = (barGraphHeight >> 10); - } + barGraphHeights[barGraphIdx] = (barGraphHeight >> 10) + (barGraphHeight & 0x000003FF) ? 1 : 0; } } else { barGraphHeights[barGraphIdx] = 0; -- cgit v1.2.3 From 700c4327d3f957a839bfc4dbb4f425f163553d1c Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 26 Jul 2016 13:24:48 +0200 Subject: DM: Move DMEngine::_rnd to private, fix erroneous ranges with random number generations --- engines/dm/TODOs/todo.txt | 3 +-- engines/dm/champion.cpp | 10 +++++----- engines/dm/dm.h | 2 +- engines/dm/gfx.cpp | 10 +++++----- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index b2bac2aa71..65e7251161 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -8,9 +8,8 @@ Bugs: Logic: When object are put on the right side of the current square, they disappear - Drawing door ornaments segfaults when going back to the start Object display is a bit mixed up with regards to which cell is it drawn in - Method cthulu messes up the callstack + Possible bugs: diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 4b9809dc21..a7d27d1011 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -207,8 +207,8 @@ bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 f304_addSkillExperience(champIndex, k10_ChampionSkillThrow, experience); kineticEnergy += weaponKineticEnergy; int16 skillLevel = f303_getSkillLevel((ChampionIndex)champIndex, k10_ChampionSkillThrow); - kineticEnergy += _vm->_rnd->getRandomNumber(16) + (kineticEnergy >> 1) + skillLevel; - int16 attack = f26_getBoundedValue((uint16)40, (uint16)((skillLevel << 3) + _vm->_rnd->getRandomNumber(31)), (uint16)200); + kineticEnergy += _vm->getRandomNumber(16) + (kineticEnergy >> 1) + skillLevel; + int16 attack = f26_getBoundedValue((uint16)40, (uint16)((skillLevel << 3) + _vm->getRandomNumber(32)), (uint16)200); int16 stepEnergy = MAX(5, 11 - skillLevel); _vm->_projexpl->f212_projectileCreate(curThing, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + side), @@ -595,7 +595,7 @@ Thing ChampionMan::f298_getObjectRemovedFromLeaderHand() { uint16 ChampionMan::f312_getStrength(int16 champIndex, int16 slotIndex) { Champion *curChampion = &_gK71_champions[champIndex]; - int16 strength = _vm->_rnd->getRandomNumber(15) + curChampion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent]; + int16 strength = _vm->getRandomNumber(16) + curChampion->_statistics[k1_ChampionStatStrength][k1_ChampionStatCurrent]; Thing curThing = curChampion->_slots[slotIndex]; uint16 objectWeight = _vm->_dungeonMan->f140_getObjectWeight(curThing); uint16 oneSixteenthMaximumLoad = f309_getMaximumLoad(curChampion) >> 4; @@ -791,7 +791,7 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in if (attack <= 0) return 0; - int16 adjustedAttack = f307_getStatisticAdjustedAttack(curChampion, k4_ChampionStatVitality, _vm->_rnd->getRandomNumber(127) + 10); + int16 adjustedAttack = f307_getStatisticAdjustedAttack(curChampion, k4_ChampionStatVitality, _vm->getRandomNumber(128) + 10); if (attack > adjustedAttack) { /* BUG0_45 This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the @@ -801,7 +801,7 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in wounded (because of more iterations in the loop below) */ do { - setFlag(*(uint16 *)&_g410_championPendingWounds[champIndex], (1 << _vm->_rnd->getRandomNumber(7)) & allowedWounds); + setFlag(*(uint16 *)&_g410_championPendingWounds[champIndex], (1 << _vm->getRandomNumber(8)) & allowedWounds); } while ((attack > (adjustedAttack <<= 1)) && adjustedAttack); } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 7d2f925120..007f22c3fe 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -230,8 +230,8 @@ private: Console *_console; byte *_g562_entranceDoorAnimSteps[10]; // @ G0562_apuc_Bitmap_EntranceDoorAnimationSteps byte *_g564_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits -public: Common::RandomSource *_rnd; +public: DisplayMan *_displayMan; DungeonMan *_dungeonMan; EventManager *_eventMan; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index d264bf1c79..eb9012e601 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1346,10 +1346,10 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d memmove(_g74_tmpBitmap, f489_getNativeBitmapOrGraphic(doorNativeBitmapIndices[doorType = door->getType()]), byteCount * 2); f109_drawDoorOrnament(door->getOrnOrdinal(), viewDoorOrnIndex); if (getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[doorType]._attributes, k0x0004_MaskDoorInfo_Animated)) { - if (_vm->_rnd->getRandomNumber(1)) { + if (_vm->getRandomNumber(2)) { f130_flipBitmapHorizontal(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight); } - if (_vm->_rnd->getRandomNumber(1)) { + if (_vm->getRandomNumber(2)) { f131_flipVertical(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight); } } @@ -3632,7 +3632,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; AL_6_bitmapRedBanana = _g74_tmpBitmap; } f133_blitBoxFilledWithMaskedBitmap(AL_6_bitmapRedBanana, _g296_bitmapViewport, nullptr, f492_getDerivedBitmap(k0_DerivedBitmapViewport), g105_BoxExplosionPattern_D0C, - _vm->_rnd->getRandomNumber(4) + 87, _vm->_rnd->getRandomNumber(64), + _vm->getRandomNumber(4) + 87, _vm->getRandomNumber(64), 224, (Color)(k0x0080_BlitDoNotUseMask | k10_ColorFlesh), 0, 0, 136, 93); warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); warning(false, "IGNORED CODE: F0493_CACHE_AddDerivedBitmap"); @@ -3655,9 +3655,9 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:; } AL_6_bitmapRedBanana = f114_getExplosionBitmap(AL_4_explosionAspectIndex, explosionScale, byteWidth, heightRedEagle); T0115200_DrawExplosion: - flipVertical = _vm->_rnd->getRandomNumber(2); + flipVertical = _vm->getRandomNumber(2); paddingPixelCount = 0; - if (flipHorizontal = _vm->_rnd->getRandomNumber(2)) { + if (flipHorizontal = _vm->getRandomNumber(2)) { paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1; /* Number of unused pixels in the units on the right of the bitmap */ } boxByteGreen._y2 = MIN(135, explosionCoordinates[1] + (heightRedEagle >> 1)); -- cgit v1.2.3 From 111d5ddc3836e9fb6f94a42bb76ae1db4bcfef59 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 27 Jul 2016 13:58:02 +0200 Subject: DM: Fix champion bargraphs --- engines/dm/TODOs/todo.txt | 3 ++- engines/dm/champion.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 65e7251161..1ef449d1c5 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -9,7 +9,8 @@ Bugs: Logic: When object are put on the right side of the current square, they disappear Object display is a bit mixed up with regards to which cell is it drawn in - + Method cthulu messes up the callstack sometimes + Possible bugs: diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index a7d27d1011..b600f28683 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1998,13 +1998,13 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) { int16 barGraphIdx = 0; if (champ->_currHealth > 0) { int32 barGraphHeight = (((int32)champ->_currHealth << 10) * 25) / champ->_maxHealth; - barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + (barGraphHeight & 0x000003FF) ? 1 : 0; + barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + ((barGraphHeight & 0x000003FF) ? 1 : 0); } else barGraphHeights[barGraphIdx++] = 0; if (champ->_currStamina > 0) { int32 barGraphHeight = (((int32)champ->_currStamina << 10) * 25) / champ->_maxStamina; - barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + (barGraphHeight & 0x000003FF) ? 1 : 0; + barGraphHeights[barGraphIdx++] = (barGraphHeight >> 10) + ((barGraphHeight & 0x000003FF) ? 1 : 0); } else barGraphHeights[barGraphIdx++] = 0; @@ -2013,7 +2013,7 @@ void ChampionMan::f287_drawChampionBarGraphs(ChampionIndex champIndex) { barGraphHeights[barGraphIdx] = 25; else { int32 barGraphHeight = (((int32)champ->_currMana << 10) * 25) / champ->_maxMana; - barGraphHeights[barGraphIdx] = (barGraphHeight >> 10) + (barGraphHeight & 0x000003FF) ? 1 : 0; + barGraphHeights[barGraphIdx] = (barGraphHeight >> 10) + ((barGraphHeight & 0x000003FF) ? 1 : 0); } } else { barGraphHeights[barGraphIdx] = 0; -- cgit v1.2.3 From 571a6b7a07e60468516318286cf733a7de948f1b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 26 Jul 2016 14:40:04 +0200 Subject: DM: Refactoring of f292_drawChampionState, including removing its GOTOs --- engines/dm/champion.cpp | 313 ++++++++++++++++++++++-------------------------- 1 file changed, 144 insertions(+), 169 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b600f28683..2db64816cc 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1829,7 +1829,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) uint16 previousPartyChampionCount = _vm->_championMan->_g305_partyChampionCount; Champion *championPtr = &_vm->_championMan->_gK71_champions[previousPartyChampionCount]; championPtr->resetToZero(); - // Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portaits could be missing in the data) + // Strangerke - TODO: Check if the new code is possible to run on the older version (example: the portraits could be missing in the data) _vm->_displayMan->_g578_useByteBoxCoordinates = true; _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), championPtr->_portrait, gBoxChampionPortrait, _vm->_championMan->M27_getChampionPortraitX(championPortraitIndex), _vm->_championMan->M28_getChampionPortraitY(championPortraitIndex), k128_byteWidth, k16_byteWidth, kM1_ColorNoTransparency); championPtr->_actionIndex = k255_ChampionActionNone; @@ -1837,9 +1837,9 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) championPtr->_hideDamageReceivedIndex = -1; championPtr->_dir = _vm->_dungeonMan->_g308_partyDir; uint16 viewCell = k0_ViewCellFronLeft; - while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone) { + while (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir)) != kM1_ChampionNone) viewCell++; - } + championPtr->_cell = (ViewCell)M21_normalizeModulo4(viewCell + _vm->_dungeonMan->_g308_partyDir); championPtr->_attributes = k0x0400_ChampionAttributeIcon; championPtr->_directionMaximumDamageReceived = _vm->_dungeonMan->_g308_partyDir; @@ -1858,9 +1858,8 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) uint16 charIdx = 0; char tmpChar; - while ((tmpChar = *decodedStringPtr++) != '\n') { /* New line */ + while ((tmpChar = *decodedStringPtr++) != '\n') championPtr->_name[charIdx++] = tmpChar; - } championPtr->_name[charIdx] = '\0'; charIdx = 0; @@ -1871,14 +1870,13 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) if (championTitleCopiedFl) break; championTitleCopiedFl = true; - } else { + } else championPtr->_title[charIdx++] = tmpChar; - } } championPtr->_title[charIdx] = '\0'; - if (*decodedStringPtr++ == 'M') { + if (*decodedStringPtr++ == 'M') setFlag(championPtr->_attributes, k0x0010_ChampionAttributeMale); - } + decodedStringPtr++; championPtr->_currHealth = championPtr->_maxHealth = _vm->_championMan->f279_getDecodedValue(decodedStringPtr, 4); decodedStringPtr += 4; @@ -2072,174 +2070,161 @@ uint16 ChampionMan::f309_getMaximumLoad(Champion *champ) { } void ChampionMan::f292_drawChampionState(ChampionIndex champIndex) { - uint16 L0862_ui_ChampionAttributes; - bool L0863_B_IsInventoryChampion; - int16 L0864_i_Multiple; -#define AL0864_i_BorderCount L0864_i_Multiple -#define AL0864_i_ColorIndex L0864_i_Multiple -#define AL0864_i_Load L0864_i_Multiple -#define AL0864_i_ChampionIconIndex L0864_i_Multiple -#define AL0864_i_StatisticIndex L0864_i_Multiple -#define AL0864_i_SlotIndex L0864_i_Multiple - Champion* L0865_ps_Champion; - char* L0866_pc_ChampionName; - char L0867_c_ChampionTitleFirstCharacter; - int16 L0868_i_ChampionStatusBoxX; - int16 L0869_i_ChampionTitleX; - int16 L0870_i_Multiple; -#define AL0870_i_NativeBitmapIndex L0870_i_Multiple -#define AL0870_i_Color L0870_i_Multiple - Box L0871_s_Box; - int16 L0872_ai_NativeBitmapIndices[3]; - - - L0868_i_ChampionStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing; - L0865_ps_Champion = &_gK71_champions[champIndex]; - L0862_ui_ChampionAttributes = L0865_ps_Champion->_attributes; - if (!getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand)) { + int16 championStatusBoxX = champIndex * k69_ChampionStatusBoxSpacing; + Champion *curChampion = &_gK71_champions[champIndex]; + uint16 championAttributes = curChampion->_attributes; + if (!getFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand)) return; - } - L0863_B_IsInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal); + + bool isInventoryChampion = (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal); _vm->_displayMan->_g578_useByteBoxCoordinates = false; _vm->_eventMan->f78_showMouse(); - if (getFlag(L0862_ui_ChampionAttributes, k0x1000_ChampionAttributeStatusBox)) { - L0871_s_Box._y1 = 0; - L0871_s_Box._y2 = 28; - L0871_s_Box._x2 = (L0871_s_Box._x1 = L0868_i_ChampionStatusBoxX) + 66; - if (L0865_ps_Champion->_currHealth) { - _vm->_displayMan->D24_fillScreenBox(L0871_s_Box, k12_ColorDarkestGray); + if (getFlag(championAttributes, k0x1000_ChampionAttributeStatusBox)) { + Box box; + box._y1 = 0; + box._y2 = 28; + box._x1 = championStatusBoxX; + box._x2 = box._x1 + 66; + if (curChampion->_currHealth) { + _vm->_displayMan->D24_fillScreenBox(box, k12_ColorDarkestGray); + int16 nativeBitmapIndices[3]; for (uint16 i = 0; i < 3; ++i) - L0872_ai_NativeBitmapIndices[i] = 0; - AL0864_i_BorderCount = 0; - if (_g407_party._fireShieldDefense > 0) { - L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k38_BorderPartyFireshieldIndice; - } - if (_g407_party._spellShieldDefense > 0) { - L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k39_BorderPartySpellshieldIndice; - } - if ((_g407_party._shieldDefense > 0) || L0865_ps_Champion->_shieldDefense) { - L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount++] = k37_BorderPartyShieldIndice; - } - while (AL0864_i_BorderCount--) { - _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(L0872_ai_NativeBitmapIndices[AL0864_i_BorderCount]), &L0871_s_Box, k40_byteWidth, k10_ColorFlesh, 29); - } - if (L0863_B_IsInventoryChampion) { + nativeBitmapIndices[i] = 0; + + uint16 borderCount = 0; + if (_g407_party._fireShieldDefense > 0) + nativeBitmapIndices[borderCount++] = k38_BorderPartyFireshieldIndice; + + if (_g407_party._spellShieldDefense > 0) + nativeBitmapIndices[borderCount++] = k39_BorderPartySpellshieldIndice; + + if ((_g407_party._shieldDefense > 0) || curChampion->_shieldDefense) + nativeBitmapIndices[borderCount++] = k37_BorderPartyShieldIndice; + + while (borderCount--) + _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndices[borderCount]), &box, k40_byteWidth, k10_ColorFlesh, 29); + + if (isInventoryChampion) { _vm->_inventoryMan->f354_drawStatusBoxPortrait(champIndex); - setFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics); - } else { - setFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand); - } + setFlag(championAttributes, k0x0100_ChampionAttributeStatistics); + } else + setFlag(championAttributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x2000_ChampionAttributeWounds | k0x8000_ChampionAttributeActionHand); } else { - _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), &L0871_s_Box, k40_byteWidth, kM1_ColorNoTransparency, 29); - _vm->_textMan->f53_printToLogicalScreen(L0868_i_ChampionStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, L0865_ps_Champion->_name); + _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k8_StatusBoxDeadChampion), &box, k40_byteWidth, kM1_ColorNoTransparency, 29); + _vm->_textMan->f53_printToLogicalScreen(championStatusBoxX + 1, 5, k13_ColorLightestGray, k1_ColorDarkGary, curChampion->_name); _vm->_menuMan->f386_drawActionIcon(champIndex); - goto T0292042; + + clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand); + _vm->_eventMan->f77_hideMouse(); + return; } } - if (!(L0865_ps_Champion->_currHealth)) - goto T0292042; - if (getFlag(L0862_ui_ChampionAttributes, k0x0080_ChampionAttributeNameTitle)) { - AL0864_i_ColorIndex = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; - if (L0863_B_IsInventoryChampion) { - _vm->_textMan->f52_printToViewport(3, 7, (Color)AL0864_i_ColorIndex, L0866_pc_ChampionName = L0865_ps_Champion->_name); - L0869_i_ChampionTitleX = 6 * strlen(L0866_pc_ChampionName) + 3; - L0867_c_ChampionTitleFirstCharacter = L0865_ps_Champion->_title[0]; - if ((L0867_c_ChampionTitleFirstCharacter != ',') && (L0867_c_ChampionTitleFirstCharacter != ';') && (L0867_c_ChampionTitleFirstCharacter != '-')) { - L0869_i_ChampionTitleX += 6; - } - _vm->_textMan->f52_printToViewport(L0869_i_ChampionTitleX, 7, (Color)AL0864_i_ColorIndex, L0865_ps_Champion->_title); - setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); + if (!(curChampion->_currHealth)) { + clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand); + _vm->_eventMan->f77_hideMouse(); + return; + } + + if (getFlag(championAttributes, k0x0080_ChampionAttributeNameTitle)) { + Color nameColor = (champIndex == _g411_leaderIndex) ? k9_ColorGold : k13_ColorLightestGray; + if (isInventoryChampion) { + char *championName = curChampion->_name; + _vm->_textMan->f52_printToViewport(3, 7, nameColor, championName); + int16 championTitleX = 6 * strlen(championName) + 3; + char titleFirstCharacter = curChampion->_title[0]; + if ((titleFirstCharacter != ',') && (titleFirstCharacter != ';') && (titleFirstCharacter != '-')) + championTitleX += 6; + + _vm->_textMan->f52_printToViewport(championTitleX, 7, nameColor, curChampion->_title); + setFlag(championAttributes, k0x4000_ChampionAttributeViewport); } else { - L0871_s_Box._y1 = 0; - L0871_s_Box._y2 = 6; - L0871_s_Box._x2 = (L0871_s_Box._x1 = L0868_i_ChampionStatusBoxX) + 42; - _vm->_displayMan->D24_fillScreenBox(L0871_s_Box, k1_ColorDarkGary); - _vm->_textMan->f53_printToLogicalScreen(L0868_i_ChampionStatusBoxX + 1, 5, (Color)AL0864_i_ColorIndex, k1_ColorDarkGary, L0865_ps_Champion->_name); + Box box; + box._y1 = 0; + box._y2 = 6; + box._x1 = championStatusBoxX; + box._x2 = box._x1 + 42; + _vm->_displayMan->D24_fillScreenBox(box, k1_ColorDarkGary); + _vm->_textMan->f53_printToLogicalScreen(championStatusBoxX + 1, 5, nameColor, k1_ColorDarkGary, curChampion->_name); } } - if (getFlag(L0862_ui_ChampionAttributes, k0x0100_ChampionAttributeStatistics)) { + if (getFlag(championAttributes, k0x0100_ChampionAttributeStatistics)) { f287_drawChampionBarGraphs(champIndex); - if (L0863_B_IsInventoryChampion) { - f290_drawHealthStaminaManaValues(L0865_ps_Champion); - if ((L0865_ps_Champion->_food < 0) || (L0865_ps_Champion->_water < 0) || (L0865_ps_Champion->_poisonEventCount)) { - AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice; - } else { - AL0870_i_NativeBitmapIndex = k33_SlotBoxNormalIndice; - } - _vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(AL0870_i_NativeBitmapIndex), gBoxMouth, k16_byteWidth, k12_ColorDarkestGray, 18); - AL0870_i_NativeBitmapIndex = k33_SlotBoxNormalIndice; - for (AL0864_i_StatisticIndex = k1_ChampionStatStrength; AL0864_i_StatisticIndex <= k6_ChampionStatAntifire; AL0864_i_StatisticIndex++) { - if ((L0865_ps_Champion->_statistics[AL0864_i_StatisticIndex][k1_ChampionStatCurrent] < L0865_ps_Champion->_statistics[AL0864_i_StatisticIndex][k0_ChampionStatMaximum])) { - AL0870_i_NativeBitmapIndex = k34_SlotBoxWoundedIndice; + if (isInventoryChampion) { + f290_drawHealthStaminaManaValues(curChampion); + int16 nativeBitmapIndex; + if ((curChampion->_food < 0) || (curChampion->_water < 0) || (curChampion->_poisonEventCount)) + nativeBitmapIndex = k34_SlotBoxWoundedIndice; + else + nativeBitmapIndex = k33_SlotBoxNormalIndice; + + _vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), gBoxMouth, k16_byteWidth, k12_ColorDarkestGray, 18); + nativeBitmapIndex = k33_SlotBoxNormalIndice; + for (int i = k1_ChampionStatStrength; i <= k6_ChampionStatAntifire; i++) { + if ((curChampion->_statistics[i][k1_ChampionStatCurrent] < curChampion->_statistics[i][k0_ChampionStatMaximum])) { + nativeBitmapIndex = k34_SlotBoxWoundedIndice; break; } } - _vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(AL0870_i_NativeBitmapIndex), gBoxEye, k16_byteWidth, k12_ColorDarkestGray, 18); - setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); + _vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), gBoxEye, k16_byteWidth, k12_ColorDarkestGray, 18); + setFlag(championAttributes, k0x4000_ChampionAttributeViewport); } } - if (getFlag(L0862_ui_ChampionAttributes, k0x2000_ChampionAttributeWounds)) { - for (AL0864_i_SlotIndex = L0863_B_IsInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; AL0864_i_SlotIndex >= k0_ChampionSlotReadyHand; AL0864_i_SlotIndex--) { - f291_drawSlot(champIndex, AL0864_i_SlotIndex); - } - if (L0863_B_IsInventoryChampion) { - setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); - } + if (getFlag(championAttributes, k0x2000_ChampionAttributeWounds)) { + for (int i = isInventoryChampion ? k5_ChampionSlotFeet : k1_ChampionSlotActionHand; i >= k0_ChampionSlotReadyHand; i--) + f291_drawSlot(champIndex, i); + + if (isInventoryChampion) + setFlag(championAttributes, k0x4000_ChampionAttributeViewport); } - if (getFlag(L0862_ui_ChampionAttributes, k0x0200_ChampionAttributeLoad) && L0863_B_IsInventoryChampion) { - if (L0865_ps_Champion->_load > (AL0864_i_Load = f309_getMaximumLoad(L0865_ps_Champion))) { - AL0870_i_Color = k8_ColorRed; - } else { - if (((long)L0865_ps_Champion->_load << 3) > ((long)AL0864_i_Load * 5)) { - AL0870_i_Color = k11_ColorYellow; - } else { - AL0870_i_Color = k13_ColorLightestGray; - } - } - _vm->_textMan->f52_printToViewport(104, 132, (Color)AL0870_i_Color, "LOAD "); - AL0864_i_Load = L0865_ps_Champion->_load / 10; - strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); + if (getFlag(championAttributes, k0x0200_ChampionAttributeLoad) && isInventoryChampion) { + uint16 maxLoad = f309_getMaximumLoad(curChampion); + Color loadColor; + if (curChampion->_load > maxLoad) + loadColor = k8_ColorRed; + else if (((long)curChampion->_load << 3) > ((long)maxLoad * 5)) + loadColor = k11_ColorYellow; + else + loadColor = k13_ColorLightestGray; + + _vm->_textMan->f52_printToViewport(104, 132, loadColor, "LOAD "); + maxLoad = curChampion->_load / 10; + strcpy(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, true, 3).c_str()); strcat(_vm->_g353_stringBuildBuffer, "."); - AL0864_i_Load = L0865_ps_Champion->_load - (AL0864_i_Load * 10); - strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, false, 1).c_str()); + maxLoad = curChampion->_load - (maxLoad * 10); + strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, false, 1).c_str()); strcat(_vm->_g353_stringBuildBuffer, "/"); - AL0864_i_Load = (f309_getMaximumLoad(L0865_ps_Champion) + 5) / 10; - strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(AL0864_i_Load, true, 3).c_str()); + maxLoad = (f309_getMaximumLoad(curChampion) + 5) / 10; + strcat(_vm->_g353_stringBuildBuffer, f288_getStringFromInteger(maxLoad, true, 3).c_str()); strcat(_vm->_g353_stringBuildBuffer, " KG"); - _vm->_textMan->f52_printToViewport(148, 132, (Color)AL0870_i_Color, _vm->_g353_stringBuildBuffer); - setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); + _vm->_textMan->f52_printToViewport(148, 132, loadColor, _vm->_g353_stringBuildBuffer); + setFlag(championAttributes, k0x4000_ChampionAttributeViewport); } - AL0864_i_ChampionIconIndex = M26_championIconIndex(L0865_ps_Champion->_cell, _vm->_dungeonMan->_g308_partyDir); - if (getFlag(L0862_ui_ChampionAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(AL0864_i_ChampionIconIndex))) { - _vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0864_i_ChampionIconIndex], g46_ChampionColor[champIndex]); - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[AL0864_i_ChampionIconIndex], _vm->_championMan->M26_championIconIndex(L0865_ps_Champion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen); + uint16 championIconIndex = M26_championIconIndex(curChampion->_cell, _vm->_dungeonMan->_g308_partyDir); + if (getFlag(championAttributes, k0x0400_ChampionAttributeIcon) && (_vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap != _vm->M0_indexToOrdinal(championIconIndex))) { + _vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[championIconIndex], g46_ChampionColor[champIndex]); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k28_ChampionIcons), _vm->_displayMan->_g348_bitmapScreen, g54_BoxChampionIcons[championIconIndex], _vm->_championMan->M26_championIconIndex(curChampion->_dir, _vm->_dungeonMan->_g308_partyDir) * 19, 0, k40_byteWidth, k160_byteWidthScreen, k12_ColorDarkestGray, 14, k200_heightScreen); } - if (getFlag(L0862_ui_ChampionAttributes, k0x0800_ChampionAttributePanel) && L0863_B_IsInventoryChampion) { - if (_vm->_g333_pressingMouth) { + if (getFlag(championAttributes, k0x0800_ChampionAttributePanel) && isInventoryChampion) { + if (_vm->_g333_pressingMouth) _vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned(); - } else { - if (_vm->_g331_pressingEye) { - if (_g415_leaderEmptyHanded) { - _vm->_inventoryMan->f351_drawChampionSkillsAndStatistics(); - } - } else { - _vm->_inventoryMan->f347_drawPanel(); - } - } - setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); + else if (_vm->_g331_pressingEye) { + if (_g415_leaderEmptyHanded) + _vm->_inventoryMan->f351_drawChampionSkillsAndStatistics(); + } else + _vm->_inventoryMan->f347_drawPanel(); + + setFlag(championAttributes, k0x4000_ChampionAttributeViewport); } - if (getFlag(L0862_ui_ChampionAttributes, k0x8000_ChampionAttributeActionHand)) { + if (getFlag(championAttributes, k0x8000_ChampionAttributeActionHand)) { f291_drawSlot(champIndex, k1_ChampionSlotActionHand); _vm->_menuMan->f386_drawActionIcon(champIndex); - if (L0863_B_IsInventoryChampion) { - setFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport); - } + if (isInventoryChampion) + setFlag(championAttributes, k0x4000_ChampionAttributeViewport); } - if (getFlag(L0862_ui_ChampionAttributes, k0x4000_ChampionAttributeViewport)) { + if (getFlag(championAttributes, k0x4000_ChampionAttributeViewport)) _vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView); - } -T0292042: - clearFlag(L0865_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand); + + clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand); _vm->_eventMan->f77_hideMouse(); } @@ -2260,20 +2245,17 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) { uint16 slotBoxIndex; if (!isInventoryChamp) { /* If drawing a slot for a champion other than the champion whose inventory is open */ - if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))) { + if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))) return; - } slotBoxIndex = (champIndex << 1) + slotIndex; - } else { + } else slotBoxIndex = k8_SlotBoxInventoryFirstSlot + slotIndex; - } Thing thing; - if (slotIndex >= k30_ChampionSlotChest_1) { + if (slotIndex >= k30_ChampionSlotChest_1) thing = _vm->_inventoryMan->_g425_chestSlots[slotIndex - k30_ChampionSlotChest_1]; - } else { + else thing = champ->getSlot((ChampionSlot)slotIndex); - } SlotBox *slotBox = &_vm->_objectMan->_g30_slotBoxes[slotBoxIndex]; Box box; @@ -2282,10 +2264,8 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) { box._x2 = box._x1 + 17; box._y2 = box._y1 + 17; - - if (!isInventoryChamp) { + if (!isInventoryChamp) _vm->_eventMan->f77_hideMouse(); - } int16 iconIndex; if (thing == Thing::_none) { @@ -2294,15 +2274,13 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) { if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) { iconIndex++; nativeBitmapIndex = k34_SlotBoxWoundedIndice; - } else { + } else nativeBitmapIndex = k33_SlotBoxNormalIndice; - } } else { - if ((slotIndex >= k10_ChampionSlotNeck) && (slotIndex <= k13_ChampionSlotBackpackLine_1_1)) { + if ((slotIndex >= k10_ChampionSlotNeck) && (slotIndex <= k13_ChampionSlotBackpackLine_1_1)) iconIndex = k208_IconIndiceNeck + (slotIndex - k10_ChampionSlotNeck); - } else { + else iconIndex = k204_IconIndiceEmptyBox; - } } } else { iconIndex = _vm->_objectMan->f33_getIconIndex(thing); // BUG0_35 @@ -2310,17 +2288,15 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) { iconIndex++; } // BUG2_00 if (slotIndex <= k5_ChampionSlotFeet) { - if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) { + if (champ->getWoundsFlag((ChampionWound)(1 << slotIndex))) nativeBitmapIndex = k34_SlotBoxWoundedIndice; - } else { + else nativeBitmapIndex = k33_SlotBoxNormalIndice; - } } } - if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->M0_indexToOrdinal(champIndex) == _g506_actingChampionOrdinal)) { + if ((slotIndex == k1_ChampionSlotActionHand) && (_vm->M0_indexToOrdinal(champIndex) == _g506_actingChampionOrdinal)) nativeBitmapIndex = k35_SlotBoxActingHandIndice; - } if (nativeBitmapIndex != -1) { _vm->_displayMan->_g578_useByteBoxCoordinates = false; @@ -2335,9 +2311,8 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) { _vm->_objectMan->f38_drawIconInSlotBox(slotBoxIndex, iconIndex); - if (!isInventoryChamp) { + if (!isInventoryChamp) _vm->_eventMan->f78_showMouse(); - } } void ChampionMan::f281_renameChampion(Champion* champ) { -- cgit v1.2.3 From 2cb7938c52147966e81bc0803e5a0f68cfef551c Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 27 Jul 2016 14:24:00 +0200 Subject: DM: Fix broken champion after loading --- engines/dm/champion.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 2db64816cc..c2bfc47247 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -147,6 +147,7 @@ ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) { _g303_partyDead = false; _g414_leaderHandObject = Thing(0); _g411_leaderIndex = kM1_ChampionNone; + _g299_candidateChampionOrdinal = 0; _g300_partyIsSleeping = false; _g506_actingChampionOrdinal = 0; _g413_leaderHandObjectIconIndex = (IconIndice)0; -- cgit v1.2.3 From 2cd9c90e17b1ac5b22dce45bbb44fcdd05ea9d17 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 27 Jul 2016 16:17:20 +0200 Subject: DM: Revert from using DisplayMan::_bitmaps directly --- engines/dm/dm.h | 1 + engines/dm/gfx.cpp | 11 +---------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 007f22c3fe..e2c8923645 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -105,6 +105,7 @@ public: static const Thing _party; // @ C0xFFFF_THING_PARTY Thing() : _data(0) {} + Thing(const Thing &other) { set(other._data); } explicit Thing(uint16 d) { set(d); } void set(uint16 d) { diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index eb9012e601..2d7a99fd4e 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -2023,12 +2023,6 @@ void DisplayMan::f124_drawSquareD1C(Direction dir, int16 posX, int16 posY) { g106_BoxThievesEye_ViewPortVisibleArea._y1, k112_byteWidthViewport, 48, kM1_ColorNoTransparency, 136, 95); bitmap = f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice); - /* BUG0_74 Creatures are drawn with wrong colors when viewed through a wall with the 'Thieve's Eye' spell. The 'hole in wall' - graphic is applied to the visible area with transparency on color 10. However the visible area may contain creature graphics - that use color 9. When the bitmap is drawn below with transparency on color 9 then the creature graphic is alterated: pixels - using color 9 are transparent and the background wall is visible through the creature graphic (grey/white pixels). - To fix this bug, the 'hole in wall' graphic should be applied to the wall graphic first (in a temporary buffer) and - then the wall with the hole should be drawn over the visible area */ f132_blitToBitmap(bitmap, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea), g107_BoxThievesEyeVisibleArea, 0, 0, 48, 48, k10_ColorFlesh, 95, 95); @@ -2451,7 +2445,7 @@ void DisplayMan::f93_applyCreatureReplColors(int replacedColor, int replacementC void DisplayMan::f104_drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &f) { if (f._srcByteWidth) - f132_blitToBitmap(_bitmaps[nativeIndex], _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh); + f132_blitToBitmap(f489_getNativeBitmapOrGraphic(nativeIndex), _g296_bitmapViewport, f._box, f._srcX, f._srcY, f._srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh); } void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &f) { @@ -2645,10 +2639,7 @@ bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWall f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport, *(Box *)AL0090_puc_CoordinateSet, AL0089_i_X, 0, AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport); -/* BUG0_05 A champion portrait sensor on a wall square is visible on all sides of the wall. -If there is another sensor with a wall ornament on one side of the wall then the champion portrait is drawn over that wall ornament */ if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { -/* A portrait is 32x29 pixels */ f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), _g296_bitmapViewport, g109_BoxChampionPortraitOnWall, (_g289_championPortraitOrdinal & 0x0007) << 5, -- cgit v1.2.3 From 572d3bf82206e8db5fb2e113cb5bbce211514f33 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Wed, 27 Jul 2016 18:17:56 +0200 Subject: DM: Fix torch, lever bug and fix several Sensor methods --- engines/dm/TODOs/todo.txt | 2 +- engines/dm/dungeonman.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 1ef449d1c5..cefa603bf2 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -4,7 +4,7 @@ Bugs: Portraits, alcoves etc. look broken from afar Arrow and hand display is messed up Items are displayed in the wrong cells - Levers look the same after pulling them + Logic: When object are put on the right side of the current square, they disappear diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 6fed1848a9..bbd1499959 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -319,7 +319,7 @@ public: uint16 getData() { return (_datAndType >> 7) & 0x1FF; } // @ M40_DATA static uint16 getDataMask1(uint16 data) { return (data >> 7) & 0xF; } // @ M42_MASK1 static uint16 getDataMask2(uint16 data) { return (data >> 11) & 0xF; } // @ M43_MASK2 - void setData(int16 dat) { _datAndType = (_datAndType & 0x7F) | (dat << 7); } // @ M41_SET_DATA + void setData(uint16 dat) { _datAndType = dat; } // @ M41_SET_DATA void setTypeDisabled() { _datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED @@ -335,11 +335,11 @@ public: uint16 getTargetMapY() { return (_action >> 11); } uint16 getTargetMapX() { return (_action >> 6) & 0x1F; } Direction getTargetCell() { return (Direction)((_action >> 4) & 3); } - uint16 M47_kineticEnergy() { return (_action & 0xFF); }// @ M47_KINETIC_ENERGY - uint16 M48_stepEnergy() { return (_action >> 8) & 0xFF; }// @ M48_STEP_ENERGY - uint16 M49_localEffect() { return _action; } // @ M49_LOCAL_EFFECT - uint16 M45_healthMultiplier() { return (_action & 0xF); } // @ M45_HEALTH_MULTIPLIER - uint16 M46_ticks() { return (_action >> 4) & 0xFFF; } // @ M46_TICKS + uint16 M45_healthMultiplier() { return ((_action >> 4) & 0xF); } // @ M45_HEALTH_MULTIPLIER + uint16 M46_ticks() { return ((_action >> 4) >> 4) & 0xFFF; } // @ M46_TICKS + uint16 M47_kineticEnergy() { return ((_action >> 4) & 0xFF); }// @ M47_KINETIC_ENERGY + uint16 M48_stepEnergy() { return ((_action >> 4) >> 8) & 0xFF; }// @ M48_STEP_ENERGY + uint16 M49_localEffect() { return (_action >> 4); } // @ M49_LOCAL_EFFECT void setDatAndTypeWithOr(uint16 val) { _datAndType |= val; } -- cgit v1.2.3 From 040a02003b9dc8a245dae25eb9a63294fd1d2700 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 28 Jul 2016 17:53:42 +0200 Subject: DM: Complete ChampionMan::f281_renameChampion --- engines/dm/champion.cpp | 221 ++++++++++++++++++++++++++++++++++++++---------- engines/dm/eventman.cpp | 14 ++- engines/dm/eventman.h | 12 ++- 3 files changed, 199 insertions(+), 48 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index c2bfc47247..de0ed3efb1 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -266,7 +266,7 @@ void ChampionMan::f299_applyModifiersToStatistics(Champion *champ, int16 slotInd ThingType thingType = thing.getType(); bool cursed = false; - if ( ((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType)) + if (((thingType == k5_WeaponThingType) || (thingType == k6_ArmourThingType)) && (slotIndex >= k0_ChampionSlotReadyHand) && (slotIndex <= k12_ChampionSlotQuiverLine_1_1)) { if (thingType == k5_WeaponThingType) { Weapon *weapon = (Weapon *)_vm->_dungeonMan->f156_getThingData(thing); @@ -746,18 +746,18 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in defense /= woundCount; switch (attackType) { - case k6_attackType_PSYCHIC: - { - int16 wisdomFactor = 115 - curChampion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent]; - if (wisdomFactor <= 0) { - attack = 0; - } else { - attack = _vm->f30_getScaledProduct(attack, 6, wisdomFactor); - } - - skipScaling = true; + case k6_attackType_PSYCHIC: + { + int16 wisdomFactor = 115 - curChampion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent]; + if (wisdomFactor <= 0) { + attack = 0; + } else { + attack = _vm->f30_getScaledProduct(attack, 6, wisdomFactor); } - break; + + skipScaling = true; + } + break; case k5_attackType_MAGIC: attack = f307_getStatisticAdjustedAttack(curChampion, k5_ChampionStatAntimagic, attack); attack -= _g407_party._spellShieldDefense; @@ -780,10 +780,10 @@ int16 ChampionMan::f321_addPendingDamageAndWounds_getDamage(int16 champIndex, in attack = _vm->f30_getScaledProduct(attack, 6, 130 - defense); } - /* BUG0_44 + /* BUG0_44 A champion may take much more damage than expected after a Black Flame attack or an impact with a Fireball projectile. If the party has a fire shield defense value higher than the fire - attack value then the resulting intermediary attack value is negative and damage should be 0. + attack value then the resulting intermediary attack value is negative and damage should be 0. However, the negative value is still used for further computations and the result may be a very high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE and if attack is negative before calling F0030_MAIN_GetScaledProduct @@ -837,7 +837,7 @@ int16 ChampionMan::f313_getWoundDefense(int16 champIndex, uint16 woundIndex) { woundDefense >>= 1; woundDefense += curChampion->_actionDefense + curChampion->_shieldDefense + _g407_party._shieldDefense + armorShieldDefense; - if (woundIndex > k1_ChampionSlotActionHand) { + if (woundIndex > k1_ChampionSlotActionHand) { Thing curThing = curChampion->_slots[woundIndex]; if (curThing.getType() == k6_ArmourThingType) { ArmourInfo *armourInfo = (ArmourInfo *)_vm->_dungeonMan->f156_getThingData(curThing); @@ -1242,7 +1242,7 @@ void ChampionMan::f283_viAltarRebirth(uint16 champIndex) { curChampion->_cell = (ViewCell)numCell; } - + uint16 maximumHealth = curChampion->_maxHealth; curChampion->_maxHealth = MAX(25, maximumHealth - (maximumHealth >> 6) - 1); curChampion->_currHealth = curChampion->_maxHealth >> 1; @@ -1454,7 +1454,7 @@ void ChampionMan::f319_championKill(uint16 champIndex) { _vm->_displayMan->_g578_useByteBoxCoordinates = false; _vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[curChampionIconIndex << 2], k0_ColorBlack); _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex); - + int16 aliveChampionIndex; for (aliveChampionIndex = k0_ChampionFirst, curChampion = _vm->_championMan->_gK71_champions; aliveChampionIndex < _vm->_championMan->_g305_partyChampionCount; aliveChampionIndex++, curChampion++) { if (curChampion->_currHealth) @@ -1555,7 +1555,7 @@ void ChampionMan::f331_applyTimeEffects() { if (championPtr->_currHealth && (_vm->M0_indexToOrdinal(championIndex) != _vm->_championMan->_g299_candidateChampionOrdinal)) { uint16 wizardSkillLevel = _vm->_championMan->f303_getSkillLevel(championIndex, k3_ChampionSkillWizard) + _vm->_championMan->f303_getSkillLevel(championIndex, k2_ChampionSkillPriest); if ((championPtr->_currMana < championPtr->_maxMana) - && (timeCriteria < championPtr->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + wizardSkillLevel)) { + && (timeCriteria < championPtr->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + wizardSkillLevel)) { int16 manaGain = championPtr->_maxMana / 40; if (_vm->_championMan->_g300_partyIsSleeping) manaGain <<= 1; @@ -1726,10 +1726,10 @@ void ChampionMan::load2_PartyPart(Common::InSaveFile* file) { champ->_statistics[y][x] = file->readByte(); for (uint16 j = 0; j < 30; ++j) champ->_slots[j] = Thing(file->readUint16BE()); - for (uint16 j = 0; j < 20; ++j) { - champ->_skills[j]._temporaryExperience = file->readSint16BE(); - champ->_skills[j]._experience = file->readSint32BE(); - } + for (uint16 j = 0; j < 20; ++j) { + champ->_skills[j]._temporaryExperience = file->readSint16BE(); + champ->_skills[j]._experience = file->readSint32BE(); + } for (uint16 j = 0; j < 8; ++j) champ->_name[j] = file->readByte(); for (uint16 j = 0; j < 20; ++j) @@ -1945,7 +1945,7 @@ void ChampionMan::f280_addCandidateChampionToParty(uint16 championPortraitIndex) curSlotIndex = slotIdx++; break; - } + } case k5_WeaponThingType: if (championPtr->_slots[k1_ChampionSlotActionHand] == Thing::_none) curSlotIndex = k1_ChampionSlotActionHand; @@ -2317,31 +2317,162 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) { } void ChampionMan::f281_renameChampion(Champion* champ) { - warning(false, "STUB METHOD: Champion::renameChampion, F0281_CHAMPION_Rename"); +#define k1_RENAME_CHAMPION_NAME 1 +#define k2_RENAME_CHAMPION_TITLE 2 + static char G0051_ac_Graphic562_UnderscoreCharacterString[2] = "_"; + static char G0052_ac_Graphic562_RenameChampionInputCharacterString[2] = " "; + static char G0053_ac_Graphic562_ReincarnateSpecialCharacters[6] = {',', '.', ';', ':', ' '}; + + uint16 L0808_ui_Multiple; +#define AL0808_ui_CharacterIndex L0808_ui_Multiple +#define AL0808_ui_ChampionIndex L0808_ui_Multiple + int16 L0809_i_RenamedChampionString; + int16 L0810_i_Character; + bool L0811_B_ChampionTitleIsFull; + char* L0812_pc_RenamedChampionString; + int16 L0813_i_X; + int16 L0814_i_Y; + Box L0815_s_Box; + int16 L0820_i_CharacterIndexBackup; + char L0821_ac_ChampionNameBackupString[8]; + + + L0815_s_Box._y1 = 3; + L0815_s_Box._y2 = 8; + L0815_s_Box._x2 = (L0815_s_Box._x1 = 3) + 167; + _vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, L0815_s_Box, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport); + _vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), g32_BoxPanel, k72_byteWidth, k4_ColorCyan, 73); + _vm->_textMan->f52_printToViewport(177, 58, k13_ColorLightestGray, "_______"); + _vm->_textMan->f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________"); + _vm->_eventMan->f78_showMouse(); + _vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView); + _vm->_eventMan->f67_setMousePointerToNormal(k0_pointerArrow); + _vm->_eventMan->f77_hideMouse(); + champ->_name[AL0808_ui_CharacterIndex = 0] = '\0'; + champ->_title[0] = '\0'; + L0809_i_RenamedChampionString = k1_RENAME_CHAMPION_NAME; + L0812_pc_RenamedChampionString = champ->_name; + L0813_i_X = 177; + L0814_i_Y = 91; - DisplayMan &dispMan = *_vm->_displayMan; - TextMan &textMan = *_vm->_textMan; + for (;;) { /*_Infinite loop_*/ + if (!(L0811_B_ChampionTitleIsFull = ((L0809_i_RenamedChampionString == k2_RENAME_CHAMPION_TITLE) && (AL0808_ui_CharacterIndex == 19)))) { + _vm->_eventMan->f78_showMouse(); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k9_ColorGold, k12_ColorDarkestGray, G0051_ac_Graphic562_UnderscoreCharacterString, k200_heightScreen); + _vm->_eventMan->f77_hideMouse(); + } + L0810_i_Character = 256; + while (L0810_i_Character == 256) { + Common::Event event; + Common::EventType eventType; + { + eventType = _vm->_eventMan->processInput(&event, &event); + _vm->_displayMan->updateScreen(); + _vm->f22_delay(1); + } + if (eventType == Common::EVENT_LBUTTONDOWN) { /* If left mouse button status has changed */ + Common::Point mousePos = _vm->_eventMan->getMousePos(); + if ((L0809_i_RenamedChampionString == k2_RENAME_CHAMPION_TITLE || (AL0808_ui_CharacterIndex > 0)) && (mousePos.x >= 197) && (mousePos.x <= 215) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'OK' button */ + L0820_i_CharacterIndexBackup = AL0808_ui_CharacterIndex; + strcpy(L0821_ac_ChampionNameBackupString, L0812_pc_RenamedChampionString = champ->_name); + AL0808_ui_CharacterIndex = strlen(L0812_pc_RenamedChampionString); + while (L0812_pc_RenamedChampionString[--AL0808_ui_CharacterIndex] == ' ') { /* Replace space characters on the right of the champion name by '\0' characters */ + L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex] = '\0'; + } + for (AL0808_ui_ChampionIndex = k0_ChampionFirst; AL0808_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount - 1; AL0808_ui_ChampionIndex++) { + if (!strcmp(_vm->_championMan->_gK71_champions[AL0808_ui_ChampionIndex]._name, L0812_pc_RenamedChampionString)) /* If an existing champion already has the specified name for the new champion */ + goto T0281011_ContinueRename; + } + return; +T0281011_ContinueRename: + if (L0809_i_RenamedChampionString == k2_RENAME_CHAMPION_TITLE) { + L0812_pc_RenamedChampionString = champ->_title; + } + strcpy(L0812_pc_RenamedChampionString = champ->_name, L0821_ac_ChampionNameBackupString); + AL0808_ui_CharacterIndex = L0820_i_CharacterIndexBackup; + } else { + if ((mousePos.x >= 107) && (mousePos.x <= 175) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'BACKSPACE' button */ + L0810_i_Character = '\b'; + break; + } + if ((mousePos.x < 107) || (mousePos.x > 215) || (mousePos.y < 116) || (mousePos.y > 144)) {/* Coordinates of table of all other characters */ + //goto T0281023; + } + if (!((mousePos.x + 4) % 10) || (!((mousePos.y + 5) % 10) && ((mousePos.x < 207) || (mousePos.y != 135)))) { + //goto T0281023; + } + L0810_i_Character = 'A' + (11 * ((mousePos.y - 116) / 10)) + ((mousePos.x - 107) / 10); + if ((L0810_i_Character == 86) || (L0810_i_Character == 97)) { /* The 'Return' button occupies two cells in the table */ + L0810_i_Character = '\r'; /* Carriage return */ + break; + } + if (L0810_i_Character >= 87) { /* Compensate for the first cell occupied by 'Return' button */ + L0810_i_Character--; + } + if (L0810_i_Character > 'Z') { + L0810_i_Character = G0053_ac_Graphic562_ReincarnateSpecialCharacters[(L0810_i_Character - 'Z') - 1]; + } + break; + } + } else if (eventType == Common::EVENT_KEYDOWN) { + L0810_i_Character = event.kbd.ascii; + } + } - Box box; - box._y1 = 3; - box._y2 = 8; - box._x1 = 3; - box._x2 = box._x1 + 167; - - dispMan.f135_fillBoxBitmap(dispMan._g296_bitmapViewport, box, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport); - dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, - 0, 0, 72, k112_byteWidthViewport, k4_ColorCyan); - textMan.f52_printToViewport(177, 58, k13_ColorLightestGray, "_______"); - textMan.f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________"); - Common::Point clickPos; - static Box okButtonBox(197, 215, 147, 155); - for (;;) { - _vm->_eventMan->processInput(); - if (_vm->_eventMan->f360_hasPendingClick(clickPos, k1_LeftMouseButton) && okButtonBox.isPointInside(clickPos)) { - return; + if ((L0810_i_Character >= 'a') && (L0810_i_Character <= 'z')) { + L0810_i_Character -= 32; /* Convert to uppercase */ + } + if (((L0810_i_Character >= 'A') && (L0810_i_Character <= 'Z')) || (L0810_i_Character == '.') || (L0810_i_Character == ',') || (L0810_i_Character == ';') || (L0810_i_Character == ':') || (L0810_i_Character == ' ')) { + if ((L0810_i_Character == ' ') && AL0808_ui_CharacterIndex == 0) { + } else { + if (!L0811_B_ChampionTitleIsFull) { + G0052_ac_Graphic562_RenameChampionInputCharacterString[0] = L0810_i_Character; + _vm->_eventMan->f78_showMouse(); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k13_ColorLightestGray, k12_ColorDarkestGray, G0052_ac_Graphic562_RenameChampionInputCharacterString, k200_heightScreen); + _vm->_eventMan->f77_hideMouse(); + L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex++] = L0810_i_Character; + L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex] = '\0'; + L0813_i_X += 6; + if ((L0809_i_RenamedChampionString == k1_RENAME_CHAMPION_NAME) && (AL0808_ui_CharacterIndex == 7)) + goto T0281033_ProceedToTitle; + } + } + } else { + if (L0810_i_Character == '\r') { /* Carriage return */ + if ((L0809_i_RenamedChampionString == k1_RENAME_CHAMPION_NAME) && (AL0808_ui_CharacterIndex > 0)) { + _vm->_eventMan->f78_showMouse(); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k13_ColorLightestGray, k12_ColorDarkestGray, G0051_ac_Graphic562_UnderscoreCharacterString, k200_heightScreen); + _vm->_eventMan->f77_hideMouse(); +T0281033_ProceedToTitle: + L0809_i_RenamedChampionString = k2_RENAME_CHAMPION_TITLE; + L0812_pc_RenamedChampionString = champ->_title; + L0813_i_X = 105; + L0814_i_Y = 109; + AL0808_ui_CharacterIndex = 0; + } + } else { + if (L0810_i_Character == '\b') { /* Backspace */ + if ((L0809_i_RenamedChampionString == k1_RENAME_CHAMPION_NAME) && (AL0808_ui_CharacterIndex == 0)) + continue; + if (!L0811_B_ChampionTitleIsFull) { + _vm->_eventMan->f78_showMouse(); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k13_ColorLightestGray, k12_ColorDarkestGray, G0051_ac_Graphic562_UnderscoreCharacterString, k200_heightScreen); + _vm->_eventMan->f77_hideMouse(); + } + if (AL0808_ui_CharacterIndex == 0) { + L0812_pc_RenamedChampionString = champ->_name; + AL0808_ui_CharacterIndex = strlen(L0812_pc_RenamedChampionString) - 1; + L0809_i_RenamedChampionString = k1_RENAME_CHAMPION_NAME; + L0813_i_X = 177 + (AL0808_ui_CharacterIndex * 6); + L0814_i_Y = 91; + } else { + AL0808_ui_CharacterIndex--; + L0813_i_X -= 6; + } + L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex] = '\0'; + } + } } - dispMan.f97_drawViewport(k0_viewportNotDungeonView); - dispMan.updateScreen(); } } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index ec25758b24..fbfc6e0f4c 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -535,13 +535,17 @@ void EventManager::setMousePos(Common::Point pos) { } -void EventManager::processInput() { +Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Event *grabMouseClick) { Common::Event event; while (_vm->_system->getEventManager()->pollEvent(event)) { switch (event.type) { case Common::EVENT_KEYDOWN: { if (event.synthetic) break; + if (grabKey) { + *grabKey = event; + return event.type; + } if (_g443_primaryKeyboardInput) { KeyboardInput *input = _g443_primaryKeyboardInput; while (input->_commandToIssue != k0_CommandNone) { @@ -565,7 +569,7 @@ void EventManager::processInput() { input++; } } - + break; } case Common::EVENT_MOUSEMOVE: if (!_g597_ignoreMouseMovements) @@ -573,6 +577,10 @@ void EventManager::processInput() { break; case Common::EVENT_LBUTTONDOWN: case Common::EVENT_RBUTTONDOWN: + if (grabMouseClick) { + *grabMouseClick = event; + return event.type; + } _g436_pendingClickPresent = true; _g437_pendingClickPos = _mousePos; _g439_pendingClickButton = (event.type == Common::EVENT_LBUTTONDOWN) ? k1_LeftMouseButton : k2_RightMouseButton; @@ -581,8 +589,10 @@ void EventManager::processInput() { break; } } + return Common::EVENT_INVALID; } + void EventManager::f360_processPendingClick() { if (_g436_pendingClickPresent) { _g436_pendingClickPresent = false; diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index 0a77cf8064..731044eee7 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -30,6 +30,7 @@ #include "common/events.h" #include "common/queue.h" +#include "common/array.h" #include "dm.h" #include "gfx.h" @@ -229,6 +230,8 @@ class DMEngine; #define k4_pointerTypeAutoselect 4 // @ C4_POINTER_TYPE_AUTOSELECT + + class EventManager { DMEngine *_vm; @@ -281,7 +284,14 @@ public: void f77_hideMouse(); // @ F0078_MOUSE_ShowPointer void setMousePos(Common::Point pos); - void processInput(); // acknowledges mouse and keyboard input + Common::Point getMousePos() { return _mousePos; } + /** + * Upon encountering an event type for which the grab parameter is not null, the function + * will return with the event type, passes the event to the grab desitination and returns without + * processing the rest of the events into commands accoring to the current keyboard and mouse input. + * If there are no more events, it returns with Common::EVENT_INVALID. + */ + Common::EventType processInput(Common::Event *grabKey = nullptr, Common::Event *grabMouseClick = nullptr); void f360_processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick void f359_processClick(Common::Point mousePos, MouseButton button); // @ F0359_COMMAND_ProcessClick_CPSC CommandType f358_getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC -- cgit v1.2.3 From 356f80af5028645de22230e6b365d955afdd081d Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 28 Jul 2016 18:10:57 +0200 Subject: DM: Fix bug where code crashed if trying to display a doorfront in square R3 --- engines/dm/TODOs/todo.txt | 2 +- engines/dm/gfx.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index cefa603bf2..db6733a365 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -9,7 +9,7 @@ Bugs: Logic: When object are put on the right side of the current square, they disappear Object display is a bit mixed up with regards to which cell is it drawn in - Method cthulu messes up the callstack sometimes + diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 2d7a99fd4e..0f274bfe54 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -809,7 +809,7 @@ void DisplayMan::f460_initializeGraphicData() { _g702_bitmapWallSet_Wall_D0R = new byte[32 * 136]; _g703_bitmapWallSet_DoorFrameTop_D2LCR = new byte[96 * 3]; _g704_bitmapWallSet_DoorFrameTop_D1LCR = new byte[128 * 4]; - _g705_bitmapWallSet_DoorFrameLeft_D3L = new byte[32 * 43]; + _g705_bitmapWallSet_DoorFrameLeft_D3L = new byte[32 * 44]; _g706_bitmapWallSet_DoorFrameLeft_D3C = new byte[32 * 44]; _g707_bitmapWallSet_DoorFrameLeft_D2C = new byte[48 * 65]; _g708_bitmapWallSet_DoorFrameLeft_D1C = new byte[32 * 94]; -- cgit v1.2.3 From e0d89afbc30a36d5825e637a06da0e695a91b57a Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 28 Jul 2016 18:35:19 +0200 Subject: DM: Add some missing code warnings to function calls --- engines/dm/menus.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index b63717d265..f0db59b068 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -238,7 +238,7 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() { _g509_actionAreaContainsIcons = false; champ->setAttributeFlag(k0x8000_ChampionAttributeActionHand, true); champMan.f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(champMan._g506_actingChampionOrdinal)); - warning(false, "MISSING CODE: F0387_MENUS_DrawActionArea"); + f387_drawActionArea(); } } } @@ -251,7 +251,7 @@ void MenuMan::f387_drawActionArea() { ChampionMan &champMan = *_vm->_championMan; TextMan &textMan = *_vm->_textMan; - warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + _vm->_eventMan->f77_hideMouse(); dispMan._g578_useByteBoxCoordinates = false; dispMan.D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack); if (_g509_actionAreaContainsIcons) { @@ -274,7 +274,7 @@ void MenuMan::f387_drawActionArea() { k12_ActionNameMaximumLength, k200_heightScreen); } } - warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer"); + _vm->_eventMan->f78_showMouse(); _g508_refreshActionArea = false; } -- cgit v1.2.3 From e9622e27b16fda6c5e87d092f2ad477c35966fc1 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Thu, 28 Jul 2016 19:27:58 +0200 Subject: DM: Add f349_processCommand70_clickOnMouth --- engines/dm/TODOs/todo.txt | 3 + engines/dm/eventman.cpp | 20 ++++- engines/dm/eventman.h | 3 +- engines/dm/inventory.cpp | 194 ++++++++++++++++++++++++++++++++++++++++++++++ engines/dm/inventory.h | 2 + engines/dm/menus.cpp | 43 +++++----- engines/dm/objectman.cpp | 9 +++ engines/dm/objectman.h | 2 +- 8 files changed, 247 insertions(+), 29 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index db6733a365..3bbcf6bdfe 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -5,6 +5,9 @@ Bugs: Arrow and hand display is messed up Items are displayed in the wrong cells + Gui is messed up by drawn spell area line on startup + Spellcasting tabs are displayed inproperly, switching between them is possible tho + Logic: When object are put on the right side of the current square, they disappear diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index fbfc6e0f4c..83e07eb1f7 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -357,6 +357,7 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) { _g444_secondaryKeyboardInput = nullptr; _g597_ignoreMouseMovements = false; _g587_hideMousePointerRequestCount = 0; + _g558_mouseButtonStatus = 0; } EventManager::~EventManager() { @@ -529,6 +530,9 @@ void EventManager::f77_hideMouse() { // CursorMan.showMouse(false); } +bool EventManager::isMouseButtonDown(MouseButton button) { + return (button != k0_NoneMouseButton) ? (_g558_mouseButtonStatus & button) : (_g558_mouseButtonStatus == 0); +} void EventManager::setMousePos(Common::Point pos) { _vm->_system->warpMouse(pos.x, pos.y); @@ -576,15 +580,24 @@ Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Eve _mousePos = event.mouse; break; case Common::EVENT_LBUTTONDOWN: - case Common::EVENT_RBUTTONDOWN: + case Common::EVENT_RBUTTONDOWN: { + MouseButton button = (event.type == Common::EVENT_LBUTTONDOWN) ? k1_LeftMouseButton : k2_RightMouseButton; + _g558_mouseButtonStatus |= button; if (grabMouseClick) { *grabMouseClick = event; return event.type; } _g436_pendingClickPresent = true; _g437_pendingClickPos = _mousePos; - _g439_pendingClickButton = (event.type == Common::EVENT_LBUTTONDOWN) ? k1_LeftMouseButton : k2_RightMouseButton; + _g439_pendingClickButton = button; + break; + } + case Common::EVENT_LBUTTONUP: + case Common::EVENT_RBUTTONUP: { + MouseButton button = (event.type == Common::EVENT_LBUTTONDOWN) ? k1_LeftMouseButton : k2_RightMouseButton; + _g558_mouseButtonStatus &= ~button; break; + } default: break; } @@ -705,7 +718,7 @@ void EventManager::f380_processCommandQueue() { return; } if (cmdType == k70_CommandClickOnMouth) { - warning(false, "MISSING CODE: F0349_INVENTORY_ProcessCommand70_ClickOnMouth();"); + _vm->_inventoryMan->f349_processCommand70_clickOnMouth(); return; } if (cmdType == k71_CommandClickOnEye) { @@ -749,7 +762,6 @@ void EventManager::f380_processCommandQueue() { } if (cmdType == k140_CommandSaveGame) { if ((_vm->_championMan->_g305_partyChampionCount > 0) && !_vm->_championMan->_g299_candidateChampionOrdinal) { - warning(false, "MISSING CODE: F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF();"); _vm->f433_processCommand140_saveGame(1, "Nice save:)"); } return; diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index 731044eee7..a12cc2e852 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -249,6 +249,7 @@ class EventManager { byte *_gK190_mousePointerTempBuffer; // @ K0190_puc_Bitmap_MousePointerTemporaryBuffer int16 _gK104_mousePointerType; // @ K0104_i_MousePointerType int16 _gK105_previousMousePointerType; // @ K0105_i_PreviousMousePointerType + uint16 _g558_mouseButtonStatus;// @ G0588_i_MouseButtonsStatus // this doesn't seem to be used anywhere at all bool _g435_isCommandQueueLocked; // @ G0435_B_CommandQueueLocked @@ -258,7 +259,6 @@ class EventManager { void f366_commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty bool f375_processType80_clickDungeonView_isLeaderHandObjThrown(int16 posX, int16 posY); // @ F0375_COMMAND_ProcessType80_ClickInDungeonView_IsLeaderHandObjectThrown - public: explicit EventManager(DMEngine *vm); ~EventManager(); @@ -282,6 +282,7 @@ public: void f69_setMousePointer(); // @ F0069_MOUSE_SetPointer void f78_showMouse(); // @ F0077_MOUSE_HidePointer_CPSE void f77_hideMouse(); // @ F0078_MOUSE_ShowPointer + bool isMouseButtonDown(MouseButton button); void setMousePos(Common::Point pos); Common::Point getMousePos() { return _mousePos; } diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 86b78bdb2b..52e70d4e62 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -32,6 +32,8 @@ #include "gfx.h" #include "text.h" #include "objectman.h" +#include "timeline.h" +#include "projexpl.h" namespace DM { @@ -745,4 +747,196 @@ void InventoryMan::f353_drawStopPressingEye() { } _vm->_eventMan->f77_hideMouse(); } + +void InventoryMan::f349_processCommand70_clickOnMouth() { + static int16 G0242_ai_Graphic559_FoodAmounts[8] = { + 500, /* Apple */ + 600, /* Corn */ + 650, /* Bread */ + 820, /* Cheese */ + 550, /* Screamer Slice */ + 350, /* Worm round */ + 990, /* Drumstick / Shank */ + 1400}; /* Dragon steak */ + + Thing L1078_T_Thing; + uint16 L1079_ui_IconIndex; + uint16 L1080_ui_ChampionIndex; + bool L1081_B_RemoveObjectFromLeaderHand; + Junk* L1082_ps_Junk; + Champion* L1083_ps_Champion; + TimelineEvent L1084_s_Event; + uint16 L1085_ui_Multiple; +#define AL1085_ui_PotionPower L1085_ui_Multiple +#define AL1085_ui_AdjustedPotionPower L1085_ui_Multiple +#define AL1085_ui_Counter L1085_ui_Multiple + uint16 L1086_ui_Counter; + int16 L1087_i_Wounds; + uint16 L1088_ui_Multiple; +#define AL1088_ui_ThingType L1088_ui_Multiple +#define AL1088_ui_Mana L1088_ui_Multiple +#define AL1088_ui_HealWoundIterationCount L1088_ui_Multiple + uint16 L1089_ui_Weight; + + + if (_vm->_championMan->_g415_leaderEmptyHanded) { + if (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned) { + return; + } + _vm->_eventMan->_g597_ignoreMouseMovements = true; + _vm->_g333_pressingMouth = true; + if (!_vm->_eventMan->isMouseButtonDown(k1_LeftMouseButton)) { + _vm->_eventMan->_g597_ignoreMouseMovements = false; + _vm->_g333_pressingMouth = false; + _vm->_g334_stopPressingMouth = false; + } else { + _vm->_eventMan->f78_showMouse(); + _vm->_eventMan->_g587_hideMousePointerRequestCount = 1; + _vm->_inventoryMan->f345_drawPanelFoodWaterPoisoned(); + _vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView); + } + return; + } + if (_vm->_championMan->_g299_candidateChampionOrdinal) { + return; + } + if (!getFlag(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1078_T_Thing = _vm->_championMan->_g414_leaderHandObject)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) { + return; + } + L1079_ui_IconIndex = _vm->_objectMan->f33_getIconIndex(L1078_T_Thing); + AL1088_ui_ThingType = L1078_T_Thing.getType(); + L1089_ui_Weight = _vm->_dungeonMan->f140_getObjectWeight(L1078_T_Thing); + L1083_ps_Champion = &_vm->_championMan->_gK71_champions[L1080_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_inventoryMan->_g432_inventoryChampionOrdinal)]; + L1082_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1078_T_Thing); + if ((L1079_ui_IconIndex >= k8_IconIndiceJunkWater) && (L1079_ui_IconIndex <= k9_IconIndiceJunkWaterSkin)) { + if (!(L1082_ps_Junk->getChargeCount())) { + return; + } + L1083_ps_Champion->_water = MIN(L1083_ps_Champion->_water + 800, 2048); + L1082_ps_Junk->setChargeCount(L1082_ps_Junk->getChargeCount() - 1); + L1081_B_RemoveObjectFromLeaderHand = false; + } else { + if (AL1088_ui_ThingType == k8_PotionThingType) { + L1081_B_RemoveObjectFromLeaderHand = false; + } else { + L1082_ps_Junk->setNextThing(Thing::_none); + L1081_B_RemoveObjectFromLeaderHand = true; + } + } + _vm->_eventMan->f78_showMouse(); + if (L1081_B_RemoveObjectFromLeaderHand) { + _vm->_championMan->f298_getObjectRemovedFromLeaderHand(); + } + if (AL1088_ui_ThingType == k8_PotionThingType) { + AL1085_ui_PotionPower = ((Potion*)L1082_ps_Junk)->getPower(); + L1086_ui_Counter = ((511 - AL1085_ui_PotionPower) / (32 + (AL1085_ui_PotionPower + 1) / 8)) >> 1; + AL1085_ui_AdjustedPotionPower = (AL1085_ui_PotionPower / 25) + 8; /* Value between 8 and 18 */ + switch (((Potion*)L1082_ps_Junk)->getType()) { + case k6_PotionTypeRos: + f348_adjustStatisticCurrentValue(L1083_ps_Champion, k2_ChampionStatDexterity, AL1085_ui_AdjustedPotionPower); + break; + case k7_PotionTypeKu: + f348_adjustStatisticCurrentValue(L1083_ps_Champion, k1_ChampionStatStrength, (((Potion*)L1082_ps_Junk)->getPower() / 35) + 5); /* Value between 5 and 12 */ + break; + case k8_PotionTypeDane: + f348_adjustStatisticCurrentValue(L1083_ps_Champion, k3_ChampionStatWisdom, AL1085_ui_AdjustedPotionPower); + break; + case k9_PotionTypeNeta: + f348_adjustStatisticCurrentValue(L1083_ps_Champion, k4_ChampionStatVitality, AL1085_ui_AdjustedPotionPower); + break; + case k10_PotionTypeAntivenin: + _vm->_championMan->f323_unpoison(L1080_ui_ChampionIndex); + break; + case k11_PotionTypeMon: + L1083_ps_Champion->_currStamina += MIN(L1083_ps_Champion->_maxStamina - L1083_ps_Champion->_currStamina, L1083_ps_Champion->_maxStamina / L1086_ui_Counter); + break; + case k12_PotionTypeYa: + AL1085_ui_AdjustedPotionPower += AL1085_ui_AdjustedPotionPower >> 1; + if (L1083_ps_Champion->_shieldDefense > 50) { + AL1085_ui_AdjustedPotionPower >>= 2; + } + L1083_ps_Champion->_shieldDefense += AL1085_ui_AdjustedPotionPower; + L1084_s_Event._type = k72_TMEventTypeChampionShield; + M33_setMapAndTime(L1084_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + (AL1085_ui_AdjustedPotionPower * AL1085_ui_AdjustedPotionPower)); + L1084_s_Event._priority = L1080_ui_ChampionIndex; + L1084_s_Event._B._defense = AL1085_ui_AdjustedPotionPower; + _vm->_timeline->f238_addEventGetEventIndex(&L1084_s_Event); + setFlag(L1083_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox); + break; + case k13_PotionTypeEe: + AL1088_ui_Mana = MIN(900, (L1083_ps_Champion->_currMana + AL1085_ui_AdjustedPotionPower) + (AL1085_ui_AdjustedPotionPower - 8)); + if (AL1088_ui_Mana > L1083_ps_Champion->_maxMana) { + AL1088_ui_Mana -= (AL1088_ui_Mana - MAX(L1083_ps_Champion->_currMana, L1083_ps_Champion->_maxMana)) >> 1; + } + L1083_ps_Champion->_currMana = AL1088_ui_Mana; + break; + case k14_PotionTypeVi: + AL1088_ui_HealWoundIterationCount = MAX(1, (((Potion*)L1082_ps_Junk)->getPower() / 42)); + L1083_ps_Champion->_currHealth += L1083_ps_Champion->_maxHealth / L1086_ui_Counter; + if (L1087_i_Wounds = L1083_ps_Champion->_wounds) { /* If the champion is wounded */ + L1086_ui_Counter = 10; + do { + for (AL1085_ui_Counter = 0; AL1085_ui_Counter < AL1088_ui_HealWoundIterationCount; AL1085_ui_Counter++) { + L1083_ps_Champion->_wounds &= _vm->getRandomNumber(65536); + } + AL1088_ui_HealWoundIterationCount = 1; + } while ((L1087_i_Wounds == L1083_ps_Champion->_wounds) && --L1086_ui_Counter); /* Loop until at least one wound is healed or there are no more heal iterations */ + } + setFlag(L1083_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad | k0x2000_ChampionAttributeWounds); + break; + case k15_PotionTypeWaterFlask: + L1083_ps_Champion->_water = MIN(L1083_ps_Champion->_water + 1600, 2048); + } + ((Potion*)L1082_ps_Junk)->setType(k20_PotionTypeEmptyFlask); + } else { + if ((L1079_ui_IconIndex >= k168_IconIndiceJunkApple) && (L1079_ui_IconIndex < k176_IconIndiceJunkIronKey)) { + L1083_ps_Champion->_food = MIN(L1083_ps_Champion->_food + G0242_ai_Graphic559_FoodAmounts[L1079_ui_IconIndex - k168_IconIndiceJunkApple], 2048); + } + } + if (L1083_ps_Champion->_currStamina > L1083_ps_Champion->_maxStamina) { + L1083_ps_Champion->_currStamina = L1083_ps_Champion->_maxStamina; + } + if (L1083_ps_Champion->_currHealth > L1083_ps_Champion->_maxHealth) { + L1083_ps_Champion->_currHealth = L1083_ps_Champion->_maxHealth; + } + if (L1081_B_RemoveObjectFromLeaderHand) { + for (L1086_ui_Counter = 5; --L1086_ui_Counter; _vm->f22_delay(8)) { /* Animate mouth icon */ + _vm->_objectMan->f37_drawIconToScreen(k205_IconIndiceMouthOpen + !(L1086_ui_Counter & 0x0001), 56, 46); + _vm->_eventMan->processInput(); + _vm->_displayMan->updateScreen(); + } + } else { + _vm->_championMan->f296_drawChangedObjectIcons(); + _vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(L1078_T_Thing) - L1089_ui_Weight; + setFlag(_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad); + } + _vm->f064_SOUND_RequestPlay_CPSD(k08_soundSWALLOW, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately); + setFlag(L1083_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); + if (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned) { + setFlag(L1083_ps_Champion->_attributes, k0x0800_ChampionAttributePanel); + } + _vm->_championMan->f292_drawChampionState((ChampionIndex)L1080_ui_ChampionIndex); + _vm->_eventMan->f77_hideMouse(); +} + +void InventoryMan::f348_adjustStatisticCurrentValue(Champion* champ, uint16 statIndex, int16 valueDelta) { + int16 L1077_i_Multiple; +#define AL1077_i_CurrentValue L1077_i_Multiple +#define AL1077_i_Delta L1077_i_Multiple + + if (valueDelta >= 0) { + if ((AL1077_i_CurrentValue = champ->_statistics[statIndex][k1_ChampionStatCurrent]) > 120) { + valueDelta >>= 1; + if (AL1077_i_CurrentValue > 150) { + valueDelta >>= 1; + } + valueDelta++; + } + AL1077_i_Delta = MIN(valueDelta, (int16)(170 - AL1077_i_CurrentValue)); + } else { /* BUG0_00 Useless code. The function is always called with valueDelta having a positive value */ + AL1077_i_Delta = MAX(valueDelta, int16(champ->_statistics[statIndex][k2_ChampionStatMinimum] - champ->_statistics[statIndex][k1_ChampionStatCurrent])); + } + champ->_statistics[statIndex][k1_ChampionStatCurrent] += AL1077_i_Delta; +} + } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 106e4cd24d..a115c9819f 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -83,6 +83,8 @@ public: void f351_drawChampionSkillsAndStatistics(); // @ F0351_INVENTORY_DrawChampionSkillsAndStatistics void f350_drawStopPressingMouth(); // @ F0350_INVENTORY_DrawStopPressingMouth void f353_drawStopPressingEye();// @ F0353_INVENTORY_DrawStopPressingEye + void f349_processCommand70_clickOnMouth(); // @ F0349_INVENTORY_ProcessCommand70_ClickOnMouth + void f348_adjustStatisticCurrentValue(Champion *champ, uint16 statIndex, int16 valueDelta); // @ F0348_INVENTORY_AdjustStatisticCurrentValue }; diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index f0db59b068..29312531b4 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -396,35 +396,32 @@ void MenuMan::f392_buildSpellAreaLine(int16 spellAreaBitmapLine) { } void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) { - ChampionMan &champMan = *_vm->_championMan; - DisplayMan &dispMan = *_vm->_displayMan; + Champion* L1213_ps_Champion; - if ((champIndex == champMan._g514_magicCasterChampionIndex) - || ((champIndex != kM1_ChampionNone) && !champMan._gK71_champions[champIndex]._currHealth)) + if ((champIndex == _vm->_championMan->_g514_magicCasterChampionIndex) || ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_gK71_champions[champIndex]._currHealth)) { return; - if (champMan._g514_magicCasterChampionIndex == kM1_ChampionNone) { - warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan.f132_blitToBitmap(dispMan.f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), dispMan._g348_bitmapScreen, g0_BoxSpellArea, 0, 0, - 48, k160_byteWidthScreen, kM1_ColorNoTransparency); - warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer"); + } + if (_vm->_championMan->_g514_magicCasterChampionIndex == kM1_ChampionNone) { + _vm->_eventMan->f78_showMouse(); + _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &g0_BoxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33); + _vm->_eventMan->f77_hideMouse(); } if (champIndex == kM1_ChampionNone) { - champMan._g514_magicCasterChampionIndex = kM1_ChampionNone; - warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - dispMan._g578_useByteBoxCoordinates = false; - dispMan.D24_fillScreenBox(g0_BoxSpellArea, k0_ColorBlack); - warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer"); + _vm->_championMan->_g514_magicCasterChampionIndex = kM1_ChampionNone; + _vm->_eventMan->f78_showMouse(); + _vm->_displayMan->_g578_useByteBoxCoordinates = false; + _vm->_displayMan->D24_fillScreenBox(g0_BoxSpellArea, k0_ColorBlack); + _vm->_eventMan->f77_hideMouse(); return; } - - champMan._g514_magicCasterChampionIndex = (ChampionIndex)champIndex; - f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols); - warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); - f393_drawSpellAreaControls((ChampionIndex)champIndex); - dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK75_BoxSpellAreaLine2, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency); - f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols); - dispMan.f132_blitToBitmap(_gK72_bitmapSpellAreaLine, dispMan._g348_bitmapScreen, gK76_BoxSpellAreaLine3, 0, 0, 48, k160_byteWidthScreen, kM1_ColorNoTransparency); - warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer"); + L1213_ps_Champion = &_vm->_championMan->_gK71_champions[_vm->_championMan->_g514_magicCasterChampionIndex = (ChampionIndex)champIndex]; + _vm->_menuMan->f392_buildSpellAreaLine(k2_SpellAreaAvailableSymbols); + _vm->_eventMan->f78_showMouse(); + _vm->_menuMan->f393_drawSpellAreaControls((ChampionIndex)champIndex); + _vm->_displayMan->f21_blitToScreen(_vm->_menuMan->_gK72_bitmapSpellAreaLine, &gK75_BoxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12); + _vm->_menuMan->f392_buildSpellAreaLine(k3_SpellAreaChampionSymbols); + _vm->_displayMan->f21_blitToScreen(_vm->_menuMan->_gK72_bitmapSpellAreaLine, &gK76_BoxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12); + _vm->_eventMan->f77_hideMouse(); } void MenuMan::f457_drawEnabledMenus() { diff --git a/engines/dm/objectman.cpp b/engines/dm/objectman.cpp index 40c650b0f8..192e66192c 100644 --- a/engines/dm/objectman.cpp +++ b/engines/dm/objectman.cpp @@ -259,4 +259,13 @@ void ObjectMan::f35_clearLeaderObjectName() { _vm->_displayMan->D24_fillScreenBox(g28_BoxLeaderHandObjectName, k0_ColorBlack); } +void ObjectMan::f37_drawIconToScreen(int16 iconIndex, int16 posX, int16 posY) { + static byte L0013_puc_Bitmap_Icon[16 * 16]; + Box L0014_s_Box; + + L0014_s_Box._x2 = (L0014_s_Box._x1 = posX) + 15; + L0014_s_Box._y2 = (L0014_s_Box._y1 = posY) + 15; + _vm->_objectMan->f36_extractIconFromBitmap(iconIndex, L0013_puc_Bitmap_Icon); + _vm->_displayMan->f21_blitToScreen(L0013_puc_Bitmap_Icon, &L0014_s_Box, k8_byteWidth, kM1_ColorNoTransparency, 16); +} } diff --git a/engines/dm/objectman.h b/engines/dm/objectman.h index 3f90f805d4..3b55e194f9 100644 --- a/engines/dm/objectman.h +++ b/engines/dm/objectman.h @@ -65,7 +65,7 @@ public: void f34_drawLeaderObjectName(Thing thing); // @ F0034_OBJECT_DrawLeaderHandObjectName IconIndice f39_getIconIndexInSlotBox(uint16 slotBoxIndex); // @ F0039_OBJECT_GetIconIndexInSlotBox void f35_clearLeaderObjectName(); // @ F0035_OBJECT_ClearLeaderHandObjectName - + void f37_drawIconToScreen(int16 iconIndex, int16 posX, int16 posY); // @ F0037_OBJECT_DrawIconToScreen }; -- cgit v1.2.3 From 78f716e1c189f4c944efa2aa6a7817e4f66a7280 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 29 Jul 2016 09:44:08 +0200 Subject: DM: Some refactoring in gfx.cpp, refactoring of f107_isDrawnWallOrnAnAlcove --- engines/dm/gfx.cpp | 424 ++++++++++++++++++++++++----------------------------- 1 file changed, 195 insertions(+), 229 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 0f274bfe54..38c1e5dd10 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -2281,30 +2281,26 @@ void DisplayMan::f94_loadFloorSet(FloorSet set) { } } -Box g161_BoxWallBitmap_D3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR -Box g162_BoxWallBitmap_D2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR - // Note: has been screened for missing code void DisplayMan::f95_loadWallSet(WallSet set) { - if ((_g231_currentWallSet != set) || _vm->_g523_restartGameRequest) { _g231_currentWallSet = set; - { - int16 graphicIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet; - f466_loadIntoBitmap(graphicIndice++, _g709_bitmapWallSet_DoorFrameFront); - f466_loadIntoBitmap(graphicIndice++, _g708_bitmapWallSet_DoorFrameLeft_D1C); - f466_loadIntoBitmap(graphicIndice++, _g707_bitmapWallSet_DoorFrameLeft_D2C); - f466_loadIntoBitmap(graphicIndice++, _g706_bitmapWallSet_DoorFrameLeft_D3C); - f466_loadIntoBitmap(graphicIndice++, _g705_bitmapWallSet_DoorFrameLeft_D3L); - f466_loadIntoBitmap(graphicIndice++, _g704_bitmapWallSet_DoorFrameTop_D1LCR); - f466_loadIntoBitmap(graphicIndice++, _g703_bitmapWallSet_DoorFrameTop_D2LCR); - f466_loadIntoBitmap(graphicIndice++, _g702_bitmapWallSet_Wall_D0R); - f466_loadIntoBitmap(graphicIndice++, _g701_bitmapWallSet_Wall_D0L); - f466_loadIntoBitmap(graphicIndice++, _g700_bitmapWallSet_Wall_D1LCR); - f466_loadIntoBitmap(graphicIndice++, _g699_bitmapWallSet_Wall_D2LCR); - f466_loadIntoBitmap(graphicIndice++, _g698_bitmapWallSet_Wall_D3LCR); - f466_loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2); - } + + int16 graphicIndice = (set * k13_WallSetGraphicCount) + k77_FirstWallSet; + f466_loadIntoBitmap(graphicIndice++, _g709_bitmapWallSet_DoorFrameFront); + f466_loadIntoBitmap(graphicIndice++, _g708_bitmapWallSet_DoorFrameLeft_D1C); + f466_loadIntoBitmap(graphicIndice++, _g707_bitmapWallSet_DoorFrameLeft_D2C); + f466_loadIntoBitmap(graphicIndice++, _g706_bitmapWallSet_DoorFrameLeft_D3C); + f466_loadIntoBitmap(graphicIndice++, _g705_bitmapWallSet_DoorFrameLeft_D3L); + f466_loadIntoBitmap(graphicIndice++, _g704_bitmapWallSet_DoorFrameTop_D1LCR); + f466_loadIntoBitmap(graphicIndice++, _g703_bitmapWallSet_DoorFrameTop_D2LCR); + f466_loadIntoBitmap(graphicIndice++, _g702_bitmapWallSet_Wall_D0R); + f466_loadIntoBitmap(graphicIndice++, _g701_bitmapWallSet_Wall_D0L); + f466_loadIntoBitmap(graphicIndice++, _g700_bitmapWallSet_Wall_D1LCR); + f466_loadIntoBitmap(graphicIndice++, _g699_bitmapWallSet_Wall_D2LCR); + f466_loadIntoBitmap(graphicIndice++, _g698_bitmapWallSet_Wall_D3LCR); + f466_loadIntoBitmap(graphicIndice++, _g697_bitmapWallSet_Wall_D3L2); + f99_copyBitmapAndFlipHorizontal(_g708_bitmapWallSet_DoorFrameLeft_D1C, _g710_bitmapWallSet_DoorFrameRight_D1C, g171_Frame_DoorFrameRight_D1C._srcByteWidth, g171_Frame_DoorFrameRight_D1C._srcHeight); f99_copyBitmapAndFlipHorizontal(_g697_bitmapWallSet_Wall_D3L2, _g696_bitmapWallSet_Wall_D3R2, @@ -2314,68 +2310,65 @@ void DisplayMan::f95_loadWallSet(WallSet set) { void DisplayMan::f96_loadCurrentMapGraphics() { + Box BoxWallD3LCR = Box(0, 115, 0, 50); // @ G0161_s_Graphic558_Box_WallBitmap_D3LCR + Box BoxWallD2LCR = Box(0, 135, 0, 70); // @ G0162_s_Graphic558_Box_WallBitmap_D2LCR + f94_loadFloorSet(_vm->_dungeonMan->_g269_currMap->_floorSet); f95_loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet); - { - _g578_useByteBoxCoordinates = true; - - f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap, - g163_FrameWalls[k0_ViewSquare_D3C]._srcByteWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight); - f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 64, 51); - f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, g161_BoxWallBitmap_D3LCR, 11, 0, 64, 64, kM1_ColorNoTransparency); - - f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap, - g163_FrameWalls[k3_ViewSquare_D2C]._srcByteWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight); - f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 72, 71); - f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, g162_BoxWallBitmap_D2LCR, 8, 0, 72, 72, kM1_ColorNoTransparency); - - f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped, - g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight); - f99_copyBitmapAndFlipHorizontal(_g98_bitmapWall_D0L_Native = _g701_bitmapWallSet_Wall_D0L, _g94_bitmapWall_D0R_Flipped, - g163_FrameWalls[k10_ViewSquare_D0L]._srcByteWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight); - f99_copyBitmapAndFlipHorizontal(_g99_bitmapWall_D0R_Native = _g702_bitmapWallSet_Wall_D0R, _g93_bitmapWall_D0L_Flipped, - g163_FrameWalls[k10_ViewSquare_D0L]._srcByteWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight); - } - - - { - int16 val = _vm->_dungeonMan->_g269_currMap->_wallSet * k18_StairsGraphicCount + k90_FirstStairs; - _g675_stairsNativeBitmapIndex_Up_Front_D3L = val++; - _g676_stairsNativeBitmapIndex_Up_Front_D3C = val++; - _g677_stairsNativeBitmapIndex_Up_Front_D2L = val++; - _g678_stairsNativeBitmapIndex_Up_Front_D2C = val++; - _g679_stairsNativeBitmapIndex_Up_Front_D1L = val++; - _g680_stairsNativeBitmapIndex_Up_Front_D1C = val++; - _g681_stairsNativeBitmapIndex_Up_Front_D0C_Left = val++; - _g682_stairsNativeBitmapIndex_Down_Front_D3L = val++; - _g683_stairsNativeBitmapIndex_Down_Front_D3C = val++; - _g684_stairsNativeBitmapIndex_Down_Front_D2L = val++; - _g685_stairsNativeBitmapIndex_Down_Front_D2C = val++; - _g686_stairsNativeBitmapIndex_Down_Front_D1L = val++; - _g687_stairsNativeBitmapIndex_Down_Front_D1C = val++; - _g688_stairsNativeBitmapIndex_Down_Front_D0C_Left = val++; - _g689_stairsNativeBitmapIndex_Side_D2L = val++; - _g690_stairsNativeBitmapIndex_Up_Side_D1L = val++; - _g691_stairsNativeBitmapIndex_Down_Side_D1L = val++; - _g692_stairsNativeBitmapIndex_Side_D0L = val++; - } + _g578_useByteBoxCoordinates = true; + + f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap, + g163_FrameWalls[k0_ViewSquare_D3C]._srcByteWidth, g163_FrameWalls[k0_ViewSquare_D3C]._srcHeight); + f134_fillBitmap(_g90_bitmapWall_D3LCR_Flipped, k10_ColorFlesh, 64, 51); + f132_blitToBitmap(_g74_tmpBitmap, _g90_bitmapWall_D3LCR_Flipped, BoxWallD3LCR, 11, 0, 64, 64, kM1_ColorNoTransparency); + + f99_copyBitmapAndFlipHorizontal(_g96_bitmapWall_D2LCR_Native = _g699_bitmapWallSet_Wall_D2LCR, _g74_tmpBitmap, + g163_FrameWalls[k3_ViewSquare_D2C]._srcByteWidth, g163_FrameWalls[k3_ViewSquare_D2C]._srcHeight); + f134_fillBitmap(_g91_bitmapWall_D2LCR_Flipped, k10_ColorFlesh, 72, 71); + f132_blitToBitmap(_g74_tmpBitmap, _g91_bitmapWall_D2LCR_Flipped, BoxWallD2LCR, 8, 0, 72, 72, kM1_ColorNoTransparency); + + f99_copyBitmapAndFlipHorizontal(_g97_bitmapWall_D1LCR_Native = _g700_bitmapWallSet_Wall_D1LCR, _g92_bitmapWall_D1LCR_Flipped, + g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight); + f99_copyBitmapAndFlipHorizontal(_g98_bitmapWall_D0L_Native = _g701_bitmapWallSet_Wall_D0L, _g94_bitmapWall_D0R_Flipped, + g163_FrameWalls[k10_ViewSquare_D0L]._srcByteWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight); + f99_copyBitmapAndFlipHorizontal(_g99_bitmapWall_D0R_Native = _g702_bitmapWallSet_Wall_D0R, _g93_bitmapWall_D0L_Flipped, + g163_FrameWalls[k10_ViewSquare_D0L]._srcByteWidth, g163_FrameWalls[k10_ViewSquare_D0L]._srcHeight); + + int16 val = _vm->_dungeonMan->_g269_currMap->_wallSet * k18_StairsGraphicCount + k90_FirstStairs; + _g675_stairsNativeBitmapIndex_Up_Front_D3L = val++; + _g676_stairsNativeBitmapIndex_Up_Front_D3C = val++; + _g677_stairsNativeBitmapIndex_Up_Front_D2L = val++; + _g678_stairsNativeBitmapIndex_Up_Front_D2C = val++; + _g679_stairsNativeBitmapIndex_Up_Front_D1L = val++; + _g680_stairsNativeBitmapIndex_Up_Front_D1C = val++; + _g681_stairsNativeBitmapIndex_Up_Front_D0C_Left = val++; + _g682_stairsNativeBitmapIndex_Down_Front_D3L = val++; + _g683_stairsNativeBitmapIndex_Down_Front_D3C = val++; + _g684_stairsNativeBitmapIndex_Down_Front_D2L = val++; + _g685_stairsNativeBitmapIndex_Down_Front_D2C = val++; + _g686_stairsNativeBitmapIndex_Down_Front_D1L = val++; + _g687_stairsNativeBitmapIndex_Down_Front_D1C = val++; + _g688_stairsNativeBitmapIndex_Down_Front_D0C_Left = val++; + _g689_stairsNativeBitmapIndex_Side_D2L = val++; + _g690_stairsNativeBitmapIndex_Up_Side_D1L = val++; + _g691_stairsNativeBitmapIndex_Down_Side_D1L = val++; + _g692_stairsNativeBitmapIndex_Side_D0L = val++; for (int16 i = 0; i < k3_AlcoveOrnCount; ++i) _g267_currMapAlcoveOrnIndices[i] = -1; + for (int16 i = 0; i < k1_FountainOrnCount; ++i) _g268_currMapFountainOrnIndices[i] = -1; - { - uint16 doorSets[2]; - doorSets[0] = _vm->_dungeonMan->_g269_currMap->_doorSet0; - doorSets[1] = _vm->_dungeonMan->_g269_currMap->_doorSet1; - for (uint16 doorSet = 0; doorSet <= 1; doorSet++) { - int16 counter = k108_FirstDoorSet + (doorSets[doorSet] * k3_DoorSetGraphicsCount); - _g693_doorNativeBitmapIndex_Front_D3LCR[doorSet] = counter++; - _g694_doorNativeBitmapIndex_Front_D2LCR[doorSet] = counter++; - _g695_doorNativeBitmapIndex_Front_D1LCR[doorSet] = counter++; - } + uint16 doorSets[2]; + doorSets[0] = _vm->_dungeonMan->_g269_currMap->_doorSet0; + doorSets[1] = _vm->_dungeonMan->_g269_currMap->_doorSet1; + for (uint16 doorSet = 0; doorSet <= 1; doorSet++) { + int16 counter = k108_FirstDoorSet + (doorSets[doorSet] * k3_DoorSetGraphicsCount); + _g693_doorNativeBitmapIndex_Front_D3LCR[doorSet] = counter++; + _g694_doorNativeBitmapIndex_Front_D2LCR[doorSet] = counter++; + _g695_doorNativeBitmapIndex_Front_D1LCR[doorSet] = counter++; } uint16 alcoveCount = 0; @@ -2397,9 +2390,10 @@ void DisplayMan::f96_loadCurrentMapGraphics() { } } - for (uint16 ornCounter = 0; ornCounter < k1_FountainOrnCount; ++ornCounter) + for (uint16 ornCounter = 0; ornCounter < k1_FountainOrnCount; ++ornCounter) { if (ornIndice == g193_FountainOrnIndices[ornCounter]) _g268_currMapFountainOrnIndices[fountainCount++] = i; + } _g101_currMapWallOrnInfo[i][k1_CoordinateSet] = g194_WallOrnCoordSetIndices[ornIndice]; } @@ -2426,6 +2420,7 @@ void DisplayMan::f96_loadCurrentMapGraphics() { uint16 replColorOrdinal = aspect.getReplColour9(); if (replColorOrdinal) f93_applyCreatureReplColors(9, _vm->M1_ordinalToIndex(replColorOrdinal)); + replColorOrdinal = aspect.getReplColour10(); if (replColorOrdinal) f93_applyCreatureReplColors(10, _vm->M1_ordinalToIndex(replColorOrdinal)); @@ -2455,198 +2450,169 @@ void DisplayMan::f105_drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativ } } - -Box g202_BoxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription -byte g203_InscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY - 48, /* 1 Line */ - 59, /* 2 lines */ - 75, /* 3 lines */ - 86}; /* 4 lines */ -byte g190_WallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_WallOrnamentDerivedBitmapIndexIncrement - 0, /* D3L Right */ - 0, /* D3R Left */ - 1, /* D3L Front */ - 1, /* D3C Front */ - 1, /* D3R Front */ - 2, /* D2L Right */ - 2, /* D2R Left */ - 3, /* D2L Front */ - 3, /* D2C Front */ - 3, /* D2R Front */ - 4, /* D1L Right */ - 4}; /* D1R Left */ - - -byte g204_UnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2 - /* { Y for 1 line, Y for 2 lines, Y for 3 lines } */ - 45, 48, 53, /* D3L Right, D3R Left */ - 43, 49, 56, /* D3L Front, D3C Front, D3R Front */ - 42, 49, 56, /* D2L Right, D2R Left */ - 46, 53, 63, /* D2L Front, D2C Front, D2R Front */ - 46, 57, 68}; /* D1L Right, D1R Left */ - -Box g109_BoxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall - bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) { -#define AP0116_i_CharacterCount wallOrnOrd -#define AP0116_i_WallOrnamentIndex wallOrnOrd - int16 L0088_i_Multiple; -#define AL0088_i_NativeBitmapIndex L0088_i_Multiple -#define AL0088_i_UnreadableTextLineCount L0088_i_Multiple - int16 L0089_i_Multiple; -#define AL0089_i_WallOrnamentCoordinateSetIndex L0089_i_Multiple -#define AL0089_i_FountainOrnamentIndex L0089_i_Multiple -#define AL0089_i_PixelWidth L0089_i_Multiple -#define AL0089_i_X L0089_i_Multiple - - uint16 *AL0090_puc_CoordinateSet = nullptr; - - byte* L0091_puc_Multiple; -#define AL0091_puc_Character L0091_puc_Multiple -#define AL0091_puc_Bitmap L0091_puc_Multiple - byte* L0092_puc_Bitmap; - int16 L0093_i_CoordinateSetOffset; - bool L0094_B_FlipHorizontal; - bool L0095_B_IsInscription; - bool L0096_B_IsAlcove; - int16 L0097_i_TextLineIndex; - uint16 tmp[6]; - byte L0099_auc_InscriptionString[70]; - + static const Box boxWallPatchBehindInscription = Box(110, 113, 37, 63); // @ G0202_ac_Graphic558_Box_WallPatchBehindInscription + static const byte inscriptionLineY[4] = { // @ G0203_auc_Graphic558_InscriptionLineY + 48, /* 1 Line */ + 59, /* 2 lines */ + 75, /* 3 lines */ + 86 /* 4 lines */ + }; + static const byte wallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_WallOrnamentDerivedBitmapIndexIncrement + 0, /* D3L Right */ + 0, /* D3R Left */ + 1, /* D3L Front */ + 1, /* D3C Front */ + 1, /* D3R Front */ + 2, /* D2L Right */ + 2, /* D2R Left */ + 3, /* D2L Front */ + 3, /* D2C Front */ + 3, /* D2R Front */ + 4, /* D1L Right */ + 4 /* D1R Left */ + }; + + static const byte unreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2 + /* { Y for 1 line, Y for 2 lines, Y for 3 lines } */ + 45, 48, 53, /* D3L Right, D3R Left */ + 43, 49, 56, /* D3L Front, D3C Front, D3R Front */ + 42, 49, 56, /* D2L Right, D2R Left */ + 46, 53, 63, /* D2L Front, D2C Front, D2R Front */ + 46, 57, 68 /* D1L Right, D1R Left */ + }; + + static const Box boxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall if (wallOrnOrd) { - wallOrnOrd--; - AL0088_i_NativeBitmapIndex = _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k0_NativeBitmapIndex]; - - AL0090_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex = - _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k1_CoordinateSet]][viewWallIndex]; - - L0096_B_IsAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(AP0116_i_WallOrnamentIndex); - if (L0095_B_IsInscription = (AP0116_i_WallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex)) { - _vm->_dungeonMan->f168_decodeText((char *)L0099_auc_InscriptionString, _g290_inscriptionThing, k0_TextTypeInscription); - } + int16 wallOrnamentIndex = wallOrnOrd - 1; + int16 nativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k0_NativeBitmapIndex]; + int16 wallOrnamentCoordinateSetIndex = _g101_currMapWallOrnInfo[wallOrnamentIndex][k1_CoordinateSet]; + uint16 *coordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][viewWallIndex]; + + bool isAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(wallOrnamentIndex); + bool isInscription = (wallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex); + byte inscriptionString[70]; + if (isInscription) + _vm->_dungeonMan->f168_decodeText((char *)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription); + + byte *displayBitmap; + int16 boxSrcX; if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) { if (viewWallIndex == k12_ViewWall_D1C_FRONT) { - if (L0095_B_IsInscription) { + if (isInscription) { f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, - g202_BoxWallPatchBehindInscription, 94, 28, + (Box &)boxWallPatchBehindInscription, 94, 28, g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, k112_byteWidthViewport, kM1_ColorNoTransparency, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport); - byte *AL0090_puc_String = L0099_auc_InscriptionString; - L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont); - L0097_i_TextLineIndex = 0; + byte *tmpString = inscriptionString; + byte *fontBitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont); + int16 textLineIndex = 0; do { - AP0116_i_CharacterCount = 0; - AL0091_puc_Character = AL0090_puc_String; - while (*AL0091_puc_Character++ < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */ - AP0116_i_CharacterCount++; + int16 characterCount = 0; + byte *curCharacter = tmpString; + while (*curCharacter++ < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */ + characterCount++; } - Frame L0098_s_Frame; - L0098_s_Frame._box._x2 = (L0098_s_Frame._box._x1 = 112 - (AP0116_i_CharacterCount << 2)) + 7; - L0098_s_Frame._box._y1 = (L0098_s_Frame._box._y2 = g203_InscriptionLineY[L0097_i_TextLineIndex++]) - 7; - while (AP0116_i_CharacterCount--) { - f132_blitToBitmap(L0092_puc_Bitmap, _g296_bitmapViewport, L0098_s_Frame._box, - *AL0090_puc_String++ << 3, 0, 144, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport); - L0098_s_Frame._box._x1 += 8; - L0098_s_Frame._box._x2 += 8; + Frame curFrame; + curFrame._box._x2 = (curFrame._box._x1 = 112 - (characterCount << 2)) + 7; + curFrame._box._y1 = (curFrame._box._y2 = inscriptionLineY[textLineIndex++]) - 7; + while (characterCount--) { + f132_blitToBitmap(fontBitmap, _g296_bitmapViewport, curFrame._box, + *tmpString++ << 3, 0, 144, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport); + curFrame._box._x1 += 8; + curFrame._box._x2 += 8; } - } while (*AL0090_puc_String++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */ - goto T0107031; + } while (*tmpString++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */ + return isAlcove; } - AL0088_i_NativeBitmapIndex++; - _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = AL0090_puc_CoordinateSet[0]; - _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = AL0090_puc_CoordinateSet[1]; - _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = AL0090_puc_CoordinateSet[2]; - _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = AL0090_puc_CoordinateSet[3]; + nativeBitmapIndex++; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordinateSet[0]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordinateSet[1]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordinateSet[2]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordinateSet[3]; - _vm->_dungeonMan->_g286_isFacingAlcove = L0096_B_IsAlcove; + _vm->_dungeonMan->_g286_isFacingAlcove = isAlcove; _vm->_dungeonMan->_g287_isFacingViAltar = - (AP0116_i_WallOrnamentIndex == _g266_currMapViAltarIndex); + (wallOrnamentIndex == _g266_currMapViAltarIndex); _vm->_dungeonMan->_g288_isFacingFountain = false; - for (AL0089_i_FountainOrnamentIndex = 0; AL0089_i_FountainOrnamentIndex < k1_FountainOrnCount; AL0089_i_FountainOrnamentIndex++) { - if (_g268_currMapFountainOrnIndices[AL0089_i_FountainOrnamentIndex] == AP0116_i_WallOrnamentIndex) { + for (int16 idx = 0; idx < k1_FountainOrnCount; idx++) { + if (_g268_currMapFountainOrnIndices[idx] == wallOrnamentIndex) { _vm->_dungeonMan->_g288_isFacingFountain = true; break; } } } - AL0091_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex); + displayBitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); if (viewWallIndex == k11_ViewWall_D1R_LEFT) { - f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]); - AL0091_puc_Bitmap = _g74_tmpBitmap; + f99_copyBitmapAndFlipHorizontal(displayBitmap, _g74_tmpBitmap, coordinateSet[4], coordinateSet[5]); + displayBitmap = _g74_tmpBitmap; } - AL0089_i_X = 0; + boxSrcX = 0; } else { - uint16 *AL0091_puc_CoordinateSet; - L0093_i_CoordinateSetOffset = 0; - if (L0094_B_FlipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT)) { - AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k11_ViewWall_D1R_LEFT]; - } else { - if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) { - AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k10_ViewWall_D1L_RIGHT]; - } else { - AL0088_i_NativeBitmapIndex++; - AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k12_ViewWall_D1C_FRONT]; - if (viewWallIndex == k7_ViewWall_D2L_FRONT) { - L0093_i_CoordinateSetOffset = 6; - } else { - if (viewWallIndex == k9_ViewWall_D2R_FRONT) { - L0093_i_CoordinateSetOffset = -6; - } - } - } + uint16 *coordinateSet; + int16 coordinateSetOffset = 0; + bool flipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT); + if (flipHorizontal || (viewWallIndex == k1_ViewWall_D3R_LEFT)) { + coordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k11_ViewWall_D1R_LEFT]; + } else if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) + coordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k10_ViewWall_D1L_RIGHT]; + else { + nativeBitmapIndex++; + coordinateSet = g205_WallOrnCoordSets[wallOrnamentCoordinateSetIndex][k12_ViewWall_D1C_FRONT]; + if (viewWallIndex == k7_ViewWall_D2L_FRONT) + coordinateSetOffset = 6; + else if (viewWallIndex == k9_ViewWall_D2R_FRONT) + coordinateSetOffset = -6; } - AL0089_i_PixelWidth = (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[1] - (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[0]; - if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + - (AP0116_i_WallOrnamentIndex << 2) + g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex])) { - L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex); - f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex), - AL0091_puc_CoordinateSet[4] << 1, - AL0091_puc_CoordinateSet[5], AL0089_i_PixelWidth + 1, - AL0090_puc_CoordinateSet[5], + int16 pixelWidth = (coordinateSet + coordinateSetOffset)[1] - (coordinateSet + coordinateSetOffset)[0]; + wallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + (wallOrnamentIndex << 2) + wallOrnDerivedBitmapIndexIncrement[viewWallIndex]; + if (!f491_isDerivedBitmapInCache(wallOrnamentIndex)) { + byte *L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(wallOrnamentIndex), + coordinateSet[4] << 1, + coordinateSet[5], pixelWidth + 1, + coordinateSet[5], (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2); - f493_addDerivedBitmap(AP0116_i_WallOrnamentIndex); - } - AL0091_puc_Bitmap = f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex); - if (L0094_B_FlipHorizontal) { - f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]); - AL0091_puc_Bitmap = _g74_tmpBitmap; - AL0089_i_X = 15 - (AL0089_i_X & 0x000F); - } else { - if (viewWallIndex == k7_ViewWall_D2L_FRONT) { - AL0089_i_X -= AL0090_puc_CoordinateSet[1] - AL0090_puc_CoordinateSet[0]; - } else { - AL0089_i_X = 0; - } + f493_addDerivedBitmap(wallOrnamentIndex); } + displayBitmap = f492_getDerivedBitmap(wallOrnamentIndex); + if (flipHorizontal) { + f99_copyBitmapAndFlipHorizontal(displayBitmap, _g74_tmpBitmap, coordinateSet[4], coordinateSet[5]); + displayBitmap = _g74_tmpBitmap; + boxSrcX = 15 - (boxSrcX & 0x000F); + } else if (viewWallIndex == k7_ViewWall_D2L_FRONT) + boxSrcX = pixelWidth - (coordinateSet[1] - coordinateSet[0]); + else + boxSrcX = 0; } - if (L0095_B_IsInscription) { - byte *AL0090_puc_String = L0099_auc_InscriptionString; - AL0088_i_UnreadableTextLineCount = 0; + if (isInscription) { + byte *tmpString = inscriptionString; + int16 unreadableTextLineCount = 0; do { - while (*AL0090_puc_String < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */ - AL0090_puc_String++; + while (*tmpString < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */ + tmpString++; } - AL0088_i_UnreadableTextLineCount++; - } while (*AL0090_puc_String++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */ - if (AL0088_i_UnreadableTextLineCount < 4) { + unreadableTextLineCount++; + } while (*tmpString++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */ + if (unreadableTextLineCount < 4) { + uint16 tmp[6]; for (uint16 i = 0; i < 6; ++i) - tmp[i] = AL0090_puc_CoordinateSet[i]; - AL0090_puc_CoordinateSet = tmp; - AL0090_puc_CoordinateSet[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + AL0088_i_UnreadableTextLineCount - 1]; + tmp[i] = coordinateSet[i]; + coordinateSet = tmp; + coordinateSet[3] = unreadableInscriptionBoxY2[wallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1]; } } - f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport, - *(Box *)AL0090_puc_CoordinateSet, AL0089_i_X, 0, - AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport); + f132_blitToBitmap(displayBitmap, _g296_bitmapViewport, + *(Box *)coordinateSet, boxSrcX, 0, + coordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, coordinateSet[5], k136_heightViewport); if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), - _g296_bitmapViewport, g109_BoxChampionPortraitOnWall, + _g296_bitmapViewport, (Box &)boxChampionPortraitOnWall, (_g289_championPortraitOrdinal & 0x0007) << 5, (_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); } -T0107031: - return L0096_B_IsAlcove; + return isAlcove; } return false; } -- cgit v1.2.3 From 800aec5d57375b4f23d071ead1d52d7700e2e36a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 29 Jul 2016 09:51:39 +0200 Subject: DM: Remove duplicate array --- engines/dm/champion.cpp | 43 +------------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index de0ed3efb1..143aa42afa 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -40,47 +40,6 @@ namespace DM { -uint16 g38_slotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks - /* 30 for champion inventory, 8 for chest */ - 0xFFFF, /* Ready Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Action Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0x0002, /* Head Head */ - 0x0008, /* Torso Torso */ - 0x0010, /* Legs Legs */ - 0x0020, /* Feet Feet */ - 0x0100, /* Pouch 2 Pouch */ - 0x0080, /* Quiver Line2 1 Quiver 2 */ - 0x0080, /* Quiver Line1 2 Quiver 2 */ - 0x0080, /* Quiver Line2 2 Quiver 2 */ - 0x0004, /* Neck Neck */ - 0x0100, /* Pouch 1 Pouch */ - 0x0040, /* Quiver Line1 1 Quiver 1 */ - 0xFFFF, /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0xFFFF, /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */ - 0x0400, /* Chest 1 Chest */ - 0x0400, /* Chest 2 Chest */ - 0x0400, /* Chest 3 Chest */ - 0x0400, /* Chest 4 Chest */ - 0x0400, /* Chest 5 Chest */ - 0x0400, /* Chest 6 Chest */ - 0x0400, /* Chest 7 Chest */ - 0x0400}; /* Chest 8 Chest */ - const char *g417_baseSkillName[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"}; Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth @@ -1281,7 +1240,7 @@ void ChampionMan::f302_processCommands28to65_clickOnSlotBox(uint16 slotBoxIndex) if ((slotThing == Thing::_none) && (leaderHandObject == Thing::_none)) return; - if ((leaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & g38_slotMasks[slotIndex]))) + if ((leaderHandObject != Thing::_none) && (!(g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(leaderHandObject)]._allowedSlots & gSlotMasks[slotIndex]))) return; _vm->_eventMan->f78_showMouse(); -- cgit v1.2.3 From 8540fdc800976e67039cfa253673b8a32a8879d2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 29 Jul 2016 10:58:35 +0200 Subject: DM: Some rework in f303_getSkillLevel --- engines/dm/champion.cpp | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 143aa42afa..b88864febb 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -2436,24 +2436,24 @@ T0281033_ProceedToTitle: } uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) { - if (_vm->_championMan->_g300_partyIsSleeping) { + if (_vm->_championMan->_g300_partyIsSleeping) return 1; - } + bool ignoreTmpExp = getFlag(skillIndex, k0x8000_IgnoreTemporaryExperience); bool ignoreObjModifiers = getFlag(skillIndex, k0x4000_IgnoreObjectModifiers); clearFlag(skillIndex, k0x8000_IgnoreTemporaryExperience | k0x4000_IgnoreObjectModifiers); Champion *champ = &_vm->_championMan->_gK71_champions[champIndex]; Skill *skill = &champ->_skills[skillIndex]; int32 exp = skill->_experience; - if (!ignoreTmpExp) { + if (!ignoreTmpExp) exp += skill->_temporaryExperience; - } + if (skillIndex > k3_ChampionSkillWizard) { /* Hidden skill */ skill = &champ->_skills[(skillIndex - k4_ChampionSkillSwing) >> 2]; exp += skill->_experience; /* Add experience in the base skill */ - if (!ignoreTmpExp) { + if (!ignoreTmpExp) exp += skill->_temporaryExperience; - } + exp >>= 1; /* Halve experience to get average of base skill + hidden skill experience */ } int16 skillLevel = 1; @@ -2462,35 +2462,33 @@ uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) { skillLevel++; } if (!ignoreObjModifiers) { - int16 actionHandIconIndex; - if ((actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand])) == k27_IconIndiceWeaponTheFirestaff) { + int16 actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]); + if (actionHandIconIndex == k27_IconIndiceWeaponTheFirestaff) skillLevel++; - } else { - if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete) { - skillLevel += 2; - } - } + else if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete) + skillLevel += 2; + int16 neckIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k10_ChampionSlotNeck]); switch (skillIndex) { case k3_ChampionSkillWizard: - if (neckIconIndex == k124_IconIndiceJunkPendantFeral) { + if (neckIconIndex == k124_IconIndiceJunkPendantFeral) skillLevel += 1; - } - break; - case k15_ChampionSkillDefend: - if (neckIconIndex == k121_IconIndiceJunkEkkhardCross) { - skillLevel += 1; - } break; case k13_ChampionSkillHeal: - if ((neckIconIndex == k120_IconIndiceJunkGemOfAges) || (actionHandIconIndex == k66_IconIndiceWeaponSceptreOfLyf)) { /* The skill modifiers of these two objects are not cumulative */ + // The skill modifiers of these two objects are not cumulative + if ((neckIconIndex == k120_IconIndiceJunkGemOfAges) || (actionHandIconIndex == k66_IconIndiceWeaponSceptreOfLyf)) skillLevel += 1; - } break; case k14_ChampionSkillInfluence: - if (neckIconIndex == k122_IconIndiceJunkMoonstone) { + if (neckIconIndex == k122_IconIndiceJunkMoonstone) skillLevel += 1; - } + break; + case k15_ChampionSkillDefend: + if (neckIconIndex == k121_IconIndiceJunkEkkhardCross) + skillLevel += 1; + break; + default: + break; } } return skillLevel; -- cgit v1.2.3 From 6e9fbffce30763f52c9634c5217ea96788904f6e Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 29 Jul 2016 15:13:38 +0200 Subject: DM: Add f352_processCommand71_clickOnEye, setting _g597_ignoreMouseMovements now prevents mouse movement --- engines/dm/TODOs/todo.txt | 2 ++ engines/dm/eventman.cpp | 16 +++++++++++++++- engines/dm/eventman.h | 2 +- engines/dm/gfx.cpp | 1 + engines/dm/inventory.cpp | 22 ++++++++++++++++++++++ engines/dm/inventory.h | 1 + 6 files changed, 42 insertions(+), 2 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 3bbcf6bdfe..3a9156458d 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -35,3 +35,5 @@ Finish stuff: Missing main loop methods Save file f433_processCommand140_saveGame fails silently +Refactoring + Places implementing mini mainloop and where input doesn't really matter should call discardInput instead of processInput diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 83e07eb1f7..16bfe4d3f9 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -596,12 +596,15 @@ Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Eve case Common::EVENT_RBUTTONUP: { MouseButton button = (event.type == Common::EVENT_LBUTTONDOWN) ? k1_LeftMouseButton : k2_RightMouseButton; _g558_mouseButtonStatus &= ~button; + f544_resetPressingEyeOrMouth(); break; } default: break; } } + if (_g597_ignoreMouseMovements) + setMousePos(_mousePos); return Common::EVENT_INVALID; } @@ -722,7 +725,7 @@ void EventManager::f380_processCommandQueue() { return; } if (cmdType == k71_CommandClickOnEye) { - warning(false, "MISSING CODE: F0352_INVENTORY_ProcessCommand71_ClickOnEye();"); + _vm->_inventoryMan->f352_processCommand71_clickOnEye(); return; } if (cmdType == k80_CommandClickInDungeonView) { @@ -1523,4 +1526,15 @@ void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX, } } } + +void EventManager::f544_resetPressingEyeOrMouth() { + if (_vm->_g331_pressingEye) { + _g597_ignoreMouseMovements = false; + _vm->_g332_stopPressingEye = true; + } + if (_vm->_g333_pressingMouth) { + _g597_ignoreMouseMovements = false; + _vm->_g334_stopPressingMouth = true; + } +} } // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index a12cc2e852..3cf54785f6 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -316,7 +316,7 @@ public: void f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY); // @ F0370_COMMAND_ProcessType100_ClickInSpellArea void f369_commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType); // @ F0369_COMMAND_ProcessTypes101To108_ClickInSpellSymbolsArea_CPSE void f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY); // @ F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE - + void f544_resetPressingEyeOrMouth();// @ F0544_INPUT_ResetPressingEyeOrMouth }; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 38c1e5dd10..ef2118f92d 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1235,6 +1235,7 @@ void DisplayMan::f97_drawViewport(int16 palSwitchingRequestedState) { } else { f565_viewportSetPalette(nullptr, nullptr); } + updateScreen(); } byte *DisplayMan::getCurrentVgaBuffer() { diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 52e70d4e62..9ecfed1f69 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -939,4 +939,26 @@ void InventoryMan::f348_adjustStatisticCurrentValue(Champion* champ, uint16 stat champ->_statistics[statIndex][k1_ChampionStatCurrent] += AL1077_i_Delta; } +void InventoryMan::f352_processCommand71_clickOnEye() { + _vm->_eventMan->_g597_ignoreMouseMovements = true; + _vm->_g331_pressingEye = true; + if (!_vm->_eventMan->isMouseButtonDown(k1_LeftMouseButton)) { + _vm->_eventMan->_g597_ignoreMouseMovements = false; + _vm->_g331_pressingEye = false; + _vm->_g332_stopPressingEye = false; + return; + } + _vm->_eventMan->f357_discardAllInput(); + _vm->_eventMan->f78_showMouse(); + _vm->f22_delay(8); + _vm->_inventoryMan->f332_drawIconToViewport(k203_IconIndiceEyeLooking, 12, 13); + if (_vm->_championMan->_g415_leaderEmptyHanded) { + f351_drawChampionSkillsAndStatistics(); + } else { + _vm->_objectMan->f35_clearLeaderObjectName(); + _vm->_inventoryMan->f342_drawPanelObject(_vm->_championMan->_g414_leaderHandObject, true); + } + _vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView); + +} } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index a115c9819f..7617a9d77c 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -85,6 +85,7 @@ public: void f353_drawStopPressingEye();// @ F0353_INVENTORY_DrawStopPressingEye void f349_processCommand70_clickOnMouth(); // @ F0349_INVENTORY_ProcessCommand70_ClickOnMouth void f348_adjustStatisticCurrentValue(Champion *champ, uint16 statIndex, int16 valueDelta); // @ F0348_INVENTORY_AdjustStatisticCurrentValue + void f352_processCommand71_clickOnEye(); // @ F0352_INVENTORY_ProcessCommand71_ClickOnEye }; -- cgit v1.2.3 From 6bbd68199c002fb4a9532f1e87ac182b2d9b386f Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 29 Jul 2016 15:17:39 +0200 Subject: DM: Add missing call to f379_drawSleepScreen, fix bytewidth bug in f379_drawSleepScreen --- engines/dm/eventman.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 16bfe4d3f9..b30292ed44 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -748,7 +748,7 @@ void EventManager::f380_processCommandQueue() { } _vm->_menuMan->f456_drawDisabledMenu(); _vm->_championMan->_g300_partyIsSleeping = true; - warning(false, "MISSING CODE: F0379_COMMAND_DrawSleepScreen();"); + f379_drawSleepScreen(); _vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame); _vm->_g318_waitForInputMaxVerticalBlankCount = 0; _vm->_eventMan->_g441_primaryMouseInput = g450_PrimaryMouseInput_PartySleeping; @@ -1297,7 +1297,7 @@ bool EventManager::f360_hasPendingClick(Common::Point& point, MouseButton button } void EventManager::f379_drawSleepScreen() { - _vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 224, 136); // TODO: localization + _vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 112, 136); // TODO: localization } void EventManager::f357_discardAllInput() { -- cgit v1.2.3 From ac9f4d7d4473e871db3e55c044eb109b339d08c3 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 29 Jul 2016 15:31:29 +0200 Subject: DM: Add some missing calls to already implemented methods --- engines/dm/TODOs/todo.txt | 9 +++++++++ engines/dm/eventman.cpp | 2 +- engines/dm/gfx.cpp | 4 ---- engines/dm/menus.cpp | 6 +++--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 3a9156458d..4fb935fad9 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -34,6 +34,15 @@ Finish stuff: f380_processCommandQueue Missing main loop methods Save file f433_processCommand140_saveGame fails silently + Sounds + F0438_STARTEND_OpenEntranceDoors + F0442_STARTEND_ProcessCommand202_EntranceDrawCredits + G0335_ui_SelectedDialogChoice + Add dialogs + Add failcheck to saveing and loading + F0444_STARTEND_Endgame + F0385_MENUS_DrawActionDamage Refactoring Places implementing mini mainloop and where input doesn't really matter should call discardInput instead of processInput + While reanming a champion, the mouse lags \ No newline at end of file diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index b30292ed44..90f22054b5 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -1209,7 +1209,7 @@ void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) { return; commandType = f358_getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton); if (commandType != k0_CommandNone) - warning(false, "MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox"); + _vm->_championMan->f302_processCommands28to65_clickOnSlotBox(commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand); break; case k5_PanelContentResurrectReincarnate: if (!champMan._g415_leaderEmptyHanded) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index ef2118f92d..b76792b651 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -1252,7 +1252,6 @@ uint16 DisplayMan::getPixelHeight(uint16 index) { return READ_BE_UINT16(data + 2); } -// Note: has been screened for missing code void DisplayMan::f99_copyBitmapAndFlipHorizontal(byte* srcBitmap, byte* destBitmap, uint16 byteWidth, uint16 height) { memmove(destBitmap, srcBitmap, byteWidth * 2 * height * sizeof(byte)); f130_flipBitmapHorizontal(destBitmap, byteWidth, height); @@ -1462,7 +1461,6 @@ void DisplayMan::f100_drawWallSetBitmap(byte *bitmap, Frame &f) { } -// NOTE: has been screened for missing code void DisplayMan::f116_drawSquareD3L(Direction dir, int16 posX, int16 posY) { static DoorFrames g179_doorFrame_D3L = DoorFrames( // @ G0179_s_Graphic558_Frames_Door_D3L /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ @@ -2272,7 +2270,6 @@ void DisplayMan::f134_fillBitmap(byte *bitmap, Color color, uint16 byteWidth, ui memset(bitmap, color, sizeof(byte) * width * height); } -// NOTE: has been screened for missing code void DisplayMan::f94_loadFloorSet(FloorSet set) { if (_g230_currentFloorSet != set) { _g230_currentFloorSet = set; @@ -2282,7 +2279,6 @@ void DisplayMan::f94_loadFloorSet(FloorSet set) { } } -// Note: has been screened for missing code void DisplayMan::f95_loadWallSet(WallSet set) { if ((_g231_currentWallSet != set) || _vm->_g523_restartGameRequest) { _g231_currentWallSet = set; diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 29312531b4..0f4bde5f21 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -187,7 +187,7 @@ void MenuMan::f456_drawDisabledMenu() { } warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox"); warning(false, "MISSING CODE: F0136_VIDEO_ShadeScreenBox"); - warning(false, "MISSING CODE: F0067_MOUSE_SetPointerToNormal"); + _vm->_eventMan->f67_setMousePointerToNormal(k0_pointerArrow); } } @@ -304,7 +304,7 @@ void MenuMan::f393_drawSpellAreaControls(ChampionIndex champIndex) { int16 champCurrHealth[4]; for (uint16 i = 0; i < 4; ++i) champCurrHealth[i] = champMan._gK71_champions[i]._currHealth; - warning(false, "MISSING CODE: F0077_MOUSE_HidePointer_CPSE"); + _vm->_eventMan->f77_hideMouse(); dispMan.D24_fillScreenBox(g504_BoxSpellAreaControls, k0_ColorBlack); int16 champCount = champMan._g305_partyChampionCount; switch (champIndex) { @@ -360,7 +360,7 @@ labelChamp3: textMan.f53_printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ._name); break; } - warning(false, "MISSING CODE: F0078_MOUSE_ShowPointer"); + _vm->_eventMan->f78_showMouse(); } #define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS -- cgit v1.2.3 From 734abf8d48a1a0d9c00d27801d6be9e54854d702 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 29 Jul 2016 15:50:38 +0200 Subject: DM: Adjust idle delay when renaming champion --- engines/dm/TODOs/todo.txt | 1 - engines/dm/champion.cpp | 2 +- engines/dm/dm.cpp | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 4fb935fad9..b6e3ad8e27 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -45,4 +45,3 @@ Finish stuff: Refactoring Places implementing mini mainloop and where input doesn't really matter should call discardInput instead of processInput - While reanming a champion, the mouse lags \ No newline at end of file diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b88864febb..9dcb199358 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -2327,7 +2327,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) { { eventType = _vm->_eventMan->processInput(&event, &event); _vm->_displayMan->updateScreen(); - _vm->f22_delay(1); + //_vm->f22_delay(1); } if (eventType == Common::EVENT_LBUTTONDOWN) { /* If left mouse button status has changed */ Common::Point mousePos = _vm->_eventMan->getMousePos(); diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index dc778aa734..33cfe2fbf3 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -472,8 +472,6 @@ void DMEngine::f441_processEntrance() { } do { f439_drawEntrance(); - //_eventMan->f77_hideMouse(); - //_eventMan->f77_hideMouse(); _eventMan->f78_showMouse(); _eventMan->f357_discardAllInput(); _g298_newGame = k99_modeWaitingOnEntrance; -- cgit v1.2.3 From ec28573a3b8dac8728f89cf7d9f221f901812388 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 29 Jul 2016 16:07:56 +0200 Subject: DM: Add f385_drawActionDamage --- engines/dm/TODOs/todo.txt | 2 +- engines/dm/gfx.h | 2 ++ engines/dm/menus.cpp | 76 +++++++++++++++++++++++++++++++++++++++++++++-- engines/dm/menus.h | 1 + 4 files changed, 78 insertions(+), 3 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index b6e3ad8e27..46928ac0f0 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -41,7 +41,7 @@ Finish stuff: Add dialogs Add failcheck to saveing and loading F0444_STARTEND_Endgame - F0385_MENUS_DrawActionDamage + Refactoring Places implementing mini mainloop and where input doesn't really matter should call discardInput instead of processInput diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 3af375d493..57216981c5 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -212,6 +212,7 @@ enum GraphicIndice { k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA k11_MenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES k13_MovementArrowsIndice = 13, // @ C013_GRAPHIC_MOVEMENT_ARROWS + k14_damageToCreatureIndice = 14, // @ C014_GRAPHIC_DAMAGE_TO_CREATURE k15_damageToChampionSmallIndice = 15, // @ C015_GRAPHIC_DAMAGE_TO_CHAMPION_SMALL k16_damageToChampionBig = 16, // @ C016_GRAPHIC_DAMAGE_TO_CHAMPION_BIG k17_InventoryGraphicIndice = 17, // @ C017_GRAPHIC_INVENTORY @@ -276,6 +277,7 @@ enum GraphicIndice { k557_FontGraphicIndice = 557 // @ C557_GRAPHIC_FONT }; +extern byte g17_PalChangesNoChanges[16]; extern uint16 gK57_PalSwoosh[16]; // @ K0057_aui_Palette_Swoosh extern uint16 gK150_PalMousePointer[16]; // @ K0150_aui_Palette_MousePointer extern uint16 g19_PalCredits[16]; // @ G0019_aui_Graphic562_Palette_Credits diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 0f4bde5f21..513b8fb0f0 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -228,7 +228,7 @@ void MenuMan::f390_refreshActionAreaAndSetChampDirMaxDamageReceived() { if (_g508_refreshActionArea) { if (!champMan._g506_actingChampionOrdinal) { if (_g513_actionDamage) { - warning(false, "MISSING CODE: F0385_MENUS_DrawActionDamage"); + f385_drawActionDamage(_g513_actionDamage); _g513_actionDamage = 0; } else { _g509_actionAreaContainsIcons = true; @@ -403,7 +403,7 @@ void MenuMan::f394_setMagicCasterAndDrawSpellArea(int16 champIndex) { } if (_vm->_championMan->_g514_magicCasterChampionIndex == kM1_ChampionNone) { _vm->_eventMan->f78_showMouse(); - _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &g0_BoxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33); + _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &g0_BoxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33); _vm->_eventMan->f77_hideMouse(); } if (champIndex == kM1_ChampionNone) { @@ -1666,4 +1666,76 @@ int16 MenuMan::f382_getActionObjectChargeCount() { return 1; } } + +void MenuMan::f385_drawActionDamage(int16 damage) { + static Box G0502_s_Graphic560_Box_ActionAreaMediumDamage = {242, 305, 81, 117}; + static Box G0503_s_Graphic560_Box_ActionAreaSmallDamage = {251, 292, 81, 117}; + + uint16 L1174_ui_Multiple; +#define AL1174_ui_DerivedBitmapIndex L1174_ui_Multiple +#define AL1174_ui_CharacterIndex L1174_ui_Multiple + int16 L1175_i_ByteWidth; + int16 L1176_i_Multiple; +#define AL1176_i_X L1176_i_Multiple +#define AL1176_i_PixelWidth L1176_i_Multiple + byte* L1177_puc_Bitmap; + unsigned char* L1178_puc_Multiple; +#define AL1178_puc_String L1178_puc_Multiple +#define AL1178_puc_Bitmap L1178_puc_Multiple + char L1179_ac_String[6]; + Box* L1180_ps_Box; + int16 L1643_i_Width; + + _vm->_eventMan->f78_showMouse(); + _vm->_displayMan->_g578_useByteBoxCoordinates = false; + _vm->_displayMan->D24_fillScreenBox(g1_BoxActionArea, k0_ColorBlack); + if (damage < 0) { + if (damage == kM1_damageCantReach) { + AL1176_i_X = 242; + AL1178_puc_String = (unsigned char*)"CAN'T REACH"; // TODO: localization + } else { + AL1176_i_X = 248; + AL1178_puc_String = (unsigned char*)"NEED AMMO"; // TODO: localization + } + _vm->_textMan->f53_printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, (char *)AL1178_puc_String); + } else { + if (damage > 40) { + L1180_ps_Box = &g499_BoxActionArea3ActionMenu; + L1177_puc_Bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k14_damageToCreatureIndice); + L1175_i_ByteWidth = k48_byteWidth; + L1643_i_Width = 45; + } else { + if (damage > 15) { + AL1174_ui_DerivedBitmapIndex = k2_DerivedBitmapDamageToCreatureMedium; + AL1176_i_PixelWidth = 64; + L1175_i_ByteWidth = k32_byteWidth; + L1180_ps_Box = &G0502_s_Graphic560_Box_ActionAreaMediumDamage; + } else { + AL1174_ui_DerivedBitmapIndex = k3_DerivedBitmapDamageToCreatureSmall; + AL1176_i_PixelWidth = 42; + L1175_i_ByteWidth = k24_byteWidth; + L1180_ps_Box = &G0503_s_Graphic560_Box_ActionAreaSmallDamage; + } + L1643_i_Width = 37; + if (!_vm->_displayMan->f491_isDerivedBitmapInCache(AL1174_ui_DerivedBitmapIndex)) { + AL1178_puc_Bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(k14_damageToCreatureIndice); + _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(AL1178_puc_Bitmap, L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex), 96, 45, AL1176_i_PixelWidth, 37, g17_PalChangesNoChanges); + _vm->_displayMan->f493_addDerivedBitmap(AL1174_ui_DerivedBitmapIndex); + } else { + L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex); + } + } + _vm->_displayMan->f21_blitToScreen(L1177_puc_Bitmap, L1180_ps_Box, L1175_i_ByteWidth, kM1_ColorNoTransparency, L1643_i_Width); + /* Convert damage value to string */ + AL1174_ui_CharacterIndex = 5; + AL1176_i_X = 274; + L1179_ac_String[5] = '\0'; + do { + L1179_ac_String[--AL1174_ui_CharacterIndex] = '0' + (damage % 10); + AL1176_i_X -= 3; + } while (damage /= 10); + _vm->_textMan->f53_printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, &L1179_ac_String[AL1174_ui_CharacterIndex]); + } + _vm->_eventMan->f77_hideMouse(); +} } diff --git a/engines/dm/menus.h b/engines/dm/menus.h index f0a1c2bf58..6652fdc291 100644 --- a/engines/dm/menus.h +++ b/engines/dm/menus.h @@ -116,6 +116,7 @@ public: void f389_processCommands116To119_setActingChampion(uint16 champIndex); // @ F0389_MENUS_ProcessCommands116To119_SetActingChampion void f383_setActionList(ActionSet *actionSet); // @ F0383_MENUS_SetActionList int16 f382_getActionObjectChargeCount(); // @ F0382_MENUS_GetActionObjectChargeCount + void f385_drawActionDamage(int16 damage); // @ F0385_MENUS_DrawActionDamage }; } -- cgit v1.2.3 From 2b2a0283322ba1d3852feb59b4cf2a4bcf5ed891 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 29 Jul 2016 22:27:43 +0200 Subject: DM: Add f444_endGame and checks for Common::EVENT_QUIT --- engines/dm/TODOs/todo.txt | 5 +- engines/dm/champion.cpp | 2 + engines/dm/dm.cpp | 175 ++++++++++++++++++++++++++++++++++++++++++++-- engines/dm/dm.h | 3 + engines/dm/eventman.cpp | 31 +++++++- engines/dm/eventman.h | 3 +- engines/dm/gfx.cpp | 17 +++++ engines/dm/gfx.h | 46 ++++++++---- engines/dm/inventory.cpp | 39 ++++++----- engines/dm/inventory.h | 2 +- engines/dm/loadsave.cpp | 2 +- engines/dm/text.cpp | 14 ++++ engines/dm/text.h | 1 + engines/dm/timeline.cpp | 2 +- 14 files changed, 297 insertions(+), 45 deletions(-) diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 46928ac0f0..8c05efa73a 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -31,6 +31,9 @@ Todo: I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions Finish stuff: + F0444_STARTEND_Endgame + Make missing code warnings to STUB methods + Add quit resuest from scummvm f380_processCommandQueue Missing main loop methods Save file f433_processCommand140_saveGame fails silently @@ -40,7 +43,7 @@ Finish stuff: G0335_ui_SelectedDialogChoice Add dialogs Add failcheck to saveing and loading - F0444_STARTEND_Endgame + Refactoring diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 9dcb199358..a2ff4393cf 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -2326,6 +2326,8 @@ void ChampionMan::f281_renameChampion(Champion* champ) { Common::EventType eventType; { eventType = _vm->_eventMan->processInput(&event, &event); + if (_vm->_engineShouldQuit) + return; _vm->_displayMan->updateScreen(); //_vm->f22_delay(1); } diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 33cfe2fbf3..852145056a 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -150,6 +150,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _projexpl = nullptr; _displayMan = nullptr; + _engineShouldQuit = false; _g528_saveFormat = 0; _g527_platform = 0; _g526_dungeonId = 0; @@ -230,10 +231,11 @@ void DMEngine::f463_initializeGame() { _textMan->f54_textInitialize(); _objectMan->loadObjectNames(); _eventMan->initMouse(); - f441_processEntrance(); - while (f435_loadgame(1) != k1_LoadgameSuccess) { + do { f441_processEntrance(); - } + if (_engineShouldQuit) + return; + } while (f435_loadgame(1) != k1_LoadgameSuccess); //F0396_MENUS_LoadSpellAreaLinesBitmap() is not needed, every bitmap has been loaded // There was some memory wizardy for the Amiga platform, I skipped that part @@ -327,7 +329,9 @@ Common::Error DMEngine::run() { f463_initializeGame(); while (true) { f2_gameloop(); - warning(false, "TODO: F0444_STARTEND_Endgame(G0303_B_PartyDead);"); + if (_engineShouldQuit) + return Common::kNoError; + f444_endGame(_championMan->_g303_partyDead); } return Common::kNoError; @@ -343,6 +347,8 @@ void DMEngine::f2_gameloop() { _g318_waitForInputMaxVerticalBlankCount = 10; while (true) { + if (_engineShouldQuit) + return; if (_g327_newPartyMapIndex != kM1_mapIndexNone) { T0002002: f3_processNewPartyMap(_g327_newPartyMapIndex); @@ -416,8 +422,10 @@ T0002002: } _eventMan->f380_processCommandQueue(); + if (_engineShouldQuit) + return; _displayMan->updateScreen(); - // if (!_vm->_g321_stopWaitingForPlayerInput) { + // if (!_g321_stopWaitingForPlayerInput) { // F0363_COMMAND_HighlightBoxDisable(); // } @@ -477,6 +485,8 @@ void DMEngine::f441_processEntrance() { _g298_newGame = k99_modeWaitingOnEntrance; do { _eventMan->processInput(); + if (_engineShouldQuit) + return; _eventMan->f380_processCommandQueue(); _displayMan->updateScreen(); } while (_g298_newGame == k99_modeWaitingOnEntrance); @@ -493,6 +503,161 @@ void DMEngine::f441_processEntrance() { _g562_entranceDoorAnimSteps[i] = nullptr; } +void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) { + // TODO: localization + static Box G0013_s_Graphic562_Box_Endgame_Restart_Outer = {103, 217, 145, 159}; + static Box G0014_s_Graphic562_Box_Endgame_Restart_Inner = {105, 215, 147, 157}; + static Box G0012_s_Graphic562_Box_Endgame_TheEnd = {120, 199, 95, 108}; + static Box G0015_s_Graphic562_Box_Endgame_ChampionMirror = {11, 74, 7, 49}; + static Box G0016_s_Graphic562_Box_Endgame_ChampionPortrait = {27, 58, 13, 41}; + int16 L1409_i_Multiple; +#define AL1409_i_Color L1409_i_Multiple +#define AL1409_i_ChampionIndex L1409_i_Multiple +#define AL1409_i_VerticalBlankCount L1409_i_Multiple + int16 L1410_i_Multiple; +#define AL1410_i_Counter L1410_i_Multiple +#define AL1410_i_Y L1410_i_Multiple + int16 L1411_i_Multiple; +#define AL1411_i_X L1411_i_Multiple +#define AL1411_i_SkillIndex L1411_i_Multiple + int16 L1412_i_SkillLevel; + char L1415_c_ChampionTitleFirstCharacter; + Champion* L1416_ps_Champion; + uint16 L1419_aui_Palette[16]; + uint16 L1420_aui_Palette_TopAndBottomScreen[16]; + uint16 L1421_aui_Palette_DarkBlue[16]; + char L1422_ac_String[20]; + // Strangerke: Not so sure it's useless. + bool L1423_B_WaitBeforeDrawingRestart; /* BUG0_00 Useless code */ + L1423_B_WaitBeforeDrawingRestart = true; /* BUG0_00 Useless code */ + + _eventMan->f67_setMousePointerToNormal(k0_pointerArrow); + _eventMan->f78_showMouse(); + _eventMan->_g441_primaryMouseInput = nullptr; + _eventMan->_g442_secondaryMouseInput = nullptr; + _eventMan->_g443_primaryKeyboardInput = nullptr; + _eventMan->_g444_secondaryKeyboardInput = nullptr; + if (doNotDrawCreditsOnly && !_g302_gameWon) { + f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately); + f22_delay(240); + } + + if (_displayMan->_g322_paletteSwitchingEnabled) { + for (uint16 i = 0; i < 16; ++i) + L1420_aui_Palette_TopAndBottomScreen[i] = _displayMan->_g347_paletteTopAndBottomScreen[i]; + for (AL1410_i_Counter = 0; AL1410_i_Counter <= 7; AL1410_i_Counter++) { + f22_delay(1); + for (AL1409_i_Color = 0; AL1409_i_Color < 16; AL1409_i_Color++) { + _displayMan->_g346_paletteMiddleScreen[AL1409_i_Color] = _displayMan->f431_getDarkenedColor(_displayMan->_g346_paletteMiddleScreen[AL1409_i_Color]); + _displayMan->_g347_paletteTopAndBottomScreen[AL1409_i_Color] = _displayMan->f431_getDarkenedColor(_displayMan->_g347_paletteTopAndBottomScreen[AL1409_i_Color]); + } + } + _displayMan->_g322_paletteSwitchingEnabled = false; + f22_delay(1); + for (uint16 i = 0; i < 16; ++i) + _displayMan->_g347_paletteTopAndBottomScreen[i] = L1420_aui_Palette_TopAndBottomScreen[i]; + } else { + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(G0345_aui_BlankBuffer)"); + } + if (doNotDrawCreditsOnly) { + if (_g302_gameWon) { + // Strangerke: Related to portraits. Game data could be missing for earlier versions of the game. + _displayMan->fillScreen(k12_ColorDarkestGray); + for (AL1409_i_ChampionIndex = k0_ChampionFirst; AL1409_i_ChampionIndex < _championMan->_g305_partyChampionCount; AL1409_i_ChampionIndex++) { + AL1410_i_Y = AL1409_i_ChampionIndex * 48; + L1416_ps_Champion = &_championMan->_gK71_champions[AL1409_i_ChampionIndex]; + _displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k208_wallOrn_43_champMirror), &G0015_s_Graphic562_Box_Endgame_ChampionMirror, k32_byteWidth, k10_ColorFlesh, 43); + _displayMan->f21_blitToScreen(L1416_ps_Champion->_portrait, &G0016_s_Graphic562_Box_Endgame_ChampionPortrait, k16_byteWidth, k1_ColorDarkGary, 29); + _textMan->f443_endgamePrintString(87, AL1410_i_Y += 14, k9_ColorGold, L1416_ps_Champion->_name); + AL1411_i_X = (6 * strlen(L1416_ps_Champion->_name)) + 87; + L1415_c_ChampionTitleFirstCharacter = L1416_ps_Champion->_title[0]; + if ((L1415_c_ChampionTitleFirstCharacter != ',') && (L1415_c_ChampionTitleFirstCharacter != ';') && (L1415_c_ChampionTitleFirstCharacter != '-')) { + AL1411_i_X += 6; + } + _textMan->f443_endgamePrintString(AL1411_i_X, AL1410_i_Y++, k9_ColorGold, L1416_ps_Champion->_title); + for (AL1411_i_SkillIndex = k0_ChampionSkillFighter; AL1411_i_SkillIndex <= k3_ChampionSkillWizard; AL1411_i_SkillIndex++) { + L1412_i_SkillLevel = MIN((uint16)16, _championMan->f303_getSkillLevel(AL1409_i_ChampionIndex, AL1411_i_SkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience))); + if (L1412_i_SkillLevel == 1) + continue; + strcpy(L1422_ac_String, G0428_apc_SkillLevelNames[L1412_i_SkillLevel - 2]); + strcat(L1422_ac_String, " "); + strcat(L1422_ac_String, g417_baseSkillName[AL1411_i_SkillIndex]); + _textMan->f443_endgamePrintString(105, AL1410_i_Y = AL1410_i_Y + 8, k13_ColorLightestGray, L1422_ac_String); + } + G0015_s_Graphic562_Box_Endgame_ChampionMirror._y1 += 48; + G0015_s_Graphic562_Box_Endgame_ChampionMirror._y2 += 48; + G0016_s_Graphic562_Box_Endgame_ChampionPortrait._y1 += 48; + G0016_s_Graphic562_Box_Endgame_ChampionPortrait._y1 += 48; + } + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);"); + _engineShouldQuit = true; + return; + } +T0444017: + _displayMan->fillScreen(k0_ColorBlack); + _displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k6_theEndIndice), &G0012_s_Graphic562_Box_Endgame_TheEnd, k40_byteWidth, kM1_ColorNoTransparency, 14); + for (uint16 i = 0; i < 16; ++i) + L1421_aui_Palette_DarkBlue[i] = D01_RGB_DARK_BLUE; + for (uint16 i = 0; i < 16; ++i) + L1419_aui_Palette[i] = L1421_aui_Palette_DarkBlue[i]; + L1419_aui_Palette[15] = D09_RGB_WHITE; + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(L1419_aui_Palette);"); + if (L1423_B_WaitBeforeDrawingRestart) { /* BUG0_00 Useless code */ + f22_delay(300); + } /* BUG0_00 Useless code */ + + if (_g524_restartGameAllowed) { + _displayMan->_g578_useByteBoxCoordinates = false; + _displayMan->D24_fillScreenBox(G0013_s_Graphic562_Box_Endgame_Restart_Outer, k12_ColorDarkestGray); + _displayMan->D24_fillScreenBox(G0014_s_Graphic562_Box_Endgame_Restart_Inner, k0_ColorBlack); + _textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RESTART THIS GAME"); + L1419_aui_Palette[1] = D03_RGB_PINK; + L1419_aui_Palette[4] = D09_RGB_WHITE; + _eventMan->_g441_primaryMouseInput = g446_PrimaryMouseInput_RestartGame; + _eventMan->f357_discardAllInput(); + _eventMan->f77_hideMouse(); + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette"); + for (AL1409_i_VerticalBlankCount = 900; --AL1409_i_VerticalBlankCount && !_g523_restartGameRequest; f22_delay(1)) { + _eventMan->f380_processCommandQueue(); + } + _eventMan->f78_showMouse(); + if (_g523_restartGameRequest) { + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette"); + _displayMan->fillScreen(k0_ColorBlack); + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette"); + _g298_newGame = k0_modeLoadSavedGame; + if (f435_loadgame(1) != kM1_LoadgameFailure) { + f462_startGame(); + _g523_restartGameRequest = false; + _eventMan->f77_hideMouse(); + _eventMan->f357_discardAllInput(); + return; + } + } + } + + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette"); + } + { + Box box(0, 319, 0, 199); + _displayMan->f132_blitToBitmap(_displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice), _displayMan->_g348_bitmapScreen, box, 0, 0, 160, 160, kM1_ColorNoTransparency); + } + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette"); + _eventMan->f541_waitForMouseOrKeyActivity(); + if (_engineShouldQuit) + return; + + if (_g524_restartGameAllowed && doNotDrawCreditsOnly) { + L1423_B_WaitBeforeDrawingRestart = false; + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette"); + goto T0444017; + } + + _engineShouldQuit = true; + return; +} + + void DMEngine::f439_drawEntrance() { static Box K0079_s_Box_Entrance_DoorsUpperHalf = Box(0, 231, 0, 80); static Box K0152_s_Box_Entrance_DoorsLowerHalf = Box(0, 231, 81, 160); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index e2c8923645..cb7d07f781 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -221,6 +221,7 @@ public: void f433_processCommand140_saveGame(uint16 slot, const Common::String desc); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF LoadgameResponse f435_loadgame(int16 slot); // @ F0435_STARTEND_LoadGame_CPSF void f441_processEntrance(); // @ F0441_STARTEND_ProcessEntrance + void f444_endGame(bool doNotDrawCreditsOnly); // @ F0444_STARTEND_Endgame void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode) { warning(true, "STUB: f064_SOUND_RequestPlay_CPSD"); } @@ -248,6 +249,8 @@ public: DialogMan *_dialog; + bool _engineShouldQuit; + int16 _g298_newGame; // @ G0298_B_NewGame bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 90f22054b5..2c95049044 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -599,6 +599,9 @@ Common::EventType EventManager::processInput(Common::Event *grabKey, Common::Eve f544_resetPressingEyeOrMouth(); break; } + case Common::EVENT_QUIT: + _vm->_engineShouldQuit = true; + break; default: break; } @@ -1171,6 +1174,8 @@ void EventManager::f282_commandProcessCommands160To162ClickInResurrectReincarnat if (commandType == k161_CommandClickInPanelReincarnate) { champMan.f281_renameChampion(champ); + if (_vm->_engineShouldQuit) + return; champ->resetSkillsToZero(); for (uint16 i = 0; i < 12; i++) { @@ -1209,7 +1214,7 @@ void EventManager::f378_commandProcess81ClickInPanel(int16 x, int16 y) { return; commandType = f358_getCommandTypeFromMouseInput(g456_MouseInput_PanelChest, Common::Point(x, y), k1_LeftMouseButton); if (commandType != k0_CommandNone) - _vm->_championMan->f302_processCommands28to65_clickOnSlotBox(commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand); + _vm->_championMan->f302_processCommands28to65_clickOnSlotBox(commandType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand); break; case k5_PanelContentResurrectReincarnate: if (!champMan._g415_leaderEmptyHanded) @@ -1302,8 +1307,10 @@ void EventManager::f379_drawSleepScreen() { void EventManager::f357_discardAllInput() { Common::Event event; - while (_vm->_system->getEventManager()->pollEvent(event)) - ; + while (_vm->_system->getEventManager()->pollEvent(event) && !_vm->_engineShouldQuit) { + if (event.type == Common::EVENT_QUIT) + _vm->_engineShouldQuit = true; + } _commandQueue.clear(); } @@ -1537,4 +1544,22 @@ void EventManager::f544_resetPressingEyeOrMouth() { _vm->_g334_stopPressingMouth = true; } } + +void EventManager::f541_waitForMouseOrKeyActivity() { + Common::Event event; + while (true) { + if (_vm->_system->getEventManager()->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_QUIT: + _vm->_engineShouldQuit = true; + case Common::EVENT_KEYDOWN: // Intentional fall through + case Common::EVENT_LBUTTONDOWN: + case Common::EVENT_RBUTTONDOWN: + return; + } + } + _vm->f22_delay(1); + _vm->_displayMan->updateScreen(); + } +} } // end of namespace DM diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index 3cf54785f6..d04b1c72c6 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -316,7 +316,8 @@ public: void f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY); // @ F0370_COMMAND_ProcessType100_ClickInSpellArea void f369_commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType); // @ F0369_COMMAND_ProcessTypes101To108_ClickInSpellSymbolsArea_CPSE void f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY); // @ F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE - void f544_resetPressingEyeOrMouth();// @ F0544_INPUT_ResetPressingEyeOrMouth + void f544_resetPressingEyeOrMouth(); // @ F0544_INPUT_ResetPressingEyeOrMouth + void f541_waitForMouseOrKeyActivity(); // @ F0541_INPUT_WaitForMouseOrKeyboardActivity }; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index b76792b651..6384302389 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -719,6 +719,10 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { Frame(136, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */ Frame(124, 159, 17, 102, 48, 88, 48, 0) /* Right Horizontal Closed three fourth */ ); + for (uint16 i = 0; i < 16; ++i) { + _g347_paletteTopAndBottomScreen[i] = 0; + _g346_paletteMiddleScreen[i] = 0; + } } DisplayMan::~DisplayMan() { @@ -3691,4 +3695,17 @@ void DisplayMan::f493_addDerivedBitmap(int16 derivedBitmapIndex) { warning(false, "f493_addDerivedBitmap DOES NOTHING"); } +uint16 DisplayMan::f431_getDarkenedColor(uint16 RGBcolor) { + if (getFlag(RGBcolor, D12_MASK_BLUE_COMPONENT)) { + RGBcolor--; + } + if (getFlag(RGBcolor, D11_MASK_GREEN_COMPONENT)) { + RGBcolor -= 16; + } + if (getFlag(RGBcolor, D10_MASK_RED_COMPONENT)) { + RGBcolor -= 256; + } + return RGBcolor; +} + } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 57216981c5..0d9017df69 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -207,6 +207,7 @@ enum GraphicIndice { k3_entranceRightDoorGraphicIndice = 3, // @ C003_GRAPHIC_ENTRANCE_RIGHT_DOOR k4_entranceGraphicIndice = 4, // @ C004_GRAPHIC_ENTRANCE k5_creditsGraphicIndice = 5, // @ C005_GRAPHIC_CREDITS + k6_theEndIndice = 6, // @ C006_GRAPHIC_THE_END k8_StatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION k9_MenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA @@ -266,6 +267,7 @@ enum GraphicIndice { k69_FieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R k73_FieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER k120_InscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT + k208_wallOrn_43_champMirror = 208, // @ C208_GRAPHIC_WALL_ORNAMENT_43_CHAMPION_MIRROR k241_FloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS k301_DoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED k315_firstDoorButton_GraphicIndice = 315, // @ C315_GRAPHIC_FIRST_DOOR_BUTTON @@ -304,7 +306,7 @@ public: bool isPointInside(Common::Point point) { return (_x1 <= point.x) && (point.x <= _x2) && (_y1 <= point.y) && (point.y <= _y2); // <= because incluseive boundaries } - bool isPointInside(int16 x, int16 y) { return isPointInside(Common::Point(x, y)); } + bool isPointInside(int16 x, int16 y) { return isPointInside(Common::Point(x, y)); } void setToZero() { _x1 = _x2 = _y1 = _y2 = 0; } }; // @ BOX_BYTE, BOX_WORD @@ -503,6 +505,21 @@ public: } }; // @ DOOR_FRAMES +#define D00_RGB_BLACK 0x0000 +#define D01_RGB_DARK_BLUE 0x0004 +#define D02_RGB_LIGHT_BROWN 0x0842 +#define D03_RGB_PINK 0x086F +#define D04_RGB_LIGHTER_BROWN 0x0A62 +#define D05_RGB_DARK_GOLD 0x0A82 +#define D06_RGB_GOLD 0x0CA2 +#define D07_RGB_RED 0x0F00 +#define D08_RGB_YELLOW 0x0FF4 +#define D09_RGB_WHITE 0x0FFF +#define D10_MASK_RED_COMPONENT 0x0F00 +#define D10_MASK_RED_COMPONENT 0x0F00 +#define D11_MASK_GREEN_COMPONENT 0x00F0 +#define D12_MASK_BLUE_COMPONENT 0x000F + class DisplayMan { friend class DM::TextMan; @@ -579,7 +596,9 @@ class DisplayMan { byte *_g696_bitmapWallSet_Wall_D3R2; // @ G0696_puc_Bitmap_WallSet_Wall_D3R2 byte *_g698_bitmapWallSet_Wall_D3LCR; // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR byte *_g699_bitmapWallSet_Wall_D2LCR; // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR +public: byte *_g700_bitmapWallSet_Wall_D1LCR; // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR +private: byte *_g701_bitmapWallSet_Wall_D0L; // @ G0701_puc_Bitmap_WallSet_Wall_D0L byte *_g702_bitmapWallSet_Wall_D0R; // @ G0702_puc_Bitmap_WallSet_Wall_D0R byte *_g703_bitmapWallSet_DoorFrameTop_D2LCR; // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR @@ -611,6 +630,7 @@ class DisplayMan { int16 _g694_doorNativeBitmapIndex_Front_D2LCR[2]; // @ G0694_ai_DoorNativeBitmapIndex_Front_D2LCR int16 _g695_doorNativeBitmapIndex_Front_D1LCR[2]; // @ G0695_ai_DoorNativeBitmapIndex_Front_D1LCR public: + uint16 _screenWidth; uint16 _screenHeight; byte *_g348_bitmapScreen; // @ G0348_pl_Bitmap_Screen @@ -622,6 +642,7 @@ public: bool _g342_refreshDungeonViewPaleteRequested; // @ G0342_B_RefreshDungeonViewPaletteRequested int16 _g304_dungeonViewPaletteIndex; // @ G0304_i_DungeonViewPaletteIndex uint16 _g347_paletteTopAndBottomScreen[16]; // @ G0347_aui_Palette_TopAndBottomScreen + uint16 _g346_paletteMiddleScreen[16]; // @ G0346_aui_Palette_MiddleScreen explicit DisplayMan(DMEngine *dmEngine); ~DisplayMan(); @@ -657,19 +678,19 @@ public: void f20_blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport void f21_blitToScreen(byte* bitmap, int16 *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen void f21_blitToScreen(byte* bitmap, Box *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen - - /* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which + + /* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/ /* Expects inclusive boundaries in box */ void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth, - uint16 destByteWidth, Color transparent = kM1_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit -/* Expects inclusive boundaries in box */ + uint16 destByteWidth, Color transparent = kM1_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit + /* Expects inclusive boundaries in box */ void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, - int16 firstUnitIndex, int16 destByteWidth, Color transparent, - int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap - // this function takes pixel widths + int16 firstUnitIndex, int16 destByteWidth, Color transparent, + int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap + // this function takes pixel widths void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap, int16 srcPixelWidth, int16 srcHight, int16 destPixelWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges void f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height); // @ F0130_VIDEO_FlipHorizontal @@ -695,8 +716,8 @@ public: int16 f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale); // @ F0459_START_GetScaledBitmapByteCount int16 M78_getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION void f115_cthulhu(Thing thingParam, Direction directionParam, - int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, - uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF + int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, + uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF uint16 M77_getNormalizedByteWidth(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH uint16 M23_getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET uint16 M22_getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET @@ -726,10 +747,7 @@ public: bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @ F0491_CACHE_IsDerivedBitmapInCache byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap void f493_addDerivedBitmap(int16 derivedBitmapIndex); // @ F0493_CACHE_AddDerivedBitmap - - - - + uint16 f431_getDarkenedColor(uint16 RGBcolor); }; } diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 9ecfed1f69..da59e7003f 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -44,6 +44,24 @@ Box g35_BoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food Box g36_BoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water Box g37_BoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned +// TODO: localization +char* G0428_apc_SkillLevelNames[15] = { // @ G0428_apc_SkillLevelNames + "NEOPHYTE", + "NOVICE", + "APPRENTICE", + "JOURNEYMAN", + "CRAFTSMAN", + "ARTISAN", + "ADEPT", + "EXPERT", + "` MASTER", + "a MASTER", + "b MASTER", + "c MASTER", + "d MASTER", + "e MASTER", + "ARCHMASTER"}; + InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) { _g432_inventoryChampionOrdinal = 0; _g424_panelContent = k0_PanelContentFoodWaterPoisoned; @@ -659,23 +677,6 @@ void InventoryMan::f338_decreaseTorchesLightPower() { } void InventoryMan::f351_drawChampionSkillsAndStatistics() { - // TODO: localization - static char* G0428_apc_SkillLevelNames[15] = { - "NEOPHYTE", - "NOVICE", - "APPRENTICE", - "JOURNEYMAN", - "CRAFTSMAN", - "ARTISAN", - "ADEPT", - "EXPERT", - "` MASTER", - "a MASTER", - "b MASTER", - "c MASTER", - "d MASTER", - "e MASTER", - "ARCHMASTER"}; uint16 L1090_ui_Multiple; #define AL1090_ui_SkillIndex L1090_ui_Multiple @@ -902,7 +903,9 @@ void InventoryMan::f349_processCommand70_clickOnMouth() { if (L1081_B_RemoveObjectFromLeaderHand) { for (L1086_ui_Counter = 5; --L1086_ui_Counter; _vm->f22_delay(8)) { /* Animate mouth icon */ _vm->_objectMan->f37_drawIconToScreen(k205_IconIndiceMouthOpen + !(L1086_ui_Counter & 0x0001), 56, 46); - _vm->_eventMan->processInput(); + _vm->_eventMan->f357_discardAllInput(); + if (_vm->_engineShouldQuit) + return; _vm->_displayMan->updateScreen(); } } else { diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 7617a9d77c..7a3543902a 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -47,7 +47,7 @@ enum PanelContent { k5_PanelContentResurrectReincarnate = 5 // @ C05_PANEL_RESURRECT_REINCARNATE }; - +extern char* G0428_apc_SkillLevelNames[15]; class InventoryMan { DMEngine *_vm; diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 7440653b0c..85b36911d9 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -298,7 +298,7 @@ void DMEngine::f433_processCommand140_saveGame(uint16 slot, const Common::String if (!saveAndPlayChoice) { _eventMan->f77_hideMouse(); - warning(false, "MISSING CODE: F0444_STARTEND_Endgame"); + f444_endGame(false); } if (!_championMan->_g415_leaderEmptyHanded) { _championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load += champHandObjWeight; diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index 993cc8e27f..d55ebca232 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -211,4 +211,18 @@ void TextMan::f44_messageAreaClearExpiredRows() { _g360_messageAreaRowExpirationTime[L0026_ui_RowIndex] = -1; } } + +void TextMan::f443_endgamePrintString(int16 x, int16 y, Color textColor, char* text) { + char* L1407_pc_Character; + char L1408_ac_ModifiedString[50]; + + L1407_pc_Character = L1408_ac_ModifiedString; + while (*L1407_pc_Character = *text++) { + if ((*L1407_pc_Character >= 'A') && (*L1407_pc_Character <= 'Z')) { + *L1407_pc_Character -= 64; /* Use the same font as the one used for scrolls */ + } + L1407_pc_Character++; + } + _vm->_textMan->f53_printToLogicalScreen(x, y, textColor, k12_ColorDarkestGray, L1408_ac_ModifiedString); +} } diff --git a/engines/dm/text.h b/engines/dm/text.h index e0f5e7a73c..3a41274c42 100644 --- a/engines/dm/text.h +++ b/engines/dm/text.h @@ -55,6 +55,7 @@ public: void f54_textInitialize(); // @ F0054_TEXT_Initialize void f42_messageAreaMoveCursor(int16 column, int16 row); // @ F0042_TEXT_MESSAGEAREA_MoveCursor void f44_messageAreaClearExpiredRows(); // @ F0044_TEXT_MESSAGEAREA_ClearExpiredRows + void f443_endgamePrintString(int16 x, int16 y, Color textColor, char *text); // @ F0443_STARTEND_EndgamePrintString }; diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 33a99c9b2f..e2b3f5fbc5 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -703,7 +703,7 @@ void Timeline::f248_timelineProcessEvent6_squareWall(TimelineEvent* event) { _vm->f22_delay(60 * L0638_ps_Sensor->getValue()); _vm->_g524_restartGameAllowed = false; _vm->_g302_gameWon = true; - warning(false, "MISSING CODE: F0444_STARTEND_Endgame"); + _vm->f444_endGame(true); } } } -- cgit v1.2.3 From 084b1df8f392500ce5ed5cd654e856bb391aa7da Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:50:57 +0200 Subject: DM: Refactor f281_renameChampion --- engines/dm/champion.cpp | 227 +++++++++++++++++++++++------------------------- 1 file changed, 111 insertions(+), 116 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index a2ff4393cf..c4809cb68d 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -2278,28 +2278,17 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) { void ChampionMan::f281_renameChampion(Champion* champ) { #define k1_RENAME_CHAMPION_NAME 1 #define k2_RENAME_CHAMPION_TITLE 2 - static char G0051_ac_Graphic562_UnderscoreCharacterString[2] = "_"; - static char G0052_ac_Graphic562_RenameChampionInputCharacterString[2] = " "; - static char G0053_ac_Graphic562_ReincarnateSpecialCharacters[6] = {',', '.', ';', ':', ' '}; - - uint16 L0808_ui_Multiple; -#define AL0808_ui_CharacterIndex L0808_ui_Multiple -#define AL0808_ui_ChampionIndex L0808_ui_Multiple - int16 L0809_i_RenamedChampionString; - int16 L0810_i_Character; - bool L0811_B_ChampionTitleIsFull; - char* L0812_pc_RenamedChampionString; - int16 L0813_i_X; - int16 L0814_i_Y; - Box L0815_s_Box; - int16 L0820_i_CharacterIndexBackup; - char L0821_ac_ChampionNameBackupString[8]; - - - L0815_s_Box._y1 = 3; - L0815_s_Box._y2 = 8; - L0815_s_Box._x2 = (L0815_s_Box._x1 = 3) + 167; - _vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, L0815_s_Box, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport); + static const char underscoreCharacterString[2] = "_"; + static char renameChampionInputCharacterString[2] = " "; + static const char reincarnateSpecialCharacters[6] = {',', '.', ';', ':', ' '}; + + Box displayBox; + displayBox._y1 = 3; + displayBox._y2 = 8; + displayBox._x1 = 3; + displayBox._x2 = displayBox._x1 + 167; + + _vm->_displayMan->f135_fillBoxBitmap(_vm->_displayMan->_g296_bitmapViewport, displayBox, k12_ColorDarkestGray, k112_byteWidthViewport, k136_heightViewport); _vm->_displayMan->f20_blitToViewport(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k27_PanelRenameChampionIndice), g32_BoxPanel, k72_byteWidth, k4_ColorCyan, 73); _vm->_textMan->f52_printToViewport(177, 58, k13_ColorLightestGray, "_______"); _vm->_textMan->f52_printToViewport(105, 76, k13_ColorLightestGray, "___________________"); @@ -2307,53 +2296,60 @@ void ChampionMan::f281_renameChampion(Champion* champ) { _vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView); _vm->_eventMan->f67_setMousePointerToNormal(k0_pointerArrow); _vm->_eventMan->f77_hideMouse(); - champ->_name[AL0808_ui_CharacterIndex = 0] = '\0'; + uint16 curCharacterIndex = 0; + champ->_name[curCharacterIndex] = '\0'; champ->_title[0] = '\0'; - L0809_i_RenamedChampionString = k1_RENAME_CHAMPION_NAME; - L0812_pc_RenamedChampionString = champ->_name; - L0813_i_X = 177; - L0814_i_Y = 91; + int16 renamedChampionStringMode = k1_RENAME_CHAMPION_NAME; + char *renamedChampionString = champ->_name; + int16 textPosX = 177; + int16 textPosY = 91; for (;;) { /*_Infinite loop_*/ - if (!(L0811_B_ChampionTitleIsFull = ((L0809_i_RenamedChampionString == k2_RENAME_CHAMPION_TITLE) && (AL0808_ui_CharacterIndex == 19)))) { + bool championTitleIsFull = ((renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE) && (curCharacterIndex == 19)); + if (!championTitleIsFull) { _vm->_eventMan->f78_showMouse(); - _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k9_ColorGold, k12_ColorDarkestGray, G0051_ac_Graphic562_UnderscoreCharacterString, k200_heightScreen); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k9_ColorGold, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen); _vm->_eventMan->f77_hideMouse(); } - L0810_i_Character = 256; - while (L0810_i_Character == 256) { + + int16 curCharacter = 256; + while (curCharacter == 256) { Common::Event event; - Common::EventType eventType; - { - eventType = _vm->_eventMan->processInput(&event, &event); - if (_vm->_engineShouldQuit) - return; - _vm->_displayMan->updateScreen(); - //_vm->f22_delay(1); - } + Common::EventType eventType = _vm->_eventMan->processInput(&event, &event); + _vm->_displayMan->updateScreen(); + _vm->f22_delay(1); + if (eventType == Common::EVENT_LBUTTONDOWN) { /* If left mouse button status has changed */ Common::Point mousePos = _vm->_eventMan->getMousePos(); - if ((L0809_i_RenamedChampionString == k2_RENAME_CHAMPION_TITLE || (AL0808_ui_CharacterIndex > 0)) && (mousePos.x >= 197) && (mousePos.x <= 215) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'OK' button */ - L0820_i_CharacterIndexBackup = AL0808_ui_CharacterIndex; - strcpy(L0821_ac_ChampionNameBackupString, L0812_pc_RenamedChampionString = champ->_name); - AL0808_ui_CharacterIndex = strlen(L0812_pc_RenamedChampionString); - while (L0812_pc_RenamedChampionString[--AL0808_ui_CharacterIndex] == ' ') { /* Replace space characters on the right of the champion name by '\0' characters */ - L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex] = '\0'; - } - for (AL0808_ui_ChampionIndex = k0_ChampionFirst; AL0808_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount - 1; AL0808_ui_ChampionIndex++) { - if (!strcmp(_vm->_championMan->_gK71_champions[AL0808_ui_ChampionIndex]._name, L0812_pc_RenamedChampionString)) /* If an existing champion already has the specified name for the new champion */ - goto T0281011_ContinueRename; + if ((renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE || (curCharacterIndex > 0)) && (mousePos.x >= 197) && (mousePos.x <= 215) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'OK' button */ + int16 characterIndexBackup = curCharacterIndex; + char L0821_ac_ChampionNameBackupString[8]; + renamedChampionString = champ->_name; + strcpy(L0821_ac_ChampionNameBackupString, renamedChampionString); + curCharacterIndex = strlen(renamedChampionString); + while (renamedChampionString[--curCharacterIndex] == ' ') + // Replace space characters on the right of the champion name by '\0' characters + renamedChampionString[curCharacterIndex] = '\0'; + + bool found = false; + for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_g305_partyChampionCount - 1; idx++) { + if (!strcmp(_vm->_championMan->_gK71_champions[idx]._name, renamedChampionString)) { + // If an existing champion already has the specified name for the new champion + found = true; + break; + } } - return; -T0281011_ContinueRename: - if (L0809_i_RenamedChampionString == k2_RENAME_CHAMPION_TITLE) { - L0812_pc_RenamedChampionString = champ->_title; - } - strcpy(L0812_pc_RenamedChampionString = champ->_name, L0821_ac_ChampionNameBackupString); - AL0808_ui_CharacterIndex = L0820_i_CharacterIndexBackup; + if (!found) + return; + + if (renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE) + renamedChampionString = champ->_title; + + strcpy(renamedChampionString = champ->_name, L0821_ac_ChampionNameBackupString); + curCharacterIndex = characterIndexBackup; } else { if ((mousePos.x >= 107) && (mousePos.x <= 175) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'BACKSPACE' button */ - L0810_i_Character = '\b'; + curCharacter = '\b'; break; } if ((mousePos.x < 107) || (mousePos.x > 215) || (mousePos.y < 116) || (mousePos.y > 144)) {/* Coordinates of table of all other characters */ @@ -2362,77 +2358,76 @@ T0281011_ContinueRename: if (!((mousePos.x + 4) % 10) || (!((mousePos.y + 5) % 10) && ((mousePos.x < 207) || (mousePos.y != 135)))) { //goto T0281023; } - L0810_i_Character = 'A' + (11 * ((mousePos.y - 116) / 10)) + ((mousePos.x - 107) / 10); - if ((L0810_i_Character == 86) || (L0810_i_Character == 97)) { /* The 'Return' button occupies two cells in the table */ - L0810_i_Character = '\r'; /* Carriage return */ + curCharacter = 'A' + (11 * ((mousePos.y - 116) / 10)) + ((mousePos.x - 107) / 10); + if ((curCharacter == 86) || (curCharacter == 97)) { /* The 'Return' button occupies two cells in the table */ + curCharacter = '\r'; /* Carriage return */ break; } - if (L0810_i_Character >= 87) { /* Compensate for the first cell occupied by 'Return' button */ - L0810_i_Character--; - } - if (L0810_i_Character > 'Z') { - L0810_i_Character = G0053_ac_Graphic562_ReincarnateSpecialCharacters[(L0810_i_Character - 'Z') - 1]; - } + if (curCharacter >= 87) // Compensate for the first cell occupied by 'Return' button + curCharacter--; + + if (curCharacter > 'Z') + curCharacter = reincarnateSpecialCharacters[(curCharacter - 'Z') - 1]; + break; } - } else if (eventType == Common::EVENT_KEYDOWN) { - L0810_i_Character = event.kbd.ascii; - } + } else if (eventType == Common::EVENT_KEYDOWN) + curCharacter = event.kbd.ascii; } - if ((L0810_i_Character >= 'a') && (L0810_i_Character <= 'z')) { - L0810_i_Character -= 32; /* Convert to uppercase */ - } - if (((L0810_i_Character >= 'A') && (L0810_i_Character <= 'Z')) || (L0810_i_Character == '.') || (L0810_i_Character == ',') || (L0810_i_Character == ';') || (L0810_i_Character == ':') || (L0810_i_Character == ' ')) { - if ((L0810_i_Character == ' ') && AL0808_ui_CharacterIndex == 0) { - } else { - if (!L0811_B_ChampionTitleIsFull) { - G0052_ac_Graphic562_RenameChampionInputCharacterString[0] = L0810_i_Character; + if ((curCharacter >= 'a') && (curCharacter <= 'z')) + curCharacter -= 32; // Convert to uppercase + + if (((curCharacter >= 'A') && (curCharacter <= 'Z')) || (curCharacter == '.') || (curCharacter == ',') || (curCharacter == ';') || (curCharacter == ':') || (curCharacter == ' ')) { + if ((curCharacter != ' ') || curCharacterIndex != 0) { + if (!championTitleIsFull) { + renameChampionInputCharacterString[0] = curCharacter; _vm->_eventMan->f78_showMouse(); - _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k13_ColorLightestGray, k12_ColorDarkestGray, G0052_ac_Graphic562_RenameChampionInputCharacterString, k200_heightScreen); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, renameChampionInputCharacterString, k200_heightScreen); _vm->_eventMan->f77_hideMouse(); - L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex++] = L0810_i_Character; - L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex] = '\0'; - L0813_i_X += 6; - if ((L0809_i_RenamedChampionString == k1_RENAME_CHAMPION_NAME) && (AL0808_ui_CharacterIndex == 7)) - goto T0281033_ProceedToTitle; + renamedChampionString[curCharacterIndex++] = curCharacter; + renamedChampionString[curCharacterIndex] = '\0'; + textPosX += 6; + if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex == 7)) { + renamedChampionStringMode = k2_RENAME_CHAMPION_TITLE; + renamedChampionString = champ->_title; + textPosX = 105; + textPosY = 109; + curCharacterIndex = 0; + } } } - } else { - if (L0810_i_Character == '\r') { /* Carriage return */ - if ((L0809_i_RenamedChampionString == k1_RENAME_CHAMPION_NAME) && (AL0808_ui_CharacterIndex > 0)) { - _vm->_eventMan->f78_showMouse(); - _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k13_ColorLightestGray, k12_ColorDarkestGray, G0051_ac_Graphic562_UnderscoreCharacterString, k200_heightScreen); - _vm->_eventMan->f77_hideMouse(); -T0281033_ProceedToTitle: - L0809_i_RenamedChampionString = k2_RENAME_CHAMPION_TITLE; - L0812_pc_RenamedChampionString = champ->_title; - L0813_i_X = 105; - L0814_i_Y = 109; - AL0808_ui_CharacterIndex = 0; - } + } else if (curCharacter == '\r') { /* Carriage return */ + if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex > 0)) { + _vm->_eventMan->f78_showMouse(); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen); + _vm->_eventMan->f77_hideMouse(); + renamedChampionStringMode = k2_RENAME_CHAMPION_TITLE; + renamedChampionString = champ->_title; + textPosX = 105; + textPosY = 109; + curCharacterIndex = 0; + } + } else if (curCharacter == '\b') { /* Backspace */ + if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex == 0)) + continue; + + if (!championTitleIsFull) { + _vm->_eventMan->f78_showMouse(); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen); + _vm->_eventMan->f77_hideMouse(); + } + if (curCharacterIndex == 0) { + renamedChampionString = champ->_name; + curCharacterIndex = strlen(renamedChampionString) - 1; + renamedChampionStringMode = k1_RENAME_CHAMPION_NAME; + textPosX = 177 + (curCharacterIndex * 6); + textPosY = 91; } else { - if (L0810_i_Character == '\b') { /* Backspace */ - if ((L0809_i_RenamedChampionString == k1_RENAME_CHAMPION_NAME) && (AL0808_ui_CharacterIndex == 0)) - continue; - if (!L0811_B_ChampionTitleIsFull) { - _vm->_eventMan->f78_showMouse(); - _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, L0813_i_X, L0814_i_Y, k13_ColorLightestGray, k12_ColorDarkestGray, G0051_ac_Graphic562_UnderscoreCharacterString, k200_heightScreen); - _vm->_eventMan->f77_hideMouse(); - } - if (AL0808_ui_CharacterIndex == 0) { - L0812_pc_RenamedChampionString = champ->_name; - AL0808_ui_CharacterIndex = strlen(L0812_pc_RenamedChampionString) - 1; - L0809_i_RenamedChampionString = k1_RENAME_CHAMPION_NAME; - L0813_i_X = 177 + (AL0808_ui_CharacterIndex * 6); - L0814_i_Y = 91; - } else { - AL0808_ui_CharacterIndex--; - L0813_i_X -= 6; - } - L0812_pc_RenamedChampionString[AL0808_ui_CharacterIndex] = '\0'; - } + curCharacterIndex--; + textPosX -= 6; } + renamedChampionString[curCharacterIndex] = '\0'; } } } -- cgit v1.2.3 From b87d7620870c80b93bb13779bfa78a02d5359384 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 29 Jul 2016 18:08:27 +0200 Subject: DM: Fix compilation using MSVC9 --- engines/dm/menus.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 513b8fb0f0..b6db53d6a6 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -1668,8 +1668,8 @@ int16 MenuMan::f382_getActionObjectChargeCount() { } void MenuMan::f385_drawActionDamage(int16 damage) { - static Box G0502_s_Graphic560_Box_ActionAreaMediumDamage = {242, 305, 81, 117}; - static Box G0503_s_Graphic560_Box_ActionAreaSmallDamage = {251, 292, 81, 117}; + static const Box G0502_s_Graphic560_Box_ActionAreaMediumDamage = Box(242, 305, 81, 117); + static const Box G0503_s_Graphic560_Box_ActionAreaSmallDamage = Box(251, 292, 81, 117); uint16 L1174_ui_Multiple; #define AL1174_ui_DerivedBitmapIndex L1174_ui_Multiple @@ -1683,7 +1683,7 @@ void MenuMan::f385_drawActionDamage(int16 damage) { #define AL1178_puc_String L1178_puc_Multiple #define AL1178_puc_Bitmap L1178_puc_Multiple char L1179_ac_String[6]; - Box* L1180_ps_Box; + const Box* L1180_ps_Box; int16 L1643_i_Width; _vm->_eventMan->f78_showMouse(); @@ -1725,7 +1725,7 @@ void MenuMan::f385_drawActionDamage(int16 damage) { L1177_puc_Bitmap = _vm->_displayMan->f492_getDerivedBitmap(AL1174_ui_DerivedBitmapIndex); } } - _vm->_displayMan->f21_blitToScreen(L1177_puc_Bitmap, L1180_ps_Box, L1175_i_ByteWidth, kM1_ColorNoTransparency, L1643_i_Width); + _vm->_displayMan->f21_blitToScreen(L1177_puc_Bitmap, (int16 *)L1180_ps_Box, L1175_i_ByteWidth, kM1_ColorNoTransparency, L1643_i_Width); /* Convert damage value to string */ AL1174_ui_CharacterIndex = 5; AL1176_i_X = 274; -- cgit v1.2.3 From a80ae5537962d6e34fb263e619bd93fbf037d193 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 29 Jul 2016 18:09:19 +0200 Subject: DM: some minor changes in f291_drawSlot and f281_renameChampion --- engines/dm/champion.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index c4809cb68d..f79c60c01e 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -2204,7 +2204,8 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) { bool isInventoryChamp = (_vm->_inventoryMan->_g432_inventoryChampionOrdinal == _vm->M0_indexToOrdinal(champIndex)); uint16 slotBoxIndex; - if (!isInventoryChamp) { /* If drawing a slot for a champion other than the champion whose inventory is open */ + if (!isInventoryChamp) { + // If drawing a slot for a champion other than the champion whose inventory is open if ((slotIndex > k1_ChampionSlotActionHand) || (_g299_candidateChampionOrdinal == _vm->M0_indexToOrdinal(champIndex))) return; slotBoxIndex = (champIndex << 1) + slotIndex; @@ -2260,13 +2261,12 @@ void ChampionMan::f291_drawSlot(uint16 champIndex, int16 slotIndex) { if (nativeBitmapIndex != -1) { _vm->_displayMan->_g578_useByteBoxCoordinates = false; - if (isInventoryChamp) { + if (isInventoryChamp) _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport, k12_ColorDarkestGray); - } else { + else _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), _vm->_displayMan->_g348_bitmapScreen, box, 0, 0, 16, k160_byteWidthScreen, k12_ColorDarkestGray); - } } _vm->_objectMan->f38_drawIconInSlotBox(slotBoxIndex, iconIndex); @@ -2319,7 +2319,8 @@ void ChampionMan::f281_renameChampion(Champion* champ) { _vm->_displayMan->updateScreen(); _vm->f22_delay(1); - if (eventType == Common::EVENT_LBUTTONDOWN) { /* If left mouse button status has changed */ + if (eventType == Common::EVENT_LBUTTONDOWN) { + // If left mouse button status has changed Common::Point mousePos = _vm->_eventMan->getMousePos(); if ((renamedChampionStringMode == k2_RENAME_CHAMPION_TITLE || (curCharacterIndex > 0)) && (mousePos.x >= 197) && (mousePos.x <= 215) && (mousePos.y >= 147) && (mousePos.y <= 155)) { /* Coordinates of 'OK' button */ int16 characterIndexBackup = curCharacterIndex; @@ -2327,14 +2328,14 @@ void ChampionMan::f281_renameChampion(Champion* champ) { renamedChampionString = champ->_name; strcpy(L0821_ac_ChampionNameBackupString, renamedChampionString); curCharacterIndex = strlen(renamedChampionString); - while (renamedChampionString[--curCharacterIndex] == ' ') // Replace space characters on the right of the champion name by '\0' characters + while (renamedChampionString[--curCharacterIndex] == ' ') renamedChampionString[curCharacterIndex] = '\0'; bool found = false; for (uint16 idx = k0_ChampionFirst; idx < _vm->_championMan->_g305_partyChampionCount - 1; idx++) { if (!strcmp(_vm->_championMan->_gK71_champions[idx]._name, renamedChampionString)) { - // If an existing champion already has the specified name for the new champion + // If an existing champion already has the specified name for the new champion found = true; break; } @@ -2352,18 +2353,23 @@ void ChampionMan::f281_renameChampion(Champion* champ) { curCharacter = '\b'; break; } +#if 0 if ((mousePos.x < 107) || (mousePos.x > 215) || (mousePos.y < 116) || (mousePos.y > 144)) {/* Coordinates of table of all other characters */ //goto T0281023; } if (!((mousePos.x + 4) % 10) || (!((mousePos.y + 5) % 10) && ((mousePos.x < 207) || (mousePos.y != 135)))) { //goto T0281023; } +#endif curCharacter = 'A' + (11 * ((mousePos.y - 116) / 10)) + ((mousePos.x - 107) / 10); - if ((curCharacter == 86) || (curCharacter == 97)) { /* The 'Return' button occupies two cells in the table */ + if ((curCharacter == 86) || (curCharacter == 97)) { + // The 'Return' button occupies two cells in the table curCharacter = '\r'; /* Carriage return */ break; } - if (curCharacter >= 87) // Compensate for the first cell occupied by 'Return' button + + if (curCharacter >= 87) + // Compensate for the first cell occupied by 'Return' button curCharacter--; if (curCharacter > 'Z') @@ -2397,7 +2403,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) { } } } - } else if (curCharacter == '\r') { /* Carriage return */ + } else if (curCharacter == '\r') { // Carriage return if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex > 0)) { _vm->_eventMan->f78_showMouse(); _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, k160_byteWidthScreen, textPosX, textPosY, k13_ColorLightestGray, k12_ColorDarkestGray, underscoreCharacterString, k200_heightScreen); @@ -2408,7 +2414,7 @@ void ChampionMan::f281_renameChampion(Champion* champ) { textPosY = 109; curCharacterIndex = 0; } - } else if (curCharacter == '\b') { /* Backspace */ + } else if (curCharacter == '\b') { // Backspace if ((renamedChampionStringMode == k1_RENAME_CHAMPION_NAME) && (curCharacterIndex == 0)) continue; @@ -2445,13 +2451,14 @@ uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) { if (!ignoreTmpExp) exp += skill->_temporaryExperience; - if (skillIndex > k3_ChampionSkillWizard) { /* Hidden skill */ + if (skillIndex > k3_ChampionSkillWizard) { + // Hidden skill skill = &champ->_skills[(skillIndex - k4_ChampionSkillSwing) >> 2]; - exp += skill->_experience; /* Add experience in the base skill */ + exp += skill->_experience; // Add experience in the base skill if (!ignoreTmpExp) exp += skill->_temporaryExperience; - exp >>= 1; /* Halve experience to get average of base skill + hidden skill experience */ + exp >>= 1; // Halve experience to get average of base skill + hidden skill experience } int16 skillLevel = 1; while (exp >= 500) { @@ -2492,5 +2499,3 @@ uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) { } } - - -- cgit v1.2.3 From f52469ce05ea962b16a9f9b01e34966e49e4bb1c Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Fri, 26 Aug 2016 22:51:02 +0200 Subject: DM: Add a stub for f436_STARTEND_FadeToPalette --- engines/dm/gfx.cpp | 51 +++++++++++++++++++-------------------------------- engines/dm/gfx.h | 47 ++++++++++++++--------------------------------- 2 files changed, 33 insertions(+), 65 deletions(-) diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 6384302389..8ca6caf151 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -155,11 +155,12 @@ Box g2_BoxMovementArrows = Box(224, 319, 124, 168); // @ G0002_s_Graphic562_Box_ byte g212_PalChangeSmoke[16] = {0, 10, 20, 30, 40, 50, 120, 10, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0212_auc_Graphic558_PaletteChanges_Smoke ExplosionAspect g211_ExplosionAspects[k4_ExplosionAspectCount] = { // @ G0211_as_Graphic558_ExplosionAspects - /* { ByteWidth, Height } */ - ExplosionAspect(80, 111), /* Fire */ -ExplosionAspect(64, 97), /* Spell */ -ExplosionAspect(80, 91), /* Poison */ -ExplosionAspect(80, 91)}; /* Death */ + // ByteWidth, Height + ExplosionAspect(80, 111), // Fire + ExplosionAspect(64, 97), // Spell + ExplosionAspect(80, 91), // Poison + ExplosionAspect(80, 91) // Death +}; #define k730_DerivedBitmapMaximumCount 730 // @ C730_DERIVED_BITMAP_MAXIMUM_COUNT @@ -708,21 +709,20 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { g186_doorFrame_D1C = new DoorFrames( // @ G0186_s_Graphic558_Frames_Door_D1C /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ - Frame(64, 159, 17, 102, 48, 88, 0, 0), /* Closed Or Destroyed */ - Frame(64, 159, 17, 38, 48, 88, 0, 66), /* Vertical Closed one fourth */ - Frame(64, 159, 17, 60, 48, 88, 0, 44), /* Vertical Closed half */ - Frame(64, 159, 17, 82, 48, 88, 0, 22), /* Vertical Closed three fourth */ - Frame(64, 75, 17, 102, 48, 88, 36, 0), /* Left Horizontal Closed one fourth */ - Frame(64, 87, 17, 102, 48, 88, 24, 0), /* Left Horizontal Closed half */ - Frame(64, 99, 17, 102, 48, 88, 12, 0), /* Left Horizontal Closed three fourth */ - Frame(148, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */ - Frame(136, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */ - Frame(124, 159, 17, 102, 48, 88, 48, 0) /* Right Horizontal Closed three fourth */ + Frame(64, 159, 17, 102, 48, 88, 0, 0), /* Closed Or Destroyed */ + Frame(64, 159, 17, 38, 48, 88, 0, 66), /* Vertical Closed one fourth */ + Frame(64, 159, 17, 60, 48, 88, 0, 44), /* Vertical Closed half */ + Frame(64, 159, 17, 82, 48, 88, 0, 22), /* Vertical Closed three fourth */ + Frame(64, 75, 17, 102, 48, 88, 36, 0), /* Left Horizontal Closed one fourth */ + Frame(64, 87, 17, 102, 48, 88, 24, 0), /* Left Horizontal Closed half */ + Frame(64, 99, 17, 102, 48, 88, 12, 0), /* Left Horizontal Closed three fourth */ + Frame(148, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed one fourth */ + Frame(136, 159, 17, 102, 48, 88, 48, 0), /* Right Horizontal Closed half */ + Frame(124, 159, 17, 102, 48, 88, 48, 0) /* Right Horizontal Closed three fourth */ ); - for (uint16 i = 0; i < 16; ++i) { - _g347_paletteTopAndBottomScreen[i] = 0; - _g346_paletteMiddleScreen[i] = 0; - } + + for (uint16 i = 0; i < 32; i++) + _g345_aui_BlankBuffer[i] = 0; } DisplayMan::~DisplayMan() { @@ -3695,17 +3695,4 @@ void DisplayMan::f493_addDerivedBitmap(int16 derivedBitmapIndex) { warning(false, "f493_addDerivedBitmap DOES NOTHING"); } -uint16 DisplayMan::f431_getDarkenedColor(uint16 RGBcolor) { - if (getFlag(RGBcolor, D12_MASK_BLUE_COMPONENT)) { - RGBcolor--; - } - if (getFlag(RGBcolor, D11_MASK_GREEN_COMPONENT)) { - RGBcolor -= 16; - } - if (getFlag(RGBcolor, D10_MASK_RED_COMPONENT)) { - RGBcolor -= 256; - } - return RGBcolor; -} - } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 0d9017df69..dfd458ef80 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -207,7 +207,6 @@ enum GraphicIndice { k3_entranceRightDoorGraphicIndice = 3, // @ C003_GRAPHIC_ENTRANCE_RIGHT_DOOR k4_entranceGraphicIndice = 4, // @ C004_GRAPHIC_ENTRANCE k5_creditsGraphicIndice = 5, // @ C005_GRAPHIC_CREDITS - k6_theEndIndice = 6, // @ C006_GRAPHIC_THE_END k8_StatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION k9_MenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA @@ -267,7 +266,6 @@ enum GraphicIndice { k69_FieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R k73_FieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER k120_InscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT - k208_wallOrn_43_champMirror = 208, // @ C208_GRAPHIC_WALL_ORNAMENT_43_CHAMPION_MIRROR k241_FloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS k301_DoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED k315_firstDoorButton_GraphicIndice = 315, // @ C315_GRAPHIC_FIRST_DOOR_BUTTON @@ -306,7 +304,7 @@ public: bool isPointInside(Common::Point point) { return (_x1 <= point.x) && (point.x <= _x2) && (_y1 <= point.y) && (point.y <= _y2); // <= because incluseive boundaries } - bool isPointInside(int16 x, int16 y) { return isPointInside(Common::Point(x, y)); } + bool isPointInside(int16 x, int16 y) { return isPointInside(Common::Point(x, y)); } void setToZero() { _x1 = _x2 = _y1 = _y2 = 0; } }; // @ BOX_BYTE, BOX_WORD @@ -505,21 +503,6 @@ public: } }; // @ DOOR_FRAMES -#define D00_RGB_BLACK 0x0000 -#define D01_RGB_DARK_BLUE 0x0004 -#define D02_RGB_LIGHT_BROWN 0x0842 -#define D03_RGB_PINK 0x086F -#define D04_RGB_LIGHTER_BROWN 0x0A62 -#define D05_RGB_DARK_GOLD 0x0A82 -#define D06_RGB_GOLD 0x0CA2 -#define D07_RGB_RED 0x0F00 -#define D08_RGB_YELLOW 0x0FF4 -#define D09_RGB_WHITE 0x0FFF -#define D10_MASK_RED_COMPONENT 0x0F00 -#define D10_MASK_RED_COMPONENT 0x0F00 -#define D11_MASK_GREEN_COMPONENT 0x00F0 -#define D12_MASK_BLUE_COMPONENT 0x000F - class DisplayMan { friend class DM::TextMan; @@ -596,9 +579,7 @@ class DisplayMan { byte *_g696_bitmapWallSet_Wall_D3R2; // @ G0696_puc_Bitmap_WallSet_Wall_D3R2 byte *_g698_bitmapWallSet_Wall_D3LCR; // @ G0698_puc_Bitmap_WallSet_Wall_D3LCR byte *_g699_bitmapWallSet_Wall_D2LCR; // @ G0699_puc_Bitmap_WallSet_Wall_D2LCR -public: byte *_g700_bitmapWallSet_Wall_D1LCR; // @ G0700_puc_Bitmap_WallSet_Wall_D1LCR -private: byte *_g701_bitmapWallSet_Wall_D0L; // @ G0701_puc_Bitmap_WallSet_Wall_D0L byte *_g702_bitmapWallSet_Wall_D0R; // @ G0702_puc_Bitmap_WallSet_Wall_D0R byte *_g703_bitmapWallSet_DoorFrameTop_D2LCR; // @ G0703_puc_Bitmap_WallSet_DoorFrameTop_D2LCR @@ -630,7 +611,6 @@ private: int16 _g694_doorNativeBitmapIndex_Front_D2LCR[2]; // @ G0694_ai_DoorNativeBitmapIndex_Front_D2LCR int16 _g695_doorNativeBitmapIndex_Front_D1LCR[2]; // @ G0695_ai_DoorNativeBitmapIndex_Front_D1LCR public: - uint16 _screenWidth; uint16 _screenHeight; byte *_g348_bitmapScreen; // @ G0348_pl_Bitmap_Screen @@ -641,8 +621,8 @@ public: bool _g322_paletteSwitchingEnabled; // @ G0322_B_PaletteSwitchingEnabled bool _g342_refreshDungeonViewPaleteRequested; // @ G0342_B_RefreshDungeonViewPaletteRequested int16 _g304_dungeonViewPaletteIndex; // @ G0304_i_DungeonViewPaletteIndex + uint16 _g345_aui_BlankBuffer[32]; // @G0345_aui_BlankBuffer uint16 _g347_paletteTopAndBottomScreen[16]; // @ G0347_aui_Palette_TopAndBottomScreen - uint16 _g346_paletteMiddleScreen[16]; // @ G0346_aui_Palette_MiddleScreen explicit DisplayMan(DMEngine *dmEngine); ~DisplayMan(); @@ -666,7 +646,6 @@ public: /// Gives the height of an IMG1 type item uint16 getPixelHeight(uint16 index); - void f99_copyBitmapAndFlipHorizontal(byte *srcBitmap, byte *destBitmap, uint16 byteWidth, uint16 height); // @ F0099_DUNGEONVIEW_CopyBitmapAndFlipHorizontal void f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloorIndex); // @ F0108_DUNGEONVIEW_DrawFloorOrnament void f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16 *doorNativeBitmapIndices, int16 byteCount, @@ -678,19 +657,19 @@ public: void f20_blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport void f21_blitToScreen(byte* bitmap, int16 *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen void f21_blitToScreen(byte* bitmap, Box *box, int16 viewDoorOrnIndex, Color transparent, int16 doorOrnOrdinal); // @ F0021_MAIN_BlitToScreen + - - /* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which + /* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters match the original exatcly, if need arises for heights then we'll have to retrospectively add them in old function calls*/ /* Expects inclusive boundaries in box */ void f132_blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth, - uint16 destByteWidth, Color transparent = kM1_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit - /* Expects inclusive boundaries in box */ + uint16 destByteWidth, Color transparent = kM1_ColorNoTransparency, int16 srcHeight = -1, int16 destHight = -1); // @ F0132_VIDEO_Blit +/* Expects inclusive boundaries in box */ void f133_blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex, - int16 firstUnitIndex, int16 destByteWidth, Color transparent, - int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap - // this function takes pixel widths + int16 firstUnitIndex, int16 destByteWidth, Color transparent, + int16 xPos, int16 yPos, int16 destHeight, int16 height2); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap + // this function takes pixel widths void f129_blitToBitmapShrinkWithPalChange(byte *srcBitmap, byte *destBitmap, int16 srcPixelWidth, int16 srcHight, int16 destPixelWidth, int16 destHeight, byte *palChange); // @ F0129_VIDEO_BlitShrinkWithPaletteChanges void f130_flipBitmapHorizontal(byte *bitmap, uint16 byteWidth, uint16 height); // @ F0130_VIDEO_FlipHorizontal @@ -716,8 +695,8 @@ public: int16 f459_getScaledBitmapByteCount(int16 byteWidth, int16 height, int16 scale); // @ F0459_START_GetScaledBitmapByteCount int16 M78_getScaledDimension(int16 dimension, int16 scale); // @ M78_SCALED_DIMENSION void f115_cthulhu(Thing thingParam, Direction directionParam, - int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, - uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF + int16 mapXpos, int16 mapYpos, int16 viewSquareIndex, + uint16 orderedViewCellOrdinals); // @ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF uint16 M77_getNormalizedByteWidth(uint16 byteWidth); // @ M77_NORMALIZED_BYTE_WIDTH uint16 M23_getVerticalOffsetM23(uint16 val); // @ M23_VERTICAL_OFFSET uint16 M22_getHorizontalOffsetM22(uint16 val); // @ M22_HORIZONTAL_OFFSET @@ -747,7 +726,9 @@ public: bool f491_isDerivedBitmapInCache(int16 derivedBitmapIndex); // @ F0491_CACHE_IsDerivedBitmapInCache byte *f492_getDerivedBitmap(int16 derivedBitmapIndex); // @ F0492_CACHE_GetDerivedBitmap void f493_addDerivedBitmap(int16 derivedBitmapIndex); // @ F0493_CACHE_AddDerivedBitmap - uint16 f431_getDarkenedColor(uint16 RGBcolor); + + void f436_STARTEND_FadeToPalette(uint16 *P0849_pui_Palette) { warning(false, "STUB: f436_STARTEND_FadeToPalette"); } + }; } -- cgit v1.2.3 From e29d843cfae8f399800c4c077e10976da9e26c57 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 29 Jul 2016 19:08:00 +0200 Subject: DM: Refactor f427_dialogDraw --- engines/dm/dialog.cpp | 154 ++++++++++++++++++++++++-------------------------- engines/dm/gfx.h | 2 +- 2 files changed, 75 insertions(+), 81 deletions(-) diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp index 71ff8dcf93..6a99ee5505 100644 --- a/engines/dm/dialog.cpp +++ b/engines/dm/dialog.cpp @@ -36,110 +36,104 @@ namespace DM { DialogMan::DialogMan(DMEngine* vm) : _vm(vm) {} void DialogMan::f427_dialogDraw(char* msg1, char* msg2, char* choice1, char* choice2, char* choice3, char* choice4, bool screenDialog, bool clearScreen, bool fading) { - static Box K0068_s_Box1 = Box(0, 223, 101, 125); - static Box K0069_s_Box2 = Box(0, 223, 76, 100); - static Box K0070_s_Box3 = Box(0, 223, 51, 75); - static Box G0469_s_Graphic561_Box_Dialog2ChoicesPatch = Box(102, 122, 89, 125); - static Box G0470_s_Graphic561_Box_Dialog4ChoicesPatch = Box(102, 122, 62, 97); - - int16 L1308_i_X; - int16 L1309_i_Y; - int16 L1310_i_ChoiceCount; - char L1312_ac_StringPart1[70]; - char L1313_ac_StringPart2[70]; - Box L1314_s_Box; - + static Box constBox1 = Box(0, 223, 101, 125); + static Box constBox2 = Box(0, 223, 76, 100); + static Box constBox3 = Box(0, 223, 51, 75); + static Box dialog2ChoicesPatch = Box(102, 122, 89, 125); + static Box dialog4ChoicesPatch = Box(102, 122, 62, 97); _vm->_displayMan->f466_loadIntoBitmap(k0_dialogBoxGraphicIndice, _vm->_displayMan->_g296_bitmapViewport); //Strangerke: the version should be replaced by a ScummVM/RogueVM (?) string // TODO: replace with ScummVM version string _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 192, 7, k2_ColorLightGray, k1_ColorDarkGary, "V2.2", k136_heightViewport); - L1310_i_ChoiceCount = 1; - if (choice2 != nullptr) { - L1310_i_ChoiceCount++; - } - if (choice3 != nullptr) { - L1310_i_ChoiceCount++; - } - if (choice4 != nullptr) { - L1310_i_ChoiceCount++; - } - if (fading) { - warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette in f427_dialogDraw"); - } - if (clearScreen) { + int16 choiceCount = 1; + if (choice2) + choiceCount++; + + if (choice3) + choiceCount++; + + if (choice4) + choiceCount++; + + if (fading) + _vm->_displayMan->f436_STARTEND_FadeToPalette(_vm->_displayMan->_g345_aui_BlankBuffer); + + if (clearScreen) _vm->_displayMan->fillScreen(k0_ColorBlack); - } + _vm->_displayMan->_g578_useByteBoxCoordinates = false; - if (L1310_i_ChoiceCount == 1) { - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, K0068_s_Box1, 0, 64, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, K0069_s_Box2, 0, 39, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, K0070_s_Box3, 0, 14, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); + if (choiceCount == 1) { + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, constBox1, 0, 64, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, constBox2, 0, 39, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, constBox3, 0, 14, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 114); - } else { - if (L1310_i_ChoiceCount == 2) { - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, G0469_s_Graphic561_Box_Dialog2ChoicesPatch, 102, 52, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); - f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77); - f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 112, 114); - } else { - if (L1310_i_ChoiceCount == 3) { - f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77); - f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 59, 114); - f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 166, 114); - } else { - if (L1310_i_ChoiceCount == 4) { - _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, G0470_s_Graphic561_Box_Dialog4ChoicesPatch, 102, 99, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); - f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 59, 77); - f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 166, 77); - f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 59, 114); - f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice4, 166, 114); - } - } - } + } else if (choiceCount == 2) { + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, dialog2ChoicesPatch, 102, 52, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 112, 114); + } else if (choiceCount == 3) { + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 112, 77); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 59, 114); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 166, 114); + } else if (choiceCount == 4) { + _vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->_g296_bitmapViewport, _vm->_displayMan->_g296_bitmapViewport, dialog4ChoicesPatch, 102, 99, k112_byteWidthViewport, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport, k136_heightViewport); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice1, 59, 77); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice2, 166, 77); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice3, 59, 114); + f425_printCenteredChoice(_vm->_displayMan->_g296_bitmapViewport, choice4, 166, 114); } - L1309_i_Y = 29; - if (msg1 != nullptr) { + + int16 textPosX; + int16 textPosY = 29; + if (msg1) { + char L1312_ac_StringPart1[70]; + char L1313_ac_StringPart2[70]; if (f426_isMessageOnTwoLines(msg1, L1312_ac_StringPart1, L1313_ac_StringPart2)) { - L1309_i_Y = 21; - L1308_i_X = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1); - _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k11_ColorYellow, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport); - L1309_i_Y += 8; - L1308_i_X = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1); - _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k11_ColorYellow, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport); - L1309_i_Y += 8; + textPosY = 21; + textPosX = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport); + textPosY += 8; + textPosX = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport); + textPosY += 8; } else { - L1308_i_X = 113 - ((strlen(msg1) * 6) >> 1); - _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k11_ColorYellow, k5_ColorLightBrown, msg1, k136_heightViewport); - L1309_i_Y += 8; + textPosX = 113 - ((strlen(msg1) * 6) >> 1); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k11_ColorYellow, k5_ColorLightBrown, msg1, k136_heightViewport); + textPosY += 8; } } - if (msg2 != nullptr) { + if (msg2) { + char L1312_ac_StringPart1[70]; + char L1313_ac_StringPart2[70]; if (f426_isMessageOnTwoLines(msg2, L1312_ac_StringPart1, L1313_ac_StringPart2)) { - L1308_i_X = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1); - _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k9_ColorGold, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport); - L1309_i_Y += 8; - L1308_i_X = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1); - _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k9_ColorGold, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport); + textPosX = 113 - ((strlen(L1312_ac_StringPart1) * 6) >> 1); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, L1312_ac_StringPart1, k136_heightViewport); + textPosY += 8; + textPosX = 113 - ((strlen(L1313_ac_StringPart2) * 6) >> 1); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, L1313_ac_StringPart2, k136_heightViewport); } else { - L1308_i_X = 113 - ((strlen(msg2) * 6) >> 1); - _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, L1308_i_X, L1309_i_Y, k9_ColorGold, k5_ColorLightBrown, msg2, k136_heightViewport); + textPosX = 113 - ((strlen(msg2) * 6) >> 1); + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, textPosX, textPosY, k9_ColorGold, k5_ColorLightBrown, msg2, k136_heightViewport); } } if (screenDialog) { - L1314_s_Box._y1 = 33; - L1314_s_Box._y2 = 168; - L1314_s_Box._x1 = 47; - L1314_s_Box._x2 = 270; + Box displayBox; + displayBox._y1 = 33; + displayBox._y2 = 168; + displayBox._x1 = 47; + displayBox._x2 = 270; _vm->_eventMan->f78_showMouse(); - _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->_g296_bitmapViewport, &L1314_s_Box, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport); + _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->_g296_bitmapViewport, &displayBox, k112_byteWidthViewport, kM1_ColorNoTransparency, k136_heightViewport); _vm->_eventMan->f77_hideMouse(); } else { _vm->_displayMan->f97_drawViewport(k0_viewportNotDungeonView); _vm->f22_delay(1); } - if (fading) { - warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette in f427_dialogDraw"); - } + + if (fading) + _vm->_displayMan->f436_STARTEND_FadeToPalette(_vm->_displayMan->_g347_paletteTopAndBottomScreen); + _vm->_displayMan->_g297_drawFloorAndCeilingRequested = true; } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index dfd458ef80..387a73de67 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -718,7 +718,7 @@ public: bool _g297_drawFloorAndCeilingRequested; // @ G0297_B_DrawFloorAndCeilingRequested - // This tells blitting functions wther to assume a BYTE_BOX or a WORD_BOX has been passed to them, + // This tells blitting functions whether to assume a BYTE_BOX or a WORD_BOX has been passed to them, // I only use WORD_BOX, so this will probably deem useless bool _g578_useByteBoxCoordinates; // @ G0578_B_UseByteBoxCoordinates bool _g77_doNotDrawFluxcagesDuringEndgame; // @ G0077_B_DoNotDrawFluxcagesDuringEndgame -- cgit v1.2.3 From 22d6973de5814a6229fb665a43882df1eb140048 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 1 Aug 2016 15:24:47 +0200 Subject: DM: Add sound loading --- engines/dm/dm.cpp | 7 ++-- engines/dm/dm.h | 12 +++++++ engines/dm/gfx.cpp | 2 ++ engines/dm/group.h | 1 - engines/dm/module.mk | 1 + engines/dm/sounds.cpp | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 engines/dm/sounds.cpp diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 852145056a..50afa43a8c 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -202,6 +202,9 @@ DMEngine::~DMEngine() { delete _projexpl; delete _dialog; + for (uint16 i = 0; i < k34_D13_soundCount; ++i) + delete[] _gK24_soundData[i]._firstSample; + // clear debug channels DebugMan.clearAllDebugChannels(); } @@ -227,7 +230,8 @@ void DMEngine::f463_initializeGame() { _displayMan->loadPalette(g21_PalDungeonView[0]); _displayMan->f94_loadFloorSet(k0_FloorSetStone); _displayMan->f95_loadWallSet(k0_WallSetStone); - + f503_loadSounds(); + warning(false, "MISSING CODE: F0437_STARTEND_DrawTitle"); _textMan->f54_textInitialize(); _objectMan->loadObjectNames(); _eventMan->initMouse(); @@ -697,5 +701,4 @@ void DMEngine::f439_drawEntrance() { _displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[4], &G0011_s_Graphic562_Box_Entrance_ClosedDoorRight, k64_byteWidth, kM1_ColorNoTransparency, 161); warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(g20_PalEntrance);"); } - } // End of namespace DM diff --git a/engines/dm/dm.h b/engines/dm/dm.h index cb7d07f781..a6d2fe635b 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -195,6 +195,16 @@ struct SaveGameHeader { }; +#define k34_D13_soundCount 34 // @ D13_SOUND_COUNT + +class SoundData { +public: + uint32 _byteCount; + byte* _firstSample; + uint32 _sampleCount; + SoundData(): _byteCount(0), _firstSample(nullptr), _sampleCount(0) {} +}; // @ SOUND_DATA + class DMEngine : public Engine { void f462_startGame(); // @ F0462_START_StartGame_CPSF void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE @@ -206,6 +216,7 @@ class DMEngine : public Engine { void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName); bool readSaveGameHeader(Common::InSaveFile *file, SaveGameHeader *header); void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance + void f503_loadSounds(); // @ F0503_SOUND_LoadAll public: explicit DMEngine(OSystem *syst); ~DMEngine(); @@ -233,6 +244,7 @@ private: byte *_g562_entranceDoorAnimSteps[10]; // @ G0562_apuc_Bitmap_EntranceDoorAnimationSteps byte *_g564_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits Common::RandomSource *_rnd; + SoundData _gK24_soundData[k34_D13_soundCount]; // @ K0024_as_SoundData public: DisplayMan *_displayMan; DungeonMan *_dungeonMan; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 8ca6caf151..515bca2763 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -2642,10 +2642,12 @@ Common::MemoryReadStream DisplayMan::getCompressedData(uint16 index) { return Common::MemoryReadStream(_packedBitmaps + _packedItemPos[index], getCompressedDataSize(index), DisposeAfterUse::NO); } + uint32 DisplayMan::getCompressedDataSize(uint16 index) { return _packedItemPos[index + 1] - _packedItemPos[index]; } + /* Field Aspect Mask */ #define kMaskFieldAspectFlipMask 0x0080 // @ MASK0x0080_FLIP_MASK #define kMaskFieldAspectIndex 0x007F // @ MASK0x007F_MASK_INDEX diff --git a/engines/dm/group.h b/engines/dm/group.h index 5194b907fd..804b562c43 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -149,7 +149,6 @@ public: #define k255_immobile 255 // @ C255_IMMOBILE #define kM1_wholeCreatureGroup -1 // @ CM1_WHOLE_CREATURE_GROUP -#define k34_D13_soundCount 34 // @ D13_SOUND_COUNT int32 M32_setTime(int32 &map_time, int32 time); // @ M32_SET_TIME diff --git a/engines/dm/module.mk b/engines/dm/module.mk index 75b4385421..bf1cef8694 100644 --- a/engines/dm/module.mk +++ b/engines/dm/module.mk @@ -44,6 +44,7 @@ MODULE_OBJS := \ movesens.o \ objectman.o \ projexpl.o \ + sounds.o \ text.o \ timeline.o diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp new file mode 100644 index 0000000000..681ff6da22 --- /dev/null +++ b/engines/dm/sounds.cpp @@ -0,0 +1,99 @@ +/* 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. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + +#include "audio/audiostream.h" +#include "audio/decoders/raw.h" + +#include "dm.h" +#include "gfx.h" + + +namespace DM { + +class Sound { +public: + int16 _graphicIndex; + byte _period; + byte _priority; + byte _loudDistance; + byte _softDistance; + Sound(int16 index, byte period, byte priority, byte loudDist, byte softDist) : + _graphicIndex(index), _period(period), _priority(priority), _loudDistance(loudDist), _softDistance(softDist) {} +}; // @ Sound + + +Sound G0060_as_Graphic562_Sounds[k34_D13_soundCount] = { + Sound(533, 112, 11, 3, 6), /* k00_soundMETALLIC_THUD 0 */ + Sound(534, 112, 15, 0, 3), /* k01_soundSWITCH 1 */ + Sound(535, 112, 72, 3, 6), /* k02_soundDOOR_RATTLE 2 */ + Sound(550, 112, 60, 3, 5), /* k03_soundATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON 3 */ + Sound(536, 112, 10, 3, 6), /* k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM 4 */ + Sound(537, 112, 99, 3, 7), /* k05_soundSTRONG_EXPLOSION 5 */ + Sound(539, 112, 110, 3, 6), /* k06_soundSCREAM 6 */ + Sound(551, 112, 55, 3, 5), /* k07_soundATTACK_MUMMY_GHOST_RIVE 7 */ + Sound(540, 112, 2, 3, 6), /* k08_soundSWALLOW 8 */ + Sound(541, 112, 80, 3, 6), /* k09_soundCHAMPION_0_DAMAGED 9 */ + Sound(542, 112, 82, 3, 6), /* k10_soundCHAMPION_1_DAMAGED 10 */ + Sound(543, 112, 84, 3, 6), /* k11_soundCHAMPION_2_DAMAGED 11 */ + Sound(544, 112, 86, 3, 6), /* k12_soundCHAMPION_3_DAMAGED 12 */ + Sound(545, 112, 95, 3, 6), /* k13_soundSPELL 13 */ + Sound(552, 112, 57, 3, 5), /* k14_soundATTACK_SCREAMER_OITU 14 */ + Sound(553, 112, 52, 3, 5), /* k15_soundATTACK_GIANT_SCORPION_SCORPION 15 */ + Sound(546, 112, 40, 2, 4), /* k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT 16 */ + Sound(547, 112, 70, 1, 4), /* k17_soundBUZZ 17 */ + Sound(549, 138, 75, 3, 6), /* k18_soundPARTY_DAMAGED 18 */ + Sound(554, 112, 50, 3, 5), /* k19_soundATTACK_MAGENTA_WORM_WORM 19 */ + Sound(537, 112, 98, 0, 4), /* k20_soundWEAK_EXPLOSION 20 */ + Sound(555, 112, 96, 2, 4), /* k21_soundATTACK_GIGGLER 21 */ + Sound(563, 138, 24, 0, 4), /* k22_soundMOVE_ANIMATED_ARMOUR_DETH_KNIGHT 22 Atari ST: not present */ + Sound(564, 138, 21, 0, 4), /* k23_soundMOVE_COUATL_GIANT_WASP_MUNCHER 23 Atari ST: not present */ + Sound(565, 138, 23, 0, 4), /* k24_soundMOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON 24 Atari ST: not present */ + Sound(566, 138, 105, 0, 4), /* k25_soundBLOW_HORN 25 Atari ST: not present */ + Sound(567, 138, 27, 0, 4), /* k26_soundMOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU 26 Atari ST: not present */ + Sound(568, 138, 28, 0, 4), /* k27_soundMOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL 27 Atari ST: not present */ + Sound(569, 138, 106, 0, 4), /* k28_soundWAR_CRY 28 Atari ST: not present */ + Sound(570, 138, 56, 0, 4), /* k29_soundATTACK_ROCK_ROCKPILE 29 Atari ST: not present */ + Sound(571, 138, 58, 0, 4), /* k30_soundATTACK_WATER_ELEMENTAL 30 Atari ST: not present */ + Sound(572, 112, 53, 0, 4), /* k31_soundATTACK_COUATL 31 Atari ST: not present */ + Sound(573, 138, 29, 0, 4), /* k32_soundMOVE_RED_DRAGON 32 Atari ST: not present */ + Sound(574, 150, 22, 0, 4)}; /* k33_soundMOVE_SKELETON 33 Atari ST: not present */ + +void DMEngine::f503_loadSounds() { + for (uint16 soundIndex = 0; soundIndex < k34_D13_soundCount; ++soundIndex) { + SoundData *soundData = _gK24_soundData + soundIndex; + + uint16 graphicIndex = G0060_as_Graphic562_Sounds[soundIndex]._graphicIndex; + soundData->_byteCount = _displayMan->getCompressedDataSize(graphicIndex) - 2; // the header is 2 bytes long + soundData->_firstSample = new byte[soundData->_byteCount]; + + Common::MemoryReadStream stream = _displayMan->getCompressedData(graphicIndex); + soundData->_sampleCount = stream.readUint16BE(); + stream.read(soundData->_firstSample, soundData->_byteCount); + } +} + +} -- cgit v1.2.3 From ba46060b13e7106e524fd1a56086e4e88c0b9fb4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 29 Jul 2016 23:14:29 +0200 Subject: DM: Fix compilation using MSVC9 --- engines/dm/dm.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 50afa43a8c..3b23028c86 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -509,11 +509,11 @@ void DMEngine::f441_processEntrance() { void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) { // TODO: localization - static Box G0013_s_Graphic562_Box_Endgame_Restart_Outer = {103, 217, 145, 159}; - static Box G0014_s_Graphic562_Box_Endgame_Restart_Inner = {105, 215, 147, 157}; - static Box G0012_s_Graphic562_Box_Endgame_TheEnd = {120, 199, 95, 108}; - static Box G0015_s_Graphic562_Box_Endgame_ChampionMirror = {11, 74, 7, 49}; - static Box G0016_s_Graphic562_Box_Endgame_ChampionPortrait = {27, 58, 13, 41}; + static Box G0013_s_Graphic562_Box_Endgame_Restart_Outer = Box(103, 217, 145, 159); + static Box G0014_s_Graphic562_Box_Endgame_Restart_Inner = Box(105, 215, 147, 157); + static Box G0012_s_Graphic562_Box_Endgame_TheEnd = Box(120, 199, 95, 108); + static Box G0015_s_Graphic562_Box_Endgame_ChampionMirror = Box(11, 74, 7, 49); + static Box G0016_s_Graphic562_Box_Endgame_ChampionPortrait = Box(27, 58, 13, 41); int16 L1409_i_Multiple; #define AL1409_i_Color L1409_i_Multiple #define AL1409_i_ChampionIndex L1409_i_Multiple -- cgit v1.2.3 From 16c3757dcddeeff00b8d66e1d3308b59c8c62098 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 29 Jul 2016 23:17:51 +0200 Subject: DM: Refactor f426_isMessageOnTwoLines --- engines/dm/dialog.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp index 6a99ee5505..fc610c6ff7 100644 --- a/engines/dm/dialog.cpp +++ b/engines/dm/dialog.cpp @@ -145,21 +145,17 @@ void DialogMan::f425_printCenteredChoice(byte* bitmap, char* str, int16 posX, in } bool DialogMan::f426_isMessageOnTwoLines(char* str, char* part1, char* part2) { - uint16 L1305_ui_StringLength; - uint16 L1306_ui_SplitPosition; - - - L1305_ui_StringLength = strlen(str); - if (L1305_ui_StringLength <= 30) { + uint16 strLength = strlen(str); + if (strLength <= 30) return false; - } + strcpy(part1, str); - L1306_ui_SplitPosition = L1305_ui_StringLength >> 1; - while ((part1[L1306_ui_SplitPosition] != ' ') && L1306_ui_SplitPosition < L1305_ui_StringLength) { - L1306_ui_SplitPosition++; - } - part1[L1306_ui_SplitPosition] = '\0'; - strcpy(part2, &part1[L1306_ui_SplitPosition + 1]); + uint16 splitPosition = strLength >> 1; + while ((part1[splitPosition] != ' ') && (splitPosition < strLength)) + splitPosition++; + + part1[splitPosition] = '\0'; + strcpy(part2, &part1[splitPosition + 1]); return true; } } -- cgit v1.2.3 From f0e037e305917bfd372254b4050315a66e1588c3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 30 Jul 2016 10:26:23 +0200 Subject: DM: Some renaming, add a couple of STUBS --- engines/dm/dm.cpp | 97 +++++++++++++++++++++++-------------------------- engines/dm/dm.h | 2 + engines/dm/loadsave.cpp | 14 ++++--- 3 files changed, 56 insertions(+), 57 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 3b23028c86..3f13bb5e35 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -179,7 +179,6 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _g562_entranceDoorAnimSteps[i] = nullptr; _g564_interfaceCredits = nullptr; debug("DMEngine::DMEngine"); - } DMEngine::~DMEngine() { @@ -259,10 +258,9 @@ void DMEngine::f448_initMemoryManager() { } void DMEngine::f462_startGame() { - static Box g61_boxScreenTop(0, 319, 0, 32); // @ G0061_s_Graphic562_Box_ScreenTop - static Box g62_boxScreenRight(224, 319, 33, 169); // @ G0062_s_Graphic562_Box_ScreenRight - static Box g63_boxScreenBottom(0, 319, 169, 199); // @ G0063_s_Graphic562_Box_ScreenBottom - + static Box boxScreenTop(0, 319, 0, 32); // @ G0061_s_Graphic562_Box_ScreenTop + static Box boxScreenRight(224, 319, 33, 169); // @ G0062_s_Graphic562_Box_ScreenRight + static Box boxScreenBottom(0, 319, 169, 199); // @ G0063_s_Graphic562_Box_ScreenBottom _g331_pressingEye = false; _g332_stopPressingEye = false; @@ -285,14 +283,14 @@ void DMEngine::f462_startGame() { if (!_g298_newGame) { _displayMan->_g578_useByteBoxCoordinates = false; f22_delay(1); - _displayMan->D24_fillScreenBox(g61_boxScreenTop, k0_ColorBlack); - _displayMan->D24_fillScreenBox(g62_boxScreenRight, k0_ColorBlack); - _displayMan->D24_fillScreenBox(g63_boxScreenBottom, k0_ColorBlack); + _displayMan->D24_fillScreenBox(boxScreenTop, k0_ColorBlack); + _displayMan->D24_fillScreenBox(boxScreenRight, k0_ColorBlack); + _displayMan->D24_fillScreenBox(boxScreenBottom, k0_ColorBlack); } else { _displayMan->_g578_useByteBoxCoordinates = false; - _displayMan->D24_fillScreenBox(g61_boxScreenTop, k0_ColorBlack); - _displayMan->D24_fillScreenBox(g62_boxScreenRight, k0_ColorBlack); - _displayMan->D24_fillScreenBox(g63_boxScreenBottom, k0_ColorBlack); + _displayMan->D24_fillScreenBox(boxScreenTop, k0_ColorBlack); + _displayMan->D24_fillScreenBox(boxScreenRight, k0_ColorBlack); + _displayMan->D24_fillScreenBox(boxScreenBottom, k0_ColorBlack); } warning(false, "TODO: build copper"); @@ -399,9 +397,8 @@ T0002002: _menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived(); - if (!(_g313_gameTime & (_championMan->_g300_partyIsSleeping ? 15 : 63))) { + if (!(_g313_gameTime & (_championMan->_g300_partyIsSleeping ? 15 : 63))) _championMan->f331_applyTimeEffects(); - } if (_g310_disabledMovementTicks) _g310_disabledMovementTicks--; @@ -451,17 +448,14 @@ int16 DMEngine::M0_indexToOrdinal(int16 val) { void DMEngine::f441_processEntrance() { - uint16 L1402_ui_AnimationStep; - Box L1405_s_Box; - _eventMan->_g441_primaryMouseInput = g445_PrimaryMouseInput_Entrance; _eventMan->_g442_secondaryMouseInput = nullptr; _eventMan->_g443_primaryKeyboardInput = nullptr; _eventMan->_g444_secondaryKeyboardInput = nullptr; _g562_entranceDoorAnimSteps[0] = new byte[128 * 161 * 12]; - for (L1402_ui_AnimationStep = 1; L1402_ui_AnimationStep < 8; L1402_ui_AnimationStep++) { - _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep] = _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep - 1] + 128 * 161; - } + for (uint16 idx = 1; idx < 8; idx++) + _g562_entranceDoorAnimSteps[idx] = _g562_entranceDoorAnimSteps[idx - 1] + 128 * 161; + _g562_entranceDoorAnimSteps[8] = _g562_entranceDoorAnimSteps[7] + 128 * 161; _g562_entranceDoorAnimSteps[9] = _g562_entranceDoorAnimSteps[8] + 128 * 161 * 2; @@ -469,19 +463,21 @@ void DMEngine::f441_processEntrance() { _displayMan->f466_loadIntoBitmap(k2_entranceLeftDoorGraphicIndice, _g562_entranceDoorAnimSteps[0]); _g564_interfaceCredits = _displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice); _displayMan->_g578_useByteBoxCoordinates = false; - L1405_s_Box._x1 = 0; - L1405_s_Box._x2 = 100; - L1405_s_Box._y1 = 0; - L1405_s_Box._y2 = 160; - for (L1402_ui_AnimationStep = 1; L1402_ui_AnimationStep < 4; L1402_ui_AnimationStep++) { - _displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[0], _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep], L1405_s_Box, L1402_ui_AnimationStep << 2, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161); - L1405_s_Box._x2 -= 4; + Box displayBox; + displayBox._x1 = 0; + displayBox._x2 = 100; + displayBox._y1 = 0; + displayBox._y2 = 160; + for (uint16 idx = 1; idx < 4; idx++) { + _displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[0], _g562_entranceDoorAnimSteps[idx], displayBox, idx << 2, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161); + displayBox._x2 -= 4; } - L1405_s_Box._x2 = 127; - for (L1402_ui_AnimationStep = 5; L1402_ui_AnimationStep < 8; L1402_ui_AnimationStep++) { - L1405_s_Box._x1 += 4; - _displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[4], _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep], L1405_s_Box, 0, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161); + displayBox._x2 = 127; + for (uint16 idx = 5; idx < 8; idx++) { + displayBox._x1 += 4; + _displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[4], _g562_entranceDoorAnimSteps[idx], displayBox, 0, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161); } + do { f439_drawEntrance(); _eventMan->f78_showMouse(); @@ -496,12 +492,12 @@ void DMEngine::f441_processEntrance() { } while (_g298_newGame == k99_modeWaitingOnEntrance); } while (_g298_newGame == k202_CommandEntranceDrawCredits); //Strangerke: CHECKME: Earlier versions were using G0566_puc_Graphic534_Sound01Switch - warning(false, "MISSING CODE: F0060_SOUND_Play"); + f060_SOUND_Play(k01_soundSWITCH, 112, 0x40, 0x40); f22_delay(20); _eventMan->f78_showMouse(); - if (_g298_newGame) { - warning(false, "MISSING CODE: F0438_STARTEND_OpenEntranceDoors();"); - } + if (_g298_newGame) + f438_STARTEND_OpenEntranceDoors(); + delete[] _g562_entranceDoorAnimSteps[0]; for (uint16 i = 0; i < 10; ++i) _g562_entranceDoorAnimSteps[i] = nullptr; @@ -560,9 +556,9 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) { f22_delay(1); for (uint16 i = 0; i < 16; ++i) _displayMan->_g347_paletteTopAndBottomScreen[i] = L1420_aui_Palette_TopAndBottomScreen[i]; - } else { - warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(G0345_aui_BlankBuffer)"); - } + } else + _displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer); + if (doNotDrawCreditsOnly) { if (_g302_gameWon) { // Strangerke: Related to portraits. Game data could be missing for earlier versions of the game. @@ -593,7 +589,7 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) { G0016_s_Graphic562_Box_Endgame_ChampionPortrait._y1 += 48; G0016_s_Graphic562_Box_Endgame_ChampionPortrait._y1 += 48; } - warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen);"); + _displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen); _engineShouldQuit = true; return; } @@ -605,7 +601,7 @@ T0444017: for (uint16 i = 0; i < 16; ++i) L1419_aui_Palette[i] = L1421_aui_Palette_DarkBlue[i]; L1419_aui_Palette[15] = D09_RGB_WHITE; - warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(L1419_aui_Palette);"); + _displayMan->f436_STARTEND_FadeToPalette(L1419_aui_Palette); if (L1423_B_WaitBeforeDrawingRestart) { /* BUG0_00 Useless code */ f22_delay(300); } /* BUG0_00 Useless code */ @@ -620,15 +616,15 @@ T0444017: _eventMan->_g441_primaryMouseInput = g446_PrimaryMouseInput_RestartGame; _eventMan->f357_discardAllInput(); _eventMan->f77_hideMouse(); - warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette"); + _displayMan->f436_STARTEND_FadeToPalette(L1419_aui_Palette); for (AL1409_i_VerticalBlankCount = 900; --AL1409_i_VerticalBlankCount && !_g523_restartGameRequest; f22_delay(1)) { _eventMan->f380_processCommandQueue(); } _eventMan->f78_showMouse(); if (_g523_restartGameRequest) { - warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette"); + _displayMan->f436_STARTEND_FadeToPalette(L1421_aui_Palette_DarkBlue); _displayMan->fillScreen(k0_ColorBlack); - warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette"); + _displayMan->f436_STARTEND_FadeToPalette(g21_PalDungeonView[0]); _g298_newGame = k0_modeLoadSavedGame; if (f435_loadgame(1) != kM1_LoadgameFailure) { f462_startGame(); @@ -640,20 +636,19 @@ T0444017: } } - warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette"); + _displayMan->f436_STARTEND_FadeToPalette(L1421_aui_Palette_DarkBlue); } - { - Box box(0, 319, 0, 199); - _displayMan->f132_blitToBitmap(_displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice), _displayMan->_g348_bitmapScreen, box, 0, 0, 160, 160, kM1_ColorNoTransparency); - } - warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette"); + Box box(0, 319, 0, 199); + _displayMan->f132_blitToBitmap(_displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice), _displayMan->_g348_bitmapScreen, box, 0, 0, 160, 160, kM1_ColorNoTransparency); + + _displayMan->f436_STARTEND_FadeToPalette(g19_PalCredits); _eventMan->f541_waitForMouseOrKeyActivity(); if (_engineShouldQuit) return; if (_g524_restartGameAllowed && doNotDrawCreditsOnly) { L1423_B_WaitBeforeDrawingRestart = false; - warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette"); + _displayMan->f436_STARTEND_FadeToPalette(L1421_aui_Palette_DarkBlue); goto T0444017; } @@ -687,7 +682,7 @@ void DMEngine::f439_drawEntrance() { L1399_auc_MicroDungeonSquares[L1397_ui_ColumnIndex + 10] = Square(k1_CorridorElemType, 0); } L1399_auc_MicroDungeonSquares[7] = Square(k1_CorridorElemType, 0); - warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(G0345_aui_BlankBuffer);"); + _displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer); // note, a global variable is used here in the original _displayMan->f466_loadIntoBitmap(k4_entranceGraphicIndice, _displayMan->_g348_bitmapScreen); @@ -699,6 +694,6 @@ void DMEngine::f439_drawEntrance() { _displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[0], &G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft, k64_byteWidth, kM1_ColorNoTransparency, 161); _displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[4], &G0011_s_Graphic562_Box_Entrance_ClosedDoorRight, k64_byteWidth, kM1_ColorNoTransparency, 161); - warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(g20_PalEntrance);"); + _displayMan->f436_STARTEND_FadeToPalette(g20_PalEntrance); } } // End of namespace DM diff --git a/engines/dm/dm.h b/engines/dm/dm.h index a6d2fe635b..33c3b0336c 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -235,6 +235,8 @@ public: void f444_endGame(bool doNotDrawCreditsOnly); // @ F0444_STARTEND_Endgame void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode) { warning(true, "STUB: f064_SOUND_RequestPlay_CPSD"); } + void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol) { warning(true, "STUB: f060_SOUND_Play"); } + void f438_STARTEND_OpenEntranceDoors() { warning(true, "STUB: f438_STARTEND_OpenEntranceDoors"); } private: int16 _g528_saveFormat; // @ G0528_i_Format diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 85b36911d9..24e1a1518c 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -140,20 +140,22 @@ LoadgameResponse DMEngine::f435_loadgame(int16 slot) { if (_g298_newGame) { _timeline->f233_initTimeline(); _groupMan->f196_initActiveGroups(); - warning(false, "MISSING CODE: missing fadePlette stuff in f435_loadgame on newGame"); - /* + +#if 0 + // always false? if (L1366_B_FadePalette) { - F0436_STARTEND_FadeToPalette(G0345_aui_BlankBuffer); + _displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer); D26_WaitForVerticalBlank(); D18_FillScreenBlack(); - F0436_STARTEND_FadeToPalette(_vm->_displayMan->_g347_paletteTopAndBottomScreen); - }*/ + _displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen); + } +#endif } else { _g528_saveFormat = dmSaveHeader._saveFormat; _g527_platform = dmSaveHeader._platform; _g526_dungeonId = dmSaveHeader._dungeonId; - _g524_restartGameAllowed = true; + _g524_restartGameAllowed = true; warning(false, "MISSING CDOE: F0427_DIALOG_Draw in f435_loadgame"); } _championMan->_g303_partyDead = false; -- cgit v1.2.3 From ef34e8bb39238530048645c3654c91a21f1248cc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 30 Jul 2016 10:37:29 +0200 Subject: DM: Apply coding conventions to a couple of oneliner functions, remove a GOTO --- engines/dm/dm.cpp | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 3f13bb5e35..1ac9a32a10 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -76,9 +76,17 @@ void warning(bool repeat, const char* s, ...) { } } -void turnDirRight(Direction &dir) { dir = (Direction)((dir + 1) & 3); } -void turnDirLeft(Direction &dir) { dir = (Direction)((dir - 1) & 3); } -Direction returnOppositeDir(Direction dir) { return (Direction)((dir + 2) & 3); } +void turnDirRight(Direction &dir) { + dir = (Direction)((dir + 1) & 3); +} + +void turnDirLeft(Direction &dir) { + dir = (Direction)((dir - 1) & 3); +} + +Direction returnOppositeDir(Direction dir) { + return (Direction)((dir + 2) & 3); +} uint16 returnPrevVal(uint16 val) { return (Direction)((val + 3) & 3); @@ -88,7 +96,9 @@ uint16 returnNextVal(uint16 val) { return (val + 1) & 0x3; } -bool isOrientedWestEast(Direction dir) { return dir & 1; } +bool isOrientedWestEast(Direction dir) { + return dir & 1; +} uint16 toggleFlag(uint16& val, uint16 mask) { return val ^= mask; @@ -134,7 +144,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { DebugMan.addDebugChannel(kDMDebugExample, "example", "example desc"); // register random source - _rnd = new Common::RandomSource("quux"); + _rnd = new Common::RandomSource("dm"); _dungeonMan = nullptr; _displayMan = nullptr; @@ -351,17 +361,19 @@ void DMEngine::f2_gameloop() { while (true) { if (_engineShouldQuit) return; - if (_g327_newPartyMapIndex != kM1_mapIndexNone) { -T0002002: - f3_processNewPartyMap(_g327_newPartyMapIndex); - _moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); - _g327_newPartyMapIndex = kM1_mapIndexNone; - _eventMan->f357_discardAllInput(); - } - _timeline->f261_processTimeline(); - if (_g327_newPartyMapIndex != kM1_mapIndexNone) - goto T0002002; + for (;;) { + if (_g327_newPartyMapIndex != kM1_mapIndexNone) { + f3_processNewPartyMap(_g327_newPartyMapIndex); + _moveSens->f267_getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); + _g327_newPartyMapIndex = kM1_mapIndexNone; + _eventMan->f357_discardAllInput(); + } + _timeline->f261_processTimeline(); + + if (_g327_newPartyMapIndex == kM1_mapIndexNone) + break; + } if (!_inventoryMan->_g432_inventoryChampionOrdinal && !_championMan->_g300_partyIsSleeping) { Box box(0, 223, 0, 135); -- cgit v1.2.3 From a2b495e0e57a42527bbb58414359c056473036af Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 30 Jul 2016 11:20:47 +0200 Subject: DM: Refactor f444_endGame --- engines/dm/dm.cpp | 136 +++++++++++++++++++++++++----------------------------- 1 file changed, 62 insertions(+), 74 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 1ac9a32a10..58097e7a52 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -350,6 +350,7 @@ Common::Error DMEngine::run() { } void DMEngine::f2_gameloop() { + //HACK: Remove this block to get real starting position in the Hall of Champions if (_g298_newGame) { warning(false, "DUMMY CODE: SETTING PARTY POS AND DIRECTION"); _dungeonMan->_g306_partyMapX = 9; @@ -399,6 +400,7 @@ void DMEngine::f2_gameloop() { _championMan->f320_applyAndDrawPendingDamageAndWounds(); if (_championMan->_g303_partyDead) break; + _g313_gameTime++; if (!(_g313_gameTime & 511)) @@ -458,7 +460,6 @@ int16 DMEngine::M0_indexToOrdinal(int16 val) { return val + 1; } - void DMEngine::f441_processEntrance() { _eventMan->_g441_primaryMouseInput = g445_PrimaryMouseInput_Entrance; _eventMan->_g442_secondaryMouseInput = nullptr; @@ -503,6 +504,7 @@ void DMEngine::f441_processEntrance() { _displayMan->updateScreen(); } while (_g298_newGame == k99_modeWaitingOnEntrance); } while (_g298_newGame == k202_CommandEntranceDrawCredits); + //Strangerke: CHECKME: Earlier versions were using G0566_puc_Graphic534_Sound01Switch f060_SOUND_Play(k01_soundSWITCH, 112, 0x40, 0x40); f22_delay(20); @@ -517,31 +519,13 @@ void DMEngine::f441_processEntrance() { void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) { // TODO: localization - static Box G0013_s_Graphic562_Box_Endgame_Restart_Outer = Box(103, 217, 145, 159); - static Box G0014_s_Graphic562_Box_Endgame_Restart_Inner = Box(105, 215, 147, 157); - static Box G0012_s_Graphic562_Box_Endgame_TheEnd = Box(120, 199, 95, 108); - static Box G0015_s_Graphic562_Box_Endgame_ChampionMirror = Box(11, 74, 7, 49); - static Box G0016_s_Graphic562_Box_Endgame_ChampionPortrait = Box(27, 58, 13, 41); - int16 L1409_i_Multiple; -#define AL1409_i_Color L1409_i_Multiple -#define AL1409_i_ChampionIndex L1409_i_Multiple -#define AL1409_i_VerticalBlankCount L1409_i_Multiple - int16 L1410_i_Multiple; -#define AL1410_i_Counter L1410_i_Multiple -#define AL1410_i_Y L1410_i_Multiple - int16 L1411_i_Multiple; -#define AL1411_i_X L1411_i_Multiple -#define AL1411_i_SkillIndex L1411_i_Multiple - int16 L1412_i_SkillLevel; - char L1415_c_ChampionTitleFirstCharacter; - Champion* L1416_ps_Champion; - uint16 L1419_aui_Palette[16]; - uint16 L1420_aui_Palette_TopAndBottomScreen[16]; - uint16 L1421_aui_Palette_DarkBlue[16]; - char L1422_ac_String[20]; - // Strangerke: Not so sure it's useless. - bool L1423_B_WaitBeforeDrawingRestart; /* BUG0_00 Useless code */ - L1423_B_WaitBeforeDrawingRestart = true; /* BUG0_00 Useless code */ + static Box restartOuterBox = Box(103, 217, 145, 159); + static Box restartInnerBox = Box(105, 215, 147, 157); + static Box theEndBox = Box(120, 199, 95, 108); + static Box championMirrorBox = Box(11, 74, 7, 49); + static Box championPortraitBox = Box(27, 58, 13, 41); + + bool waitBeforeDrawingRestart = true; _eventMan->f67_setMousePointerToNormal(k0_pointerArrow); _eventMan->f78_showMouse(); @@ -555,51 +539,55 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) { } if (_displayMan->_g322_paletteSwitchingEnabled) { + uint16 oldPalTopAndBottomScreen[16]; for (uint16 i = 0; i < 16; ++i) - L1420_aui_Palette_TopAndBottomScreen[i] = _displayMan->_g347_paletteTopAndBottomScreen[i]; - for (AL1410_i_Counter = 0; AL1410_i_Counter <= 7; AL1410_i_Counter++) { + oldPalTopAndBottomScreen[i] = _displayMan->_g347_paletteTopAndBottomScreen[i]; + for (int i = 0; i <= 7; i++) { f22_delay(1); - for (AL1409_i_Color = 0; AL1409_i_Color < 16; AL1409_i_Color++) { - _displayMan->_g346_paletteMiddleScreen[AL1409_i_Color] = _displayMan->f431_getDarkenedColor(_displayMan->_g346_paletteMiddleScreen[AL1409_i_Color]); - _displayMan->_g347_paletteTopAndBottomScreen[AL1409_i_Color] = _displayMan->f431_getDarkenedColor(_displayMan->_g347_paletteTopAndBottomScreen[AL1409_i_Color]); + for (int colIdx = 0; colIdx < 16; colIdx++) { + _displayMan->_g346_paletteMiddleScreen[colIdx] = _displayMan->f431_getDarkenedColor(_displayMan->_g346_paletteMiddleScreen[colIdx]); + _displayMan->_g347_paletteTopAndBottomScreen[colIdx] = _displayMan->f431_getDarkenedColor(_displayMan->_g347_paletteTopAndBottomScreen[colIdx]); } } _displayMan->_g322_paletteSwitchingEnabled = false; f22_delay(1); for (uint16 i = 0; i < 16; ++i) - _displayMan->_g347_paletteTopAndBottomScreen[i] = L1420_aui_Palette_TopAndBottomScreen[i]; + _displayMan->_g347_paletteTopAndBottomScreen[i] = oldPalTopAndBottomScreen[i]; } else _displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer); + uint16 darkBluePalette[16]; if (doNotDrawCreditsOnly) { if (_g302_gameWon) { // Strangerke: Related to portraits. Game data could be missing for earlier versions of the game. _displayMan->fillScreen(k12_ColorDarkestGray); - for (AL1409_i_ChampionIndex = k0_ChampionFirst; AL1409_i_ChampionIndex < _championMan->_g305_partyChampionCount; AL1409_i_ChampionIndex++) { - AL1410_i_Y = AL1409_i_ChampionIndex * 48; - L1416_ps_Champion = &_championMan->_gK71_champions[AL1409_i_ChampionIndex]; - _displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k208_wallOrn_43_champMirror), &G0015_s_Graphic562_Box_Endgame_ChampionMirror, k32_byteWidth, k10_ColorFlesh, 43); - _displayMan->f21_blitToScreen(L1416_ps_Champion->_portrait, &G0016_s_Graphic562_Box_Endgame_ChampionPortrait, k16_byteWidth, k1_ColorDarkGary, 29); - _textMan->f443_endgamePrintString(87, AL1410_i_Y += 14, k9_ColorGold, L1416_ps_Champion->_name); - AL1411_i_X = (6 * strlen(L1416_ps_Champion->_name)) + 87; - L1415_c_ChampionTitleFirstCharacter = L1416_ps_Champion->_title[0]; - if ((L1415_c_ChampionTitleFirstCharacter != ',') && (L1415_c_ChampionTitleFirstCharacter != ';') && (L1415_c_ChampionTitleFirstCharacter != '-')) { - AL1411_i_X += 6; - } - _textMan->f443_endgamePrintString(AL1411_i_X, AL1410_i_Y++, k9_ColorGold, L1416_ps_Champion->_title); - for (AL1411_i_SkillIndex = k0_ChampionSkillFighter; AL1411_i_SkillIndex <= k3_ChampionSkillWizard; AL1411_i_SkillIndex++) { - L1412_i_SkillLevel = MIN((uint16)16, _championMan->f303_getSkillLevel(AL1409_i_ChampionIndex, AL1411_i_SkillIndex | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience))); - if (L1412_i_SkillLevel == 1) + for (int16 championIndex = k0_ChampionFirst; championIndex < _championMan->_g305_partyChampionCount; championIndex++) { + int16 textPosY = championIndex * 48; + Champion *curChampion = &_championMan->_gK71_champions[championIndex]; + _displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k208_wallOrn_43_champMirror), &championMirrorBox, k32_byteWidth, k10_ColorFlesh, 43); + _displayMan->f21_blitToScreen(curChampion->_portrait, &championPortraitBox, k16_byteWidth, k1_ColorDarkGary, 29); + _textMan->f443_endgamePrintString(87, textPosY += 14, k9_ColorGold, curChampion->_name); + int textPosX = (6 * strlen(curChampion->_name)) + 87; + char championTitleFirstCharacter = curChampion->_title[0]; + if ((championTitleFirstCharacter != ',') && (championTitleFirstCharacter != ';') && (championTitleFirstCharacter != '-')) + textPosX += 6; + + _textMan->f443_endgamePrintString(textPosX, textPosY++, k9_ColorGold, curChampion->_title); + for (int16 idx = k0_ChampionSkillFighter; idx <= k3_ChampionSkillWizard; idx++) { + uint16 skillLevel = MIN(16, _championMan->f303_getSkillLevel(championIndex, idx | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience))); + if (skillLevel == 1) continue; - strcpy(L1422_ac_String, G0428_apc_SkillLevelNames[L1412_i_SkillLevel - 2]); - strcat(L1422_ac_String, " "); - strcat(L1422_ac_String, g417_baseSkillName[AL1411_i_SkillIndex]); - _textMan->f443_endgamePrintString(105, AL1410_i_Y = AL1410_i_Y + 8, k13_ColorLightestGray, L1422_ac_String); + + char displStr[20]; + strcpy(displStr, G0428_apc_SkillLevelNames[skillLevel - 2]); + strcat(displStr, " "); + strcat(displStr, g417_baseSkillName[idx]); + _textMan->f443_endgamePrintString(105, textPosY = textPosY + 8, k13_ColorLightestGray, displStr); } - G0015_s_Graphic562_Box_Endgame_ChampionMirror._y1 += 48; - G0015_s_Graphic562_Box_Endgame_ChampionMirror._y2 += 48; - G0016_s_Graphic562_Box_Endgame_ChampionPortrait._y1 += 48; - G0016_s_Graphic562_Box_Endgame_ChampionPortrait._y1 += 48; + championMirrorBox._y1 += 48; + championMirrorBox._y2 += 48; + championPortraitBox._y1 += 48; + championPortraitBox._y1 += 48; } _displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g347_paletteTopAndBottomScreen); _engineShouldQuit = true; @@ -607,34 +595,34 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) { } T0444017: _displayMan->fillScreen(k0_ColorBlack); - _displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k6_theEndIndice), &G0012_s_Graphic562_Box_Endgame_TheEnd, k40_byteWidth, kM1_ColorNoTransparency, 14); - for (uint16 i = 0; i < 16; ++i) - L1421_aui_Palette_DarkBlue[i] = D01_RGB_DARK_BLUE; + _displayMan->f21_blitToScreen(_displayMan->f489_getNativeBitmapOrGraphic(k6_theEndIndice), &theEndBox, k40_byteWidth, kM1_ColorNoTransparency, 14); for (uint16 i = 0; i < 16; ++i) - L1419_aui_Palette[i] = L1421_aui_Palette_DarkBlue[i]; - L1419_aui_Palette[15] = D09_RGB_WHITE; - _displayMan->f436_STARTEND_FadeToPalette(L1419_aui_Palette); - if (L1423_B_WaitBeforeDrawingRestart) { /* BUG0_00 Useless code */ + darkBluePalette[i] = D01_RGB_DARK_BLUE; + uint16 curPalette[16]; + for (uint16 i = 0; i < 15; ++i) + curPalette[i] = darkBluePalette[i]; + curPalette[15] = D09_RGB_WHITE; + _displayMan->f436_STARTEND_FadeToPalette(curPalette); + if (waitBeforeDrawingRestart) f22_delay(300); - } /* BUG0_00 Useless code */ if (_g524_restartGameAllowed) { _displayMan->_g578_useByteBoxCoordinates = false; - _displayMan->D24_fillScreenBox(G0013_s_Graphic562_Box_Endgame_Restart_Outer, k12_ColorDarkestGray); - _displayMan->D24_fillScreenBox(G0014_s_Graphic562_Box_Endgame_Restart_Inner, k0_ColorBlack); + _displayMan->D24_fillScreenBox(restartOuterBox, k12_ColorDarkestGray); + _displayMan->D24_fillScreenBox(restartInnerBox, k0_ColorBlack); _textMan->f53_printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RESTART THIS GAME"); - L1419_aui_Palette[1] = D03_RGB_PINK; - L1419_aui_Palette[4] = D09_RGB_WHITE; + curPalette[1] = D03_RGB_PINK; + curPalette[4] = D09_RGB_WHITE; _eventMan->_g441_primaryMouseInput = g446_PrimaryMouseInput_RestartGame; _eventMan->f357_discardAllInput(); _eventMan->f77_hideMouse(); - _displayMan->f436_STARTEND_FadeToPalette(L1419_aui_Palette); - for (AL1409_i_VerticalBlankCount = 900; --AL1409_i_VerticalBlankCount && !_g523_restartGameRequest; f22_delay(1)) { + _displayMan->f436_STARTEND_FadeToPalette(curPalette); + for (int16 verticalBlankCount = 900; --verticalBlankCount && !_g523_restartGameRequest; f22_delay(1)) _eventMan->f380_processCommandQueue(); - } + _eventMan->f78_showMouse(); if (_g523_restartGameRequest) { - _displayMan->f436_STARTEND_FadeToPalette(L1421_aui_Palette_DarkBlue); + _displayMan->f436_STARTEND_FadeToPalette(darkBluePalette); _displayMan->fillScreen(k0_ColorBlack); _displayMan->f436_STARTEND_FadeToPalette(g21_PalDungeonView[0]); _g298_newGame = k0_modeLoadSavedGame; @@ -648,7 +636,7 @@ T0444017: } } - _displayMan->f436_STARTEND_FadeToPalette(L1421_aui_Palette_DarkBlue); + _displayMan->f436_STARTEND_FadeToPalette(darkBluePalette); } Box box(0, 319, 0, 199); _displayMan->f132_blitToBitmap(_displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice), _displayMan->_g348_bitmapScreen, box, 0, 0, 160, 160, kM1_ColorNoTransparency); @@ -659,8 +647,8 @@ T0444017: return; if (_g524_restartGameAllowed && doNotDrawCreditsOnly) { - L1423_B_WaitBeforeDrawingRestart = false; - _displayMan->f436_STARTEND_FadeToPalette(L1421_aui_Palette_DarkBlue); + waitBeforeDrawingRestart = false; + _displayMan->f436_STARTEND_FadeToPalette(darkBluePalette); goto T0444017; } -- cgit v1.2.3 From db164ae9d67e8be14b349a76fcac279604e646f9 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 31 Jul 2016 21:48:37 +0200 Subject: DM: Refactor f439_drawEntrance --- engines/dm/dm.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 58097e7a52..e825ead2c2 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -658,30 +658,30 @@ T0444017: void DMEngine::f439_drawEntrance() { - static Box K0079_s_Box_Entrance_DoorsUpperHalf = Box(0, 231, 0, 80); - static Box K0152_s_Box_Entrance_DoorsLowerHalf = Box(0, 231, 81, 160); - static Box G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft = Box(0, 104, 30, 190); - static Box G0011_s_Graphic562_Box_Entrance_ClosedDoorRight = Box(105, 231, 30, 190); + static Box doorsUpperHalfBox = Box(0, 231, 0, 80); + static Box doorsLowerHalfBox = Box(0, 231, 81, 160); + static Box closedDoorLeftBox = Box(0, 104, 30, 190); + static Box closedDoorRightBox = Box(105, 231, 30, 190); - uint16 L1397_ui_ColumnIndex; - byte* L1398_apuc_MicroDungeonCurrentMapData[32]; - Square L1399_auc_MicroDungeonSquares[25]; + byte *microDungeonCurrentMapData[32]; _dungeonMan->_g309_partyMapIndex = k255_mapIndexEntrance; _displayMan->_g297_drawFloorAndCeilingRequested = true; _dungeonMan->_g273_currMapWidth = 5; _dungeonMan->_g274_currMapHeight = 5; - _dungeonMan->_g271_currMapData = L1398_apuc_MicroDungeonCurrentMapData; + _dungeonMan->_g271_currMapData = microDungeonCurrentMapData; Map map; // uninitialized, won't be used _dungeonMan->_g269_currMap = ↦ + Square microDungeonSquares[25]; for (uint16 i = 0; i < 25; ++i) - L1399_auc_MicroDungeonSquares[i] = Square(k0_ElementTypeWall, 0); - for (L1397_ui_ColumnIndex = 0; L1397_ui_ColumnIndex < 5; L1397_ui_ColumnIndex++) { - L1398_apuc_MicroDungeonCurrentMapData[L1397_ui_ColumnIndex] = (byte*)&L1399_auc_MicroDungeonSquares[L1397_ui_ColumnIndex * 5]; - L1399_auc_MicroDungeonSquares[L1397_ui_ColumnIndex + 10] = Square(k1_CorridorElemType, 0); + microDungeonSquares[i] = Square(k0_ElementTypeWall, 0); + + for (int16 idx = 0; idx < 5; idx++) { + microDungeonCurrentMapData[idx] = (byte*)µDungeonSquares[idx * 5]; + microDungeonSquares[idx + 10] = Square(k1_CorridorElemType, 0); } - L1399_auc_MicroDungeonSquares[7] = Square(k1_CorridorElemType, 0); + microDungeonSquares[7] = Square(k1_CorridorElemType, 0); _displayMan->f436_STARTEND_FadeToPalette(_displayMan->_g345_aui_BlankBuffer); // note, a global variable is used here in the original @@ -689,11 +689,11 @@ void DMEngine::f439_drawEntrance() { _displayMan->f128_drawDungeon(kDirSouth, 2, 0); warning(false, "IGNORED CODE: G0324_B_DrawViewportRequested = false;"); - _displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], K0079_s_Box_Entrance_DoorsUpperHalf, 0, 30, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161); - _displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], K0152_s_Box_Entrance_DoorsLowerHalf, 0, 111, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161); + _displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], doorsUpperHalfBox, 0, 30, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161); + _displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], doorsLowerHalfBox, 0, 111, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161); - _displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[0], &G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft, k64_byteWidth, kM1_ColorNoTransparency, 161); - _displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[4], &G0011_s_Graphic562_Box_Entrance_ClosedDoorRight, k64_byteWidth, kM1_ColorNoTransparency, 161); + _displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[0], &closedDoorLeftBox, k64_byteWidth, kM1_ColorNoTransparency, 161); + _displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[4], &closedDoorRightBox, k64_byteWidth, kM1_ColorNoTransparency, 161); _displayMan->f436_STARTEND_FadeToPalette(g20_PalEntrance); } } // End of namespace DM -- cgit v1.2.3 From 19317e631c464e00522b4f24c9d98f77ee771985 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 31 Jul 2016 22:00:17 +0200 Subject: DM: Some renaming in f173_setCurrentMap --- engines/dm/dungeonman.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index da7d2dafa0..684e81d1f1 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -377,13 +377,13 @@ DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine) { _g282_dungeonColumCount = 0; _g281_dungeonMapsFirstColumnIndex = nullptr; - _g282_dungeonColumCount = 0; _g280_dungeonColumnsCumulativeSquareThingCount = nullptr; _g283_squareFirstThings = nullptr; _g260_dungeonTextData = nullptr; for (uint16 i = 0; i < 16; ++i) _g284_thingData[i] = nullptr; + _g279_dungeonMapData = nullptr; _g308_partyDir = (Direction)0; _g306_partyMapX = 0; @@ -540,7 +540,6 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) { if (_vm->_g298_newGame) f455_decompressDungeonFile(); - Common::ReadStream *dunDataStream = nullptr; if (file) { // if loading a save dunDataStream = file; @@ -627,37 +626,38 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) { for (uint16 i = 0; i < columCount; ++i) _g280_dungeonColumnsCumulativeSquareThingCount[i] = dunDataStream->readUint16BE(); - - // load sqaure first things + // load square first things if (!_vm->_g523_restartGameRequest) { delete[] _g283_squareFirstThings; _g283_squareFirstThings = new Thing[_g278_dungeonFileHeader._squareFirstThingCount]; } + for (uint16 i = 0; i < actualSquareFirstThingCount; ++i) _g283_squareFirstThings[i].set(dunDataStream->readUint16BE()); - if (_vm->_g298_newGame) + + if (_vm->_g298_newGame) { for (uint16 i = 0; i < 300; ++i) _g283_squareFirstThings[actualSquareFirstThingCount + i] = Thing::_none; - + } // load text data if (!_vm->_g523_restartGameRequest) { delete[] _g260_dungeonTextData; _g260_dungeonTextData = new uint16[_g278_dungeonFileHeader._textDataWordCount]; } + for (uint16 i = 0; i < _g278_dungeonFileHeader._textDataWordCount; ++i) _g260_dungeonTextData[i] = dunDataStream->readUint16BE(); - if (_vm->_g298_newGame) _vm->_timeline->_g369_eventMaxCount = 100; // load things for (uint16 thingType = k0_DoorThingType; thingType < k16_ThingTypeTotal; ++thingType) { uint16 thingCount = _g278_dungeonFileHeader._thingCounts[thingType]; - if (_vm->_g298_newGame) { + if (_vm->_g298_newGame) _g278_dungeonFileHeader._thingCounts[thingType] = MIN((thingType == k15_ExplosionThingType) ? 768 : 1024, thingCount + g236_AdditionalThingCounts[thingType]); - } + uint16 thingStoreWordCount = g235_ThingDataWordCount[thingType]; if (thingStoreWordCount == 0) @@ -689,9 +689,9 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) { if (_vm->_g298_newGame) { if ((thingType == k4_GroupThingType) || thingType >= k14_ProjectileThingType) _vm->_timeline->_g369_eventMaxCount += _g278_dungeonFileHeader._thingCounts[thingType]; - for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) { + + for (uint16 i = 0; i < g236_AdditionalThingCounts[thingType]; ++i) (_g284_thingData[thingType] + (thingCount + i) * thingStoreWordCount)[0] = Thing::_none.toUint16(); - } } } @@ -704,7 +704,6 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) { for (uint32 i = 0; i < _g278_dungeonFileHeader._rawMapDataSize; ++i) _g276_dungeonRawMapData[i] = dunDataStream->readByte(); - if (!_vm->_g523_restartGameRequest) { uint8 mapCount = _g278_dungeonFileHeader._mapCount; delete[] _g279_dungeonMapData; @@ -727,7 +726,7 @@ void DungeonMan::f434_loadDungeonFile(Common::InSaveFile *file) { } void DungeonMan::f173_setCurrentMap(uint16 mapIndex) { - static DoorInfo g254_doorInfo[4] = { // @ G0254_as_Graphic559_DoorInfo + static const DoorInfo doorInfo[4] = { // @ G0254_as_Graphic559_DoorInfo /* { Attributes, Defense } */ DoorInfo(3, 110), /* Door type 0 Portcullis */ DoorInfo(0, 42), /* Door type 1 Wooden door */ @@ -736,15 +735,15 @@ void DungeonMan::f173_setCurrentMap(uint16 mapIndex) { if (_g272_currMapIndex == mapIndex) return; + _g272_currMapIndex = mapIndex; _g271_currMapData = _g279_dungeonMapData[mapIndex]; _g269_currMap = _g277_dungeonMaps + mapIndex; _g273_currMapWidth = _g277_dungeonMaps[mapIndex]._width + 1; _g274_currMapHeight = _g277_dungeonMaps[mapIndex]._height + 1; - _g275_currMapDoorInfo[0] = g254_doorInfo[_g269_currMap->_doorSet0]; - _g275_currMapDoorInfo[1] = g254_doorInfo[_g269_currMap->_doorSet1]; - _g270_currMapColCumulativeSquareFirstThingCount - = &_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]]; + _g275_currMapDoorInfo[0] = doorInfo[_g269_currMap->_doorSet0]; + _g275_currMapDoorInfo[1] = doorInfo[_g269_currMap->_doorSet1]; + _g270_currMapColCumulativeSquareFirstThingCount = &_g280_dungeonColumnsCumulativeSquareThingCount[_g281_dungeonMapsFirstColumnIndex[mapIndex]]; } void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) { -- cgit v1.2.3 From 03db641f251891760a8c54426110d902d45186a3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 1 Aug 2016 00:28:38 +0200 Subject: DM: Refactor f151_getSquare --- engines/dm/dungeonman.cpp | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 684e81d1f1..c91412a0df 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -767,34 +767,28 @@ void DungeonMan::f174_setCurrentMapAndPartyMap(uint16 mapIndex) { Square DungeonMan::f151_getSquare(int16 mapX, int16 mapY) { - int16 L0248_i_Multiple; -#define AL0248_B_IsMapXInBounds L0248_i_Multiple -#define AL0248_i_SquareType L0248_i_Multiple - int16 L0249_i_Multiple; -#define AL0249_B_IsMapYInBounds L0249_i_Multiple -#define AL0249_i_SquareType L0249_i_Multiple - - AL0249_B_IsMapYInBounds = (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight); - if ((AL0248_B_IsMapXInBounds = (mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth)) && AL0249_B_IsMapYInBounds) { + bool isMapYInBounds = (mapY >= 0) && (mapY < _vm->_dungeonMan->_g274_currMapHeight); + bool isMapXInBounds = (mapX >= 0) && (mapX < _vm->_dungeonMan->_g273_currMapWidth); + + if (isMapXInBounds && isMapYInBounds) return Square(_vm->_dungeonMan->_g271_currMapData[mapX][mapY]); - } - if (AL0249_B_IsMapYInBounds) { - if (((mapX == -1) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[0][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) { + if (isMapYInBounds) { + SquareType squareType = Square(_vm->_dungeonMan->_g271_currMapData[0][mapY]).getType(); + if (((mapX == -1) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit)) return Square(k0_ElementTypeWall, k0x0004_WallEastRandOrnAllowed); - } - if (((mapX == _vm->_dungeonMan->_g273_currMapWidth) && ((AL0249_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[_vm->_dungeonMan->_g273_currMapWidth - 1][mapY]).getType()) == k1_CorridorElemType)) || (AL0249_i_SquareType == k2_ElementTypePit)) { + + squareType = Square(_vm->_dungeonMan->_g271_currMapData[_vm->_dungeonMan->_g273_currMapWidth - 1][mapY]).getType(); + if (((mapX == _vm->_dungeonMan->_g273_currMapWidth) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit)) return Square(k0_ElementTypeWall, k0x0001_WallWestRandOrnAllowed); - } - } else { - if (AL0248_B_IsMapXInBounds) { - if (((mapY == -1) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][0]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) { - return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed); - } - if (((mapY == _vm->_dungeonMan->_g274_currMapHeight) && ((AL0248_i_SquareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][_vm->_dungeonMan->_g274_currMapHeight - 1]).getType()) == k1_CorridorElemType)) || (AL0248_i_SquareType == k2_ElementTypePit)) { - return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed); - } - } + } else if (isMapXInBounds) { + SquareType squareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][0]).getType(); + if (((mapY == -1) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit)) + return Square(k0_ElementTypeWall, k0x0002_WallSouthRandOrnAllowed); + + squareType = Square(_vm->_dungeonMan->_g271_currMapData[mapX][_vm->_dungeonMan->_g274_currMapHeight - 1]).getType(); + if (((mapY == _vm->_dungeonMan->_g274_currMapHeight) && (squareType == k1_CorridorElemType)) || (squareType == k2_ElementTypePit)) + return Square(k0_ElementTypeWall, k0x0008_WallNorthRandOrnAllowed); } return Square(k0_ElementTypeWall, 0); } -- cgit v1.2.3 From a387f45d57241dbc8f96e214bb0b90a6069a75bb Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Mon, 1 Aug 2016 17:03:50 +0200 Subject: DM: Add f60_playSound --- engines/dm/dm.h | 4 +++- engines/dm/sounds.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 33c3b0336c..02def018d1 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -205,6 +205,8 @@ public: SoundData(): _byteCount(0), _firstSample(nullptr), _sampleCount(0) {} }; // @ SOUND_DATA + + class DMEngine : public Engine { void f462_startGame(); // @ F0462_START_StartGame_CPSF void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE @@ -235,7 +237,7 @@ public: void f444_endGame(bool doNotDrawCreditsOnly); // @ F0444_STARTEND_Endgame void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode) { warning(true, "STUB: f064_SOUND_RequestPlay_CPSD"); } - void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol) { warning(true, "STUB: f060_SOUND_Play"); } + void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol); void f438_STARTEND_OpenEntranceDoors() { warning(true, "STUB: f438_STARTEND_OpenEntranceDoors"); } private: diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp index 681ff6da22..cdbed462a3 100644 --- a/engines/dm/sounds.cpp +++ b/engines/dm/sounds.cpp @@ -30,6 +30,7 @@ #include "dm.h" #include "gfx.h" +#include