aboutsummaryrefslogtreecommitdiff
path: root/engines/m4
diff options
context:
space:
mode:
authorPaul Gilbert2010-07-29 11:04:54 +0000
committerPaul Gilbert2010-07-29 11:04:54 +0000
commitfd804eb44b3e0f952efc2ffd3c66303e4a1c882c (patch)
tree4c9c42838dd47aaf06b18c65af45efa48ee5162b /engines/m4
parentf22821af666fe89a3635d53f02351273b435c952 (diff)
downloadscummvm-rg350-fd804eb44b3e0f952efc2ffd3c66303e4a1c882c.tar.gz
scummvm-rg350-fd804eb44b3e0f952efc2ffd3c66303e4a1c882c.tar.bz2
scummvm-rg350-fd804eb44b3e0f952efc2ffd3c66303e4a1c882c.zip
M4: Further work done on the setup and starting of actions
svn-id: r51461
Diffstat (limited to 'engines/m4')
-rw-r--r--engines/m4/mads_logic.cpp2
-rw-r--r--engines/m4/mads_logic.h2
-rw-r--r--engines/m4/mads_player.cpp2
-rw-r--r--engines/m4/mads_scene.cpp110
-rw-r--r--engines/m4/mads_scene.h3
-rw-r--r--engines/m4/mads_views.cpp23
-rw-r--r--engines/m4/mads_views.h5
-rw-r--r--engines/m4/scene.cpp1
-rw-r--r--engines/m4/scene.h1
9 files changed, 97 insertions, 52 deletions
diff --git a/engines/m4/mads_logic.cpp b/engines/m4/mads_logic.cpp
index 49ba7e1468..e7c20b237d 100644
--- a/engines/m4/mads_logic.cpp
+++ b/engines/m4/mads_logic.cpp
@@ -425,7 +425,7 @@ void MadsSceneLogic::doAction() {
warning("Still to do actions logic");
}
-void MadsSceneLogic::sceneStep() {
+void MadsSceneLogic::doSceneStep() {
// TODO: Sound handling
switch (_madsVm->scene()->_abortTimers) {
diff --git a/engines/m4/mads_logic.h b/engines/m4/mads_logic.h
index b5608dc721..ec6eff368b 100644
--- a/engines/m4/mads_logic.h
+++ b/engines/m4/mads_logic.h
@@ -61,7 +61,7 @@ public:
void enterScene();
void doPreactions();
void doAction();
- void sceneStep();
+ void doSceneStep();
};
class MadsGameLogic {
diff --git a/engines/m4/mads_player.cpp b/engines/m4/mads_player.cpp
index 19cd9eafe5..de09e97640 100644
--- a/engines/m4/mads_player.cpp
+++ b/engines/m4/mads_player.cpp
@@ -591,6 +591,8 @@ void MadsPlayer::reset() {
_destFacing = 5;
_newDirection = _direction;
+ _madsVm->scene()->_action._startWalkFlag = false;
+ _madsVm->scene()->_action._walkFlag = false;
_moving = false;
_v844BC = false;
_v844C0 = false;
diff --git a/engines/m4/mads_scene.cpp b/engines/m4/mads_scene.cpp
index 1f43f73cc0..ca8460a53a 100644
--- a/engines/m4/mads_scene.cpp
+++ b/engines/m4/mads_scene.cpp
@@ -252,9 +252,12 @@ void MadsScene::mouseMove(int x, int y) {
}
void MadsScene::leftClick(int x, int y) {
- // **DEBUG** - being used for movement testing
- _madsVm->_player.moveComplete();
- _madsVm->_player.setDest(x, y, 2);
+ // TODO: figure out the rest of Scene_leftClick, and implements relevant parts in the interface class
+ _action._v86F4C = -1;
+ _action._v86F4E = 0;
+ _customDest = _madsVm->_mouse->currentPos();
+ _action._selectedAction = -1;
+ _action._v86F4A = true;
}
void MadsScene::rightClick(int x, int y) {
@@ -308,62 +311,74 @@ void MadsScene::update() {
}
void MadsScene::updateState() {
- if ((_action._selectedAction != 0) || !_madsVm->_player._stepEnabled)
- _action.clear();
-
if (!_abortTimers && !_madsVm->_player._unk3) {
if (_dynamicHotspots._changed)
_dynamicHotspots.refresh();
-// int v = (_madsVm->_player._stepEnabled && !_action._verbNounFlag && !_abortTimers2) ? 1 : 0;
+// int v = (_madsVm->_player._stepEnabled && !_action._startWalkFlag && !_abortTimers2) ? 1 : 0;
// _screenObjects.check(v, false);
}
// Handle starting off any selected action
- bool lookFlag = false;
+ bool doPreAction = false;
if ((_action._selectedAction != 0) && _madsVm->_player._stepEnabled &&
- !_action._verbNounFlag && !_abortTimers && !_madsVm->_player._unk3) {
+ !_action._startWalkFlag && !_abortTimers && !_madsVm->_player._unk3) {
// Start the action
_action.startAction();
- lookFlag = (_action._action.verbId == kVerbLookAt) || (_action._action.verbId == kVerbLook);
+ if (_action._action.verbId == kVerbLookAt) {
+ _action._action.verbId = kVerbLook;
+ _action._savedFields.selectedRow = 0;
+ }
+ doPreAction = true;
}
- if (lookFlag || ((_abortTimers != 0) && (_abortTimersMode == ABORTMODE_2)))
+ if (doPreAction || ((_abortTimers != 0) && (_abortTimersMode == ABORTMODE_2)))
doPreactions();
checkStartWalk();
- // Update the player
- _madsVm->_player.update();
-
- // Handle refreshing the mouse position display
- if (_mouseMsgIndex != -1)
- _madsVm->scene()->_kernelMessages.remove(_mouseMsgIndex);
- if (_showMousePos) {
- char buffer[20];
- sprintf(buffer, "(%d,%d)", _madsVm->_mouse->currentPos().x, _madsVm->_mouse->currentPos().y);
-
- _mouseMsgIndex = _madsVm->scene()->_kernelMessages.add(Common::Point(5, 5), 0x203, 0, 0, 1, buffer);
+ if (_action._inProgress && !_madsVm->_player._moving && !_action._startWalkFlag &&
+ (_madsVm->_player._newDirection == _madsVm->_player._direction)) {
+ // Reached the end of action movement, so ready to actually do action
+ doAction();
+ } else if ((_abortTimers != 0) && (_abortTimersMode == ABORTMODE_0))
+ // Do an action designated by scripts
+ doAction();
+
+ bool freeFlag = false;
+ if (_currentScene != _nextScene)
+ freeFlag = true;
+ else {
+ doSceneStep();
+
+ if (_currentScene != _nextScene)
+ freeFlag = true;
+ else {
+ // Update the player
+ _madsVm->_player.nextFrame();
+
+ // Handle updating the animation
+ if (!_abortTimers && (_activeAnimation))
+ _activeAnimation->update();
+
+ // Handle refreshing the mouse position display
+ if (_mouseMsgIndex != -1)
+ _madsVm->scene()->_kernelMessages.remove(_mouseMsgIndex);
+ if (_showMousePos) {
+ char buffer[20];
+ sprintf(buffer, "(%d,%d)", _madsVm->_mouse->currentPos().x, _madsVm->_mouse->currentPos().y);
+
+ _mouseMsgIndex = _madsVm->scene()->_kernelMessages.add(Common::Point(5, 5), 0x203, 0, 0, 1, buffer);
+ }
+ }
}
if (_madsVm->globals()->_config.easyMouse)
_action.refresh();
-
- // Step through the scene
- _sceneLogic.sceneStep();
-
- _madsVm->_player.step();
- _madsVm->_player._unk3 = 0;
-
- if (_abortTimersMode == ABORTMODE_1)
- _abortTimers = 0;
-
- // Handle updating the player frame
- _madsVm->_player.nextFrame();
if ((_activeAnimation) && !_abortTimers) {
_activeAnimation->update();
- if (((MadsAnimation *) _activeAnimation)->freeFlag()) {
+ if (((MadsAnimation *) _activeAnimation)->freeFlag() || freeFlag) {
delete _activeAnimation;
_activeAnimation = NULL;
}
@@ -374,12 +389,17 @@ void MadsScene::updateState() {
// Remove the animation if it's been completed
if ((_activeAnimation) && ((MadsAnimation *)_activeAnimation)->freeFlag())
freeAnimation();
+
+ if ((_action._selectedAction != 0) || !_madsVm->_player._stepEnabled) {
+ _action.clear();
+ _action._selectedAction = 0;
+ }
}
void MadsScene::checkStartWalk() {
- if (_action._verbNounFlag && _action._walkFlag) {
+ if (_action._startWalkFlag && _action._walkFlag) {
_madsVm->_player.setDest(_destPos.x, _destPos.y, _destFacing);
- _action._verbNounFlag = false;
+ _action._startWalkFlag = false;
}
}
@@ -395,6 +415,22 @@ void MadsScene::doPreactions() {
}
}
+void MadsScene::doSceneStep() {
+ // Step through the scene
+ _sceneLogic.doSceneStep();
+
+ _madsVm->_player.step();
+ _madsVm->_player._unk3 = 0;
+
+ if (_abortTimersMode == ABORTMODE_1)
+ _abortTimers = 0;
+}
+
+void MadsScene::doAction() {
+ warning("TODO MadsScene::doAction");
+}
+
+
/**
* Does extra work at cleaning up the animation, and then deletes it
*/
diff --git a/engines/m4/mads_scene.h b/engines/m4/mads_scene.h
index baa6a67861..7723058cc7 100644
--- a/engines/m4/mads_scene.h
+++ b/engines/m4/mads_scene.h
@@ -100,11 +100,14 @@ private:
void setAction();
void checkStartWalk();
void doPreactions();
+ void doSceneStep();
+ void doAction();
public:
char _aaName[100];
bool _showMousePos;
Common::Point _destPos;
int _destFacing;
+ Common::Point _customDest;
public:
MadsScene(MadsEngine *vm);
virtual ~MadsScene();
diff --git a/engines/m4/mads_views.cpp b/engines/m4/mads_views.cpp
index 20d469fedf..6c16e0e611 100644
--- a/engines/m4/mads_views.cpp
+++ b/engines/m4/mads_views.cpp
@@ -40,9 +40,10 @@ namespace M4 {
MadsAction::MadsAction(MadsView &owner): _owner(owner) {
clear();
_currentAction = kVerbNone;
- _verbNounFlag = false;
+ _startWalkFlag = false;
_statusTextIndex = -1;
_selectedAction = 0;
+ _inProgress = false;
}
void MadsAction::clear() {
@@ -256,7 +257,7 @@ void MadsAction::refresh() {
void MadsAction::startAction() {
_madsVm->_player.moveComplete();
- _v84538 = -1;
+ _inProgress = true;
_v8453A = 0;
_savedFields.selectedRow = _selectedRow;
_savedFields.articleNumber = _articleNumber;
@@ -274,7 +275,7 @@ void MadsAction::startAction() {
if ((_savedFields.actionMode2 == ACTMODE2_4) && (savedV86F42 == 0))
_v8453A = true;
- _verbNounFlag = false;
+ _startWalkFlag = false;
int hotspotId = -1;
HotSpotList &dynHotspots = *_madsVm->scene()->getSceneResources().dynamicHotspots;
HotSpotList &hotspots = *_madsVm->scene()->getSceneResources().hotspots;
@@ -289,11 +290,11 @@ void MadsAction::startAction() {
HotSpot &hs = dynHotspots[hotspotId - hotspots.size()];
if ((hs.getFeetX() == -1) || (hs.getFeetX() == -3)) {
if (_v86F4A && ((hs.getFeetX() == -3) || (_savedFields.selectedRow < 0))) {
- _verbNounFlag = true;
- _madsVm->scene()->_destPos = _customDest;
+ _startWalkFlag = true;
+ _madsVm->scene()->_destPos = _madsVm->scene()->_customDest;
}
} else if ((hs.getFeetX() >= 0) && ((_savedFields.actionMode == ACTMODE_NONE) || (hs.getCursor() < 2))) {
- _verbNounFlag = true;
+ _startWalkFlag = true;
_madsVm->scene()->_destPos.x = hs.getFeetX();
_madsVm->scene()->_destPos.y = hs.getFeetY();
}
@@ -306,21 +307,23 @@ void MadsAction::startAction() {
HotSpot &hs = hotspots[hotspotId];
if ((hs.getFeetX() == -1) || (hs.getFeetX() == -3)) {
if (_v86F4A && ((hs.getFeetX() == -3) || (_savedFields.selectedRow < 0))) {
- _verbNounFlag = true;
- _madsVm->scene()->_destPos = _customDest;
+ _startWalkFlag = true;
+ _madsVm->scene()->_destPos = _madsVm->scene()->_customDest;
}
} else if ((hs.getFeetX() >= 0) && ((_savedFields.actionMode == ACTMODE_NONE) || (hs.getCursor() < 2))) {
- _verbNounFlag = true;
+ _startWalkFlag = true;
_madsVm->scene()->_destPos.x = hs.getFeetX();
_madsVm->scene()->_destPos.y = hs.getFeetY();
}
_madsVm->scene()->_destFacing = hs.getFacing();
}
+
+ _walkFlag = _startWalkFlag;
}
void MadsAction::checkAction() {
if (isAction(kVerbLookAt) || isAction(kVerbThrow))
- _verbNounFlag = 0;
+ _startWalkFlag = 0;
}
bool MadsAction::isAction(int verbId, int objectNameId, int indirectObjectId) {
diff --git a/engines/m4/mads_views.h b/engines/m4/mads_views.h
index 2f4103eaca..c93d0beda3 100644
--- a/engines/m4/mads_views.h
+++ b/engines/m4/mads_views.h
@@ -71,12 +71,11 @@ public:
int _selectedRow;
bool _textChanged;
int _selectedAction;
- bool _verbNounFlag;
+ bool _startWalkFlag;
int _statusTextIndex;
int _hotspotId;
MadsActionSavedFields _savedFields;
bool _walkFlag;
- Common::Point _customDest;
// Unknown fields
int16 _v86F3A;
@@ -85,7 +84,7 @@ public:
bool _v86F4A;
int16 _v86F4C;
int _v83338;
- int _v84538;
+ bool _inProgress;
bool _v8453A;
public:
diff --git a/engines/m4/scene.cpp b/engines/m4/scene.cpp
index 361d1bad47..8457f2087a 100644
--- a/engines/m4/scene.cpp
+++ b/engines/m4/scene.cpp
@@ -61,6 +61,7 @@ Scene::~Scene() {
void Scene::loadScene(int sceneNumber) {
_previousScene = _currentScene;
_currentScene = sceneNumber;
+ _nextScene = sceneNumber;
}
void Scene::leaveScene() {
diff --git a/engines/m4/scene.h b/engines/m4/scene.h
index e6eaed0ab9..9262a7c828 100644
--- a/engines/m4/scene.h
+++ b/engines/m4/scene.h
@@ -79,6 +79,7 @@ private:
protected:
int _currentScene;
int _previousScene;
+ int _nextScene;
GameInterfaceView *_interfaceSurface;
M4Surface *_backgroundSurface;
M4Surface *_walkSurface;