diff options
-rw-r--r-- | engines/dm/TODOs/methodtree.txt | 10 | ||||
-rw-r--r-- | engines/dm/dm.cpp | 11 | ||||
-rw-r--r-- | engines/dm/dm.h | 6 | ||||
-rw-r--r-- | engines/dm/dungeonman.h | 2 | ||||
-rw-r--r-- | engines/dm/gfx.cpp | 8 | ||||
-rw-r--r-- | engines/dm/gfx.h | 18 | ||||
-rw-r--r-- | engines/dm/group.cpp | 29 | ||||
-rw-r--r-- | engines/dm/group.h | 51 |
8 files changed, 114 insertions, 21 deletions
diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 2b9d6bd309..894ea89bc5 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -8,11 +8,11 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF F0142_DUNGEON_GetProjectileAspect // done F0158_DUNGEON_GetWeaponInfo // done M66_PROJECTILE_ASPECT_ORDINAL // done - F0176_GROUP_GetCreatureOrdinalInCell + F0176_GROUP_GetCreatureOrdinalInCell // done F0145_DUNGEON_GetGroupCells // done - F0147_DUNGEON_GetGroupDirections + F0147_DUNGEON_GetGroupDirections // done GROUP // done - CreatureType + CreatureType // done G0017_auc_Graphic562_PaletteChanges_NoChanges G0075_apuc_PaletteChanges_Projectile G0077_B_DoNotDrawFluxcagesDuringEndgame @@ -46,8 +46,8 @@ F0115_DUNGEONVIEW_DrawObjectsCreaturesProjectilesExplosions_CPSEF OBJECT_ASPECT GROUP // done ACTIVE_GROUP - CREATURE_INFO - CREATURE_ASPECT + CREATURE_INFO // done + CREATURE_ASPECT // done PROJECTILE EXPLOSION FIELD_ASPECT // done diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 1b2edceb81..924988d39d 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -56,6 +56,15 @@ namespace DM { void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); } direction returnOppositeDir(direction dir) { return (direction)((dir + 2) & 3); } + +uint16 returnPrevVal(uint16 val) { + return (direction)((val + 3) & 3); +} + +uint16 returnNextVal(uint16 val) { + return (val + 1) & 0x3; +} + bool isOrientedWestEast(direction dir) { return dir & 1; } uint16 getFlag(uint16 val, uint16 mask) { @@ -205,7 +214,7 @@ Common::Error DMEngine::run() { _objectMan = new ObjectMan(this); _inventoryMan = new InventoryMan(this); _textMan = new TextMan(this); - _movsens = new MovesensMan(this); + _movsens = new MovesensMan(this); _groupMan = new GroupMan(this); _displayMan->setUpScreens(320, 200); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 5bbeb4f1ae..b0d063125b 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -58,8 +58,10 @@ enum direction { void turnDirRight(direction &dir); void turnDirLeft(direction &dir); -direction returnOppositeDir(direction dir); -bool isOrientedWestEast(direction dir); +direction returnOppositeDir(direction dir); // @ M18_OPPOSITE +uint16 returnPrevVal(uint16 val); // @ M19_PREVIOUS +uint16 returnNextVal(uint16 val); // @ M17_NEXT +bool isOrientedWestEast(direction dir); // @ M16_IS_ORIENTED_WEST_EAST uint16 getFlag(uint16 val, uint16 mask); diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index a4f06ee963..ec04aa8c8f 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -177,6 +177,8 @@ enum SquareAspectIndice { kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS }; + + struct CreatureInfo { byte _creatureAspectIndex; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 177f9aec8f..67604f9ef0 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -816,23 +816,23 @@ void DisplayMan::loadGraphics() { int16 creatureFrontBitmapD2PixelCount; _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2); - if (getFlag(creatureGraphicInfo, kCreatureInfoMaskSide)) { + if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskSide)) { _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale16_D3); _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale20_D2); } - if (getFlag(creatureGraphicInfo, kCreatureInfoMaskBack)) { + if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskBack)) { _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount; _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount; } - if (getFlag(creatureGraphicInfo, kCreatureInfoMaskAttack)) { + if (getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskAttack)) { _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, kScale16_D3); _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthAttack, creatureAsp->_heightAttack, kScale20_D2); } int16 additionalFronGraphicCount; - if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, kCreatureInfoMaskAdditional)) { + if (additionalFronGraphicCount = getFlag(creatureGraphicInfo, kCreatureInfoGraphicMaskAdditional)) { do { _derivedBitmapByteCount[derivedBitmapIndex++] = creatureAsp->_byteWidthFront * creatureAsp->_heightFront; _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3); diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 2df0ac0a5c..3d5d46ea3c 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -57,15 +57,15 @@ namespace DM { #define kExplosionAspectSmoke 3 // @ C3_EXPLOSION_ASPECT_SMOKE /* Creature info GraphicInfo */ -#define kCreatureInfoMaskAdditional 0x0003 // @ MASK0x0003_ADDITIONAL -#define kCreatureInfoMaskFlipNonAttack 0x0004 // @ MASK0x0004_FLIP_NON_ATTACK -#define kCreatureInfoMaskSide 0x0008 // @ MASK0x0008_SIDE -#define kCreatureInfoMaskBack 0x0010 // @ MASK0x0010_BACK -#define kCreatureInfoMaskAttack 0x0020 // @ MASK0x0020_ATTACK -#define kCreatureInfoMaskSpecialD2Front 0x0080 // @ MASK0x0080_SPECIAL_D2_FRONT -#define kCreatureInfoMaskSpecialD2FrontIsFlipped 0x0100 // @ MASK0x0100_SPECIAL_D2_FRONT_IS_FLIPPED_FRONT -#define kCreatureInfoMaskFlipAttack 0x0200 // @ MASK0x0200_FLIP_ATTACK -#define kCreatureInfoMaskFlipDuringAttack 0x0400 // @ MASK0x0400_FLIP_DURING_ATTACK +#define kCreatureInfoGraphicMaskAdditional 0x0003 // @ MASK0x0003_ADDITIONAL +#define kCreatureInfoGraphicMaskFlipNonAttack 0x0004 // @ MASK0x0004_FLIP_NON_ATTACK +#define kCreatureInfoGraphicMaskSide 0x0008 // @ MASK0x0008_SIDE +#define kCreatureInfoGraphicMaskBack 0x0010 // @ MASK0x0010_BACK +#define kCreatureInfoGraphicMaskAttack 0x0020 // @ MASK0x0020_ATTACK +#define kCreatureInfoGraphicMaskSpecialD2Front 0x0080 // @ MASK0x0080_SPECIAL_D2_FRONT +#define kCreatureInfoGraphicMaskSpecialD2FrontIsFlipped 0x0100 // @ MASK0x0100_SPECIAL_D2_FRONT_IS_FLIPPED_FRONT +#define kCreatureInfoGraphicMaskFlipAttack 0x0200 // @ MASK0x0200_FLIP_ATTACK +#define kCreatureInfoGraphicMaskFlipDuringAttack 0x0400 // @ MASK0x0400_FLIP_DURING_ATTACK class ExplosionAspect { public: diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 4a1a7e1180..b224dff229 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -68,4 +68,33 @@ uint16 GroupMan::getGroupDirections(Group* group, int16 mapIndex) { return gGroupDirections[group->getDir()]; } + +int16 GroupMan::getCreatureOrdinalInCell(Group* group, uint16 cell) { + uint16 currMapIndex = _vm->_dungeonMan->_currMap._index; + byte groupCells = getGroupCells(group, currMapIndex); + if (groupCells == kCreatureTypeSingleCenteredCreature) + return _vm->indexToOrdinal(0); + + byte creatureIndex = group->getCount(); + if (getFlag(gCreatureInfo[group->_type]._attributes, kMaskCreatureInfo_size) == kMaskCreatureSizeHalf) { + if ((getGroupDirections(group, currMapIndex) & 1) == (cell & 1)) + cell = returnPrevVal(cell); + + do { + byte creatureCell = getCreatureValue(groupCells, creatureIndex); + if (creatureCell == cell || creatureCell == returnNextVal(cell)) + return _vm->indexToOrdinal(creatureIndex); + } while (creatureIndex--); + } else { + do { + if (getCreatureValue(groupCells, creatureIndex) == cell) + return _vm->indexToOrdinal(creatureIndex); + } while (creatureIndex--); + } + return 0; +} + +uint16 GroupMan::getCreatureValue(uint16 groupVal, uint16 creatureIndex) { + return (groupVal >> (creatureIndex << 1)) & 0x3; +} } diff --git a/engines/dm/group.h b/engines/dm/group.h index 0ad9cbb545..49ec009d94 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -33,6 +33,55 @@ namespace DM { +/* Creature types */ +enum CreatureType { + kCreatureTypeGiantScorpionScorpion = 0, // @ C00_CREATURE_GIANT_SCORPION_SCORPION + kCreatureTypeSwampSlimeSlime = 1, // @ C01_CREATURE_SWAMP_SLIME_SLIME_DEVIL + kCreatureTypeGiggler = 2, // @ C02_CREATURE_GIGGLER + kCreatureTypeWizardEyeFlyingEye = 3, // @ C03_CREATURE_WIZARD_EYE_FLYING_EYE + kCreatureTypePainRatHellHound = 4, // @ C04_CREATURE_PAIN_RAT_HELLHOUND + kCreatureTypeRuster = 5, // @ C05_CREATURE_RUSTER + kCreatureTypeScreamer = 6, // @ C06_CREATURE_SCREAMER + kCreatureTypeRockpile = 7, // @ C07_CREATURE_ROCK_ROCKPILE + kCreatureTypeGhostRive = 8, // @ C08_CREATURE_GHOST_RIVE + kCreatureTypeStoneGolem = 9, // @ C09_CREATURE_STONE_GOLEM + kCreatureTypeMummy = 10, // @ C10_CREATURE_MUMMY + kCreatureTypeBlackFlame = 11, // @ C11_CREATURE_BLACK_FLAME + kCreatureTypeSkeleton = 12, // @ C12_CREATURE_SKELETON + kCreatureTypeCouatl = 13, // @ C13_CREATURE_COUATL + kCreatureTypeVexirk = 14, // @ C14_CREATURE_VEXIRK + kCreatureTypeMagnetaWormWorm = 15, // @ C15_CREATURE_MAGENTA_WORM_WORM + kCreatureTypeTrolinAntman = 16, // @ C16_CREATURE_TROLIN_ANTMAN + kCreatureTypeGiantWaspMuncher = 17, // @ C17_CREATURE_GIANT_WASP_MUNCHER + kCreatureTypeAnimatedArmourDethKnight = 18, // @ C18_CREATURE_ANIMATED_ARMOUR_DETH_KNIGHT + kCreatureTypeMaterializerZytaz = 19, // @ C19_CREATURE_MATERIALIZER_ZYTAZ + kCreatureTypeWaterElemental = 20, // @ C20_CREATURE_WATER_ELEMENTAL + kCreatureTypeOitu = 21, // @ C21_CREATURE_OITU + kCreatureTypeDemon = 22, // @ C22_CREATURE_DEMON + kCreatureTypeLordChaos = 23, // @ C23_CREATURE_LORD_CHAOS + kCreatureTypeRedDragon = 24, // @ C24_CREATURE_RED_DRAGON + kCreatureTypeLordOrder = 25, // @ C25_CREATURE_LORD_ORDER + kCreatureTypeGreyLord = 26, // @ C26_CREATURE_GREY_LORD + kCreatureTypeSingleCenteredCreature = 255 // @ C255_SINGLE_CENTERED_CREATURE +}; + +#define kMaskCreatureSizeQuarter 0 // @ C0_SIZE_QUARTER_SQUARE +#define kMaskCreatureSizeHalf 1 // @ C1_SIZE_HALF_SQUARE +#define kMaskCreatureSizeFull 2 // @ C2_SIZE_FULL_SQUARE + +#define kMaskCreatureInfo_size 0x0003 // @ MASK0x0003_SIZE +#define kMaskCreatureInfo_sideAttack 0x0004 // @ MASK0x0004_SIDE_ATTACK +#define kMaskCreatureInfo_preferBackRow 0x0008 // @ MASK0x0008_PREFER_BACK_ROW +#define kMaskCreatureInfo_attackAnyChamp 0x0010 // @ MASK0x0010_ATTACK_ANY_CHAMPION +#define kMaskCreatureInfo_levitation 0x0020 // @ MASK0x0020_LEVITATION +#define kMaskCreatureInfo_nonMaterial 0x0040 // @ MASK0x0040_NON_MATERIAL +#define kMaskCreatureInfo_dropFixedPoss 0x0200 // @ MASK0x0200_DROP_FIXED_POSSESSIONS +#define kMaskCreatureInfo_keepThrownSharpWeapon 0x0400 // @ MASK0x0400_KEEP_THROWN_SHARP_WEAPONS +#define kMaskCreatureInfo_seeInvisible 0x0800 // @ MASK0x0800_SEE_INVISIBLE +#define kMaskCreatureInfo_nightVision 0x1000 // @ MASK0x1000_NIGHT_VISION +#define kMaskCreatureInfo_archenemy 0x2000 // @ MASK0x2000_ARCHENEMY +#define kMaskCreatureInfo_magicmap 0x4000 // @ MASK0x4000_MAGICMAP + class ActiveGroup { public: int _groupThingIndex; @@ -87,6 +136,8 @@ public: void initActiveGroups(); // @ F0196_GROUP_InitializeActiveGroups uint16 getGroupCells(Group *group, int16 mapIndex); // @ F0145_DUNGEON_GetGroupCells uint16 getGroupDirections(Group *group, int16 mapIndex); // @ F0147_DUNGEON_GetGroupDirections + int16 getCreatureOrdinalInCell(Group *group, uint16 cell); // @ F0176_GROUP_GetCreatureOrdinalInCell + uint16 getCreatureValue(uint16 groupVal, uint16 creatureIndex); // @ M50_CREATURE_VALUE }; |