diff options
-rw-r--r-- | engines/dm/champion.cpp | 22 | ||||
-rw-r--r-- | engines/dm/champion.h | 4 | ||||
-rw-r--r-- | engines/dm/dm.cpp | 4 | ||||
-rw-r--r-- | engines/dm/dm.h | 1 | ||||
-rw-r--r-- | engines/dm/dungeonman.cpp | 217 | ||||
-rw-r--r-- | engines/dm/dungeonman.h | 1 | ||||
-rw-r--r-- | engines/dm/gfx.cpp | 875 | ||||
-rw-r--r-- | engines/dm/gfx.h | 23 |
8 files changed, 804 insertions, 343 deletions
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 333243c969..b35e0d8f5a 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -427,6 +427,28 @@ void ChampionMan::f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, Ch champ->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
}
+int16 ChampionMan::f315_getScentOrdinal(int16 mapX, int16 mapY) {
+ uint16 searchedScentRedEagle;
+ int16 scentIndex;
+ Scent* scent;
+ Scent searchedScent;
+
+
+ if (scentIndex = _g407_party._scentCount) {
+ searchedScent.setMapX(mapX);
+ searchedScent.setMapY(mapY);
+ searchedScent.setMapIndex(_vm->_dungeonMan->_g272_currMapIndex);
+ searchedScentRedEagle = searchedScent.toUint16();
+ scent = &_g407_party._scents[scentIndex--];
+ do {
+ if ((*(--scent)).toUint16() == searchedScentRedEagle) {
+ return _vm->M0_indexToOrdinal(scentIndex);
+ }
+ } while (scentIndex--);
+ }
+ return 0;
+}
+
ChampionIndex ChampionMan::f285_getIndexInCell(ViewCell cell) {
for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h index cabf06fbfb..43e976e543 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -55,6 +55,8 @@ public: void setMapX(uint16 val) { _scent = (_scent & ~0x1F) & (val & 0x1F); } void setMapY(uint16 val) { _scent = (_scent & ~(0x1F << 5)) & (val & 0x1F); } void setMapIndex(uint16 val) { _scent = (_scent & ~(0x1F << 10)) & (val & 0x3F); } + + uint16 toUint16() { return _scent; } }; // @ SCENT class Party { @@ -466,6 +468,8 @@ public: bool f295_hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged void f296_drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons void f301_addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot + int16 f315_getScentOrdinal(int16 mapX, int16 mapY); // @ F0315_CHAMPION_GetScentOrdinal + }; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 7fa1eea7b9..d824cf349a 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -88,6 +88,10 @@ uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height) { return pixelWidth / 2 * height; } +uint16 M21_normalizeModulo4(uint16 val) { + return val & 3; +} + DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { // Do not load data files // Do not initialize graphics here diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 8133fd231f..c4fe3c5ce1 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -70,6 +70,7 @@ uint16 setFlag(uint16 &val, uint16 mask); // @ M08_SET uint16 clearFlag(uint16 &val, uint16 mask); // @ M09_CLEAR uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE uint16 M75_bitmapByteCount(uint16 pixelWidth, uint16 height); // @ M75_BITMAP_BYTE_COUNT +uint16 M21_normalizeModulo4(uint16 val); // @ M21_NORMALIZE enum ThingType { diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index 0cecd049e7..fa0e72c4ba 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -30,6 +30,7 @@ #include "dungeonman.h" #include "timeline.h" +#include "champion.h" @@ -512,7 +513,7 @@ byte g236_AdditionalThingCounts[16] = { // @ G0236_auc_Graphic559_AdditionalThin 0, /* Unused */ 60, /* Projectile */ 50 /* Explosion */ -}; +}; // this is the number of uint16s the data has to be stored, not the length of the data in dungeon.dat! byte g235_ThingDataWordCount[16] = { // @ G0235_auc_Graphic559_ThingDataByteCount @@ -532,7 +533,7 @@ byte g235_ThingDataWordCount[16] = { // @ G0235_auc_Graphic559_ThingDataByteCoun 0, /* Unused */ 5, /* Projectile */ 2 /* Explosion */ -}; +}; const Thing Thing::_none(0); // @ C0xFFFF_THING_NONE const Thing Thing::_endOfList(0xFFFE); // @ C0xFFFE_THING_ENDOFLIST @@ -826,140 +827,154 @@ Thing DungeonMan::f161_getSquareFirstThing(int16 mapX, int16 mapY) { } -// TODO: get rid of the GOTOs +// TODO: produce more GOTOs void DungeonMan::f172_setSquareAspect(uint16 *aspectArray, direction dir, int16 mapX, int16 mapY) { // complete, except where marked - _vm->_displayMan->_g289_championPortraitOrdinal = 0; // BUG0_75, possible fix +#define thingType dir + byte L0307_uc_Multiple; +#define square L0307_uc_Multiple +#define footprintsAllowed L0307_uc_Multiple +#define scentOrdinal L0307_uc_Multiple + Sensor* sensor; + bool leftRandWallOrnAllowed; + int16 L0310_i_Multiple; +#define frontRandWallOrnAllowed L0310_i_Multiple +#define sideIndex L0310_i_Multiple + bool rightRandWallOrnAllowed; + int16 thingTypeRedEagle; + bool squreIsFakeWall; + Thing thing; + for (uint16 i = 0; i < 5; ++i) aspectArray[i] = 0; - Thing thing = f161_getSquareFirstThing(mapX, mapY); - Square square = f151_getSquare(mapX, mapY); - - aspectArray[k0_ElemAspect] = square.getType(); - - bool leftOrnAllowed = false; - bool rightOrnAllowed = false; - bool frontOrnAllowed = false; - bool squareIsFakeWall = false; - bool footPrintsAllowed = false; - switch (square.getType()) { - case k0_WallElemType: + thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY); + square = _vm->_dungeonMan->f151_getSquare(mapX, mapY).toByte(); + switch (aspectArray[k0_ElemAspect] = Square(square).getType()) { + case k0_ElementTypeWall: switch (dir) { case kDirNorth: - leftOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed); - frontOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed); - rightOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed); + leftRandWallOrnAllowed = getFlag(square, k0x0004_WallEastRandOrnAllowed); + frontRandWallOrnAllowed = getFlag(square, k0x0002_WallSouthRandOrnAllowed); + rightRandWallOrnAllowed = getFlag(square, k0x0001_WallWestRandOrnAllowed); break; case kDirEast: - leftOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed); - frontOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed); - rightOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed); + leftRandWallOrnAllowed = getFlag(square, k0x0002_WallSouthRandOrnAllowed); + frontRandWallOrnAllowed = getFlag(square, k0x0001_WallWestRandOrnAllowed); + rightRandWallOrnAllowed = getFlag(square, k0x0008_WallNorthRandOrnAllowed); break; case kDirSouth: - leftOrnAllowed = square.get(k0x0001_WallWestRandOrnAllowed); - frontOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed); - rightOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed); + leftRandWallOrnAllowed = getFlag(square, k0x0001_WallWestRandOrnAllowed); + frontRandWallOrnAllowed = getFlag(square, k0x0008_WallNorthRandOrnAllowed); + rightRandWallOrnAllowed = getFlag(square, k0x0004_WallEastRandOrnAllowed); break; case kDirWest: - leftOrnAllowed = square.get(k0x0008_WallNorthRandOrnAllowed); - frontOrnAllowed = square.get(k0x0004_WallEastRandOrnAllowed); - rightOrnAllowed = square.get(k0x0002_WallSouthRandOrnAllowed); - break; - default: - break; + leftRandWallOrnAllowed = getFlag(square, k0x0008_WallNorthRandOrnAllowed); + frontRandWallOrnAllowed = getFlag(square, k0x0004_WallEastRandOrnAllowed); + rightRandWallOrnAllowed = getFlag(square, k0x0002_WallSouthRandOrnAllowed); } - + /* BUG0_75 Multiple champion portraits are drawn (one at a time) then the game crashes. This variable is only + reset to 0 when at least one square in the dungeon view is a wall. If the party is in front of a wall with a + champion portrait and the next time the dungeon view is drawn there is no wall square in the view and the + square in front of the party is a fake wall with a random ornament then the same champion portrait will be + drawn again because the variable was not reset to 0. Each time _vm->_displayMan->f107_isDrawnWallOrnAnAlcove + draws the portrait, _vm->_displayMan->_g289_championPortraitOrdinal is decremented so that the portait is + different each time the dungeon view is drawn until the game crashes */ + _vm->_displayMan->_g289_championPortraitOrdinal = 0; + squreIsFakeWall = false; T0172010_ClosedFakeWall: - f171_setSquareAspectOrnOrdinals(aspectArray, leftOrnAllowed, frontOrnAllowed, rightOrnAllowed, dir, mapX, mapY, squareIsFakeWall); - - while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) { - int16 sideIndex = (thing.getCell() - dir) & 3; - if (sideIndex) { - if (thing.getType() == k2_TextstringType) { - if (TextString(f156_getThingData(thing)).isVisible()) { - aspectArray[sideIndex + 1] = _g265_currMapInscriptionWallOrnIndex + 1; - _vm->_displayMan->_g290_inscriptionThing = thing; // BUG0_76 + _vm->_dungeonMan->f171_setSquareAspectOrnOrdinals(aspectArray, + leftRandWallOrnAllowed, frontRandWallOrnAllowed, rightRandWallOrnAllowed, dir, mapX, mapY, squreIsFakeWall); + while ((thing != Thing::_endOfList) && ((thingTypeRedEagle = thing.getType()) <= k3_SensorThingType)) { + if (sideIndex = M21_normalizeModulo4(thing.getCell() - dir)) { /* Invisible on the back wall if 0 */ + sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(thing); + if (thingTypeRedEagle == k2_TextstringType) { + if (((TextString*)sensor)->isVisible()) { + aspectArray[sideIndex + 1] = _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex + 1; +/* BUG0_76 The same text is drawn on multiple sides of a wall square. The engine stores only a +single text to draw on a wall in a global variable. Even if different texts are placed on +differents sides of the wall, the same text is drawn on each affected side */ + _vm->_displayMan->_g290_inscriptionThing = thing; } } else { - Sensor sensor(f156_getThingData(thing)); - aspectArray[sideIndex + 1] = sensor.getOrnOrdinal(); - if (sensor.getType() == k127_SensorWallChampionPortrait) { - _vm->_displayMan->_g289_championPortraitOrdinal = _vm->M0_indexToOrdinal(sensor.getData()); + aspectArray[sideIndex + 1] = sensor->getOrnOrdinal(); + if (sensor->getType() == k127_SensorWallChampionPortrait) { + _vm->_displayMan->_g289_championPortraitOrdinal = _vm->M0_indexToOrdinal(sensor->getData()); } } } - thing = f159_getNextThing(thing); + thing = _vm->_dungeonMan->f159_getNextThing(thing); } - if (squareIsFakeWall && (_g306_partyMapX != mapX) && (_g307_partyMapY != mapY)) { + if (squreIsFakeWall && (_vm->_dungeonMan->_g306_partyMapX != mapX) && (_vm->_dungeonMan->_g307_partyMapY != mapY)) { aspectArray[k1_FirstGroupOrObjectAspect] = Thing::_endOfList.toUint16(); return; } break; - case k2_PitElemType: - if (square.get(k0x0008_PitOpen)) { - aspectArray[k2_PitInvisibleAspect] = square.get(k0x0004_PitInvisible); - footPrintsAllowed = square.toByte() & 1; + case k2_ElementTypePit: + if (getFlag(square, k0x0008_PitOpen)) { + aspectArray[k2_PitInvisibleAspect] = getFlag(square, k0x0004_PitInvisible); + footprintsAllowed &= 0x0001; } else { aspectArray[k0_ElemAspect] = k1_CorridorElemType; - footPrintsAllowed = true; + footprintsAllowed = true; } goto T0172030_Pit; - case k6_FakeWallElemType: - if (!square.get(k0x0004_FakeWallOpen)) { - aspectArray[k0_ElemAspect] = k0_WallElemType; - leftOrnAllowed = rightOrnAllowed = frontOrnAllowed = square.get(k0x0008_FakeWallRandOrnOrFootPAllowed); - squareIsFakeWall = true; + case k6_ElementTypeFakeWall: + if (!getFlag(square, k0x0004_FakeWallOpen)) { + aspectArray[k0_ElemAspect] = k0_ElementTypeWall; + leftRandWallOrnAllowed = rightRandWallOrnAllowed = frontRandWallOrnAllowed = getFlag(square, k0x0008_FakeWallRandOrnOrFootPAllowed); + squreIsFakeWall = true; goto T0172010_ClosedFakeWall; } - aspectArray[k0_WallElemType] = k1_CorridorElemType; - footPrintsAllowed = square.get(k0x0008_FakeWallRandOrnOrFootPAllowed); - square = Square(footPrintsAllowed ? 8 : 0); - // intentional fallthrough + aspectArray[k0_ElemAspect] = k1_CorridorElemType; + footprintsAllowed = getFlag(square, k0x0008_FakeWallRandOrnOrFootPAllowed) ? 8 : 0; case k1_CorridorElemType: - aspectArray[k4_FloorOrnOrdAspect] = f170_getRandomOrnOrdinal(square.get(k0x0008_CorridorRandOrnAllowed), _g269_currMap->_randFloorOrnCount, mapX, mapY, 30); + aspectArray[k4_FloorOrnOrdAspect] = _vm->_dungeonMan->f170_getRandomOrnOrdinal(getFlag(square, k0x0008_CorridorRandOrnAllowed), + _vm->_dungeonMan->_g269_currMap->_randFloorOrnCount, mapX, mapY, 30); T0172029_Teleporter: - footPrintsAllowed = true; + footprintsAllowed = true; T0172030_Pit: - while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) { - if (thing.getType() == k3_SensorThingType) - aspectArray[k4_FloorOrnOrdAspect] = Sensor(f156_getThingData(thing)).getOrnOrdinal(); - thing = f159_getNextThing(thing); + while ((thing != Thing::_endOfList) && ((thingType = (direction)thing.getType()) <= k3_SensorThingType)) { + if (thingType == k3_SensorThingType) { + sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(thing); + aspectArray[k4_FloorOrnOrdAspect] = sensor->getOrnOrdinal(); + } + thing = _vm->_dungeonMan->f159_getNextThing(thing); } goto T0172049_Footprints; - case k5_TeleporterElemType: - aspectArray[k2_TeleporterVisibleAspect] = square.get(k0x0008_TeleporterOpen) && square.get(k0x0004_TeleporterVisible); + case k5_ElementTypeTeleporter: + aspectArray[k2_TeleporterVisibleAspect] = getFlag(square, k0x0008_TeleporterOpen) && getFlag(square, k0x0004_TeleporterVisible); goto T0172029_Teleporter; - case k3_StairsElemType: - aspectArray[k0_ElemAspect] = ((square.get(k0x0008_StairsNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) ? k18_StairsSideElemType : k19_StairsFrontElemType; - aspectArray[k2_StairsUpAspect] = square.get(k0x0004_StairsUp); - footPrintsAllowed = false; + case k3_ElementTypeStairs: + aspectArray[k0_ElemAspect] = ((getFlag(square, k0x0008_StairsNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) ? k18_ElementTypeStairsSide : k19_ElementTypeStaisFront; + aspectArray[k2_StairsUpAspect] = getFlag(square, k0x0004_StairsUp); + footprintsAllowed = false; goto T0172046_Stairs; case k4_DoorElemType: - if ((square.get(k0x0008_DoorNorthSouthOrient) >> 3) == (isOrientedWestEast(dir) ? 1 : 0)) { + if ((getFlag(square, k0x0008_DoorNorthSouthOrient) >> 3) == isOrientedWestEast(dir)) { aspectArray[k0_ElemAspect] = k16_DoorSideElemType; } else { aspectArray[k0_ElemAspect] = k17_DoorFrontElemType; - aspectArray[k2_DoorStateAspect] = square.getDoorState(); - aspectArray[k3_DoorThingIndexAspect] = f161_getSquareFirstThing(mapX, mapY).getIndex(); + aspectArray[k2_DoorStateAspect] = Square(square).getDoorState(); + aspectArray[k3_DoorThingIndexAspect] = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY).getIndex(); } - footPrintsAllowed = true; + footprintsAllowed = true; T0172046_Stairs: - while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) - thing = f159_getNextThing(thing); + while ((thing != Thing::_endOfList) && (thing.getType() <= k3_SensorThingType)) { + thing = _vm->_dungeonMan->f159_getNextThing(thing); + } T0172049_Footprints: - unsigned char scentOrdinal; // see next line comment - if (footPrintsAllowed) // TODO: I skipped some party query code, must come back later and complete - aspectArray[k4_FloorOrnOrdAspect] &= k0x8000_FootprintsAspect; - break; - default: - break; + if (footprintsAllowed && (scentOrdinal = _vm->_championMan->f315_getScentOrdinal(mapX, mapY)) + && (--scentOrdinal >= _vm->_championMan->_g407_party._firstScentIndex) + && (scentOrdinal < _vm->_championMan->_g407_party._lastScentIndex)) { + setFlag(aspectArray[k4_FloorOrnOrdAspect], k0x8000_FootprintsAspect); + } } aspectArray[k1_FirstGroupOrObjectAspect] = thing.toUint16(); } void DungeonMan::f171_setSquareAspectOrnOrdinals(uint16 *aspectArray, bool leftAllowed, bool frontAllowed, bool rightAllowed, direction dir, - int16 mapX, int16 mapY, bool isFakeWall) { + int16 mapX, int16 mapY, bool isFakeWall) { int16 ornCount = _g269_currMap->_randWallOrnCount; turnDirRight(dir); @@ -1336,4 +1351,34 @@ int16 DungeonMan::f142_getProjectileAspect(Thing thing) { return g237_ObjectInfo[f141_getObjectInfoIndex(thing)]._objectAspectIndex; } +int16 DungeonMan::f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16* mapX, int16* mapY) { + int16 newMapX; + int16 newMapY; + int16 newLevel; + int16 offset; + Map* map; + int16 targetMapIndex; + + + if (_vm->_dungeonMan->_g309_partyMapIndex == k255_mapIndexEntrance) { + return kM1_mapIndexNone; + } + map = _vm->_dungeonMan->_g277_dungeonMaps + mapIndex; + newMapX = map->_offsetMapX + *mapX; + newMapY = map->_offsetMapY + *mapY; + newLevel = map->_level + levelDelta; + map = _vm->_dungeonMan->_g277_dungeonMaps; + for (targetMapIndex = 0; targetMapIndex < _vm->_dungeonMan->_g278_dungeonFileHeader._mapCount; targetMapIndex++) { + if ((map->_level == newLevel) + && (newMapX >= (offset = map->_offsetMapX)) + && (newMapX <= (offset + map->_width)) + && (newMapY >= (offset = map->_offsetMapY)) && (newMapY <= (offset + map->_height))) { + *mapY = newMapY - offset; + *mapX = newMapX - map->_offsetMapX; + return targetMapIndex; + } + map++; + } + return kM1_mapIndexNone; +} } diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index d2a82ac8f2..a32edcf3a4 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -648,6 +648,7 @@ public: void f163_linkThingToList(Thing thingToLink, Thing thingInList, int16 mapX, int16 mapY); // @ F0163_DUNGEON_LinkThingToList WeaponInfo *f158_getWeaponInfo(Thing thing); // @ F0158_DUNGEON_GetWeaponInfo int16 f142_getProjectileAspect(Thing thing); // @ F0142_DUNGEON_GetProjectileAspect + int16 f154_getLocationAfterLevelChange(int16 mapIndex, int16 levelDelta, int16 *mapX, int16 *mapY); // @ F0154_DUNGEON_GetLocationAfterLevelChange uint32 _rawDunFileDataSize; // @ probably NONE byte *_rawDunFileData; // @ ??? diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 2a9a90dc7a..460e7b54a9 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -40,6 +40,19 @@ namespace DM { +Box g106_BoxThievesEye_ViewPortVisibleArea(64, 159, 19, 113); // @ G0106_s_Graphic558_Box_ThievesEye_ViewportVisibleArea +byte g198_PalChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3 +byte g199_PalChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2 + +byte g197_doorButtonCoordSet[1] = {0}; // @ G0197_auc_Graphic558_DoorButtonCoordinateSet + +uint16 g208_doorButtonCoordSets[1][4][6] = { // @ G0208_aaauc_Graphic558_DoorButtonCoordinateSets + /* X1, X2, Y1, Y2, ByteWidth, Height */ + {{199, 204, 41, 44, 8, 4}, /* D3R */ + {136, 141, 41, 44, 8, 4}, /* D3C */ + {144, 155, 42, 47, 8, 6}, /* D2C */ + {160, 175, 44, 52, 8, 9}}}; /* D1C */ + DoorFrames g179_doorFrame_D3L = { // @ G0179_s_Graphic558_Frames_Door_D3L /* { X1, X2, Y1, Y2, ByteWidth, Height, X, Y } */ Frame(24, 71, 28, 67, 24, 41, 0, 0), /* Closed Or Destroyed */ @@ -1073,12 +1086,57 @@ void DisplayMan::f461_allocateFlippedWallBitmaps() { void DisplayMan::f102_drawDoorBitmap(Frame* frame) { if (frame->_srcByteWidth) { - f132_blitToBitmap(_vm->_displayMan->_g74_tmpBitmap, - _vm->_displayMan->_g296_bitmapViewport, + f132_blitToBitmap(_g74_tmpBitmap, + _g296_bitmapViewport, frame->_box, frame->_srcX, frame->_srcY, frame->_srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, frame->_srcHeight, k136_heightViewport); } } +void DisplayMan::f103_drawDoorFrameBitmapFlippedHorizontally(byte* bitmap, Frame* frame) { + if (frame->_srcByteWidth) { + f130_flipBitmapHorizontal(bitmap, frame->_srcByteWidth, frame->_srcHeight); + f132_blitToBitmap(bitmap, _g296_bitmapViewport, frame->_box, frame->_srcX, frame->_srcY, + frame->_srcByteWidth, k112_byteWidthViewport, k10_ColorFlesh, frame->_srcHeight, k136_heightViewport); + } +} + +void DisplayMan::f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButtonIndex) { + int16 nativeBitmapIndex; + int coordSet; + uint16* coordSetRedEagle; + byte* bitmap; + byte* bitmapNative; + + if (doorButtonOrdinal) { + doorButtonOrdinal--; + nativeBitmapIndex = doorButtonOrdinal + k315_firstDoorButton_GraphicIndice; + coordSetRedEagle = g208_doorButtonCoordSets[coordSet = g197_doorButtonCoordSet[doorButtonOrdinal]][viewDoorButtonIndex]; + if (viewDoorButtonIndex == k3_viewDoorButton_D1C) { + bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordSetRedEagle[0]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordSetRedEagle[1]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordSetRedEagle[2]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordSetRedEagle[3]; + } else { + if (!f491_isDerivedBitmapInCache(doorButtonOrdinal = k102_DerivedBitmapFirstDoorButton + (doorButtonOrdinal * 2) + ((!viewDoorButtonIndex) ? 0 : viewDoorButtonIndex - 1))) { + uint16* coordSetBlueGoat = g208_doorButtonCoordSets[coordSet][k3_viewDoorButton_D1C]; + bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + f129_blitToBitmapShrinkWithPalChange(bitmapNative, f492_getDerivedBitmap(doorButtonOrdinal), + coordSetBlueGoat[4] << 1, coordSetBlueGoat[5], + coordSetRedEagle[1] - coordSetRedEagle[0] + 1, + coordSetRedEagle[5], + (viewDoorButtonIndex == k2_viewDoorButton_D2C) ? g199_PalChangesDoorButtonAndWallOrn_D2 : g198_PalChangesDoorButtonAndWallOrn_D3); + + f493_addDerivedBitmap(doorButtonOrdinal); + } + bitmap = f492_getDerivedBitmap(doorButtonOrdinal); + } + f132_blitToBitmap(bitmap, _g296_bitmapViewport, *(Box*)coordSetRedEagle, 0, 0, + coordSetRedEagle[4], k112_byteWidthViewport, k10_ColorFlesh, coordSetRedEagle[5], k136_heightViewport); + } +} + void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* topAndBottomScreen) { if (middleScreenPalette && topAndBottomScreen) debugC(kDMDebugOftenCalledWarning, "MISSING CODE: F0508_AMIGA_BuildPaletteChangeCopperList"); @@ -1348,20 +1406,20 @@ void DisplayMan::f108_drawFloorOrnament(uint16 floorOrnOrdinal, uint16 viewFloor } floorOrnOrdinal--; floorOrnIndex = floorOrnOrdinal; - nativeBitmapIndex = _vm->_displayMan->_g102_currMapFloorOrnInfo[floorOrnIndex][k0_NativeBitmapIndex] + nativeBitmapIndex = _g102_currMapFloorOrnInfo[floorOrnIndex][k0_NativeBitmapIndex] + g191_floorOrnNativeBitmapndexInc[viewFloorIndex]; - coordSets = g206_floorOrnCoordSets[_vm->_displayMan->_g102_currMapFloorOrnInfo[floorOrnIndex][k1_CoordinateSet]][viewFloorIndex]; + coordSets = g206_floorOrnCoordSets[_g102_currMapFloorOrnInfo[floorOrnIndex][k1_CoordinateSet]][viewFloorIndex]; if ((viewFloorIndex == k8_viewFloor_D1R) || (viewFloorIndex == k5_viewFloor_D2R) || (viewFloorIndex == k2_viewFloor_D3R) - || ((floorOrnIndex == k15_FloorOrnFootprints) && _vm->_displayMan->_g76_useFlippedWallAndFootprintsBitmap && + || ((floorOrnIndex == k15_FloorOrnFootprints) && _g76_useFlippedWallAndFootprintsBitmap && ((viewFloorIndex == k7_viewFloor_D1C) || (viewFloorIndex == k4_viewFloor_D2C) || (viewFloorIndex == k1_viewFloor_D3C)))) { - _vm->_displayMan->f99_copyBitmapAndFlipHorizontal(_vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex), - bitmap = _vm->_displayMan->_g74_tmpBitmap, coordSets[4], coordSets[5]); + f99_copyBitmapAndFlipHorizontal(f489_getNativeBitmapOrGraphic(nativeBitmapIndex), + bitmap = _g74_tmpBitmap, coordSets[4], coordSets[5]); } else { - bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); } - _vm->_displayMan->f132_blitToBitmap(bitmap, _vm->_displayMan->_g296_bitmapViewport, - *(Box*)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport); + f132_blitToBitmap(bitmap, _g296_bitmapViewport, + *(Box*)coordSets, 0, 0, coordSets[4], k112_byteWidthViewport, k10_ColorFlesh, coordSets[5], k136_heightViewport); T0108005: if (drawFootprints) { f108_drawFloorOrnament(_vm->M0_indexToOrdinal(k15_FloorOrnFootprints), viewFloorIndex); @@ -1382,10 +1440,10 @@ void DisplayMan::f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16* d f109_drawDoorOrnament(door->getOrnOrdinal(), viewDoorOrnIndex); if (getFlag(_vm->_dungeonMan->_g275_currMapDoorInfo[doorType]._attributes, k0x0004_MaskDoorInfo_Animated)) { if (_vm->_rnd->getRandomNumber(1)) { - _vm->_displayMan->f130_flipBitmapHorizontal(_vm->_displayMan->_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight); + f130_flipBitmapHorizontal(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight); } if (_vm->_rnd->getRandomNumber(1)) { - f131_flipVertical(_vm->_displayMan->_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight); + f131_flipVertical(_g74_tmpBitmap, doorFramesTemp->_closedOrDestroyed._srcByteWidth, doorFramesTemp->_closedOrDestroyed._srcHeight); } } if ((doorFramesTemp == &g186_doorFrame_D1C) && _vm->_championMan->_g407_party._event73Count_ThievesEye) { @@ -1427,25 +1485,25 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn if (doorOrnOrdinal) { doorOrnOrdinal--; - nativeBitmapIndex = _vm->_displayMan->_g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex]; - coordSetOrangeElk = g207_doorOrnCoordSets[coordSetGreenToad = _vm->_displayMan->_g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]][viewDoorOrnIndex]; + nativeBitmapIndex = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k0_NativeBitmapIndex]; + coordSetOrangeElk = g207_doorOrnCoordSets[coordSetGreenToad = _g103_currMapDoorOrnInfo[doorOrnOrdinal][k1_CoordinateSet]][viewDoorOrnIndex]; if (viewDoorOrnIndex == k2_ViewDoorOrnament_D1LCR) { - bitmap = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + bitmap = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); byteWidth = 48; height = 88; } else { - if (!_vm->_displayMan->f491_isDerivedBitmapInCache(doorOrnOrdinal = k68_DerivedBitmapFirstDoorOrnament_D3 + (doorOrnOrdinal * 2) + viewDoorOrnIndex)) { + if (!f491_isDerivedBitmapInCache(doorOrnOrdinal = k68_DerivedBitmapFirstDoorOrnament_D3 + (doorOrnOrdinal * 2) + viewDoorOrnIndex)) { uint16 *coordSetRedEagle = g207_doorOrnCoordSets[coordSetGreenToad][k2_ViewDoorOrnament_D1LCR]; - bitmapNative = _vm->_displayMan->f489_getNativeBitmapOrGraphic(nativeBitmapIndex); - _vm->_displayMan->f129_blitToBitmapShrinkWithPalChange(bitmapNative, - f492_getDerivedBitmap(doorOrnOrdinal), - coordSetRedEagle[4] << 1, coordSetRedEagle[5], - coordSetOrangeElk[2] - coordSetOrangeElk[0] + 1, - coordSetOrangeElk[5], - (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2); - _vm->_displayMan->f493_addDerivedBitmap(doorOrnOrdinal); + bitmapNative = f489_getNativeBitmapOrGraphic(nativeBitmapIndex); + f129_blitToBitmapShrinkWithPalChange(bitmapNative, + f492_getDerivedBitmap(doorOrnOrdinal), + coordSetRedEagle[4] << 1, coordSetRedEagle[5], + coordSetOrangeElk[2] - coordSetOrangeElk[0] + 1, + coordSetOrangeElk[5], + (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) ? g200_palChangesDoorOrn_D3 : g201PalChangesDoorOrn_D2); + f493_addDerivedBitmap(doorOrnOrdinal); } - bitmap = _vm->_displayMan->f492_getDerivedBitmap(doorOrnOrdinal); + bitmap = f492_getDerivedBitmap(doorOrnOrdinal); if (viewDoorOrnIndex == k0_ViewDoorOrnament_D3LCR) { byteWidth = 24; height = 41; @@ -1454,8 +1512,25 @@ void DisplayMan::f109_drawDoorOrnament(int16 doorOrnOrdinal, int16 viewDoorOrnIn height = 61; } } - _vm->_displayMan->f132_blitToBitmap(bitmap, _vm->_displayMan->_g74_tmpBitmap, - *(Box*)coordSetOrangeElk, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height); + f132_blitToBitmap(bitmap, _g74_tmpBitmap, + *(Box*)coordSetOrangeElk, 0, 0, coordSetOrangeElk[4], byteWidth, k9_ColorGold, coordSetOrangeElk[5], height); + } +} + +void DisplayMan::f112_drawCeilingPit(int16 nativeBitmapIndex, Frame* frame, int16 mapX, int16 mapY, bool flipHorizontal) { + int16 L0117_i_Multiple; +#define AL0117_i_MapIndex L0117_i_Multiple +#define AL0117_i_Square L0117_i_Multiple + + + if (((AL0117_i_MapIndex = _vm->_dungeonMan->f154_getLocationAfterLevelChange(_vm->_dungeonMan->_g272_currMapIndex, -1, &mapX, &mapY)) >= 0) && + (Square(AL0117_i_Square = _vm->_dungeonMan->_g279_dungeonMapData[AL0117_i_MapIndex][mapX][mapY]).getType() == k2_ElementTypePit) && + getFlag(AL0117_i_Square, k0x0008_PitOpen)) { + if (flipHorizontal) { + _vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(nativeBitmapIndex, *frame); + } else { + _vm->_displayMan->f104_drawFloorPitOrStairsBitmap(nativeBitmapIndex, *frame); + } } } @@ -1553,9 +1628,9 @@ void DisplayMan::f117_drawSquareD3R(direction dir, int16 posX, int16 posY) { f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k2_viewFloor_D3R); f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k2_ViewSquare_D3R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); memmove(_g74_tmpBitmap, _g705_bitmapWallSet_DoorFrameLeft_D3L, 32 * 44); - warning("MISSING CODE: F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally"); + f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g165_Frame_DoorFrameRight_D3R); if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { - warning("MISSING CODE: F0110_DUNGEONVIEW_DrawDoorButton"); + f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k0_viewDoorButton_D3R); } f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], _g693_doorNativeBitmapIndex_Front_D3LCR, @@ -1581,162 +1656,393 @@ T0117018: } void DisplayMan::f118_drawSquareD3C(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: - if (squareAspect[k2_StairsUpAspect]) + int16 order; + int16 squareAspect[5]; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { f104_drawFloorPitOrStairsBitmap(_g676_stairsNativeBitmapIndex_Up_Front_D3C, g111_FrameStairsUpFront_D3C); - else + } else { f104_drawFloorPitOrStairsBitmap(_g683_stairsNativeBitmapIndex_Down_Front_D3C, g122_FrameStairsDownFront_D3C); - break; - case k0_WallElemType: + } + goto T0118027; + case k0_ElementTypeWall: f101_drawWallSetBitmapWithoutTransparency(_g698_bitmapWallSet_Wall_D3LCR, g163_FrameWalls[k0_ViewSquare_D3C]); if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k3_ViewWall_D3C_FRONT)) { - //... missing code + order = k0x0000_CellOrder_Alcove; + goto T0118028; } - break; - default: - break; + return; + case k17_DoorFrontElemType: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); + f100_drawWallSetBitmap(_g706_bitmapWallSet_DoorFrameLeft_D3C, g166_Frame_DoorFrameLeft_D3C); + memmove(_g74_tmpBitmap, _g706_bitmapWallSet_DoorFrameLeft_D3C, 32 * 44); + f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g167_Frame_DoorFrameRight_D3C); + if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { + f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k1_ViewDoorOrnament_D2LCR); + } + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], + _g693_doorNativeBitmapIndex_Front_D3LCR, M75_bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &g180_doorFrame_D3C); + order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; + goto T0118028; + case k2_ElementTypePit: + if (!squareAspect[k2_PitInvisibleAspect]) { + f104_drawFloorPitOrStairsBitmap(k50_FloorPit_D3C_GraphicIndice, g141_FrameFloorPit_D3C); + } + case k5_ElementTypeTeleporter: + case k1_CorridorElemType: +T0118027: + order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight; + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k1_viewFloor_D3C); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ +T0118028: + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k0_ViewSquare_D3C, order); + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + f113_drawField(&g188_FieldAspects[k0_ViewSquare_D3C], g163_FrameWalls[k0_ViewSquare_D3C]._box); } } void DisplayMan::f119_drawSquareD2L(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: - if (squareAspect[k2_StairsUpAspect]) - f104_drawFloorPitOrStairsBitmap(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L); - else - f104_drawFloorPitOrStairsBitmap(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L); - break; - case k0_WallElemType: - f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]); - f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT); - if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) { - // ... missing code + int16 order; + int16 squareAspect[5]; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { + _vm->_displayMan->f104_drawFloorPitOrStairsBitmap(_vm->_displayMan->_g677_stairsNativeBitmapIndex_Up_Front_D2L, g113_FrameStairsUpFront_D2L); + } else { + _vm->_displayMan->f104_drawFloorPitOrStairsBitmap(_vm->_displayMan->_g684_stairsNativeBitmapIndex_Down_Front_D2L, g124_FrameStairsDownFront_D2L); } - break; - case k18_StairsSideElemType: - f104_drawFloorPitOrStairsBitmap(_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L); - break; - default: - break; + goto T0119018; + case k0_ElementTypeWall: + _vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k4_ViewSquare_D2L]); + _vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k5_ViewWall_D2L_RIGHT); + if (_vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k7_ViewWall_D2L_FRONT)) { + order = k0x0000_CellOrder_Alcove; + goto T0119020; + } + return; + case k18_ElementTypeStairsSide: + _vm->_displayMan->f104_drawFloorPitOrStairsBitmap(_vm->_displayMan->_g689_stairsNativeBitmapIndex_Side_D2L, g132_FrameStairsSide_D2L); + case k16_DoorSideElemType: + order = k0x0342_CellOrder_BackRight_FrontLeft_FrontRight; + goto T0119019; + case k17_DoorFrontElemType: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); + _vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); + _vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g703_bitmapWallSet_DoorFrameTop_D2LCR, g173_Frame_DoorFrameTop_D2L); + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], _g694_doorNativeBitmapIndex_Front_D2LCR, + M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g182_doorFrame_D2L); + order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; + goto T0119020; + case k2_ElementTypePit: + _vm->_displayMan->f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, + g143_FrameFloorPit_D2L); + case k5_ElementTypeTeleporter: + case k1_CorridorElemType: +T0119018: + order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight; +T0119019: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k3_viewFloor_D2L); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ +T0119020: + f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &g152_FrameFloorPit_D2L, posX, posY, false); + _vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, order); + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + _vm->_displayMan->f113_drawField(&g188_FieldAspects[k4_ViewSquare_D2L], g163_FrameWalls[k4_ViewSquare_D2L]._box); } } void DisplayMan::f120_drawSquareD2R(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: - if (squareAspect[k2_StairsUpAspect]) - f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R); - else - f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R); - break; - case k0_WallElemType: - f100_drawWallSetBitmap(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]); - f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT); - if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) { - // ... missing code + int16 order; + int16 squareAspect[5]; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { + _vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_vm->_displayMan->_g677_stairsNativeBitmapIndex_Up_Front_D2L, g115_FrameStairsUpFront_D2R); + } else { + _vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_vm->_displayMan->_g684_stairsNativeBitmapIndex_Down_Front_D2L, g126_FrameStairsDownFront_D2R); } - break; - case k18_StairsSideElemType: - f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R); - break; - default: - break; + goto T0120027; + case k0_ElementTypeWall: + _vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k5_ViewSquare_D2R]); + _vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k6_ViewWall_D2R_LEFT); + if (_vm->_displayMan->f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k9_ViewWall_D2R_FRONT)) { + order = k0x0000_CellOrder_Alcove; + goto T0120029; + } + return; + case k18_ElementTypeStairsSide: + _vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_vm->_displayMan->_g689_stairsNativeBitmapIndex_Side_D2L, g133_FrameStairsSide_D2R); + case k16_DoorSideElemType: + order = k0x0431_CellOrder_BackLeft_FrontRight_FrontLeft; + goto T0120028; + case k17_DoorFrontElemType: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_ViewSquare_D2R); + _vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); + _vm->_displayMan->f100_drawWallSetBitmap(_vm->_displayMan->_g703_bitmapWallSet_DoorFrameTop_D2LCR, g175_Frame_DoorFrameTop_D2R); + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], + _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g184_doorFrame_D2R); + order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft; + goto T0120029; + case k2_ElementTypePit: + _vm->_displayMan->f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] + ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, g145_FrameFloorPit_D2R); + case k5_ElementTypeTeleporter: + case k1_CorridorElemType: +T0120027: + order = k0x4312_CellOrder_BackRight_BackLeft_FrontRight_FrontLeft; +T0120028: +/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k5_viewFloor_D2R); + f112_drawCeilingPit(k63_ceilingPit_D2L_GraphicIndice, &g154_FrameFloorPit_D2R, posX, posY, true); +T0120029: + _vm->_displayMan->f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, order); + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + _vm->_displayMan->f113_drawField(&g188_FieldAspects[k5_ViewSquare_D2R], g163_FrameWalls[k5_ViewSquare_D2R]._box); } } void DisplayMan::f121_drawSquareD2C(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: - if (squareAspect[k2_StairsUpAspect]) + int16 order; + int16 squareAspect[5]; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { f104_drawFloorPitOrStairsBitmap(_g678_stairsNativeBitmapIndex_Up_Front_D2C, g114_FrameStairsUpFront_D2C); - else + } else { f104_drawFloorPitOrStairsBitmap(_g685_stairsNativeBitmapIndex_Down_Front_D2C, g125_FrameStairsDownFront_D2C); - break; - case k0_WallElemType: + } + goto T0121015; + case k0_ElementTypeWall: f101_drawWallSetBitmapWithoutTransparency(_g699_bitmapWallSet_Wall_D2LCR, g163_FrameWalls[k3_ViewSquare_D2C]); if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k8_ViewWall_D2C_FRONT)) { - // ... missing code + order = k0x0000_CellOrder_Alcove; + goto T0121016; } - break; - default: - break; + return; + case k17_DoorFrontElemType: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); + f100_drawWallSetBitmap(_g703_bitmapWallSet_DoorFrameTop_D2LCR, g174_Frame_DoorFrameTop_D2C); + f100_drawWallSetBitmap(_g707_bitmapWallSet_DoorFrameLeft_D2C, g168_Frame_DoorFrameLeft_D2C); + memcpy(_g74_tmpBitmap, _g707_bitmapWallSet_DoorFrameLeft_D2C, 48 * 65); + f103_drawDoorFrameBitmapFlippedHorizontally(_g74_tmpBitmap, &g169_Frame_DoorFrameRight_D2C); + if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { + f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k2_viewDoorButton_D2C); + } + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], + _g694_doorNativeBitmapIndex_Front_D2LCR, M75_bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &g183_doorFrame_D2C); + order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; + goto T0121016; + case k2_ElementTypePit: + f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k58_FloorPit_invisible_D2C_GraphicIndice : k52_FloorPit_D2C_GraphicIndice, g144_FrameFloorPit_D2C); + case k5_ElementTypeTeleporter: + case k1_CorridorElemType: +T0121015: + order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight; + /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k4_viewFloor_D2C); + f112_drawCeilingPit(k64_ceilingPitD2C_GraphicIndice, &g153_FrameFloorPit_D2C, posX, posY, false); +T0121016: + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k3_ViewSquare_D2C, order); + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + f113_drawField(&g188_FieldAspects[k3_ViewSquare_D2C], g163_FrameWalls[k3_ViewSquare_D2C]._box); } } + void DisplayMan::f122_drawSquareD1L(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: - if (squareAspect[k2_StairsUpAspect]) + int16 order; + int16 squareAspect[5]; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { f104_drawFloorPitOrStairsBitmap(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g116_FrameStairsUpFront_D1L); - else + } else { f104_drawFloorPitOrStairsBitmap(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g127_FrameStairsDownFront_D1L); - break; - case k0_WallElemType: + } + goto T0122019; + case k0_ElementTypeWall: f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k7_ViewSquare_D1L]); f107_isDrawnWallOrnAnAlcove(squareAspect[k2_RightWallOrnOrdAspect], k10_ViewWall_D1L_RIGHT); - break; - case k18_StairsSideElemType: - if (squareAspect[k2_StairsUpAspect]) + return; + case k18_ElementTypeStairsSide: + if (squareAspect[k2_StairsUpAspect]) { f104_drawFloorPitOrStairsBitmap(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g134_FrameStairsUpSide_D1L); - else + } else { f104_drawFloorPitOrStairsBitmap(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g136_FrameStairsDownSide_D1L); - break; - default: - break; + } + case k16_DoorSideElemType: + order = k0x0032_CellOrder_BackRight_FrontRight; + goto T0122020; + case k17_DoorFrontElemType: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, k0x0028_CellOrder_DoorPass1_BackRight); + f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g176_Frame_DoorFrameTop_D1L); + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], + _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &g185_doorFrame_D1L); + order = k0x0039_CellOrder_DoorPass2_FrontRight; + goto T0122021; + case k2_ElementTypePit: + f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice : k53_FloorPit_D1L_GraphicIndice, g146_FrameFloorPit_D1L); + case k5_ElementTypeTeleporter: + case k1_CorridorElemType: +T0122019: + order = k0x0032_CellOrder_BackRight_FrontRight; +T0122020: + /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k6_viewFloor_D1L); + f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &g155_FrameFloorPit_D1L, posX, posY, false); +T0122021: + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, order); + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + f113_drawField(&g188_FieldAspects[k7_ViewSquare_D1L], g163_FrameWalls[k7_ViewSquare_D1L]._box); } } void DisplayMan::f123_drawSquareD1R(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: - if (squareAspect[k2_StairsUpAspect]) + int16 order; + int16 squareAspect[5]; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g679_stairsNativeBitmapIndex_Up_Front_D1L, g118_FrameStairsUpFront_D1R); - else + } else { f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g686_stairsNativeBitmapIndex_Down_Front_D1L, g129_FrameStairsDownFront_D1R); - break; - case k0_WallElemType: + } + goto T0123019; + case k0_ElementTypeWall: f100_drawWallSetBitmap(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k8_ViewSquare_D1R]); f107_isDrawnWallOrnAnAlcove(squareAspect[k4_LeftWallOrnOrdAspect], k11_ViewWall_D1R_LEFT); - break; - case k18_StairsSideElemType: - if (squareAspect[k2_StairsUpAspect]) + return; + case k18_ElementTypeStairsSide: + if (squareAspect[k2_StairsUpAspect]) { f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g690_stairsNativeBitmapIndex_Up_Side_D1L, g135_FrameStairsUpSide_D1R); - else + } else { f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g691_stairsNativeBitmapIndex_Down_Side_D1L, g137_FrameStairsDownSide_D1R); - break; - default: - break; + } + case k16_DoorSideElemType: + order = k0x0041_CellOrder_BackLeft_FrontLeft; + goto T0123020; + case k17_DoorFrontElemType: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, k0x0018_CellOrder_DoorPass1_BackLeft); + f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g178_Frame_DoorFrameTop_D1R); + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], + _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &g187_doorFrame_D1R); + order = k0x0049_CellOrder_DoorPass2_FrontLeft; + goto T0123021; + case k2_ElementTypePit: + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] ? k59_floorPit_invisible_D1L_GraphicIndice + : k53_FloorPit_D1L_GraphicIndice, g148_FrameFloorPit_D1R); + case k5_ElementTypeTeleporter: + case k1_CorridorElemType: +T0123019: + order = k0x0041_CellOrder_BackLeft_FrontLeft; +T0123020: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k8_viewFloor_D1R); /* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ + f112_drawCeilingPit(k65_ceilingPitD1L_GraphicIndice, &g157_FrameFloorPit_D1R, posX, posY, true); +T0123021: + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, order); + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + f113_drawField(&g188_FieldAspects[k8_ViewSquare_D1R], g163_FrameWalls[k8_ViewSquare_D1R]._box); } } void DisplayMan::f124_drawSquareD1C(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: - if (squareAspect[k2_StairsUpAspect]) + static Box g107_BoxThievesEyeVisibleArea(0, 95, 0, 94); // @ G0107_s_Graphic558_Box_ThievesEye_VisibleArea + int16 order; + int16 squareAspect[5]; + byte* bitmap; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16*)squareAspect, dir, posX, posY); + switch (_vm->_dungeonMan->_g285_squareAheadElement = (ElementType)squareAspect[k0_ElemAspect]) { + case k19_ElementTypeStaisFront: + if (squareAspect[k2_StairsUpAspect]) { f104_drawFloorPitOrStairsBitmap(_g680_stairsNativeBitmapIndex_Up_Front_D1C, g117_FrameStairsUpFront_D1C); - else + } else { f104_drawFloorPitOrStairsBitmap(_g687_stairsNativeBitmapIndex_Down_Front_D1C, g128_FrameStairsDownFront_D1C); - break; - case k0_WallElemType: + } + goto T0124017; + case k0_ElementTypeWall: _vm->_dungeonMan->_g286_isFacingAlcove = false; _vm->_dungeonMan->_g287_isFacingViAltar = false; _vm->_dungeonMan->_g288_isFacingFountain = false; + if (_vm->_championMan->_g407_party._event73Count_ThievesEye) { + f491_isDerivedBitmapInCache(k1_DerivedBitmapThievesEyeVisibleArea); + f132_blitToBitmap(_g296_bitmapViewport, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea), + g107_BoxThievesEyeVisibleArea, + g106_BoxThievesEye_ViewPortVisibleArea._x1, + g106_BoxThievesEye_ViewPortVisibleArea._y1, + k112_byteWidthViewport, 48, k255_ColorNoTransparency, 136, 95); + bitmap = f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice); + /* BUG0_74 Creatures are drawn with wrong colors when viewed through a wall with the 'Thieve's Eye' spell. The 'hole in wall' + graphic is applied to the visible area with transparency on color 10. However the visible area may contain creature graphics + that use color 9. When the bitmap is drawn below with transparency on color 9 then the creature graphic is alterated: pixels + using color 9 are transparent and the background wall is visible through the creature graphic (grey/white pixels). + To fix this bug, the 'hole in wall' graphic should be applied to the wall graphic first (in a temporary buffer) and + then the wall with the hole should be drawn over the visible area */ + f132_blitToBitmap(bitmap, f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea), + g107_BoxThievesEyeVisibleArea, + 0, 0, 48, 48, k10_ColorFlesh, 95, 95); + } f101_drawWallSetBitmapWithoutTransparency(_g700_bitmapWallSet_Wall_D1LCR, g163_FrameWalls[k6_ViewSquare_D1C]); if (f107_isDrawnWallOrnAnAlcove(squareAspect[k3_FrontWallOrnOrdAspect], k12_ViewWall_D1C_FRONT)) { - // .... code not yet implemneted + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0000_CellOrder_Alcove); } - break; - default: - break; + if (_vm->_championMan->_g407_party._event73Count_ThievesEye) { + f132_blitToBitmap(f492_getDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea), + _g296_bitmapViewport, g106_BoxThievesEye_ViewPortVisibleArea, 0, 0, + 48, k112_byteWidthViewport, k9_ColorGold, 95, k136_heightViewport); /* BUG0_74 */ + f493_addDerivedBitmap(k1_DerivedBitmapThievesEyeVisibleArea); + warning("MISSING CODE: F0480_CACHE_ReleaseBlock"); + } + return; + case k17_DoorFrontElemType: + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); + f100_drawWallSetBitmap(_g704_bitmapWallSet_DoorFrameTop_D1LCR, g177_Frame_DoorFrameTop_D1C); + f100_drawWallSetBitmap(_g708_bitmapWallSet_DoorFrameLeft_D1C, g170_Frame_DoorFrameLeft_D1C); + f100_drawWallSetBitmap(_g710_bitmapWallSet_DoorFrameRight_D1C, g171_Frame_DoorFrameRight_D1C); + if (((Door*)_vm->_dungeonMan->_g284_thingData[k0_DoorThingType])[squareAspect[k3_DoorThingIndexAspect]].hasButton()) { + f110_drawDoorButton(_vm->M0_indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C); + } + f111_drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], + _g695_doorNativeBitmapIndex_Front_D1LCR, M75_bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &g186_doorFrame_D1C); + order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; + goto T0124018; + case k2_ElementTypePit: + f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k60_floorPitInvisibleD1C_GraphicIndice : k54_FloorPit_D1C_GraphicIndice, g147_FrameFloorPit_D1C); + case k5_ElementTypeTeleporter: + case k1_CorridorElemType: +T0124017: + order = k0x3421_CellOrder_BackLeft_BackRight_FrontLeft_FrontRight; +/* BUG0_64 Floor ornaments are drawn over open pits. There is no check to prevent drawing floor ornaments over open pits */ + f108_drawFloorOrnament(squareAspect[k4_FloorOrnOrdAspect], k7_viewFloor_D1C); + f112_drawCeilingPit(k66_ceilingPitD1C_GraphicIndice, &g156_FrameFloorPit_D1C, posX, posY, false); +T0124018: + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k6_ViewSquare_D1C, order); + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + f113_drawField(&g188_FieldAspects[k6_ViewSquare_D1C], g163_FrameWalls[k6_ViewSquare_D1C]._box); } } @@ -1757,26 +2063,51 @@ void DisplayMan::f125_drawSquareD0L(direction dir, int16 posX, int16 posY) { } void DisplayMan::f126_drawSquareD0R(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k18_StairsSideElemType: - if (squareAspect[k2_StairsUpAspect]) - f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R); + int16 squareAspect[5]; + + + _vm->_dungeonMan->f172_setSquareAspect((uint16 *)squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k18_ElementTypeStairsSide: + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g692_stairsNativeBitmapIndex_Side_D0L, g139_FrameStairsSide_D0R); return; - case k0_WallElemType: - f100_drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, g163_FrameWalls[k11_ViewSquare_D0R]); - break; - default: + case k2_ElementTypePit: + f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect] ? k61_floorPitInvisibleD0L_GraphicIndice + : k55_FloorPit_D0L_GraphicIndice, g151_FrameFloorPit_D0R); + case k1_CorridorElemType: + case k16_DoorSideElemType: + case k5_ElementTypeTeleporter: + f112_drawCeilingPit(k67_ceilingPitD0L_grahicIndice, &g160_FrameFloorPit_D0R, posX, posY, true); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k11_ViewSquare_D0R, k0x0001_CellOrder_BackLeft); break; + case k0_ElementTypeWall: + f100_drawWallSetBitmap(_g702_bitmapWallSet_Wall_D0R, g163_FrameWalls[k11_ViewSquare_D0R]); + return; + } + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + f113_drawField(&g188_FieldAspects[k11_ViewSquare_D0R], g163_FrameWalls[k11_ViewSquare_D0R]._box); } } void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) { - uint16 squareAspect[5]; - _vm->_dungeonMan->f172_setSquareAspect(squareAspect, dir, posX, posY); - switch (squareAspect[0]) { - case k19_StairsFrontElemType: + static Box g108_BoxThievesEyeHoleInDoorFrame(0, 31, 19, 113); // @ G0108_s_Graphic558_Box_ThievesEye_HoleInDoorFrame + + int16 squareAspect[5]; + + _vm->_dungeonMan->f172_setSquareAspect((uint16*) squareAspect, dir, posX, posY); + switch (squareAspect[k0_ElemAspect]) { + case k16_DoorSideElemType: + if (_vm->_championMan->_g407_party._event73Count_ThievesEye) { + memmove(_g74_tmpBitmap, _g709_bitmapWallSet_DoorFrameFront, 32 * 123); + f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k41_holeInWall_GraphicIndice), + _g74_tmpBitmap, g108_BoxThievesEyeHoleInDoorFrame, g172_Frame_DoorFrame_D0C._box._x1 - g106_BoxThievesEye_ViewPortVisibleArea._x1, + 0, 48, 16, k9_ColorGold, 95, 123); + f100_drawWallSetBitmap(_g74_tmpBitmap, g172_Frame_DoorFrame_D0C); + } else { + f100_drawWallSetBitmap(_g709_bitmapWallSet_DoorFrameFront, g172_Frame_DoorFrame_D0C); + } + break; + case k19_ElementTypeStaisFront: if (squareAspect[k2_StairsUpAspect]) { f104_drawFloorPitOrStairsBitmap(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g119_FrameStairsUpFront_D0L); f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g681_stairsNativeBitmapIndex_Up_Front_D0C_Left, g120_FrameStairsUpFront_D0R); @@ -1785,8 +2116,13 @@ void DisplayMan::f127_drawSquareD0C(direction dir, int16 posX, int16 posY) { f105_drawFloorPitOrStairsBitmapFlippedHorizontally(_g688_stairsNativeBitmapIndex_Down_Front_D0C_Left, g131_FrameStairsDownFront_D0R); } break; - default: - break; + case k2_ElementTypePit: + f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k62_flootPitInvisibleD0C_graphicIndice : k56_FloorPit_D0C_GraphicIndice, g150_FrameFloorPit_D0C); + } + f112_drawCeilingPit(k68_ceilingPitD0C_graphicIndice, &g159_FrameFloorPit_D0C, posX, posY, false); + f115_cthulhu(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k9_ViewSquare_D0C, k0x0021_CellOrder_BackLeft_BackRight); + if ((squareAspect[k0_ElemAspect] == k5_ElementTypeTeleporter) && squareAspect[k2_TeleporterVisibleAspect]) { + f113_drawField(&g188_FieldAspects[k9_ViewSquare_D0C], g163_FrameWalls[k9_ViewSquare_D0C]._box); } } @@ -2086,8 +2422,6 @@ byte g190_WallOrnDerivedBitmapIndexIncrement[12] = { // @ G0190_auc_Graphic558_W 4, /* D1L Right */ 4}; /* D1R Left */ -byte g198_PalChangesDoorButtonAndWallOrn_D3[16] = {0, 0, 120, 30, 40, 30, 0, 60, 30, 90, 100, 110, 0, 10, 0, 20}; // @ G0198_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D3 -byte g199_PalChangesDoorButtonAndWallOrn_D2[16] = {0, 120, 10, 30, 40, 30, 60, 70, 50, 90, 100, 110, 0, 20, 140, 130}; // @ G0199_auc_Graphic558_PaletteChanges_DoorButtonAndWallOrnament_D2 byte g204_UnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_UnreadableInscriptionBoxY2 /* { Y for 1 line, Y for 2 lines, Y for 3 lines } */ @@ -2100,141 +2434,168 @@ byte g204_UnreadableInscriptionBoxY2[15] = { // @ G0204_auc_Graphic558_Unreadabl Box g109_BoxChampionPortraitOnWall = Box(96, 127, 35, 63); // G0109_s_Graphic558_Box_ChampionPortraitOnWall bool DisplayMan::f107_isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex) { - byte *bitmapGreen; - byte *bitmapRed; - int16 coordinateSetOffset; - bool flipHorizontal; - bool isInscription; - bool isAlcove; - Frame frame; - unsigned char inscriptionString[70]; +#define AP0116_i_CharacterCount wallOrnOrd +#define AP0116_i_WallOrnamentIndex wallOrnOrd + int16 L0088_i_Multiple; +#define AL0088_i_NativeBitmapIndex L0088_i_Multiple +#define AL0088_i_UnreadableTextLineCount L0088_i_Multiple + int16 L0089_i_Multiple; +#define AL0089_i_WallOrnamentCoordinateSetIndex L0089_i_Multiple +#define AL0089_i_FountainOrnamentIndex L0089_i_Multiple +#define AL0089_i_PixelWidth L0089_i_Multiple +#define AL0089_i_X L0089_i_Multiple + + uint16 *AL0090_puc_CoordinateSet = nullptr; + + byte* L0091_puc_Multiple; +#define AL0091_puc_Character L0091_puc_Multiple +#define AL0091_puc_Bitmap L0091_puc_Multiple + byte* L0092_puc_Bitmap; + int16 L0093_i_CoordinateSetOffset; + bool L0094_B_FlipHorizontal; + bool L0095_B_IsInscription; + bool L0096_B_IsAlcove; + int16 L0097_i_TextLineIndex; + uint16 tmp[6]; + byte L0099_auc_InscriptionString[70]; if (wallOrnOrd) { - int16 var_X; - int16 wallOrnIndex = wallOrnOrd - 1; - int16 nativeBitmapIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k0_NativeBitmapIndex]; + wallOrnOrd--; + AL0088_i_NativeBitmapIndex = _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k0_NativeBitmapIndex]; - uint16 *coordinateSetA = g205_WallOrnCoordSets[_g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]][viewWallIndex]; - isAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(wallOrnIndex); - isInscription = (wallOrnIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex); - if (isInscription) { - _vm->_dungeonMan->f168_decodeText((char*)inscriptionString, _g290_inscriptionThing, k0_TextTypeInscription); - } + AL0090_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex = + _g101_currMapWallOrnInfo[AP0116_i_WallOrnamentIndex][k1_CoordinateSet]][viewWallIndex]; + L0096_B_IsAlcove = _vm->_dungeonMan->f149_isWallOrnAnAlcove(AP0116_i_WallOrnamentIndex); + if (L0095_B_IsInscription = (AP0116_i_WallOrnamentIndex == _vm->_dungeonMan->_g265_currMapInscriptionWallOrnIndex)) { + _vm->_dungeonMan->f168_decodeText((char *)L0099_auc_InscriptionString, _g290_inscriptionThing, k0_TextTypeInscription); + } if (viewWallIndex >= k10_ViewWall_D1L_RIGHT) { if (viewWallIndex == k12_ViewWall_D1C_FRONT) { - if (isInscription) { - Frame &D1CFrame = g163_FrameWalls[k6_ViewSquare_D1C]; - f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR, _g296_bitmapViewport, g202_BoxWallPatchBehindInscription, 94, 28, - D1CFrame._srcByteWidth, k112_byteWidthViewport, k255_ColorNoTransparency); - - unsigned char *string = inscriptionString; - bitmapRed = _bitmaps[k120_InscriptionFontIndice]; - int16 textLineIndex = 0; + if (L0095_B_IsInscription) { + f132_blitToBitmap(_g700_bitmapWallSet_Wall_D1LCR,_g296_bitmapViewport, + g202_BoxWallPatchBehindInscription, 94, 28, + g163_FrameWalls[k6_ViewSquare_D1C]._srcByteWidth, + k112_byteWidthViewport, k255_ColorNoTransparency, g163_FrameWalls[k6_ViewSquare_D1C]._srcHeight, k136_heightViewport); + byte *AL0090_puc_String = L0099_auc_InscriptionString; + L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(k120_InscriptionFont); + L0097_i_TextLineIndex = 0; do { - int16 characterCount = 0; - unsigned char *character = string; - while (*character++ < 0x80) { - characterCount++; + AP0116_i_CharacterCount = 0; + AL0091_puc_Character = AL0090_puc_String; + while (*AL0091_puc_Character++ < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */ + AP0116_i_CharacterCount++; } - frame._box._x2 = (frame._box._x1 = 112 - (characterCount * 4)) + 7; - frame._box._y1 = (frame._box._y2 = g203_InscriptionLineY[textLineIndex++]) - 7; - while (characterCount--) { - f132_blitToBitmap(bitmapRed, _g296_bitmapViewport, frame._box, (*string++) * 8, 0, 144, k112_byteWidthViewport, k10_ColorFlesh); - frame._box._x1 += 8; - frame._box._x2 += 8; + Frame L0098_s_Frame; + L0098_s_Frame._box._x2 = (L0098_s_Frame._box._x1 = 112 - (AP0116_i_CharacterCount << 2)) + 7; + L0098_s_Frame._box._y1 = (L0098_s_Frame._box._y2 = g203_InscriptionLineY[L0097_i_TextLineIndex++]) - 7; + while (AP0116_i_CharacterCount--) { + f132_blitToBitmap(L0092_puc_Bitmap, _g296_bitmapViewport, L0098_s_Frame._box, + *AL0090_puc_String++ << 3, 0, 144, k112_byteWidthViewport, k10_ColorFlesh, 8, k136_heightViewport); + L0098_s_Frame._box._x1 += 8; + L0098_s_Frame._box._x2 += 8; } - } while (*string++ != 0x81); - return isAlcove; + } while (*AL0090_puc_String++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */ + goto T0107031; } - nativeBitmapIndex++; - - _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = coordinateSetA[0]; - _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = coordinateSetA[1]; - _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = coordinateSetA[2]; - _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = coordinateSetA[3]; - - _vm->_dungeonMan->_g286_isFacingAlcove = isAlcove; - _vm->_dungeonMan->_g287_isFacingViAltar = (wallOrnIndex == _g266_currMapViAltarIndex); + AL0088_i_NativeBitmapIndex++; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x1 = AL0090_puc_CoordinateSet[0]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._x2 = AL0090_puc_CoordinateSet[1]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y1 = AL0090_puc_CoordinateSet[2]; + _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn]._y2 = AL0090_puc_CoordinateSet[3]; + + _vm->_dungeonMan->_g286_isFacingAlcove = L0096_B_IsAlcove; + _vm->_dungeonMan->_g287_isFacingViAltar = + (AP0116_i_WallOrnamentIndex == _g266_currMapViAltarIndex); _vm->_dungeonMan->_g288_isFacingFountain = false; - for (int16 fountainOrnIndex = 0; fountainOrnIndex < k1_FountainOrnCount; ++fountainOrnIndex) { - if (_g268_currMapFountainOrnIndices[fountainOrnIndex] == wallOrnIndex) { + for (AL0089_i_FountainOrnamentIndex = 0; AL0089_i_FountainOrnamentIndex < k1_FountainOrnCount; AL0089_i_FountainOrnamentIndex++) { + if (_g268_currMapFountainOrnIndices[AL0089_i_FountainOrnamentIndex] == AP0116_i_WallOrnamentIndex) { _vm->_dungeonMan->_g288_isFacingFountain = true; break; } } } - bitmapGreen = _bitmaps[nativeBitmapIndex]; + AL0091_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex); if (viewWallIndex == k11_ViewWall_D1R_LEFT) { - f99_copyBitmapAndFlipHorizontal(bitmapGreen, _g74_tmpBitmap, coordinateSetA[4], coordinateSetA[5]); - bitmapGreen = _g74_tmpBitmap; + f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]); + AL0091_puc_Bitmap = _g74_tmpBitmap; } - var_X = 0; + AL0089_i_X = 0; } else { - coordinateSetOffset = 0; - uint16 *coordSetB; - int16 wallOrnCoordSetIndex = _g101_currMapWallOrnInfo[wallOrnIndex][k1_CoordinateSet]; - flipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT); - if (flipHorizontal) { - coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k11_ViewWall_D1R_LEFT]; - } else if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) { - coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k10_ViewWall_D1L_RIGHT]; + uint16 *AL0091_puc_CoordinateSet; + L0093_i_CoordinateSetOffset = 0; + if (L0094_B_FlipHorizontal = (viewWallIndex == k6_ViewWall_D2R_LEFT) || (viewWallIndex == k1_ViewWall_D3R_LEFT)) { + AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k11_ViewWall_D1R_LEFT]; } else { - nativeBitmapIndex++; - coordSetB = g205_WallOrnCoordSets[wallOrnCoordSetIndex][k12_ViewWall_D1C_FRONT]; - if (viewWallIndex == k7_ViewWall_D2L_FRONT) { - coordinateSetOffset = 6; - } else if (viewWallIndex == k9_ViewWall_D2R_FRONT) { - coordinateSetOffset = -6; + if ((viewWallIndex == k5_ViewWall_D2L_RIGHT) || (viewWallIndex == k0_ViewWall_D3L_RIGHT)) { + AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k10_ViewWall_D1L_RIGHT]; + } else { + AL0088_i_NativeBitmapIndex++; + AL0091_puc_CoordinateSet = g205_WallOrnCoordSets[AL0089_i_WallOrnamentCoordinateSetIndex][k12_ViewWall_D1C_FRONT]; + if (viewWallIndex == k7_ViewWall_D2L_FRONT) { + L0093_i_CoordinateSetOffset = 6; + } else { + if (viewWallIndex == k9_ViewWall_D2R_FRONT) { + L0093_i_CoordinateSetOffset = -6; + } + } } } - int16 pixelWidth = (coordinateSetA + coordinateSetOffset)[1] - (coordinateSetA + coordinateSetOffset)[0]; - f129_blitToBitmapShrinkWithPalChange(_bitmaps[nativeBitmapIndex], _g74_tmpBitmap, coordSetB[4] << 1, coordSetB[5], pixelWidth + 1, coordinateSetA[5], - (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2); - bitmapGreen = _bitmaps[nativeBitmapIndex]; - var_X = pixelWidth; - if (flipHorizontal) { - f99_copyBitmapAndFlipHorizontal(bitmapGreen, _g74_tmpBitmap, coordSetB[4], coordSetB[5]); - bitmapGreen = _g74_tmpBitmap; - var_X = 15 - (var_X & 0xF); - } else if (viewWallIndex == k7_ViewWall_D2L_FRONT) { - var_X -= coordinateSetA[1] - coordinateSetA[0]; + AL0089_i_PixelWidth = (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[1] - (AL0090_puc_CoordinateSet + L0093_i_CoordinateSetOffset)[0]; + if (!f491_isDerivedBitmapInCache(AP0116_i_WallOrnamentIndex = k4_DerivedBitmapFirstWallOrnament + + (AP0116_i_WallOrnamentIndex << 2) + g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex])) { + L0092_puc_Bitmap = f489_getNativeBitmapOrGraphic(AL0088_i_NativeBitmapIndex); + f129_blitToBitmapShrinkWithPalChange(L0092_puc_Bitmap, f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex), + AL0091_puc_CoordinateSet[4] << 1, + AL0091_puc_CoordinateSet[5], AL0089_i_PixelWidth + 1, + AL0090_puc_CoordinateSet[5], + (viewWallIndex <= k4_ViewWall_D3R_FRONT) ? g198_PalChangesDoorButtonAndWallOrn_D3 : g199_PalChangesDoorButtonAndWallOrn_D2); + f493_addDerivedBitmap(AP0116_i_WallOrnamentIndex); + } + AL0091_puc_Bitmap = f492_getDerivedBitmap(AP0116_i_WallOrnamentIndex); + if (L0094_B_FlipHorizontal) { + f99_copyBitmapAndFlipHorizontal(AL0091_puc_Bitmap, _g74_tmpBitmap, AL0090_puc_CoordinateSet[4], AL0090_puc_CoordinateSet[5]); + AL0091_puc_Bitmap = _g74_tmpBitmap; + AL0089_i_X = 15 - (AL0089_i_X & 0x000F); } else { - var_X = 0; + if (viewWallIndex == k7_ViewWall_D2L_FRONT) { + AL0089_i_X -= AL0090_puc_CoordinateSet[1] - AL0090_puc_CoordinateSet[0]; + } else { + AL0089_i_X = 0; + } } } - if (isInscription) { - unsigned char *string = inscriptionString; - int16 unreadableTextLineCount = 0; + if (L0095_B_IsInscription) { + byte *AL0090_puc_String = L0099_auc_InscriptionString; + AL0088_i_UnreadableTextLineCount = 0; do { - while (*string < 0x80) { - string++; + while (*AL0090_puc_String < 128) { /* Hexadecimal: 0x80 (Megamax C does not support hexadecimal character constants) */ + AL0090_puc_String++; } - unreadableTextLineCount++; - } while (*string++ != 0x81); - - if (unreadableTextLineCount < 4) { - frame._box._x1 = coordinateSetA[0]; - frame._box._x2 = coordinateSetA[1]; - frame._box._y1 = coordinateSetA[2]; - frame._box._y2 = coordinateSetA[3]; - frame._srcByteWidth = coordinateSetA[4]; - frame._srcHeight = coordinateSetA[5]; - - coordinateSetA = (uint16*)&frame._box; - - coordinateSetA[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + unreadableTextLineCount - 1]; + AL0088_i_UnreadableTextLineCount++; + } while (*AL0090_puc_String++ != 129); /* Hexadecimal: 0x81 (Megamax C does not support hexadecimal character constants) */ + if (AL0088_i_UnreadableTextLineCount < 4) { + for (uint16 i = 0; i < 6; ++i) + tmp[i] = AL0090_puc_CoordinateSet[i]; + AL0090_puc_CoordinateSet = tmp; + AL0090_puc_CoordinateSet[3] = g204_UnreadableInscriptionBoxY2[g190_WallOrnDerivedBitmapIndexIncrement[viewWallIndex] * 3 + AL0088_i_UnreadableTextLineCount - 1]; } } - f132_blitToBitmap(bitmapGreen, _g296_bitmapViewport, *(Box*)coordinateSetA, var_X, 0, coordinateSetA[4], k112_byteWidthViewport, k10_ColorFlesh); - - if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { - Box &box = g109_BoxChampionPortraitOnWall; - f132_blitToBitmap(_bitmaps[k26_ChampionPortraitsIndice], _g296_bitmapViewport, box, (_g289_championPortraitOrdinal & 0x7) << 5, - (_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary); + f132_blitToBitmap(AL0091_puc_Bitmap, _g296_bitmapViewport, + *(Box*)AL0090_puc_CoordinateSet, AL0089_i_X, 0, + AL0090_puc_CoordinateSet[4], k112_byteWidthViewport, k10_ColorFlesh, AL0090_puc_CoordinateSet[5], k136_heightViewport); +/* BUG0_05 A champion portrait sensor on a wall square is visible on all sides of the wall. +If there is another sensor with a wall ornament on one side of the wall then the champion portrait is drawn over that wall ornament */ + if ((viewWallIndex == k12_ViewWall_D1C_FRONT) && _g289_championPortraitOrdinal--) { +/* A portrait is 32x29 pixels */ + f132_blitToBitmap(f489_getNativeBitmapOrGraphic(k26_ChampionPortraitsIndice), + _g296_bitmapViewport, g109_BoxChampionPortraitOnWall, + (_g289_championPortraitOrdinal & 0x0007) << 5, + (_g289_championPortraitOrdinal >> 3) * 29, 128, k112_byteWidthViewport, k1_ColorDarkGary, 87, k136_heightViewport); } - return isAlcove; +T0107031: + return L0096_B_IsAlcove; } return false; } diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 1db59901e4..cfe271052d 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -57,6 +57,11 @@ namespace DM { #define k1_ViewDoorOrnament_D2LCR 1 // @ C1_VIEW_DOOR_ORNAMENT_D2LCR #define k2_ViewDoorOrnament_D1LCR 2 // @ C2_VIEW_DOOR_ORNAMENT_D1LCR +#define k0_viewDoorButton_D3R 0 // @ C0_VIEW_DOOR_BUTTON_D3R +#define k1_viewDoorButton_D3C 1 // @ C1_VIEW_DOOR_BUTTON_D3C +#define k2_viewDoorButton_D2C 2 // @ C2_VIEW_DOOR_BUTTON_D2C +#define k3_viewDoorButton_D1C 3 // @ C3_VIEW_DOOR_BUTTON_D1C + #define k0x0001_MaskDoorInfo_CraturesCanSeeThrough 0x0001 // @ MASK0x0001_CREATURES_CAN_SEE_THROUGH #define k0x0002_MaskDoorInfo_ProjectilesCanPassThrough 0x0002 // @ MASK0x0002_PROJECTILES_CAN_PASS_THROUGH #define k0x0004_MaskDoorInfo_Animated 0x0004 // @ MASK0x0004_ANIMATED @@ -222,6 +227,7 @@ enum GraphicIndice { k38_BorderPartyFireshieldIndice = 38, // @ C038_GRAPHIC_BORDER_PARTY_FIRESHIELD k39_BorderPartySpellshieldIndice = 39, // @ C039_GRAPHIC_BORDER_PARTY_SPELLSHIELD k40_PanelResurectReincaranteIndice = 40, // @ C040_GRAPHIC_PANEL_RESURRECT_REINCARNATE + k41_holeInWall_GraphicIndice = 41, // @ C041_GRAPHIC_HOLE_IN_WALL k42_ObjectIcons_000_TO_031 = 42, // @ C042_GRAPHIC_OBJECT_ICONS_000_TO_031 k43_ObjectIcons_032_TO_063 = 43, // @ C043_GRAPHIC_OBJECT_ICONS_032_TO_063 k44_ObjectIcons_064_TO_095 = 44, // @ C044_GRAPHIC_OBJECT_ICONS_064_TO_095 @@ -237,11 +243,24 @@ enum GraphicIndice { k54_FloorPit_D1C_GraphicIndice = 54, // @ C054_GRAPHIC_FLOOR_PIT_D1C k55_FloorPit_D0L_GraphicIndice = 55, // @ C055_GRAPHIC_FLOOR_PIT_D0L k56_FloorPit_D0C_GraphicIndice = 56, // @ C056_GRAPHIC_FLOOR_PIT_D0C + k57_FloorPir_Invisible_D2L_GraphicIndice = 57, // @ C057_GRAPHIC_FLOOR_PIT_INVISIBLE_D2L + k58_FloorPit_invisible_D2C_GraphicIndice = 58, // @ C058_GRAPHIC_FLOOR_PIT_INVISIBLE_D2C + k59_floorPit_invisible_D1L_GraphicIndice = 59, // @ C059_GRAPHIC_FLOOR_PIT_INVISIBLE_D1L + k60_floorPitInvisibleD1C_GraphicIndice = 60, // @ C060_GRAPHIC_FLOOR_PIT_INVISIBLE_D1C + k61_floorPitInvisibleD0L_GraphicIndice = 61, // @ C061_GRAPHIC_FLOOR_PIT_INVISIBLE_D0L + k62_flootPitInvisibleD0C_graphicIndice = 62, // @ C062_GRAPHIC_FLOOR_PIT_INVISIBLE_D0C + k63_ceilingPit_D2L_GraphicIndice = 63, // @ C063_GRAPHIC_CEILING_PIT_D2L + k64_ceilingPitD2C_GraphicIndice = 64, // @ C064_GRAPHIC_CEILING_PIT_D2C + k65_ceilingPitD1L_GraphicIndice = 65, // @ C065_GRAPHIC_CEILING_PIT_D1L + k66_ceilingPitD1C_GraphicIndice = 66, // @ C066_GRAPHIC_CEILING_PIT_D1C + k67_ceilingPitD0L_grahicIndice = 67, // @ C067_GRAPHIC_CEILING_PIT_D0L + k68_ceilingPitD0C_graphicIndice = 68, // @ C068_GRAPHIC_CEILING_PIT_D0C k69_FieldMask_D3R_GraphicIndice = 69, // @ C069_GRAPHIC_FIELD_MASK_D3R k73_FieldTeleporterGraphicIndice = 73, // @ C073_GRAPHIC_FIELD_TELEPORTER k120_InscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT k241_FloorOrn_15_D3L_footprints = 241, // @ C241_GRAPHIC_FLOOR_ORNAMENT_15_D3L_FOOTPRINTS k301_DoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED + k315_firstDoorButton_GraphicIndice = 315, // @ C315_GRAPHIC_FIRST_DOOR_BUTTON k316_FirstProjectileGraphicIndice = 316, // @ C316_GRAPHIC_FIRST_PROJECTILE k348_FirstExplosionGraphicIndice = 348, // @ C348_GRAPHIC_FIRST_EXPLOSION k351_FirstExplosionPatternGraphicIndice = 351, // @ C351_GRAPHIC_FIRST_EXPLOSION_PATTERN @@ -590,6 +609,8 @@ public: void loadPalette(uint16 *palette); void f461_allocateFlippedWallBitmaps(); // @ F0461_START_AllocateFlippedWallBitmaps void f102_drawDoorBitmap(Frame *frame);// @ F0102_DUNGEONVIEW_DrawDoorBitmap + void f103_drawDoorFrameBitmapFlippedHorizontally(byte *bitmap, Frame *frame); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally + void f110_drawDoorButton(int16 doorButtonOrdinal, int16 viewDoorButtonIndex); // @ F0110_DUNGEONVIEW_DrawDoorButton /// Gives the width of an IMG0 type item uint16 getPixelWidth(uint16 index); @@ -602,6 +623,8 @@ public: void f111_drawDoor(uint16 doorThingIndex, uint16 doorState, int16 *doorNativeBitmapIndices, int16 byteCount, int16 viewDoorOrnIndex, DoorFrames *doorFrames); // @ F0111_DUNGEONVIEW_DrawDoor void f109_drawDoorOrnament(int16 doorOrnOdinal, int16 viewDoorOrnIndex); // @ F0109_DUNGEONVIEW_DrawDoorOrnament + void f112_drawCeilingPit(int16 nativeBitmapIndex, Frame *frame, int16 mapX, int16 mapY, bool flipHorizontal); // @ F0112_DUNGEONVIEW_DrawCeilingPit + /* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which |