diff options
author | Bendegúz Nagy | 2016-07-12 11:30:25 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | 42cbf35b0bbe821b7127a0a883b4248c4da9f90a (patch) | |
tree | 77db4164ed7407a94166e2d41e695f1a71e43f2d | |
parent | 0f76448e5794bea0097f1c806c67623093c79cf8 (diff) | |
download | scummvm-rg350-42cbf35b0bbe821b7127a0a883b4248c4da9f90a.tar.gz scummvm-rg350-42cbf35b0bbe821b7127a0a883b4248c4da9f90a.tar.bz2 scummvm-rg350-42cbf35b0bbe821b7127a0a883b4248c4da9f90a.zip |
DM: Clean up f380_processCommandQueue, add _g318_waitForInputMaxVerticalBlankCount
-rw-r--r-- | engines/dm/TODOs/todo.txt | 7 | ||||
-rw-r--r-- | engines/dm/champion.cpp | 1 | ||||
-rw-r--r-- | engines/dm/dm.cpp | 4 | ||||
-rw-r--r-- | engines/dm/dm.h | 5 | ||||
-rw-r--r-- | engines/dm/eventman.cpp | 182 |
5 files changed, 175 insertions, 24 deletions
diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt index 78a5e9cd80..26aa3335b0 100644 --- a/engines/dm/TODOs/todo.txt +++ b/engines/dm/TODOs/todo.txt @@ -21,5 +21,8 @@ Todo: I forgot to add a bunch of warning for show/hide mouse pointer and other mouse functions Finish stuff: - f261_processTimeline - + f380_processCommandQueue + Missing main loop methods + F0577_VBLANK_Handler, if enought time passes, takes the player's chance to act + - TODO: implement it + - NOTE: _g318_waitForInputMaxVerticalBlankCount is already included in the engine diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 443b7646ae..3745924a3e 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -820,6 +820,7 @@ uint16 ChampionMan::f307_getStatisticAdjustedAttack(Champion* champ, uint16 stat void ChampionMan::f314_wakeUp() {
_vm->_g321_stopWaitingForPlayerInput = true;
_g300_partyIsSleeping = false;
+ _vm->_g318_waitForInputMaxVerticalBlankCount = 10;
_vm->f22_delay(10);
_vm->_displayMan->f98_drawFloorAndCeiling();
_vm->_eventMan->_g441_primaryMouseInput = g447_PrimaryMouseInput_Interface;
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index dbf7a9577a..194bfa2a8a 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -168,6 +168,7 @@ DMEngine::DMEngine(OSystem *syst) : Engine(syst), _console(nullptr) { _g310_disabledMovementTicks = 0; _g313_gameTime = 0; _g353_stringBuildBuffer[0] = '\0'; + _g318_waitForInputMaxVerticalBlankCount = 0; debug("DMEngine::DMEngine"); @@ -320,11 +321,12 @@ Common::Error DMEngine::run() { } void DMEngine::f2_gameloop() { - warning(false, "DUMMY CODE SETTING PARTY POS AND DIRECTION"); + warning(false, "DUMMY CODE: SETTING PARTY POS AND DIRECTION"); _dungeonMan->_g306_partyMapX = 10; _dungeonMan->_g307_partyMapY = 4; _dungeonMan->_g308_partyDir = kDirNorth; + _g318_waitForInputMaxVerticalBlankCount = 10; while (true) { if (_g327_newPartyMapIndex != kM1_mapIndexNone) { T0002002: diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 1e1fc6a53c..dce88f17f8 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -172,6 +172,10 @@ inline T f26_getBoundedValue(T min, T val, T max) { #define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember)) +#define k0_modeLoadSavedGame 0 // @ C000_MODE_LOAD_SAVED_GAME +#define k1_modeLoadDungeon 1 // @ C001_MODE_LOAD_DUNGEON +#define k99_modeWaitingOnEntrance 99 // @ C099_MODE_WAITING_ON_ENTRANCE +#define k202_modeEntranceDrawCredits 202 // @ C202_MODE_ENTRANCE_DRAW_CREDITS class DMEngine : public Engine { void f462_startGame(); // @ F0462_START_StartGame_CPSF @@ -234,6 +238,7 @@ public: int8 _dirIntoStepCountNorth[4]; // @ G0234_ai_Graphic559_DirectionToStepNorthCount uint32 _g313_gameTime; // @ G0313_ul_GameTime char _g353_stringBuildBuffer[128]; // @ G0353_ac_StringBuildBuffer + int16 _g318_waitForInputMaxVerticalBlankCount; // @ G0318_i_WaitForInputMaximumVerticalBlankCount }; class Console : public GUI::Debugger { diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 4f3ffc5e74..9045c624fd 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -613,39 +613,179 @@ CommandType EventManager::f358_getCommandTypeFromMouseInput(MouseInput *input, C void EventManager::f380_processCommandQueue() { - _g435_isCommandQueueLocked = true; - if (_commandQueue.empty()) { - _g435_isCommandQueueLocked = false; - f360_processPendingClick(); + int16 AL1159_i_ChampionIndex; + CommandType cmdType; + int16 L1161_i_CommandX; + int16 L1162_i_CommandY; + static KeyboardInput* G0481_ps_PrimaryKeyboardInputBackup; + static KeyboardInput* G0482_ps_SecondaryKeyboardInputBackup; + static MouseInput* G0483_ps_PrimaryMouseInputBackup; + static MouseInput* G0484_ps_SecondaryMouseInputBackup; + + + _vm->_eventMan->_g435_isCommandQueueLocked = true; + if (_commandQueue.empty()) { /* If the command queue is empty */ + _vm->_eventMan->_g435_isCommandQueueLocked = false; + _vm->_eventMan->f360_processPendingClick(); return; } Command cmd = _commandQueue.pop(); - - int16 commandX = cmd._pos.x; - int16 commandY = cmd._pos.y; - - _g435_isCommandQueueLocked = false; - f360_processPendingClick(); - - if ((cmd._type == k2_CommandTurnRight) || (cmd._type == k1_CommandTurnLeft)) { - f365_commandTurnParty(cmd._type); + cmdType = cmd._type; + if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft) && (_vm->_g310_disabledMovementTicks || (_vm->_g311_projectileDisableMovementTicks && (_vm->_g312_lastProjectileDisabledMovementDirection == (M21_normalizeModulo4(_vm->_dungeonMan->_g308_partyDir + cmdType - k3_CommandMoveForward)))))) { /* If movement is disabled */ + _vm->_eventMan->_g435_isCommandQueueLocked = false; + _vm->_eventMan->f360_processPendingClick(); + return; + } + L1161_i_CommandX = cmd._pos.x; + L1162_i_CommandY = cmd._pos.y; + _vm->_eventMan->_g435_isCommandQueueLocked = false; + _vm->_eventMan->f360_processPendingClick(); + if ((cmdType == k2_CommandTurnRight) || (cmdType == k1_CommandTurnLeft)) { + _vm->_eventMan->f365_commandTurnParty(cmdType); + return; + } + if ((cmdType >= k3_CommandMoveForward) && (cmdType <= k6_CommandMoveLeft)) { + _vm->_eventMan->f366_commandMoveParty(cmdType); + return; + } + if ((cmdType >= k12_CommandClickInChampion_0_StatusBox) && (cmdType <= k15_CommandClickInChampion_3_StatusBox)) { + if (((AL1159_i_ChampionIndex = cmdType - k12_CommandClickInChampion_0_StatusBox) < _vm->_championMan->_g305_partyChampionCount) && !_vm->_championMan->_g299_candidateChampionOrdinal) { + warning(false, "MISSING CODE: F0367_COMMAND_ProcessTypes12To27_ClickInChampionStatusBox(AL1159_i_ChampionIndex, L1161_i_CommandX, L1162_i_CommandY);"); + } + return; + } + if ((cmdType >= k125_CommandClickOnChamptionIcon_Top_Left) && (cmdType <= k128_CommandClickOnChamptionIcon_Lower_Left)) { + warning(false, "MISSING CODE: F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon(cmdType - k125_CommandClickOnChamptionIcon_Top_Left);"); + return; + } + if ((cmdType >= k28_CommandClickOnSlotBoxInventoryReadyHand) && (cmdType < (k65_CommandClickOnSlotBoxChest_8 + 1))) { + if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) { + warning(false, "MISSING CODE: F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox(cmdType - k20_CommandClickOnSlotBoxChampion_0_StatusBoxReadyHand);"); + } + return; + } + if ((cmdType >= k7_CommandToggleInventoryChampion_0) && (cmdType <= k11_CommandCloseInventory)) { + if ((((AL1159_i_ChampionIndex = cmdType - k7_CommandToggleInventoryChampion_0) == k4_ChampionCloseInventory) || (AL1159_i_ChampionIndex < _vm->_championMan->_g305_partyChampionCount)) && !_vm->_championMan->_g299_candidateChampionOrdinal) { + _vm->_inventoryMan->f355_toggleInventory((ChampionIndex)AL1159_i_ChampionIndex); + } + return; + } + if (cmdType == k83_CommandToggleInventoryLeader) { + if (_vm->_championMan->_g411_leaderIndex != kM1_ChampionNone) { + _vm->_inventoryMan->f355_toggleInventory(_vm->_championMan->_g411_leaderIndex); + } + return; + } + if (cmdType == k100_CommandClickInSpellArea) { + if ((!_vm->_championMan->_g299_candidateChampionOrdinal) && (_vm->_championMan->_g514_magicCasterChampionIndex != kM1_ChampionNone)) { + warning(false, "MISSING CODE: F0370_COMMAND_ProcessType100_ClickInSpellArea(L1161_i_CommandX, L1162_i_CommandY);"); + } + return; + } + if (cmdType == k111_CommandClickInActionArea) { + if (!_vm->_championMan->_g299_candidateChampionOrdinal) { + warning(false, "MISSING CODE: F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE(L1161_i_CommandX, L1162_i_CommandY);"); + } + return; + } + if (cmdType == k70_CommandClickOnMouth) { + warning(false, "MISSING CODE: F0349_INVENTORY_ProcessCommand70_ClickOnMouth();"); + return; + } + if (cmdType == k71_CommandClickOnEye) { + warning(false, "MISSING CODE: F0352_INVENTORY_ProcessCommand71_ClickOnEye();"); + return; + } + if (cmdType == k80_CommandClickInDungeonView) { + _vm->_eventMan->f377_commandProcessType80ClickInDungeonView(L1161_i_CommandX, L1162_i_CommandY); + return; + } + if (cmdType == k81_CommandClickInPanel) { + _vm->_eventMan->f378_commandProcess81ClickInPanel(L1161_i_CommandX, L1162_i_CommandY); return; } - if ((cmd._type >= k3_CommandMoveForward) && (cmd._type <= k6_CommandMoveLeft)) { - f366_commandMoveParty(cmd._type); + if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) { return; } - if (cmd._type == k80_CommandClickInDungeonView) { - f377_commandProcessType80ClickInDungeonView(commandX, commandY); + if (cmdType == k145_CommandSleep) { + if (!_vm->_championMan->_g299_candidateChampionOrdinal) { + if (_vm->_inventoryMan->_g432_inventoryChampionOrdinal) { + _vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory); + } + _vm->_menuMan->f456_drawDisabledMenu(); + _vm->_championMan->_g300_partyIsSleeping = true; + warning(false, "MISSING CODE: F0379_COMMAND_DrawSleepScreen();"); + _vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame); + _vm->_g318_waitForInputMaxVerticalBlankCount = 0; + _vm->_eventMan->_g441_primaryMouseInput = g450_PrimaryMouseInput_PartySleeping; + _vm->_eventMan->_g442_secondaryMouseInput = 0; + _g443_primaryKeyboardInput = g460_primaryKeyboardInput_partySleeping; + _g444_secondaryKeyboardInput = nullptr; + f357_discardAllInput(); + } + return; } - if (cmd._type == k81_CommandClickInPanel) { - f378_commandProcess81ClickInPanel(commandX, commandY); + if (cmdType == k146_CommandWakeUp) { + _vm->_championMan->f314_wakeUp(); + return; + } + if (cmdType == k140_CommandSaveGame) { + if ((_vm->_championMan->_g305_partyChampionCount > 0) && !_vm->_championMan->_g299_candidateChampionOrdinal) { + warning(false, "MISSING CODE: F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF();"); + } + return; + } + if (cmdType == k147_CommandFreezeGame) { + _vm->_g301_gameTimeTicking = false; + _vm->_menuMan->f456_drawDisabledMenu(); + _vm->_displayMan->f134_fillBitmap(_vm->_displayMan->_g296_bitmapViewport, k0_ColorBlack, 224, 136); + // TODO: localization + _vm->_textMan->f40_printTextToBitmap(_vm->_displayMan->_g296_bitmapViewport, k112_byteWidthViewport, 81, 69, k4_ColorCyan, k0_ColorBlack, + "GAME FROZEN", k136_heightViewport); + _vm->_displayMan->f97_drawViewport(k2_viewportAsBeforeSleepOrFreezeGame); + G0483_ps_PrimaryMouseInputBackup = _vm->_eventMan->_g441_primaryMouseInput; + G0484_ps_SecondaryMouseInputBackup = _vm->_eventMan->_g442_secondaryMouseInput; + G0481_ps_PrimaryKeyboardInputBackup = _g443_primaryKeyboardInput; + G0482_ps_SecondaryKeyboardInputBackup = _g444_secondaryKeyboardInput; + _vm->_eventMan->_g441_primaryMouseInput = g451_PrimaryMouseInput_FrozenGame; + _vm->_eventMan->_g442_secondaryMouseInput = 0; + _g443_primaryKeyboardInput = g461_primaryKeyboardInput_frozenGame; + _g444_secondaryKeyboardInput = nullptr; + f357_discardAllInput(); + return; + } + if (cmdType == k148_CommandUnfreezeGame) { + _vm->_g301_gameTimeTicking = true; + _vm->_menuMan->f457_drawEnabledMenus(); + _vm->_eventMan->_g441_primaryMouseInput = G0483_ps_PrimaryMouseInputBackup; + _vm->_eventMan->_g442_secondaryMouseInput = G0484_ps_SecondaryMouseInputBackup; + _g443_primaryKeyboardInput = G0481_ps_PrimaryKeyboardInputBackup; + _g444_secondaryKeyboardInput = G0482_ps_SecondaryKeyboardInputBackup; + f357_discardAllInput(); + return; + } + if (cmdType == k200_CommandEntranceEnterDungeon) { + _vm->_g298_newGame = k1_modeLoadDungeon; + return; + } + if (cmdType == k201_CommandEntranceResume) { + _vm->_g298_newGame = k0_modeLoadSavedGame; + return; + } + if (cmdType == k202_CommandEntranceDrawCredits) { + warning(false, "MISSING CODE: F0442_STARTEND_ProcessCommand202_EntranceDrawCredits()"); + return; + } + if ((cmdType >= k210_CommandClickOnDialogChoice_1) && (cmdType <= k213_CommandClickOnDialogChoice_4)) { + warning(false, "MISSING CODE:G0335_ui_SelectedDialogChoice = cmdType - (k210_CommandClickOnDialogChoice_1 - 1);"); + return; + } + if (cmdType == k215_CommandRestartGame) { + _vm->_g523_restartGameRequest = true; } - - // MISSING CODE: the rest of the function } void EventManager::f365_commandTurnParty(CommandType cmdType) { |