1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22 
23 /*
24 * Based on the Reverse Engineering work of Christophe Fontanel,
25 * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
26 */
27 
28 #ifndef DM_DUNGEONMAN_H
29 #define DM_DUNGEONMAN_H
30 
31 #include "dm/dm.h"
32 #include "dm/gfx.h"
33 
34 namespace DM {
35 
36 /* Object info */
37 enum ObjectInfoIndexConst {
38 	kDMObjectInfoIndexFirstScroll = 0, // @ C000_OBJECT_INFO_INDEX_FIRST_SCROLL
39 	kDMObjectInfoIndexFirstContainer = 1, // @ C001_OBJECT_INFO_INDEX_FIRST_CONTAINER
40 	kDMObjectInfoIndexFirstPotion = 2, // @ C002_OBJECT_INFO_INDEX_FIRST_POTION
41 	kDMObjectInfoIndexFirstWeapon = 23, // @ C023_OBJECT_INFO_INDEX_FIRST_WEAPON
42 	kDMObjectInfoIndexFirstArmour = 69, // @ C069_OBJECT_INFO_INDEX_FIRST_ARMOUR
43 	kDMObjectInfoIndexFirstJunk = 127 // @ C127_OBJECT_INFO_INDEX_FIRST_JUNK
44 };
45 
46 #define kDMMapXNotOnASquare -1 // @ CM1_MAPX_NOT_ON_A_SQUARE
47 
48 enum ElementType {
49 	kDMElementTypeChampion = -2, // @ CM2_ELEMENT_CHAMPION /* Values -2 and -1 are only used as projectile impact types */
50 	kDMElementTypeCreature = -1, // @ CM1_ELEMENT_CREATURE
51 	kDMElementTypeWall = 0, // @ C00_ELEMENT_WALL /* Values 0-6 are used as square types and projectile impact types. Values 0-2 and 5-6 are also used for square aspect */
52 	kDMElementTypeCorridor = 1, // @ C01_ELEMENT_CORRIDOR
53 	kDMElementTypePit = 2, // @ C02_ELEMENT_PIT
54 	kDMElementTypeStairs = 3, // @ C03_ELEMENT_STAIRS
55 	kDMElementTypeDoor = 4, // @ C04_ELEMENT_DOOR
56 	kDMElementTypeTeleporter = 5, // @ C05_ELEMENT_TELEPORTER
57 	kDMElementTypeFakeWall = 6, // @ C06_ELEMENT_FAKEWALL
58 	kDMElementTypeDoorSide = 16, // @ C16_ELEMENT_DOOR_SIDE /* Values 16-19 are only used for square aspect */
59 	kDMElementTypeDoorFront = 17, // @ C17_ELEMENT_DOOR_FRONT
60 	kDMElementTypeStairsSide = 18, // @ C18_ELEMENT_STAIRS_SIDE
61 	kDMElementTypeStairsFront = 19  // @ C19_ELEMENT_STAIRS_FRONT
62 };
63 
64 enum ObjectAllowedSlot {
65 	kDMMaskMouth = 0x0001, // @ MASK0x0001_MOUTH
66 	kDMMaskHead = 0x0002, // @ MASK0x0002_HEAD
67 	kDMMaskNeck = 0x0004, // @ MASK0x0004_NECK
68 	kDMMaskTorso = 0x0008, // @ MASK0x0008_TORSO
69 	kDMMaskLegs = 0x0010, // @ MASK0x0010_LEGS
70 	kDMMaskFeet = 0x0020, // @ MASK0x0020_FEET
71 	kDMMaskQuiverLine1 = 0x0040, // @ MASK0x0040_QUIVER_LINE1
72 	kDMMaskQuiverLine2 = 0x0080, // @ MASK0x0080_QUIVER_LINE2
73 	kDMMaskPouchPassAndThroughDoors = 0x0100, // @ MASK0x0100_POUCH_PASS_AND_THROUGH_DOORS
74 	kDMMaskHands = 0x0200, // @ MASK0x0200_HANDS
75 	kDMMaskContainer = 0x0400, // @ MASK0x0400_CONTAINER
76 	kDMMaskFootprints = 0x8000, // @ MASK0x8000_FOOTPRINTS
77 	kDMMaskRandomDrop = 0x8000 // @ MASK0x8000_RANDOM_DROP
78 };
79 
80 enum ArmourAttribute {
81 	kDMArmourAttributeShield = 0x0080, // @ MASK0x0080_IS_A_SHIELD
82 	kDMArmourAttributeSharpDefense = 0x0007 // @ MASK0x0007_SHARP_DEFENSE
83 };
84 
85 enum WeaponClass {
86 	kDMWeaponClassNone = -1,
87 /* Class 0: SWING weapons */
88 	kDMWeaponClassSwingWeapon = 0, // @ C000_CLASS_SWING_WEAPON
89 /* Class 1 to 15: THROW weapons */
90 	kDMWeaponClassDaggerAndAxes = 2, // @ C002_CLASS_DAGGER_AND_AXES
91 	kDMWeaponClassBowAmmunition = 10, // @ C010_CLASS_BOW_AMMUNITION
92 	kDMWeaponClassSlingAmmunition = 11, // @ C011_CLASS_SLING_AMMUNITION
93 	kDMWeaponClassPoisinDart = 12, // @ C012_CLASS_POISON_DART
94 /* Class 16 to 111: SHOOT weapons */
95 	kDMWeaponClassFirstBow = 16, // @ C016_CLASS_FIRST_BOW
96 	kDMWeaponClassLastBow = 31, // @ C031_CLASS_LAST_BOW
97 	kDMWeaponClassFirstSling = 32, // @ C032_CLASS_FIRST_SLING
98 	kDMWeaponClassLastSling = 47, // @ C047_CLASS_LAST_SLING
99 /* Class 112 to 255: Magic and special weapons */
100 	kDMWeaponClassFirstMagicWeapon = 112 // @ C112_CLASS_FIRST_MAGIC_WEAPON
101 };
102 
103 enum TextType {
104 	/* Used for text on walls */
105 	kDMTextTypeInscription = 0, // @ C0_TEXT_TYPE_INSCRIPTION
106 	/* Used for messages displayed when the party walks on a square */
107 	kDMTextTypeMessage = 1, // @ C1_TEXT_TYPE_MESSAGE
108 	/* Used for text on scrolls and champion information */
109 	kDMTextTypeScroll = 2 // @ C2_TEXT_TYPE_SCROLL
110 };
111 
112 enum SquareAspect {
113 	kDMSquareAspectElement = 0, // @ C0_ELEMENT
114 	kDMSquareAspectFirstGroupOrObject = 1, // @ C1_FIRST_GROUP_OR_OBJECT
115 	kDMSquareAspectRightWallOrnOrd = 2, // @ C2_RIGHT_WALL_ORNAMENT_ORDINAL
116 	kDMSquareFrontWallOrnOrd = 3, // @ C3_FRONT_WALL_ORNAMENT_ORDINAL
117 	kDMSquareAspectLeftWallOrnOrd = 4, // @ C4_LEFT_WALL_ORNAMENT_ORDINAL
118 	kDMSquareAspectPitInvisible = 2, // @ C2_PIT_INVISIBLE
119 	kDMSquareAspectTeleporterVisible = 2, // @ C2_TELEPORTER_VISIBLE
120 	kDMSquareAspectStairsUp = 2, // @ C2_STAIRS_UP
121 	kDMSquareAspectDoorState = 2, // @ C2_DOOR_STATE
122 	kDMSquareAspectDoorThingIndex = 3, // @ C3_DOOR_THING_INDEX
123 	kDMSquareAspectFloorOrn = 4 // @ C4_FLOOR_ORNAMENT_ORDINAL
124 };
125 
126 #define kDMImmuneToFire 15 // @ C15_IMMUNE_TO_FIRE
127 #define kDMImmuneToPoison 15 // @ C15_IMMUNE_TO_POISON
128 
129 enum TeleporterScope {
130 	kDMTeleporterScopeCreatures = 1, // @ MASK0x0001_SCOPE_CREATURES
131 	kDMTeleporterScopeObjectsOrParty = 2 // @ MASK0x0002_SCOPE_OBJECTS_OR_PARTY
132 };
133 
134 enum SensorType {
135 	kDMSensorDisabled = 0, // @ C000_SENSOR_DISABLED    /* Never triggered, may be used for a floor or wall ornament */
136 	kDMSensorFloorTheronPartyCreatureObj = 1, // @ C001_SENSOR_FLOOR_THERON_PARTY_CREATURE_OBJECT    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
137 	kDMSensorFloorTheronPartyCreature = 2, // @ C002_SENSOR_FLOOR_THERON_PARTY_CREATURE    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
138 	kDMSensorFloorParty = 3, // @ C003_SENSOR_FLOOR_PARTY    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
139 	kDMSensorFloorObj = 4, // @ C004_SENSOR_FLOOR_OBJECT    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
140 	kDMSensorFloorPartyOnStairs = 5, // @ C005_SENSOR_FLOOR_PARTY_ON_STAIRS    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
141 	kDMSensorFloorGroupGenerator = 6, // @ C006_SENSOR_FLOOR_GROUP_GENERATOR    /* Triggered by event F0245_TIMELINE_ProcessEvent5_Square_Corridor */
142 	kDMSensorFloorCreature = 7, // @ C007_SENSOR_FLOOR_CREATURE    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
143 	kDMSensorFloorPartyPossession = 8, // @ C008_SENSOR_FLOOR_PARTY_POSSESSION    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
144 	kDMSensorFloorVersionChecker = 9, // @ C009_SENSOR_FLOOR_VERSION_CHECKER    /* Triggered by party/thing F0276_SENSOR_ProcessThingAdditionOrRemoval */
145 	kDMSensorWallOrnClick = 1, // @ C001_SENSOR_WALL_ORNAMENT_CLICK    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
146 	kDMSensorWallOrnClickWithAnyObj = 2, // @ C002_SENSOR_WALL_ORNAMENT_CLICK_WITH_ANY_OBJECT    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
147 	kDMSensorWallOrnClickWithSpecObj = 3, // @ C003_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
148 	kDMSensorWallOrnClickWithSpecObjRemoved = 4, // @ C004_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
149 	kDMSensorWallAndOrGate = 5, // @ C005_SENSOR_WALL_AND_OR_GATE    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
150 	kDMSensorWallCountdown = 6, // @ C006_SENSOR_WALL_COUNTDOWN    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
151 	kDMSensorWallSingleProjLauncherNewObj = 7, // @ C007_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_NEW_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
152 	kDMSensorWallSingleProjLauncherExplosion = 8, // @ C008_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_EXPLOSION    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
153 	kDMSensorWallDoubleProjLauncherNewObj = 9, // @ C009_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_NEW_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
154 	kDMSensorWallDoubleProjLauncherExplosion = 10, // @ C010_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_EXPLOSION    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
155 	kDMSensorWallOrnClickWithSpecObjRemovedRotateSensors = 11, // @ C011_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_ROTATE_SENSORS   /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
156 	kDMSensorWallObjGeneratorRotateSensors = 12, // @ C012_SENSOR_WALL_OBJECT_GENERATOR_ROTATE_SENSORS    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
157 	kDMSensorWallSingleObjStorageRotateSensors = 13, // @ C013_SENSOR_WALL_SINGLE_OBJECT_STORAGE_ROTATE_SENSORS    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
158 	kDMSensorWallSingleProjLauncherSquareObj = 14, // @ C014_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
159 	kDMSensorWallDoubleProjLauncherSquareObj = 15, // @ C015_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
160 	kDMSensorWallObjExchanger = 16, // @ C016_SENSOR_WALL_OBJECT_EXCHANGER    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
161 	kDMSensorWallOrnClickWithSpecObjRemovedSensor = 17, // @ C017_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_REMOVE_SENSOR    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
162 	kDMSensorWallEndGame = 18, // @ C018_SENSOR_WALL_END_GAME    /* Triggered by event F0248_TIMELINE_ProcessEvent6_Square_Wall */
163 	kDMSensorWallChampionPortrait = 127 // @ C127_SENSOR_WALL_CHAMPION_PORTRAIT    /* Triggered by player click F0275_SENSOR_IsTriggeredByClickOnWall */
164 };
165 
166 enum WeaponType {
167 	kDMWeaponTorch = 2, // @ C02_WEAPON_TORCH
168 	kDMWeaponDagger = 8, // @ C08_WEAPON_DAGGER
169 	kDMWeaponFalchion = 9, // @ C09_WEAPON_FALCHION
170 	kDMWeaponSword = 10, // @ C10_WEAPON_SWORD
171 	kDMWeaponClub = 23, // @ C23_WEAPON_CLUB
172 	kDMWeaponStoneClub = 24, // @ C24_WEAPON_STONE_CLUB
173 	kDMWeaponArrow = 27, // @ C27_WEAPON_ARROW
174 	kDMWeaponSlayer = 28, // @ C28_WEAPON_SLAYER
175 	kDMWeaponRock = 30, // @ C30_WEAPON_ROCK
176 	kDMWeaponPoisonDart = 31, // @ C31_WEAPON_POISON_DART
177 	kDMWeaponThrowingStar = 32 // @ C32_WEAPON_THROWING_STAR
178 };
179 
180 enum ArmourType {
181 	kDMArmourWoodenShield = 30, // @ C30_ARMOUR_WOODEN_SHIELD
182 	kDMArmourArmet = 38, // @ C38_ARMOUR_ARMET
183 	kDMArmourTorsoPlate = 39, // @ C39_ARMOUR_TORSO_PLATE
184 	kDMArmourLegPlate = 40, // @ C40_ARMOUR_LEG_PLATE
185 	kDMArmourFootPlate = 41 // @ C41_ARMOUR_FOOT_PLATE
186 };
187 
188 enum PotionType {
189 	kDMPotionTypeVen = 3, // @ C03_POTION_VEN_POTION,
190 	kDMPotionTypeRos = 6, // @ C06_POTION_ROS_POTION,
191 	kDMPotionTypeKu = 7, // @ C07_POTION_KU_POTION,
192 	kDMPotionTypeDane = 8, // @ C08_POTION_DANE_POTION,
193 	kDMPotionTypeNeta = 9, // @ C09_POTION_NETA_POTION,
194 	kDMPotionTypeAntivenin = 10, // @ C10_POTION_ANTIVENIN,
195 	kDMPotionTypeMon = 11, // @ C11_POTION_MON_POTION,
196 	kDMPotionTypeYa = 12, // @ C12_POTION_YA_POTION,
197 	kDMPotionTypeEe = 13, // @ C13_POTION_EE_POTION,
198 	kDMPotionTypeVi = 14, // @ C14_POTION_VI_POTION,
199 	kDMPotionTypeWaterFlask = 15, // @ C15_POTION_WATER_FLASK,
200 	kDMPotionTypeFulBomb = 19, // @ C19_POTION_FUL_BOMB,
201 	kDMPotionTypeEmptyFlask = 20 // @ C20_POTION_EMPTY_FLASK,
202 };
203 
204 enum JunkType {
205 	kDMJunkTypeWaterskin = 1, // @ C01_JUNK_WATERSKIN,
206 	kDMJunkTypeBones = 5, // @ C05_JUNK_BONES,
207 	kDMJunkTypeBoulder = 25, // @ C25_JUNK_BOULDER,
208 	kDMJunkTypeScreamerSlice = 33, // @ C33_JUNK_SCREAMER_SLICE,
209 	kDMJunkTypeWormRound = 34, // @ C34_JUNK_WORM_ROUND,
210 	kDMJunkTypeDrumstickShank = 35, // @ C35_JUNK_DRUMSTICK_SHANK,
211 	kDMJunkTypeDragonSteak = 36, // @ C36_JUNK_DRAGON_STEAK,
212 	kDMJunkTypeMagicalBoxBlue = 42, // @ C42_JUNK_MAGICAL_BOX_BLUE,
213 	kDMJunkTypeMagicalBoxGreen = 43, // @ C43_JUNK_MAGICAL_BOX_GREEN,
214 	kDMJunkTypeZokathra = 51 // @ C51_JUNK_ZOKATHRA,
215 };
216 
217 enum ExplosionType {
218 	kDMExplosionTypeFireball = 0, // @ C000_EXPLOSION_FIREBALL
219 	kDMExplosionTypeSlime = 1, // @ C001_EXPLOSION_SLIME
220 	kDMExplosionTypeLightningBolt = 2, // @ C002_EXPLOSION_LIGHTNING_BOLT
221 	kDMExplosionTypeHarmNonMaterial = 3, // @ C003_EXPLOSION_HARM_NON_MATERIAL
222 	kDMExplosionTypeOpenDoor = 4, // @ C004_EXPLOSION_OPEN_DOOR
223 	kDMExplosionTypePoisonBolt = 6, // @ C006_EXPLOSION_POISON_BOLT
224 	kDMExplosionTypePoisonCloud = 7, // @ C007_EXPLOSION_POISON_CLOUD
225 	kDMExplosionTypeSmoke = 40, // @ C040_EXPLOSION_SMOKE
226 	kDMExplosionTypeFluxcage = 50, // @ C050_EXPLOSION_FLUXCAGE
227 	kDMExplosionTypeRebirthStep1 = 100, // @ C100_EXPLOSION_REBIRTH_STEP1
228 	kDMExplosionTypeRebirthStep2 = 101 // @ C101_EXPLOSION_REBIRTH_STEP2
229 };
230 
231 enum SquareMask {
232 	kDMSquareMaskWallWestRandOrnament = 0x1, // @ MASK0x0001_WALL_WEST_RANDOM_ORNAMENT_ALLOWED
233 	kDMSquareMaslWallSouthRandOrnament = 0x2, // @ MASK0x0002_WALL_SOUTH_RANDOM_ORNAMENT_ALLOWED
234 	kDMSquareMaskWallEastRandOrnament = 0x4, // @ MASK0x0004_WALL_EAST_RANDOM_ORNAMENT_ALLOWED
235 	kDMSquareMaskWallNorthRandOrnament = 0x8, // @ MASK0x0008_WALL_NORTH_RANDOM_ORNAMENT_ALLOWED
236 	kDMSquareMaskCorridorRandOrnament = 0x8, // @ MASK0x0008_CORRIDOR_RANDOM_ORNAMENT_ALLOWED
237 	kDMSquareMaskPitImaginary = 0x1, // @ MASK0x0001_PIT_IMAGINARY
238 	kDMSquareMaskPitInvisible = 0x4, // @ MASK0x0004_PIT_INVISIBLE
239 	kDMSquareMaskPitOpen = 0x8, // @ MASK0x0008_PIT_OPEN
240 	kDMSquareMaskStairsUp = 0x4, // @ MASK0x0004_STAIRS_UP
241 	kDMSquareMaskStairsNorthSouth = 0x8, // @ MASK0x0008_STAIRS_NORTH_SOUTH_ORIENTATION
242 	kDMSquareMaskDoorNorthSouth = 0x8, // @ MASK0x0008_DOOR_NORTH_SOUTH_ORIENTATION
243 	kDMSquareMaskTeleporterVisible = 0x4, // @ MASK0x0004_TELEPORTER_VISIBLE
244 	kDMSquareMaskTeleporterOpen = 0x8, // @ MASK0x0008_TELEPORTER_OPEN
245 	kDMSquareMaskFakeWallImaginary = 0x1, // @ MASK0x0001_FAKEWALL_IMAGINARY
246 	kDMSquareMaskFakeWallOpen = 0x4, // @ MASK0x0004_FAKEWALL_OPEN
247 	kDMSquareMaskFakeWallRandOrnamentOrFootprintsAllowed = 0x8, // @ MASK0x0008_FAKEWALL_RANDOM_ORNAMENT_OR_FOOTPRINTS_ALLOWED
248 	kDMSquareMaskThingListPresent = 0x10 // @ MASK0x0010_THING_LIST_PRESENT
249 };
250 
251 #define kDMMaskChampionBones 0x8000 // @ MASK0x8000_CHAMPION_BONES
252 #define kDMMaskThingType 0x7FFF // @ MASK0x7FFF_THING_TYPE
253 
254 class ObjectInfoIndex {
255 public:
256 	int16 _type;
257 	uint16 _objectAspectIndex;
258 	uint16 _actionSetIndex;
259 	uint16 _allowedSlots;
ObjectInfoIndex(int16 type,uint16 objectAspectIndex,uint16 actionSetIndex,uint16 allowedSlots)260 	ObjectInfoIndex(int16 type, uint16 objectAspectIndex, uint16 actionSetIndex, uint16 allowedSlots)
261 		: _type(type), _objectAspectIndex(objectAspectIndex), _actionSetIndex(actionSetIndex), _allowedSlots(allowedSlots) {}
ObjectInfoIndex()262 	ObjectInfoIndex() : _type(0), _objectAspectIndex(0), _actionSetIndex(0), _allowedSlots(0) {}
getAllowedSlot(ObjectAllowedSlot slot)263 	bool getAllowedSlot(ObjectAllowedSlot slot) { return _allowedSlots & slot; }
getAllowedSlots()264 	uint16 getAllowedSlots() { return _allowedSlots; }
setAllowedSlot(ObjectAllowedSlot slot,bool val)265 	void setAllowedSlot(ObjectAllowedSlot slot, bool val) {
266 		if (val) {
267 			_allowedSlots |= slot;
268 		} else {
269 			_allowedSlots &= ~slot;
270 		}
271 	}
272 }; // @ OBJECT_INFO
273 
274 class ArmourInfo {
275 public:
276 	uint16 _weight;
277 	uint16 _defense;
278 	uint16 _attributes;
279 
ArmourInfo(uint16 weight,uint16 defense,uint16 attributes)280 	ArmourInfo(uint16 weight, uint16 defense, uint16 attributes)
281 		:_weight(weight), _defense(defense), _attributes(attributes) {}
ArmourInfo()282 	ArmourInfo() :_weight(0), _defense(0), _attributes(0) {}
283 
getAttribute(ArmourAttribute attribute)284 	uint16 getAttribute(ArmourAttribute attribute) { return _attributes & attribute; }
setAttribute(ArmourAttribute attribute)285 	void setAttribute(ArmourAttribute attribute) { _attributes |= attribute; }
286 }; // @ ARMOUR_INFO
287 
288 class WeaponInfo {
289 public:
290 	uint16 _weight;
291 	uint16 _class;
292 	uint16 _strength;
293 	uint16 _kineticEnergy;
294 private:
295 	uint16 _attributes; /* Bits 15-13 Unreferenced */
296 public:
WeaponInfo(uint16 weight,uint16 wClass,uint16 strength,uint16 kineticEnergy,uint16 attributes)297 	WeaponInfo(uint16 weight, uint16 wClass, uint16 strength, uint16 kineticEnergy, uint16 attributes)
298 		: _weight(weight), _class(wClass), _strength(strength), _kineticEnergy(kineticEnergy), _attributes(attributes) {}
WeaponInfo()299 	WeaponInfo() : _weight(0), _class(0), _strength(0), _kineticEnergy(0), _attributes(0) {}
300 
getShootAttack()301 	uint16 getShootAttack() { return _attributes & 0xFF; } // @ M65_SHOOT_ATTACK
getProjectileAspectOrdinal()302 	uint16 getProjectileAspectOrdinal() { return (_attributes >> 8) & 0x1F; } // @ M66_PROJECTILE_ASPECT_ORDINAL
303 }; // @ WEAPON_INFO
304 
305 class CreatureInfo {
306 public:
307 	byte _creatureAspectIndex;
308 	byte _attackSoundOrdinal;
309 	uint16 _attributes; /* Bits 15-14 Unreferenced */
310 	uint16 _graphicInfo; /* Bits 11 and 6 Unreferenced */
311 	byte _movementTicks; /* Value 255 means the creature cannot move */
312 	byte _attackTicks; /* Minimum ticks between attacks */
313 	byte _defense;
314 	byte _baseHealth;
315 	byte _attack;
316 	byte _poisonAttack;
317 	byte _dexterity;
318 	uint16 _ranges; /* Bits 7-4 Unreferenced */
319 	uint16 _properties;
320 	uint16 _resistances; /* Bits 15-12 and 3-0 Unreferenced */
321 	uint16 _animationTicks; /* Bits 15-12 Unreferenced */
322 	uint16 _woundProbabilities; /* Contains 4 probabilities to wound a champion's Head (Bits 15-12), Legs (Bits 11-8), Torso (Bits 7-4) and Feet (Bits 3-0) */
323 	byte _attackType;
324 
getFearResistance()325 	uint16 getFearResistance() { return (_properties >> 4) & 0xF; }
getExperience()326 	uint16 getExperience() { return (_properties >> 8) & 0xF; }
getWariness()327 	uint16 getWariness() { return (_properties >> 12) & 0xF; }
getFireResistance()328 	uint16 getFireResistance() { return (_resistances >> 4) & 0xF; }
getPoisonResistance()329 	uint16 getPoisonResistance() { return (_resistances >> 8) & 0xF; }
getHeight(uint16 attrib)330 	static uint16 getHeight(uint16 attrib) { return (attrib >> 7) & 0x3; }
getSightRange()331 	uint16 getSightRange() { return (_ranges) & 0xF; }
getSmellRange()332 	uint16 getSmellRange() { return  (_ranges >> 8) & 0xF; }
getAttackRange()333 	uint16 getAttackRange() { return (_ranges >> 12) & 0xF; }
334 }; // @ CREATURE_INFO
335 
336 class Door {
337 	Thing _nextThing;
338 	uint16 _attributes;
339 public:
Door(uint16 * rawDat)340 	explicit Door(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
getNextThing()341 	Thing getNextThing() { return _nextThing; }
isMeleeDestructible()342 	bool isMeleeDestructible() { return (_attributes >> 8) & 1; }
isMagicDestructible()343 	bool isMagicDestructible() { return (_attributes >> 7) & 1; }
hasButton()344 	bool hasButton() { return (_attributes >> 6) & 1; }
opensVertically()345 	bool opensVertically() { return (_attributes >> 5) & 1; }
getOrnOrdinal()346 	byte getOrnOrdinal() { return (_attributes >> 1) & 0xF; }
getType()347 	byte getType() { return _attributes & 1; }
348 }; // @ DOOR
349 
350 class Teleporter {
351 	Thing _nextThing;
352 	uint16 _attributes;
353 	uint16 _destMapIndex;
354 public:
Teleporter(uint16 * rawDat)355 	explicit Teleporter(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]), _destMapIndex(rawDat[2]) {}
getNextThing()356 	Thing getNextThing() { return _nextThing; }
isAudible()357 	bool isAudible() { return (_attributes >> 15) & 1; }
getScope()358 	TeleporterScope getScope() { return (TeleporterScope)((_attributes >> 13) & 1); }
getAbsoluteRotation()359 	bool getAbsoluteRotation() { return (_attributes >> 12) & 1; }
getRotation()360 	Direction getRotation() { return (Direction)((_attributes >> 10) & 1); }
getTargetMapY()361 	byte getTargetMapY() { return (_attributes >> 5) & 0xF; }
getTargetMapX()362 	byte getTargetMapX() { return _attributes & 0xF; }
getTargetMapIndex()363 	uint16 getTargetMapIndex() { return _destMapIndex >> 8; }
364 }; // @ TELEPORTER
365 
366 class TextString {
367 	Thing _nextThing;
368 	uint16 _textDataRef;
369 public:
TextString(uint16 * rawDat)370 	explicit TextString(uint16 *rawDat) : _nextThing(rawDat[0]), _textDataRef(rawDat[1]) {}
371 
getNextThing()372 	Thing getNextThing() { return _nextThing; }
getWordOffset()373 	uint16 getWordOffset() { return _textDataRef >> 3; }
isVisible()374 	bool isVisible() { return _textDataRef & 1; }
setVisible(bool visible)375 	void setVisible(bool visible) { _textDataRef = (_textDataRef & ~1) | (visible ? 1 : 0); }
376 }; // @ TEXTSTRING
377 
378 class Sensor {
379 	Thing _nextThing;
380 	uint16 _datAndType;
381 	uint16 _attributes; // A
382 	uint16 _action; // B
383 public:
Sensor(uint16 * rawDat)384 	explicit Sensor(uint16 *rawDat) : _nextThing(rawDat[0]), _datAndType(rawDat[1]), _attributes(rawDat[2]), _action(rawDat[3]) {}
385 
getNextThing()386 	Thing getNextThing() { return _nextThing; }
setNextThing(Thing thing)387 	void setNextThing(Thing thing) { _nextThing = thing; }
getType()388 	SensorType getType() { return (SensorType)(_datAndType & 0x7F); } // @ M39_TYPE
getData()389 	uint16 getData() { return (_datAndType >> 7) & 0x1FF; } // @ M40_DATA
getDataMask1(uint16 data)390 	static uint16 getDataMask1(uint16 data) { return (data >> 7) & 0xF; } // @ M42_MASK1
getDataMask2(uint16 data)391 	static uint16 getDataMask2(uint16 data) { return (data >> 11) & 0xF; } // @ M43_MASK2
setData(uint16 dat)392 	void setData(uint16 dat) { _datAndType = dat; } // @ M41_SET_DATA
setTypeDisabled()393 	void setTypeDisabled() { _datAndType &= 0xFF80; } // @ M44_SET_TYPE_DISABLED
394 
getAttrOnlyOnce()395 	bool getAttrOnlyOnce() { return (_attributes >> 2) & 1; }
getAttrEffectA()396 	uint16 getAttrEffectA() { return (_attributes >> 3) & 0x3; }
getAttrRevertEffectA()397 	bool getAttrRevertEffectA() { return (_attributes >> 5) & 0x1; }
getAttrAudibleA()398 	bool getAttrAudibleA() { return (_attributes >> 6) & 0x1; }
getAttrValue()399 	uint16 getAttrValue() { return (_attributes >> 7) & 0xF; }
getAttrLocalEffect()400 	bool getAttrLocalEffect() { return (_attributes >> 11) & 1; }
getAttrOrnOrdinal()401 	uint16 getAttrOrnOrdinal() { return _attributes >> 12; }
402 
getActionTargetMapY()403 	uint16 getActionTargetMapY() { return (_action >> 11); }
getActionTargetMapX()404 	uint16 getActionTargetMapX() { return (_action >> 6) & 0x1F; }
getActionTargetCell()405 	Cell getActionTargetCell() { return (Cell)((_action >> 4) & 3); }
getActionHealthMultiplier()406 	uint16 getActionHealthMultiplier() { return ((_action >> 4) & 0xF); } // @ M45_HEALTH_MULTIPLIER
getActionTicks()407 	uint16 getActionTicks() { return ((_action >> 4) >> 4) & 0xFFF; } // @ M46_TICKS
getActionKineticEnergy()408 	uint16 getActionKineticEnergy() { return ((_action >> 4) & 0xFF); }// @ M47_KINETIC_ENERGY
getActionStepEnergy()409 	uint16 getActionStepEnergy() { return ((_action >> 4) >> 8) & 0xFF; }// @ M48_STEP_ENERGY
getActionLocalEffect()410 	uint16 getActionLocalEffect() { return (_action >> 4); } // @ M49_LOCAL_EFFECT
411 
setDatAndTypeWithOr(uint16 val)412 	void setDatAndTypeWithOr(uint16 val) { _datAndType |= val;  }
413 
414 }; // @ SENSOR
415 
416 class Weapon {
417 	Thing _nextThing;
418 	uint16 _desc;
419 public:
Weapon(uint16 * rawDat)420 	explicit Weapon(uint16 *rawDat) : _nextThing(rawDat[0]), _desc(rawDat[1]) {}
421 
getType()422 	WeaponType getType() { return (WeaponType)(_desc & 0x7F); }
setType(uint16 val)423 	void setType(uint16 val) { _desc = (_desc & ~0x7F) | (val & 0x7F); }
isLit()424 	bool isLit() { return (_desc >> 15) & 1; }
setLit(bool val)425 	void setLit(bool val) {
426 		if (val)
427 			_desc |= (1 << 15);
428 		else
429 			_desc &= (~(1 << 15));
430 	}
getChargeCount()431 	uint16 getChargeCount() { return (_desc >> 10) & 0xF; }
setChargeCount(uint16 val)432 	uint16 setChargeCount(uint16 val) { _desc = (_desc & ~(0xF << 10)) | ((val & 0xF) << 10); return (val & 0xF); }
getNextThing()433 	Thing getNextThing() { return _nextThing; }
setNextThing(Thing val)434 	void setNextThing(Thing val) { _nextThing = val;  }
getCursed()435 	uint16 getCursed() { return (_desc >> 8) & 1; }
setCursed(uint16 val)436 	void setCursed(uint16 val) { _desc = (_desc & ~(1 << 8)) | ((val & 1) << 8); }
getPoisoned()437 	uint16 getPoisoned() { return (_desc >> 9) & 1; }
getBroken()438 	uint16 getBroken() { return (_desc >> 14) & 1; }
getDoNotDiscard()439 	uint16 getDoNotDiscard() { return (_desc >> 7) & 1; }
setDoNotDiscard(uint16 val)440 	void setDoNotDiscard(uint16 val) { _desc = (_desc & ~(1 << 7)) | ((val & 1) << 7); }
441 }; // @ WEAPON
442 
443 class Armour {
444 	Thing _nextThing;
445 	uint16 _attributes;
446 public:
Armour(uint16 * rawDat)447 	explicit Armour(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
448 
getType()449 	ArmourType getType() { return (ArmourType)(_attributes & 0x7F); }
getNextThing()450 	Thing getNextThing() { return _nextThing; }
getCursed()451 	uint16 getCursed() { return (_attributes >> 8) & 1; }
getBroken()452 	uint16 getBroken() { return (_attributes >> 13) & 1; }
getDoNotDiscard()453 	uint16 getDoNotDiscard() { return (_attributes >> 7) & 1; }
getChargeCount()454 	uint16 getChargeCount() { return (_attributes >> 9) & 0xF; }
setChargeCount(uint16 val)455 	void setChargeCount(uint16 val) { _attributes = (_attributes & ~(0xF << 9)) | ((val & 0xF) << 9); }
456 }; // @ ARMOUR
457 
458 class Scroll {
459 	Thing _nextThing;
460 	uint16 _attributes;
461 public:
Scroll(uint16 * rawDat)462 	explicit Scroll(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
set(Thing next,uint16 attribs)463 	void set(Thing next, uint16 attribs) {
464 		_nextThing = next;
465 		_attributes = attribs;
466 	}
getNextThing()467 	Thing getNextThing() { return _nextThing; }
getClosed()468 	uint16 getClosed() { return (_attributes >> 10) & 0x3F; } // ??? dunno why, the original bitfield is 6 bits long
setClosed(bool val)469 	void setClosed(bool val) {
470 		if (val)
471 			_attributes |= (1 << 10);
472 		else
473 			_attributes &= (~(0x3F << 10));
474 	}
getTextStringThingIndex()475 	uint16 getTextStringThingIndex() { return _attributes & 0x3FF; }
476 }; // @ SCROLL
477 
478 class Potion {
479 public:
480 	Thing _nextThing;
481 	uint16 _attributes;
Potion(uint16 * rawDat)482 	explicit Potion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
483 
getType()484 	PotionType getType() { return (PotionType)((_attributes >> 8) & 0x7F); }
setType(PotionType val)485 	void setType(PotionType val) { _attributes = (_attributes & ~(0x7F << 8)) | ((val & 0x7F) << 8); }
getNextThing()486 	Thing getNextThing() { return _nextThing; }
getPower()487 	uint16 getPower() { return _attributes & 0xFF; }
setPower(uint16 val)488 	void setPower(uint16 val) { _attributes = (_attributes & ~0xFF) | (val & 0xFF); }
getDoNotDiscard()489 	uint16 getDoNotDiscard() { return (_attributes >> 15) & 1; }
490 }; // @ POTION
491 
492 class Container {
493 	Thing _nextThing;
494 	Thing _slot;
495 	uint16 _type;
496 public:
Container(uint16 * rawDat)497 	explicit Container(uint16 *rawDat) : _nextThing(rawDat[0]), _slot(rawDat[1]), _type(rawDat[2]) {}
498 
getType()499 	uint16 getType() { return (_type >> 1) & 0x3; }
getSlot()500 	Thing &getSlot() { return _slot; }
getNextThing()501 	Thing &getNextThing() { return _nextThing; }
502 }; // @ CONTAINER
503 
504 class Junk {
505 	Thing _nextThing;
506 	uint16 _attributes;
507 public:
Junk(uint16 * rawDat)508 	explicit Junk(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
509 
getType()510 	JunkType getType() { return (JunkType)(_attributes & 0x7F); }
setType(uint16 val)511 	void setType(uint16 val) { _attributes = (_attributes & ~0x7F) | (val & 0x7F); }
getChargeCount()512 	uint16 getChargeCount() { return (_attributes >> 14) & 0x3; }
setChargeCount(uint16 val)513 	void setChargeCount(uint16 val) { _attributes = (_attributes & ~(0x3 << 14)) | ((val & 0x3) << 14); }
getDoNotDiscard()514 	uint16 getDoNotDiscard() { return (_attributes >> 7) & 1; }
setDoNotDiscard(uint16 val)515 	void setDoNotDiscard(uint16 val) { _attributes = (_attributes & ~(1 << 7)) | ((val & 1) << 7); }
516 
getNextThing()517 	Thing getNextThing() { return _nextThing; }
setNextThing(Thing thing)518 	void setNextThing(Thing thing) { _nextThing = thing; }
519 }; // @ JUNK
520 
521 class Projectile {
522 public:
523 	Thing _nextThing;
524 	Thing _slot;
525 	uint16 _kineticEnergy;
526 	uint16 _attack;
527 	uint16 _eventIndex;
Projectile(uint16 * rawDat)528 	explicit Projectile(uint16 *rawDat) : _nextThing(rawDat[0]), _slot(rawDat[1]), _kineticEnergy(rawDat[2]),
529 		_attack(rawDat[3]), _eventIndex(rawDat[4]) {}
530 
531 }; // @ PROJECTILE
532 
533 class Explosion {
534 	Thing _nextThing;
535 	uint16 _attributes;
536 public:
Explosion(uint16 * rawDat)537 	explicit Explosion(uint16 *rawDat) : _nextThing(rawDat[0]), _attributes(rawDat[1]) {}
538 
getNextThing()539 	Thing getNextThing() { return _nextThing; }
setNextThing(Thing val)540 	Thing setNextThing(Thing val) { return _nextThing = val; }
getType()541 	uint16 getType() { return _attributes & 0x7F; }
setType(uint16 val)542 	uint16 setType(uint16 val) { _attributes = (_attributes & ~0x7F) | (val & 0x7F); return (val & 0x7F); }
getAttack()543 	uint16 getAttack() { return (_attributes >> 8) & 0xFF; }
setAttack(uint16 val)544 	void setAttack(uint16 val) { _attributes = (_attributes & ~(0xFF << 8)) | ((val & 0xFF) << 8); }
getCentered()545 	uint16 getCentered() { return (_attributes >> 7) & 0x1; }
setCentered(uint16 val)546 	void setCentered(uint16 val) { _attributes = (_attributes & ~(1 << 7)) | ((val & 1) << 7); }
547 }; // @ EXPLOSION
548 
549 class Square {
550 	byte _data;
551 public:
_data(dat)552 	explicit Square(byte dat = 0) : _data(dat) {}
Square(ElementType type)553 	explicit Square(ElementType type) { setType(type); }
Square(byte element,byte mask)554 	explicit Square(byte element, byte mask) : _data((element << 5) | mask) {}
set(byte dat)555 	Square &set(byte dat) { this->_data = dat; return *this; }
set(SquareMask mask)556 	Square &set(SquareMask mask) { _data |= mask; return *this; }
get(SquareMask mask)557 	byte get(SquareMask mask) { return _data & mask; }
getDoorState()558 	byte getDoorState() { return _data & 0x7; } // @ M36_DOOR_STATE
setDoorState(byte state)559 	void setDoorState(byte state) { _data = ((_data & ~0x7) | state); } // @ M37_SET_DOOR_STATE
getType()560 	ElementType getType() { return (ElementType)(_data >> 5); } // @ M34_SQUARE_TYPE
setType(ElementType type)561 	void setType(ElementType type) { _data = (_data & 0x1F) | type << 5; }
toByte()562 	byte toByte() { return _data; } // I don't like 'em casts
563 }; // wrapper for bytes which are used as squares
564 
565 struct DungeonFileHeader {
566 	uint16 _ornamentRandomSeed;
567 	uint16 _rawMapDataSize;
568 	uint8 _mapCount;
569 	uint16 _textDataWordCount;
570 	uint16 _partyStartLocation;
571 	uint16 _squareFirstThingCount; // @ SquareFirstThingCount
572 	uint16 _thingCounts[16]; // @ ThingCount[16]
573 }; // @ DUNGEON_HEADER
574 
575 struct Map {
576 	uint32 _rawDunDataOffset;
577 	uint8 _offsetMapX, _offsetMapY;
578 
579 	uint8 _level; // only used in DMII
580 	uint8 _width, _height; // !!! THESRE ARE INCLUSIVE BOUNDARIES
581 	// orn short for Ornament
582 	uint8 _wallOrnCount; /* May be used in a Sensor on a Wall or closed Fake Wall square */
583 	uint8 _randWallOrnCount; /* Used only on some Wall squares and some closed Fake Wall squares */
584 	uint8 _floorOrnCount; /* May be used in a Sensor on a Pit, open Fake Wall, Corridor or Teleporter square */
585 	uint8 _randFloorOrnCount; /* Used only on some Corridor squares and some open Fake Wall squares */
586 
587 	uint8 _doorOrnCount;
588 	uint8 _creatureTypeCount;
589 	uint8 _difficulty;
590 
591 	FloorSet _floorSet;
592 	WallSet _wallSet;
593 	uint8 _doorSet0, _doorSet1;
594 }; // @ MAP
595 
596 
597 class DoorInfo {
598 public:
599 	byte _attributes;
600 	byte _defense;
DoorInfo(byte b1,byte b2)601 	DoorInfo(byte b1, byte b2) : _attributes(b1), _defense(b2) {}
DoorInfo()602 	DoorInfo() { resetToZero(); }
resetToZero()603 	void resetToZero() { _attributes = _defense = 0; }
604 }; // @ DOOR_INFO
605 
606 class Group;
607 
608 class DungeonMan {
609 	DMEngine *_vm;
610 
611 	DungeonMan(const DungeonMan &other); // no implementation on purpose
612 	void operator=(const DungeonMan &rhs); // no implementation on purpose
613 
614 	Square getRelSquare(Direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare
615 
616 	void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon
617 
618 	int16 getSquareFirstThingIndex(int16 mapX, int16 mapY); // @ F0160_DUNGEON_GetSquareFirstThingIndex
619 
620 	int16 getRandomOrnOrdinal(bool allowed, int16 count, int16 mapX, int16 mapY, int16 modulo); // @ F0170_DUNGEON_GetRandomOrnamentOrdinal
621 	void setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, int16 dir,
622 										 int16 mapX, int16 mapY, bool isFakeWall); // @ F0171_DUNGEON_SetSquareAspectRandomWallOrnamentOrdinals
623 
624 public:
625 	explicit DungeonMan(DMEngine *dmEngine);
626 	~DungeonMan();
627 
628 	Square getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare
629 	void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap
630 	Thing getSquareFirstThing(int16 mapX, int16 mapY); // @ F0161_DUNGEON_GetSquareFirstThing
631 	Thing getNextThing(Thing thing); // @ F0159_DUNGEON_GetNextThing(THING P0280_T_Thing)
632 	uint16 *getThingData(Thing thing); // @ F0156_DUNGEON_GetThingData
633 	uint16 *getSquareFirstThingData(int16 mapX, int16 mapY); // @ F0157_DUNGEON_GetSquareFirstThingData
634 
635 	// TODO: this does stuff other than load the file!
636 	void loadDungeonFile(Common::InSaveFile *file);	// @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC
637 	void setCurrentMapAndPartyMap(uint16 mapIndex); // @ F0174_DUNGEON_SetCurrentMapAndPartyMap
638 
639 	bool isWallOrnAnAlcove(int16 wallOrnIndex); // @ F0149_DUNGEON_IsWallOrnamentAnAlcove
640 	void mapCoordsAfterRelMovement(Direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement
getRelSquareType(Direction dir,int16 stepsForward,int16 stepsRight,int16 posX,int16 posY)641 	ElementType getRelSquareType(Direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) {
642 		return Square(getRelSquare(dir, stepsForward, stepsRight, posX, posY)).getType();
643 	} // @ F0153_DUNGEON_GetRelativeSquareType
644 	void setSquareAspect(uint16 *aspectArray, Direction dir, int16 mapX, int16 mapY); // @ F0172_DUNGEON_SetSquareAspect
645 	void decodeText(char *destString, Thing thing, TextType type); // F0168_DUNGEON_DecodeText
646 	Thing getUnusedThing(uint16 thingType); // @ F0166_DUNGEON_GetUnusedThing
647 
648 	uint16 getObjectWeight(Thing thing); // @ F0140_DUNGEON_GetObjectWeight
649 	int16 getObjectInfoIndex(Thing thing); // @ F0141_DUNGEON_GetObjectInfoIndex
650 	void linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList
651 	WeaponInfo *getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo
652 	int16 getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect
653 	int16 getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16 *mapX, int16 *mapY); // @ F0154_DUNGEON_GetLocationAfterLevelChange
654 	Thing getSquareFirstObject(int16 mapX, int16 mapY); // @ F0162_DUNGEON_GetSquareFirstObject
655 	uint16 getArmourDefense(ArmourInfo *armourInfo, bool useSharpDefense); // @ F0143_DUNGEON_GetArmourDefense
656 	Thing getDiscardThing(uint16 thingType); // @ F0165_DUNGEON_GetDiscardedThing
657 	uint16 getCreatureAttributes(Thing thing); // @ F0144_DUNGEON_GetCreatureAttributes
658 	void setGroupCells(Group *group, uint16 cells, uint16 mapIndex); // @ F0146_DUNGEON_SetGroupCells
659 	void setGroupDirections(Group *group, int16 dir, uint16 mapIndex); // @ F0148_DUNGEON_SetGroupDirections
660 	bool isCreatureAllowedOnMap(Thing thing, uint16 mapIndex); // @ F0139_DUNGEON_IsCreatureAllowedOnMap
661 	void unlinkThingFromList(Thing thingToUnlink, Thing thingInList, int16 mapX, int16 mapY); // @ F0164_DUNGEON_UnlinkThingFromList
662 	int16 getStairsExitDirection(int16 mapX, int16 mapY); // @ F0155_DUNGEON_GetStairsExitDirection
663 	Thing getObjForProjectileLaucherOrObjGen(uint16 iconIndex); // @ F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator
664 	int16 getRandomOrnamentIndex(uint16 val1, uint16 val2, int16 modulo); // @ F0169_DUNGEON_GetRandomOrnamentIndex
665 
666 	uint32 _rawDunFileDataSize;	 // @ probably NONE
667 	byte *_rawDunFileData; // @ ???
668 	DungeonFileHeader _dungeonFileHeader; // @ G0278_ps_DungeonHeader
669 
670 	uint16 *_dungeonMapsFirstColumnIndex; // @ G0281_pui_DungeonMapsFirstColumnIndex
671 	uint16 _dungeonColumCount; // @ G0282_ui_DungeonColumnCount
672 	uint16 *_dungeonColumnsCumulativeSquareThingCount; // @ G0280_pui_DungeonColumnsCumulativeSquareThingCount
673 	Thing *_squareFirstThings; // @ G0283_pT_SquareFirstThings
674 	uint16 *_dungeonTextData; // @ G0260_pui_DungeonTextData
675 	uint16 *_thingData[16]; // @ G0284_apuc_ThingData
676 	byte ***_dungeonMapData; // @ G0279_pppuc_DungeonMapData
677 
678 	Direction _partyDir; // @ G0308_i_PartyDirection
679 	int16 _partyMapX; // @ G0306_i_PartyMapX
680 	int16 _partyMapY; // @ G0307_i_PartyMapY
681 	uint8 _partyMapIndex; // @ G0309_i_PartyMapIndex
682 	int16 _currMapIndex; // @ G0272_i_CurrentMapIndex
683 	byte **_currMapData; // @ G0271_ppuc_CurrentMapData
684 	Map *_currMap; // @ G0269_ps_CurrentMap
685 	uint16 _currMapWidth; // @ G0273_i_CurrentMapWidth
686 	uint16 _currMapHeight; // @ G0274_i_CurrentMapHeight
687 	uint16 *_currMapColCumulativeSquareFirstThingCount; // @G0270_pui_CurrentMapColumnsCumulativeSquareFirstThingCount
688 
689 	Map *_dungeonMaps; // @ G0277_ps_DungeonMaps
690 	byte *_dungeonRawMapData; // @ G0276_puc_DungeonRawMapData
691 
692 	int16 _currMapInscriptionWallOrnIndex; // @ G0265_i_CurrentMapInscriptionWallOrnamentIndex
693 	Box _dungeonViewClickableBoxes[6]; // G0291_aauc_DungeonViewClickableBoxes
694 	bool _isFacingAlcove; // @ G0286_B_FacingAlcove
695 	bool _isFacingViAltar; // @ G0287_B_FacingViAltar
696 	bool _isFacingFountain; // @ G0288_B_FacingFountain
697 	ElementType _squareAheadElement; // @ G0285_i_SquareAheadElement
698 	Thing _pileTopObject[5]; // @ G0292_aT_PileTopObject
699 	DoorInfo _currMapDoorInfo[2]; // @ G0275_as_CurrentMapDoorInfo
700 
701 	ObjectInfoIndex _objectInfos[180]; // @ G0237_as_Graphic559_ObjectInfo
702 	ArmourInfo _armourInfos[58]; // @ G0239_as_Graphic559_ArmourInfo
703 	WeaponInfo _weaponInfos[46]; // @ G0238_as_Graphic559_WeaponInfo
704 	CreatureInfo _creatureInfos[k27_CreatureTypeCount]; // @ G0243_as_Graphic559_CreatureInfo
705 	byte _thingDataWordCount[16]; // @ G0235_auc_Graphic559_ThingDataByteCount
706 
707 	void setupConstants();
708 };
709 
710 }
711 
712 #endif
713