diff options
| author | Paul Gilbert | 2015-05-28 21:47:52 -0400 | 
|---|---|---|
| committer | Paul Gilbert | 2015-05-28 21:47:52 -0400 | 
| commit | a6607ff2d60e7951594a6a2ad8fd319fb776e35b (patch) | |
| tree | 986b35f3ba4641f9f3c24a974f414892ea8f075c | |
| parent | 88d245814314b9e452d02ce8ce8e2aa89bc3ecea (diff) | |
| download | scummvm-rg350-a6607ff2d60e7951594a6a2ad8fd319fb776e35b.tar.gz scummvm-rg350-a6607ff2d60e7951594a6a2ad8fd319fb776e35b.tar.bz2 scummvm-rg350-a6607ff2d60e7951594a6a2ad8fd319fb776e35b.zip | |
SHERLOCK: Implemented flushScaleImage and scale calculations
| -rw-r--r-- | engines/sherlock/resources.cpp | 24 | ||||
| -rw-r--r-- | engines/sherlock/resources.h | 6 | ||||
| -rw-r--r-- | engines/sherlock/screen.cpp | 26 | ||||
| -rw-r--r-- | engines/sherlock/screen.h | 12 | 
4 files changed, 61 insertions, 7 deletions
| diff --git a/engines/sherlock/resources.cpp b/engines/sherlock/resources.cpp index 961286fcf4..f1c705b522 100644 --- a/engines/sherlock/resources.cpp +++ b/engines/sherlock/resources.cpp @@ -469,11 +469,31 @@ void ImageFile::decompressFrame(ImageFrame &frame, const byte *src) {  /*----------------------------------------------------------------*/  int ImageFrame::sDrawXSize(int scaleVal) const { -	error("TODO: sDrawXSize"); +	int width = _width; +	int scale = scaleVal == 0 ? 1 : scaleVal; + +	if (scaleVal >= 256) +		--width; + +	int result = width * 256 / scale; +	if (scaleVal >= 256) +		++result; + +	return result;  }  int ImageFrame::sDrawYSize(int scaleVal) const { -	error("TODO: sDrawYSize"); +	int height = _height; +	int scale = scaleVal == 0 ? 1 : scaleVal; + +	if (scaleVal >= 256) +		--height; + +	int result = height * 256 / scale; +	if (scaleVal >= 256) +		++result; + +	return result;  }  } // End of namespace Sherlock diff --git a/engines/sherlock/resources.h b/engines/sherlock/resources.h index c5b76ac151..5c071e3922 100644 --- a/engines/sherlock/resources.h +++ b/engines/sherlock/resources.h @@ -174,8 +174,14 @@ struct ImageFrame {  	byte _rleMarker;  	Graphics::Surface _frame; +	/** +	 * Return the frame width adjusted by a specified scale amount +	 */  	int sDrawXSize(int scaleVal) const; +	/** +	 * Return the frame height adjusted by a specified scale amount +	 */  	int sDrawYSize(int scaleVal) const;  }; diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp index e826a10fc0..a3af5559c7 100644 --- a/engines/sherlock/screen.cpp +++ b/engines/sherlock/screen.cpp @@ -283,7 +283,31 @@ void Screen::flushImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, i  void Screen::flushScaleImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp,  		int16 *width, int16 *height, int scaleVal) { -	error("TODO"); +	Common::Point imgPos = pt + frame->_offset; +	Common::Rect newBounds(imgPos.x, imgPos.y, imgPos.x + frame->sDrawXSize(scaleVal),  +		imgPos.y + frame->sDrawYSize(scaleVal)); +	Common::Rect oldBounds(*xp, *yp, *xp + *width, *yp + *height); + +	if (!_flushScreen) { +		// See if the areas of the old and new overlap, and if so combine the areas +		if (newBounds.intersects(oldBounds)) { +			Common::Rect mergedBounds = newBounds; +			mergedBounds.extend(oldBounds); +			mergedBounds.right += 1; +			mergedBounds.bottom += 1; + +			slamRect(mergedBounds); +		} else { +			// The two areas are independent, so copy them both +			slamRect(newBounds); +			slamRect(oldBounds); +		} +	} + +	*xp = newBounds.left; +	*yp = newBounds.top; +	*width = newBounds.width(); +	*height = newBounds.height();  }  void Screen::print(const Common::Point &pt, byte color, const char *formatStr, ...) { diff --git a/engines/sherlock/screen.h b/engines/sherlock/screen.h index 949f9debf8..8fda9cbb9c 100644 --- a/engines/sherlock/screen.h +++ b/engines/sherlock/screen.h @@ -181,11 +181,15 @@ public:  	 * Copy an image from the back buffer to the screen, taking care of both the  	 * new area covered by the shape as well as the old area, which must be restored  	 */ -	void flushImage(ImageFrame *frame, const Common::Point &pt, -		int16 *xp, int16 *yp, int16 *width, int16 *height); +	void flushImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp,  +		int16 *width, int16 *height); -	void flushScaleImage(ImageFrame *frame, const Common::Point &pt, -		int16 *xp, int16 *yp, int16 *width, int16 *height, int scaleVal); +	/** +	 * Similar to flushImage, this method takes in an extra parameter for the scale proporation, +	 * which affects the calculated bounds accordingly +	 */ +	void flushScaleImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp,  +		int16 *width, int16 *height, int scaleVal);  	/**  	 * Returns the width of a string in pixels | 
