[Scummvm-cvs-logs] CVS: scummvm/queen graphics.h,1.28,1.29 graphics.cpp,1.30,1.31 logic.h,1.36,1.37 logic.cpp,1.50,1.51

Gregory Montoir cyx at users.sourceforge.net
Mon Oct 20 05:37:15 CEST 2003


Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv18200

Modified Files:
	graphics.h graphics.cpp logic.h logic.cpp 
Log Message:
Logic::anim / BobSlot cleanup

Index: graphics.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- graphics.h	19 Oct 2003 18:52:28 -0000	1.28
+++ graphics.h	20 Oct 2003 08:34:47 -0000	1.29
@@ -90,6 +90,9 @@
 
 	void moveOneStep();
 	void animOneStep();
+
+	void animString(const AnimFrame *animBuf);
+	void animNormal(uint16 firstFrame, uint16 lastFrame, uint16 speed, bool rebound, bool xflip);
 };
 
 
@@ -117,6 +120,7 @@
 	void bobSetupControl();
 	void bobAnimString(uint32 bobnum, const AnimFrame *buf); // stringanim()
 	void bobAnimNormal(uint32 bobnum, uint16 firstFrame, uint16 lastFrame, uint16 speed, bool rebound, bool xflip); // makeanim()
+	void bobAnimReset(uint32 bobnum);
 	void bobMove(uint32 bobnum, int16 endx, int16 endy, int16 speed); // movebob()
 	void bobDraw(uint32 bobnum, int16 x, int16 y, uint16 scale, bool xflip, const Box& box); // bob()
 	void bobDrawInventoryItem(uint32 bobnum, uint16 x, uint16 y); // invbob()

Index: graphics.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- graphics.cpp	18 Oct 2003 19:40:11 -0000	1.30
+++ graphics.cpp	20 Oct 2003 08:34:48 -0000	1.31
@@ -143,32 +143,34 @@
 
 void Graphics::bobAnimString(uint32 bobnum, const AnimFrame *animBuf) {
 
-	BobSlot *pbs = &_bobs[bobnum];
-	pbs->active = true;
-	pbs->animating = true;
-	pbs->anim.string.buffer = animBuf;
-	pbs->anim.string.curPos = animBuf;
-	pbs->frameNum = animBuf->frame;
-	pbs->anim.speed = animBuf->speed / 4;
+	debug(9, "Graphics::bobAnimString(%d)", bobnum);
+	_bobs[bobnum].animString(animBuf);
 }
 
 
 void Graphics::bobAnimNormal(uint32 bobnum, uint16 firstFrame, uint16 lastFrame, uint16 speed, bool rebound, bool xflip) {
 
 	debug(9, "Graphics::bobAnimNormal(%d, %d, %d, %d)", bobnum, firstFrame, lastFrame, speed);
+	_bobs[bobnum].animNormal(firstFrame, lastFrame, speed, rebound, xflip);
+}
+
+
+void Graphics::bobAnimReset(uint32 bobnum) {
 
 	BobSlot *pbs = &_bobs[bobnum];
-	pbs->active = true;
-	pbs->animating = true;
-	pbs->frameNum = firstFrame;
-	pbs->anim.speed = speed;
-	pbs->anim.speedBak = speed;
-	pbs->anim.string.buffer = NULL;
-	pbs->anim.normal.firstFrame = firstFrame;
-	pbs->anim.normal.lastFrame = lastFrame;
-	pbs->anim.normal.rebound = rebound;
-	pbs->frameDir = 1;
-	pbs->xflip = xflip;
+	if(pbs->active && pbs->animating) {
+		const AnimFrame *anim = pbs->anim.string.buffer;
+		if (anim != NULL) {
+			pbs->anim.string.curPos = anim;
+			pbs->frameNum = anim->frame;
+			pbs->anim.speed = anim->speed / 4;
+		}
+		else {
+			pbs->anim.speed = pbs->anim.speedBak;
+			pbs->frameNum = pbs->anim.normal.firstFrame;
+			pbs->frameDir = 1;
+		}
+	}
 }
 
 
@@ -296,7 +298,34 @@
 		}
 	}
 }
-          
+
+
+void BobSlot::animString(const AnimFrame *animBuf) {
+
+	active = true;
+	animating = true;
+	anim.string.buffer = animBuf;
+	anim.string.curPos = animBuf;
+	frameNum = animBuf->frame;
+	anim.speed = animBuf->speed / 4;
+}
+
+
+void BobSlot::animNormal(uint16 firstFrame, uint16 lastFrame, uint16 spd, bool rebound, bool flip) {
+
+	active = true;
+	animating = true;
+	frameNum = firstFrame;
+	anim.speed = spd;
+	anim.speedBak = spd;
+	anim.string.buffer = NULL;
+	anim.normal.firstFrame = firstFrame;
+	anim.normal.lastFrame = lastFrame;
+	anim.normal.rebound = rebound;
+	frameDir = 1;
+	xflip = flip;
+}
+
 
 void Graphics::bobDraw(uint32 bobnum, int16 x, int16 y, uint16 scale, bool xflip, const Box& box) {
 

Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- logic.h	19 Oct 2003 18:52:28 -0000	1.36
+++ logic.h	20 Oct 2003 08:34:48 -0000	1.37
@@ -131,7 +131,7 @@
 
 	uint16 animCreate(uint16 curImage, const Person *person); // CREATE_ANIM
 	void animErase(uint16 bobNum);
-	int16 animFindAll(const GraphicData *gd, uint16 firstImage, AnimFrame *paf); // FIND_GRAPHIC_ANIMS
+	void animSetup(const GraphicData *gd, uint16 firstImage, uint16 bobNum, bool visible); // FIND_GRAPHIC_ANIMS
 
 	StateDirection findStateDirection(uint16 state); // == FIND_STATE(state, "DIR");
 	StateTalk      findStateTalk     (uint16 state); // == FIND_STATE(state, "TALK");
@@ -240,7 +240,7 @@
 	//! Last frame number used for person animation
 	uint16 _personFrames[4];
 
-	//! Describe an string based animation (30 frames maximum, bob number must be < 17)
+	//! Describe a string based animation (30 frames maximum, bob number must be < 17)
 	AnimFrame _newAnim[17][30];
 
 	Resource *_resource;

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- logic.cpp	19 Oct 2003 18:52:28 -0000	1.50
+++ logic.cpp	20 Oct 2003 08:34:48 -0000	1.51
@@ -900,7 +900,9 @@
 			if (pgd->firstFrame < 0) {
 				// FIXME: if(TEMPA[1]<0) bobs[CURRBOB].xflip=1;
 				curBob = 5 + _numFurnitureAnimated;
-				AnimFrame *paf = NULL;
+				animSetup(pgd, curImage + 1, curBob + numObjectAnimated, pod->name > 0);
+				curImage += pgd->lastFrame;
+/*				AnimFrame *paf = NULL;
 				if (pod->name > 0) {
 					paf = _newAnim[curBob + numObjectAnimated];
 				}
@@ -918,7 +920,7 @@
 				}
 				else {
 					pbs->animating = false;
-				}
+				}*/
 				++numObjectAnimated;
 			}
 			else if (lastFrame != 0) {
@@ -1062,7 +1064,9 @@
 		rebound = true;
 	}
 	if (pgd->firstFrame < 0) {
-		AnimFrame *paf = NULL;
+		animSetup(pgd, curImage, curBob, pod->name != 0);
+		curImage += pgd->lastFrame - 1;
+/*		AnimFrame *paf = NULL;
 		if (pod->name != 0) {
 			paf = _newAnim[curBob];
 		}
@@ -1079,7 +1083,7 @@
 		}
 		else {
 			pbs->animating = false;
-		}
+		}*/
 	}
 	else if (lastFrame != 0) {
 		// turn on an animated bob
@@ -1331,6 +1335,7 @@
 					++curImage;
 				}
 			}
+			// FIXME: shouldn't this line be executed BEFORE curImage is incremented ?
 			_personFrames[bobNum] = curImage + 1;
 		}
 	}
@@ -1399,6 +1404,7 @@
 
 
 void Logic::animErase(uint16 bobNum) {
+
 	_newAnim[bobNum][0].frame = 0;
 	BobSlot *pbs = _graphics->bob(bobNum);
 	pbs->animating = false;
@@ -1406,7 +1412,7 @@
 }
 
 
-int16 Logic::animFindAll(const GraphicData *gd, uint16 firstImage, AnimFrame *paf) {
+void Logic::animSetup(const GraphicData *gd, uint16 firstImage, uint16 bobNum, bool visible) {
 	
 	int16 tempFrames[20];
 	memset(tempFrames, 0, sizeof(tempFrames));
@@ -1450,7 +1456,15 @@
 	for (i = 0; i < gd->lastFrame; ++i) {
 		_graphics->bankUnpack(ABS(tempFrames[i]), firstImage + i, 15);
 	}
-	if (paf != NULL) {
+	BobSlot *pbs = _graphics->bob(bobNum);
+	pbs->animating = false;
+	if (visible) {
+		pbs->x = gd->x;
+		pbs->y = gd->y;
+		if (tempFrames[0] < 0) {
+			pbs->xflip = true;
+		}
+		AnimFrame *paf = _newAnim[bobNum];
 		for (i = 1; i <= _numGraphicAnim; ++i) {
 			const GraphicAnim *pga = &_graphicAnim[i];
 			if (pga->keyFrame == gd->firstFrame) {
@@ -1472,8 +1486,8 @@
 		}
 		paf->frame = 0;
 		paf->speed = 0;
+		pbs->animString(_newAnim[bobNum]);
 	}
-	return tempFrames[0];
 }
 
 





More information about the Scummvm-git-logs mailing list