[Scummvm-cvs-logs] CVS: scummvm/queen cutaway.cpp,1.100,1.101 graphics.cpp,1.68,1.69 graphics.h,1.52,1.53 logic.cpp,1.157,1.158 logic.h,1.100,1.101 talk.cpp,1.68,1.69 xref.txt,1.54,1.55

Gregory Montoir cyx at users.sourceforge.net
Tue Jan 6 06:23:02 CET 2004


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

Modified Files:
	cutaway.cpp graphics.cpp graphics.h logic.cpp logic.h talk.cpp 
	xref.txt 
Log Message:
moved animation stuff to Graphics class

Index: cutaway.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/cutaway.cpp,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- cutaway.cpp	6 Jan 2004 12:45:29 -0000	1.100
+++ cutaway.cpp	6 Jan 2004 14:21:50 -0000	1.101
@@ -1023,7 +1023,7 @@
 			if (object->image == -3 || object->image == -4) {
 				k++;
 				if (object->name > 0) {
-					_vm->logic()->animReset(k);
+					_vm->graphics()->animReset(k);
 				}
 			}
 		}

Index: graphics.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.cpp,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- graphics.cpp	6 Jan 2004 12:45:29 -0000	1.68
+++ graphics.cpp	6 Jan 2004 14:21:50 -0000	1.69
@@ -668,6 +668,161 @@
 }
 
 
+uint16 Graphics::animCreate(uint16 curImage, const Person *person) {
+	AnimFrame *animFrames = _newAnim[person->actor->bobNum];
+
+	uint16 allocatedFrames[256];
+	memset(allocatedFrames, 0, sizeof(allocatedFrames));
+	const char *p = person->anim;
+	int frame = 0;
+	uint16 f1, f2;
+	do {
+		sscanf(p, "%3hu,%3hu", &f1, &f2);
+		animFrames[frame].frame = f1;
+		animFrames[frame].speed = f2;
+
+		if (f1 > 500) {
+			// SFX
+			allocatedFrames[f1 - 500] = 1;
+		} else {
+			allocatedFrames[f1] = 1;
+		}
+		
+		p += 8;
+		++frame;
+	} while(f1 != 0);
+	
+	// ajust frame numbers
+	uint16 n = 1;
+	uint16 i;
+	for (i = 1; i <= 255; ++i) {
+		if (allocatedFrames[i] != 0) {
+			allocatedFrames[i] = n;
+			++n;
+		}
+	}
+	for (i = 0; animFrames[i].frame != 0; ++i) {
+		uint16 frameNum = animFrames[i].frame;
+		if (frameNum > 500) {
+			animFrames[i].frame = curImage + allocatedFrames[frameNum - 500] + 500;
+		} else {
+			animFrames[i].frame = curImage + allocatedFrames[frameNum];
+		}
+	}
+
+	// unpack necessary frames
+	for (i = 1; i <= 255; ++i) {
+		if (allocatedFrames[i] != 0) {
+			++curImage;
+			_vm->bankMan()->unpack(i, curImage, person->actor->bankNum);
+		}
+	}
+
+	// start animation
+	bob(person->actor->bobNum)->animString(animFrames);
+
+	return curImage;
+}
+
+
+void Graphics::animSetup(const GraphicData *gd, uint16 firstImage, uint16 bobNum, bool visible) {
+	int16 tempFrames[20];
+	memset(tempFrames, 0, sizeof(tempFrames));
+	uint16 numTempFrames = 0;
+	uint16 i, j;
+	for (i = 1; i <= _vm->logic()->graphicAnimCount(); ++i) {
+		const GraphicAnim *pga = _vm->logic()->graphicAnim(i);
+		if (pga->keyFrame == gd->firstFrame) {
+			int16 frame = pga->frame;
+			if (frame > 500) { // SFX
+				frame -= 500;
+			}
+			bool foundMatchingFrame = false;
+			for (j = 0; j < numTempFrames; ++j) {
+				if (tempFrames[j] == frame) {
+					foundMatchingFrame = true;
+					break;
+				}
+			}
+			if (!foundMatchingFrame) {
+				assert(numTempFrames < 20);
+				tempFrames[numTempFrames] = frame;
+				++numTempFrames;
+			}
+		}
+	}
+
+	// sort found frames ascending
+	bool swap = true;
+	while (swap) {
+		swap = false;
+		for (i = 0; i < numTempFrames - 1; ++i) {
+			if (tempFrames[i] > tempFrames[i + 1]) {
+				SWAP(tempFrames[i], tempFrames[i + 1]);
+				swap = true;
+			}
+		}
+	}
+
+	// queen.c l.962-980 / l.1269-1294
+	for (i = 0; i < gd->lastFrame; ++i) {
+		_vm->bankMan()->unpack(ABS(tempFrames[i]), firstImage + i, 15);
+	}
+	BobSlot *pbs = bob(bobNum);
+	pbs->animating = false;
+	if (visible) {
+		pbs->curPos(gd->x, gd->y);
+		if (tempFrames[0] < 0) {
+			pbs->xflip = true;
+		}
+		AnimFrame *paf = _newAnim[bobNum];
+		for (i = 1; i <= _vm->logic()->graphicAnimCount(); ++i) {
+			const GraphicAnim *pga = _vm->logic()->graphicAnim(i);
+			if (pga->keyFrame == gd->firstFrame) {
+				uint16 frameNr = 0;
+				for (j = 1; j <= gd->lastFrame; ++j) {
+					if (pga->frame > 500) {
+						if (pga->frame - 500 == tempFrames[j - 1]) {
+							frameNr = j + firstImage - 1 + 500;
+						}
+					} else if (pga->frame == tempFrames[j - 1]) {
+						frameNr = j + firstImage - 1;
+					}
+				}
+				paf->frame = frameNr;
+				paf->speed = pga->speed;
+				++paf;
+			}
+		}
+		paf->frame = 0;
+		paf->speed = 0;
+		pbs->animString(_newAnim[bobNum]);
+	}
+}
+
+
+void Graphics::animReset(uint16 bobNum) {
+	if (_newAnim[bobNum][0].frame != 0) {
+		bob(bobNum)->animString(_newAnim[bobNum]);
+	}
+}
+
+
+void Graphics::animErase(uint16 bobNum) {
+	_newAnim[bobNum][0].frame = 0;
+	BobSlot *pbs = bob(bobNum);
+	pbs->animating = false;
+	pbs->anim.string.buffer = NULL;
+}
+
+
+void Graphics::animEraseAll() {
+	for (int i = 1; i <= 16; ++i) {
+		_newAnim[i][0].frame = 0;
+	}
+}
+
+
 void Graphics::loadPanel() {
 	uint8 *pcxbuf = _vm->resource()->loadFile("panel.pcx");
 	if (pcxbuf == NULL) {

Index: graphics.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.h,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- graphics.h	6 Jan 2004 12:45:29 -0000	1.52
+++ graphics.h	6 Jan 2004 14:21:50 -0000	1.53
@@ -179,6 +179,12 @@
 	int textCenterX(const char *text) const; // MIDDLE()
 	void textColor(uint16 y, uint8 color) { _texts[y].color = color; }
 
+	uint16 animCreate(uint16 curImage, const Person *person);
+	void animSetup(const GraphicData *gd, uint16 firstImage, uint16 bobNum, bool visible);
+	void animReset(uint16 bobNum);
+	void animErase(uint16 bobNum);
+	void animEraseAll();
+
 	void loadPanel();
 
 	void putCameraOnBob(int bobNum) { _cameraBob = bobNum; }
@@ -208,6 +214,8 @@
 
 	TextSlot _texts[GAME_SCREEN_HEIGHT];
 	uint8 _curTextColor;
+
+	AnimFrame _newAnim[17][30];
 
 	int _cameraBob;
 

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.157
retrieving revision 1.158
diff -u -d -r1.157 -r1.158
--- logic.cpp	6 Jan 2004 12:45:29 -0000	1.157
+++ logic.cpp	6 Jan 2004 14:21:50 -0000	1.158
@@ -67,18 +67,14 @@
 	delete _queen2jas;
 }
 
-void Logic::initialise() {
-	
+void Logic::initialise() {	
 	int16 i, j;
 
-
 	// Step 1 : read queen.jas file and 'unserialize' some arrays
 
 	uint8 *jas = _vm->resource()->loadFile("QUEEN.JAS", 20);
 	uint8 *ptr = jas;
 
-	_queen2jas = new LineReader((char*)_vm->resource()->loadFile("QUEEN2.JAS"));
-
 	_numRooms = READ_BE_UINT16(ptr); ptr += 2;
 	_numNames = READ_BE_UINT16(ptr); ptr += 2;
 	_numObjects = READ_BE_UINT16(ptr); ptr += 2;
@@ -218,6 +214,8 @@
 
 
 	// Step 2 : read queen2.jas and grab all description texts
+
+	_queen2jas = new LineReader((char*)_vm->resource()->loadFile("QUEEN2.JAS"));
 	
 	_objDescription = new char*[_numDescriptions + 1];
 	_objDescription[0] = 0;
@@ -622,17 +620,13 @@
 	} else {
 		_vm->display()->palFadeOut(0, 223, _currentRoom);
 	}
-	
-	// TODO: credits system
 
 	// invalidates all persons animations
 	uint16 i;
 	for (i = 0; i <= 3; ++i) {
 		_personFrames[i] = 0;
 	}
-	for (i = 1; i <= 16; ++i) {
-		_newAnim[i][0].frame = 0;
-	}
+	_vm->graphics()->animEraseAll();
 
 	uint16 cur = _roomData[_oldRoom] + 1;
 	uint16 last = _roomData[_oldRoom + 1];
@@ -783,7 +777,7 @@
 			if (pgd->firstFrame < 0) {
 				// FIXME: if(TEMPA[1]<0) bobs[CURRBOB].xflip=1;
 				curBob = 5 + _numFurnitureAnimated;
-				animSetup(pgd, curImage + 1, curBob + numObjectAnimated, pod->name > 0);
+				_vm->graphics()->animSetup(pgd, curImage + 1, curBob + numObjectAnimated, pod->name > 0);
 				curImage += pgd->lastFrame;
 				++numObjectAnimated;
 			} else if (lastFrame != 0) {
@@ -922,7 +916,7 @@
 		rebound = true;
 	}
 	if (pgd->firstFrame < 0) {
-		animSetup(pgd, curImage, curBob, pod->name != 0);
+		_vm->graphics()->animSetup(pgd, curImage, curBob, pod->name != 0);
 		curImage += pgd->lastFrame - 1;
 	} else if (lastFrame != 0) {
 		// turn on an animated bob
@@ -1114,9 +1108,9 @@
 
 	if (p.anim != NULL) {
 		_personFrames[pad->bobNum] = curImage + 1;
-		curImage = animCreate(curImage, &p);
+		curImage = _vm->graphics()->animCreate(curImage, &p);
 	} else {
-		animErase(pad->bobNum);
+		_vm->graphics()->animErase(pad->bobNum);
 	}
 	return curImage;
 }
@@ -1170,154 +1164,6 @@
 		}
 	}
 	return curImage;
-}
-
-
-uint16 Logic::animCreate(uint16 curImage, const Person *person) {
-	AnimFrame *animFrames = _newAnim[person->actor->bobNum];
-
-	uint16 allocatedFrames[256];
-	memset(allocatedFrames, 0, sizeof(allocatedFrames));
-	const char *p = person->anim;
-	int frame = 0;
-	uint16 f1, f2;
-	do {
-		sscanf(p, "%3hu,%3hu", &f1, &f2);
-		animFrames[frame].frame = f1;
-		animFrames[frame].speed = f2;
-
-		if (f1 > 500) {
-			// SFX
-			allocatedFrames[f1 - 500] = 1;
-		} else {
-			allocatedFrames[f1] = 1;
-		}
-		
-		p += 8;
-		++frame;
-	} while(f1 != 0);
-	
-	// ajust frame numbers
-	uint16 n = 1;
-	uint16 i;
-	for (i = 1; i <= 255; ++i) {
-		if (allocatedFrames[i] != 0) {
-			allocatedFrames[i] = n;
-			++n;
-		}
-	}
-	for (i = 0; animFrames[i].frame != 0; ++i) {
-		uint16 frameNum = animFrames[i].frame;
-		if (frameNum > 500) {
-			animFrames[i].frame = curImage + allocatedFrames[frameNum - 500] + 500;
-		} else {
-			animFrames[i].frame = curImage + allocatedFrames[frameNum];
-		}
-	}
-
-	// unpack necessary frames
-	for (i = 1; i <= 255; ++i) {
-		if (allocatedFrames[i] != 0) {
-			++curImage;
-			_vm->bankMan()->unpack(i, curImage, person->actor->bankNum);
-		}
-	}
-
-	// start animation
-	_vm->graphics()->bob(person->actor->bobNum)->animString(animFrames);
-
-	return curImage;
-}
-
-
-void Logic::animErase(uint16 bobNum) {
-	_newAnim[bobNum][0].frame = 0;
-	BobSlot *pbs = _vm->graphics()->bob(bobNum);
-	pbs->animating = false;
-	pbs->anim.string.buffer = NULL;
-}
-
-
-void Logic::animReset(uint16 bobNum) {
-	if (_newAnim[bobNum][0].frame != 0) {
-		_vm->graphics()->bob(bobNum)->animString(_newAnim[bobNum]);
-	}
-}
-
-
-void Logic::animSetup(const GraphicData *gd, uint16 firstImage, uint16 bobNum, bool visible) {
-	int16 tempFrames[20];
-	memset(tempFrames, 0, sizeof(tempFrames));
-	uint16 numTempFrames = 0;
-	uint16 i, j;
-	for (i = 1; i <= _numGraphicAnim; ++i) {
-		const GraphicAnim *pga = &_graphicAnim[i];
-		if (pga->keyFrame == gd->firstFrame) {
-			int16 frame = pga->frame;
-			if (frame > 500) { // SFX
-				frame -= 500;
-			}
-			bool foundMatchingFrame = false;
-			for (j = 0; j < numTempFrames; ++j) {
-				if (tempFrames[j] == frame) {
-					foundMatchingFrame = true;
-					break;
-				}
-			}
-			if (!foundMatchingFrame) {
-				assert(numTempFrames < 20);
-				tempFrames[numTempFrames] = frame;
-				++numTempFrames;
-			}
-		}
-	}
-
-	// sort found frames ascending
-	bool swap = true;
-	while (swap) {
-		swap = false;
-		for (i = 0; i < numTempFrames - 1; ++i) {
-			if (tempFrames[i] > tempFrames[i + 1]) {
-				SWAP(tempFrames[i], tempFrames[i + 1]);
-				swap = true;
-			}
-		}
-	}
-
-	// queen.c l.962-980 / l.1269-1294
-	for (i = 0; i < gd->lastFrame; ++i) {
-		_vm->bankMan()->unpack(ABS(tempFrames[i]), firstImage + i, 15);
-	}
-	BobSlot *pbs = _vm->graphics()->bob(bobNum);
-	pbs->animating = false;
-	if (visible) {
-		pbs->curPos(gd->x, 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) {
-				uint16 frameNr = 0;
-				for (j = 1; j <= gd->lastFrame; ++j) {
-					if (pga->frame > 500) {
-						if (pga->frame - 500 == tempFrames[j - 1]) {
-							frameNr = j + firstImage - 1 + 500;
-						}
-					} else if (pga->frame == tempFrames[j - 1]) {
-						frameNr = j + firstImage - 1;
-					}
-				}
-				paf->frame = frameNr;
-				paf->speed = pga->speed;
-				++paf;
-			}
-		}
-		paf->frame = 0;
-		paf->speed = 0;
-		pbs->animString(_newAnim[bobNum]);
-	}
 }
 
 

Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.h,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- logic.h	6 Jan 2004 12:45:29 -0000	1.100
+++ logic.h	6 Jan 2004 14:21:50 -0000	1.101
@@ -106,6 +106,8 @@
 	WalkOffData *walkOffData(int index) const { return &_walkOffData[index]; }
 	uint16 currentRoomObjMax() const { return _objMax[_currentRoom]; }
 	uint16 currentRoomData() const { return _roomData[_currentRoom]; }
+	GraphicAnim *graphicAnim(int index) const { return &_graphicAnim[index]; }
+	uint16 graphicAnimCount() const { return _numGraphicAnim; }
 	ObjectDescription *objectDescription(uint16 objNum) const { return &_objectDescription[objNum]; }
 	uint16 objectDescriptionCount() const { return _numObjDesc; }
 	uint16 currentRoomSfx() const { return _sfxName[_currentRoom]; }
@@ -171,11 +173,6 @@
 	uint16 personAllocate(uint16 noun, uint16 curImage);
 	uint16 personFrames(uint16 bobNum) const { return _personFrames[bobNum]; }
 
-	uint16 animCreate(uint16 curImage, const Person *person);
-	void animErase(uint16 bobNum);
-	void animReset(uint16 bobNum);
-	void animSetup(const GraphicData *gd, uint16 firstImage, uint16 bobNum, bool visible);
-
 	void joeSetupFromBanks(const char *animBank, const char *standBank);
 
 	//! Load the various bobs needed to animate Joe
@@ -428,9 +425,6 @@
 
 	//! Last frame number used for person animation
 	uint16 _personFrames[4];
-
-	//! Describe a string based animation (30 frames maximum, bob number must be < 17)
-	AnimFrame _newAnim[17][30];
 
 	//! Inventory items
 	int16 _inventoryItem[4];

Index: talk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.cpp,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- talk.cpp	6 Jan 2004 12:45:29 -0000	1.68
+++ talk.cpp	6 Jan 2004 14:21:50 -0000	1.69
@@ -337,7 +337,7 @@
 		pbs->y = person.actor->y;
 		
 		// Better kick start the persons anim sequence
-		_vm->logic()->animReset(person.actor->bobNum);
+		_vm->graphics()->animReset(person.actor->bobNum);
 	}
 
 	_vm->logic()->joeWalk(JWM_NORMAL);

Index: xref.txt
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/xref.txt,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- xref.txt	5 Jan 2004 13:40:28 -0000	1.54
+++ xref.txt	6 Jan 2004 14:21:50 -0000	1.55
@@ -270,7 +270,7 @@
 PERSONS
 =======
 ALLOCATE_PERSON()			Logic::personAllocate
-CREATE_ANIM()				Logic::animCreate
+CREATE_ANIM()				Graphics::animCreate
 SET_PERSON_DATA()			Logic::personSetData
 SETUP_PERSON()				Logic::personSetup
 OBJ_PERSON()				Logic::objectForPerson





More information about the Scummvm-git-logs mailing list