From 253730787de69da9b914f41138f7a54214f41eff Mon Sep 17 00:00:00 2001 From: WinterGrascph Date: Fri, 13 May 2016 00:54:01 +0200 Subject: DM: Finish implementing ornament masks in DungeonMan::getSquare --- engines/dm/dungeonman.cpp | 29 ++++++++++++++++++++++++----- engines/dm/dungeonman.h | 41 +++++++++++++++++++++++++++-------------- engines/dm/gfx.cpp | 13 ++++++++++--- engines/dm/gfx.h | 3 ++- 4 files changed, 63 insertions(+), 23 deletions(-) diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp index b5c2a3e1fb..80239e14fe 100644 --- a/engines/dm/dungeonman.cpp +++ b/engines/dm/dungeonman.cpp @@ -16,7 +16,7 @@ void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); } using namespace DM; -void DungeonMan::mapCoordsAfterRelMovement(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 &posX, uint16 &posY) { +void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) { posX += dirIntoStepCountEast[dir] * stepsForward; posY += dirIntoStepCountNorth[dir] * stepsForward; turnDirRight(dir); @@ -282,17 +282,36 @@ void DungeonMan::setCurrentMap(uint16 mapIndex) { = &_dunData.columnsCumulativeSquareThingCount[_dunData.mapsFirstColumnIndex[mapIndex]]; } -byte DungeonMan::getSquare(uint16 mapX, uint16 mapY) { +byte DungeonMan::getSquare(int16 mapX, int16 mapY) { bool isInXBounds = (mapX >= 0) && (mapX < _currMap.width); bool isInYBounds = (mapY >= 0) && (mapY < _currMap.height); if (isInXBounds && isInYBounds) return _currMap.data[mapX][mapY]; - else - return kWallSquareType; + + int16 tmpSquare; + if (isInYBounds) { + tmpSquare = getSquareType(_currMap.data[0][mapY]); + if (mapX == -1 && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType)) + return (kWallElemType << 5) | kWallEastRandOrnAllowed; + + tmpSquare = getSquareType(_currMap.data[_currMap.width - 1][mapY]); + if (mapX == _currMap.width && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType)) + return (kWallElemType << 5) | kWallWestRandOrnAllowed; + } else if (isInXBounds) { + tmpSquare = getSquareType(_currMap.data[mapX][0]); + if (mapY == -1 && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType)) + return (kWallElemType << 5) | kWallSouthRandOrnAllowed; + + tmpSquare = getSquareType(_currMap.data[mapX][_currMap.height - 1]); + if (mapY == _currMap.height && (tmpSquare == kCorridorElemType || tmpSquare == kPitElemType)) + return (kWallElemType << 5) | kWallNorthRandOrnAllowed; + } + + return kWallElemType << 5; } -byte DungeonMan::getRelSquare(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY) { +byte DungeonMan::getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { mapCoordsAfterRelMovement(dir, stepsForward, stepsForward, posX, posY); return getSquare(posX, posY); } \ No newline at end of file diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 2afc2aab88..dbe13d3018 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -26,15 +26,28 @@ enum ThingType { kThingTypeTotal = 16 // +1 than the last }; // @ C[00..15]_THING_TYPE_... -enum SquareType { - kWallSquareType = 0, - kCorridorSquareType = 1, - kPitSquareType = 2, - kStairsSquareType = 3, - kDoorSquareType = 4, - kTeleporterSquareType = 5, - kFakeWallSquareType = 6 -}; // @ C[00..06]_ELEMENT_... +enum ElementType { + kChampionElemType = -2, + kCreatureElemType = -1, + kWallElemType = 0, + kCorridorElemType = 1, + kPitElemType = 2, + kStairsElemType = 3, + kDoorElemType = 4, + kTeleporterElemType = 5, + kFakeWallElemType = 6, + kDoorSideElemType = 16, + kDoorFrontElemType = 17, + kStairsSideElemType = 18, + kStairsFrontElemType = 19 +}; // @ C[-2..19]_ELEMENT_... + +enum WallOrnMask { + kWallWestRandOrnAllowed = 0x1, + kWallSouthRandOrnAllowed = 0x2, + kWallEastRandOrnAllowed = 0x4, + kWallNorthRandOrnAllowed = 0x8 +}; class DungeonFileHeader { @@ -156,11 +169,10 @@ class DungeonMan { DungeonMan(const DungeonMan &other); // no implementation on purpose void operator=(const DungeonMan &rhs); // no implementation on purpose - void mapCoordsAfterRelMovement(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 &posX, uint16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement - byte getSquare(uint16 mapX, uint16 mapY); // @ F0151_DUNGEON_GetSquare - byte getRelSquare(direction dir, uint16 stepsForward, uint16 stepsRight, uint16 posX, uint16 posY); // @ F0152_DUNGEON_GetRelativeSquare + byte getSquare(int16 mapX, int16 mapY); // @ F0151_DUNGEON_GetSquare + byte getRelSquare(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY); // @ F0152_DUNGEON_GetRelativeSquare - SquareType getSquareType(uint16 square) { return (SquareType)(square << 5); } // @ M34_SQUARE_TYPE + ElementType getSquareType(int16 square) { return (ElementType)(square << 5); } // @ M34_SQUARE_TYPE void decompressDungeonFile(); // @ F0455_FLOPPY_DecompressDungeon public: @@ -169,7 +181,8 @@ public: // TODO: this does stuff other than load the file! void loadDungeonFile(); // @ F0434_STARTEND_IsLoadDungeonSuccessful_CPSC void setCurrentMap(uint16 mapIndex); // @ F0173_DUNGEON_SetCurrentMap - SquareType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { + void mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY); // @ F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement + ElementType getRelSquareType(direction dir, int16 stepsForward, int16 stepsRight, int16 posX, int16 posY) { return getSquareType(getRelSquare(dir, stepsForward, stepsRight, posX, posY)); }// @ F0153_DUNGEON_GetRelativeSquareType }; diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index ad8d230e6b..385b23fdac 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -253,6 +253,10 @@ void DisplayMan::drawWallSetBitmap(byte *bitmap, Frame &f) { blitToScreen(bitmap, f.srcWidth, f.srcX, f.srcY, f.destFromX, f.destToX, f.destFromY, f.destToY, kColorFlesh, gDungeonViewport); } +void drawSquareD3L(direction dir, int16 posX, int16 posY) { + +} + enum WallSetIndices { kDoorFrameFront = 0, // @ G0709_puc_Bitmap_WallSet_DoorFrameFront @@ -273,7 +277,7 @@ enum WallSetIndices { kDoorFrameRight_D1C = 14// @ G0710_puc_Bitmap_WallSet_DoorFrameRight_D1C }; -void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) { +void DisplayMan::drawDungeon(direction dir, int16 posX, int16 posY) { loadPalette(kPalDungeonView0); // TODO: this is a global variable, set from here bool flippedFloorCeiling = (posX + posY + dir) & 1; @@ -296,11 +300,14 @@ void DisplayMan::drawDungeon(direction dir, uint16 posX, uint16 posY) { drawWallSetBitmap(_floorBitmap, gFloorFrame); } - if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallSquareType) + if (_vm->_dungeonMan->getRelSquareType(dir, 3, -2, posX, posY) == kWallElemType) drawWallSetBitmap(_wallSetBitMaps[kWall_D3L2], gWallFrameD3L2); - if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallSquareType) + if (_vm->_dungeonMan->getRelSquareType(dir, 3, 2, posX, posY) == kWallElemType) drawWallSetBitmap(_wallSetBitMaps[kWall_D3R2], gWallFrameD3R2); + // D3L + int16 tmpPosX = posX, tmpPosY = posY; + _vm->_dungeonMan->getRelSquareType(dir, 3, -1, tmpPosX, tmpPosY); diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index b2c29bf8c6..5670a5657c 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -87,6 +87,7 @@ class DisplayMan { void loadIntoBitmap(uint16 index, byte *destBitmap); // @ F0466_EXPAND_GraphicToBitmap void unpackGraphics(); void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap + void drawSquareD3L(direction dir, int16 posX, int16 posY); // @ F0116_DUNGEONVIEW_DrawSquareD3L public: DisplayMan(DMEngine *dmEngine); ~DisplayMan(); @@ -117,7 +118,7 @@ public: void clearBitmap(byte *bitmap, uint16 width, uint16 height, Color color); void clearScreen(Color color); - void drawDungeon(direction dir, uint16 posX, uint16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF + void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); }; -- cgit v1.2.3