[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.294,1.295 akos.cpp,1.177,1.178 gfx.cpp,2.312,2.313 gfx.h,1.72,1.73 vars.cpp,1.104,1.105

Gregory Montoir cyx at users.sourceforge.net
Mon Sep 20 11:28:07 CEST 2004


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

Modified Files:
	actor.cpp akos.cpp gfx.cpp gfx.h vars.cpp 
Log Message:
cleanup / code re-use

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.294
retrieving revision 1.295
diff -u -d -r1.294 -r1.295
--- actor.cpp	19 Sep 2004 08:58:51 -0000	1.294
+++ actor.cpp	20 Sep 2004 18:27:12 -0000	1.295
@@ -1918,16 +1918,16 @@
 				} else {
 					uint16 comp = READ_LE_UINT16(axfd);
 					if (comp != 0) {
-						int x1 = (int16)READ_LE_UINT16(axfd + 2) + dx;
-						int y1 = (int16)READ_LE_UINT16(axfd + 4) + dy;
-						int x2 = (int16)READ_LE_UINT16(axfd + 6);
-						int y2 = (int16)READ_LE_UINT16(axfd + 8);
+						int x = (int16)READ_LE_UINT16(axfd + 2) + dx;
+						int y = (int16)READ_LE_UINT16(axfd + 4) + dy;
+						int w = (int16)READ_LE_UINT16(axfd + 6);
+						int h = (int16)READ_LE_UINT16(axfd + 8);
 						VirtScreen *pvs = &virtscr[kMainVirtScreen];
-						uint8 *dst1 = pvs->getPixels(0, 0);
-						uint8 *dst2 = pvs->getBackPixels(0, 0);
+						uint8 *dst1 = pvs->getPixels(0, pvs->topline);
+						uint8 *dst2 = pvs->getBackPixels(0, pvs->topline);
 						switch (comp) {
 						case 1:
-							gdi.copyAuxImage(dst1, dst2, axfd + 10, pvs->w, pvs->h, x1, y1, x2, y2, 0);
+							gdi.copyAuxImage(dst1, dst2, axfd + 10, pvs->w, pvs->h, x, y, w, h, NULL);
 							break;
 						default:
 							warning("unimplemented compression type %d", comp);
@@ -1939,11 +1939,11 @@
 				if (axur) {
 					uint16 n = READ_LE_UINT16(axur); axur += 2;
 					while (n--) {
-						int x = (int16)READ_LE_UINT16(axur + 0) + dx;
-						int y = (int16)READ_LE_UINT16(axur + 2) + dy;
-						int w = (int16)READ_LE_UINT16(axur + 4) + dx;
-						int h = (int16)READ_LE_UINT16(axur + 6) + dy;
-						markRectAsDirty(kMainVirtScreen, x, w, y, h);
+						int x1 = (int16)READ_LE_UINT16(axur + 0) + dx;
+						int y1 = (int16)READ_LE_UINT16(axur + 2) + dy;
+						int x2 = (int16)READ_LE_UINT16(axur + 4) + dx;
+						int y2 = (int16)READ_LE_UINT16(axur + 6) + dy;
+						markRectAsDirty(kMainVirtScreen, x1, x2, y1, y2);
 						axur += 8;
 					}
 				}

Index: akos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v
retrieving revision 1.177
retrieving revision 1.178
diff -u -d -r1.177 -r1.178
--- akos.cpp	18 Sep 2004 06:29:07 -0000	1.177
+++ akos.cpp	20 Sep 2004 18:27:12 -0000	1.178
@@ -1239,7 +1239,7 @@
 	if (_draw_bottom < dst.bottom)
 		_draw_bottom = dst.bottom;
 
-	_vm->gdi.decompressWizImage(_outptr, _outwidth, &dst, _srcptr, &src);
+	_vm->gdi.decompressWizImage(_outptr, _outwidth, dst, _srcptr, src);
 	return 0;
 }
 

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.312
retrieving revision 2.313
diff -u -d -r2.312 -r2.313
--- gfx.cpp	20 Sep 2004 13:41:36 -0000	2.312
+++ gfx.cpp	20 Sep 2004 18:27:12 -0000	2.313
@@ -1401,53 +1401,61 @@
 	}
 }
 
-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);
+static bool calcClipRects(int dst_w, int dst_h, int src_x, int src_y, int src_w, int src_h, const Common::Rect *rect, Common::Rect &srcRect, Common::Rect &dstRect) {
+	srcRect = Common::Rect(0, 0, src_w, src_h);
+	dstRect = Common::Rect(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 {
+		if (r3.intersects(r4)) {
 			r3.clip(r4);
+		} else {
+			return false;
 		}
 	} else {
 		r3 = Common::Rect(0, 0, dst_w, dst_h);
 	}
-	diff = r2.left - r3.left;
+	diff = dstRect.left - r3.left;
 	if (diff < 0) {
-		r1.left -= diff;
-		r2.left -= diff;
+		srcRect.left -= diff;
+		dstRect.left -= diff;
 	}
-	diff = r2.right - r3.right;
+	diff = dstRect.right - r3.right;
 	if (diff > 0) {
-		r1.right -= diff;
-		r2.right -= diff;
+		srcRect.right -= diff;
+		dstRect.right -= diff;
 	}
-	diff = r2.top - r3.top;
+	diff = dstRect.top - r3.top;
 	if (diff < 0) {
-		r1.top -= diff;
-		r2.top -= diff;
+		srcRect.top -= diff;
+		dstRect.top -= diff;
 	}
-	diff = r2.bottom - r3.bottom;
+	diff = dstRect.bottom - r3.bottom;
 	if (diff > 0) {
-		r1.bottom -= diff;
-		r2.bottom -= diff;
+		srcRect.bottom -= diff;
+		dstRect.bottom -= diff;
 	}
-	// TODO/FIXME: At this point, unless I am mistaken, r1 == r2.moveTo(0, 0)
-	// As such the code above could be simplified (i.e. r1 could be removed,
+	// TODO/FIXME: At this point, unless I am mistaken, srcRect == dstRect.moveTo(0, 0)
+	// As such the code above could be simplified (i.e. srcRect could be removed,
 	// and then the uses of the diff variables can be folded in).
 	// In fact it looks to me as if the code above just does some simple clipping...
 	// Since I don't have the HE games in questions, I can't test this, though.
-	if (r1.isValidRect() && r2.isValidRect()) {
-		decompressWizImage(dst, dst_w, &r2, src, &r1);
+	return true;
+}
+
+void Gdi::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect) {
+	Common::Rect r1, r2;
+	if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
+		if (r1.isValidRect() && r2.isValidRect()) {
+			decompressWizImage(dst, dstw, r2, src, r1);
+		}
 	}
 }
 
-void Gdi::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect) {
+void Gdi::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect) {
 	const uint8 *dataPtr, *dataPtrNext;
 	uint8 *dstPtr, *dstPtrNext;
 	uint32 code;
@@ -1455,25 +1463,25 @@
 	int h, w, xoff;
 	uint16 off;
 	
-	dstPtr = dst + dstRect->left + dstRect->top * dstPitch;
+	dstPtr = dst + dstRect.left + dstRect.top * dstPitch;
 	dataPtr = src;
 	
 	// Skip over the first 'srcRect->top' lines in the data
-	h = srcRect->top;
+	h = srcRect.top;
 	while (h--) {
 		dataPtr += READ_LE_UINT16(dataPtr) + 2;
 	}
-	h = srcRect->bottom - srcRect->top + 1;
+	h = srcRect.bottom - srcRect.top + 1;
 	if (h <= 0)
 		return;
-	w = srcRect->right - srcRect->left + 1;
+	w = srcRect.right - srcRect.left + 1;
 	if (w <= 0)
 		return;
 		
 	while (h--) {
-		xoff = srcRect->left;
+		xoff = srcRect.left;
 		off = READ_LE_UINT16(dataPtr);
-		w = srcRect->right - srcRect->left + 1;
+		w = srcRect.right - srcRect.left + 1;
 		dstPtrNext = dstPitch + dstPtr;
 		dataPtrNext = off + 2 + dataPtr;
 		dataPtr += 2;
@@ -1550,78 +1558,44 @@
 	}
 }
 
-void Gdi::copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, Common::Rect *rect) {
-	Common::Rect r1(0, 0, srcw - 1, srch - 1);
-	Common::Rect r2(srcx, srcy, srcx + srcw - 1, srcy + srch - 1);
-	Common::Rect r3;
-	int diff;
-
-	if (rect) {
-		r3 = *rect;
-		Common::Rect r4(0, 0, dstw - 1, dsth - 1);
-		if (!r3.intersects(r4)) {
-			return;
+void Gdi::copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect) {
+	Common::Rect r1, r2;
+	if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
+		if (r1.isValidRect() && r2.isValidRect()) {
+			--r1.right;
+			--r1.bottom;
+			decompressAuxImage(dst1, dst2, dstw, r2, src, r1);
 		}
-	} else {
-		r3 = Common::Rect(0, 0, dstw - 1, dsth - 1);
-	}
-	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;
-	}
-	// TODO/FIXME: At this point, unless I am mistaken, r1 == r2.moveTo(0, 0)
-	// As such the code above could be simplified (i.e. r1 could be removed,
-	// and then the uses of the diff variables can be folded in).
-	// In fact it looks to me as if the code above just does some simple clipping...
-	// Since I don't have the HE games in questions, I can't test this, though.
-	if (r1.isValidRect() && r2.isValidRect()) {
-		decompressAuxImage(dst1, dst2, dstw, &r2, src, &r1);
 	}
 }
 
-void Gdi::decompressAuxImage(uint8 *dst1, uint8 *dst2, int dstPitch, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect) {
+void Gdi::decompressAuxImage(uint8 *dst1, uint8 *dst2, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect) {
 	const uint8 *dataPtr, *dataPtrNext;
 	uint8 *dst1Ptr, *dst2Ptr, *dst1PtrNext, *dst2PtrNext;
 	int h, w, xoff;
 	uint16 off;
   	uint8 code;
-  
-	dst1Ptr = dst1 + dstRect->left + dstRect->top * dstPitch;
-	dst2Ptr = dst2 + dstRect->left + dstRect->top * dstPitch;
+
+	dst1Ptr = dst1 + dstRect.left + dstRect.top * dstPitch;
+	dst2Ptr = dst2 + dstRect.left + dstRect.top * dstPitch;
 	dataPtr = src;
-	
+
 	// Skip over the first 'srcRect->top' lines in the data
-	h = srcRect->top;
+	h = srcRect.top;
 	while (h--) {
 		dataPtr += READ_LE_UINT16(dataPtr) + 2;
 	}
-	h = srcRect->bottom - srcRect->top + 1;
+	h = srcRect.bottom - srcRect.top + 1;
 	if (h <= 0)
 		return;
-	w = srcRect->right - srcRect->left + 1;
+	w = srcRect.right - srcRect.left + 1;
 	if (w <= 0)
 		return;
 
   	while (h--) {
-		xoff = srcRect->left;
+		xoff = srcRect.left;
  		off = READ_LE_UINT16(dataPtr);
-		w = srcRect->right - srcRect->left + 1;
+		w = srcRect.right - srcRect.left + 1;
 		dst1PtrNext = dstPitch + dst1Ptr;
 		dst2PtrNext = dstPitch + dst2Ptr;
 		dataPtrNext = off + 2 + dataPtr;

Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- gfx.h	19 Sep 2004 21:14:51 -0000	1.72
+++ gfx.h	20 Sep 2004 18:27:13 -0000	1.73
@@ -277,10 +277,10 @@
 	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 *rect);
-	void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect);
-	void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, Common::Rect *rect);
-	void decompressAuxImage(uint8 *dst1, uint8 *dst2, int dstPitch, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect);
+	void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect);
+	void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect);
+	void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect);
+	void decompressAuxImage(uint8 *dst1, uint8 *dst2, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect);
 	void copyVirtScreenBuffers(const Common::Rect &rect);
 
 	void disableZBuffer() { _zbufferDisabled = true; }

Index: vars.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/vars.cpp,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- vars.cpp	19 Sep 2004 23:21:09 -0000	1.104
+++ vars.cpp	20 Sep 2004 18:27:13 -0000	1.105
@@ -259,12 +259,12 @@
 	VAR_NUM_GLOBAL_OBJS = 74;
 	VAR_POLYGONS_ONLY = 76;
 
-	if (_heversion >= 80) {
+	if (_heversion >= 80)
 		VAR_WINDOWS_VERSION = 79;
+	if (_heversion >= 90) {
+		VAR_NUM_SPRITES = 106;
 		VAR_WIZ_TCOLOR = 117;
 	}
-	if (_heversion >= 90)
-		VAR_NUM_SPRITES = 106;
 }
 
 void ScummEngine_v7::setupScummVars() {





More information about the Scummvm-git-logs mailing list