[Scummvm-cvs-logs] scummvm master -> ee8615d6b1a81a7f0c72d06921397deb28844243

csnover csnover at users.noreply.github.com
Sun Mar 13 18:46:28 CET 2016


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
362b46259f SCI32: Implement kCelHigh and kCelWide SCI32 versions
30cb8f5c4f SCI32: Correct some kernel call signatures
ee8615d6b1 SCI32: Clarify the purpose of scaling ratios used in ScreenItem


Commit: 362b46259f75a262fea65c098f7277203dc5a1da
    https://github.com/scummvm/scummvm/commit/362b46259f75a262fea65c098f7277203dc5a1da
Author: Colin Snover (github.com at zetafleet.com)
Date: 2016-03-13T12:40:16-05:00

Commit Message:
SCI32: Implement kCelHigh and kCelWide SCI32 versions

The SCI16 versions do not implement the scaling algorithm used
by SCI32 so would be off by one in some cases.

Changed paths:
    engines/sci/engine/kernel.h
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kgraphics32.cpp



diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index 8321b8d..62566a7 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -491,6 +491,8 @@ reg_t kSetShowStyle(EngineState *s, int argc, reg_t *argv);
 reg_t kSetPalStyleRange(EngineState *s, int argc, reg_t *argv);
 reg_t kGetHighPlanePri(EngineState *s, int argc, reg_t *argv);
 reg_t kFrameOut(EngineState *s, int argc, reg_t *argv);
+reg_t kCelHigh32(EngineState *s, int argc, reg_t *argv);
+reg_t kCelWide32(EngineState *s, int argc, reg_t *argv);
 
 reg_t kIsOnMe(EngineState *s, int argc, reg_t *argv); // kOnMe for SCI2, kIsOnMe for SCI2.1
 reg_t kInPolygon(EngineState *s, int argc, reg_t *argv);
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index a61eb5a..08a1527 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -461,8 +461,12 @@ static SciKernelMapEntry s_kernelMap[] = {
 #ifdef ENABLE_SCI32
 	{ MAP_CALL(CantBeHere),        SIG_SCI32, SIGFOR_ALL,    "ol",                    NULL,            NULL },
 #endif
-	{ MAP_CALL(CelHigh),           SIG_EVERYWHERE,           "ii(i)",                 NULL,            kCelHigh_workarounds },
-	{ MAP_CALL(CelWide),           SIG_EVERYWHERE,           "ii(i)",                 NULL,            kCelWide_workarounds },
+	{ MAP_CALL(CelHigh),           SIG_SCI16, SIGFOR_ALL,    "ii(i)",                 NULL,            kCelHigh_workarounds },
+	{ MAP_CALL(CelWide),           SIG_SCI16, SIGFOR_ALL,    "ii(i)",                 NULL,            kCelWide_workarounds },
+#ifdef ENABLE_SCI32
+	{ "CelHigh", kCelHigh32,       SIG_SCI32, SIGFOR_ALL,    "iii",                   NULL,            NULL },
+	{ "CelWide", kCelWide32,       SIG_SCI32, SIGFOR_ALL,    "iii",                   NULL,            NULL },
+#endif
 	{ MAP_CALL(CheckFreeSpace),    SIG_SCI32, SIGFOR_ALL,    "r.*",                   NULL,            NULL },
 	{ MAP_CALL(CheckFreeSpace),    SIG_SCI11, SIGFOR_ALL,    "r(i)",                  NULL,            NULL },
 	{ MAP_CALL(CheckFreeSpace),    SIG_EVERYWHERE,           "r",                     NULL,            NULL },
diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index b64aff7..6e45944 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -310,6 +310,22 @@ reg_t kSetShowStyle(EngineState *s, int argc, reg_t *argv) {
 	return NULL_REG;
 }
 
+reg_t kCelHigh32(EngineState *s, int argc, reg_t *argv) {
+	GuiResourceId resourceId = argv[0].toUint16();
+	int16 loopNo = argv[1].toSint16();
+	int16 celNo = argv[2].toSint16();
+	CelObjView celObj(resourceId, loopNo, celNo);
+	return make_reg(0, mulru(celObj._height, Ratio(g_sci->_gfxFrameout->getCurrentBuffer().scriptHeight, celObj._scaledHeight)));
+}
+
+reg_t kCelWide32(EngineState *s, int argc, reg_t *argv) {
+	GuiResourceId resourceId = argv[0].toUint16();
+	int16 loopNo = argv[1].toSint16();
+	int16 celNo = argv[2].toSint16();
+	CelObjView celObj(resourceId, loopNo, celNo);
+	return make_reg(0, mulru(celObj._width, Ratio(g_sci->_gfxFrameout->getCurrentBuffer().scriptWidth, celObj._scaledWidth)));
+}
+
 reg_t kCelInfo(EngineState *s, int argc, reg_t *argv) {
 	// Used by Shivers 1, room 23601 to determine what blocks on the red door puzzle board
 	// are occupied by pieces already


Commit: 30cb8f5c4fc52ce213fb7c33f0bb22915ce5df38
    https://github.com/scummvm/scummvm/commit/30cb8f5c4fc52ce213fb7c33f0bb22915ce5df38
Author: Colin Snover (github.com at zetafleet.com)
Date: 2016-03-13T12:45:59-05:00

Commit Message:
SCI32: Correct some kernel call signatures

Changed paths:
    engines/sci/engine/kernel_tables.h



diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 08a1527..3463d05 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -730,8 +730,8 @@ static SciKernelMapEntry s_kernelMap[] = {
 	{ MAP_CALL(WinHelp),           SIG_EVERYWHERE,           "(.*)",                  NULL,            NULL },
 	{ MAP_CALL(GetConfig),         SIG_EVERYWHERE,           "ro",                    NULL,            NULL },
 	{ MAP_CALL(GetSierraProfileInt), SIG_EVERYWHERE,         "rri",                   NULL,            NULL },
-	{ MAP_CALL(CelInfo),           SIG_EVERYWHERE,           "iiiiii",                NULL,            NULL },
-	{ MAP_CALL(SetLanguage),       SIG_EVERYWHERE,           "r",                     NULL,            NULL },
+	{ MAP_CALL(CelInfo),           SIG_SINCE_SCI21MID, SIGFOR_ALL, "iiiiii",          NULL,            NULL },
+	{ MAP_CALL(SetLanguage),       SIG_SINCE_SCI21MID, SIGFOR_ALL, "r",               NULL,            NULL },
 	{ MAP_CALL(ScrollWindow),      SIG_EVERYWHERE,           "i(.*)",                 kScrollWindow_subops, NULL },
 	{ MAP_CALL(SetFontRes),        SIG_SCI21EARLY, SIGFOR_ALL, "ii",                  NULL,            NULL },
 	{ MAP_CALL(Font),              SIG_SINCE_SCI21MID, SIGFOR_ALL, "i(.*)",           kFont_subops,    NULL },


Commit: ee8615d6b1a81a7f0c72d06921397deb28844243
    https://github.com/scummvm/scummvm/commit/ee8615d6b1a81a7f0c72d06921397deb28844243
Author: Colin Snover (github.com at zetafleet.com)
Date: 2016-03-13T12:45:59-05:00

Commit Message:
SCI32: Clarify the purpose of scaling ratios used in ScreenItem

Changed paths:
    engines/sci/graphics/screen_item32.cpp



diff --git a/engines/sci/graphics/screen_item32.cpp b/engines/sci/graphics/screen_item32.cpp
index 41771c8..c44d3e9 100644
--- a/engines/sci/graphics/screen_item32.cpp
+++ b/engines/sci/graphics/screen_item32.cpp
@@ -241,28 +241,33 @@ void ScreenItem::calcRects(const Plane &plane) {
 		_insetRect = celRect;
 	}
 
-	Ratio newRatioX;
-	Ratio newRatioY;
+	Ratio scaleX, scaleY;
 
 	if (_scale.signal & kScaleSignalDoScaling32) {
 		if (_scale.signal & kScaleSignalUseVanishingPoint) {
 			int num = _scale.max * (_position.y - plane._vanishingPoint.y) / (scriptWidth - plane._vanishingPoint.y);
-			newRatioX = Ratio(num, 128);
-			newRatioY = Ratio(num, 128);
+			scaleX = Ratio(num, 128);
+			scaleY = Ratio(num, 128);
 		} else {
-			newRatioX = Ratio(_scale.x, 128);
-			newRatioY = Ratio(_scale.y, 128);
+			scaleX = Ratio(_scale.x, 128);
+			scaleY = Ratio(_scale.y, 128);
 		}
 	}
 
-	if (newRatioX.getNumerator() && newRatioY.getNumerator()) {
+	if (scaleX.getNumerator() && scaleY.getNumerator()) {
 		_screenItemRect = _insetRect;
 
+		const Ratio celToScreenX(screenWidth, celObj._scaledWidth);
+		const Ratio celToScreenY(screenHeight, celObj._scaledHeight);
+
+		// Cel may use a coordinate system that is not the same size as the
+		// script coordinate system (usually this means high-resolution
+		// pictures with low-resolution scripts)
 		if (celObj._scaledWidth != scriptWidth || celObj._scaledHeight != scriptHeight) {
 			if (_useInsetRect) {
-				Ratio celScriptXRatio(celObj._scaledWidth, scriptWidth);
-				Ratio celScriptYRatio(celObj._scaledHeight, scriptHeight);
-				mulru(_screenItemRect, celScriptXRatio, celScriptYRatio, 0);
+				const Ratio scriptToCelX(celObj._scaledWidth, scriptWidth);
+				const Ratio scriptToCelY(celObj._scaledHeight, scriptHeight);
+				mulru(_screenItemRect, scriptToCelX, scriptToCelY, 0);
 
 				if (_screenItemRect.intersects(celRect)) {
 					_screenItemRect.clip(celRect);
@@ -278,26 +283,25 @@ void ScreenItem::calcRects(const Plane &plane) {
 				displaceX = celObj._width - celObj._displace.x - 1;
 			}
 
-			if (!newRatioX.isOne() || !newRatioY.isOne()) {
-				mulinc(_screenItemRect, newRatioX, newRatioY);
-				displaceX = (displaceX * newRatioX).toInt();
-				displaceY = (displaceY * newRatioY).toInt();
+			if (!scaleX.isOne() || !scaleY.isOne()) {
+				mulinc(_screenItemRect, scaleX, scaleY);
+				displaceX = (displaceX * scaleX).toInt();
+				displaceY = (displaceY * scaleY).toInt();
 			}
 
-			Ratio celXRatio(screenWidth, celObj._scaledWidth);
-			Ratio celYRatio(screenHeight, celObj._scaledHeight);
-
-			displaceX = (displaceX * celXRatio).toInt();
-			displaceY = (displaceY * celYRatio).toInt();
+			mulinc(_screenItemRect, celToScreenX, celToScreenY);
+			displaceX = (displaceX * celToScreenX).toInt();
+			displaceY = (displaceY * celToScreenY).toInt();
 
-			mulinc(_screenItemRect, celXRatio, celYRatio);
+			const Ratio scriptToScreenX = Ratio(screenWidth, scriptWidth);
+			const Ratio scriptToScreenY = Ratio(screenHeight, scriptHeight);
 
 			if (/* TODO: dword_C6288 */ false && _celInfo.type == kCelTypePic) {
 				_scaledPosition.x = _position.x;
 				_scaledPosition.y = _position.y;
 			} else {
-				_scaledPosition.x = (_position.x * screenWidth / scriptWidth) - displaceX;
-				_scaledPosition.y = (_position.y * screenHeight / scriptHeight) - displaceY;
+				_scaledPosition.x = (_position.x * scriptToScreenX).toInt() - displaceX;
+				_scaledPosition.y = (_position.y * scriptToScreenY).toInt() - displaceY;
 			}
 
 			_screenItemRect.translate(_scaledPosition.x, _scaledPosition.y);
@@ -305,14 +309,14 @@ void ScreenItem::calcRects(const Plane &plane) {
 			if (_mirrorX != celObj._mirrorX && _celInfo.type == kCelTypePic) {
 				Common::Rect temp(_insetRect);
 
-				if (!newRatioX.isOne()) {
-					mulinc(temp, newRatioX, Ratio());
+				if (!scaleX.isOne()) {
+					mulinc(temp, scaleX, Ratio());
 				}
 
-				mulinc(temp, celXRatio, Ratio());
+				mulinc(temp, celToScreenX, Ratio());
 
 				CelObjPic *celObjPic = dynamic_cast<CelObjPic *>(_celObj);
-				temp.translate(celObjPic->_relativePosition.x * screenWidth / scriptWidth - displaceX, 0);
+				temp.translate((celObjPic->_relativePosition.x * scriptToScreenX).toInt() - displaceX, 0);
 
 				// TODO: This is weird.
 				int deltaX = plane._planeRect.width() - temp.right - 1 - temp.left;
@@ -325,16 +329,16 @@ void ScreenItem::calcRects(const Plane &plane) {
 			_scaledPosition.y += plane._planeRect.top;
 			_screenItemRect.translate(plane._planeRect.left, plane._planeRect.top);
 
-			_ratioX = newRatioX * Ratio(screenWidth, celObj._scaledWidth);
-			_ratioY = newRatioY * Ratio(screenHeight, celObj._scaledHeight);
+			_ratioX = scaleX * celToScreenX;
+			_ratioY = scaleY * celToScreenY;
 		} else {
 			int displaceX = celObj._displace.x;
 			if (_mirrorX != celObj._mirrorX && _celInfo.type != kCelTypePic) {
 				displaceX = celObj._width - celObj._displace.x - 1;
 			}
 
-			if (!newRatioX.isOne() || !newRatioY.isOne()) {
-				mulinc(_screenItemRect, newRatioX, newRatioY);
+			if (!scaleX.isOne() || !scaleY.isOne()) {
+				mulinc(_screenItemRect, scaleX, scaleY);
 				// TODO: This was in the original code, baked into the
 				// multiplication though it is not immediately clear
 				// why this is the only one that reduces the BR corner
@@ -342,20 +346,20 @@ void ScreenItem::calcRects(const Plane &plane) {
 				_screenItemRect.bottom -= 1;
 			}
 
-			_scaledPosition.x = _position.x - (displaceX * newRatioX).toInt();
-			_scaledPosition.y = _position.y - (celObj._displace.y * newRatioY).toInt();
+			_scaledPosition.x = _position.x - (displaceX * scaleX).toInt();
+			_scaledPosition.y = _position.y - (celObj._displace.y * scaleY).toInt();
 			_screenItemRect.translate(_scaledPosition.x, _scaledPosition.y);
 
 			if (_mirrorX != celObj._mirrorX && _celInfo.type == kCelTypePic) {
 				Common::Rect temp(_insetRect);
 
-				if (!newRatioX.isOne()) {
-					mulinc(temp, newRatioX, Ratio());
+				if (!scaleX.isOne()) {
+					mulinc(temp, scaleX, Ratio());
 					temp.right -= 1;
 				}
 
 				CelObjPic *celObjPic = dynamic_cast<CelObjPic *>(_celObj);
-				temp.translate(celObjPic->_relativePosition.x - (displaceX * newRatioX).toInt(), celObjPic->_relativePosition.y - (celObj._displace.y * newRatioY).toInt());
+				temp.translate(celObjPic->_relativePosition.x - (displaceX * scaleX).toInt(), celObjPic->_relativePosition.y - (celObj._displace.y * scaleY).toInt());
 
 				// TODO: This is weird.
 				int deltaX = plane._gameRect.width() - temp.right - 1 - temp.left;
@@ -368,15 +372,13 @@ void ScreenItem::calcRects(const Plane &plane) {
 			_scaledPosition.y += plane._gameRect.top;
 			_screenItemRect.translate(plane._gameRect.left, plane._gameRect.top);
 
-			if (screenWidth != celObj._scaledWidth || celObj._scaledHeight != screenHeight) {
-				Ratio celXRatio(screenWidth, celObj._scaledWidth);
-				Ratio celYRatio(screenHeight, celObj._scaledHeight);
-				mulru(_scaledPosition, celXRatio, celYRatio);
-				mulru(_screenItemRect, celXRatio, celYRatio, 1);
+			if (celObj._scaledWidth != screenWidth || celObj._scaledHeight != screenHeight) {
+				mulru(_scaledPosition, celToScreenX, celToScreenY);
+				mulru(_screenItemRect, celToScreenX, celToScreenY, 1);
 			}
 
-			_ratioX = newRatioX * Ratio(screenWidth, celObj._scaledWidth);
-			_ratioY = newRatioY * Ratio(screenHeight, celObj._scaledHeight);
+			_ratioX = scaleX * celToScreenX;
+			_ratioY = scaleY * celToScreenY;
 		}
 
 		_screenRect = _screenItemRect;
@@ -547,9 +549,9 @@ Common::Rect ScreenItem::getNowSeenRect(const Plane &plane) const {
 
 	if (celObj._scaledWidth != scriptWidth || celObj._scaledHeight != scriptHeight) {
 		if (_useInsetRect) {
-			Ratio scriptToScaledX(celObj._scaledWidth, scriptWidth);
-			Ratio scriptToScaledY(celObj._scaledHeight, scriptHeight);
-			mulru(nsRect, scriptToScaledX, scriptToScaledY, 0);
+			Ratio scriptToCelX(celObj._scaledWidth, scriptWidth);
+			Ratio scriptToCelY(celObj._scaledHeight, scriptHeight);
+			mulru(nsRect, scriptToCelX, scriptToCelY, 0);
 
 			// TODO: This is weird. Checking to see if the inset rect is
 			// fully inside the bounds of the celObjRect, and then
@@ -570,13 +572,13 @@ Common::Rect ScreenItem::getNowSeenRect(const Plane &plane) const {
 			nsRect.bottom -= 1;
 		}
 
-		Ratio scaledToScriptX(scriptWidth, celObj._scaledWidth);
-		Ratio scaledToScriptY(scriptHeight, celObj._scaledHeight);
+		Ratio celToScriptX(scriptWidth, celObj._scaledWidth);
+		Ratio celToScriptY(scriptHeight, celObj._scaledHeight);
 
-		displaceX = (displaceX * scaleX * scaledToScriptX).toInt();
-		displaceY = (displaceY * scaleY * scaledToScriptY).toInt();
+		displaceX = (displaceX * scaleX * celToScriptX).toInt();
+		displaceY = (displaceY * scaleY * celToScriptY).toInt();
 
-		mulinc(nsRect, scaledToScriptX, scaledToScriptY);
+		mulinc(nsRect, celToScriptX, celToScriptY);
 		nsRect.translate(_position.x - displaceX, _position.y - displaceY);
 	} else {
 		if (!scaleX.isOne() || !scaleY.isOne()) {






More information about the Scummvm-git-logs mailing list