Skip to content

Commit

Permalink
DM: Add F0355_INVENTORY_Toggle_CPSE
Browse files Browse the repository at this point in the history
  • Loading branch information
Bendegúz Nagy committed Aug 26, 2016
1 parent e64e352 commit e9a4e81
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 4 deletions.
2 changes: 1 addition & 1 deletion engines/dm/gfx.cpp
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions engines/dm/gfx.h
Expand Up @@ -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];
Expand Down Expand Up @@ -295,7 +296,7 @@ class DisplayMan {

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);
Expand Down
79 changes: 78 additions & 1 deletion 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");
}


}
3 changes: 3 additions & 0 deletions engines/dm/inventory.h
@@ -1,5 +1,6 @@
#include "dm.h"
#include "gfx.h"
#include "champion.h"



Expand All @@ -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
};

}

0 comments on commit e9a4e81

Please sign in to comment.