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

dreammaster dreammaster at scummvm.org
Sun Dec 17 17:45:17 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:
f8bc19159b XEEN: Correct usage of enlarging scaled drawing


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

Commit Message:
XEEN: Correct usage of enlarging scaled drawing

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


diff --git a/engines/xeen/interface_scene.cpp b/engines/xeen/interface_scene.cpp
index d495d46..35b1ff2 100644
--- a/engines/xeen/interface_scene.cpp
+++ b/engines/xeen/interface_scene.cpp
@@ -145,7 +145,7 @@ OutdoorDrawList::OutdoorDrawList() : _sky1(_data[0]), _sky2(_data[1]),
 	_data[107] = DrawStruct(0, 200, 40, 0, SPRFLAG_HORIZ_FLIPPED | SPRFLAG_SCENE_CLIPPED);
 	_data[108] = DrawStruct(0, 8, 47);
 	_data[109] = DrawStruct(0, 169, 47, 0, SPRFLAG_HORIZ_FLIPPED);
-	_data[110] = DrawStruct(1, -56, -4, 0x8000, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED);
+	_data[110] = DrawStruct(1, -56, -4, SCALE_ENLARGE, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED);
 	_data[111] = DrawStruct(0, -5, 2, 0, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED);
 	_data[112] = DrawStruct(0, -67, 2, 0, SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED);
 	_data[113] = DrawStruct(0, 44, 73);
@@ -477,7 +477,7 @@ void InterfaceScene::drawOutdoorsScene() {
 				ds2._frame = 0;
 				ds2._scale = combat._monsterScale[idx];
 
-				if (ds2._scale == 0x8000) {
+				if (ds2._scale == SCALE_ENLARGE) {
 					ds2._x /= 3;
 					ds2._y = 60;
 				} else {
@@ -493,7 +493,7 @@ void InterfaceScene::drawOutdoorsScene() {
 				ds1._frame = combat._elemPow[idx];
 				ds1._scale = combat._elemScale[idx];
 
-				if (ds1._scale == 0x8000)
+				if (ds1._scale == SCALE_ENLARGE)
 					ds1._x /= 3;
 				ds1._flags = SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED;
 				ds1._sprites = &_charPowSprites;
@@ -614,7 +614,7 @@ void InterfaceScene::drawIndoorsScene() {
 				ds1._x = COMBAT_POS_X[idx][posIndex];
 				ds1._frame = 0;
 				ds1._scale = combat._monsterScale[idx];
-				if (ds1._scale == 0x8000) {
+				if (ds1._scale == SCALE_ENLARGE) {
 					ds1._x /= 3;
 					ds1._y = 60;
 				} else {
@@ -629,7 +629,7 @@ void InterfaceScene::drawIndoorsScene() {
 				ds2._x = COMBAT_POS_X[idx][posIndex] + COMBAT_OFFSET_X[idx];
 				ds2._frame = combat._elemPow[idx];
 				ds2._scale = combat._elemScale[idx];
-				if (ds2._scale == 0x8000)
+				if (ds2._scale == SCALE_ENLARGE)
 					ds2._x /= 3;
 				ds2._flags = SPRFLAG_4000 | SPRFLAG_SCENE_CLIPPED;
 				ds2._sprites = &_charPowSprites;
diff --git a/engines/xeen/sprites.cpp b/engines/xeen/sprites.cpp
index 5a217e0..dac7949 100644
--- a/engines/xeen/sprites.cpp
+++ b/engines/xeen/sprites.cpp
@@ -106,12 +106,12 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi
 	};
 	static const int PATTERN_STEPS[] = { 0, 1, 1, 1, 2, 2, 3, 3, 0, -1, -1, -1, -2, -2, -3, -3 };
 
-	assert(ABS(scale) < 16);
-	uint16 scaleMask = SCALE_TABLE[ABS(scale)];
+	assert((scale & SCALE_MASK) < 16);
+	uint16 scaleMask = SCALE_TABLE[scale & SCALE_MASK];
 	uint16 scaleMaskX = scaleMask, scaleMaskY = scaleMask;
 	bool flipped = (flags & SPRFLAG_HORIZ_FLIPPED) != 0;
 	int xInc = flipped ? -1 : 1;
-	bool enlarge = scale < 0;
+	bool enlarge = (scale & SCALE_ENLARGE) != 0;
 
 	// Get cell header
 	Common::MemoryReadStream f(_data, _filesize);
@@ -269,7 +269,7 @@ void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Poi
 
 				if (bit) {
 					// Check whether there's a pixel to write, and we're within the allowable bounds. Note that for
-					// the SPRFLAG_SCENE_CLIPPED or when scale == 0x8000, we also have an extra horizontal bounds check
+					// the SPRFLAG_SCENE_CLIPPED or when enlarging, we also have an extra horizontal bounds check
 					if (*lineP != -1 && xp >= bounds.left && xp < bounds.right &&
 							((!(flags & SPRFLAG_SCENE_CLIPPED) && !enlarge) || (xp >= SCENE_CLIP_LEFT && xp < SCENE_CLIP_RIGHT))) {
 						drawBounds.left = MIN(drawBounds.left, xp);
diff --git a/engines/xeen/sprites.h b/engines/xeen/sprites.h
index 1970f35..a370cee 100644
--- a/engines/xeen/sprites.h
+++ b/engines/xeen/sprites.h
@@ -35,6 +35,10 @@ namespace Xeen {
 class XeenEngine;
 class Window;
 
+enum {
+	SCALE_MASK = 0x7FFF, SCALE_ENLARGE = 0x8000
+};
+
 enum SpriteFlags {
 	SPRFLAG_800 = 0x800, SPRFLAG_SCENE_CLIPPED = 0x2000,
 	SPRFLAG_4000 = 0x4000, SPRFLAG_HORIZ_FLIPPED = 0x8000,
@@ -110,9 +114,8 @@ public:
 	 * @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
+	 * @param scale		Scale: 0=No scale, SCALE_ENLARGE=Enlarge it
+	 *					1..15   -> reduces the sprite: the higher, the smaller it'll be
 	 */
 	void draw(XSurface &dest, int frame, const Common::Point &destPos,
 		uint flags = 0, int scale = 0);
@@ -123,9 +126,8 @@ public:
 	 * @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
+	 * @param scale		Scale: 0=No scale, SCALE_ENLARGE=Enlarge it
+	 *					1..15   -> reduces the sprite: the higher, the smaller it'll be
 	 */
 	void draw(Window &dest, int frame, const Common::Point &destPos,
 		uint flags = 0, int scale = 0);
@@ -136,9 +138,8 @@ public:
 	 * @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
+	 * @param scale		Scale: 0=No scale, SCALE_ENLARGE=Enlarge it
+	 *					1..15   -> reduces the sprite: the higher, the smaller it'll be
 	 */
 	void draw(int windowIndex, int frame, const Common::Point &destPos,
 		uint flags = 0, int scale = 0);





More information about the Scummvm-git-logs mailing list