Skip to content

Commit

Permalink
DM: Add F0292_CHAMPION_DrawState, G0407_s_Party, M26_CHAMPION_ICON_IN…
Browse files Browse the repository at this point in the history
…DEX, several graphic indices, fix missing kPanelResurectReincaranteIndice value
  • Loading branch information
Bendegúz Nagy committed Aug 26, 2016
1 parent 2c669d4 commit c986a71
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 5 deletions.
166 changes: 165 additions & 1 deletion engines/dm/champion.cpp
Expand Up @@ -364,4 +364,168 @@ uint16 ChampionMan::getMaximumLoad(Champion *champ) {
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;
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);
}
}
3 changes: 3 additions & 0 deletions engines/dm/champion.h
Expand Up @@ -401,13 +401,16 @@ class ChampionMan {
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
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
};


Expand Down
1 change: 1 addition & 0 deletions engines/dm/dm.h
Expand Up @@ -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,
Expand Down
15 changes: 11 additions & 4 deletions engines/dm/gfx.h
Expand Up @@ -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];
Expand All @@ -49,7 +56,7 @@ class Box {
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);
Expand All @@ -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) {}
};

Expand Down

0 comments on commit c986a71

Please sign in to comment.