1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#include "objectman.h"
#include "dungeonman.h"
namespace DM {
int16 gIconGraphicHeight[7] = {32, 32, 32, 32, 32, 32, 32}; // @ K0077_ai_IconGraphicHeight
int16 gIconGraphicFirstIndex[7] = { // G0026_ai_Graphic562_IconGraphicFirstIconIndex
0, /* First icon index in graphic #42 */
32, /* First icon index in graphic #43 */
64, /* First icon index in graphic #44 */
96, /* First icon index in graphic #45 */
128, /* First icon index in graphic #46 */
160, /* First icon index in graphic #47 */
192}; /* First icon index in graphic #48 */
ObjectMan::ObjectMan(DMEngine *vm) : _vm(vm) {}
IconIndice ObjectMan::getObjectType(Thing thing) {
if (thing == Thing::_thingNone)
return kIconIndiceNone;
int16 objectInfoIndex = _vm->_dungeonMan->getObjectInfoIndex(thing);
if (objectInfoIndex != -1) {
objectInfoIndex = gObjectInfo[objectInfoIndex]._type;
}
return (IconIndice)objectInfoIndex;
}
byte gChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType
IconIndice ObjectMan::getIconIndex(Thing thing) {
IconIndice iconIndex = getObjectType(thing);
if ((iconIndex != kIconIndiceNone) &&
((iconIndex < kIconIndiceWeaponDagger) &&(iconIndex >= kIconIndiceJunkCompassNorth)) || // < instead of <= is no error
((iconIndex >= kIconIndicePotionMaPotionMonPotion) && (iconIndex <= kIconIndicePotionWaterFlask)) ||
(iconIndex == kIconIndicePotionEmptyFlask)
) {
uint16 *rawType = _vm->_dungeonMan->getThingData(thing);
switch (iconIndex) {
case kIconIndiceJunkCompassNorth:
iconIndex = (IconIndice)(iconIndex + _vm->_dungeonMan->_currMap._partyDir);
break;
case kIconIndiceWeaponTorchUnlit: {
Weapon weapon(rawType);
if (weapon.isLit()) {
iconIndex = (IconIndice)(iconIndex + gChargeCountToTorchType[weapon.getChargeCount()]);
}
break;
}
case kIconIndiceScrollOpen:
if (Scroll(rawType).getClosed()) {
iconIndex = (IconIndice)(iconIndex + 1);
}
break;
case kIconIndiceJunkWater:
case kIconIndiceJunkIllumuletUnequipped:
case kIconIndiceJunkJewelSymalUnequipped:
if (Junk(rawType).getChargeCount()) {
iconIndex = (IconIndice)(iconIndex + 1);
}
break;
case kIconIndiceWeaponBoltBladeStormEmpty:
case kIconIndiceWeaponFlamittEmpty:
case kIconIndiceWeaponStormringEmpty:
case kIconIndiceWeaponFuryRaBladeEmpty:
case kIconIndiceWeaponEyeOfTimeEmpty:
case kIconIndiceWeaponStaffOfClawsEmpty:
if (Weapon(rawType).getChargeCount()) {
iconIndex = (IconIndice)(iconIndex + 1);
}
break;
}
}
return iconIndex;
}
void ObjectMan::extractIconFromBitmap(uint16 iconIndex, byte *destBitmap) {
int16 i;
for (i = 0; i < 7; ++i)
if (gIconGraphicFirstIndex[i] > iconIndex)
break;
--i;
byte *srcBitmap = _vm->_displayMan->getBitmap(kObjectIcons_000_TO_031 + i);
iconIndex -= gIconGraphicFirstIndex[i];
_vm->_displayMan->_useByteBoxCoordinates = true;
_vm->_displayMan->blitToBitmap(srcBitmap, 256, (iconIndex & 0x000F) << 4, iconIndex & 0x0FF0, destBitmap, 16, 0, 16, 0, 16, kColorNoTransparency);
}
}
|