[Scummvm-cvs-logs] CVS: scummvm/sword1 logic.h,1.2,1.3 router.cpp,1.2,1.3 router.h,1.1,1.2 screen.cpp,1.4,1.5 screen.h,1.1,1.2 sword1.cpp,1.2,1.3

Robert G?ffringmann lavosspawn at users.sourceforge.net
Tue Dec 16 10:24:02 CET 2003


Update of /cvsroot/scummvm/scummvm/sword1
In directory sc8-pr-cvs1:/tmp/cvs-serv21382/sword1

Modified Files:
	logic.h router.cpp router.h screen.cpp screen.h sword1.cpp 
Log Message:
copied the SwordRouter from the original BS1 sources.
It doesn't fit to our coding guidelines but at least it's working, so please bear with it for now. :)

Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/logic.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- logic.h	16 Dec 2003 09:43:08 -0000	1.2
+++ logic.h	16 Dec 2003 18:23:15 -0000	1.3
@@ -50,7 +50,6 @@
 	void engine(void);
 	void updateScreenParams(void);
 	void runMouseScript(BsObject *cpt, int32 scriptId);
-	SwordRouter *giveRouter(void) { return _router; }; // for router debugging
 
 	static uint32 _scriptVars[NUM_SCRIPT_VARS];
 private:

Index: router.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/router.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- router.cpp	16 Dec 2003 09:43:08 -0000	1.2
+++ router.cpp	16 Dec 2003 18:23:15 -0000	1.3
@@ -1,5 +1,5 @@
 /* ScummVM - Scumm Interpreter
- * Copyright (C) Revolution Software Ltd.
+ * Copyright (C) 2003 The ScummVM project
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -21,625 +21,298 @@
 
 #include "stdafx.h"
 #include "router.h"
-#include "util.h"
[...3786 lines suppressed...]
+	else if ( (abs(deltaY) * DIAGONALX / 2) > (abs(deltaX) * DIAGONALY ) )
 		slope = 2;// its vertical
 	else
 		slope = 1;// its diagonal
@@ -1965,4 +2645,15 @@
 			tar_dir = 7;
 	}
 	return tar_dir;
+}
+
+void SwordRouter::resetExtraData(void) {
+	_numExtraBars = _numExtraNodes = 0;
+}
+
+void SwordRouter::setPlayerTarget(int32 x, int32 y, int32 dir, int32 stance) {
+	_playerTargetX = x;
+	_playerTargetY = y;
+	_playerTargetDir = dir;
+	_playerTargetStance = stance;
 }

Index: router.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/router.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- router.h	16 Dec 2003 02:09:25 -0000	1.1
+++ router.h	16 Dec 2003 18:23:15 -0000	1.2
@@ -79,7 +79,7 @@
 	int32	num;
 };
 
-struct FrameInfos {
+/*struct FrameInfos {
 	int32 framesPerStep, framesPerChar;
 	int32 standFrames;
 	int32 slowInFrames, slowOutFrames;
@@ -87,7 +87,7 @@
 	int32 walkFramesLeft, walkFramesRight;
 	uint16 startX, startY, targetX, targetY, targetDir;
 	int32 scaleA, scaleB;
-};
+};*/
 
 #define ROUTE_END_FLAG 255
 #define NO_DIRECTIONS 8
@@ -97,20 +97,21 @@
 
 class ObjectMan;
 class ResMan;
+class SwordScreen;
 
 class SwordRouter {
 public:
 	SwordRouter(ObjectMan *pObjMan, ResMan *pResMan);
 	~SwordRouter(void);
-	int routeFinder(int32 id, BsObject *mega, int32 x, int32 y, int32 dir);
+	int32 routeFinder(int32 id, BsObject *mega, int32 x, int32 y, int32 dir);
 	int whatTarget(int32 startX, int32 startY, int32 destX, int32 destY);
 	void setPlayerTarget(int32 x, int32 y, int32 dir, int32 stance);
 	void resetExtraData(void);
 
 	// these should be private but are read by SwordScreen for debugging:
-	int32 _nBars, _nNodes;
-	BarData _bars[O_GRID_SIZE + EXTRA_GRID_SIZE];
-	NodeData _node[O_GRID_SIZE + EXTRA_GRID_SIZE];
+	BarData   bars[O_GRID_SIZE+EXTRA_GRID_SIZE];
+	NodeData  node[O_GRID_SIZE+EXTRA_GRID_SIZE];
+	int32 nbars, nnodes;
 private:
 	// when the player collides with another mega, we'll receive a ReRouteRequest here.
 	// that's why we need to remember the player's target coordinates
@@ -122,40 +123,63 @@
 	ObjectMan *_objMan;
 	ResMan *_resMan;
 
-	uint8 _nWalkFrames, _nTurnFrames;
+	/*uint8 _nWalkFrames, _nTurnFrames;
 	int32 _dx[NO_DIRECTIONS + MAX_FRAMES_PER_CHAR];
 	int32 _dy[NO_DIRECTIONS + MAX_FRAMES_PER_CHAR];
 	int32 _modX[NO_DIRECTIONS];
 	int32 _modY[NO_DIRECTIONS];
-	int32 _diagonalx, _diagonaly;
+	int32 _diagonalx, _diagonaly;*/
 
-	RouteData _route[O_ROUTE_SIZE];
+	int32 startX, startY, startDir;
+	int32 targetX, targetY, targetDir;
+	int32 scaleA, scaleB;
+	int32 megaId;
+
+	/*RouteData _route[O_ROUTE_SIZE];
 	//int32 _routeLength;
 	PathData  _smoothPath[O_ROUTE_SIZE];
-	PathData  _modularPath[O_ROUTE_SIZE];
+	PathData  _modularPath[O_ROUTE_SIZE];*/
+	RouteData			route[O_ROUTE_SIZE];
+	PathData			smoothPath[O_ROUTE_SIZE];
+	PathData			modularPath[O_ROUTE_SIZE];
+	int32   			routeLength;
+
+	int32		framesPerStep, framesPerChar;
+	uint8		nWalkFrames, nTurnFrames;
+	int32		dx[NO_DIRECTIONS + MAX_FRAMES_PER_CHAR];
+	int32		dy[NO_DIRECTIONS + MAX_FRAMES_PER_CHAR];
+	int32		modX[NO_DIRECTIONS];
+	int32		modY[NO_DIRECTIONS];
+	int32		diagonalx, diagonaly;
+	int32		standFrames;
+	int32		turnFramesLeft, turnFramesRight;
+	int32		walkFramesLeft, walkFramesRight; // left/right walking turn
+	int32		slowInFrames, slowOutFrames;
 
 
-	void loadWalkResources(int32 megaId, BsObject *mega, int32 x, int32 y, int32 targetDir);
-	int getRoute(void);
-	int checkTarget(int16 x, int16 y);
+	int32 LoadWalkResources(BsObject *mega, int32 x, int32 y, int32 targetDir);
+	int32 GetRoute(void);
+	int32 CheckTarget(int32 x, int32 y);
 	
-	int scan(int32 level);	
-	int newCheck(int32 status, int16 x1, int16 x2, int16 y1, int16 y2);
-	int check(int16 x1, int16 y1, int16 x2, int16 y2);
-	int horizCheck(int16 x1, int16 y, int16 x2);
-	int vertCheck(int16 x, int16 y1, int16 y2);
-	int lineCheck(int16 x1, int16 y1, int16 x2, int16 y2);
+	int32 Scan(int32 level);	
+	int32 NewCheck(int32 status, int32 x1, int32 x2, int32 y1, int32 y2);
+	int32 Check(int32 x1, int32 y1, int32 x2, int32 y2);
+	int32 HorizCheck(int32 x1, int32 y, int32 x2);
+	int32 VertCheck(int32 x, int32 y1, int32 y2);
+	int32 LineCheck(int32 x1, int32 y1, int32 x2, int32 y2);
 
-	int32 extractRoute(int32 targetDir);
+	void ExtractRoute();
 
-	void slidyPath(int32 scaleA, int32 scaleB, uint16 targetDir);
-	void slidyWalkAnimator(WalkData *walkAnim, FrameInfos *frInfo, int32 megaId);
+	int32 SlidyPath();
+	void SlidyWalkAnimator(WalkData *walkAnim);
 	
-	int32 smoothestPath(uint16 startX, uint16 startY, uint16 startDir, int32 routeLength);
-	int32 smoothCheck(int32 best, int32 p, int32 dirS, int32 dirD);
+	int32 SmoothestPath();
+	int32 SmoothCheck(int32 best, int32 p, int32 dirS, int32 dirD);
 
-    int32 solidPath(int32 scaleA, int32 scaleB);
-	int32 solidWalkAnimator(WalkData *walkAnim, FrameInfos *frInfo, int32 megaId);
+    int32 SolidPath();
+	int32 SolidWalkAnimator(WalkData *walkAnim);
+	void RouteLine(int32 x1,int32 y1,int32 x2,int32 y2 ,int32 colour);
+	void BresenhamLine(int32 x1,int32 y1,int32 x2,int32 y2, uint8 *screen, int32 width, int32 height, int32 colour);
 };
 
 #endif //BSROUTER_H

Index: screen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/screen.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- screen.cpp	16 Dec 2003 09:43:08 -0000	1.4
+++ screen.cpp	16 Dec 2003 18:23:15 -0000	1.5
@@ -285,7 +285,7 @@
 	_targetPalette[0] = _targetPalette[1] = _targetPalette[2] = 0;
 	_system->set_palette(_targetPalette, 0, 256);	
 	_resMan->resClose(_roomDefTable[_currentScreen].palettes[0]);
-	_resMan->resClose(_roomDefTable[_currentScreen].palettes[1]);
+	//_resMan->resClose(_roomDefTable[_currentScreen].palettes[1]);
 }
 
 void SwordScreen::quitScreen(void) {
@@ -861,24 +861,5 @@
 		bsubline_4(x1, y1, x2, y2);
     } else {
 		bsubline_3(x1, y1, x2, y2);
-    }	
-
-}
-
-void SwordScreen::showBarsAndNodes(SwordRouter *router) {
-	for (uint16 cnt = 0; cnt < router->_nBars; cnt++) {
-		drawLine(router->_bars[cnt].x1 - 128, router->_bars[cnt].y1 - 128, router->_bars[cnt].x2 - 128, router->_bars[cnt].y2 - 128);
-	}
-	if (!router->_nNodes)
-		return;
-	for (uint16 cnt = 0; cnt <= router->_nNodes; cnt++) {
-		uint16 y = router->_node[cnt].y - 128;
-		uint16 x = router->_node[cnt].x - 128;
-		vline(x, y - 2, y + 2);
-		hline(x - 2, x + 2, y);
-		if (router->_node[cnt].dist != 9999) {
-			drawLine(x, y, router->_node[router->_node[cnt].prev].x - 128, router->_node[router->_node[cnt].prev].y - 128);
-		}
-	}
+    }
 }
-

Index: screen.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/screen.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- screen.h	16 Dec 2003 02:09:25 -0000	1.1
+++ screen.h	16 Dec 2003 18:23:15 -0000	1.2
@@ -19,8 +19,6 @@
  *
  */
 
-// vertical_mask from layers.c belongs here, as well.
-
 #ifndef BSSCREEN_H
 #define BSSCREEN_H
 
@@ -93,8 +91,6 @@
 	void fnSetParallax(uint32 screen, uint32 resId);
 	void fnFlash(uint8 color);
 	void fnBorder(uint8 color);
-
-	void showBarsAndNodes(SwordRouter *router);
 
 private:
 	// for router debugging

Index: sword1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sword1.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- sword1.cpp	16 Dec 2003 10:08:27 -0000	1.2
+++ sword1.cpp	16 Dec 2003 18:23:15 -0000	1.3
@@ -218,7 +218,6 @@
 			}*/
 
 			_sound->engine();
-			_screen->showBarsAndNodes(_logic->giveRouter());
 			_screen->updateScreen();
 		//-
 			_menu->refresh(MENU_TOP);





More information about the Scummvm-git-logs mailing list