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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Oct 28 15:23:24 CET 2009


Revision: 45463
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45463&view=rev
Author:   thebluegr
Date:     2009-10-28 14:23:23 +0000 (Wed, 28 Oct 2009)

Log Message:
-----------
Rewrote kBaseSetter() to use new graphics functions and behave like the original, and fixed a bug in the process (the previous code ignored z when calculating the height)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kernel.h
    scummvm/trunk/engines/sci/engine/kgraphics.cpp

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-10-28 13:43:57 UTC (rev 45462)
+++ scummvm/trunk/engines/sci/console.cpp	2009-10-28 14:23:23 UTC (rev 45463)
@@ -3151,7 +3151,7 @@
 
 	nsrect = get_nsrect(s, pos, 0);
 	nsrect_clipped = get_nsrect(s, pos, 1);
-	brrect = set_base(s, pos);
+	//brrect = set_base(s, pos);
 	printf("new nsRect: [%d..%d]x[%d..%d]\n", nsrect.x, nsrect.xend, nsrect.y, nsrect.yend);
 	printf("new clipped nsRect: [%d..%d]x[%d..%d]\n", nsrect_clipped.x, nsrect_clipped.xend, nsrect_clipped.y, nsrect_clipped.yend);
 	printf("new brRect: [%d..%d]x[%d..%d]\n", brrect.x, brrect.xend, brrect.y, brrect.yend);

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-10-28 13:43:57 UTC (rev 45462)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-10-28 14:23:23 UTC (rev 45463)
@@ -28,7 +28,6 @@
 #include "sci/resource.h"
 #include "sci/engine/state.h"
 #include "sci/engine/kernel_types.h"
-#include "sci/gfx/operations.h"	// for gfxop_get_cel_parameters
 
 namespace Sci {
 
@@ -729,69 +728,4 @@
 	return true;
 }
 
-Common::Rect set_base(EngineState *s, reg_t object) {
-	SegManager *segMan = s->_segMan;
-	int x, y, original_y, z, ystep, xsize = 0, ysize = 0;
-	int xbase, ybase, xend, yend;
-	int view, loop, cel;
-	int oldloop, oldcel;
-	int xmod = 0, ymod = 0;
-	Common::Rect retval;
-
-	x = (int16)GET_SEL32V(segMan, object, x);
-	original_y = y = (int16)GET_SEL32V(segMan, object, y);
-
-	if (s->_kernel->_selectorCache.z > -1)
-		z = (int16)GET_SEL32V(segMan, object, z);
-	else
-		z = 0;
-
-	y -= z; // Subtract z offset
-
-	ystep = (int16)GET_SEL32V(segMan, object, yStep);
-
-	view = (int16)GET_SEL32V(segMan, object, view);
-	int l = GET_SEL32V(segMan, object, loop);
-	oldloop = loop = (l & 0x80) ? l - 256 : l;
-	int c = GET_SEL32V(segMan, object, cel);
-	oldcel = cel = (c & 0x80) ? c - 256 : c;
-
-	Common::Point offset = Common::Point(0, 0);
-
-	if (loop != oldloop) {
-		loop = 0;
-		PUT_SEL32V(segMan, object, loop, 0);
-		debugC(2, kDebugLevelGraphics, "Resetting loop for %04x:%04x!\n", PRINT_REG(object));
-	}
-
-	if (cel != oldcel) {
-		cel = 0;
-		PUT_SEL32V(segMan, object, cel, 0);
-	}
-
-#ifdef INCLUDE_OLDGFX
-	gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &xsize, &ysize, &offset);
-#else
-	// TODO
-#endif
-
-	xmod = offset.x;
-	ymod = offset.y;
-
-	xbase = x - xmod - (xsize >> 1);
-	xend = xbase + xsize;
-	yend = y /* - ymod */ + 1;
-	ybase = yend - ystep;
-
-	debugC(2, kDebugLevelBaseSetter, "(%d,%d)+/-(%d,%d), (%d x %d) -> (%d, %d) to (%d, %d)\n",
-	          x, y, xmod, ymod, xsize, ysize, xbase, ybase, xend, yend);
-
-	retval.left = xbase;
-	retval.top = ybase;
-	retval.right = xend;
-	retval.bottom = yend;
-
-	return retval;
-}
-
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2009-10-28 13:43:57 UTC (rev 45462)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2009-10-28 14:23:23 UTC (rev 45463)
@@ -236,13 +236,6 @@
 
 
 /******************** Dynamic view list functions ********************/
-/**
- * Determines the base rectangle of the specified view object
- * @param s The state to use
- * @param object The object to set
- * @return The absolute base rectangle
- */
-Common::Rect set_base(EngineState *s, reg_t object);
 
 /**
  * Determines the now-seen rectangle of a view object

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-28 13:43:57 UTC (rev 45462)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-28 14:23:23 UTC (rev 45463)
@@ -491,21 +491,38 @@
 	reg_t object = argv[0];
 
 	if (lookup_selector(s->_segMan, object, s->_kernel->_selectorCache.brLeft, NULL, NULL) == kSelectorVariable) {
-		// Note: there was a check here for a very old version of SCI, which supposedly needed
-		// to subtract 1 from absrect.top. The original check was for version 0.000.256, which
-		// does not exist (earliest one was KQ4 SCI, version 0.000.274). This code is left here
-		// for reference only
-#if 0
-		if (getSciVersion() <= SCI_VERSION_0)
-			--absrect.top; // Compensate for early SCI OB1 'bug'
-#endif
+		SegManager *segMan = s->_segMan;
 
-		Common::Rect absrect = set_base(s, object);
-		SegManager *segMan = s->_segMan;
-		PUT_SEL32V(segMan, object, brLeft, absrect.left);
-		PUT_SEL32V(segMan, object, brRight, absrect.right);
-		PUT_SEL32V(segMan, object, brTop, absrect.top);
-		PUT_SEL32V(segMan, object, brBottom, absrect.bottom);
+		int x = (int16)GET_SEL32V(segMan, object, x);
+		int y = (int16)GET_SEL32V(segMan, object, y);
+		int z = (s->_kernel->_selectorCache.z > -1) ? (int16)GET_SEL32V(segMan, object, z) : 0;
+
+		y -= z; // Subtract z offset
+
+		int ystep = (int16)GET_SEL32V(segMan, object, yStep);
+
+		int view = (int16)GET_SEL32V(segMan, object, view);
+		int loop = GET_SEL32V(segMan, object, loop);
+		int cel = GET_SEL32V(segMan, object, cel);
+
+		Common::Point offset;
+
+		SciGuiView *tmpView = new SciGuiView(s->resMan, NULL, NULL, view);
+		sciViewCelInfo *celInfo = tmpView->getCelInfo(loop, cel);
+		int left = x + celInfo->displaceX - (celInfo->width >> 1);
+		int right = left + celInfo->width;
+		int bottom = y + celInfo->displaceY - z + 1;
+		int top = bottom - celInfo->height;
+
+		debugC(2, kDebugLevelBaseSetter, "(%d,%d)+/-(%d,%d), (%d x %d) -> (%d, %d) to (%d, %d)\n",
+				  x, y, celInfo->displaceX, celInfo->displaceY, celInfo->width, celInfo->height, left, top, bottom, right);
+
+		delete tmpView;
+
+		PUT_SEL32V(segMan, object, brLeft, left);
+		PUT_SEL32V(segMan, object, brRight, right);
+		PUT_SEL32V(segMan, object, brTop, top);
+		PUT_SEL32V(segMan, object, brBottom, bottom);
 	}
 
 	return s->r_acc;


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