aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/m4/globals.h11
-rw-r--r--engines/m4/mads_logic.cpp4
-rw-r--r--engines/m4/mads_scene.cpp17
-rw-r--r--engines/m4/mads_scene.h4
4 files changed, 26 insertions, 10 deletions
diff --git a/engines/m4/globals.h b/engines/m4/globals.h
index 67dcfc2b94..117769ee8e 100644
--- a/engines/m4/globals.h
+++ b/engines/m4/globals.h
@@ -229,15 +229,18 @@ struct MadsConfigData {
#define SET_GLOBAL(x,y) _madsVm->globals()->_globals[x] = y
#define SET_GLOBAL32(x,y) { _madsVm->globals()->_globals[x] = (y) & 0xffff; _madsVm->globals()->_globals[(x) + 1] = (y) >> 16; }
+typedef int (*IntFunctionPtr)();
+
union DataMapEntry {
bool *boolValue;
uint16 *uint16Value;
int *intValue;
+ IntFunctionPtr fnPtr;
};
typedef Common::HashMap<uint16, uint16> DataMapHash;
-enum DataMapType {BOOL, UINT16, INT};
+enum DataMapType {BOOL, UINT16, INT, INT_FN};
class DataMapWrapper {
friend class DataMap;
@@ -249,16 +252,18 @@ public:
DataMapWrapper(uint16 *v) { _value.uint16Value = v; _type = UINT16; }
DataMapWrapper(int16 *v) { _value.uint16Value = (uint16 *)v; _type = UINT16; }
DataMapWrapper(int *v) { _value.intValue = v; _type = INT; }
+ DataMapWrapper(IntFunctionPtr v) { _value.fnPtr = v; _type = INT_FN; }
uint16 getIntValue() {
if (_type == BOOL) return *_value.boolValue ? 0xffff : 0;
else if (_type == UINT16) return *_value.uint16Value;
- else return *_value.intValue;
+ else if (_type == INT) return *_value.intValue;
+ else return _value.fnPtr();
}
void setIntValue(uint16 v) {
if (_type == BOOL) *_value.boolValue = v != 0;
else if (_type == UINT16) *_value.uint16Value = v;
- else *_value.intValue = v;
+ else if (_type == INT) *_value.intValue = v;
}
};
diff --git a/engines/m4/mads_logic.cpp b/engines/m4/mads_logic.cpp
index 2d4a581abe..878e86c573 100644
--- a/engines/m4/mads_logic.cpp
+++ b/engines/m4/mads_logic.cpp
@@ -182,7 +182,9 @@ void MadsSceneLogic::initialiseDataMap() {
MAP_DATA(&_madsVm->_player._playerPos.y);
MAP_DATA(&_madsVm->_player._direction);
MAP_DATA(&_madsVm->_player._visible);
- MAP_DATA(&_madsVm->scene()->_animActive);
+ MAP_DATA(&getActiveAnimationBool);
+ MAP_DATA(&getAnimationCurrentFrame);
+
}
DataMap &MadsSceneLogic::dataMap() {
diff --git a/engines/m4/mads_scene.cpp b/engines/m4/mads_scene.cpp
index 641ee756e3..e88a21eb4e 100644
--- a/engines/m4/mads_scene.cpp
+++ b/engines/m4/mads_scene.cpp
@@ -62,7 +62,6 @@ void SceneNode::load(Common::SeekableReadStream *stream) {
MadsScene::MadsScene(MadsEngine *vm): _sceneResources(), Scene(vm, &_sceneResources), MadsView(this) {
_vm = vm;
_activeAnimation = NULL;
- _animActive = false;
MadsView::_bgSurface = Scene::_backgroundSurface;
MadsView::_depthSurface = Scene::_walkSurface;
@@ -217,7 +216,6 @@ void MadsScene::leaveScene() {
if (_activeAnimation) {
delete _activeAnimation;
_activeAnimation = NULL;
- _animActive = false;
}
Scene::leaveScene();
@@ -386,7 +384,6 @@ void MadsScene::updateState() {
if (((MadsAnimation *) _activeAnimation)->freeFlag() || freeFlag) {
delete _activeAnimation;
_activeAnimation = NULL;
- _animActive = false;
}
}
@@ -458,7 +455,6 @@ void MadsScene::freeAnimation() {
delete _activeAnimation;
_activeAnimation = NULL;
- _animActive = false;
}
@@ -578,7 +574,6 @@ void MadsScene::loadAnimation(const Common::String &animName, int abortTimers) {
MadsAnimation *anim = new MadsAnimation(_vm, this);
anim->load(animName.c_str(), abortTimers);
_activeAnimation = anim;
- _animActive = true;
}
bool MadsScene::getDepthHighBit(const Common::Point &pt) {
@@ -1244,4 +1239,16 @@ void MadsInterfaceView::leaveScene() {
_madsVm->_viewManager->deleteView(view);
}
+//--------------------------------------------------------------------------
+
+int getActiveAnimationBool() {
+ return (_madsVm->scene()->activeAnimation()) ? 1 : 0;
+}
+
+int getAnimationCurrentFrame() {
+ Animation *anim = _madsVm->scene()->activeAnimation();
+ return anim ? anim->getCurrentFrame() : 0;
+}
+
+
} // End of namespace M4
diff --git a/engines/m4/mads_scene.h b/engines/m4/mads_scene.h
index a029c63a4b..743719d954 100644
--- a/engines/m4/mads_scene.h
+++ b/engines/m4/mads_scene.h
@@ -108,7 +108,6 @@ public:
Common::Point _destPos;
int _destFacing;
Common::Point _customDest;
- bool _animActive;
public:
MadsScene(MadsEngine *vm);
virtual ~MadsScene();
@@ -192,6 +191,9 @@ public:
bool onEvent(M4EventType eventType, int32 param1, int x, int y, bool &captureEvents);
};
+extern int getActiveAnimationBool();
+extern int getAnimationCurrentFrame();
+
} // End of namespace M4
#endif