aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Montoir2005-04-15 08:34:18 +0000
committerGregory Montoir2005-04-15 08:34:18 +0000
commit7c2e66df0e546083d92223514befa9c475ecba30 (patch)
treea09c052ed17ca58effea5ae8d36e4b65a63f0671
parent4cd1104317b3b1fbb9a01a5b91aeb7091053bc27 (diff)
downloadscummvm-rg350-7c2e66df0e546083d92223514befa9c475ecba30.tar.gz
scummvm-rg350-7c2e66df0e546083d92223514befa9c475ecba30.tar.bz2
scummvm-rg350-7c2e66df0e546083d92223514befa9c475ecba30.zip
Got rid of scaleX and scaleY, previous code was relying on overflow and to get it right, we would have to introduce floating point numbers. Easier, yet less efficient, is just to get rid of those 2 temporary variables and do the multiplications and divisions when needed.
svn-id: r17605
-rw-r--r--scumm/saveload.h2
-rw-r--r--scumm/sprite_he.cpp22
-rw-r--r--scumm/sprite_he.h4
3 files changed, 9 insertions, 19 deletions
diff --git a/scumm/saveload.h b/scumm/saveload.h
index 2d9fbced8f..a84ecd30a7 100644
--- a/scumm/saveload.h
+++ b/scumm/saveload.h
@@ -33,7 +33,7 @@ namespace Scumm {
// Can be useful for other ports too :)
#define VER(x) x
-#define CURRENT_VER 48
+#define CURRENT_VER 49
// To work around a warning in GCC 3.2 (and 3.1 ?) regarding non-POD types,
// we use a small trick: instead of 0 we use 42. Why? Well, it seems newer GCC
diff --git a/scumm/sprite_he.cpp b/scumm/sprite_he.cpp
index 45ee0d123e..74825705b8 100644
--- a/scumm/sprite_he.cpp
+++ b/scumm/sprite_he.cpp
@@ -51,8 +51,8 @@ void ScummEngine_v90he::getSpriteBounds(int spriteId, bool checkGroup, Common::R
SpriteGroup *spg = &_spriteGroups[spi->groupNum];
if (spg->scaling) {
- x1 = spi->tx * spg->scaleX - spr_wiz_x + spg->tx;
- y1 = spi->ty * spg->scaleY - spr_wiz_y + spg->ty;
+ x1 = spi->tx * spg->scale_x_ratio_mul / spg->scale_x_ratio_div - spr_wiz_x + spg->tx;
+ y1 = spi->ty * spg->scale_y_ratio_mul / spg->scale_y_ratio_div - spr_wiz_y + spg->ty;
} else {
x1 = spi->tx - spr_wiz_x + spg->tx;
y1 = spi->ty - spr_wiz_y + spg->ty;
@@ -989,8 +989,6 @@ void ScummEngine_v90he::spriteGroupSet_scale_x_ratio_mul(int spriteGroupId, int
if (_spriteGroups[spriteGroupId].scale_x_ratio_mul != value) {
_spriteGroups[spriteGroupId].scale_x_ratio_mul = value;
- _spriteGroups[spriteGroupId].scaleX = _spriteGroups[spriteGroupId].scale_x_ratio_mul / _spriteGroups[spriteGroupId].scale_x_ratio_div;
-
spriteGroupSet_scaling(spriteGroupId);
redrawSpriteGroup(spriteGroupId);
}
@@ -1004,8 +1002,6 @@ void ScummEngine_v90he::spriteGroupSet_scale_x_ratio_div(int spriteGroupId, int
if (_spriteGroups[spriteGroupId].scale_x_ratio_div != value) {
_spriteGroups[spriteGroupId].scale_x_ratio_div = value;
- _spriteGroups[spriteGroupId].scaleX = _spriteGroups[spriteGroupId].scale_x_ratio_mul / _spriteGroups[spriteGroupId].scale_x_ratio_div;
-
spriteGroupSet_scaling(spriteGroupId);
redrawSpriteGroup(spriteGroupId);
}
@@ -1016,8 +1012,6 @@ void ScummEngine_v90he::spriteGroupSet_scale_y_ratio_mul(int spriteGroupId, int
if (_spriteGroups[spriteGroupId].scale_y_ratio_mul != value) {
_spriteGroups[spriteGroupId].scale_y_ratio_mul = value;
- _spriteGroups[spriteGroupId].scaleY = _spriteGroups[spriteGroupId].scale_y_ratio_mul / _spriteGroups[spriteGroupId].scale_y_ratio_div;
-
spriteGroupSet_scaling(spriteGroupId);
redrawSpriteGroup(spriteGroupId);
}
@@ -1031,8 +1025,6 @@ void ScummEngine_v90he::spriteGroupSet_scale_y_ratio_div(int spriteGroupId, int
if (_spriteGroups[spriteGroupId].scale_y_ratio_div != value) {
_spriteGroups[spriteGroupId].scale_y_ratio_div = value;
- _spriteGroups[spriteGroupId].scaleY = _spriteGroups[spriteGroupId].scale_y_ratio_mul / _spriteGroups[spriteGroupId].scale_y_ratio_div;
-
spriteGroupSet_scaling(spriteGroupId);
redrawSpriteGroup(spriteGroupId);
}
@@ -1067,10 +1059,8 @@ void ScummEngine_v90he::spritesResetGroup(int spriteGroupId) {
spg->dstResNum = 0;
spg->scaling = 0;
- spg->scaleX = 0x3F800000;
spg->scale_x_ratio_mul = 1;
spg->scale_x_ratio_div = 1;
- spg->scaleY = 0x3F800000;
spg->scale_y_ratio_mul = 1;
spg->scale_y_ratio_div = 1;
}
@@ -1270,8 +1260,8 @@ void ScummEngine_v90he::spritesProcessWiz(bool arg) {
SpriteGroup *spg = &_spriteGroups[spi->groupNum];
if (spg->scaling) {
- wiz.img.x1 = spi->tx * spg->scaleX - spr_wiz_x + spg->tx;
- wiz.img.y1 = spi->ty * spg->scaleY - spr_wiz_y + spg->ty;
+ wiz.img.x1 = spi->tx * spg->scale_x_ratio_mul / spg->scale_x_ratio_div - spr_wiz_x + spg->tx;
+ wiz.img.y1 = spi->ty * spg->scale_y_ratio_mul / spg->scale_y_ratio_div - spr_wiz_y + spg->ty;
} else {
wiz.img.x1 = spi->tx - spr_wiz_x + spg->tx;
wiz.img.y1 = spi->ty - spr_wiz_y + spg->ty;
@@ -1440,8 +1430,8 @@ void ScummEngine_v90he::saveOrLoadSpriteData(Serializer *s, uint32 savegameVersi
MKLINE(SpriteGroup, ty, sleInt32, VER(48)),
MKLINE(SpriteGroup, dstResNum, sleInt32, VER(48)),
MKLINE(SpriteGroup, scaling, sleInt32, VER(48)),
- MKLINE(SpriteGroup, scaleX, sleInt32, VER(48)),
- MKLINE(SpriteGroup, scaleY, sleInt32, VER(48)),
+ MK_OBSOLETE(SpriteGroup, scaleX, sleInt32, VER(48), VER(48)),
+ MK_OBSOLETE(SpriteGroup, scaleY, sleInt32, VER(48), VER(48)),
MKLINE(SpriteGroup, scale_x_ratio_mul, sleInt32, VER(48)),
MKLINE(SpriteGroup, scale_x_ratio_div, sleInt32, VER(48)),
MKLINE(SpriteGroup, scale_y_ratio_mul, sleInt32, VER(48)),
diff --git a/scumm/sprite_he.h b/scumm/sprite_he.h
index 5c0af87ebd..6a6500c5ba 100644
--- a/scumm/sprite_he.h
+++ b/scumm/sprite_he.h
@@ -92,8 +92,8 @@ struct SpriteGroup {
int32 ty;
int32 dstResNum;
int32 scaling;
- int32 scaleX;
- int32 scaleY;
+// int32 scaleX;
+// int32 scaleY;
int32 scale_x_ratio_mul;
int32 scale_x_ratio_div;
int32 scale_y_ratio_mul;