diff options
author | Bendegúz Nagy | 2016-07-20 16:42:37 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | aacecd6c06b08c719077130cfd113f302b51923b (patch) | |
tree | 1c5618056ff021f5c2aaf89b82647c91b1e316bd | |
parent | 11704d0c509c1fc5af73c22bd64be60572ff4b8c (diff) | |
download | scummvm-rg350-aacecd6c06b08c719077130cfd113f302b51923b.tar.gz scummvm-rg350-aacecd6c06b08c719077130cfd113f302b51923b.tar.bz2 scummvm-rg350-aacecd6c06b08c719077130cfd113f302b51923b.zip |
DM: Add entrance processing
-rw-r--r-- | engines/dm/TODOs/todo.txt | 1 | ||||
-rw-r--r-- | engines/dm/detection.cpp | 2 | ||||
-rw-r--r-- | engines/dm/dm.cpp | 112 | ||||
-rw-r--r-- | engines/dm/dm.h | 9 | ||||
-rw-r--r-- | engines/dm/eventman.cpp | 1 | ||||
-rw-r--r-- | engines/dm/gfx.cpp | 15 | ||||
-rw-r--r-- | engines/dm/gfx.h | 4 | ||||
-rw-r--r-- | engines/dm/loadsave.cpp | 1 |
8 files changed, 133 insertions, 12 deletions
diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 4aa4d36360..d4162722e9 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -31,4 +31,5 @@ Todo: Finish stuff: f380_processCommandQueue Missing main loop methods + Save file f433_processCommand140_saveGame fails silently diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp index 1d31a7459d..7d1c463045 100644 --- a/engines/dm/detection.cpp +++ b/engines/dm/detection.cpp @@ -83,7 +83,7 @@ public: } virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { return gameDescriptions; } - virtual bool hasFeature(MetaEngineFeature f) const { return false; } + virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { if(desc) *engine = new DM::DMEngine(syst); diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index d401c7bbe6..2861cf1243 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -172,6 +172,9 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _g313_gameTime = 0; _g353_stringBuildBuffer[0] = '\0'; _g318_waitForInputMaxVerticalBlankCount = 0; + for (uint16 i = 0; i < 10; ++i) + _g562_entranceDoorAnimSteps[i] = nullptr; + _g564_interfaceCredits = nullptr; debug("DMEngine::DMEngine"); @@ -202,6 +205,12 @@ DMEngine::~DMEngine() { DebugMan.clearAllDebugChannels(); } +bool DMEngine::hasFeature(EngineFeature f) const { + return + (f == kSupportsSavingDuringRuntime) || + (f == kSupportsLoadingDuringRuntime); +} + void DMEngine::f22_delay(uint16 verticalBlank) { _system->delayMillis(verticalBlank * 20); // Google says most Amiga games had a refreshrate of 50 hz } @@ -221,9 +230,9 @@ void DMEngine::f463_initializeGame() { _textMan->f54_textInitialize(); _objectMan->loadObjectNames(); _eventMan->initMouse(); - //F0441_STARTEND_ProcessEntrance(); + f441_processEntrance(); while (f435_loadgame() != k1_LoadgameSuccess) { - warning(false, "TODO: F0441_STARTEND_ProcessEntrance"); + f441_processEntrance(); } //F0396_MENUS_LoadSpellAreaLinesBitmap() is not needed, every bitmap has been loaded @@ -423,4 +432,103 @@ int16 DMEngine::M0_indexToOrdinal(int16 val) { return val + 1; } + +void DMEngine::f441_processEntrance() { + uint16 L1402_ui_AnimationStep; + Box L1405_s_Box; + + _eventMan->_g441_primaryMouseInput = g445_PrimaryMouseInput_Entrance; + _eventMan->_g442_secondaryMouseInput = nullptr; + _eventMan->_g443_primaryKeyboardInput = nullptr; + _eventMan->_g444_secondaryKeyboardInput = nullptr; + _g562_entranceDoorAnimSteps[0] = new byte[128 * 161 * 12]; + for (L1402_ui_AnimationStep = 1; L1402_ui_AnimationStep < 8; L1402_ui_AnimationStep++) { + _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep] = _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep - 1] + 128 * 161; + } + _g562_entranceDoorAnimSteps[8] = _g562_entranceDoorAnimSteps[7] + 128 * 161; + _g562_entranceDoorAnimSteps[9] = _g562_entranceDoorAnimSteps[8] + 128 * 161 * 2; + + _displayMan->f466_loadIntoBitmap(k3_entranceRightDoorGraphicIndice, _g562_entranceDoorAnimSteps[4]); + _displayMan->f466_loadIntoBitmap(k2_entranceLeftDoorGraphicIndice, _g562_entranceDoorAnimSteps[0]); + _g564_interfaceCredits = _displayMan->f489_getNativeBitmapOrGraphic(k5_creditsGraphicIndice); + _displayMan->_g578_useByteBoxCoordinates = false; + L1405_s_Box._x1 = 0; + L1405_s_Box._x2 = 100; + L1405_s_Box._y1 = 0; + L1405_s_Box._y2 = 160; + for (L1402_ui_AnimationStep = 1; L1402_ui_AnimationStep < 4; L1402_ui_AnimationStep++) { + _displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[0], _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep], L1405_s_Box, L1402_ui_AnimationStep << 2, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161); + L1405_s_Box._x2 -= 4; + } + L1405_s_Box._x2 = 127; + for (L1402_ui_AnimationStep = 5; L1402_ui_AnimationStep < 8; L1402_ui_AnimationStep++) { + L1405_s_Box._x1 += 4; + _displayMan->f132_blitToBitmap(_g562_entranceDoorAnimSteps[4], _g562_entranceDoorAnimSteps[L1402_ui_AnimationStep], L1405_s_Box, 0, 0, k64_byteWidth, k64_byteWidth, kM1_ColorNoTransparency, 161, 161); + } + do { + f439_drawEntrance(); + //_eventMan->f77_hideMouse(); + //_eventMan->f77_hideMouse(); + _eventMan->f78_showMouse(); + _eventMan->f357_discardAllInput(); + _g298_newGame = k99_modeWaitingOnEntrance; + do { + _eventMan->processInput(); + _eventMan->f380_processCommandQueue(); + _displayMan->updateScreen(); + } while (_g298_newGame == k99_modeWaitingOnEntrance); + } while (_g298_newGame == k202_CommandEntranceDrawCredits); + //Strangerke: CHECKME: Earlier versions were using G0566_puc_Graphic534_Sound01Switch + warning(false, "MISSING CODE: F0060_SOUND_Play"); + f22_delay(20); + _eventMan->f78_showMouse(); + if (_g298_newGame) { + warning(false, "MISSING CODE: F0438_STARTEND_OpenEntranceDoors();"); + } + delete[] _g562_entranceDoorAnimSteps[0]; + for (uint16 i = 0; i < 10; ++i) + _g562_entranceDoorAnimSteps[i] = nullptr; +} + + +void DMEngine::f439_drawEntrance() { + static Box K0079_s_Box_Entrance_DoorsUpperHalf = {0, 231, 0, 80}; + static Box K0152_s_Box_Entrance_DoorsLowerHalf = {0, 231, 81, 160}; + static Box G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft = {0, 104, 30, 190}; + static Box G0011_s_Graphic562_Box_Entrance_ClosedDoorRight = {105, 231, 30, 190}; + + uint16 L1397_ui_ColumnIndex; + byte* L1398_apuc_MicroDungeonCurrentMapData[32]; + Square L1399_auc_MicroDungeonSquares[25]; + + _dungeonMan->_g309_partyMapIndex = k255_mapIndexEntrance; + _displayMan->_g297_drawFloorAndCeilingRequested = true; + _dungeonMan->_g273_currMapWidth = 5; + _dungeonMan->_g274_currMapHeight = 5; + _dungeonMan->_g271_currMapData = L1398_apuc_MicroDungeonCurrentMapData; + + Map map; // uninitialized, won't be used + _dungeonMan->_g269_currMap = ↦ + for (uint16 i = 0; i < 25; ++i) + L1399_auc_MicroDungeonSquares[i] = Square(k0_ElementTypeWall, 0); + for (L1397_ui_ColumnIndex = 0; L1397_ui_ColumnIndex < 5; L1397_ui_ColumnIndex++) { + L1398_apuc_MicroDungeonCurrentMapData[L1397_ui_ColumnIndex] = (byte*)&L1399_auc_MicroDungeonSquares[L1397_ui_ColumnIndex * 5]; + L1399_auc_MicroDungeonSquares[L1397_ui_ColumnIndex + 10] = Square(k1_CorridorElemType, 0); + } + L1399_auc_MicroDungeonSquares[7] = Square(k1_CorridorElemType, 0); + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(G0345_aui_BlankBuffer);"); + + // note, a global variable is used here in the original + _displayMan->f466_loadIntoBitmap(k4_entranceGraphicIndice, _displayMan->_g348_bitmapScreen); + _displayMan->f128_drawDungeon(kDirSouth, 2, 0); + warning(false, "IGNORED CODE: G0324_B_DrawViewportRequested = false;"); + + _displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], K0079_s_Box_Entrance_DoorsUpperHalf, 0, 30, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161); + _displayMan->_g578_useByteBoxCoordinates = false, _displayMan->f132_blitToBitmap(_displayMan->_g348_bitmapScreen, _g562_entranceDoorAnimSteps[8], K0152_s_Box_Entrance_DoorsLowerHalf, 0, 111, k160_byteWidthScreen, k128_byteWidth, kM1_ColorNoTransparency, 200, 161); + + _displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[0], &G0010_s_Graphic562_Box_Entrance_ClosedDoorLeft, k64_byteWidth, kM1_ColorNoTransparency, 161); + _displayMan->f21_blitToScreen(_g562_entranceDoorAnimSteps[4], &G0011_s_Graphic562_Box_Entrance_ClosedDoorRight, k64_byteWidth, kM1_ColorNoTransparency, 161); + warning(false, "MISSING CODE: F0436_STARTEND_FadeToPalette(g20_PalEntrance);"); +} + } // End of namespace DM diff --git a/engines/dm/dm.h b/engines/dm/dm.h index dfc7b4c01c..cbc0bd35e0 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -193,11 +193,13 @@ class DMEngine : public Engine { void initArrays(); Common::String getSavefileName(uint16 slot); void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName); + void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance public: explicit DMEngine(OSystem *syst); ~DMEngine(); + virtual bool hasFeature(EngineFeature f) const; - void f22_delay(uint16 ms); // @ F0022_MAIN_Delay + void f22_delay(uint16 verticalBlank); // @ F0022_MAIN_Delay uint16 f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2); // @ F0030_MAIN_GetScaledProduct uint16 getRandomNumber(uint32 max) { return _rnd->getRandomNumber(max - 1); } int16 M1_ordinalToIndex(int16 val); // @ M01_ORDINAL_TO_INDEX @@ -206,12 +208,15 @@ public: virtual Common::Error run(); // @ main void f433_processCommand140_saveGame(uint16 slot, const Common::String desc); // @ F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF LoadgameResponse f435_loadgame(); // @ F0435_STARTEND_LoadGame_CPSF + void f441_processEntrance(); // @ F0441_STARTEND_ProcessEntrance private: int16 _g528_saveFormat; // @ G0528_i_Format int16 _g527_platform; // @ G0527_i_Platform uint16 _g526_dungeonId; // @ G0526_ui_DungeonID Console *_console; + byte *_g562_entranceDoorAnimSteps[10]; // @ G0562_apuc_Bitmap_EntranceDoorAnimationSteps + byte *_g564_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits public: Common::RandomSource *_rnd; DisplayMan *_displayMan; @@ -228,7 +233,7 @@ public: ProjExpl *_projexpl; - bool _g298_newGame; // @ G0298_B_NewGame + int16 _g298_newGame; // @ G0298_B_NewGame bool _g523_restartGameRequest; // @ G0523_B_RestartGameRequested bool _g321_stopWaitingForPlayerInput; // @ G0321_B_StopWaitingForPlayerInput diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 5fe80e2eda..6e868f73de 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -740,6 +740,7 @@ void EventManager::f380_processCommandQueue() { if (cmdType == k140_CommandSaveGame) { if ((_vm->_championMan->_g305_partyChampionCount > 0) && !_vm->_championMan->_g299_candidateChampionOrdinal) { warning(false, "MISSING CODE: F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF();"); + _vm->f433_processCommand140_saveGame(1, "Nice save:)"); } return; } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 5efb3f05ac..dae340085f 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -772,6 +772,8 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) { delete[] _g348_bitmapScreen; _g348_bitmapScreen = new byte[_screenWidth * _screenHeight]; fillScreen(k0_ColorBlack); + + _g74_tmpBitmap = new byte[_screenWidth * _screenHeight]; } void DisplayMan::f479_loadGraphics() { @@ -2248,11 +2250,13 @@ void DisplayMan::f128_drawDungeon(direction dir, int16 posX, int16 posY) { f126_drawSquareD0R(dir, tmpPosX, tmpPosY); f127_drawSquareD0C(dir, posX, posY); - _g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native; - _g699_bitmapWallSet_Wall_D2LCR = _g96_bitmapWall_D2LCR_Native; - _g700_bitmapWallSet_Wall_D1LCR = _g97_bitmapWall_D1LCR_Native; - _g701_bitmapWallSet_Wall_D0L = _g98_bitmapWall_D0L_Native; - _g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native; + if (_g76_useFlippedWallAndFootprintsBitmap) { + _g698_bitmapWallSet_Wall_D3LCR = _g95_bitmapWall_D3LCR_Native; + _g699_bitmapWallSet_Wall_D2LCR = _g96_bitmapWall_D2LCR_Native; + _g700_bitmapWallSet_Wall_D1LCR = _g97_bitmapWall_D1LCR_Native; + _g701_bitmapWallSet_Wall_D0L = _g98_bitmapWall_D0L_Native; + _g702_bitmapWallSet_Wall_D0R = _g99_bitmapWall_D0R_Native; + } f97_drawViewport((_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) ? 1 : 0); if (_vm->_dungeonMan->_g309_partyMapIndex != k255_mapIndexEntrance) @@ -2320,7 +2324,6 @@ void DisplayMan::f96_loadCurrentMapGraphics() { f95_loadWallSet(_vm->_dungeonMan->_g269_currMap->_wallSet); { - _g74_tmpBitmap = new byte[_screenWidth * _screenHeight]; _g578_useByteBoxCoordinates = true; f99_copyBitmapAndFlipHorizontal(_g95_bitmapWall_D3LCR_Native = _g698_bitmapWallSet_Wall_D3LCR, _g74_tmpBitmap, diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index d1cc5b77cd..2a18b39b39 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -202,6 +202,10 @@ enum ViewCell { }; enum GraphicIndice { + k2_entranceLeftDoorGraphicIndice = 2, // @ C002_GRAPHIC_ENTRANCE_LEFT_DOOR + k3_entranceRightDoorGraphicIndice = 3, // @ C003_GRAPHIC_ENTRANCE_RIGHT_DOOR + k4_entranceGraphicIndice = 4, // @ C004_GRAPHIC_ENTRANCE + k5_creditsGraphicIndice = 5, // @ C005_GRAPHIC_CREDITS k8_StatusBoxDeadChampion = 8, // @ C008_GRAPHIC_STATUS_BOX_DEAD_CHAMPION k9_MenuSpellAreaBackground = 9, // @ C009_GRAPHIC_MENU_SPELL_AREA_BACKGROUND k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 9d705ef8e5..28b57f2651 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -176,5 +176,4 @@ void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::Strin out->writeUint32BE(playTime); } - } |