[Scummvm-cvs-logs] CVS: scummvm/queen command.cpp,1.53,1.54 cutaway.cpp,1.106,1.107 graphics.cpp,1.74,1.75 graphics.h,1.57,1.58 logic.cpp,1.164,1.165 logic.h,1.107,1.108 talk.cpp,1.72,1.73 xref.txt,1.59,1.60

Gregory Montoir cyx at users.sourceforge.net
Thu Jan 8 14:47:01 CET 2004


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

Modified Files:
	command.cpp cutaway.cpp graphics.cpp graphics.h logic.cpp 
	logic.h talk.cpp xref.txt 
Log Message:
moved the remaining 'graphics' stuff from Logic to Graphics

Index: command.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/command.cpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- command.cpp	8 Jan 2004 14:10:32 -0000	1.53
+++ command.cpp	8 Jan 2004 22:46:42 -0000	1.54
@@ -394,14 +394,14 @@
 		} else {
 			od->image = com->imageOrder;
 		}
-		_vm->logic()->roomRefreshObject(_state.subject[0]);
+		_vm->graphics()->refreshObject(_state.subject[0]);
 	} else {
 		// this object is not being updated by command list, see if
 		// it has another image copied to it
 		if (_state.subject[0] > 0) {
 			// an object (not an item)
 			if (_vm->logic()->objectData(_state.subject[0])->image != oldImage) {
-				_vm->logic()->roomRefreshObject(_state.subject[0]);
+				_vm->graphics()->refreshObject(_state.subject[0]);
 			}
 		}
 	}
@@ -1144,7 +1144,7 @@
 				if (dstObj != _state.subject[0]) {
 					// if the new object we have updated is on screen and
 					// is not current object then update it
-					_vm->logic()->roomRefreshObject(dstObj);
+					_vm->graphics()->refreshObject(dstObj);
 				}
 			} else {
 				// hide the object
@@ -1153,7 +1153,7 @@
 					// may need to turn BOBs off for objects to be hidden on current 
 					// screen ! if the new object we have updated is on screen and
 					// is not current object then update it
-					_vm->logic()->roomRefreshObject(dstObj);
+					_vm->graphics()->refreshObject(dstObj);
 				}
 			}
 		}

Index: cutaway.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/cutaway.cpp,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- cutaway.cpp	8 Jan 2004 16:41:03 -0000	1.106
+++ cutaway.cpp	8 Jan 2004 22:46:42 -0000	1.107
@@ -420,7 +420,7 @@
 
 	_vm->logic()->roomDisplay(_vm->logic()->currentRoom(), mode, object.scale, comPanel, true);
 
-	_currentImage = _vm->logic()->numFrames();
+	_currentImage = _vm->graphics()->numFrames();
 
 	_temporaryRoom = _vm->logic()->currentRoom();
 
@@ -460,7 +460,7 @@
 			objectData->name = ABS(objectData->name);
 		}
 
-		_vm->logic()->roomRefreshObject(object.objectNumber);
+		_vm->graphics()->refreshObject(object.objectNumber);
 
 		// Skip doing any anim stuff
 		objectType = OBJECT_TYPE_NO_ANIMATION;
@@ -638,7 +638,7 @@
 		if ((_vm->logic()->currentRoom() == 47 || _vm->logic()->currentRoom() == 63) &&
 			objAnim[0].object == 1) {
 			//CR 2 - 3/3/95, Special harcoded section to make Oracle work...
-			makeComplexAnimation(_vm->logic()->personFrames(1) - 1,  objAnim, frameCount);
+			makeComplexAnimation(_vm->graphics()->personFrames(1) - 1,  objAnim, frameCount);
 		}
 		else {
 			_currentImage = makeComplexAnimation(_currentImage, objAnim, frameCount);
@@ -856,7 +856,7 @@
 	int i;
 	nextFilename[0] = '\0';
 
-	_currentImage = _vm->logic()->numFrames();
+	_currentImage = _vm->graphics()->numFrames();
 
 	BobSlot *joeBob = _vm->graphics()->bob(0);
 	int initialJoeX = joeBob->x;
@@ -1128,7 +1128,7 @@
 				}
 
 				if (_vm->logic()->currentRoom() == room)
-					_vm->logic()->roomRefreshObject(objectIndex);
+					_vm->graphics()->refreshObject(objectIndex);
 			}
 
 			if (_vm->logic()->currentRoom() == object->room) {
@@ -1225,13 +1225,13 @@
 				objectData->name        = ABS(objectData->name);
 				if (fromObject > 0)
 					_vm->logic()->objectCopy(fromObject, objectIndex);
-				_vm->logic()->roomRefreshObject(objectIndex);
+				_vm->graphics()->refreshObject(objectIndex);
 			}
 			else if (objectIndex < 0) {               // Hide the object
 				objectIndex             = -objectIndex;
 				ObjectData *objectData  = _vm->logic()->objectData(objectIndex);
 				objectData->name        = -ABS(objectData->name);
-				_vm->logic()->roomRefreshObject(objectIndex);
+				_vm->graphics()->refreshObject(objectIndex);
 			}
 
 			if (areaIndex > 0) {

Index: graphics.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.cpp,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- graphics.cpp	8 Jan 2004 16:41:03 -0000	1.74
+++ graphics.cpp	8 Jan 2004 22:46:42 -0000	1.75
@@ -24,6 +24,7 @@
 
 #include "queen/bankman.h"
 #include "queen/display.h"
+#include "queen/grid.h"
 #include "queen/logic.h"
 #include "queen/queen.h"
 #include "queen/resource.h"
@@ -501,8 +502,118 @@
 }
 
 
-void Graphics::textCurrentColor(uint8 color) {
-	_curTextColor = color;
+void Graphics::bobSetText(
+		BobSlot *pbs, 
+		const char *text, 
+		int textX, int textY, 
+		int color, int flags) {
+	// function MAKE_SPEAK_BOB, lines 335-457 in talk.c
+
+	if (text[0] == '\0')
+		return;
+
+	// debug(0, "makeSpeakBob('%s', (%i,%i), %i, %i, %i, %i);", 
+	//		text, bob->x, bob->y, textX, textY, color, flags);
+
+	// Duplicate string and append zero if needed
+
+	char textCopy[MAX_STRING_SIZE];
+
+	int length = strlen(text);
+	memcpy(textCopy, text, length);
+
+	if (textCopy[length - 1] >= 'A')
+		textCopy[length++] = '.';
+
+	textCopy[length] = '\0';
+
+	// Split text into lines
+
+	char lines[8][MAX_STRING_SIZE];
+	int lineCount = 0;
+	int wordCount = 0;
+	int lineLength = 0;
+	int i;
+
+	for (i = 0; i < length; i++) {
+		if (textCopy[i] == ' ')
+			wordCount++;
+
+		lineLength++;
+
+		if ((lineLength > 20 && textCopy[i] == ' ') || i == (length-1)) {
+			memcpy(lines[lineCount], textCopy + i + 1 - lineLength, lineLength);
+			lines[lineCount][lineLength] = '\0';
+			lineCount++;
+			lineLength = 0;
+		}
+	}
+
+
+	// Plan: write each line to Screen 2, put black outline around lines and
+	// pick them up as a BOB.
+
+
+	// Find width of widest line 
+
+	int maxLineWidth = 0;
+
+	for (i = 0; i < lineCount; i++) {
+		int width = textWidth(lines[i]);
+		if (maxLineWidth < width)
+			maxLineWidth = width;
+	}
+
+	// Calc text position
+
+	short x, y, width, height;
+
+	if (flags) {
+		if (flags == 2)
+			x = 160 - maxLineWidth / 2;
+		else
+			x = textX;
+
+		y = textY;
+
+		width = 0;
+	} else {
+		x = pbs->x;
+		y = pbs->y;
+
+		BobFrame *pbf = _vm->bankMan()->fetchFrame(pbs->frameNum);
+
+		width  = (pbf->width  * pbs->scale) / 100;
+		height = (pbf->height * pbs->scale) / 100;
+
+		y = y - height - 16 - lineCount * 9;
+	}
+
+	x -= _vm->display()->horizontalScroll();
+
+	if (y < 0) {
+		y = 0;
+
+		if (x < 160)
+			x += width / 2;
+		else
+			x -= width / 2 + maxLineWidth;
+	} else if (!flags)
+		x -= maxLineWidth / 2;
+
+	if (x < 0)
+		x = 4;
+	else if ((x + maxLineWidth) > 320)
+		x = 320 - maxLineWidth - 4;
+
+	textCurrentColor(color);
+
+	for (i = 0; i < lineCount; i++) {
+		int lineX = x + (maxLineWidth - textWidth(lines[i])) / 2;
+
+		//debug(0, "Setting text '%s' at (%i, %i)", lines[i], lineX, y + 9 * i);
+		textSet(lineX, y + 9 * i, lines[i]);
+	}
 }
 
 
@@ -550,6 +661,30 @@
 }
 
 
+int Graphics::textCenterX(const char *text) const {
+	return 160 - textWidth(text) / 2;
+}
+
+
+void Graphics::setupNewRoom(const char *room, uint16 roomNum, int16 *furniture, uint16 furnitureCount) {
+	// reset sprites table (bounding box...)
+	bobClearAll();
+
+	// load/setup objects associated to this room
+	char filename[20];	
+	sprintf(filename, "%s.BBK", room);
+	_vm->bankMan()->load(filename, 15);
+
+	_numFrames = 37 + FRAMES_JOE_XTRA;
+	setupRoomFurniture(furniture, furnitureCount);
+	setupRoomObjects();
+
+	if (roomNum >= 90) {
+		putCameraOnBob(0);
+	}
+}
+
+
 void Graphics::fillAnimBuffer(const char *anim, AnimFrame *af) {
 	while (true) {
 		sscanf(anim, "%3hu,%3hu", &af->frame, &af->speed);
@@ -661,6 +796,8 @@
 
 uint16 Graphics::setupPersonAnim(const ActorData *ad, const char *anim, uint16 curImage) {
 	debug(9, "Graphics::setupPersonAnim(%s, %d)", anim, curImage);
+	_personFrames[ad->bobNum] = curImage + 1;
+
 	AnimFrame *animFrames = _newAnim[ad->bobNum];
 	fillAnimBuffer(anim, animFrames);
 	uint16 frameCount[256];
@@ -727,6 +864,356 @@
 }
 
 
+uint16 Graphics::refreshObject(uint16 obj) {
+	debug(6, "Graphics::refreshObject(%X)", obj);
+	uint16 curImage = _numFrames;
+
+	ObjectData *pod = _vm->logic()->objectData(obj);
+	if (pod->image == 0) {
+		return curImage;
+	}
+
+	// check the object is in the current room
+	if (pod->room != _vm->logic()->currentRoom()) {
+		return curImage;
+	}
+
+	// find bob for the object
+	uint16 curBob = _vm->logic()->findBob(obj);
+	BobSlot *pbs = bob(curBob);
+
+	if (pod->image == -3 || pod->image == -4) {
+		// a person object
+		if (pod->name <= 0) {
+			bobClear(curBob);
+		} else {
+			// find person number
+			uint16 pNum = _vm->logic()->findPersonNumber(obj);
+			curImage = _personFrames[pNum] - 1;
+			if (_personFrames[pNum] == 0) {
+				_personFrames[pNum] = curImage = _numFrames;
+			}
+			curImage = setupPerson(obj - _vm->logic()->currentRoomData(), curImage);
+		}
+		return curImage;
+	}
+
+	// find frame used for object
+	curImage = _vm->logic()->findFrame(obj);
+
+	if (pod->name < 0 || pod->image < 0) {
+		// object is hidden or disabled
+		bobClear(curBob);
+		return curImage;
+	}
+
+	int image = pod->image;
+	if (image > 5000) {
+		image -= 5000;
+	}
+	
+	GraphicData *pgd = _vm->logic()->graphicData(image);
+	bool rebound = false;
+	int16 lastFrame = pgd->lastFrame;
+	if (lastFrame < 0) {
+		lastFrame = -lastFrame;
+		rebound = true;
+	}
+	if (pgd->firstFrame < 0) {
+		setupObjectAnim(pgd, curImage, curBob, pod->name != 0);
+		curImage += pgd->lastFrame - 1;
+	} else if (lastFrame != 0) {
+		// turn on an animated bob
+		_vm->bankMan()->unpack(pgd->firstFrame, 2, 15);
+		pbs->animating = false;
+		uint16 firstImage = curImage;
+		--curImage;
+		uint16 j;
+		for (j = pgd->firstFrame; j <= lastFrame; ++j) {
+			++curImage;
+			_vm->bankMan()->unpack(j, curImage, 15);
+		}
+		pbs->curPos(pgd->x, pgd->y);
+		pbs->frameNum = firstImage;
+		if (pgd->speed > 0) {
+			pbs->animNormal(firstImage, curImage, pgd->speed / 4, rebound, false);
+		}
+	} else {
+		// frame 2 is used as a buffer frame to prevent BOB flickering
+		_vm->bankMan()->unpack(pgd->firstFrame, 2, 15);
+		_vm->bankMan()->unpack(pgd->firstFrame, curImage, 15);
+		pbs->curPos(pgd->x, pgd->y);
+		pbs->frameNum = curImage;
+	}
+
+	return curImage;
+}
+
+
+void Graphics::setupRoomFurniture(int16 *furniture, uint16 furnitureCount) {
+	uint16 i;
+	uint16 curImage = 36 + FRAMES_JOE_XTRA;
+
+	// unpack the furniture from bank 15
+	// there are 3 kinds :
+	// - static (bobs), gamestate range = ]0;5000]
+	// - animated (bobs), gamestate range = ]0;5000]
+	// - static (paste downs), gamestate range = [5000; [
+
+	// unpack the static bobs
+	_numFurnitureStatic = 0;
+	for	(i = 1; i <= furnitureCount; ++i) {
+		int16 obj = furniture[i];
+		if (obj > 0 && obj <= 5000) {
+			GraphicData *pgd = _vm->logic()->graphicData(obj);
+			if (pgd->lastFrame == 0) {
+				++_numFurnitureStatic;
+				++curImage;
+				_vm->bankMan()->unpack(pgd->firstFrame, curImage, 15);
+				++_numFrames;
+				BobSlot *pbs = bob(19 + _numFurnitureStatic);
+				pbs->curPos(pgd->x, pgd->y);
+				pbs->frameNum = curImage;
+			}
+		}
+	}
+
+	// unpack the animated bobs
+	_numFurnitureAnimated = 0;
+	_numFurnitureAnimatedLen = 0;
+	uint16 curBob = 0;
+	for  (i = 1; i <= furnitureCount; ++i) {
+		int16 obj = furniture[i];
+		if (obj > 0 && obj <= 5000) {
+			GraphicData *pgd = _vm->logic()->graphicData(obj);
+
+			bool rebound = false;
+			int16 lastFrame = pgd->lastFrame;
+			if (lastFrame < 0) {
+				rebound = true;
+				lastFrame = -lastFrame;
+			}
+
+			if (lastFrame > 0) {
+				_numFurnitureAnimatedLen += lastFrame - pgd->firstFrame + 1;
+				++_numFurnitureAnimated;
+				uint16 image = curImage + 1;
+				int k;
+				for (k = pgd->firstFrame; k <= lastFrame; ++k) {
+					++curImage;
+					_vm->bankMan()->unpack(k, curImage, 15);
+					++_numFrames;
+				}
+				BobSlot *pbs = bob(5 + curBob);
+				pbs->animNormal(image, curImage, pgd->speed / 4, rebound, false);
+				pbs->curPos(pgd->x, pgd->y);
+				++curBob;
+			}
+		}
+	}
+
+	// unpack the paste downs
+	for  (i = 1; i <= furnitureCount; ++i) {
+		if (furniture[i] > 5000) {;
+			bobPaste(furniture[i] - 5000, curImage + 1);
+		}
+	}
+}
+
+
+void Graphics::setupRoomObjects() {
+	uint16 i;
+	// furniture frames are reserved in ::setupRoomFurniture(), we append objects 
+	// frames after the furniture ones.
+	uint16 curImage = 36 + FRAMES_JOE_XTRA + _numFurnitureStatic + _numFurnitureAnimatedLen;
+	uint16 firstRoomObj = _vm->logic()->currentRoomData() + 1;
+	uint16 lastRoomObj = _vm->logic()->roomData(_vm->logic()->currentRoom() + 1);
+	uint16 numObjectStatic = 0;
+	uint16 numObjectAnimated = 0;
+	uint16 curBob;
+
+	// invalidates all Bobs for persons (except Joe's one)
+	for (i = 1; i <= 3; ++i) {
+		_bobs[i].active = false;
+	}
+
+	// static/animated Bobs
+	for (i = firstRoomObj; i <= lastRoomObj; ++i) {
+		ObjectData *pod = _vm->logic()->objectData(i);
+		// setup blanks bobs for turned off objects (in case 
+		// you turn them on again)
+		if (pod->image == -1) {
+			// static OFF Bob
+			curBob = 20 + _numFurnitureStatic + numObjectStatic;
+			++numObjectStatic;
+			// create a blank frame for the OFF object
+			++_numFrames;
+			++curImage;
+		} else if(pod->image == -2) {
+			// animated OFF Bob
+			curBob = 5 + _numFurnitureAnimated + numObjectAnimated;
+			++numObjectAnimated;
+		} else if(pod->image > 0 && pod->image < 5000) {
+			GraphicData *pgd = _vm->logic()->graphicData(pod->image);
+			int16 lastFrame = pgd->lastFrame;
+			bool rebound = false;
+			if (lastFrame < 0) {
+				lastFrame = -lastFrame;
+				rebound = true;
+			}
+			if (pgd->firstFrame < 0) {
+				// XXX if(TEMPA[1]<0) bobs[CURRBOB].xflip=1;
+				curBob = 5 + _numFurnitureAnimated;
+				setupObjectAnim(pgd, curImage + 1, curBob + numObjectAnimated, pod->name > 0);
+				curImage += pgd->lastFrame;
+				++numObjectAnimated;
+			} else if (lastFrame != 0) {
+				// animated objects
+				uint16 j;
+				uint16 firstFrame = curImage + 1;
+				for (j = pgd->firstFrame; j <= lastFrame; ++j) {
+					++curImage;
+					_vm->bankMan()->unpack(j, curImage, 15);
+					++_numFrames;
+				}
+				curBob = 5 + _numFurnitureAnimated + numObjectAnimated;
+				if (pod->name > 0) {
+					BobSlot *pbs = bob(curBob);
+					pbs->curPos(pgd->x, pgd->y);
+					pbs->frameNum = firstFrame;
+					if (pgd->speed > 0) {
+						pbs->animNormal(firstFrame, curImage, pgd->speed / 4, rebound, false);
+					}
+				}
+				++numObjectAnimated;
+			} else {
+				// static objects
+				curBob = 20 + _numFurnitureStatic + numObjectStatic;
+				++curImage;
+				bobClear(curBob);
+
+				// XXX if((COMPANEL==2) && (FULLSCREEN==1)) bobs[CURRBOB].y2=199;
+
+				_vm->bankMan()->unpack(pgd->firstFrame, curImage, 15);
+				++_numFrames;
+				if (pod->name > 0) {
+					BobSlot *pbs = bob(curBob);
+					pbs->curPos(pgd->x, pgd->y);
+					pbs->frameNum = curImage;
+				}
+				++numObjectStatic;
+			}
+		}
+	}
+
+	// persons Bobs
+	for (i = firstRoomObj; i <= lastRoomObj; ++i) {
+		ObjectData *pod = _vm->logic()->objectData(i);
+		if (pod->image == -3 || pod->image == -4) {
+			debug(6, "Graphics::setupRoomObjects() - Setting up person %X, name=%X", i, pod->name);
+			uint16 noun = i - _vm->logic()->currentRoomData();
+			if (pod->name > 0) {
+				curImage = setupPerson(noun, curImage);
+			} else {
+				curImage = allocPerson(noun, curImage);
+			}
+		}
+	}
+
+	// paste downs list
+	++curImage;
+	_numFrames = curImage;
+	for (i = firstRoomObj; i <= lastRoomObj; ++i) {
+		ObjectData *pod = _vm->logic()->objectData(i);
+		if (pod->name > 0 && pod->image > 5000) {
+			bobPaste(pod->image - 5000, curImage);
+		}
+	}
+}
+
+
+uint16 Graphics::setupPerson(uint16 noun, uint16 curImage) {
+	if (noun == 0) {
+		warning("Trying to setup person 0");
+		return curImage;
+	}
+
+	Person p;
+	_vm->logic()->initPerson(noun, "", true, &p);
+
+	const ActorData *pad = p.actor;
+	uint16 scale = 100;
+	uint16 a = _vm->grid()->findAreaForPos(GS_ROOM, pad->x, pad->y);
+	if (a != 0) {
+		// person is not standing in the area box, scale it accordingly
+		scale = _vm->grid()->area(_vm->logic()->currentRoom(), a)->calcScale(pad->y);
+	}
+
+	_vm->bankMan()->unpack(pad->bobFrameStanding, p.bobFrame, p.actor->bankNum);
+	uint16 obj = _vm->logic()->currentRoomData() + noun;
+	BobSlot *pbs = bob(pad->bobNum);
+	pbs->curPos(pad->x, pad->y);
+	pbs->scale = scale;
+	pbs->frameNum = p.bobFrame;
+	pbs->xflip = (_vm->logic()->objectData(obj)->image == -3); // person is facing left
+
+	debug(6, "Graphics::setupPerson(%d, %d) - bob = %d name = %s", noun, curImage, pad->bobNum, p.name);
+
+	if (p.anim != NULL) {		
+		curImage = setupPersonAnim(pad, p.anim, curImage);
+	} else {
+		erasePersonAnim(pad->bobNum);
+	}
+	return curImage;
+}
+
+
+uint16 Graphics::allocPerson(uint16 noun, uint16 curImage) {
+	Person p;
+	_vm->logic()->initPerson(noun, "", false, &p);
+	if (p.anim != NULL) {
+		curImage += countAnimFrames(p.anim);
+		_personFrames[p.actor->bobNum] = curImage + 1;
+	}
+	return curImage;
+}
+
+
+void Graphics::update(uint16 room) {
+	bobSortAll();
+	if (_cameraBob >= 0) {
+		_vm->display()->horizontalScrollUpdate(_bobs[_cameraBob].x);
+	}
+	bobCustomParallax(room);
+	_vm->display()->prepareUpdate();
+	bobDrawAll();
+	textDrawAll();
+}
+
+
+
+BamScene::BamScene(QueenEngine *vm)
+	: _flag(F_STOP), _screenShaked(false), _fightData(_fight1Data), _vm(vm) {
+}
+
+
+void BamScene::prepareAnimation() {
+	_obj1 = _vm->graphics()->bob(BOB_OBJ1);
+	_vm->graphics()->bobClear(BOB_OBJ1);
+	_obj1->active = true;
+
+	_obj2 = _vm->graphics()->bob(BOB_OBJ2);
+	_vm->graphics()->bobClear(BOB_OBJ2);
+	_obj2->active = true;
+
+	_objfx = _vm->graphics()->bob(BOB_FX);
+	_vm->graphics()->bobClear(BOB_FX);
+	_objfx->active = true;
+
+	_index = 0;
+}
+
+
 void BamScene::updateCarAnimation() {
 	if (_flag != F_STOP) {
 		const BamDataBlock *bdb = &_carData[_index];
@@ -818,159 +1305,6 @@
 			break;
 		}
 	}
-}
-
-
-void Graphics::update(uint16 room) {
-	bobSortAll();
-	if (_cameraBob >= 0) {
-		_vm->display()->horizontalScrollUpdate(_bobs[_cameraBob].x);
-	}
-	bobCustomParallax(room);
-	_vm->display()->prepareUpdate();
-	bobDrawAll();
-	textDrawAll();
-}
-
-void Graphics::bobSetText(
-		BobSlot *pbs, 
-		const char *text, 
-		int textX, int textY, 
-		int color, int flags) {
-	// function MAKE_SPEAK_BOB, lines 335-457 in talk.c
-
-	if (text[0] == '\0')
-		return;
-
-	// debug(0, "makeSpeakBob('%s', (%i,%i), %i, %i, %i, %i);", 
-	//		text, bob->x, bob->y, textX, textY, color, flags);
-
-	// Duplicate string and append zero if needed
-
-	char textCopy[MAX_STRING_SIZE];
-
-	int length = strlen(text);
-	memcpy(textCopy, text, length);
-
-	if (textCopy[length - 1] >= 'A')
-		textCopy[length++] = '.';
-
-	textCopy[length] = '\0';
-
-	// Split text into lines
-
-	char lines[8][MAX_STRING_SIZE];
-	int lineCount = 0;
-	int wordCount = 0;
-	int lineLength = 0;
-	int i;
-
-	for (i = 0; i < length; i++) {
-		if (textCopy[i] == ' ')
-			wordCount++;
-
-		lineLength++;
-
-		if ((lineLength > 20 && textCopy[i] == ' ') || i == (length-1)) {
-			memcpy(lines[lineCount], textCopy + i + 1 - lineLength, lineLength);
-			lines[lineCount][lineLength] = '\0';
-			lineCount++;
-			lineLength = 0;
-		}
-	}
-
-
-	// Plan: write each line to Screen 2, put black outline around lines and
-	// pick them up as a BOB.
-
-
-	// Find width of widest line 
-
-	int maxLineWidth = 0;
-
-	for (i = 0; i < lineCount; i++) {
-		int width = textWidth(lines[i]);
-		if (maxLineWidth < width)
-			maxLineWidth = width;
-	}
-
-	// Calc text position
-
-	short x, y, width, height;
-
-	if (flags) {
-		if (flags == 2)
-			x = 160 - maxLineWidth / 2;
-		else
-			x = textX;
-
-		y = textY;
-
-		width = 0;
-	} else {
-		x = pbs->x;
-		y = pbs->y;
-
-		BobFrame *pbf = _vm->bankMan()->fetchFrame(pbs->frameNum);
-
-		width  = (pbf->width  * pbs->scale) / 100;
-		height = (pbf->height * pbs->scale) / 100;
-
-		y = y - height - 16 - lineCount * 9;
-	}
-
-	x -= _vm->display()->horizontalScroll();
-
-	if (y < 0) {
-		y = 0;
-
-		if (x < 160)
-			x += width / 2;
-		else
-			x -= width / 2 + maxLineWidth;
-	} else if (!flags)
-		x -= maxLineWidth / 2;
-
-	if (x < 0)
-		x = 4;
-	else if ((x + maxLineWidth) > 320)
-		x = 320 - maxLineWidth - 4;
-
-	textCurrentColor(color);
-
-	for (i = 0; i < lineCount; i++) {
-		int lineX = x + (maxLineWidth - textWidth(lines[i])) / 2;
-
-		//debug(0, "Setting text '%s' at (%i, %i)", lines[i], lineX, y + 9 * i);
-		textSet(lineX, y + 9 * i, lines[i]);
-	}
-}
-
-int Graphics::textCenterX(const char *text) const {
-	return 160 - textWidth(text) / 2;
-}
-
-
-
-BamScene::BamScene(QueenEngine *vm)
-	: _flag(F_STOP), _screenShaked(false), _fightData(_fight1Data), _vm(vm) {
-}
-
-
-void BamScene::prepareAnimation() {
-	_obj1 = _vm->graphics()->bob(BOB_OBJ1);
-	_vm->graphics()->bobClear(BOB_OBJ1);
-	_obj1->active = true;
-
-	_obj2 = _vm->graphics()->bob(BOB_OBJ2);
-	_vm->graphics()->bobClear(BOB_OBJ2);
-	_obj2->active = true;
-
-	_objfx = _vm->graphics()->bob(BOB_FX);
-	_vm->graphics()->bobClear(BOB_FX);
-	_objfx->active = true;
-
-	_index = 0;
 }
 
 

Index: graphics.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- graphics.h	8 Jan 2004 16:41:03 -0000	1.57
+++ graphics.h	8 Jan 2004 22:46:42 -0000	1.58
@@ -114,13 +114,9 @@
 
 	void bobCustomParallax(uint16 roomNum); // CHECK_PARALLAX()
 
-	void bobSetText(
-		BobSlot *bob, 
-		const char *text, 
-		int textX, int textY, 
-		int color, int flags);	// MAKE_SPEAK_BOB
+	void bobSetText(BobSlot *bob, const char *text, int textX, int textY, int color, int flags);
 
-	void textCurrentColor(uint8 color); // ink()
+	void textCurrentColor(uint8 color) { _curTextColor = color; }
 	void textSet(uint16 x, uint16 y, const char *text, bool outlined = true); // text()
 	void textSetCentered(uint16 y, const char *text, bool outlined = true);
 	void textDrawAll(); // drawtext()
@@ -129,6 +125,8 @@
 	int textCenterX(const char *text) const; // MIDDLE()
 	void textColor(uint16 y, uint8 color) { _texts[y].color = color; }
 
+	void setupNewRoom(const char *room, uint16 roomNum, int16 *furniture, uint16 furnitureCount);
+
 	void fillAnimBuffer(const char *anim, AnimFrame *af);
 	uint16 countAnimFrames(const char *anim);
 	void setupObjectAnim(const GraphicData *gd, uint16 firstImage, uint16 bobNum, bool visible);
@@ -137,10 +135,26 @@
 	void erasePersonAnim(uint16 bobNum);
 	void eraseAllAnims();
 
+	uint16 refreshObject(uint16 obj);
+
+	void setupRoomFurniture(int16 *furniture, uint16 furnitureCount);
+	void setupRoomObjects();
+
+	uint16 setupPerson(uint16 noun, uint16 curImage);
+	uint16 allocPerson(uint16 noun, uint16 curImage);
+
+	uint16 personFrames(uint16 bobNum) const { return _personFrames[bobNum]; }
+	void clearPersonFrames() { memset(_personFrames, 0, sizeof(_personFrames)); }
+	uint16 numFrames() const { return _numFrames; }
+	uint16 numStaticFurniture() const { return _numFurnitureStatic; }
+	uint16 numAnimatedFurniture() const { return _numFurnitureAnimated; }
+	uint16 numFurnitureFrames() const { return _numFurnitureStatic + _numFurnitureAnimatedLen; }
+
 	void putCameraOnBob(int bobNum) { _cameraBob = bobNum; }
 
 	void update(uint16 room);
 
+
 	enum {
 		MAX_BOBS_NUMBER     =  64,
 		MAX_STRING_LENGTH   = 255,
@@ -166,6 +180,20 @@
 	uint8 _curTextColor;
 
 	AnimFrame _newAnim[17][30];
+
+	uint16 _personFrames[4];
+
+	//! Number of animated furniture in current room
+	uint16 _numFurnitureAnimated;
+
+	//! Number of static furniture in current room
+	uint16 _numFurnitureStatic;
+
+	//! Total number of frames for the animated furniture
+	uint16 _numFurnitureAnimatedLen;
+
+	//! Current number of frames unpacked
+	uint16 _numFrames;
 
 	int _cameraBob;
 

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.164
retrieving revision 1.165
diff -u -d -r1.164 -r1.165
--- logic.cpp	8 Jan 2004 16:41:03 -0000	1.164
+++ logic.cpp	8 Jan 2004 22:46:42 -0000	1.165
@@ -258,10 +258,8 @@
 }
 
 
-uint16 Logic::findBob(uint16 obj) {
-	uint16 i;
+uint16 Logic::findBob(uint16 obj) {	
 	uint16 bobnum = 0;
-	uint16 bobtype = 0; // 1 for animated, 0 for static
 
 	if (obj > _numObjects)
 		error("Object index (%i) > _numObjects (%i)", obj, _numObjects);
@@ -276,13 +274,10 @@
 	if(img != 0) {
 		if(img == -3 || img == -4) {
 			// a person object
-			for(i = _roomData[room] + 1; i <= obj; ++i) {
-				img = _objectData[i].image;
-				if(img == -3 || img == -4) {
-					++bobnum;
-				}
-			}
+			bobnum = findPersonNumber(obj);
 		} else {
+			uint16 bobtype = 0; // 1 for animated, 0 for static
+
 			if(img <= -10) {
 				// object has been turned off, but the image order hasn't been updated
 				if(_graphicData[-(img + 10)].lastFrame != 0) {
@@ -299,6 +294,7 @@
 
 			uint16 idxAnimated = 0;
 			uint16 idxStatic = 0;
+			uint16 i;
 			for(i = _roomData[room] + 1; i <= obj; ++i) {
 				img = _objectData[i].image;
 				if(img <= -10) {
@@ -329,12 +325,12 @@
 			if(bobtype == 0) {
 				// static bob
 				if(idxStatic > 0) {
-					bobnum = 19 + _numFurnitureStatic + idxStatic;
+					bobnum = 19 + _vm->graphics()->numStaticFurniture() + idxStatic;
 				}
 			} else {
 				// animated bob
 				if(idxAnimated > 0) {
-					bobnum = 4 + _numFurnitureAnimated + idxAnimated;
+					bobnum = 4 + _vm->graphics()->numAnimatedFurniture() + idxAnimated;
 				}
 			}
 		}
@@ -350,13 +346,7 @@
 	uint16 room = _objectData[obj].room;
 	int16 img = _objectData[obj].image;
 	if(img == -3 || img == -4) {
-		uint16 bobnum = 0;
-		for(i = _roomData[room] + 1; i <= obj; ++i) {
-			img = _objectData[i].image;
-			if(img == -3 || img == -4) {
-				++bobnum;
-			}
-		}
+		uint16 bobnum = findPersonNumber(obj);
 		if(bobnum <= 3) {
 			framenum = 29 + FRAMES_JOE_XTRA + bobnum;
 		}
@@ -405,7 +395,7 @@
 
 		// calculate only if there are person frames
 		if(idx > 0) {
-			framenum = 36 + FRAMES_JOE_XTRA + _numFurnitureStatic + _numFurnitureAnimatedLen + idx;
+			framenum = 36 + FRAMES_JOE_XTRA + _vm->graphics()->numFurnitureFrames() + idx;
 		}
 	}
 	return framenum;
@@ -482,10 +472,7 @@
 	}
 
 	// invalidates all persons animations
-	uint16 i;
-	for (i = 0; i <= 3; ++i) {
-		_personFrames[i] = 0;
-	}
+	_vm->graphics()->clearPersonFrames();
 	_vm->graphics()->eraseAllAnims();
 
 	uint16 cur = _roomData[_oldRoom] + 1;
@@ -509,303 +496,6 @@
 }
 
 
-void Logic::roomSetupFurniture() {
-	int16 gstate[9];
-	_numFurnitureStatic = 0;
-	_numFurnitureAnimated = 0;
-	_numFurnitureAnimatedLen = 0;
-	uint16 curImage = 36 + FRAMES_JOE_XTRA;
-
-	// count the furniture and update gameState
-	uint16 furnitureTotal = 0;
-	uint16 i;
-	for (i = 1; i <= _numFurniture; ++i) {
-		if (_furnitureData[i].room == _currentRoom) {
-			++furnitureTotal;
-			gstate[furnitureTotal] = _furnitureData[i].gameStateValue;
-		}
-	}
-	if (furnitureTotal == 0) {
-		return;
-	}
-
-	// unpack the furniture from the bank 15
-	// there are 3 kinds :
-	// - static (bobs), gamestate range = ]0;5000]
-	// - animated (bobs), gamestate range = ]0;5000]
-	// - static (paste downs), gamestate range = [5000; [
-
-	// unpack the static bobs
-	for	(i = 1; i <= furnitureTotal; ++i) {
-		int16 obj = gstate[i];
-		if (obj > 0 && obj <= 5000) {
-			GraphicData *pgd = &_graphicData[obj];
-			if (pgd->lastFrame == 0) {
-				++_numFurnitureStatic;
-				++curImage;
-				_vm->bankMan()->unpack(pgd->firstFrame, curImage, 15);
-				++_numFrames;
-				BobSlot *pbs = _vm->graphics()->bob(19 + _numFurnitureStatic);
-				pbs->curPos(pgd->x, pgd->y);
-				pbs->frameNum = curImage;
-			}
-		}
-	}
-
-	// unpack the animated bobs
-	uint16 curBob = 0;
-	for  (i = 1; i <= furnitureTotal; ++i) {
-		int16 obj = gstate[i];
-		if (obj > 0 && obj <= 5000) {
-			GraphicData *pgd = &_graphicData[obj];
-
-			bool rebound = false;
-			int16 lastFrame = pgd->lastFrame;
-			if (lastFrame < 0) {
-				rebound = true;
-				lastFrame = -lastFrame;
-			}
-
-			if (lastFrame > 0) {
-				_numFurnitureAnimatedLen += lastFrame - pgd->firstFrame + 1;
-				++_numFurnitureAnimated;
-				uint16 image = curImage + 1;
-				int k;
-				for (k = pgd->firstFrame; k <= lastFrame; ++k) {
-					++curImage;
-					_vm->bankMan()->unpack(k, curImage, 15);
-					++_numFrames;
-				}
-				BobSlot *pbs = _vm->graphics()->bob(5 + curBob);
-				pbs->animNormal(image, curImage, pgd->speed / 4, rebound, false);
-				pbs->curPos(pgd->x, pgd->y);
-				++curBob;
-			}
-		}
-	}
-
-	// unpack the paste downs
-	++curImage;
-	for  (i = 1; i <= furnitureTotal; ++i) {
-		if (gstate[i] > 5000) {;
-			_vm->graphics()->bobPaste(gstate[i] - 5000, curImage);
-		}
-	}
-}
-
-
-void Logic::roomSetupObjects() {
-	uint16 i;
-	// furniture frames are reserved in ::roomSetupFurniture(), we append objects 
-	// frames after the furniture ones.
-	uint16 curImage = 36 + FRAMES_JOE_XTRA + _numFurnitureStatic + _numFurnitureAnimatedLen;
-	uint16 firstRoomObj = currentRoomData() + 1;
-	uint16 lastRoomObj = _roomData[_currentRoom + 1];
-	uint16 numObjectStatic = 0;
-	uint16 numObjectAnimated = 0;
-	uint16 curBob;
-
-	// invalidates all Bobs for persons (except Joe's one)
-	for (i = 1; i <= 3; ++i) {
-		_vm->graphics()->bob(i)->active = false;
-	}
-
-	// static/animated Bobs
-	for (i = firstRoomObj; i <= lastRoomObj; ++i) {
-		ObjectData *pod = &_objectData[i];
-		// setup blanks bobs for turned off objects (in case 
-		// you turn them on again)
-		if (pod->image == -1) {
-			// static OFF Bob
-			curBob = 20 + _numFurnitureStatic + numObjectStatic;
-			++numObjectStatic;
-			// create a blank frame for the for the OFF object
-			++_numFrames;
-			++curImage;
-		} else if(pod->image == -2) {
-			// animated OFF Bob
-			curBob = 5 + _numFurnitureAnimated + numObjectAnimated;
-			++numObjectAnimated;
-		} else if(pod->image > 0 && pod->image < 5000) {
-			GraphicData *pgd = &_graphicData[pod->image];
-			int16 lastFrame = pgd->lastFrame;
-			bool rebound = false;
-			if (lastFrame < 0) {
-				lastFrame = -lastFrame;
-				rebound = true;
-			}
-			if (pgd->firstFrame < 0) {
-				// FIXME: if(TEMPA[1]<0) bobs[CURRBOB].xflip=1;
-				curBob = 5 + _numFurnitureAnimated;
-				_vm->graphics()->setupObjectAnim(pgd, curImage + 1, curBob + numObjectAnimated, pod->name > 0);
-				curImage += pgd->lastFrame;
-				++numObjectAnimated;
-			} else if (lastFrame != 0) {
-				// animated objects
-				uint16 j;
-				uint16 firstFrame = curImage + 1;
-				for (j = pgd->firstFrame; j <= lastFrame; ++j) {
-					++curImage;
-					_vm->bankMan()->unpack(j, curImage, 15);
-					++_numFrames;
-				}
-				curBob = 5 + _numFurnitureAnimated + numObjectAnimated;
-				if (pod->name > 0) {
-					BobSlot *pbs = _vm->graphics()->bob(curBob);
-					pbs->curPos(pgd->x, pgd->y);
-					pbs->frameNum = firstFrame;
-					if (pgd->speed > 0) {
-						pbs->animNormal(firstFrame, curImage, pgd->speed / 4, rebound, false);
-					}
-				}
-				++numObjectAnimated;
-			} else {
-				// static objects
-				curBob = 20 + _numFurnitureStatic + numObjectStatic;
-				++curImage;
-				_vm->graphics()->bobClear(curBob);
-
-				// FIXME: if((COMPANEL==2) && (FULLSCREEN==1)) bobs[CURRBOB].y2=199;
-
-				_vm->bankMan()->unpack(pgd->firstFrame, curImage, 15);
-				++_numFrames;
-				if (pod->name > 0) {
-					BobSlot *pbs = _vm->graphics()->bob(curBob);
-					pbs->curPos(pgd->x, pgd->y);
-					pbs->frameNum = curImage;
-				}
-				++numObjectStatic;
-			}
-		}
-	}
-
-	// persons Bobs
-	for (i = firstRoomObj; i <= lastRoomObj; ++i) {
-		ObjectData *pod = &_objectData[i];
-		if (pod->image == -3 || pod->image == -4) {
-			debug(6, "Logic::roomSetupObjects() - Setting up person %X, name=%X", i, pod->name);
-			uint16 noun = i - currentRoomData();
-			if (pod->name > 0) {
-				curImage = setupPersonInRoom(noun, curImage);
-			} else {
-				curImage = countPersonFrames(noun, curImage);
-			}
-		}
-	}
-
-	// paste downs list
-	++curImage;
-	_numFrames = curImage;
-	for (i = firstRoomObj; i <= lastRoomObj; ++i) {
-		ObjectData *pod = &_objectData[i];
-		if (pod->name > 0 && pod->image > 5000) {
-			_vm->graphics()->bobPaste(pod->image - 5000, curImage);
-		}
-	}
-}
-
-
-uint16 Logic::roomRefreshObject(uint16 obj) {
-	uint16 curImage = _numFrames;
-
-	if (obj == 0 || obj > _numObjects) {
-		warning("Invalid object number %d", obj);
-		return curImage;
-	}
-
-	ObjectData *pod = &_objectData[obj];
-	if (pod->image == 0) {
-		return curImage;
-	}
-
-	debug(6, "Logic::roomRefreshObject(%X, %s)", obj, _objName[ABS(pod->name)]);
-
-	// check the object is in the current room
-	if (pod->room != _currentRoom) {
-		debug(6, "Refreshing an object (%i=%s) not in current room (object room=%i, current room=%i)", obj, _objName[ABS(pod->name)], pod->room, _currentRoom);
-		return curImage;
-	}
-
-	// find bob for the object
-	uint16 curBob = findBob(obj);
-	BobSlot *pbs = _vm->graphics()->bob(curBob);
-
-	if (pod->image == -3 || pod->image == -4) {
-		// a person object
-		if (pod->name <= 0) {
-			_vm->graphics()->bobClear(curBob);
-		} else {
-			// find person number
-			uint16 pNum = 1;
-			uint16 i = currentRoomData() + 1;
-			while (i < obj) {
-				if (_objectData[i].image == -3 || _objectData[i].image == -4) {
-					++pNum;
-				}
-				++i;
-			}
-			curImage = _personFrames[pNum] - 1;
-			if (_personFrames[pNum] == 0) {
-				curImage = _numFrames;
-				_personFrames[pNum] = curImage;
-			}
-			curImage = setupPersonInRoom(obj - currentRoomData(), curImage);
-		}
-		return curImage;
-	}
-
-	// find frame used for object
-	curImage = findFrame(obj);
-
-	if (pod->name < 0 || pod->image < 0) {
-		// object is hidden or disabled
-		_vm->graphics()->bobClear(curBob);
-		return curImage;
-	}
-
-	int image = pod->image;
-	if (image > 5000) {
-		image -= 5000;
-	}
-	
-	GraphicData *pgd = &_graphicData[image];
-	bool rebound = false;
-	int16 lastFrame = pgd->lastFrame;
-	if (lastFrame < 0) {
-		lastFrame = -lastFrame;
-		rebound = true;
-	}
-	if (pgd->firstFrame < 0) {
-		_vm->graphics()->setupObjectAnim(pgd, curImage, curBob, pod->name != 0);
-		curImage += pgd->lastFrame - 1;
-	} else if (lastFrame != 0) {
-		// turn on an animated bob
-		_vm->bankMan()->unpack(pgd->firstFrame, 2, 15);
-		pbs->animating = false;
-		uint16 firstImage = curImage;
-		--curImage;
-		uint16 j;
-		for (j = pgd->firstFrame; j <= lastFrame; ++j) {
-			++curImage;
-			_vm->bankMan()->unpack(j, curImage, 15);
-		}
-		pbs->curPos(pgd->x, pgd->y);
-		pbs->frameNum = firstImage;
-		if (pgd->speed > 0) {
-			pbs->animNormal(firstImage, curImage, pgd->speed / 4, rebound, false);
-		}
-	} else {
-		// frame 2 is used as a buffer frame to prevent BOB flickering
-		_vm->bankMan()->unpack(pgd->firstFrame, 2, 15);
-		_vm->bankMan()->unpack(pgd->firstFrame, curImage, 15);
-		pbs->curPos(pgd->x, pgd->y);
-		pbs->frameNum = curImage;
-	}
-
-	return curImage;
-}
-
-
 void Logic::roomSetup(const char *room, int comPanel, bool inCutaway) {
 	// load backdrop image, init dynalum, setup colors
 	_vm->display()->setupNewRoom(room, _currentRoom);
@@ -813,23 +503,18 @@
 	// setup graphics to enter fullscreen/panel mode
 	_vm->display()->screenMode(comPanel, inCutaway);
 
-	// reset sprites table (bounding box...)
-	_vm->graphics()->bobClearAll();
-
-	// load/setup objects associated to this room
-	char filename[20];	
-	sprintf(filename, "%s.BBK", room);
-	_vm->bankMan()->load(filename, 15);
-
-	_numFrames = 37 + FRAMES_JOE_XTRA;
-	roomSetupFurniture();
-	roomSetupObjects();
+	_vm->grid()->setupNewRoom(_currentRoom, _roomData[_currentRoom]);
 
-	if (_currentRoom >= 90) {
-		_vm->graphics()->putCameraOnBob(0);
+	int16 furn[9];
+	uint16 furnTot = 0;
+	for (uint16 i = 1; i <= _numFurniture; ++i) {
+		if (_furnitureData[i].room == _currentRoom) {
+			++furnTot;
+			furn[furnTot] = _furnitureData[i].gameStateValue;
+		}
 	}
+	_vm->graphics()->setupNewRoom(room, _currentRoom, furn, furnTot);
 
-	_vm->grid()->setupNewRoom(_currentRoom, _roomData[_currentRoom]);
 	_vm->display()->forceFullRefresh();
 
 }
@@ -869,17 +554,11 @@
 	}
 
 	// search Bob number for the person
-	uint16 i;
-	uint16 bobNum = 0;
-	for (i = currentRoomData() + 1; i <= obj; ++i) {
-		img = _objectData[i].image;
-		if (img == -3 || img == -4) {
-			++bobNum;
-		}
-	}
+	uint16 bobNum = findPersonNumber(obj);
 
 	// search for a matching actor
 	if (bobNum > 0) {
+		uint16 i;
 		for (i = 1; i <= _numActors; ++i) {
 			ActorData *pad = &_actorData[i];
 			if (pad->room == _currentRoom && gameState(pad->gsSlot) == pad->gsValue) {
@@ -916,50 +595,16 @@
 }
 
 
-uint16 Logic::setupPersonInRoom(uint16 noun, uint16 curImage) {
-	if (noun == 0) {
-		warning("Trying to setup person 0");
-		return curImage;
-	}
-
-	Person p;
-	initPerson(noun, "", true, &p);
-
-	const ActorData *pad = p.actor;
-	uint16 scale = 100;
-	uint16 a = _vm->grid()->findAreaForPos(GS_ROOM, pad->x, pad->y);
-	if (a > 0) {
-		// person is not standing in the area box, scale it accordingly
-		scale = _vm->grid()->area(_currentRoom, a)->calcScale(pad->y);
-	}
-
-	_vm->bankMan()->unpack(pad->bobFrameStanding, p.bobFrame, p.actor->bankNum);
-	uint16 obj = currentRoomData() + noun;
-	BobSlot *pbs = _vm->graphics()->bob(pad->bobNum);
-	pbs->curPos(pad->x, pad->y);
-	pbs->scale = scale;
-	pbs->frameNum = p.bobFrame;
-	pbs->xflip = (_objectData[obj].image == -3); // person is facing left
-
-	debug(6, "Logic::personSetup(%d, %d) - bob = %d name = %s", noun, curImage, pad->bobNum, p.name);
-
-	if (p.anim != NULL) {
-		_personFrames[pad->bobNum] = curImage + 1;
-		curImage = _vm->graphics()->setupPersonAnim(pad, p.anim, curImage);
-	} else {
-		_vm->graphics()->erasePersonAnim(pad->bobNum);
-	}
-	return curImage;
-}
-
-
-uint16 Logic::countPersonFrames(uint16 noun, uint16 curImage) {
-	ActorData *pad = findActor(noun);
-	if (pad != NULL && pad->anim != 0) {
-		curImage += _vm->graphics()->countAnimFrames(_aAnim[pad->anim]);
-		_personFrames[pad->bobNum] = curImage + 1;
+uint16 Logic::findPersonNumber(uint16 obj) const {
+	uint16 num = 0;
+	uint16 i;
+	for (i = currentRoomData() + 1; i <= obj; ++i) {
+		int16 img = _objectData[i].image;
+		if (img == -3 || img == -4) {
+			++num;
+		}
 	}
-	return curImage;
+	return num;
 }
 
 
@@ -2231,7 +1876,7 @@
 	lightningBob->y = 0;
 
 	// 23/2/95 - Play lightning SFX
-	_vm->sound()->playSfx(_vm->logic()->currentRoomSfx());
+	_vm->sound()->playSfx(currentRoomSfx());
 
 	_vm->bankMan()->unpack(18, lightningBob->frameNum, 15);
 	_vm->bankMan()->unpack(4,  planeBob    ->frameNum, 15);

Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.h,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -d -r1.107 -r1.108
--- logic.h	8 Jan 2004 16:41:03 -0000	1.107
+++ logic.h	8 Jan 2004 22:46:42 -0000	1.108
@@ -139,22 +139,15 @@
 	const char *objectTextualDescription(uint16 objNum) const { return _objDescription[objNum]; }
 
 	void roomErase();
-	void roomSetupFurniture();
-	void roomSetupObjects();
-	uint16 roomRefreshObject(uint16 obj);
 	void roomSetup(const char *room, int comPanel, bool inCutaway);
 	void roomDisplay(uint16 room, RoomDisplayMode mode, uint16 joeScale, int comPanel, bool inCutaway);
 
 	int16 entryObj() const { return _entryObj; }
 	void entryObj(int16 obj) { _entryObj = obj; }
 
-	uint16 numFrames() const { return _numFrames; }
-
 	ActorData *findActor(uint16 noun, const char *name = NULL);
 	void initPerson(int16 noun, const char *actorName, bool loadBank, Person *pp);
-	uint16 setupPersonInRoom(uint16 noun, uint16 curImage);
-	uint16 countPersonFrames(uint16 noun, uint16 curImage);
-	uint16 personFrames(uint16 bobNum) const { return _personFrames[bobNum]; }
+	uint16 findPersonNumber(uint16 obj) const;
 
 	void loadJoeBanks(const char *animBank, const char *standBank);
 
@@ -357,21 +350,6 @@
 	int16 _gameState[GAME_STATE_COUNT];
 
 	TalkSelected _talkSelected[TALK_SELECTED_COUNT];
-	
-	//! Number of animated furniture in current room
-	uint16 _numFurnitureAnimated;
-
-	//! Number of static furniture in current room
-	uint16 _numFurnitureStatic;
-
-	//! Total number of frames for the animated furniture
-	uint16 _numFurnitureAnimatedLen;
-
-	//! Current number of frames unpacked
-	uint16 _numFrames;
-
-	//! Last frame number used for person animation
-	uint16 _personFrames[4];
 
 	//! Inventory items
 	int16 _inventoryItem[4];

Index: talk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- talk.cpp	8 Jan 2004 14:10:32 -0000	1.72
+++ talk.cpp	8 Jan 2004 22:46:42 -0000	1.73
@@ -590,7 +590,7 @@
 				if (0 == strcmp(person->name, "JOE"))
 					_vm->walk()->moveJoe(0, x, y, _vm->input()->cutawayRunning());
 				else
-					_vm->walk()->movePerson(person, x, y, _vm->logic()->numFrames(), 0);
+					_vm->walk()->movePerson(person, x, y, _vm->graphics()->numFrames(), 0);
 				index += 11;
 				// if(JOEWALK==3) CUTQUIT=0;
 				// XXX personWalking = true;
@@ -737,9 +737,9 @@
 
 			offset += 4;
 
-			_vm->bankMan()->unpack(frame, _vm->logic()->numFrames(), bankNum);
+			_vm->bankMan()->unpack(frame, _vm->graphics()->numFrames(), bankNum);
 
-			bob2->frameNum = _vm->logic()->numFrames();
+			bob2->frameNum = _vm->graphics()->numFrames();
 			bob2->scale = 100;
 			bob2->active = true;
 			bob2->x = x;
@@ -984,7 +984,7 @@
 			// Dont turn AMAL animation off, and dont manually anim person
 			command = SPEAK_ORACLE;
 			oracle = true;
-			uint16 frameNum = _vm->logic()->personFrames(bobNum);
+			uint16 frameNum = _vm->graphics()->personFrames(bobNum);
 			for (i = 5; i <= 8; ++i) {
 				_vm->bankMan()->unpack(i, frameNum, bankNum);
 				++frameNum;
@@ -1111,7 +1111,7 @@
 	_vm->graphics()->textClear(0,198);
 
 	if (oracle) {
-		uint16 frameNum = _vm->logic()->personFrames(bobNum);
+		uint16 frameNum = _vm->graphics()->personFrames(bobNum);
 		for (i = 1; i <= 4; ++i) {
 			_vm->bankMan()->unpack(i, frameNum, bankNum);
 			++frameNum;

Index: xref.txt
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/xref.txt,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- xref.txt	8 Jan 2004 16:41:03 -0000	1.59
+++ xref.txt	8 Jan 2004 22:46:42 -0000	1.60
@@ -124,6 +124,7 @@
 CHECK_PARALLAX()			Graphics::bobCustomParallax
 clearallbobs()				Graphics::bobClearAll
 clearbob()					Graphics::bobClear
+DISP_OBJECTS()				Graphics::setupRoomObjects
 drawbobs()					Graphics::bobDrawAll
 invbob()					Graphics::bobDrawInventoryItem
 loadbackdrop()				*not needed* (included in Display::setupNewRoom)
@@ -132,6 +133,7 @@
 makeanim()					BobSlot::animNormal
 movebob()					BobSlot::move
 pastebob()					Graphics::bobPaste
+REDISP_OBJECT()				Graphics::refreshObject
 requestor()
 shrinkbob()					Graphics::bobShrink
 sortbobs()					Graphics::bobSortAll
@@ -206,17 +208,15 @@
 =====
 CHECK_PLAYER()				QueenEngine::update
 CUTAWAY_SPECIAL()			Logic::removeHotelItemsFromInventory
-DISP_OBJECTS()				Logic::roomSetupObjects
 DISP_ROOM()					Logic::roomDisplay
 FIND_BOB()					Logic::findBob
 FIND_FRAME()				Logic::findFrame
 FIND_GRAPHIC()				Logic::graphicData
 P3_COPY_FROM()				Logic::objectCopy
 R_MAP()						Logic::handlePinnacleRoom
-REDISP_OBJECT()				Logic::roomRefreshObject
 restart_game()
 SETUP_BOBS()				Graphics::bobSetupControl
-SETUP_FURNITURE()			Logic::roomSetupFurniture
+SETUP_FURNITURE()			Graphics::setupRoomFurniture
 SETUP_ROOM()				Logic::changeRoom
 SETUP_SCREENS()				*not needed* (only calls Display::setupPanel)
 SETUP_VARS()				*not needed* (equivalent to Command::clear(), SCENE=0, clear(gamestate))





More information about the Scummvm-git-logs mailing list