aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/dm/champion.cpp43
-rw-r--r--engines/dm/eventman.cpp26
-rw-r--r--engines/dm/menus.cpp102
-rw-r--r--engines/dm/menus.h4
4 files changed, 90 insertions, 85 deletions
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 7d696a3fe3..6385547433 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1495,19 +1495,19 @@ void ChampionMan::championKill(uint16 champIndex) {
_vm->_displayMan->fillScreenBox(_boxChampionIcons[curChampionIconIndex], k0_ColorBlack);
drawChampionState((ChampionIndex)champIndex);
- int16 aliveChampionIndex;
- for (aliveChampionIndex = k0_ChampionFirst, curChampion = _champions; aliveChampionIndex < _partyChampionCount; aliveChampionIndex++, curChampion++) {
- if (curChampion->_currHealth)
- break;
- }
+ ChampionIndex aliveChampionIndex;
+ int idx = 0;
+ for (curChampion = _champions; (idx < _partyChampionCount) && (curChampion->_currHealth == 0); idx++, curChampion++)
+ ;
+ aliveChampionIndex = (ChampionIndex)idx;
if (aliveChampionIndex == _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) */
_partyDead = true;
return;
}
if (champIndex == _leaderIndex)
- _vm->_eventMan->commandSetLeader((ChampionIndex)aliveChampionIndex);
+ _vm->_eventMan->commandSetLeader(aliveChampionIndex);
if (champIndex == _magicCasterChampionIndex)
_vm->_menuMan->setMagicCasterAndDrawSpellArea(aliveChampionIndex);
@@ -1829,28 +1829,31 @@ ChampionIndex ChampionMan::getIndexInCell(int16 cell) {
void ChampionMan::resetDataToStartGame() {
if (!_vm->_newGameFl) {
- Thing L0787_T_Thing;
- if ((L0787_T_Thing = _leaderHandObject) == Thing::_none) {
+ Thing handThing = _leaderHandObject;
+ if (handThing == Thing::_none) {
_leaderEmptyHanded = true;
_leaderHandObjectIconIndex = kM1_IconIndiceNone;
_vm->_eventMan->setMousePointer();
- } else {
- 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 = _champions;
- int16 L0785_i_ChampionIndex;
- for (L0785_i_ChampionIndex = k0_ChampionFirst; L0785_i_ChampionIndex < _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);
+ } else
+ putObjectInLeaderHand(handThing, true); /* This call will add the weight of the leader hand object to the Load of the leader a first time */
+
+ Champion *curChampion = _champions;
+ for (int16 idx = 0; idx < _partyChampionCount; idx++, curChampion++) {
+ clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+ setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
}
drawAllChampionStates();
- if ((L0785_i_ChampionIndex = _leaderIndex) != kM1_ChampionNone) {
+
+ ChampionIndex championIndex = _leaderIndex;
+ if (championIndex != kM1_ChampionNone) {
_leaderIndex = kM1_ChampionNone;
- _vm->_eventMan->commandSetLeader((ChampionIndex)L0785_i_ChampionIndex);
+ _vm->_eventMan->commandSetLeader(championIndex);
}
- if ((L0785_i_ChampionIndex = _magicCasterChampionIndex) != kM1_ChampionNone) {
+
+ championIndex = _magicCasterChampionIndex;
+ if (championIndex != kM1_ChampionNone) {
_magicCasterChampionIndex = kM1_ChampionNone;
- _vm->_menuMan->setMagicCasterAndDrawSpellArea(L0785_i_ChampionIndex);
+ _vm->_menuMan->setMagicCasterAndDrawSpellArea(championIndex);
}
return;
}
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 2c6ee2bab4..8027b30bdd 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1497,43 +1497,43 @@ void EventManager::mouseProcessCommands125To128_clickOnChampionIcon(uint16 champ
}
void EventManager::commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY) {
- int16 championIndex = kM1_ChampionNone;
+ ChampionIndex championIndex = kM1_ChampionNone;
if (posY <= 48) {
switch (_vm->_championMan->_magicCasterChampionIndex) {
case 0:
if ((posX >= 280) && (posX <= 291))
- championIndex = 1;
+ championIndex = k1_ChampionSecond;
else if ((posX >= 294) && (posX <= 305))
- championIndex = 2;
+ championIndex = k2_ChampionThird;
else if (posX >= 308)
- championIndex = 3;
+ championIndex = k3_ChampionFourth;
break;
case 1:
if ((posX >= 233) && (posX <= 244))
- championIndex = 0;
+ championIndex = k0_ChampionFirst;
else if ((posX >= 294) && (posX <= 305))
- championIndex = 2;
+ championIndex = k2_ChampionThird;
else if (posX >= 308)
- championIndex = 3;
+ championIndex = k3_ChampionFourth;
break;
case 2:
if ((posX >= 233) && (posX <= 244))
- championIndex = 0;
+ championIndex = k0_ChampionFirst;
else if ((posX >= 247) && (posX <= 258))
- championIndex = 1;
+ championIndex = k1_ChampionSecond;
else if (posX >= 308)
- championIndex = 3;
+ championIndex = k3_ChampionFourth;
break;
case 3:
if ((posX >= 247) && (posX <= 258))
- championIndex = 1;
+ championIndex = k1_ChampionSecond;
else if ((posX >= 261) && (posX <= 272))
- championIndex = 2;
+ championIndex = k2_ChampionThird;
else if (posX <= 244)
- championIndex = 0;
+ championIndex = k0_ChampionFirst;
break;
default:
break;
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index f0f7930795..17c08a4daa 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -283,7 +283,7 @@ void MenuMan::drawActionArea() {
}
const char *MenuMan::getActionName(ChampionAction actionIndex) {
- const char *g490_ChampionActionNames[44] = { // @ G0490_ac_Graphic560_ActionNames
+ const char *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",
@@ -294,7 +294,7 @@ const char *MenuMan::getActionName(ChampionAction actionIndex) {
"BRANDISH", "THROW", "FUSE"
};
- return (actionIndex == k255_ChampionActionNone) ? "" : g490_ChampionActionNames[actionIndex];
+ return (actionIndex == k255_ChampionActionNone) ? "" : championActionNames[actionIndex];
}
void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
@@ -308,55 +308,61 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
int16 champHP3 = _vm->_championMan->_champions[3]._currHealth;
_vm->_eventMan->showMouse();
_vm->_displayMan->fillScreenBox(boxSpellAreaControls, k0_ColorBlack);
+
switch (champIndex) {
case 0:
_vm->_eventMan->highlightScreenBox(233, 277, 42, 49);
_vm->_textMan->printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
if (_vm->_championMan->_partyChampionCount > 1) {
- if (champHP1) {
+ if (champHP1)
_vm->_eventMan->highlightScreenBox(280, 291, 42, 48);
- }
-T0393002:
+
if (_vm->_championMan->_partyChampionCount > 2) {
- if (champHP2) {
+ if (champHP2)
_vm->_eventMan->highlightScreenBox(294, 305, 42, 48);
- }
-T0393003:
- if (_vm->_championMan->_partyChampionCount > 3) {
- if (champHP3) {
- _vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
- }
- }
+
+ if ((_vm->_championMan->_partyChampionCount > 3) && champHP3)
+ _vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
}
}
break;
case 1:
- if (champHP0) {
+ if (champHP0)
_vm->_eventMan->highlightScreenBox(233, 244, 42, 48);
- }
+
_vm->_eventMan->highlightScreenBox(247, 291, 42, 49);
_vm->_textMan->printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
- goto T0393002;
+ if (_vm->_championMan->_partyChampionCount > 2) {
+ if (champHP2)
+ _vm->_eventMan->highlightScreenBox(294, 305, 42, 48);
+
+ if ((_vm->_championMan->_partyChampionCount > 3) && champHP3)
+ _vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
+ }
+ break;
case 2:
- if (champHP0) {
+ if (champHP0)
_vm->_eventMan->highlightScreenBox(233, 244, 42, 48);
- }
- if (champHP1) {
+
+ if (champHP1)
_vm->_eventMan->highlightScreenBox(247, 258, 42, 48);
- }
+
_vm->_eventMan->highlightScreenBox(261, 305, 42, 49);
_vm->_textMan->printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
- goto T0393003;
+ if ((_vm->_championMan->_partyChampionCount > 3) && champHP3)
+ _vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
+ break;
+
case 3:
- if (champHP0) {
+ if (champHP0)
_vm->_eventMan->highlightScreenBox(233, 244, 42, 48);
- }
- if (champHP1) {
+
+ if (champHP1)
_vm->_eventMan->highlightScreenBox(247, 258, 42, 48);
- }
- if (champHP2) {
+
+ if (champHP2)
_vm->_eventMan->highlightScreenBox(261, 272, 42, 48);
- }
+
_vm->_eventMan->highlightScreenBox(275, 319, 42, 49);
_vm->_textMan->printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
break;
@@ -366,44 +372,42 @@ T0393003:
_vm->_eventMan->hideMouse();
}
-#define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
-#define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
-
void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
static Box boxSpellAreaLine(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine
- char L1204_ac_SpellSymbolString[2] = {'\0', '\0'};
- Champion *L1203_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+ char spellSymbolString[2] = {'\0', '\0'};
+ Champion *magicChampion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
_vm->_displayMan->_useByteBoxCoordinates = false;
_vm->_displayMan->blitToBitmap(_bitmapSpellAreaLines, _bitmapSpellAreaLine, boxSpellAreaLine, 0, 12, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
int16 x = 1;
- char character = 96 + (6 * L1203_ps_Champion->_symbolStep);
+ char character = 96 + (6 * magicChampion->_symbolStep);
for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
- L1204_ac_SpellSymbolString[0] = character++;
- _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 48, x += 14, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
+ spellSymbolString[0] = character++;
+ x += 14;
+ _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 48, x, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
}
} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
_vm->_displayMan->_useByteBoxCoordinates = false;
_vm->_displayMan->blitToBitmap(_bitmapSpellAreaLines, _bitmapSpellAreaLine, boxSpellAreaLine, 0, 24, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
int16 x = 8;
for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
- if ((L1204_ac_SpellSymbolString[0] = L1203_ps_Champion->_symbols[symbolIndex]) == '\0')
+ if ((spellSymbolString[0] = magicChampion->_symbols[symbolIndex]) == '\0')
break;
- _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 48, x += 9, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
+ x += 9;
+ _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 48, x, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
}
}
}
-void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
+void MenuMan::setMagicCasterAndDrawSpellArea(ChampionIndex champIndex) {
static Box boxSpellAreaLine2(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2
static Box boxSpellAreaLine3(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3
- Champion *L1213_ps_Champion;
-
- if ((champIndex == _vm->_championMan->_magicCasterChampionIndex) || ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_champions[champIndex]._currHealth)) {
+ if ((champIndex == _vm->_championMan->_magicCasterChampionIndex)
+ || ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_champions[champIndex]._currHealth))
return;
- }
+
if (_vm->_championMan->_magicCasterChampionIndex == kM1_ChampionNone) {
_vm->_eventMan->showMouse();
_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &_boxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
@@ -417,7 +421,8 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
_vm->_eventMan->hideMouse();
return;
}
- L1213_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex = (ChampionIndex)champIndex];
+ _vm->_championMan->_magicCasterChampionIndex = champIndex;
+ Champion *L1213_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
_vm->_eventMan->showMouse();
drawSpellAreaControls((ChampionIndex)champIndex);
@@ -428,23 +433,18 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
}
void MenuMan::drawEnabledMenus() {
- int16 L1462_i_Multiple;
-#define AL1462_i_MagicCasterChampionIndex L1462_i_Multiple
-#define AL1462_i_InventoryChampionOrdinal L1462_i_Multiple
-
-
if (_vm->_championMan->_partyIsSleeping) {
_vm->_eventMan->drawSleepScreen();
_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
} else {
- AL1462_i_MagicCasterChampionIndex = _vm->_championMan->_magicCasterChampionIndex;
+ ChampionIndex casterChampionIndex = _vm->_championMan->_magicCasterChampionIndex;
_vm->_championMan->_magicCasterChampionIndex = kM1_ChampionNone; /* Force next function to draw the spell area */
- setMagicCasterAndDrawSpellArea(AL1462_i_MagicCasterChampionIndex);
+ setMagicCasterAndDrawSpellArea(casterChampionIndex);
if (!_vm->_championMan->_actingChampionOrdinal) {
_actionAreaContainsIcons = true;
}
drawActionArea();
- AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_inventoryChampionOrdinal;
+ int16 AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_inventoryChampionOrdinal;
if (AL1462_i_InventoryChampionOrdinal) {
_vm->_inventoryMan->_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
_vm->_inventoryMan->toggleInventory((ChampionIndex)_vm->ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 1d37651bf8..ab6e00269a 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -36,6 +36,8 @@ namespace DM {
#define kM1_damageCantReach -1 // @ CM1_DAMAGE_CANT_REACH
#define kM2_damageNoAmmunition -2 // @ CM2_DAMAGE_NO_AMMUNITION
+#define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
+#define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
#define k0x8000_hitNonMaterialCreatures 0x8000 // @ MASK0x8000_HIT_NON_MATERIAL_CREATURES
@@ -90,7 +92,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
+ void setMagicCasterAndDrawSpellArea(ChampionIndex champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea
void drawEnabledMenus(); // @ F0457_START_DrawEnabledMenus_CPSF
int16 getClickOnSpellCastResult(); // @ F0408_MENUS_GetClickOnSpellCastResult
int16 getChampionSpellCastResult(uint16 champIndex); // @ F0412_MENUS_GetChampionSpellCastResult