[Scummvm-cvs-logs] scummvm master -> 08124396035e8fd0996c9d347be3d606a58ecd1f

bluegr md5 at scummvm.org
Fri Jun 22 08:32:51 CEST 2012


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

Summary:
0812439603 SCI: Simplify the SCI32 coordinate adjustment code


Commit: 08124396035e8fd0996c9d347be3d606a58ecd1f
    https://github.com/scummvm/scummvm/commit/08124396035e8fd0996c9d347be3d606a58ecd1f
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2012-06-21T23:31:51-07:00

Commit Message:
SCI: Simplify the SCI32 coordinate adjustment code

Changed paths:
    engines/sci/graphics/frameout.cpp
    engines/sci/graphics/frameout.h



diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index 7a9c7ba..0681102 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -62,8 +62,6 @@ GfxFrameout::GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxCoordAd
 	: _segMan(segMan), _resMan(resMan), _cache(cache), _screen(screen), _palette(palette), _paint32(paint32) {
 
 	_coordAdjuster = (GfxCoordAdjuster32 *)coordAdjuster;
-	_scriptsRunningWidth = 320;
-	_scriptsRunningHeight = 200;
 	_curScrollText = -1;
 	_showScrollText = false;
 	_maxScrollTexts = 0;
@@ -129,12 +127,12 @@ void GfxFrameout::kernelAddPlane(reg_t object) {
 		uint16 tmpRunningHeight = readSelectorValue(_segMan, object, SELECTOR(resY));
 
 		// The above can be 0 in SCI3 (e.g. Phantasmagoria 2)
-		if (tmpRunningWidth > 0 && tmpRunningHeight > 0) {
-			_scriptsRunningWidth = tmpRunningWidth;
-			_scriptsRunningHeight = tmpRunningHeight;
+		if (tmpRunningWidth == 0 && tmpRunningHeight == 0) {
+			tmpRunningWidth = 320;
+			tmpRunningHeight = 200;
 		}
 
-		_coordAdjuster->setScriptsResolution(_scriptsRunningWidth, _scriptsRunningHeight);
+		_coordAdjuster->setScriptsResolution(tmpRunningWidth, tmpRunningHeight);
 	}
 
 	newPlane.object = object;
@@ -172,11 +170,8 @@ void GfxFrameout::kernelUpdatePlane(reg_t object) {
 			it->planeRect.bottom = readSelectorValue(_segMan, object, SELECTOR(bottom));
 			it->planeRect.right = readSelectorValue(_segMan, object, SELECTOR(right));
 
-			Common::Rect screenRect(_screen->getWidth(), _screen->getHeight());
-			it->planeRect.top = (it->planeRect.top * screenRect.height()) / _scriptsRunningHeight;
-			it->planeRect.left = (it->planeRect.left * screenRect.width()) / _scriptsRunningWidth;
-			it->planeRect.bottom = (it->planeRect.bottom * screenRect.height()) / _scriptsRunningHeight;
-			it->planeRect.right = (it->planeRect.right * screenRect.width()) / _scriptsRunningWidth;
+			_coordAdjuster->fromScriptToDisplay(it->planeRect.top, it->planeRect.left);
+			_coordAdjuster->fromScriptToDisplay(it->planeRect.bottom, it->planeRect.right);
 
 			// We get negative left in kq7 in scrolling rooms
 			if (it->planeRect.left < 0) {
@@ -241,11 +236,9 @@ void GfxFrameout::kernelDeletePlane(reg_t object) {
 			planeRect.bottom = readSelectorValue(_segMan, object, SELECTOR(bottom));
 			planeRect.right = readSelectorValue(_segMan, object, SELECTOR(right));
 
-			Common::Rect screenRect(_screen->getWidth(), _screen->getHeight());
-			planeRect.top = (planeRect.top * screenRect.height()) / _scriptsRunningHeight;
-			planeRect.left = (planeRect.left * screenRect.width()) / _scriptsRunningWidth;
-			planeRect.bottom = (planeRect.bottom * screenRect.height()) / _scriptsRunningHeight;
-			planeRect.right = (planeRect.right * screenRect.width()) / _scriptsRunningWidth;
+			_coordAdjuster->fromScriptToDisplay(planeRect.top, planeRect.left);
+			_coordAdjuster->fromScriptToDisplay(planeRect.bottom, planeRect.right);
+
 			// Blackout removed plane rect
 			_paint32->fillRect(planeRect, 0);
 			return;
@@ -466,23 +459,6 @@ void GfxFrameout::sortPlanes() {
 	Common::sort(_planes.begin(), _planes.end(), planeSortHelper);
 }
 
-int16 GfxFrameout::upscaleHorizontalCoordinate(int16 coordinate) {
-	return ((coordinate * _screen->getWidth()) / _scriptsRunningWidth);
-}
-
-int16 GfxFrameout::upscaleVerticalCoordinate(int16 coordinate) {
-	return ((coordinate * _screen->getHeight()) / _scriptsRunningHeight);
-}
-
-Common::Rect GfxFrameout::upscaleRect(Common::Rect &rect) {
-	rect.top = (rect.top * _scriptsRunningHeight) / _screen->getHeight();
-	rect.left = (rect.left * _scriptsRunningWidth) / _screen->getWidth();
-	rect.bottom = (rect.bottom * _scriptsRunningHeight) / _screen->getHeight();
-	rect.right = (rect.right * _scriptsRunningWidth) / _screen->getWidth();
-
-	return rect;
-}
-
 void GfxFrameout::showVideo() {
 	bool skipVideo = false;
 	RobotDecoder *videoDecoder = g_sci->_robotDecoder;
@@ -665,10 +641,8 @@ void GfxFrameout::kernelFrameout() {
 			
 			if (itemEntry->object.isNull()) {
 				// Picture cel data
-				itemEntry->x = upscaleHorizontalCoordinate(itemEntry->x);
-				itemEntry->y = upscaleVerticalCoordinate(itemEntry->y);
-				itemEntry->picStartX = upscaleHorizontalCoordinate(itemEntry->picStartX);
-				itemEntry->picStartY = upscaleVerticalCoordinate(itemEntry->picStartY);
+				_coordAdjuster->fromScriptToDisplay(itemEntry->y, itemEntry->x);
+				_coordAdjuster->fromScriptToDisplay(itemEntry->picStartY, itemEntry->picStartX);
 
 				if (!isPictureOutOfView(itemEntry, it->planeRect, it->planeOffsetX, it->planeOffsetY))
 					drawPicture(itemEntry, it->planeOffsetX, it->planeOffsetY, it->planePictureMirrored);
@@ -680,9 +654,9 @@ void GfxFrameout::kernelFrameout() {
 					view->adjustToUpscaledCoordinates(itemEntry->y, itemEntry->x);
 					view->adjustToUpscaledCoordinates(itemEntry->z, dummyX);
 				} else if (getSciVersion() == SCI_VERSION_2_1) {
-					itemEntry->x = upscaleHorizontalCoordinate(itemEntry->x);
-					itemEntry->y = upscaleVerticalCoordinate(itemEntry->y);
-					itemEntry->z = upscaleVerticalCoordinate(itemEntry->z);
+					_coordAdjuster->fromScriptToDisplay(itemEntry->y, itemEntry->x);
+					int16 tmpVal = 0;
+					_coordAdjuster->fromScriptToDisplay(itemEntry->z, tmpVal);
 				}
 
 				// Adjust according to current scroll position
@@ -719,7 +693,8 @@ void GfxFrameout::kernelFrameout() {
 						view->adjustBackUpscaledCoordinates(nsRect.top, nsRect.left);
 						view->adjustBackUpscaledCoordinates(nsRect.bottom, nsRect.right);
 					} else if (getSciVersion() == SCI_VERSION_2_1) {
-						nsRect = upscaleRect(nsRect);
+						_coordAdjuster->fromDisplayToScript(nsRect.top, nsRect.left);
+						_coordAdjuster->fromDisplayToScript(nsRect.bottom, nsRect.right);
 					}
 
 					if (g_sci->getGameId() == GID_PHANTASMAGORIA2) {
diff --git a/engines/sci/graphics/frameout.h b/engines/sci/graphics/frameout.h
index 0d80a68..ecaf450 100644
--- a/engines/sci/graphics/frameout.h
+++ b/engines/sci/graphics/frameout.h
@@ -148,9 +148,6 @@ private:
 	void createPlaneItemList(reg_t planeObject, FrameoutList &itemList);
 	bool isPictureOutOfView(FrameoutEntry *itemEntry, Common::Rect planeRect, int16 planeOffsetX, int16 planeOffsetY);
 	void drawPicture(FrameoutEntry *itemEntry, int16 planeOffsetX, int16 planeOffsetY, bool planePictureMirrored);
-	int16 upscaleHorizontalCoordinate(int16 coordinate);
-	int16 upscaleVerticalCoordinate(int16 coordinate);
-	Common::Rect upscaleRect(Common::Rect &rect);
 
 	SegManager *_segMan;
 	ResourceManager *_resMan;
@@ -169,9 +166,6 @@ private:
 	uint16 _maxScrollTexts;
 
 	void sortPlanes();
-
-	uint16 _scriptsRunningWidth;
-	uint16 _scriptsRunningHeight;
 };
 
 } // End of namespace Sci






More information about the Scummvm-git-logs mailing list