diff options
author | Max Horn | 2003-01-13 01:29:45 +0000 |
---|---|---|
committer | Max Horn | 2003-01-13 01:29:45 +0000 |
commit | eb9726c4974111ac56bbc256658785f06d4df531 (patch) | |
tree | ed335402a935d3f49c80675f752a4d1bad1201cd /scumm/boxes.cpp | |
parent | 1f88542417b58ce2e71708217f17ebcc7de78c20 (diff) | |
download | scummvm-rg350-eb9726c4974111ac56bbc256658785f06d4df531.tar.gz scummvm-rg350-eb9726c4974111ac56bbc256658785f06d4df531.tar.bz2 scummvm-rg350-eb9726c4974111ac56bbc256658785f06d4df531.zip |
added V8 scaling code
svn-id: r6440
Diffstat (limited to 'scumm/boxes.cpp')
-rw-r--r-- | scumm/boxes.cpp | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/scumm/boxes.cpp b/scumm/boxes.cpp index a22d5c5ee0..c57ca1e27e 100644 --- a/scumm/boxes.cpp +++ b/scumm/boxes.cpp @@ -50,7 +50,7 @@ struct Box { /* Internal walkbox file format */ int32 llx, lly; uint32 mask; // FIXME - is 'mask' really here? uint32 flags; // FIXME - is 'flags' really here? - uint32 unk1; + uint32 scaleSlot; uint32 scale; uint32 unk2; uint32 unk3; @@ -128,6 +128,59 @@ void Scumm::setBoxScale(int box, int scale) b->old.scale = TO_LE_16(scale); } +int Scumm::getScale(int box, int x, int y) +{ + Box *ptr = getBoxBaseAddr(box); + assert(ptr); + + if (_features & GF_AFTER_V8) { + int slot = FROM_LE_32(ptr->v8.scaleSlot); + if (slot) { + assert(0 <= slot && slot < 20); + int scaleX = 0, scaleY = 0; + ScaleSlot &s = _scaleSlots[slot]; + + 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; + + scaleY = (s.scale2 - s.scale1) * (y - s.y1) / (s.y2 - s.y1) + s.scale1; + if (s.x1 == s.x2) { + return scaleY; + } + } + + scaleX = (s.scale2 - s.scale1) * (x - s.x1) / (s.x2 - s.x1) + s.scale1; + + if (s.y1 == s.y2) { + return scaleX; + } else { + return (scaleX + scaleY - s.x1) / 2; + } + } else + return FROM_LE_32(ptr->v8.scale); + } else { + uint16 scale = FROM_LE_16(ptr->old.scale); + + if (scale & 0x8000) { + scale = (scale & 0x7FFF) + 1; + byte *resptr = getResourceAddress(rtScaleTable, scale); + if (resptr == NULL) + error("Scale table %d not defined", scale); + if (y >= _realHeight) + y = _realHeight - 1; + else if (y < 0) + y = 0; + scale = resptr[y]; + } + + return scale; + } +} + int Scumm::getBoxScale(int box) { if (_features & GF_NO_SCALLING) |