From f0a6f6b269fb121affa252e36d23c895c7d32e4e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 11 Sep 2016 10:27:29 +0200 Subject: DM: Make some functions private, move 2 functions to more specific classes --- engines/dm/dm.cpp | 8 -------- engines/dm/dm.h | 12 ++++++------ engines/dm/gfx.cpp | 22 +++++++++++++--------- engines/dm/gfx.h | 1 + engines/dm/group.cpp | 8 ++++++-- engines/dm/group.h | 2 ++ 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 199752a81b..970e47cc77 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -99,14 +99,6 @@ bool DMEngine::isOrientedWestEast(Direction dir) { return dir & 1; } -uint16 DMEngine::toggleFlag(uint16& val, uint16 mask) { - return val ^= mask; -} - -uint16 DMEngine::bitmapByteCount(uint16 pixelWidth, uint16 height) { - return pixelWidth / 2 * height; -} - uint16 DMEngine::normalizeModulo4(uint16 val) { return val & 3; } diff --git a/engines/dm/dm.h b/engines/dm/dm.h index c37ab23f40..eeca0a8c96 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -218,6 +218,7 @@ struct SaveGameHeader { }; class DMEngine : public Engine { +private: void startGame(); // @ F0462_START_StartGame_CPSF void processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF @@ -228,6 +229,11 @@ class DMEngine : public Engine { void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName); bool writeCompleteSaveFile(int16 slot, Common::String &desc, int16 saveAndPlayChoice); void drawEntrance(); // @ F0439_STARTEND_DrawEntrance + void fuseSequenceUpdate(); // @ F0445_STARTEND_FuseSequenceUpdate + void processEntrance(); // @ F0441_STARTEND_ProcessEntrance + void openEntranceDoors(); // @ F0438_STARTEND_OpenEntranceDoors + void drawTittle(); // @ F0437_STARTEND_DrawTitle + public: explicit DMEngine(OSystem *syst, const DMADGameDescription *gameDesc); ~DMEngine(); @@ -246,14 +252,10 @@ public: virtual Common::Error run(); // @ main void saveGame(); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF LoadgameResult loadgame(int16 slot); // @ F0435_STARTEND_LoadGame_CPSF - void processEntrance(); // @ F0441_STARTEND_ProcessEntrance void endGame(bool doNotDrawCreditsOnly); // @ F0444_STARTEND_Endgame - void openEntranceDoors(); // @ F0438_STARTEND_OpenEntranceDoors - void drawTittle(); // @ F0437_STARTEND_DrawTitle void entranceDrawCredits(); void fuseSequence(); // @ F0446_STARTEND_FuseSequence - void fuseSequenceUpdate(); // @ F0445_STARTEND_FuseSequenceUpdate Common::Language getGameLanguage(); void turnDirRight(Direction &dir); @@ -262,8 +264,6 @@ public: uint16 returnPrevVal(uint16 val); // @ M19_PREVIOUS uint16 returnNextVal(uint16 val); // @ M17_NEXT bool isOrientedWestEast(Direction dir); // @ M16_IS_ORIENTED_WEST_EAST - uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE - uint16 bitmapByteCount(uint16 pixelWidth, uint16 height); // @ M75_BITMAP_BYTE_COUNT uint16 normalizeModulo4(uint16 val); // @ M21_NORMALIZE int32 filterTime(int32 map_time); // @ M30_TIME int32 setMapAndTime(int32 &map_time, uint32 map, uint32 time); // @ M33_SET_MAP_AND_TIME diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index ab6a5854f8..bb2d73eb4b 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -461,6 +461,10 @@ DisplayMan::~DisplayMan() { delete _doorFrameD1C; } +uint16 DisplayMan::bitmapByteCount(uint16 pixelWidth, uint16 height) { + return pixelWidth / 2 * height; +} + void DisplayMan::setUpScreens(uint16 width, uint16 height) { _screenWidth = width; _screenHeight = height; @@ -1249,7 +1253,7 @@ void DisplayMan::drawSquareD3L(Direction dir, int16 posX, int16 posY) { drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k1_ViewSquare_D3L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); drawWallSetBitmap(_bitmapWallSetDoorFrameLeftD3L, doorFrameLeftD3L); drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], - _doorNativeBitmapIndexFrontD3LCR, _vm->bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3L); + _doorNativeBitmapIndexFrontD3LCR, bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3L); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; break; case k2_ElementTypePit: @@ -1333,7 +1337,7 @@ void DisplayMan::drawSquareD3R(Direction dir, int16 posX, int16 posY) { drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], _doorNativeBitmapIndexFrontD3LCR, - _vm->bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3R); + bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3R); break;; case k2_ElementTypePit: if (!squareAspect[k2_PitInvisibleAspect]) @@ -1410,7 +1414,7 @@ void DisplayMan::drawSquareD3C(Direction dir, int16 posX, int16 posY) { drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k1_ViewDoorOrnament_D2LCR); drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], - _doorNativeBitmapIndexFrontD3LCR, _vm->bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3C); + _doorNativeBitmapIndexFrontD3LCR, bitmapByteCount(48, 41), k0_ViewDoorOrnament_D3LCR, &doorFrameD3C); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; break; case k2_ElementTypePit: @@ -1490,7 +1494,7 @@ void DisplayMan::drawSquareD2L(Direction dir, int16 posX, int16 posY) { drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k4_ViewSquare_D2L, k0x0218_CellOrder_DoorPass1_BackLeft_BackRight); drawWallSetBitmap(_bitmapWallSetDoorFrameTopD2LCR, doorFrameTopD2L); drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], _doorNativeBitmapIndexFrontD2LCR, - _vm->bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2L); + bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2L); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; break; case k2_ElementTypePit: @@ -1577,7 +1581,7 @@ void DisplayMan::drawSquareD2R(Direction dir, int16 posX, int16 posY) { drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k5_ViewSquare_D2R, k0x0128_CellOrder_DoorPass1_BackRight_BackLeft); drawWallSetBitmap(_bitmapWallSetDoorFrameTopD2LCR, doorFrameTopD2R); drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], - _doorNativeBitmapIndexFrontD2LCR, _vm->bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2R); + _doorNativeBitmapIndexFrontD2LCR, bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2R); order = k0x0439_CellOrder_DoorPass2_FrontRight_FrontLeft; break; case k2_ElementTypePit: @@ -1660,7 +1664,7 @@ void DisplayMan::drawSquareD2C(Direction dir, int16 posX, int16 posY) { drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k2_viewDoorButton_D2C); drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], - _doorNativeBitmapIndexFrontD2LCR, _vm->bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2C); + _doorNativeBitmapIndexFrontD2LCR, bitmapByteCount(64, 61), k1_ViewDoorOrnament_D2LCR, &doorFrameD2C); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; break; case k2_ElementTypePit: @@ -1745,7 +1749,7 @@ void DisplayMan::drawSquareD1L(Direction dir, int16 posX, int16 posY) { drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k7_ViewSquare_D1L, k0x0028_CellOrder_DoorPass1_BackRight); drawWallSetBitmap(_bitmapWallSetDoorFrameTopD1LCR, doorFrameTopD1L); drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], - _doorNativeBitmapIndexFrontD1LCR, _vm->bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1L); + _doorNativeBitmapIndexFrontD1LCR, bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1L); order = k0x0039_CellOrder_DoorPass2_FrontRight; break; case k2_ElementTypePit: @@ -1829,7 +1833,7 @@ void DisplayMan::drawSquareD1R(Direction dir, int16 posX, int16 posY) { drawObjectsCreaturesProjectilesExplosions(Thing(squareAspect[k1_FirstGroupOrObjectAspect]), dir, posX, posY, k8_ViewSquare_D1R, k0x0018_CellOrder_DoorPass1_BackLeft); drawWallSetBitmap(_bitmapWallSetDoorFrameTopD1LCR, doorFrameTopD1R); drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], - _doorNativeBitmapIndexFrontD1LCR, _vm->bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1R); + _doorNativeBitmapIndexFrontD1LCR, bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, &doorFrameD1R); order = k0x0049_CellOrder_DoorPass2_FrontLeft; break; case k2_ElementTypePit: @@ -1914,7 +1918,7 @@ void DisplayMan::drawSquareD1C(Direction dir, int16 posX, int16 posY) { drawDoorButton(_vm->indexToOrdinal(k0_DoorButton), k3_viewDoorButton_D1C); drawDoor(squareAspect[k3_DoorThingIndexAspect], squareAspect[k2_DoorStateAspect], - _doorNativeBitmapIndexFrontD1LCR, _vm->bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, _doorFrameD1C); + _doorNativeBitmapIndexFrontD1LCR, bitmapByteCount(96, 88), k2_ViewDoorOrnament_D1LCR, _doorFrameD1C); order = k0x0349_CellOrder_DoorPass2_FrontLeft_FrontRight; break; case k2_ElementTypePit: diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 76f08e8859..f9aa3823aa 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -825,6 +825,7 @@ public: private: void initConstants(); + uint16 bitmapByteCount(uint16 pixelWidth, uint16 height); // @ M75_BITMAP_BYTE_COUNT }; } diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index 6df3857732..722fac472b 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -70,6 +70,10 @@ GroupMan::~GroupMan() { delete[] _activeGroups; } +uint16 GroupMan::toggleFlag(uint16& val, uint16 mask) { + return val ^= mask; +} + void GroupMan::initActiveGroups() { if (_vm->_newGameFl) _maxActiveGroupCount = 60; @@ -1270,7 +1274,7 @@ int32 GroupMan::getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 crea if (getFlag(creatureGraphicInfo, k0x0200_CreatureInfoGraphicMaskFlipAttack)) { if (getFlag(aspect, k0x0080_MaskActiveGroupIsAttacking) && (creatureType == k18_CreatureTypeAnimatedArmourDethKnight)) { if (_vm->getRandomNumber(2)) { - _vm->toggleFlag(aspect, k0x0040_MaskActiveGroupFlipBitmap); + toggleFlag(aspect, k0x0040_MaskActiveGroupFlipBitmap); _vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _currentGroupMapX, _currentGroupMapY, k1_soundModePlayIfPrioritized); } } else if (!getFlag(aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(creatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) { @@ -1287,7 +1291,7 @@ int32 GroupMan::getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 crea if (getFlag(creatureGraphicInfo, k0x0004_CreatureInfoGraphicMaskFlipNonAttack)) { if (creatureType == k13_CreatureTypeCouatl) { if (_vm->getRandomNumber(2)) { - _vm->toggleFlag(aspect, k0x0040_MaskActiveGroupFlipBitmap); + toggleFlag(aspect, k0x0040_MaskActiveGroupFlipBitmap); uint16 soundIndex = _vm->_moveSens->getSound(k13_CreatureTypeCouatl); if (soundIndex <= k34_D13_soundCount) _vm->_sound->requestPlay(soundIndex, _currentGroupMapX, _currentGroupMapY, k1_soundModePlayIfPrioritized); diff --git a/engines/dm/group.h b/engines/dm/group.h index 53d80c6e4d..3b6cf2f8aa 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -171,6 +171,8 @@ class GroupMan { bool _groupMovementBlockedByParty; // @ G0390_B_GroupMovementBlockedByParty bool _groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter; // @ G0387_B_GroupMovementBlockedByWallStairsPitFakeWallFluxcageTeleporter int32 twoHalfSquareSizedCreaturesGroupLastDirectionSetTime; // @ G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime + uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE + public: uint16 _maxActiveGroupCount; // @ G0376_ui_MaximumActiveGroupCount ActiveGroup *_activeGroups; // @ G0375_ps_ActiveGroups -- cgit v1.2.3