[Scummvm-cvs-logs] CVS: scummvm/queen logic.cpp,1.8,1.9 logic.h,1.4,1.5

Gregory Montoir cyx at users.sourceforge.net
Thu Oct 2 07:45:17 CEST 2003


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

Modified Files:
	logic.cpp logic.h 
Log Message:
findBob function + tweaks in QueenLogic

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- logic.cpp	2 Oct 2003 11:03:33 -0000	1.8
+++ logic.cpp	2 Oct 2003 14:44:50 -0000	1.9
@@ -49,6 +49,36 @@
 	
 
 	//Object data
+#ifdef USE_STRUCTS_JAS
+	_objectData = new ObjectData[_numObjects + 1];
+	//clear first object
+	_objectData[0].name = 0;
+	_objectData[0].x = 0;
+	_objectData[0].y = 0;
+	_objectData[0].description = 0;
+	_objectData[0].entryObj = 0;
+	_objectData[0].room = 0;
+	_objectData[0].state = 0;
+	_objectData[0].image = 0;	
+	for (i = 1; i < (_numObjects + 1); i++) {
+		_objectData[0].name = READ_BE_UINT16(ptr);
+		ptr += 2;
+		_objectData[0].x = READ_BE_UINT16(ptr);
+		ptr += 2;
+		_objectData[0].y = READ_BE_UINT16(ptr);
+		ptr += 2;
+		_objectData[0].description = READ_BE_UINT16(ptr);
+		ptr += 2;
+		_objectData[0].entryObj = (int16)READ_BE_UINT16(ptr);
+		ptr += 2;
+		_objectData[0].room = READ_BE_UINT16(ptr);
+		ptr += 2;
+		_objectData[0].state = (int16)READ_BE_UINT16(ptr);
+		ptr += 2;
+		_objectData[0].image = (int16)READ_BE_UINT16(ptr);
+		ptr += 2;
+	}
+#else
 	_objectData = new int16[_numObjects + 1][8];
 		
 	//clear first object
@@ -60,6 +90,7 @@
 			_objectData[i][j] = (int16)READ_BE_UINT16(ptr);
 			ptr += 2;
 		}
+#endif
 	
 	//Room data
 	_roomData = new uint16[_numRooms + 2];
@@ -71,7 +102,9 @@
 	_roomData[_numRooms + 1] = _numObjects;
 
 	//SFX Name
+	// FIXME: the following table isn't available in demo version
 	_sfxName = new uint16[_numRooms + 1];
+
 	for (i = 0; i < (_numRooms + 1); i++) {
 		_sfxName[i] = READ_BE_UINT16(ptr);
 		ptr += 2;
@@ -97,13 +130,20 @@
 	_numGraphics = READ_BE_UINT16(ptr);
 	ptr += 2;
 
-	_graphicData = new uint16[_numGraphics + 1][5];
+	_graphicData = new GraphicData[_numGraphics + 1];
 
-	for (i = 1; i < _numGraphics; i++)
-		for (uint16 j = 0; j < 5; j++) {
-			_graphicData[i][j] = READ_BE_UINT16(ptr);
-			ptr += 2;
-		}
+	for (i = 1; i < (_numGraphics + 1); i++) {
+		_graphicData[i].x = READ_BE_UINT16(ptr);
+		ptr += 2;
+		_graphicData[i].y = READ_BE_UINT16(ptr);
+		ptr += 2;
+		_graphicData[i].firstFrame = (int16)READ_BE_UINT16(ptr);
+		ptr += 2;
+		_graphicData[i].lastFrame = (int16)READ_BE_UINT16(ptr);
+		ptr += 2;
+		_graphicData[i].speed = READ_BE_UINT16(ptr);
+		ptr += 2;
+	}
 	
 	_objMax = new uint16[_numRooms + 1];
 	_areaMax = new uint16[_numRooms + 1];
@@ -148,9 +188,15 @@
 	_oldRoom = room;
 }
 
+#ifdef USE_STRUCTS_JAS
+ObjectData* QueenLogic::objectData(int index) {
+  return &_objectData[index];
+}
+#else
 int16* QueenLogic::objectData(int index) {
 	return _objectData[index];
 }
+#endif
 
 uint16 QueenLogic::roomData(int room) {
 	return _roomData[room];
@@ -172,3 +218,159 @@
 	return _walkOffData[index];
 }
 
+GraphicData* QueenLogic::findGraphic(int index) {
+	return &_graphicData[index];
+}
+
+#ifdef USE_STRUCTS_JAS
+uint16 QueenLogic::findBob(uint16 obj) {
+
+	uint16 i;
+	uint16 bobnum = 0;
+	uint16 bobtype = 0; // 1 for animated, 0 for static
+
+	uint16 room = _objectData[obj].room;
+	int16 img = _objectData[obj].image;
+	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;
+				}
+			}
+		}
+		else {
+			if(img <= -10) {
+				// object has been turned off, but the image order hasn't been updated
+				if(_graphicData[-(img + 10)].lastFrame != 0) {
+					bobtype = 1;
+				}
+			}
+			else if(img == -2) {
+				// -1 static, -2 animated
+				bobtype = 1;
+			}
+			else if(img > 0) {
+				if(_graphicData[img].lastFrame != 0) {
+					bobtype = 1;
+				}
+			}
+
+			uint16 idxAnimated = 0;
+			uint16 idxStatic = 0;
+			for(i = _roomData[room] + 1; i <= obj; ++i) {
+				img = _objectData[i].image;
+				if(img <= -10) {
+					if(_graphicData[-(img + 10)].lastFrame != 0) {
+						++idxAnimated;
+					}
+					else {
+						++idxStatic;
+					}
+				}
+				else if(img > 0) {
+					if(img > 5000) {
+						img -= 5000;
+					}
+					if(_graphicData[img].lastFrame != 0) {
+						++idxAnimated;
+					}
+					else {
+						++idxStatic;
+					}
+				}
+			}
+			// FIXME: _max*Frame variables should initialized in SETUP_FURNITURE and DISP_ROOM
+			if(bobtype == 0) {
+				// static bob
+				bobnum = 19 + _maxStaticFrame + idxStatic;
+			}
+			else {
+				// animated bob
+				bobnum = 4 + _maxAnimatedFrame + idxAnimated;
+
+			}
+		}
+	}
+	return bobnum;
+}
+
+
+uint16 QueenLogic::findFrame(uint16 obj) {
+
+	uint16 i;
+	uint16 framenum = 0;
+
+	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;
+			}
+		}
+		if(bobnum <= 3) {
+			framenum = 29 + FRAME_XTRA;
+		}
+	}
+	else {
+		uint16 idx = 0;
+		for(i = _roomData[room] + 1; i < obj; ++i) {
+			img = _objectData[i].image;
+			if(img <= -10) {
+				GraphicData* pgd = &_graphicData[-(img + 10)];
+				if(pgd->lastFrame != 0) {
+					// skip all the frames of the animation
+					idx += ABS(pgd->lastFrame) - pgd->firstFrame + 1;
+				}
+				else {
+					++idx;
+				}
+			}
+			else if(img == -1) {
+				++idx;
+			}
+			else if(img > 0) {
+				if(img > 5000) {
+					img -= 5000;
+				}
+				GraphicData* pgd = &_graphicData[img];
+				uint16 lastFrame = ABS(pgd->lastFrame);
+				if(pgd->firstFrame < 0) {
+					idx += lastFrame;
+				}
+				else if(lastFrame != 0) {
+					idx += (lastFrame - pgd->firstFrame) + 1;
+				}
+				else {
+					++idx;
+				}
+			}
+		}
+
+		img = _objectData[obj].image;
+		if(img <= -10) {
+			GraphicData* pgd = &_graphicData[-(img + 10)];
+			if(pgd->lastFrame != 0) {
+				idx += ABS(pgd->lastFrame - pgd->firstFrame) + 1;
+			}
+			else {
+				++idx;
+			}
+		}
+		else if(img == -1 || img > 0) {
+			++idx;
+		}
+
+		// calculate only if there are person frames
+		if(idx > 0) {
+			framenum = 36 + _maxStaticFrame + _maxAnimatedFrameLen + idx + FRAME_XTRA;
+		}
+	}
+	return framenum;
+}
+#endif

Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- logic.h	2 Oct 2003 11:03:34 -0000	1.4
+++ logic.h	2 Oct 2003 14:44:51 -0000	1.5
@@ -24,6 +24,28 @@
 
 #include "queen/queen.h"
 
+
+struct GraphicData {
+	uint16 x, y;
+	int16 firstFrame, lastFrame;
+	uint16 speed;
+};
+
+struct ObjectData {
+	uint16 name;
+	uint16 x;
+	uint16 y;
+	uint16 description;
+	int16 entryObj;
+	uint16 room;
+	int16 state;
+	int16 image;
+};
+
+enum {
+	FRAME_XTRA = 2
+};
+
 class QueenLogic {
 
 public:
@@ -32,12 +54,20 @@
 
 	uint16 currentRoom();
 	void currentRoom(uint16 room);
-
 	void oldRoom(uint16 room);
-
+#ifdef USE_STRUCTS_JAS
+	ObjectData* objectData(int index);
+#else 
 	int16 *objectData(int index);
+#endif
 	uint16 roomData(int room);
 	uint16 objMax(int room);
+	GraphicData* findGraphic(int index);
+
+#ifdef USE_STRUCTS_JAS
+	uint16 findBob(uint16 obj); // FIXME: move that to QueenDisplay ?
+	uint16 findFrame(uint16 obj); // FIXME: move that to QueenDisplay ?
+#endif
 
 	int16 *area(int index, int subIndex);
 	uint16 walkOffCount();
@@ -65,13 +95,16 @@
 	uint16 *_areaMax;
 	uint16 (*_objectBox)[4];
 	uint16 (*_itemData)[5];
-	uint16 (*_graphicData)[5];
+	GraphicData *_graphicData;
+#ifdef USE_STRUCTS_JAS
+	ObjectData *_objectData;
+#else
 	int16 (*_objectData)[8];
+#endif
 	uint16 (*_actorData)[12];
-
 	int16 (*_area)[11][8];
-
 	uint16 (*_walkOffData)[3];
+	uint16 _maxAnimatedFrame, _maxStaticFrame, _maxAnimatedFrameLen; // FMAXA, FMAX, FMAXALEN
 
 	QueenResource *_resource;
 





More information about the Scummvm-git-logs mailing list