[Scummvm-cvs-logs] SF.net SVN: scummvm:[54034] scummvm/trunk/engines/m4

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Tue Nov 2 01:15:19 CET 2010


Revision: 54034
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54034&view=rev
Author:   dreammaster
Date:     2010-11-02 00:15:18 +0000 (Tue, 02 Nov 2010)

Log Message:
-----------
M4: Added function pointers to the the script engine data map list

Modified Paths:
--------------
    scummvm/trunk/engines/m4/globals.h
    scummvm/trunk/engines/m4/mads_logic.cpp
    scummvm/trunk/engines/m4/mads_scene.cpp
    scummvm/trunk/engines/m4/mads_scene.h

Modified: scummvm/trunk/engines/m4/globals.h
===================================================================
--- scummvm/trunk/engines/m4/globals.h	2010-11-02 00:13:04 UTC (rev 54033)
+++ scummvm/trunk/engines/m4/globals.h	2010-11-02 00:15:18 UTC (rev 54034)
@@ -229,15 +229,18 @@
 #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 @@
 	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;
 	}
 };
 

Modified: scummvm/trunk/engines/m4/mads_logic.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_logic.cpp	2010-11-02 00:13:04 UTC (rev 54033)
+++ scummvm/trunk/engines/m4/mads_logic.cpp	2010-11-02 00:15:18 UTC (rev 54034)
@@ -182,7 +182,9 @@
 	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() {

Modified: scummvm/trunk/engines/m4/mads_scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_scene.cpp	2010-11-02 00:13:04 UTC (rev 54033)
+++ scummvm/trunk/engines/m4/mads_scene.cpp	2010-11-02 00:15:18 UTC (rev 54034)
@@ -62,7 +62,6 @@
 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 @@
 	if (_activeAnimation) {
 		delete _activeAnimation;
 		_activeAnimation = NULL;
-		_animActive = false;
 	}
 
 	Scene::leaveScene();
@@ -386,7 +384,6 @@
 		if (((MadsAnimation *) _activeAnimation)->freeFlag() || freeFlag) {
 			delete _activeAnimation;
 			_activeAnimation = NULL;
-			_animActive = false;
 		}
 	}
 
@@ -458,7 +455,6 @@
 
 	delete _activeAnimation;
 	_activeAnimation = NULL;
-	_animActive = false;
 }
 
 
@@ -578,7 +574,6 @@
 	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 @@
 	_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

Modified: scummvm/trunk/engines/m4/mads_scene.h
===================================================================
--- scummvm/trunk/engines/m4/mads_scene.h	2010-11-02 00:13:04 UTC (rev 54033)
+++ scummvm/trunk/engines/m4/mads_scene.h	2010-11-02 00:15:18 UTC (rev 54034)
@@ -108,7 +108,6 @@
 	Common::Point _destPos;
 	int _destFacing;
 	Common::Point _customDest;
-	bool _animActive;
 public:
 	MadsScene(MadsEngine *vm);
 	virtual ~MadsScene();
@@ -192,6 +191,9 @@
 	bool onEvent(M4EventType eventType, int32 param1, int x, int y, bool &captureEvents);
 };
 
+extern int getActiveAnimationBool();
+extern int getAnimationCurrentFrame();
+
 } // End of namespace M4
 
 #endif


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list