[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,2.299,2.300 gfx.h,1.67,1.68 intern.h,2.216,2.217 object.cpp,1.180,1.181 script_v72he.cpp,2.49,2.50

Eugene Sandulenko sev at users.sourceforge.net
Sun Sep 5 10:41:01 CEST 2004


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv650

Modified Files:
	gfx.cpp gfx.h intern.h object.cpp script_v72he.cpp 
Log Message:
Added BMAP support in objects.
Though I didn't test it as I don't know when it is used. Please, tell me when
you'll see warning that it is called.
Now we have BMAP for all cases in HE 70+ games.


Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.299
retrieving revision 2.300
diff -u -d -r2.299 -r2.300
--- gfx.cpp	5 Sep 2004 15:44:29 -0000	2.299
+++ gfx.cpp	5 Sep 2004 17:39:51 -0000	2.300
@@ -557,20 +557,28 @@
 				gdi.drawBMAPBg(room, &virtscr[0], _screenStartStrip, _screenWidth);
 			}
 			cont = false;
+		} else if (findResource(MKID('SMAP'), room) == NULL) {
+			warning("redrawBGAreas(): Both SMAP and BMAP are missing...");
+			cont = false;
+		}
+
+		if (!cont) {
+			drawRoomObjects(val);
+			_BgNeedsRedraw = false;
+			return;
 		}
 	}
 
 	// Redraw parts of the background which are marked as dirty.
-	if (!_fullRedraw && _BgNeedsRedraw && cont) {
+	if (!_fullRedraw && _BgNeedsRedraw) {
 		for (i = 0; i != gdi._numStrips; i++) {
 			if (testGfxUsageBit(_screenStartStrip + i, USAGE_BIT_DIRTY)) {
 				redrawBGStrip(i, 1);
-				cont = false;
 			}
 		}
 	}
 
-	if (_features & GF_NEW_CAMERA && cont) {
+	if (_features & GF_NEW_CAMERA) {
 		diff = camera._cur.x / 8 - camera._last.x / 8;
 		if (_fullRedraw == 0 && diff == 1) {
 			val = 2;
@@ -1288,7 +1296,7 @@
 	bmap_ptr = _vm->findResource(MKID('BMAP'), ptr) + 8;
 
 	if (bmap_ptr == NULL) {
-		error("Room %d has no compressed bitmap?", _vm->_roomResource);
+		error("Gdi::drawBMAPBg: Room %d has no compressed bitmap?", _vm->_roomResource);
 		return;
 	}
 
@@ -1300,7 +1308,7 @@
 
 		decompressBMAPbg((byte *)vs->backBuf, width, vs->w, vs->h, bmap_ptr, decomp_shr, decomp_mask);
 	}
-	copyVirtScreenBuffers(0, 0, vs->w - 1, vs->h - 1);
+	copyVirtScreenBuffers(Common::Rect(0, 0, vs->w - 1, vs->h - 1));
 
 	if (_numZBuffer <= 1)
 		return;
@@ -1336,6 +1344,38 @@
 		}
 }
 
+void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, int w, int h) {
+	const byte *bmap_ptr;
+
+	warning("drawBMAPObject() called");
+
+	bmap_ptr = _vm->findResource(MKID('BMAP'), ptr) + 8;
+	if (bmap_ptr == NULL) {
+		error("Gdi::drawBMAPObject: No image for item %d?", obj);
+		return;
+	}
+
+	byte code = *ptr++;
+	int scrX = _vm->_screenStartStrip * 8;
+
+	if (code == 8 || code == 9) {
+		Common::Rect rScreen(0, 0, vs->w, vs->h);
+		byte *dst = (byte *)_vm->virtscr[0].backBuf + scrX;
+		copyWizImage(dst, ptr, vs->w, vs->h, x - scrX, y, w, h, &rScreen);
+	}
+
+	Common::Rect rect1(x, y, w, h);
+	Common::Rect rect2(scrX, 0, vs->w + scrX, vs->h);
+
+	if (rect1.intersects(rect2) && rect1.top <= rect1.bottom && rect1.left <= rect1.right) {
+		rect1.left -= rect2.left;
+		rect1.right -= rect2.left;
+		rect1.top -= rect2.top;
+		rect1.bottom -= rect2.top;
+		copyVirtScreenBuffers(rect1);
+	}
+}
+
 void Gdi::decompressBMAPbg(byte *dst, int screenwidth, int w, int height, const byte *src, int shr, int mask) {
 	uint32 color, dataBit, data, shift;
 	int32 iteration;
@@ -1385,6 +1425,47 @@
 	 }
 }
 
+void Gdi::copyWizImage(uint8 *dst, const uint8 *src, int dst_w, int dst_h, int src_x, int src_y, int src_w, int src_h, Common::Rect *rect) {
+	Common::Rect r1(0, 0, src_w, src_h), r2(src_x, src_y, src_x + src_w, src_y + src_h);
+	Common::Rect r3;
+	int diff;
+
+	if (rect) {
+		r3 = *rect;
+		Common::Rect r4(0, 0, dst_w, dst_h);
+		if (!r3.intersects(r4)) {
+			return;
+		} else {
+			r3.clip(r4);
+		}
+	} else {
+		r3 = Common::Rect(0, 0, dst_w, dst_h);
+	}
+	diff = r2.left - r3.left;
+	if (diff < 0) {
+		r1.left -= diff;
+		r2.left -= diff;
+	}
+	diff = r2.right - r3.right;
+	if (diff > 0) {
+		r1.right -= diff;
+		r2.right -= diff;
+	}
+	diff = r2.top - r3.top;
+	if (diff < 0) {
+		r1.top -= diff;
+		r2.top -= diff;
+	}
+	diff = r2.bottom - r3.bottom;
+	if (diff > 0) {
+		r1.bottom -= diff;
+		r2.bottom -= diff;
+	}
+	if (r1.isValidRect() && r2.isValidRect()) {
+		decompressImageHE(dst, dst_w, &r2, src, &r1);
+	}
+}
+
 void Gdi::decompressImageHE(uint8 *dst, int dstWidth, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect) {
 	const uint8 *dataPtr, *dataPtrNext;
 	uint8 *dstPtr, *dstPtrNext;
@@ -1489,16 +1570,16 @@
 	}
 }
 
-void Gdi::copyVirtScreenBuffers(int x1, int y1, int x2, int y2) {
-	int rw = x2 - x1 + 1;
-	int rh = y2 - y1 + 1;
+void Gdi::copyVirtScreenBuffers(Common::Rect rect) {
+	int rw = rect.right - rect.left + 1;
+	int rh = rect.bottom - rect.top + 1;
 	byte *src, *dst;
 
-	src = (byte *)_vm->virtscr[0].backBuf + (_vm->_screenStartStrip + y1 * _numStrips) * 8 + x1;
-	dst = (byte *)_vm->virtscr[0].pixels + (_vm->_screenStartStrip + y1 * _numStrips) * 8 + x1;
+	src = (byte *)_vm->virtscr[0].backBuf + (_vm->_screenStartStrip + rect.top * _numStrips) * 8 + rect.left;
+	dst = (byte *)_vm->virtscr[0].pixels + (_vm->_screenStartStrip + rect.top * _numStrips) * 8 + rect.left;
 	
 	copyBufferBox(dst, src, rw, rh);
-	_vm->markRectAsDirty(kMainVirtScreen, x1, x2, y1, y2, 0);
+	_vm->markRectAsDirty(kMainVirtScreen, rect.left, rect.right, rect.top, rect.bottom, 0);
 }
 
 /**

Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- gfx.h	3 Sep 2004 17:27:40 -0000	1.67
+++ gfx.h	5 Sep 2004 17:39:52 -0000	1.68
@@ -274,8 +274,10 @@
 	                int stripnr, int numstrip, StripTable *table);
 	StripTable *generateStripTable(const byte *src, int width, int height, StripTable *table);
 	void drawBMAPBg(const byte *ptr, VirtScreen *vs, int startstrip, int width);
+	void drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, int w, int h);
+	void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, Common::Rect *pr);
 	void decompressImageHE(uint8 *dst, int dstWidth, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect);
-	void copyVirtScreenBuffers(int x1, int y1, int x2, int y2);
+	void copyVirtScreenBuffers(Common::Rect rect);
 
 	void disableZBuffer() { _zbufferDisabled = true; }
 	void enableZBuffer() { _zbufferDisabled = false; }

Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.216
retrieving revision 2.217
diff -u -d -r2.216 -r2.217
--- intern.h	5 Sep 2004 09:36:50 -0000	2.216
+++ intern.h	5 Sep 2004 17:39:52 -0000	2.217
@@ -698,7 +698,6 @@
 
 	void drawWizImage(int restype, int resnum, int x1, int y1, int flags);
 	void flushWizBuffer();
-	void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, Common::Rect *pr);
 
 	virtual void decodeParseString(int a, int b);
 	void decodeScriptString(byte *dst, bool scriptString = false);

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.180
retrieving revision 1.181
diff -u -d -r1.180 -r1.181
--- object.cpp	2 Sep 2004 11:35:42 -0000	1.180
+++ object.cpp	5 Sep 2004 17:39:53 -0000	1.181
@@ -484,7 +484,11 @@
 		// the inventory and conversation icons.
 		if ((_version >= 7 || _gameId == GID_SAMNMAX) && getClass(od.obj_nr, kObjectClassIgnoreBoxes))
 			flags |= Gdi::dbDrawMaskOnAll;
-		gdi.drawBitmap(ptr, &virtscr[0], x, ypos, width * 8, height, x - xpos, numstrip, flags);
+
+		if (_heversion >= 70 && findResource(MKID('SMAP'), ptr) == NULL)
+			gdi.drawBMAPObject(ptr, &virtscr[0], obj, od.x_pos * 8, od.y_pos * 8, od.width * 8, od.height * 8);
+		else
+			gdi.drawBitmap(ptr, &virtscr[0], x, ypos, width * 8, height, x - xpos, numstrip, flags);
 	}
 }
 

Index: script_v72he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v72he.cpp,v
retrieving revision 2.49
retrieving revision 2.50
diff -u -d -r2.49 -r2.50
--- script_v72he.cpp	5 Sep 2004 10:28:30 -0000	2.49
+++ script_v72he.cpp	5 Sep 2004 17:39:54 -0000	2.50
@@ -1295,7 +1295,7 @@
 		if (flags & 2) {			
 			warning("unhandled Wiz image w/ rmap");
 		} else {
-			copyWizImage(dst, wizd, pvs->w, pvs->h, x1, y1, width, height, &rScreen);
+			gdi.copyWizImage(dst, wizd, pvs->w, pvs->h, x1, y1, width, height, &rScreen);
 		}
 
 		Common::Rect rImage(x1, y1, x1 + width, y1 + height);
@@ -1305,7 +1305,7 @@
 				++rImage.bottom;
 				markRectAsDirty(kMainVirtScreen, rImage);
 			} else {
-				gdi.copyVirtScreenBuffers(rImage.left, rImage.top, rImage.right - 1, rImage.bottom - 1);
+				gdi.copyVirtScreenBuffers(rImage);
 			}
 		}
 	}
@@ -1324,47 +1324,6 @@
 	_wizImagesNum = 0;
 }
 
-void ScummEngine_v72he::copyWizImage(uint8 *dst, const uint8 *src, int dst_w, int dst_h, int src_x, int src_y, int src_w, int src_h, Common::Rect *rect) {
-	Common::Rect r1(0, 0, src_w, src_h), r2(src_x, src_y, src_x + src_w, src_y + src_h);
-	Common::Rect r3;
-	int diff;
-
-	if (rect) {
-		r3 = *rect;
-		Common::Rect r4(0, 0, dst_w, dst_h);
-		if (!r3.intersects(r4)) {
-			return;
-		} else {
-			r3.clip(r4);
-		}
-	} else {
-		r3 = Common::Rect(0, 0, dst_w, dst_h);
-	}
-	diff = r2.left - r3.left;
-	if (diff < 0) {
-		r1.left -= diff;
-		r2.left -= diff;
-	}
-	diff = r2.right - r3.right;
-	if (diff > 0) {
-		r1.right -= diff;
-		r2.right -= diff;
-	}
-	diff = r2.top - r3.top;
-	if (diff < 0) {
-		r1.top -= diff;
-		r2.top -= diff;
-	}
-	diff = r2.bottom - r3.bottom;
-	if (diff > 0) {
-		r1.bottom -= diff;
-		r2.bottom -= diff;
-	}
-	if (r1.isValidRect() && r2.isValidRect()) {
-		gdi.decompressImageHE(dst, dst_w, &r2, src, &r1);
-	}
-}
-
 void ScummEngine_v72he::o72_drawWizImage() {
 	int flags = pop();
 	int y1 = pop();





More information about the Scummvm-git-logs mailing list