[Scummvm-cvs-logs] SF.net SVN: scummvm:[51313] scummvm/trunk/engines/sci/graphics

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Mon Jul 26 16:41:19 CEST 2010


Revision: 51313
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51313&view=rev
Author:   m_kiewitz
Date:     2010-07-26 14:41:19 +0000 (Mon, 26 Jul 2010)

Log Message:
-----------
SCI: adding scrollcapability to sci32

Modified Paths:
--------------
    scummvm/trunk/engines/sci/graphics/frameout.cpp
    scummvm/trunk/engines/sci/graphics/frameout.h
    scummvm/trunk/engines/sci/graphics/picture.cpp
    scummvm/trunk/engines/sci/graphics/picture.h

Modified: scummvm/trunk/engines/sci/graphics/frameout.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/frameout.cpp	2010-07-26 14:22:16 UTC (rev 51312)
+++ scummvm/trunk/engines/sci/graphics/frameout.cpp	2010-07-26 14:41:19 UTC (rev 51313)
@@ -68,7 +68,6 @@
 
 	newPlane.object = object;
 	newPlane.pictureId = 0xFFFF;
-	newPlane.picture = NULL;
 	newPlane.lastPriority = 0xFFFF; // hidden
 	_planes.push_back(newPlane);
 
@@ -84,13 +83,11 @@
 			it->pictureId = readSelectorValue(_segMan, object, SELECTOR(picture));
 			if (lastPictureId != it->pictureId) {
 				// picture got changed, load new picture
+				deletePlanePictures(object);
 				if ((it->pictureId != 0xFFFF) && (it->pictureId != 0xFFFE)) {
 					// SQ6 gives us a bad picture number for the control menu
 					if (_resMan->testResource(ResourceId(kResourceTypePic, it->pictureId)))
-						it->picture = new GfxPicture(_resMan, _coordAdjuster, 0, _screen, _palette, it->pictureId, false);
-				} else {
-					delete it->picture;
-					it->picture = NULL;
+						addPlanePicture(object, it->pictureId, 0);
 				}
 			}
 			sortPlanes();
@@ -101,6 +98,7 @@
 }
 
 void GfxFrameout::kernelDeletePlane(reg_t object) {
+	deletePlanePictures(object);
 	for (PlaneList::iterator it = _planes.begin(); it != _planes.end(); it++) {
 		if (it->object == object) {
 			_planes.erase(it);
@@ -121,6 +119,26 @@
 	}
 }
 
+void GfxFrameout::addPlanePicture(reg_t object, GuiResourceId pictureId, uint16 startX) {
+	PlanePictureEntry newPicture;
+	newPicture.object = object;
+	newPicture.pictureId = pictureId;
+	newPicture.picture = new GfxPicture(_resMan, _coordAdjuster, 0, _screen, _palette, pictureId, false);
+	newPicture.startX = startX;
+	_planePictures.push_back(newPicture);
+}
+
+void GfxFrameout::deletePlanePictures(reg_t object) {
+	for (PlanePictureList::iterator it = _planePictures.begin(); it != _planePictures.end(); it++) {
+		if (it->object == object) {
+			delete it->picture;
+			_planePictures.erase(it);
+			deletePlanePictures(object);
+			return;
+		}
+	}
+}
+
 void GfxFrameout::kernelAddScreenItem(reg_t object) {
 	_screenItems.push_back(object);
 }
@@ -141,11 +159,7 @@
 
 // No idea yet how to implement this
 void GfxFrameout::kernelAddPicAt(reg_t planeObj, int16 forWidth, GuiResourceId pictureId) {
-	//if (forWidth == 320) {
-	//	writeSelectorValue(_segMan, planeObj, SELECTOR(left), 0);
-	//	writeSelectorValue(_segMan, planeObj, SELECTOR(picture), pictureId);
-	//	kernelUpdatePlane(planeObj);
-	//}
+	addPlanePicture(planeObj, pictureId, forWidth);
 }
 
 bool sortHelper(const FrameoutEntry* entry1, const FrameoutEntry* entry2) {
@@ -247,21 +261,15 @@
 		if (planeBack)
 			_paint32->fillRect(planeRect, planeBack);
 
-		GuiResourceId planePictureNr = it->pictureId;
-		GfxPicture *planePicture = it->picture;
-		int16 planePictureCels = 0;
+		GuiResourceId planeMainPictureId = it->pictureId;
+
 		bool planePictureMirrored = false;
+		if (readSelectorValue(_segMan, planeObject, SELECTOR(mirrored)))
+			planePictureMirrored = true;
 
-		if (planePicture) {
-			planePictureCels = planePicture->getSci32celCount();
+		_coordAdjuster->pictureSetDisplayArea(planeRect);
+		_palette->drewPicture(planeMainPictureId);
 
-			_coordAdjuster->pictureSetDisplayArea(planeRect);
-			_palette->drewPicture(planePictureNr);
-
-			if (readSelectorValue(_segMan, planeObject, SELECTOR(mirrored)))
-				planePictureMirrored = true;
-		}
-
 		// Fill our itemlist for this plane
 		int16 itemCount = 0;
 		FrameoutEntry *itemEntry = itemData;
@@ -302,23 +310,28 @@
 			}
 		}
 
-		FrameoutEntry *pictureCels = NULL;
+		for (PlanePictureList::iterator pictureIt = _planePictures.begin(); pictureIt != _planePictures.end(); pictureIt++) {
+			if (pictureIt->object == planeObject) {
+				GfxPicture *planePicture = pictureIt->picture;
+				// Allocate memory for picture cels
+				pictureIt->pictureCels = new FrameoutEntry[planePicture->getSci32celCount()];
 
-		if (planePicture) {
-			// Allocate memory for picture cels
-			pictureCels = new FrameoutEntry[planePicture->getSci32celCount()];
-			// Add following cels to the itemlist
-			FrameoutEntry *picEntry = pictureCels;
-			for (int pictureCelNr = 0; pictureCelNr < planePictureCels; pictureCelNr++) {
-				picEntry->celNo = pictureCelNr;
-				picEntry->object = NULL_REG;
-				picEntry->y = planePicture->getSci32celY(pictureCelNr);
-				picEntry->x = planePicture->getSci32celX(pictureCelNr);
+				// Add following cels to the itemlist
+				FrameoutEntry *picEntry = pictureIt->pictureCels;
+				int planePictureCels = planePicture->getSci32celCount();
+				for (int pictureCelNr = 0; pictureCelNr < planePictureCels; pictureCelNr++) {
+					picEntry->celNo = pictureCelNr;
+					picEntry->object = NULL_REG;
+					picEntry->picture = planePicture;
+					picEntry->y = planePicture->getSci32celY(pictureCelNr);
+					picEntry->x = planePicture->getSci32celX(pictureCelNr);
+					picEntry->picStartX = pictureIt->startX;
 
-				picEntry->priority = planePicture->getSci32celPriority(pictureCelNr);
+					picEntry->priority = planePicture->getSci32celPriority(pictureCelNr);
 
-				itemList.push_back(picEntry);
-				picEntry++;
+					itemList.push_back(picEntry);
+					picEntry++;
+				}
 			}
 		}
 
@@ -337,10 +350,32 @@
 				// Picture cel data
 				itemEntry->y = ((itemEntry->y * _screen->getHeight()) / scriptsRunningHeight);
 				itemEntry->x = ((itemEntry->x * _screen->getWidth()) / scriptsRunningWidth);
+				itemEntry->picStartX = ((itemEntry->picStartX * _screen->getWidth()) / scriptsRunningWidth);
 
-				planePicture->drawSci32Vga(itemEntry->celNo, itemEntry->x, itemEntry->y, planeOffsetX, planePictureMirrored);
-//				warning("picture cel %d %d", itemEntry->celNo, itemEntry->priority);
+				// Out of view
+				int16 pictureCelStartX = itemEntry->picStartX + itemEntry->x;
+				int16 pictureCelEndX = pictureCelStartX + itemEntry->picture->getSci32celWidth(itemEntry->celNo);
+				int16 planeStartX = planeOffsetX;
+				int16 planeEndX = planeStartX + planeRect.width();
+				if (pictureCelEndX < planeStartX)
+					continue;
+				if (pictureCelStartX > planeEndX)
+					continue;
 
+				int16 pictureOffsetX = planeOffsetX;
+				int16 pictureX = itemEntry->x;
+				if (planeOffsetX) {
+					if (planeOffsetX <= itemEntry->picStartX) {
+						pictureX += itemEntry->picStartX - planeOffsetX;
+						pictureOffsetX = 0;
+					} else {
+						pictureOffsetX = planeOffsetX - itemEntry->picStartX;
+					}
+				}
+
+				itemEntry->picture->drawSci32Vga(itemEntry->celNo, pictureX, itemEntry->y, pictureOffsetX, planePictureMirrored);
+				warning("picture cel %d %d", itemEntry->celNo, itemEntry->priority);
+
 			} else if (itemEntry->viewId != 0xFFFF) {
 				GfxView *view = _cache->getView(itemEntry->viewId);
 
@@ -468,8 +503,10 @@
 			}
 		}
 
-		if (planePicture) {
-			delete[] pictureCels;
+		for (PlanePictureList::iterator pictureIt = _planePictures.begin(); pictureIt != _planePictures.end(); pictureIt++) {
+			if (pictureIt->object == planeObject) {
+				delete[] pictureIt->pictureCels;
+			}
 		}
 	}
 

Modified: scummvm/trunk/engines/sci/graphics/frameout.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/frameout.h	2010-07-26 14:22:16 UTC (rev 51312)
+++ scummvm/trunk/engines/sci/graphics/frameout.h	2010-07-26 14:41:19 UTC (rev 51313)
@@ -31,9 +31,8 @@
 struct PlaneEntry {
 	reg_t object;
 	uint16 priority;
+	uint16 lastPriority;
 	GuiResourceId pictureId;
-	GfxPicture *picture;
-	uint16 lastPriority;
 };
 
 typedef Common::List<PlaneEntry> PlaneList;
@@ -51,10 +50,22 @@
 	int16 scaleX;
 	int16 scaleY;
 	Common::Rect celRect;
+	GfxPicture *picture;
+	int16 picStartX;
 };
 
 typedef Common::List<FrameoutEntry *> FrameoutList;
 
+struct PlanePictureEntry {
+	reg_t object;
+	int16 startX;
+	GuiResourceId pictureId;
+	GfxPicture *picture;
+	FrameoutEntry *pictureCels; // temporary
+};
+
+typedef Common::List<PlanePictureEntry> PlanePictureList;
+
 class GfxCache;
 class GfxCoordAdjuster32;
 class GfxPaint32;
@@ -77,6 +88,9 @@
 	void kernelAddPicAt(reg_t planeObj, int16 forWidth, GuiResourceId pictureId);
 	void kernelFrameout();
 
+	void addPlanePicture(reg_t object, GuiResourceId pictureId, uint16 startX);
+	void deletePlanePictures(reg_t object);
+
 private:
 	SegManager *_segMan;
 	ResourceManager *_resMan;
@@ -88,6 +102,7 @@
 
 	Common::Array<reg_t> _screenItems;
 	PlaneList _planes;
+	PlanePictureList _planePictures;
 
 	void sortPlanes();
 

Modified: scummvm/trunk/engines/sci/graphics/picture.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/picture.cpp	2010-07-26 14:22:16 UTC (rev 51312)
+++ scummvm/trunk/engines/sci/graphics/picture.cpp	2010-07-26 14:41:19 UTC (rev 51313)
@@ -146,6 +146,13 @@
 	return READ_LE_UINT16(inbuffer + cel_headerPos + 38);
 }
 
+int16 GfxPicture::getSci32celWidth(int16 celNo) {
+	byte *inbuffer = _resource->data;
+	int header_size = READ_LE_UINT16(inbuffer);
+	int cel_headerPos = header_size + 42 * celNo;
+	return READ_LE_UINT16(inbuffer + cel_headerPos + 0);
+}
+
 int16 GfxPicture::getSci32celPriority(int16 celNo) {
 	byte *inbuffer = _resource->data;
 	int header_size = READ_LE_UINT16(inbuffer);

Modified: scummvm/trunk/engines/sci/graphics/picture.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/picture.h	2010-07-26 14:22:16 UTC (rev 51312)
+++ scummvm/trunk/engines/sci/graphics/picture.h	2010-07-26 14:41:19 UTC (rev 51313)
@@ -58,6 +58,7 @@
 	int16 getSci32celCount();
 	int16 getSci32celY(int16 celNo);
 	int16 getSci32celX(int16 celNo);
+	int16 getSci32celWidth(int16 celNo);
 	int16 getSci32celPriority(int16 celNo);
 	void drawSci32Vga(int16 celNo, int16 callerX, int16 callerY, int16 pictureX, bool mirrored);
 #endif


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list