aboutsummaryrefslogtreecommitdiff
path: root/engines/dm
diff options
context:
space:
mode:
authorBendegúz Nagy2016-06-17 14:29:05 +0200
committerBendegúz Nagy2016-08-26 23:02:22 +0200
commit98c79f89bf2c5860f39a6ec7ca88a01a2f987323 (patch)
tree9f994595202a3fb9d68b6e6bfa5fc1481cb6b8fb /engines/dm
parentbcfe176df557b78adf9181a9dfea229ff3fadfe1 (diff)
downloadscummvm-rg350-98c79f89bf2c5860f39a6ec7ca88a01a2f987323.tar.gz
scummvm-rg350-98c79f89bf2c5860f39a6ec7ca88a01a2f987323.tar.bz2
scummvm-rg350-98c79f89bf2c5860f39a6ec7ca88a01a2f987323.zip
DM: Add mouse input processing and display for movement arrows
Diffstat (limited to 'engines/dm')
-rw-r--r--engines/dm/dm.cpp15
-rw-r--r--engines/dm/dm.h4
-rw-r--r--engines/dm/eventman.cpp79
-rw-r--r--engines/dm/eventman.h10
-rw-r--r--engines/dm/gfx.cpp12
-rw-r--r--engines/dm/gfx.h13
-rw-r--r--engines/dm/menus.cpp18
-rw-r--r--engines/dm/menus.h18
-rw-r--r--engines/dm/module.mk3
9 files changed, 158 insertions, 14 deletions
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 44c90d245e..40e25d30fd 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -15,6 +15,7 @@
#include "gfx.h"
#include "dungeonman.h"
#include "eventman.h"
+#include "menus.h"
namespace DM {
@@ -52,6 +53,7 @@ DMEngine::~DMEngine() {
delete _displayMan;
delete _dungeonMan;
delete _eventMan;
+ delete _menuMan;
// clear debug channels
DebugMan.clearAllDebugChannels();
@@ -64,6 +66,7 @@ Common::Error DMEngine::run() {
_displayMan = new DisplayMan(this);
_dungeonMan = new DungeonMan(this);
_eventMan = new EventManager(this);
+ _menuMan = new MenuMan(this);
_displayMan->setUpScreens(320, 200);
@@ -84,9 +87,16 @@ Common::Error DMEngine::run() {
while (true) {
- _eventMan->processInput();
+ _stopWaitingForPlayerInput = false;
+ //do {
+ _eventMan->processInput();
+ _eventMan->processCommandQueue();
+ //} while (!_stopWaitingForPlayerInput || !_gameTimeTicking);
+
_displayMan->clearScreen(kColorBlack);
_displayMan->drawDungeon(_dungeonMan->_currMap.partyDir, _dungeonMan->_currMap.partyPosX, _dungeonMan->_currMap.partyPosY);
+ // DUMMY CODE:
+ _menuMan->drawMovementArrows();
_displayMan->updateScreen();
_system->delayMillis(10);
}
@@ -99,6 +109,9 @@ Common::Error DMEngine::run() {
void DMEngine::startGame() {
_eventMan->_primaryMouseInput = gPrimaryMouseInput_Interface;
_eventMan->_secondaryMouseInput = gSecondaryMouseInput_Movement;
+
+ _menuMan->drawMovementArrows();
+ _gameTimeTicking = true;
}
} // End of namespace DM
diff --git a/engines/dm/dm.h b/engines/dm/dm.h
index 83f80e4327..384ac1dd5d 100644
--- a/engines/dm/dm.h
+++ b/engines/dm/dm.h
@@ -12,6 +12,7 @@ class Console;
class DisplayMan;
class DungeonMan;
class EventManager;
+class MenuMan;
enum direction {
@@ -90,6 +91,9 @@ public:
DisplayMan *_displayMan;
DungeonMan *_dungeonMan;
EventManager *_eventMan;
+ MenuMan *_menuMan;
+ bool _stopWaitingForPlayerInput; // G0321_B_StopWaitingForPlayerInput
+ bool _gameTimeTicking; // @ G0301_B_GameTimeTicking
};
class Console : public GUI::Debugger {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index f2ca15e0c5..488deeb017 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -268,6 +268,7 @@ void EventManager::processInput() {
Common::Event event;
while (_vm->_system->getEventManager()->pollEvent(event)) {
switch (event.type) {
+ // DUMMY CODE: EVENT_KEYDOWN, only for testing
case Common::EVENT_KEYDOWN:
if (event.synthetic)
break;
@@ -303,11 +304,11 @@ void EventManager::processInput() {
case Common::EVENT_MOUSEMOVE:
_mousePos = event.mouse;
break;
- case Common::EVENT_LBUTTONUP:
- case Common::EVENT_RBUTTONUP:
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_RBUTTONDOWN:
_pendingClickPresent = true;
_pendingClickPos = _mousePos;
- _pendingClickButton = (event.type == Common::EVENT_LBUTTONUP) ? kLeftMouseButton : kRightMouseButton;
+ _pendingClickButton = (event.type == Common::EVENT_LBUTTONDOWN) ? kLeftMouseButton : kRightMouseButton;
break;
}
}
@@ -347,4 +348,76 @@ CommandType EventManager::getCommandTypeFromMouseInput(MouseInput *input, Common
}
+void EventManager::processCommandQueue() {
+ _isCommandQueueLocked = true;
+ if (_commandQueue.empty()) {
+ _isCommandQueueLocked = false;
+ processPendingClick();
+ return;
+ }
+
+ Command cmd = _commandQueue.pop();
+
+ // MISSING CODE: for when movement is disabled
+
+ _isCommandQueueLocked = false;
+ processPendingClick();
+
+ if ((cmd.type == kCommandTurnRight) || (cmd.type == kCommandTurnLeft)) {
+ commandTurnParty(cmd.type);
+ return;
+ }
+
+ if ((cmd.type >= kCommandMoveForward) && (cmd.type <= kCommandMoveLeft)) {
+ commandMoveParty(cmd.type);
+ return;
+ }
+
+ // MISSING CODE: the rest of the function
+}
+
+void EventManager::commandTurnParty(CommandType cmdType) {
+ _vm->_stopWaitingForPlayerInput = true;
+
+ // MISSING CODE: highlight turn left/right buttons
+
+ // MISSING CODE: processing stairs
+
+ // MISSING CODE: process sensors
+
+ // DUMMY CODE: should call F0284_CHAMPION_SetPartyDirection instead
+ direction &partyDir = _vm->_dungeonMan->_currMap.partyDir;
+ (cmdType == kCommandTurnLeft) ? turnDirLeft(partyDir) : turnDirRight(partyDir);
+
+ // MISSING CODE: process sensors
+}
+
+void EventManager::commandMoveParty(CommandType cmdType) {
+ _vm->_stopWaitingForPlayerInput = true;
+
+ // MISSING CODE: Lots of code
+
+ // DUMMY CODE:
+ DungeonMan &dungeonMan = *_vm->_dungeonMan;
+ CurrMapData &currMap = dungeonMan._currMap;
+
+ switch (cmdType) {
+ case kCommandMoveForward:
+ dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 1, 0, currMap.partyPosX, currMap.partyPosY);
+ break;
+ case kCommandMoveLeft:
+ dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, -1, currMap.partyPosX, currMap.partyPosY);
+ break;
+ case kCommandMoveBackward:
+ dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, -1, 0, currMap.partyPosX, currMap.partyPosY);
+ break;
+ case kCommandMoveRight:
+ dungeonMan.mapCoordsAfterRelMovement(dungeonMan._currMap.partyDir, 0, 1, currMap.partyPosX, currMap.partyPosY);
+ break;
+ }
+
+ // MISSING CODE: Lots of code
+}
+
+
}; // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index c52cf6d95c..ed6bba20b1 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -131,7 +131,7 @@ public:
Common::Point pos;
CommandType type;
- Command(Common::Point position, CommandType commandType): pos(position), type(type) {}
+ Command(Common::Point position, CommandType commandType): pos(position), type(commandType) {}
}; // @ COMMAND
@@ -189,8 +189,11 @@ class EventManager {
Common::Point _pendingClickPos; // @ G0437_i_PendingClickX, G0438_i_PendingClickY
MouseButton _pendingClickButton; // @ G0439_i_PendingClickButtonsStatus
- bool _isCommandQueueLocked;
+ bool _isCommandQueueLocked; // this doesn't seem to be used anywhere at all
Common::Queue<Command> _commandQueue;
+
+ void commandTurnParty(CommandType cmdType); // @ F0365_COMMAND_ProcessTypes1To2_TurnParty
+ void commandMoveParty(CommandType cmdType); // @ F0366_COMMAND_ProcessTypes3To6_MoveParty
public:
MouseInput* _primaryMouseInput;// @ G0441_ps_PrimaryMouseInput
MouseInput* _secondaryMouseInput;// @ G0442_ps_SecondaryMouseInput
@@ -200,10 +203,11 @@ public:
void showMouse(bool visibility);
void setMousePos(Common::Point pos);
- void processInput();
+ void processInput(); // acknowledges mouse and keyboard input
void processPendingClick(); // @ F0360_COMMAND_ProcessPendingClick
void processClick(Common::Point mousePos, MouseButton button); // @ F0359_COMMAND_ProcessClick_CPSC
CommandType getCommandTypeFromMouseInput(MouseInput *input, Common::Point mousePos, MouseButton button); // @ F0358_COMMAND_GetCommandFromMouseInput_CPSC
+ void processCommandQueue(); // @ F0380_COMMAND_ProcessQueue_CPSC
};
}
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 3042d8f03e..8f88bab5f6 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -10,6 +10,8 @@
namespace DM {
+Box gBoxMovementArrows = {224, 319, 124, 168};
+
enum ViewCell {
kViewCellFronLeft = 0, // @ C00_VIEW_CELL_FRONT_LEFT
kViewCellFrontRight = 1, // @ C01_VIEW_CELL_FRONT_RIGHT
@@ -548,11 +550,7 @@ CreatureReplColorSet gCreatureReplColorSets[13] = { // @ G0220_as_Graphic558_Cre
byte gPalChangesCreature_D3[16] = {0, 120, 10, 30, 40, 30, 0, 60, 30, 0, 0, 110, 0, 20, 0, 130}; // @ G0221_auc_Graphic558_PaletteChanges_Creature_D3
byte gPalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, 110, 120, 130, 140, 150}; // @ G0222_auc_Graphic558_PaletteChanges_Creature_D2
-enum GraphicIndice {
- kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT
- kDoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
- kChampionPortraitsIndice = 26 // @ C026_GRAPHIC_CHAMPION_PORTRAITS
-};
+
Viewport gDefultViewPort = {0, 0};
@@ -1505,3 +1503,7 @@ void DisplayMan::blitToBitmapShrinkWithPalChange(byte *srcBitmap, int16 srcWidth
}
}
+
+byte* DisplayMan::getBitmap(uint16 index) {
+ return _bitmaps[index];
+}
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 50171feaa3..fd9a4a3bd9 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -7,6 +7,14 @@
namespace DM {
+
+enum GraphicIndice {
+ kInscriptionFontIndice = 120, // @ C120_GRAPHIC_INSCRIPTION_FONT
+ kDoorMaskDestroyedIndice = 301, // @ C301_GRAPHIC_DOOR_MASK_DESTROYED
+ kChampionPortraitsIndice = 26, // @ C026_GRAPHIC_CHAMPION_PORTRAITS
+ kMovementArrowsIndice = 13 // @ C013_GRAPHIC_MOVEMENT_ARROWS
+};
+
extern uint16 gPalSwoosh[16];
extern uint16 gPalMousePointer[16];
extern uint16 gPalCredits[16];
@@ -20,12 +28,14 @@ public:
uint16 Y1;
uint16 Y2;
- Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): X1(x1), X2(x2), Y1(y1), Y2(y2) {}
+ Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): X1(x1), X2(x2 + 1), Y1(y1), Y2(y2 + 1) {}
bool isPointInside(Common::Point point) {
return (X1 <= point.x) && (point.x < X2) && (Y1 <= point.y) && (point.y < Y2);
}
}; // @ BOX_BYTE, BOX_WORD
+extern Box gBoxMovementArrows; // G0002_s_Graphic562_Box_MovementArrows
+
// The frames in the original sources contain inclusive boundaries and byte widths, not pixel widths
struct Frame {
uint16 destFromX, destToX, destFromY, destToY;
@@ -269,6 +279,7 @@ public:
void clearScreen(Color color);
void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF
void updateScreen();
+ byte* getBitmap(uint16 index);
int16 _championPortraitOrdinal; // @ G0289_i_DungeonView_ChampionPortraitOrdinal
int16 _currMapAlcoveOrnIndices[kAlcoveOrnCount]; // @ G0267_ai_CurrentMapAlcoveOrnamentIndices
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
new file mode 100644
index 0000000000..1b4c68dafe
--- /dev/null
+++ b/engines/dm/menus.cpp
@@ -0,0 +1,18 @@
+#include "menus.h"
+#include "gfx.h"
+
+
+namespace DM {
+
+MenuMan::MenuMan(DMEngine *vm): _vm(vm) {}
+
+void MenuMan::drawMovementArrows() {
+ DisplayMan &disp = *_vm->_displayMan;
+ byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice);
+ Box &dest = gBoxMovementArrows;
+ uint16 w = disp.width(kMovementArrowsIndice);
+
+ disp.blitToScreen(arrowsBitmap, w, 0, 0, dest.X1, dest.X2, dest.Y1, dest.Y2, kColorNoTransparency);
+}
+
+} \ No newline at end of file
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
new file mode 100644
index 0000000000..d4ea2d68ba
--- /dev/null
+++ b/engines/dm/menus.h
@@ -0,0 +1,18 @@
+#ifndef DM_MENUS_H
+#define DM_MENUS_H
+
+#include "dm.h"
+
+namespace DM {
+
+class MenuMan {
+ DMEngine *_vm;
+public:
+ MenuMan(DMEngine *vm);
+
+ void drawMovementArrows();
+};
+
+}
+
+#endif // !DM_MENUS_H
diff --git a/engines/dm/module.mk b/engines/dm/module.mk
index 3078fa54ab..ed2e2ea442 100644
--- a/engines/dm/module.mk
+++ b/engines/dm/module.mk
@@ -5,7 +5,8 @@ MODULE_OBJS := \
dm.o \
gfx.o \
dungeonman.o \
- eventman.o
+ eventman.o \
+ menus.o
MODULE_DIRS += \
engines/dm