[Scummvm-git-logs] scummvm master -> a124b1d26a6b2e7d121a48b45d5aaf9f413dbe80

dreammaster dreammaster at scummvm.org
Sun Dec 17 17:08:21 CET 2017


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:
a124b1d26a XEEN: Cleanup and comments for SpriteResource class


Commit: a124b1d26a6b2e7d121a48b45d5aaf9f413dbe80
    https://github.com/scummvm/scummvm/commit/a124b1d26a6b2e7d121a48b45d5aaf9f413dbe80
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-12-17T11:08:09-05:00

Commit Message:
XEEN: Cleanup and comments for SpriteResource class

Changed paths:
    engines/xeen/sprites.cpp
    engines/xeen/sprites.h


diff --git a/engines/xeen/sprites.cpp b/engines/xeen/sprites.cpp
index 430505e..5a217e0 100644
--- a/engines/xeen/sprites.cpp
+++ b/engines/xeen/sprites.cpp
@@ -37,13 +37,11 @@ SpriteResource::SpriteResource() {
 	_filesize = 0;
 	_data = nullptr;
 	_scaledWidth = _scaledHeight = 0;
-	Common::fill(&_lineDist[0], &_lineDist[SCREEN_WIDTH], false);
 }
 
 SpriteResource::SpriteResource(const Common::String &filename) {
 	_data = nullptr;
 	_scaledWidth = _scaledHeight = 0;
-	Common::fill(&_lineDist[0], &_lineDist[SCREEN_WIDTH], false);
 	load(filename);
 }
 
@@ -101,18 +99,19 @@ void SpriteResource::clear() {
 }
 
 void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Point &pt,
-		const Common::Rect &clipRect, int flags, int scale) {
+		const Common::Rect &clipRect, uint flags, int scale) {
 	static const uint SCALE_TABLE[] = {
 		0xFFFF, 0xFFEF, 0xEFEF, 0xEFEE, 0xEEEE, 0xEEAE, 0xAEAE, 0xAEAA,
 		0xAAAA, 0xAA8A, 0x8A8A, 0x8A88, 0x8888, 0x8880, 0x8080, 0x8000
 	};
 	static const int PATTERN_STEPS[] = { 0, 1, 1, 1, 2, 2, 3, 3, 0, -1, -1, -1, -2, -2, -3, -3 };
 
-	uint16 scaleMask = SCALE_TABLE[scale & 0x7fff];
+	assert(ABS(scale) < 16);
+	uint16 scaleMask = SCALE_TABLE[ABS(scale)];
 	uint16 scaleMaskX = scaleMask, scaleMaskY = scaleMask;
 	bool flipped = (flags & SPRFLAG_HORIZ_FLIPPED) != 0;
 	int xInc = flipped ? -1 : 1;
-	bool enlarge = (scale & 0x8000) != 0;
+	bool enlarge = scale < 0;
 
 	// Get cell header
 	Common::MemoryReadStream f(_data, _filesize);
@@ -299,24 +298,25 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi
 }
 
 void SpriteResource::draw(XSurface &dest, int frame, const Common::Point &destPos,
-		int flags, int scale) {
+		uint flags, int scale) {
 	draw(dest, frame, destPos, Common::Rect(0, 0, dest.w, dest.h), flags, scale);
 }
 
 void SpriteResource::draw(Window &dest, int frame, const Common::Point &destPos,
-		int flags, int scale) {
+		uint flags, int scale) {
 	draw(dest, frame, destPos, dest.getBounds(), flags, scale);
 }
 
 void SpriteResource::draw(int windowIndex, int frame, const Common::Point &destPos,
-		int flags, int scale) {
+		uint flags, int scale) {
 	Window &win = (*g_vm->_windows)[windowIndex];
 	draw(win, frame, destPos, flags, scale);
 }
 
 void SpriteResource::draw(XSurface &dest, int frame, const Common::Point &destPos,
-		const Common::Rect &bounds, int flags, int scale) {
+		const Common::Rect &bounds, uint flags, int scale) {
 
+	// Sprites can consist of separate background & foreground
 	drawOffset(dest, _index[frame]._offset1, destPos, bounds, flags, scale);
 	if (_index[frame]._offset2)
 		drawOffset(dest, _index[frame]._offset2, destPos, bounds, flags, scale);
diff --git a/engines/xeen/sprites.h b/engines/xeen/sprites.h
index b94b7c9..1970f35 100644
--- a/engines/xeen/sprites.h
+++ b/engines/xeen/sprites.h
@@ -49,7 +49,6 @@ private:
 	Common::Array<IndexEntry> _index;
 	int32 _filesize;
 	byte *_data;
-	bool _lineDist[320];
 	int _scaledWidth, _scaledHeight;
 
 	/**
@@ -61,19 +60,19 @@ private:
 	 * Draw the sprite onto the given surface
 	 */
 	void draw(XSurface &dest, int frame, const Common::Point &destPos,
-		const Common::Rect &bounds, int flags = 0, int scale = 0);
+		const Common::Rect &bounds, uint flags = 0, int scale = 0);
 
 	/**
 	 * Draw the sprite onto a given window
 	 */
 	void draw(int windowNum, int frame, const Common::Point &destPos,
-		const Common::Rect &bounds, int flags = 0, int scale = 0);
+		const Common::Rect &bounds, uint flags = 0, int scale = 0);
 
 	/**
 	 * Draw a sprite frame based on a passed offset into the data stream
 	 */
 	void drawOffset(XSurface &dest, uint16 offset, const Common::Point &pt,
-		const Common::Rect &clipRect, int flags, int scale);
+		const Common::Rect &clipRect, uint flags, int scale);
 
 	/**
 	 * Scale a co-ordinate value based on the passed scaling mask
@@ -107,34 +106,65 @@ public:
 
 	/**
 	 * Draw a sprite onto a surface
+	 * @param dest		Destination surface
+	 * @param frame		Frame number
+	 * @param destPos	Destination position
+	 * @param flags		Flags
+	 * @param scale		Scale: 0=No scale
+	 *					1..15   -> reduces the sprite: the higher, the smaller it'll be.
+	 *					-1..-15 -> enlarges the sprite
 	 */
 	void draw(XSurface &dest, int frame, const Common::Point &destPos,
-		int flags = 0, int scale = 0);
+		uint flags = 0, int scale = 0);
 
 	/**
 	 * Draw a sprite onto a specific window
+	 * @param dest		Destination window
+	 * @param frame		Frame number
+	 * @param destPos	Destination position
+	 * @param flags		Flags
+	 * @param scale		Scale: 0=No scale
+	 *					1..15   -> reduces the sprite: the higher, the smaller it'll be.
+	 *					-1..-15 -> enlarges the sprite
 	 */
 	void draw(Window &dest, int frame, const Common::Point &destPos,
-		int flags = 0, int scale = 0);
+		uint flags = 0, int scale = 0);
 
 	/**
 	 * Draw a sprite onto a given window
+	 * @param windowIndex	Destination window number
+	 * @param frame		Frame number
+	 * @param destPos	Destination position
+	 * @param flags		Flags
+	 * @param scale		Scale: 0=No scale
+	 *					1..15   -> reduces the sprite: the higher, the smaller it'll be.
+	 *					-1..-15 -> enlarges the sprite
 	 */
 	void draw(int windowIndex, int frame, const Common::Point &destPos,
-		int flags = 0, int scale = 0);
+		uint flags = 0, int scale = 0);
 
 	/**
 	 * Draw the sprite onto the given surface
+	 * @param dest		Destination surface
+	 * @param frame		Frame number
 	 */
 	void draw(XSurface &dest, int frame);
 
 	/**
 	 * Draw the sprite onto the given window
+	 * @param windowIndex	Destination window number
+	 * @param frame			Frame number
 	 */
 	void draw(int windowIndex, int frame);
 
-	int size() const { return _index.size(); }
+	/**
+	 * Returns the number of frames the sprite resource has
+	 */
+	size_t size() const { return _index.size(); }
 
+	/**
+	 * Returns true if the sprite resource is empty (ie. nothing is loaded)
+	 */
 	bool empty() const { return _index.size() == 0; }
 };
 





More information about the Scummvm-git-logs mailing list