diff options
-rw-r--r-- | engines/dm/TODOs/todo.txt | 7 | ||||
-rw-r--r-- | engines/dm/champion.cpp | 88 | ||||
-rw-r--r-- | engines/dm/champion.h | 2 | ||||
-rw-r--r-- | engines/dm/dungeonman.cpp | 54 | ||||
-rw-r--r-- | engines/dm/eventman.cpp | 19 | ||||
-rw-r--r-- | 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 }; |