diff options
author | Colin Snover | 2017-08-04 18:53:00 -0500 |
---|---|---|
committer | Colin Snover | 2017-09-03 20:58:07 -0500 |
commit | 43a07abb46cc55d09f7415090f9f53c068c856aa (patch) | |
tree | bf31cbe8d30dadce8706e9484d519e71b73afc9e /engines/sci/graphics | |
parent | d2b4e16ab2bd28ce8b39a6330683228bd48950c2 (diff) | |
download | scummvm-rg350-43a07abb46cc55d09f7415090f9f53c068c856aa.tar.gz scummvm-rg350-43a07abb46cc55d09f7415090f9f53c068c856aa.tar.bz2 scummvm-rg350-43a07abb46cc55d09f7415090f9f53c068c856aa.zip |
SCI32: Implement kCelLink
kCelLink exists in SSCI since 2.1mid, but it is only known to be
used in Lighthouse, during the weapon creation puzzle near the end
of the game.
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r-- | engines/sci/graphics/celobj32.cpp | 32 | ||||
-rw-r--r-- | engines/sci/graphics/celobj32.h | 2 |
2 files changed, 34 insertions, 0 deletions
diff --git a/engines/sci/graphics/celobj32.cpp b/engines/sci/graphics/celobj32.cpp index 49b3b0053b..687ecd64f3 100644 --- a/engines/sci/graphics/celobj32.cpp +++ b/engines/sci/graphics/celobj32.cpp @@ -1081,6 +1081,38 @@ const SciSpan<const byte> CelObjView::getResPointer() const { return *resource; } +Common::Point CelObjView::getLinkPosition(const int16 linkId) const { + const SciSpan<const byte> resource = getResPointer(); + + if (resource[18] < 0x84) { + error("%s unsupported version %u for Links", _info.toString().c_str(), resource[18]); + } + + const SciSpan<const byte> celHeader = resource.subspan(_celHeaderOffset); + const int16 numLinks = celHeader.getInt16SEAt(40); + + if (numLinks) { + const int recordSize = 6; + SciSpan<const byte> linkTable = resource.subspan(celHeader.getInt32SEAt(36), recordSize * numLinks); + for (int16 i = 0; i < numLinks; ++i) { + if (linkTable[4] == linkId) { + Common::Point point; + point.x = linkTable.getInt16SEAt(0); + if (_mirrorX) { + // NOTE: SSCI had an off-by-one error here (missing -1) + point.x = _width - point.x - 1; + } + point.y = linkTable.getInt16SEAt(2); + return point; + } + + linkTable += recordSize; + } + } + + return Common::Point(-1, -1); +} + #pragma mark - #pragma mark CelObjPic diff --git a/engines/sci/graphics/celobj32.h b/engines/sci/graphics/celobj32.h index d51913473c..6e50f7232e 100644 --- a/engines/sci/graphics/celobj32.h +++ b/engines/sci/graphics/celobj32.h @@ -540,6 +540,8 @@ public: virtual CelObjView *duplicate() const override; virtual const SciSpan<const byte> getResPointer() const override; + + Common::Point getLinkPosition(const int16 linkId) const; }; #pragma mark - |