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

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Sun Feb 28 02:07:25 CET 2010


Revision: 48150
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48150&view=rev
Author:   dreammaster
Date:     2010-02-28 01:07:25 +0000 (Sun, 28 Feb 2010)

Log Message:
-----------
Implemented loading of the Rex Nebular walkable areas

Modified Paths:
--------------
    scummvm/trunk/engines/m4/console.cpp
    scummvm/trunk/engines/m4/scene.cpp
    scummvm/trunk/engines/m4/scene.h

Modified: scummvm/trunk/engines/m4/console.cpp
===================================================================
--- scummvm/trunk/engines/m4/console.cpp	2010-02-27 18:54:21 UTC (rev 48149)
+++ scummvm/trunk/engines/m4/console.cpp	2010-02-28 01:07:25 UTC (rev 48150)
@@ -137,10 +137,7 @@
 }
 
 bool Console::cmdShowCodes(int argc, const char **argv) {
-	if (_vm->getGameType() != GType_RexNebular)
-		_vm->_scene->showCodes();
-	else
-		DebugPrintf("Pathfinding codes not done yet for Rex Nebular");
+	_vm->_scene->showCodes();
 	return false;
 }
 

Modified: scummvm/trunk/engines/m4/scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/scene.cpp	2010-02-27 18:54:21 UTC (rev 48149)
+++ scummvm/trunk/engines/m4/scene.cpp	2010-02-28 01:07:25 UTC (rev 48150)
@@ -46,12 +46,12 @@
 	_sceneResources.parallax = new HotSpotList();
 	_sceneResources.props = new HotSpotList();
 	_backgroundSurface = new M4Surface();
-	_codeSurface = new M4Surface();
+	_walkSurface = new M4Surface();
 	_palData = NULL;
 	_interfacePal = NULL;
 	_interfaceSurface = NULL;
 	_inverseColorTable = NULL;
-	_vm->_rails->setCodeSurface(_codeSurface);
+	_vm->_rails->setCodeSurface(_walkSurface);
 }
 
 Scene::~Scene() {
@@ -250,24 +250,28 @@
 	}
 }
 
-// Test function, shows all scene codes
+/**
+ * Debug function that shows the walkable areas by copying them over the current background surface
+ */
 void Scene::showCodes() {
-	uint8 *pixelData = _codeSurface->getBasePtr(0, 0);
-	for (int i = 0; i < _codeSurface->width() * _codeSurface->height(); i++)
-		if (pixelData[i] & 0x10)
-			pixelData[i] = 0xFF;
-		else
-			pixelData[i] = 0;
+	if (_vm->isM4()) {
+		// Show the walk areas for the M4 engine in black and white
+		const byte *srcP = (const byte *)_walkSurface->getBasePtr(0, 0);
+		byte *destP = _backgroundSurface->getBasePtr(0, 0);
+		
+		for (int i = 0; i < _walkSurface->width() * _walkSurface->height(); i++)
+			destP[i] = (srcP[i] & 0x10) ? 0xFF : 0;
 
-	byte colors[256 * 4];
-	memset(colors, 0, sizeof(colors));
-	colors[255 * 4 + 0] = 255;
-	colors[255 * 4 + 1] = 255;
-	colors[255 * 4 + 2] = 255;
-	_vm->_palette->setPalette(colors, 0, 256);
-
-	_backgroundSurface->copyFrom(_codeSurface, Common::Rect(0, 0, 640, 480), 0, 0);
-	//_system->copyRectToScreen(codes->getBasePtr(0, 0), codes->w, 0, 0, codes->w, codes->h);
+		byte colors[256 * 4];
+		memset(colors, 0, sizeof(colors));
+		colors[255 * 4 + 0] = 255;
+		colors[255 * 4 + 1] = 255;
+		colors[255 * 4 + 2] = 255;
+		_vm->_palette->setPalette(colors, 0, 256);
+	} else {
+		// For MADS, simply copy the walk data to the background, in whatever current palette is active
+		_walkSurface->copyTo(_backgroundSurface);
+	}
 }
 
 void Scene::playIntro() {
@@ -472,7 +476,7 @@
 
 	sprintf(filename, "%i.cod", sceneNumber);
 	sceneS = _vm->res()->openFile(filename);
-	_codeSurface->loadCodesM4(sceneS);
+	_walkSurface->loadCodesM4(sceneS);
 	_vm->res()->toss(filename);
 }
 
@@ -603,9 +607,12 @@
 /**
  * Secondary scene loading code
  */
-void MadsScene::loadScene2(int sceneNumber, const char *aaName) {
+void MadsScene::loadScene2(const char *aaName) {
+	// Load up the properties for the scene
+	_sceneInfo.load(_currentScene);
 
-	_sceneInfo.load(sceneNumber);
+	// Load scene walk paths
+	loadSceneCodes(_currentScene);
 }
 
 /**
@@ -645,9 +652,6 @@
 	// TODO: set walker scaling
 	// TODO: destroy woodscript buffer
 
-	// Load scene walk path file (*.COD/*.WW?)
-	loadSceneCodes(_currentScene);
-
 	// Load inverse color table file (*.IPL)
 	loadSceneInverseColorTable(_currentScene);
 }
@@ -670,7 +674,7 @@
 	_vm->globals()->addVisitedScene(sceneNumber);
 
 	// Secondary scene load routine
-	loadScene2(sceneNumber, "*I0.AA");
+	loadScene2("*I0.AA");
 
 	// Do any scene specific setup
 	_sceneLogic.enterScene();
@@ -696,7 +700,7 @@
 	_sceneSprites.clear();
 
 	delete _backgroundSurface;
-	delete _codeSurface;
+	delete _walkSurface;
 
 	Scene::leaveScene();
 }
@@ -714,10 +718,17 @@
 		sprintf(filename, "rm%i.ww%i", sceneNumber, index);
 		MadsPack walkData(filename, _vm);
 		sceneS = walkData.getItemStream(0);
-		_codeSurface->loadCodesMads(sceneS);
+		_walkSurface->loadCodesMads(sceneS);
 		_vm->res()->toss(filename);
 	} else if (_vm->getGameType() == GType_RexNebular) {
-		// TODO
+		// For Rex Nebular, the walk areas are part of the scene info
+		byte *destP = _walkSurface->getBasePtr(0, 0);
+		const byte *srcP = _sceneInfo.walkData;
+		byte runLength;
+		while ((runLength = *srcP++) != 0) {
+			Common::set_to(destP, destP + runLength, *srcP++);
+			destP += runLength;
+		}
 	}
 }
 
@@ -919,6 +930,8 @@
 	const char *sceneInfoStr = MADSResourceManager::getResourceName(RESPREFIX_RM, sceneId, ".DAT");
 	Common::SeekableReadStream *rawStream = _vm->_resourceManager->get(sceneInfoStr);
 	MadsPack sceneInfo(rawStream);
+
+	// Basic scene info
 	Common::SeekableReadStream *stream = sceneInfo.getItemStream(0);
 
 	int resSceneId = stream->readUint16LE();
@@ -940,6 +953,15 @@
 		objects[i].load(stream);
 	}
 
+	// For Rex Nebular, read in the scene's compressed walk surface information
+	if (_vm->getGameType() == GType_RexNebular) {
+		delete walkData;
+
+		stream = sceneInfo.getItemStream(1);
+		walkData = (byte *)malloc(stream->size());
+		stream->read(walkData, stream->size());
+	}
+
 	_vm->_resourceManager->toss(sceneInfoStr);
 }
 

Modified: scummvm/trunk/engines/m4/scene.h
===================================================================
--- scummvm/trunk/engines/m4/scene.h	2010-02-27 18:54:21 UTC (rev 48149)
+++ scummvm/trunk/engines/m4/scene.h	2010-02-28 01:07:25 UTC (rev 48150)
@@ -94,7 +94,7 @@
 	int _previousScene;
 	GameInterfaceView *_interfaceSurface;
 	M4Surface *_backgroundSurface;
-	M4Surface *_codeSurface;
+	M4Surface *_walkSurface;
 	RGBList *_palData;
 	RGBList *_interfacePal;
 	SceneResources _sceneResources;
@@ -195,7 +195,12 @@
 
 	int objectCount;
 	MadsObject objects[32];
+	
+	int walkSize;
+	byte *walkData;
 
+	MadsSceneInfo() { walkSize = 0; walkData = NULL; }
+	~MadsSceneInfo() { delete walkData; }
 	void load(int sceneId);	
 };
 
@@ -221,7 +226,7 @@
 	int _spriteSlotsStart;
 
 	void drawElements();
-	void loadScene2(int sceneNumber, const char *aaName);
+	void loadScene2(const char *aaName);
 	void loadSceneTemporary();
 public:
 	char _aaName[100];


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