diff options
-rw-r--r-- | engines/dm/dm.cpp | 2 | ||||
-rw-r--r-- | engines/dm/dm.h | 49 | ||||
-rw-r--r-- | engines/dm/dungeonman.cpp | 81 | ||||
-rw-r--r-- | engines/dm/dungeonman.h | 45 | ||||
-rw-r--r-- | engines/dm/gfx.h | 3 |
5 files changed, 122 insertions, 58 deletions
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 9295ea6b57..72a068d31b 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -71,7 +71,7 @@ Common::Error DMEngine::run() { uint16 i = 0; //TODO: testing, please delete me while (true) { _displayMan->clearScreen(kColorBlack); - _displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY + i); + _displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY); _displayMan->updateScreen(); _system->delayMillis(2000); //TODO: testing, please set me to 10 if (++i == 100) break; diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 7c8afd132a..a0bbadd156 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -8,6 +8,11 @@ namespace DM { +class Console; +class DisplayMan; +class DungeonMan; + + enum direction { kDirNorth = 0, kDirEast = 1, @@ -15,9 +20,47 @@ enum direction { kDirWest = 3 }; -class Console; -class DisplayMan; -class DungeonMan; +int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX +int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL +enum ThingType { + kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value + kDoorThingType = 0, + kTeleporterThingType = 1, + kTextstringType = 2, + kSensorThingType = 3, + kGroupThingType = 4, + kWeaponThingType = 5, + kArmourThingType = 6, + kScrollThingType = 7, + kPotionThingType = 8, + kContainerThingType = 9, + kJunkThingType = 10, + kProjectileThingType = 14, + kExplosionThingType = 15, + kThingTypeTotal = 16 // +1 than the last (explosionThingType) +}; // @ C[00..15]_THING_TYPE_... + +class Thing { + uint16 data; +public: + static const Thing thingNone; + static const Thing thingEndOfList; + + Thing() {} + Thing(uint16 d) { set(d); } + + void set(uint16 d) { + data = d; + } + + byte getCell() const { return data >> 14; } + ThingType getType() const { return (ThingType)((data >> 10) & 0xF); } + uint16 getIndex() const { return data & 0x1FF; } + uint16 toUint16() const { return data; } // I don't like 'em cast operators + bool operator==(const Thing &rhs) const { return data == rhs.data; } + bool operator!=(const Thing &rhs) const { return data != rhs.data; } +}; // @ THING + enum { // engine debug channels diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index e2ad66a418..cd713e4127 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -12,6 +12,7 @@ int8 dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* int8 dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } +bool isOrientedWestEast(direction dir) { return dir & 1; } } @@ -458,21 +459,24 @@ enum SquareAspectIndice { kStairsUpAspect = 2, kDoorStateAspect = 2, kDoorThingIndexAspect = 3, - kFloorOrnOrdAspect = 4 + kFloorOrnOrdAspect = 4, + kFootprintsAspect = 0x8000 // @ MASK0x8000_FOOTPRINTS }; -void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) { +// TODO: get rid of the GOTOs +void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) { // complete, except where marked bool leftOrnAllowed, rightOrnAllowed, frontOrnAllowed; bool squareIsFakeWall; + bool footPrintsAllowed; + _vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75, possible fix + + memset(aspectArray, 0, 5 * sizeof(uint16)); Thing thing = getSquareFirstThing(mapX, mapY); Square square = getSquare(mapX, mapY); - memset(aspectArray, 0, 5 * sizeof(int16)); aspectArray[kElemAspect] = square.getType(); - - _vm->_displayMan->_championPortraitOrdinal = 0; // BUG0_75, possible fix switch (square.getType()) { case kWallElemType: switch (dir) { @@ -499,6 +503,7 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, } squareIsFakeWall = false; +T0172010_ClosedFakeWall: setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall); while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) { @@ -507,13 +512,13 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, if (thing.getType() == kTextstringType) { if (TextString(getThingData(thing)).isVisible()) { aspectArray[sideIndex + 1] = _currMapInscriptionWallOrnIndex + 1; - - } else { - Sensor sensor(getThingData(thing)); - aspectArray[sideIndex + 1] = sensor.getOrnOrdinal(); - if (sensor.getType() == kSensorWallChampionPortrait) { - _vm->_displayMan->_championPortraitOrdinal = indexToOrdinal(sensor.getData()); - } + _vm->_displayMan->_inscriptionThing = thing; // BUG0_76 + } + } else { + Sensor sensor(getThingData(thing)); + aspectArray[sideIndex + 1] = sensor.getOrnOrdinal(); + if (sensor.getType() == kSensorWallChampionPortrait) { + _vm->_displayMan->_championPortraitOrdinal = indexToOrdinal(sensor.getData()); } } } @@ -521,8 +526,60 @@ void DungeonMan::setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, } if (squareIsFakeWall && (_currMap.partyPosX != mapX) && (_currMap.partyPosY != mapY)) { aspectArray[kFirstGroupOrObjectAspect] = Thing::thingEndOfList.toUint16(); + return; } break; + case kPitElemType: + if (square.get(kPitOpen)) + aspectArray[kPitInvisibleAspect] = square.get(kPitInvisible); + else + aspectArray[kElemAspect] = kCorridorElemType; + footPrintsAllowed = true; + goto T0172030_Pit; + case kFakeWallElemType: + if (!square.get(kFakeWallOpen)) { + aspectArray[kElemAspect] = kWallElemType; + leftOrnAllowed = rightOrnAllowed = frontOrnAllowed = square.get(kFakeWallRandOrnOrFootPAllowed); + squareIsFakeWall = true; + goto T0172010_ClosedFakeWall; + } + aspectArray[kWallElemType] = kCorridorElemType; + footPrintsAllowed = square.get(kFakeWallRandOrnOrFootPAllowed); + // intentional fallthrough + case kCorridorElemType: + aspectArray[kFloorOrnOrdAspect] = getRandomOrnOrdinal(square.get(kCorridorRandOrnAllowed), _currMap.map->randFloorOrnCount, mapX, mapY, 30); +T0172029_Teleporter: + footPrintsAllowed = true; +T0172030_Pit: + while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) { + if (thing.getType() == kSensorThingType) + aspectArray[kFloorOrnOrdAspect] = Sensor(getThingData(thing)).getOrnOrdinal(); + thing = getNextThing(thing); + } + goto T0172049_Footprints; + case kTeleporterElemType: + aspectArray[kTeleporterVisibleAspect] = square.get(kTeleporterOpen) && square.get(kTeleporterVisible); + goto T0172029_Teleporter; + case kStairsElemType: + aspectArray[kElemAspect] = ((square.get(kStairsNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) ? kStairsSideElemType : kStairsFrontElemType; + aspectArray[kStairsUpAspect] = square.get(kStairsUp); + footPrintsAllowed = false; + goto T0172046_Stairs; + case kDoorElemType: + if ((square.get(kDoorNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) { + aspectArray[kElemAspect] = kDoorSideElemType; + } else { + aspectArray[kElemAspect] = kDoorFrontElemType; + aspectArray[kDoorStateAspect] = square.getDoorState(); + aspectArray[kDoorThingIndexAspect] = getSquareFirstThing(mapX, mapY).getIndex(); + } + footPrintsAllowed = true; +T0172046_Stairs: + while ((thing != Thing::thingEndOfList) && (thing.getType() <= kSensorThingType)) + thing = getNextThing(thing); +T0172049_Footprints: + if (footPrintsAllowed) // TODO: I skipped some party query code, must come back later and complete + aspectArray[kFloorOrnOrdAspect] &= kFootprintsAspect; } aspectArray[kFirstGroupOrObjectAspect] = thing.toUint16(); } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 931d635da0..3c0215849c 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -10,46 +10,6 @@ class DungeonMan; struct Map; -int16 ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX -int16 indexToOrdinal(int16 val); // @ M00_INDEX_TO_ORDINAL -enum ThingType { - kPartyThingType = -1, // @ CM1_THING_TYPE_PARTY, special value - kDoorThingType = 0, - kTeleporterThingType = 1, - kTextstringType = 2, - kSensorThingType = 3, - kGroupThingType = 4, - kWeaponThingType = 5, - kArmourThingType = 6, - kScrollThingType = 7, - kPotionThingType = 8, - kContainerThingType = 9, - kJunkThingType = 10, - kProjectileThingType = 14, - kExplosionThingType = 15, - kThingTypeTotal = 16 // +1 than the last (explosionThingType) -}; // @ C[00..15]_THING_TYPE_... - -class Thing { - uint16 data; -public: - static const Thing thingNone; - static const Thing thingEndOfList; - - Thing() {} - Thing(uint16 d) { set(d); } - - void set(uint16 d) { - data = d; - } - - byte getCell() const { return data >> 14; } - ThingType getType() const { return (ThingType)((data >> 10) & 0xF); } - uint16 getIndex() const { return data & 0x1FF; } - uint16 toUint16() const { return data; } // I don't like 'em cast operators - bool operator==(const Thing &rhs) const { return data == rhs.data; } - bool operator!=(const Thing &rhs) const { return data != rhs.data; } -}; // @ THING struct CreatureInfo { byte creatureAspectIndex; @@ -297,6 +257,7 @@ enum SquareMask { kWallSouthRandOrnAllowed = 0x2, kWallEastRandOrnAllowed = 0x4, kWallNorthRandOrnAllowed = 0x8, + kCorridorRandOrnAllowed = 0x8, kPitImaginary = 0x1, kPitInvisible = 0x4, kPitOpen = 0x8, @@ -334,7 +295,9 @@ public: Square(SquareType type) { setType(type); } Square &set(byte dat) { this->data = dat; return *this; } Square &set(SquareMask mask) { data |= mask; return *this; } - bool get(SquareMask mask) { return data & mask; } + byte get(SquareMask mask) { return data & mask; } + byte getDoorState() { return data & 0x7; } // @ M36_DOOR_STATE + Square &setDoorState(byte state) { data = ((data & ~0x7) | state); } // @ M37_SET_DOOR_STATE SquareType getType() { return (SquareType)(data >> 5); } // @ M34_SQUARE_TYPE Square &setType(SquareType type) { data = (data & 0x1F) | type << 5; return *this; } byte toByte() { return data; } // I don't like 'em casts diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 963a8412e3..4c54ff6ca6 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -166,7 +166,6 @@ public: void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); - int16 _championPortraitOrdinal = 0; // @ G0289_i_DungeonView_ChampionPortraitOrdinal int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount] = {0}; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices int16 _currMapFountainOrnIndices[kFountainOrnCount] = {0}; // @ G0268_ai_CurrentMapFountainOrnamentIndices @@ -179,6 +178,8 @@ public: byte _currMapDoorOrnIndices[18] = {0}; // @ G0263_auc_CurrentMapDoorOrnamentIndices int16 _currMapViAltarIndex = 0; // @ G0266_i_CurrentMapViAltarWallOrnamentIndex + + Thing _inscriptionThing = Thing::thingNone; // @ G0290_T_DungeonView_InscriptionThing }; } |