[Scummvm-cvs-logs] CVS: scummvm/sky logic.cpp,1.14,1.15 logic.h,1.6,1.7 autoroute.cpp,1.4,1.5

Oliver Kiehl olki at users.sourceforge.net
Sun Apr 27 15:16:09 CEST 2003


Update of /cvsroot/scummvm/scummvm/sky
In directory sc8-pr-cvs1:/tmp/cvs-serv2316

Modified Files:
	logic.cpp logic.h autoroute.cpp 
Log Message:
fixed autoroute a bit (still doesn't work correctly but at least it doesn't
segfault) and linked it to SkyLogic


Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/logic.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- logic.cpp	26 Apr 2003 20:06:50 -0000	1.14
+++ logic.cpp	27 Apr 2003 22:15:35 -0000	1.15
@@ -47,9 +47,10 @@
 	&SkyLogic::simpleAnim,	 // 16 Module anim without x,y's
 };
 
-SkyLogic::SkyLogic(SkyDisk *skyDisk, SkyGrid *grid) {
+SkyLogic::SkyLogic(SkyDisk *skyDisk, SkyGrid *skyGrid) {
 	_skyDisk = skyDisk;
-	_grid = grid;
+	_skyGrid = skyGrid;
+	_skyAutoRoute = new SkyAutoRoute(_skyGrid);
 
 	for (uint i = 0; i < sizeof(_moduleList)/sizeof(uint16*); i++)
 		_moduleList[i] = 0;
@@ -61,6 +62,9 @@
 void SkyLogic::engine() {
 	Compact *compact2 = SkyState::fetchCompact(141); // logic list
 
+	printf("XXXXXXX: loading grids\n");
+	_skyGrid->loadGrids();
+
 	while (compact2->logic) { // 0 means end of list
 		if (compact2->logic == 0xffff) {
 			// Change logic data address
@@ -78,13 +82,13 @@
 		// ok, here we process the logic bit system
 
 		if (_compact->status & (1 << 7))
-			_grid->removeObjectFromWalk(_compact);
+			_skyGrid->removeObjectFromWalk(_compact);
 
 		SkyDebug::logic(_compact->logic);
 		(this->*logicTable[_compact->logic]) ();
 
 		if (_compact->status & (1 << 7))
-			_grid->objectToWalk(_compact);
+			_skyGrid->objectToWalk(_compact);
 
 		// a sync sent to the compact is available for one cycle
 		// only. that cycle has just ended so remove the sync.
@@ -123,12 +127,8 @@
 }
 
 void SkyLogic::autoRoute() {
-	error("autoRoute unimplemented");
-	uint16 *route;
-	route = 0;
-	
-	warning("autoRoute unimplemented");
-	uint32 ret = 0; // = autoRoute(route);
+	uint16 *route = 0;
+	uint16 ret = _skyAutoRoute->autoRoute(_compact, &route);
 
 	_compact->logic = L_SCRIPT; // continue the script
 

Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/logic.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- logic.h	26 Apr 2003 14:00:59 -0000	1.6
+++ logic.h	27 Apr 2003 22:15:35 -0000	1.7
@@ -25,10 +25,11 @@
 #include "sky/sky.h"
 #include "sky/disk.h"
 #include "sky/grid.h"
+#include "sky/autoroute.h"
 
 class SkyLogic {
 public:
-	SkyLogic(SkyDisk *skyDisk, SkyGrid *grid);
+	SkyLogic(SkyDisk *skyDisk, SkyGrid *skyGrid);
 	void engine();
 
 	void lreturn();
@@ -181,7 +182,8 @@
 	uint32 _scriptVariables[838];
 
 	SkyDisk *_skyDisk;
-	SkyGrid *_grid;
+	SkyGrid *_skyGrid;
+	SkyAutoRoute *_skyAutoRoute;
 };
 
 #endif

Index: autoroute.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/autoroute.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- autoroute.cpp	27 Apr 2003 16:36:24 -0000	1.4
+++ autoroute.cpp	27 Apr 2003 22:15:35 -0000	1.5
@@ -41,7 +41,7 @@
 uint16 SkyAutoRoute::checkBlock(uint16 *blockPos) {
 
 	uint16 fieldVal, retVal = 0;
-    fieldVal = blockPos[1]; // field to the right
+	fieldVal = blockPos[1]; // field to the right
 	if ((!(fieldVal & 0x8000)) && (fieldVal != 0)) retVal = fieldVal;
 	fieldVal = (blockPos - 1)[0]; // field to the left
 	if ((!(fieldVal & 0x8000)) && (fieldVal != 0) && (fieldVal > retVal)) retVal = fieldVal;
@@ -63,8 +63,8 @@
 	
 	uint8 stretch1, stretch2; // bl / bh
 	stretch1 = 0;
-	//FIXME: don't know if this is uint16 or uint32 (endian problem)
-	stretch2 = (uint8)*(uint32 *)SkyCompact::getCompactElem(cpt, C_GRID_WIDTH + cpt->extCompact->megaSet);
+	MegaSet *mega = (MegaSet *)SkyCompact::getCompactElem(cpt, C_GRID_WIDTH + cpt->extCompact->megaSet);
+	stretch2 = (uint8)(mega->gridWidth & 0xff);
 
 	uint16 cnt;
 	//First clear the bottom line and right hand edge of next line
@@ -113,7 +113,7 @@
 			stretch1 = 0; // clear stretch factor
 			gridCntY--;
 		}
-	} while(gridCntX || gridCntY);
+	} while(gridCntY);
 	for (cnt = 0; cnt < ROUTE_GRID_WIDTH-1; cnt++) 
 		_routeGrid[cnt] = 0; // clear top line (right hand edge already done
 	
@@ -193,12 +193,12 @@
 	//postBlockX <<= 1; postBlockY <<= 1; // multiply by 2
 	uint16 *routeDestCalc;
 	routeDestCalc = postBlockY * ROUTE_GRID_WIDTH + postBlockX + _routeGrid;
-    routeDestCalc += ROUTE_GRID_WIDTH+1; // skip blank edges (what?)
+	routeDestCalc += ROUTE_GRID_WIDTH+1; // skip blank edges (what?)
 
 	//initBlockX <<= 1; initBlockY <<= 1;
 	uint16 *routeSrcCalc;
 	routeSrcCalc = initBlockY * ROUTE_GRID_WIDTH + initBlockX + _routeGrid;
-    routeSrcCalc += ROUTE_GRID_WIDTH+1; // skip blank edges
+	routeSrcCalc += ROUTE_GRID_WIDTH+1; // skip blank edges
 	routeSrcCalc[0] = 1; //start this one off
 	// means: mark the block we start from as accessible
 
@@ -225,12 +225,12 @@
 		cnty = numLines;
 		uint16 *yPushedSrc = routeSrcCalc;
 		do { // wallow_x
-            cntx = numCols;
+			cntx = numCols;
 			uint16 *xPushedSrc = routeSrcCalc;
 			do { // wallow
 				if (!routeSrcCalc[0]) {
 					// block wasn't yet done
-                    blockRet = checkBlock(routeSrcCalc);
+					blockRet = checkBlock(routeSrcCalc);
 					if (blockRet > 0) {
 						// this block is accessible
 						routeSrcCalc[0] = blockRet;
@@ -247,7 +247,7 @@
 
 		foundRoute = false;
 		if (!routeDestCalc[0]) {
-            // we have done a section, see if we want to shift backwards (what?)
+			// we have done a section, see if we want to shift backwards (what?)
 			if (numLines < ROUTE_GRID_HEIGHT-4) {
 				routeSrcCalc -= directionY;
 				numLines++;
@@ -258,12 +258,12 @@
 			}
 		} else foundRoute = true;			
 	} while ((!foundRoute) && gridChanged);
-	
+
 	if (!routeDestCalc[0]) {
 		// no route exists from routeSrc to routeDest
 		return 2;
 	}
-    // ok, we know now that it's possible to get from the start position to the desired
+	// ok, we know now that it's possible to get from the start position to the desired
 	// destination. Let's see how.
 	uint16 *saveRoute = routeData+(ROUTE_SPACE >> 1)-1; // route_space is given in bytes so >> 1
 	saveRoute[0] = 0; // route is null terminated
@@ -329,7 +329,7 @@
 			error("AutoRoute:: Can't find way backwards through _routeGrid");
 		}
 	} while (!routeDone);
-    // the route is done. if there was an initial x/y movement tag it onto the start
+	// the route is done. if there was an initial x/y movement tag it onto the start
 	if (initX < 0) {
         saveRoute -= 4;
 		saveRoute[1] = RIGHTY;
@@ -340,7 +340,7 @@
 		saveRoute[0] = (initX+7)&0xFFF8;
 	}
 	// I wonder why initY isn't checked
-    // saveRoute should now point to routeData
+	// saveRoute should now point to routeData
 	if (routeData > saveRoute) error("Autoroute: Internal pointer error! routeData overflow.");
 	*pSaveRoute = saveRoute;
 	return 1;





More information about the Scummvm-git-logs mailing list