[Scummvm-cvs-logs] CVS: scummvm actor.h,1.7,1.8 actor.cpp,1.79,1.80 gfx.cpp,1.95,1.96 object.cpp,1.71,1.72 script.cpp,1.61,1.62 script_v1.cpp,1.113,1.114 script_v2.cpp,1.68,1.69 scumm.h,1.170,1.171 scummvm.cpp,1.162,1.163

Max Horn fingolfin at users.sourceforge.net
Tue Jun 4 16:33:04 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv8075

Modified Files:
	actor.h actor.cpp gfx.cpp object.cpp script.cpp script_v1.cpp 
	script_v2.cpp scumm.h scummvm.cpp 
Log Message:
more Actor class cleanup; renamed unkRoomFunc4 to palManipulate and added an icky, wrong implementation for it - yes this is complete nonsense but I'll try to replace it with the right thing RSN :-)

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/actor.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- actor.h	23 May 2002 21:22:07 -0000	1.7
+++ actor.h	4 Jun 2002 23:32:49 -0000	1.8
@@ -70,7 +70,6 @@
 
 class Actor {
 
-//protected:
 public:
 	int x, y, top, bottom;
 	int elevation;
@@ -131,6 +130,7 @@
 	int updateActorDirection();
 	void setActorDirection(int direction);
 
+	AdjustBoxResult adjustXYToBeInBox(int dstX, int dstY, int pathfrom);
 	void adjustActorPos();	
 	void turnToDirection(int newdir);
 	void walkActor();
@@ -142,8 +142,11 @@
 	
 	void remapActor(int b, int c, int d, int e);
 	void walkActorOld();
+
+	void animateActor(int anim);
 	
 	bool isInCurrentRoom()					{ return room == _vm->_currentRoom; }
+	int getRoom()							{ return room; }
 
 	int getAnimVar(byte var)				{ return animVariable[var]; }
 	void setAnimVar(byte var, int value)	{ animVariable[var] = value; }

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/actor.cpp,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- actor.cpp	3 Jun 2002 21:52:34 -0000	1.79
+++ actor.cpp	4 Jun 2002 23:32:50 -0000	1.80
@@ -452,6 +452,45 @@
 	}
 }
 
+void Actor::animateActor(int anim)
+{
+	int cmd, dir;
+
+	if (_vm->_features & GF_AFTER_V7) {
+
+		if (anim == 0xFF)
+			anim = 2000;
+
+		cmd = anim / 1000;
+		dir = anim % 1000;
+
+	} else {
+
+		cmd = anim >> 2;
+		dir = Scumm::oldDirToNewDir(anim & 3);
+
+		// Convert into old cmd code
+		cmd = 0x3F - cmd + 2;
+
+	}
+
+	switch (cmd) {
+	case 2:
+		stopActorMoving();
+		startAnimActor(standFrame);
+		break;
+	case 3:
+		moving &= ~MF_TURN;
+		setActorDirection(dir);
+		break;
+	case 4:
+		turnToDirection(dir);
+		break;
+	default:
+		startAnimActor(anim);
+	}
+}
+
 void Actor::setActorDirection(int direction)
 {
 	uint aMask;
@@ -499,7 +538,7 @@
 	}
 
 	if (a->visible) {
-		if (_currentRoom == room) {
+		if (a->isInCurrentRoom()) {
 			if (a->moving) {
 				a->startAnimActor(a->standFrame);
 				a->moving = 0;
@@ -509,7 +548,7 @@
 			a->hideActor();
 		}
 	} else {
-		if (_currentRoom == room)
+		if (a->isInCurrentRoom())
 			a->showActor();
 	}
 }
@@ -526,7 +565,7 @@
 	return 0;
 }
 
-AdjustBoxResult Scumm::adjustXYToBeInBox(Actor * a, int dstX, int dstY, int pathfrom)
+AdjustBoxResult Actor::adjustXYToBeInBox(int dstX, int dstY, int pathfrom)
 {
 	AdjustBoxResult abr, tmp;
 	uint threshold;
@@ -535,7 +574,7 @@
 	int firstValidBox, j;
 	byte flags, b;
 
-	if (_features & GF_SMALL_HEADER)
+	if (_vm->_features & GF_SMALL_HEADER)
 		firstValidBox = 0;
 	else
 		firstValidBox = 1;
@@ -544,44 +583,44 @@
 	abr.y = dstY;
 	abr.dist = 0;
 
-	if ((_features & GF_SMALL_HEADER) && getClass(a->number, 22))
+	if ((_vm->_features & GF_SMALL_HEADER) && _vm->getClass(number, 22))
 		return abr;
 
-	if (a && a->ignoreBoxes == 0) {
+	if (ignoreBoxes == 0) {
 		threshold = 30;
 
 		while (1) {
 			iterations++;
 			if (iterations > 1000)
 				return abr;							/* Safety net */
-			box = getNumBoxes() - 1;
+			box = _vm->getNumBoxes() - 1;
 			if (box == 0)
 				return abr;
 
 			best = (uint) 0xFFFF;
 			b = 0;
 
-			if (((_features & GF_SMALL_HEADER) && box)
-					|| !(_features & GF_SMALL_HEADER))
+			if (((_vm->_features & GF_SMALL_HEADER) && box)
+					|| !(_vm->_features & GF_SMALL_HEADER))
 				for (j = box; j >= firstValidBox; j--) {
-					flags = getBoxFlags(j);
-					if (flags & 0x80 && (!(flags & 0x20) || getClass(a->number, 0x1F)))
+					flags = _vm->getBoxFlags(j);
+					if (flags & 0x80 && (!(flags & 0x20) || _vm->getClass(number, 0x1F)))
 						continue;
 
-					if (pathfrom && (getPathToDestBox(pathfrom, j) == -1))
+					if (pathfrom && (_vm->getPathToDestBox(pathfrom, j) == -1))
 						continue;
 
-					if (!inBoxQuickReject(j, dstX, dstY, threshold))
+					if (!_vm->inBoxQuickReject(j, dstX, dstY, threshold))
 						continue;
 
-					if (checkXYInBoxBounds(j, dstX, dstY)) {
+					if (_vm->checkXYInBoxBounds(j, dstX, dstY)) {
 						abr.x = dstX;
 						abr.y = dstY;
 						abr.dist = j;
 						return abr;
 					}
 
-					tmp = getClosestPtOnBox(j, dstX, dstY);
+					tmp = _vm->getClosestPtOnBox(j, dstX, dstY);
 
 					if (tmp.dist >= best)
 						continue;
@@ -612,7 +651,7 @@
 	AdjustBoxResult abr;
 	byte flags;
 
-	abr = _vm->adjustXYToBeInBox(this, x, y, 0);
+	abr = adjustXYToBeInBox(x, y, 0);
 
 	x = abr.x;
 	y = abr.y;
@@ -920,7 +959,7 @@
 		return;
 
 	// Sort actors by position before we draw them (to ensure that actors in
-	// front are drawn after thos behind them).
+	// front are drawn after those "behind" them).
 	ac = actors;
 	cnt = numactors;
 	do {
@@ -1182,7 +1221,7 @@
 {
 	AdjustBoxResult abr;
 
-	abr = _vm->adjustXYToBeInBox(this, destX, destY, walkbox);
+	abr = adjustXYToBeInBox(destX, destY, walkbox);
 
 	if (!isInCurrentRoom()) {
 		x = abr.x;
@@ -1199,7 +1238,7 @@
 		if (_vm->checkXYInBoxBounds(walkdata.destbox, abr.x, abr.y)) {
 			abr.dist = walkdata.destbox;
 		} else {
-			abr = _vm->adjustXYToBeInBox(this, abr.x, abr.y, walkbox);
+			abr = adjustXYToBeInBox(abr.x, abr.y, walkbox);
 		}
 		if (moving && walkdata.destdir == dir
 				&& walkdata.destx == abr.x && walkdata.desty == abr.y)
@@ -1379,4 +1418,33 @@
 	moving &= MF_IN_LEG;
 	moving |= MF_NEW_LEG;
 	goto restart;
+}
+
+void Scumm::resetActorBgs()
+{
+	Actor *a;
+	int i;
+	uint32 onlyActorFlags, bitpos;
+
+	for (i = 0; i < 40; i++) {
+		onlyActorFlags = (gfxUsageBits[_screenStartStrip + i] &= 0x3FFFFFFF);
+		a = getFirstActor();
+		bitpos = 1;
+
+		while (onlyActorFlags) {
+			if (onlyActorFlags & 1 && a->top != 0xFF && a->needBgReset) {
+				gfxUsageBits[_screenStartStrip + i] ^= bitpos;
+
+				if((a->bottom - a->top) >=0)
+					gdi.resetBackground(a->top, a->bottom, i);
+			}
+			bitpos <<= 1;
+			onlyActorFlags >>= 1;
+			a++;
+		}
+	}
+
+	for (i = 1, a = getFirstActor(); ++a, i < NUM_ACTORS; i++) {
+		a->needBgReset = false;
+	}
 }

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gfx.cpp,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -d -r1.95 -r1.96
--- gfx.cpp	3 Jun 2002 21:51:11 -0000	1.95
+++ gfx.cpp	4 Jun 2002 23:32:51 -0000	1.96
@@ -311,8 +311,8 @@
 
 		cd->_follows = a->number;
 
-		if (a->room != _currentRoom) {
-			startScene(a->room, 0, 0);
+		if (!a->isInCurrentRoom()) {
+			startScene(a->getRoom(), 0, 0);
 		}
 
 		ax = abs(a->x - cd->_cur.x);
@@ -332,8 +332,8 @@
 		cd->_mode = CM_FOLLOW_ACTOR;
 		cd->_follows = a->number;
 
-		if (a->room != _currentRoom) {
-			startScene(a->room, 0, 0);
+		if (!a->isInCurrentRoom()) {
+			startScene(a->getRoom(), 0, 0);
 			cd->_mode = CM_FOLLOW_ACTOR;
 			cd->_cur.x = a->x;
 			setCameraAt(cd->_cur.x, 0);
@@ -346,7 +346,7 @@
 			setCameraAt(a->x, 0);
 
 		for (i = 1, a = getFirstActor(); ++a, i < NUM_ACTORS; i++) {
-			if (a->room == _currentRoom)
+			if (a->isInCurrentRoom())
 				a->needRedraw = true;
 		}
 		runHook(0);
@@ -2214,35 +2214,6 @@
 		warning("Unknown screen effect, %d", effect);
 	}
 	_screenEffectFlag = true;
-}
-
-void Scumm::resetActorBgs()
-{
-	Actor *a;
-	int i;
-	uint32 onlyActorFlags, bitpos;
-
-	for (i = 0; i < 40; i++) {
-		onlyActorFlags = (gfxUsageBits[_screenStartStrip + i] &= 0x3FFFFFFF);
-		a = getFirstActor();
-		bitpos = 1;
-
-		while (onlyActorFlags) {
-			if (onlyActorFlags & 1 && a->top != 0xFF && a->needBgReset) {
-				gfxUsageBits[_screenStartStrip + i] ^= bitpos;
-
-				if((a->bottom - a->top) >=0)
-					gdi.resetBackground(a->top, a->bottom, i);
-			}
-			bitpos <<= 1;
-			onlyActorFlags >>= 1;
-			a++;
-		}
-	}
-
-	for (i = 1, a = getFirstActor(); ++a, i < NUM_ACTORS; i++) {
-		a->needBgReset = false;
-	}
 }
 
 void Gdi::resetBackground(int top, int bottom, int strip)

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/object.cpp,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- object.cpp	22 May 2002 13:14:55 -0000	1.71
+++ object.cpp	4 Jun 2002 23:32:52 -0000	1.72
@@ -224,8 +224,8 @@
 	if (b < NUM_ACTORS)
 		actb = derefActorSafe(b, "getObjActToObjActDist(2)");
 
-	if (acta && actb && acta->room == actb->room && acta->room &&
-			acta->room != _currentRoom)
+	if (acta && actb && acta->getRoom() == actb->getRoom() && acta->getRoom() &&
+			!acta->isInCurrentRoom())
 		return 0;
 
 	if (getObjectOrActorXY(a) == -1)
@@ -238,7 +238,7 @@
 		return 0xFF;
 
 	if (acta) {
-		AdjustBoxResult r = adjustXYToBeInBox(acta, _xPos, _yPos, 0);
+		AdjustBoxResult r = acta->adjustXYToBeInBox(_xPos, _yPos, 0);
 		_xPos = r.x;
 		_yPos = r.y;
 	}

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- script.cpp	23 May 2002 21:22:07 -0000	1.61
+++ script.cpp	4 Jun 2002 23:32:52 -0000	1.62
@@ -889,61 +889,11 @@
 
 void Scumm::animateActor(int act, int anim)
 {
-	if (_features & GF_AFTER_V7) {
-		int cmd, dir;
-		Actor *a;
-
-		a = derefActorSafe(act, "animateActor");
-
-		if (anim == 0xFF)
-			anim = 2000;
-
-		cmd = anim / 1000;
-		dir = anim % 1000;
-
-		switch (cmd) {
-		case 2:
-			a->stopActorMoving();
-			a->startAnimActor(a->standFrame);
-			break;
-		case 3:
-			a->moving &= ~MF_TURN;
-			a->setActorDirection(dir);
-			break;
-		case 4:
-			a->turnToDirection(dir);
-			break;
-		default:
-			a->startAnimActor(anim);
-		}
-
-	} else {
-		int dir;
-		Actor *a;
-
-		a = derefActorSafe(act, "animateActor");
-		if (!a)
-			return;
-
-		dir = anim & 3;
-
-		switch (anim >> 2) {
-		case 0x3F:
-			a->stopActorMoving();
-			a->startAnimActor(a->standFrame);
-			break;
-		case 0x3E:
-			a->moving &= ~MF_TURN;
-			a->setActorDirection(oldDirToNewDir(dir));
-			break;
-		case 0x3D:
-			a->turnToDirection(oldDirToNewDir(dir));
-			break;
-		default:
-			a->startAnimActor(anim);
-		}
+	Actor *a = derefActorSafe(act, "animateActor");
+	if (!a)
+		return;
 
-	}
+	a->animateActor(anim);
 }
 
 bool Scumm::isScriptRunning(int script)

Index: script_v1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script_v1.cpp,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -d -r1.113 -r1.114
--- script_v1.cpp	14 May 2002 23:32:34 -0000	1.113
+++ script_v1.cpp	4 Jun 2002 23:32:53 -0000	1.114
@@ -801,7 +801,7 @@
 			a->ignoreBoxes = 1;
 			a->forceClip = 0;
 		FixRoom:
-			if (a->room == _currentRoom)
+			if (a->isInCurrentRoom())
 				putActor(a, a->x, a->y, a->room);
 			break;
 		case 21:										/* followboxes */
@@ -2047,14 +2047,14 @@
 			;
 		warning("roomops:14 load-string(%d,\"%s\") not implemented", a, buf);
 		break;
-	case 15:											/* palmanip? */
+	case 15:											/* palmanip */
 		a = getVarOrDirectByte(0x80);
 		_opcode = fetchScriptByte();
 		b = getVarOrDirectByte(0x80);
 		c = getVarOrDirectByte(0x40);
 		_opcode = fetchScriptByte();
 		d = getVarOrDirectByte(0x80);
-		unkRoomFunc4(b, c, a, d, 1);
+		palManipulate(b, c, a, d, 1);
 		break;
 
 	case 16:			
@@ -2566,7 +2566,7 @@
 	if (!a)
 		return;
 
-	if (a->room != _currentRoom) {
+	if (!a->isInCurrentRoom()) {
 		getVarOrDirectByte(0x40);
 		fetchScriptByte();
 		return;
@@ -2583,7 +2583,7 @@
 	if (!a2)
 		return;
 
-	if (a2->room != _currentRoom) {
+	if (!a2->isInCurrentRoom()) {
 		fetchScriptByte();
 		return;
 	}

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script_v2.cpp,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- script_v2.cpp	25 May 2002 19:40:42 -0000	1.68
+++ script_v2.cpp	4 Jun 2002 23:32:53 -0000	1.69
@@ -1351,7 +1351,7 @@
 		a2 = derefActorSafe(obj, "o6_walkActorToObj(2)");
 		if (!a2)
 			return;
-		if (a2->room != _currentRoom || a->room != _currentRoom)
+		if (!a->isInCurrentRoom() || !a->isInCurrentRoom())
 			return;
 		if (dist == 0) {
 			dist = a2->scalex * a2->width / 0xFF;
@@ -1883,7 +1883,7 @@
 		c = pop();
 		b = pop();
 		a = pop();
-		unkRoomFunc4(a, b, c, d, 1);
+		palManipulate(a, b, c, d, 1);
 		break;
 
 	case 187:										/* color cycle delay */
@@ -2001,7 +2001,7 @@
 		else
 			a->forceClip = 0;
 	FixRooms:;
-		if (a->room == _currentRoom)
+		if (a->isInCurrentRoom())
 			putActor(a, a->x, a->y, a->room);
 		break;
 	case 96:
@@ -2049,7 +2049,7 @@
 		a->startAnimActor(a->standFrame);
 		break;
 	case 230:										/* set direction */
-		a->moving &= ~4;
+		a->moving &= ~MF_TURN;
 		a->setActorDirection(pop());
 		break;
 	case 231:										/* turn to direction */
@@ -2369,7 +2369,7 @@
 	case 226:{										/* wait until actor drawn */
 			Actor *a = derefActorSafe(pop(), "o6_wait:226");
 			int offs = (int16) fetchScriptWord();
-			if (a->room == _currentRoom && a->needRedraw) {
+			if (a->isInCurrentRoom() && a->needRedraw) {
 				_scriptPointer += offs;
 				o6_breakHere();
 			}
@@ -2378,7 +2378,7 @@
 	case 232:{										/* wait until actor stops turning */
 			Actor *a = derefActorSafe(pop(), "o6_wait:226");
 			int offs = (int16) fetchScriptWord();
-			if (a->room == _currentRoom && a->moving & 4) {
+			if (a->isInCurrentRoom() && a->moving & MF_TURN) {
 				_scriptPointer += offs;
 				o6_breakHere();
 			}

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm.h,v
retrieving revision 1.170
retrieving revision 1.171
diff -u -d -r1.170 -r1.171
--- scumm.h	25 May 2002 08:53:08 -0000	1.170
+++ scumm.h	4 Jun 2002 23:32:53 -0000	1.171
@@ -639,7 +639,7 @@
 	int8 _userPut;
 	int _resourceHeaderSize;
 	void unkRoomFunc3(int a, int b, int c, int d, int e);
-	void unkRoomFunc4(int a, int b, int c, int d, int e);
+	void palManipulate(int a, int b, int c, int d, int e);
 	void setScaleItem(int slot, int a, int b, int c, int d);
 	void clearClickedStatus();
 	void startManiac();
@@ -863,9 +863,6 @@
 
 	/* Should be in Costume class */
 	void loadCostume(LoadedCostume *lc, int costume);
-//	void cost_setPalette(CostumeRenderer *cr, byte *palette);
-//	void cost_setFacing(CostumeRenderer *cr, Actor *a);
-//	void cost_setCostume(CostumeRenderer *cr, int costume);
 	byte cost_increaseAnims(LoadedCostume *lc, Actor *a);
 	byte cost_increaseAnim(LoadedCostume *lc, Actor *a, int slot);
 	void cost_decodeData(Actor *a, int frame, uint usemask);
@@ -984,8 +981,8 @@
 
 	uint32 *_classData;
 
-	int newDirToOldDir(int dir);
-	int oldDirToNewDir(int dir);
+	static int newDirToOldDir(int dir);
+	static int oldDirToNewDir(int dir);
 
 	static int normalizeAngle(int angle);
 	int getAngleFromPos(int x, int y);
@@ -996,7 +993,6 @@
 	int getProgrDirChange(Actor *a, int mode);
 
 	int getActorXYPos(Actor *a);
-	AdjustBoxResult adjustXYToBeInBox(Actor *a, int x, int y, int pathfrom);
 	void walkActors();
 	void playActorSounds();
 	void setActorRedrawFlags();

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scummvm.cpp,v
retrieving revision 1.162
retrieving revision 1.163
diff -u -d -r1.162 -r1.163
--- scummvm.cpp	2 Jun 2002 12:07:12 -0000	1.162
+++ scummvm.cpp	4 Jun 2002 23:32:53 -0000	1.163
@@ -789,10 +789,62 @@
 }
 
 
-void Scumm::unkRoomFunc4(int a, int b, int c, int d, int e)
+void Scumm::palManipulate(int palettes, int brightness, int color, int time, int e)
 {
+	byte *cptr;
+
 	/* TODO: implement this */
-	warning("unkRoomFunc4: not implemented");
+	warning("palManipulate(%d, %d, %d, %d): not implemented", palettes, brightness, color, time);
+	
+	printf("_curPalIndex=%d\n", _curPalIndex);
+
+	cptr = _currentPalette + color * 3;
+	printf("color %d = (%d,%d,%d)\n", color, (int)*cptr++, (int)*cptr++, (int)*cptr++);
+
+//	darkenPalette(0, 255, 0xFF+0x10, brightness, brightness);
+	{
+		int startColor = 0;
+		int endColor = 255;
+		int redScale = 0xFF;
+		int greenScale = brightness;
+		int blueScale = brightness;
+		byte *cur;
+		int num;
+		int color;
+	
+		cptr = _currentPalette + startColor * 3;
+		cur = _currentPalette + startColor * 3;
+		num = endColor - startColor + 1;
+
+		do {
+			color = *cptr++;
+			if (redScale != 0xFF)
+				color = color * redScale / 0xFF;
+			if (color > 255)
+				color = 255;
+			*cur++ = color;
+
+			color = *cptr++;
+			if (greenScale != 0xFF)
+				color = color * greenScale / 0xFF;
+			if (color > 255)
+				color = 255;
+			*cur++ = color;
+
+			color = *cptr++;
+			if (blueScale != 0xFF)
+				color = color * blueScale / 0xFF;
+			if (color > 255)
+				color = 255;
+			*cur++ = color;
+		} while (--num);
+		setDirtyColors(startColor, endColor);
+	}
+
+	cptr = _currentPalette + color * 3;
+	printf("color %d = (%d,%d,%d)\n", color, (int)*cptr++, (int)*cptr++, (int)*cptr++);
+
+//	setPalette(palettes);
 }
 
 void Scumm::pauseGame(bool user)





More information about the Scummvm-git-logs mailing list