diff options
author | Travis Howell | 2004-11-05 05:13:56 +0000 |
---|---|---|
committer | Travis Howell | 2004-11-05 05:13:56 +0000 |
commit | df17c27ebf688309c97efa6638088d396087fe20 (patch) | |
tree | 27414b4507feb6659d5ab98461f531b3a5832981 /scumm | |
parent | 775bd838c7a2857a1ca755494994e178a7707b00 (diff) | |
download | scummvm-rg350-df17c27ebf688309c97efa6638088d396087fe20.tar.gz scummvm-rg350-df17c27ebf688309c97efa6638088d396087fe20.tar.bz2 scummvm-rg350-df17c27ebf688309c97efa6638088d396087fe20.zip |
Add patch #1060453 - MIVGA: Actor Scale Patch
svn-id: r15712
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/actor.cpp | 2 | ||||
-rw-r--r-- | scumm/boxes.cpp | 60 | ||||
-rw-r--r-- | scumm/scumm.h | 1 |
3 files changed, 35 insertions, 28 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp index e6b367a6ee..9609ae41ef 100644 --- a/scumm/actor.cpp +++ b/scumm/actor.cpp @@ -1036,7 +1036,7 @@ void Actor::drawActorCostume(bool hitTestMode) { bcr->_clipOverride = _clipOverride; if (_vm->_version == 4 && boxscale & 0x8000) { - bcr->_scaleX = bcr->_scaleY = _vm->getScale(_walkbox, _pos.x, _pos.y); + bcr->_scaleX = bcr->_scaleY = _vm->getScaleFromSlot((boxscale & 0x7fff) + 1, _pos.x, _pos.y); } else { bcr->_scaleX = scalex; bcr->_scaleY = scaley; diff --git a/scumm/boxes.cpp b/scumm/boxes.cpp index c3dfc2b2d1..7da38cbd49 100644 --- a/scumm/boxes.cpp +++ b/scumm/boxes.cpp @@ -177,40 +177,46 @@ int ScummEngine::getScale(int box, int x, int y) { // Was a scale slot specified? If so, we compute the effective scale // from it, ignoring the box scale. - if (slot) { - assert(1 <= slot && slot <= ARRAYSIZE(_scaleSlots)); - int scaleX = 0, scaleY = 0; - ScaleSlot &s = _scaleSlots[slot-1]; + if (slot) + scale = getScaleFromSlot(slot, x, y); + + return scale; +} - if (s.y1 == s.y2 && s.x1 == s.x2) - error("Invalid scale slot %d", slot); - if (s.y1 != s.y2) { - if (y < 0) - y = 0; +int ScummEngine::getScaleFromSlot(int slot, int x, int y) { + assert(1 <= slot && slot <= ARRAYSIZE(_scaleSlots)); + int scale; + int scaleX = 0, scaleY = 0; + ScaleSlot &s = _scaleSlots[slot-1]; - scaleY = (s.scale2 - s.scale1) * (y - s.y1) / (s.y2 - s.y1) + s.scale1; - } - if (s.x1 == s.x2) { - scale = scaleY; - } else { - scaleX = (s.scale2 - s.scale1) * (x - s.x1) / (s.x2 - s.x1) + s.scale1; + if (s.y1 == s.y2 && s.x1 == s.x2) + error("Invalid scale slot %d", slot); - if (s.y1 == s.y2) { - scale = scaleX; - } else { - scale = (scaleX + scaleY) / 2; - } - } + if (s.y1 != s.y2) { + if (y < 0) + y = 0; - // Clip the scale to range 1-255 - if (scale < 1) - scale = 1; - else if (scale > 255) - scale = 255; + scaleY = (s.scale2 - s.scale1) * (y - s.y1) / (s.y2 - s.y1) + s.scale1; + } + if (s.x1 == s.x2) { + scale = scaleY; + } else { + scaleX = (s.scale2 - s.scale1) * (x - s.x1) / (s.x2 - s.x1) + s.scale1; + + if (s.y1 == s.y2) { + scale = scaleX; + } else { + scale = (scaleX + scaleY) / 2; + } } + + // Clip the scale to range 1-255 + if (scale < 1) + scale = 1; + else if (scale > 255) + scale = 255; - // Finally return the scale return scale; } diff --git a/scumm/scumm.h b/scumm/scumm.h index bed8d1137e..61029f4689 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -1117,6 +1117,7 @@ public: int getBoxScale(int box); int getScale(int box, int x, int y); + int getScaleFromSlot(int slot, int x, int y); protected: // Scaling slots/items |