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