mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-11 12:18:05 +00:00
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
This commit is contained in:
parent
4cd1104317
commit
7c2e66df0e
@ -33,7 +33,7 @@ namespace Scumm {
|
|||||||
// Can be useful for other ports too :)
|
// Can be useful for other ports too :)
|
||||||
|
|
||||||
#define VER(x) x
|
#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,
|
// 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
|
// we use a small trick: instead of 0 we use 42. Why? Well, it seems newer GCC
|
||||||
|
@ -51,8 +51,8 @@ void ScummEngine_v90he::getSpriteBounds(int spriteId, bool checkGroup, Common::R
|
|||||||
SpriteGroup *spg = &_spriteGroups[spi->groupNum];
|
SpriteGroup *spg = &_spriteGroups[spi->groupNum];
|
||||||
|
|
||||||
if (spg->scaling) {
|
if (spg->scaling) {
|
||||||
x1 = spi->tx * spg->scaleX - spr_wiz_x + spg->tx;
|
x1 = spi->tx * spg->scale_x_ratio_mul / spg->scale_x_ratio_div - spr_wiz_x + spg->tx;
|
||||||
y1 = spi->ty * spg->scaleY - spr_wiz_y + spg->ty;
|
y1 = spi->ty * spg->scale_y_ratio_mul / spg->scale_y_ratio_div - spr_wiz_y + spg->ty;
|
||||||
} else {
|
} else {
|
||||||
x1 = spi->tx - spr_wiz_x + spg->tx;
|
x1 = spi->tx - spr_wiz_x + spg->tx;
|
||||||
y1 = spi->ty - spr_wiz_y + spg->ty;
|
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) {
|
if (_spriteGroups[spriteGroupId].scale_x_ratio_mul != value) {
|
||||||
_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);
|
spriteGroupSet_scaling(spriteGroupId);
|
||||||
redrawSpriteGroup(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) {
|
if (_spriteGroups[spriteGroupId].scale_x_ratio_div != value) {
|
||||||
_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);
|
spriteGroupSet_scaling(spriteGroupId);
|
||||||
redrawSpriteGroup(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) {
|
if (_spriteGroups[spriteGroupId].scale_y_ratio_mul != value) {
|
||||||
_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);
|
spriteGroupSet_scaling(spriteGroupId);
|
||||||
redrawSpriteGroup(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) {
|
if (_spriteGroups[spriteGroupId].scale_y_ratio_div != value) {
|
||||||
_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);
|
spriteGroupSet_scaling(spriteGroupId);
|
||||||
redrawSpriteGroup(spriteGroupId);
|
redrawSpriteGroup(spriteGroupId);
|
||||||
}
|
}
|
||||||
@ -1067,10 +1059,8 @@ void ScummEngine_v90he::spritesResetGroup(int spriteGroupId) {
|
|||||||
|
|
||||||
spg->dstResNum = 0;
|
spg->dstResNum = 0;
|
||||||
spg->scaling = 0;
|
spg->scaling = 0;
|
||||||
spg->scaleX = 0x3F800000;
|
|
||||||
spg->scale_x_ratio_mul = 1;
|
spg->scale_x_ratio_mul = 1;
|
||||||
spg->scale_x_ratio_div = 1;
|
spg->scale_x_ratio_div = 1;
|
||||||
spg->scaleY = 0x3F800000;
|
|
||||||
spg->scale_y_ratio_mul = 1;
|
spg->scale_y_ratio_mul = 1;
|
||||||
spg->scale_y_ratio_div = 1;
|
spg->scale_y_ratio_div = 1;
|
||||||
}
|
}
|
||||||
@ -1270,8 +1260,8 @@ void ScummEngine_v90he::spritesProcessWiz(bool arg) {
|
|||||||
SpriteGroup *spg = &_spriteGroups[spi->groupNum];
|
SpriteGroup *spg = &_spriteGroups[spi->groupNum];
|
||||||
|
|
||||||
if (spg->scaling) {
|
if (spg->scaling) {
|
||||||
wiz.img.x1 = spi->tx * spg->scaleX - spr_wiz_x + spg->tx;
|
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->scaleY - spr_wiz_y + spg->ty;
|
wiz.img.y1 = spi->ty * spg->scale_y_ratio_mul / spg->scale_y_ratio_div - spr_wiz_y + spg->ty;
|
||||||
} else {
|
} else {
|
||||||
wiz.img.x1 = spi->tx - spr_wiz_x + spg->tx;
|
wiz.img.x1 = spi->tx - spr_wiz_x + spg->tx;
|
||||||
wiz.img.y1 = spi->ty - spr_wiz_y + spg->ty;
|
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, ty, sleInt32, VER(48)),
|
||||||
MKLINE(SpriteGroup, dstResNum, sleInt32, VER(48)),
|
MKLINE(SpriteGroup, dstResNum, sleInt32, VER(48)),
|
||||||
MKLINE(SpriteGroup, scaling, sleInt32, VER(48)),
|
MKLINE(SpriteGroup, scaling, sleInt32, VER(48)),
|
||||||
MKLINE(SpriteGroup, scaleX, sleInt32, VER(48)),
|
MK_OBSOLETE(SpriteGroup, scaleX, sleInt32, VER(48), VER(48)),
|
||||||
MKLINE(SpriteGroup, scaleY, sleInt32, 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_mul, sleInt32, VER(48)),
|
||||||
MKLINE(SpriteGroup, scale_x_ratio_div, sleInt32, VER(48)),
|
MKLINE(SpriteGroup, scale_x_ratio_div, sleInt32, VER(48)),
|
||||||
MKLINE(SpriteGroup, scale_y_ratio_mul, sleInt32, VER(48)),
|
MKLINE(SpriteGroup, scale_y_ratio_mul, sleInt32, VER(48)),
|
||||||
|
@ -92,8 +92,8 @@ struct SpriteGroup {
|
|||||||
int32 ty;
|
int32 ty;
|
||||||
int32 dstResNum;
|
int32 dstResNum;
|
||||||
int32 scaling;
|
int32 scaling;
|
||||||
int32 scaleX;
|
// int32 scaleX;
|
||||||
int32 scaleY;
|
// int32 scaleY;
|
||||||
int32 scale_x_ratio_mul;
|
int32 scale_x_ratio_mul;
|
||||||
int32 scale_x_ratio_div;
|
int32 scale_x_ratio_div;
|
||||||
int32 scale_y_ratio_mul;
|
int32 scale_y_ratio_mul;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user