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

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Tue Mar 16 09:26:09 CET 2010


Revision: 48266
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48266&view=rev
Author:   dreammaster
Date:     2010-03-16 08:26:08 +0000 (Tue, 16 Mar 2010)

Log Message:
-----------
Further code implemented for the current action display

Modified Paths:
--------------
    scummvm/trunk/engines/m4/console.cpp
    scummvm/trunk/engines/m4/hotspot.h
    scummvm/trunk/engines/m4/m4_scene.cpp
    scummvm/trunk/engines/m4/m4_scene.h
    scummvm/trunk/engines/m4/mads_scene.cpp
    scummvm/trunk/engines/m4/mads_scene.h
    scummvm/trunk/engines/m4/mads_views.h
    scummvm/trunk/engines/m4/scene.cpp
    scummvm/trunk/engines/m4/scene.h
    scummvm/trunk/engines/m4/staticres.cpp
    scummvm/trunk/engines/m4/staticres.h

Modified: scummvm/trunk/engines/m4/console.cpp
===================================================================
--- scummvm/trunk/engines/m4/console.cpp	2010-03-15 22:24:52 UTC (rev 48265)
+++ scummvm/trunk/engines/m4/console.cpp	2010-03-16 08:26:08 UTC (rev 48266)
@@ -103,7 +103,7 @@
 	_vm->_scene->getSceneResources().hotspots->dump();
 	if (_vm->isM4()) {
 		DebugPrintf("Scene parallax\n");
-		_vm->_scene->getSceneResources().parallax->dump();
+		_m4Vm->scene()->getSceneResources().parallax->dump();
 		DebugPrintf("Scene props\n");
 		_vm->_scene->getSceneResources().props->dump();
 	}
@@ -395,23 +395,23 @@
 }
 
 bool M4Console::cmdSceneInfo(int argc, const char **argv) {
-	DebugPrintf("Current scene is: %i\n", _vm->_scene->getCurrentScene());
+	DebugPrintf("Current scene is: %i\n", _m4Vm->scene()->getCurrentScene());
 
 	DebugPrintf("Scene resources:\n");
-	DebugPrintf("artBase: %s\n", _vm->_scene->getSceneResources().artBase);
-	DebugPrintf("pictureBase: %s\n", _vm->_scene->getSceneResources().pictureBase);
-	DebugPrintf("hotspotCount: %i\n", _vm->_scene->getSceneResources().hotspotCount);
-	DebugPrintf("parallaxCount: %i\n", _vm->_scene->getSceneResources().parallaxCount);
-	DebugPrintf("propsCount: %i\n", _vm->_scene->getSceneResources().propsCount);
-	DebugPrintf("frontY: %i\n", _vm->_scene->getSceneResources().frontY);
-	DebugPrintf("backY: %i\n", _vm->_scene->getSceneResources().backY);
-	DebugPrintf("frontScale: %i\n", _vm->_scene->getSceneResources().frontScale);
-	DebugPrintf("backScale: %i\n", _vm->_scene->getSceneResources().backScale);
+	DebugPrintf("artBase: %s\n", _m4Vm->scene()->getSceneResources().artBase);
+	DebugPrintf("pictureBase: %s\n", _m4Vm->scene()->getSceneResources().pictureBase);
+	DebugPrintf("hotspotCount: %i\n", _m4Vm->scene()->getSceneResources().hotspotCount);
+	DebugPrintf("parallaxCount: %i\n", _m4Vm->scene()->getSceneResources().parallaxCount);
+	DebugPrintf("propsCount: %i\n", _m4Vm->scene()->getSceneResources().propsCount);
+	DebugPrintf("frontY: %i\n", _m4Vm->scene()->getSceneResources().frontY);
+	DebugPrintf("backY: %i\n", _m4Vm->scene()->getSceneResources().backY);
+	DebugPrintf("frontScale: %i\n", _m4Vm->scene()->getSceneResources().frontScale);
+	DebugPrintf("backScale: %i\n", _m4Vm->scene()->getSceneResources().backScale);
 	DebugPrintf("depthTable: ");
 	for (uint i = 0; i < 16; i++)
-		DebugPrintf("%i ", _vm->_scene->getSceneResources().depthTable[i]);
+		DebugPrintf("%i ", _m4Vm->scene()->getSceneResources().depthTable[i]);
 	DebugPrintf("\n");
-	DebugPrintf("railNodeCount: %i\n", _vm->_scene->getSceneResources().railNodeCount);
+	DebugPrintf("railNodeCount: %i\n", _m4Vm->scene()->getSceneResources().railNodeCount);
 
 	return true;
 }

Modified: scummvm/trunk/engines/m4/hotspot.h
===================================================================
--- scummvm/trunk/engines/m4/hotspot.h	2010-03-15 22:24:52 UTC (rev 48265)
+++ scummvm/trunk/engines/m4/hotspot.h	2010-03-16 08:26:08 UTC (rev 48266)
@@ -59,6 +59,7 @@
 	void setRect(int x1, int y1, int x2, int y2);
 	void setFeet(int x, int y);
 	void setFacing(uint8 facing) { _facing = facing; }
+	void setArticle(int8 v) { _articleNumber = v; }
 	char *getVocab() const { return _vocab; }
 	int32 getVocabID() { return _vocabID; }
 	char *getVerb() const { return _verb; }
@@ -70,6 +71,7 @@
 	uint8 getFacing() const { return _facing; }
 	int getFeetX() { return _feetX; }
 	int getFeetY() { return _feetY; }
+	int8 getArticle() const { return _articleNumber; }
 	Common::Rect getRect() const;
 
 	int32 area() const { return (_rect.width() - 1) * (_rect.height() - 1); }
@@ -85,6 +87,8 @@
 	// Unused in Orion Burger, used in MADS games
 	uint8 _syntax;
 	int32 _vocabID, _verbID;
+	int8 _articleNumber;
+
 	//TODO: check if this is actually needed by the game
 	int16 _hash;
 };

Modified: scummvm/trunk/engines/m4/m4_scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/m4_scene.cpp	2010-03-15 22:24:52 UTC (rev 48265)
+++ scummvm/trunk/engines/m4/m4_scene.cpp	2010-03-16 08:26:08 UTC (rev 48266)
@@ -41,8 +41,10 @@
 M4Scene::M4Scene(M4Engine *vm): _sceneResources(), Scene(vm, &_sceneResources) {
 	_vm = vm;
 	_sceneSprites = NULL;
+	_inverseColourTable = NULL;
+
+	_sceneResources.parallax = new HotSpotList();
 	_interfaceSurface = new M4InterfaceView(vm);
-	_inverseColourTable = NULL;
 }
 
 M4Scene::~M4Scene() {
@@ -195,6 +197,9 @@
 }
 
 void M4Scene::leaveScene() {
+	_sceneResources.parallax->clear();
+
+	delete _sceneResources.parallax;
 	delete[] _inverseColourTable;
 
 	Scene::leaveScene();
@@ -308,4 +313,14 @@
 	_vm->_mouse->setCursorNum(cursorIndex);
 }
 
+void M4Scene::showHotSpots() {
+	Scene::showHotSpots();
+
+	// parallax (yellow)
+	for (int i = 0; i < _sceneResources.parallaxCount; i++) {
+		HotSpot *currentHotSpot = _sceneResources.parallax->get(i);
+		_backgroundSurface->frameRect(currentHotSpot->getRect(), _vm->_palette->YELLOW);
+	}
+}
+
 } // End of namespace M4

Modified: scummvm/trunk/engines/m4/m4_scene.h
===================================================================
--- scummvm/trunk/engines/m4/m4_scene.h	2010-03-15 22:24:52 UTC (rev 48265)
+++ scummvm/trunk/engines/m4/m4_scene.h	2010-03-16 08:26:08 UTC (rev 48266)
@@ -42,6 +42,9 @@
 	int32 frontScale, backScale;
 	int16 depthTable[16];
 	int32 railNodeCount;	// # of rails
+
+	int32 parallaxCount;
+	HotSpotList *parallax;
 };
 
 class M4Scene : public Scene {
@@ -70,12 +73,13 @@
 	virtual void leftClick(int x, int y);
 	virtual void rightClick(int x, int y);
 	virtual void setAction(int action, int objectId = -1);
-	virtual void setStatusText(const char *text);
 	virtual void update();
+	virtual void showHotSpots();
 
 	byte *getInverseColourTable() const { return _inverseColourTable; }
 	M4InterfaceView *getInterface() { return (M4InterfaceView *)_interfaceSurface; };
 	M4SceneResources &getSceneResources() { return _sceneResources; };
+	void setStatusText(const char *text);
 };
 
 } // End of namespace M4

Modified: scummvm/trunk/engines/m4/mads_scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_scene.cpp	2010-03-15 22:24:52 UTC (rev 48265)
+++ scummvm/trunk/engines/m4/mads_scene.cpp	2010-03-16 08:26:08 UTC (rev 48266)
@@ -43,7 +43,6 @@
 MadsScene::MadsScene(MadsEngine *vm): _sceneResources(), Scene(vm, &_sceneResources) {
 	_vm = vm;
 
-	strcpy(_statusText, "");
 	_interfaceSurface = new MadsInterfaceView(vm);
 	_spriteSlotsStart = 0;
 	for (int i = 0; i < 3; ++i)
@@ -94,6 +93,8 @@
 		return;
 
 	loadSceneHotspots(_currentScene);
+
+	_action.clear();
 }
 
 void MadsScene::loadScene(int sceneNumber) {
@@ -149,11 +150,9 @@
 
 void MadsScene::leaveScene() {
 	_sceneResources.hotspots->clear();
-	_sceneResources.parallax->clear();
 	_sceneResources.props->clear();
 
 	delete _sceneResources.hotspots;
-	delete _sceneResources.parallax;
 	delete _sceneResources.props;
 
 	// Delete the sprites
@@ -263,10 +262,6 @@
 	setStatusText(statusText);
 }
 
-void MadsScene::setStatusText(const char *text) {
-	strcpy(_statusText, text);
-}
-
 /**
  * Draws all the elements of the scene
  */
@@ -316,8 +311,11 @@
 	// Draw all the various elements
 	drawElements();
 
+	_action.set();
+	const char *sStatusText = _action.statusText();
+
 	// Handle display of any status text
-	if (_statusText[0]) {
+	if (sStatusText[0]) {
 		// Text colors are inverted in Dragonsphere
 		if (_vm->getGameType() == GType_DragonSphere)
 			_vm->_font->setColors(_vm->_palette->BLACK, _vm->_palette->WHITE, _vm->_palette->BLACK);
@@ -325,7 +323,7 @@
 			_vm->_font->setColors(_vm->_palette->WHITE, _vm->_palette->BLACK, _vm->_palette->BLACK);
 
 		_vm->_font->setFont(FONT_MAIN_MADS);
-		_vm->_font->writeString(this, _statusText, (width() - _vm->_font->getWidth(_statusText)) / 2, 142, 0);
+		_vm->_font->writeString(this, sStatusText, (width() - _vm->_font->getWidth(sStatusText)) / 2, 142, 0);
 	}
 
 	//***DEBUG***
@@ -476,16 +474,22 @@
 
 void MadsAction::clear() {
 	_actionMode = ACTMODE_NONE;
+	_actionMode2 = ACTMODE2_0;
+	_word_86F42 = 0;
+	_word_86F4E = 0;
 	_articleNumber = 0;
 	_lookFlag = false;
+	_word_86F4A = 0;
 	_statusText[0] = '\0';
 	_selectedRow = -1;
 	_currentHotspot = -1;
+	_word_86F3A = -1;
+	_word_86F4C = -1;
 	//word_86F3A/word_86F4C
 	_currentAction = kVerbNone;
 	_objectNameId = -1;
 	_objectDescId = -1;
-	//word_83334
+	_word_83334 = -1;
 }
 
 void MadsAction::appendVocab(int vocabId, bool capitalise) {
@@ -499,6 +503,7 @@
 }
 
 void MadsAction::set() {
+	int hotspotCount = _madsVm->scene()->getSceneResources().hotspotCount;
 	bool flag = false;
 	_currentAction = -1;
 	_objectNameId = -1;
@@ -562,14 +567,13 @@
 			if (_currentHotspot >= 0) {
 				if (_selectedRow < 0) {
 					int verbId;
-					int hotspotCount = _madsVm->scene()->getSceneResources().hotspotCount;
 
 					if (_currentHotspot < hotspotCount) {
 						// Get the verb Id from the hotspot
 						verbId = (*_madsVm->scene()->getSceneResources().hotspots)[_currentHotspot].getVerbID();
 					} else {
 						// Get the verb Id from the scene object
-						verbId = 0;//Scene_object[_currentHotspot - _hotspotCount].verbId;
+						verbId = (*_madsVm->scene()->getSceneResources().props)[_currentHotspot - hotspotCount].getVerbID();
 					}
 
 					if (verbId > 0) {
@@ -583,12 +587,58 @@
 					}
 				}
 
-				//loc_21CE2
+				if ((_actionMode2 == ACTMODE2_2) || (_actionMode2 == ACTMODE2_5)) {
+					// Get name from given inventory object
+					int objectId = _madsVm->scene()->getInterface()->getInventoryObject(_currentHotspot);
+					_objectNameId = _madsVm->globals()->getObject(objectId)->descId;
+				} else if (_currentHotspot < hotspotCount) {
+					// Get name from scene hotspot
+					_objectNameId = (*_madsVm->scene()->getSceneResources().hotspots)[_currentHotspot].getVocabID();
+				} else {
+					// Get name from temporary scene hotspot
+					_objectNameId = (*_madsVm->scene()->getSceneResources().props)[_currentHotspot].getVocabID();
+				}
 			}
 		}
+
+		if ((_currentHotspot >= 0) && (_articleNumber > 0) && !flag) {
+			if (_articleNumber == -1) {
+				if (_word_86F3A >= 0) {
+					int articleNum = 0;
+
+					if ((_word_86F42 == 2) || (_word_86F42 == 5)) {
+						int objectId = _madsVm->scene()->getInterface()->getInventoryObject(_currentHotspot);
+						articleNum = _madsVm->globals()->getObject(objectId)->article;
+					} else if (_word_86F3A < hotspotCount) {
+						articleNum = (*_madsVm->scene()->getSceneResources().hotspots)[_currentHotspot].getArticle();
+					} else {
+
+					}
+				}
+
+			} else if ((_articleNumber == kVerbLook) || (_vm->getGameType() != GType_RexNebular) ||
+				(strcmp(_madsVm->globals()->getVocab(_objectDescId), fenceStr) != 0)) {
+				// Write out the article
+				strcat(_statusText, englishMADSArticleList[_articleNumber]);
+			} else {
+				// Special case for a 'fence' entry in Rex Nebular
+				strcat(_statusText, overStr);
+			}
+
+			strcat(_statusText, " ");
+		}
+
+		// Append object description if necessary
+		if (_word_86F3A >= 0)
+			appendVocab(_objectDescId);
+
+		// Remove any trailing space character
+		int statusLen = strlen(_statusText);
+		if ((statusLen > 0) && (_statusText[statusLen - 1] == ' '))
+			_statusText[statusLen - 1] = '\0';
 	}
 
-	//word_83334 = -1;
+	_word_83334 = -1;
 }
 
 /*--------------------------------------------------------------------------*/

Modified: scummvm/trunk/engines/m4/mads_scene.h
===================================================================
--- scummvm/trunk/engines/m4/mads_scene.h	2010-03-15 22:24:52 UTC (rev 48265)
+++ scummvm/trunk/engines/m4/mads_scene.h	2010-03-16 08:26:08 UTC (rev 48266)
@@ -124,26 +124,38 @@
 };
 
 enum MadsActionMode {ACTMODE_NONE = 0, ACTMODE_VERB = 1, ACTMODE_OBJECT = 3, ACTMODE_TALK = 6};
+enum MAdsActionMode2 {ACTMODE2_0 = 0, ACTMODE2_2 = 2, ACTMODE2_5 = 5};
 
 class MadsAction {
 private:
 	char _statusText[100];
+
+	void appendVocab(int vocabId, bool capitalise = false);
+public:
 	int _currentHotspot;
 	int _objectNameId;
 	int _objectDescId;
 	int _currentAction;
 	int8 _flags1, _flags2;
 	MadsActionMode _actionMode;
+	MAdsActionMode2 _actionMode2;
 	int _articleNumber;
 	bool _lookFlag;
 	int _selectedRow;
+	// Unknown fields
+	int16 _word_86F3A;
+	int16 _word_86F42;
+	int16 _word_86F4E;
+	int16 _word_86F4A;
+	int16 _word_83334;
+	int16 _word_86F4C;
 
-	void appendVocab(int vocabId, bool capitalise = false);
 public:
 	MadsAction();
 
 	void clear();
 	void set();
+	const char *statusText() const { return _statusText; }
 };
 
 typedef Common::Array<SpriteAsset *> SpriteAssetArray;
@@ -155,7 +167,7 @@
 private:
 	MadsEngine *_vm;
 	MadsSceneResources _sceneResources;
-	char _statusText[100];
+	MadsAction _action;
 
 	MadsSceneLogic _sceneLogic;
 	SpriteAsset *_playerSprites;
@@ -187,7 +199,6 @@
 	virtual void leftClick(int x, int y);
 	virtual void rightClick(int x, int y);
 	virtual void setAction(int action, int objectId = -1);
-	virtual void setStatusText(const char *text);
 	virtual void update();
 
 	int loadSceneSpriteSet(const char *setName);
@@ -196,6 +207,7 @@
 
 	MadsInterfaceView *getInterface() { return (MadsInterfaceView *)_interfaceSurface; };
 	MadsSceneResources &getSceneResources() { return _sceneResources; };
+	void setStatusText(const char *text) {};//***DEPRECATED***
 };
 
 } // End of namespace M4

Modified: scummvm/trunk/engines/m4/mads_views.h
===================================================================
--- scummvm/trunk/engines/m4/mads_views.h	2010-03-15 22:24:52 UTC (rev 48265)
+++ scummvm/trunk/engines/m4/mads_views.h	2010-03-16 08:26:08 UTC (rev 48266)
@@ -77,6 +77,7 @@
 	virtual void setSelectedObject(int objectNumber);
 	virtual void addObjectToInventory(int objectNumber);
 	int getSelectedObject() { return _selectedObject; }
+	int getInventoryObject(int objectIndex) { return _inventoryList[objectIndex]; }
 
 	void onRefresh(RectList *rects, M4Surface *destSurface);
 	bool onEvent(M4EventType eventType, int32 param1, int x, int y, bool &captureEvents);

Modified: scummvm/trunk/engines/m4/scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/scene.cpp	2010-03-15 22:24:52 UTC (rev 48265)
+++ scummvm/trunk/engines/m4/scene.cpp	2010-03-16 08:26:08 UTC (rev 48266)
@@ -44,7 +44,6 @@
 	_screenType = VIEWID_SCENE;
 
 	_sceneResources->hotspots = new HotSpotList();
-	_sceneResources->parallax = new HotSpotList();
 	_sceneResources->props = new HotSpotList();
 	_backgroundSurface = new M4Surface();
 	_walkSurface = new M4Surface();
@@ -124,22 +123,17 @@
 void Scene::showHotSpots() {
 	int i = 0;
 	HotSpot *currentHotSpot;
+
 	// hotspots (green)
 	for (i = 0; i < _sceneResources->hotspotCount; i++) {
 		currentHotSpot = _sceneResources->hotspots->get(i);
 		_backgroundSurface->frameRect(currentHotSpot->getRect(), _vm->_palette->GREEN);
 	}
-	if (_vm->isM4()) {
-		// parallax (yellow)
-		for (i = 0; i < _sceneResources->parallaxCount; i++) {
-			currentHotSpot = _sceneResources->parallax->get(i);
-			_backgroundSurface->frameRect(currentHotSpot->getRect(), _vm->_palette->YELLOW);
-		}
-		// props (red)
-		for (i = 0; i < _sceneResources->propsCount; i++) {
-			currentHotSpot = _sceneResources->props->get(i);
-			_backgroundSurface->frameRect(currentHotSpot->getRect(), _vm->_palette->RED);
-		}
+
+	// props (red)
+	for (i = 0; i < _sceneResources->propsCount; i++) {
+		currentHotSpot = _sceneResources->props->get(i);
+		_backgroundSurface->frameRect(currentHotSpot->getRect(), _vm->_palette->RED);
 	}
 }
 

Modified: scummvm/trunk/engines/m4/scene.h
===================================================================
--- scummvm/trunk/engines/m4/scene.h	2010-03-15 22:24:52 UTC (rev 48265)
+++ scummvm/trunk/engines/m4/scene.h	2010-03-16 08:26:08 UTC (rev 48266)
@@ -64,8 +64,6 @@
 	char pictureBase[MAX_CHK_FILENAME_SIZE];
 	int32 hotspotCount;
 	HotSpotList *hotspots;
-	int32 parallaxCount;
-	HotSpotList *parallax;
 	int32 propsCount;
 	HotSpotList *props;
 	int32 frontY, backY;
@@ -103,13 +101,12 @@
 	virtual void leftClick(int x, int y) = 0;
 	virtual void rightClick(int x, int y) = 0;
 	virtual void setAction(int action, int objectId = -1) = 0;
-	virtual void setStatusText(const char *text) = 0;
 	virtual void update() = 0;
+	virtual void showHotSpots();
 
 	// TODO: perhaps move playIntro() someplace else?
 	void playIntro();
 	void showSprites();
-	void showHotSpots();
 	void showCodes();
 	int getCurrentScene() { return _currentScene; }
 	M4Surface *getBackgroundSurface() const { return _backgroundSurface; }

Modified: scummvm/trunk/engines/m4/staticres.cpp
===================================================================
--- scummvm/trunk/engines/m4/staticres.cpp	2010-03-15 22:24:52 UTC (rev 48265)
+++ scummvm/trunk/engines/m4/staticres.cpp	2010-03-16 08:26:08 UTC (rev 48266)
@@ -42,6 +42,8 @@
 const char *toStr = "to ";
 const char *useStr = "Use ";
 const char *walkToStr = "Walk to ";
+const char *fenceStr = "fence";
+const char *overStr = "over";
 
 VerbInit verbList[10] = {
 	{kVerbLook, 2, 0},

Modified: scummvm/trunk/engines/m4/staticres.h
===================================================================
--- scummvm/trunk/engines/m4/staticres.h	2010-03-15 22:24:52 UTC (rev 48265)
+++ scummvm/trunk/engines/m4/staticres.h	2010-03-16 08:26:08 UTC (rev 48266)
@@ -40,6 +40,8 @@
 extern const char *toStr;
 extern const char *useStr;
 extern const char *walkToStr;
+extern const char *fenceStr;
+extern const char *overStr;
 
 struct VerbInit {
 	int verb;


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