diff options
author | Eugene Sandulenko | 2019-12-09 22:36:57 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2019-12-10 00:32:54 +0100 |
commit | 080c2b8410c6c2d48f72a156a43710776872b9c3 (patch) | |
tree | 68868da8b828da925b0f41c20ba02fd6bb7d5cca /engines/director | |
parent | 1c119b41197f2de5c2615f2fdd74e07824b7a268 (diff) | |
download | scummvm-rg350-080c2b8410c6c2d48f72a156a43710776872b9c3.tar.gz scummvm-rg350-080c2b8410c6c2d48f72a156a43710776872b9c3.tar.bz2 scummvm-rg350-080c2b8410c6c2d48f72a156a43710776872b9c3.zip |
DIRECTOR: Do precomputations for 'zoomBox' built-in
Diffstat (limited to 'engines/director')
-rw-r--r-- | engines/director/frame.cpp | 8 | ||||
-rw-r--r-- | engines/director/frame.h | 1 | ||||
-rw-r--r-- | engines/director/lingo/lingo-builtins.cpp | 48 |
3 files changed, 56 insertions, 1 deletions
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp index 9d7c1790e8..e3615d3cf7 100644 --- a/engines/director/frame.cpp +++ b/engines/director/frame.cpp @@ -998,4 +998,12 @@ bool Frame::checkSpriteIntersection(uint16 spriteId, Common::Point pos) { return false; } +Common::Rect *Frame::getSpriteRect(uint16 spriteId) { + for (int dr = _drawRects.size() - 1; dr >= 0; dr--) + if (_drawRects[dr]->spriteId == spriteId) + return &_drawRects[dr]->rect; + + return nullptr; +} + } // End of namespace Director diff --git a/engines/director/frame.h b/engines/director/frame.h index 529a19a0e8..1e02ea810f 100644 --- a/engines/director/frame.h +++ b/engines/director/frame.h @@ -118,6 +118,7 @@ public: void prepareFrame(Score *score); uint16 getSpriteIDFromPos(Common::Point pos); bool checkSpriteIntersection(uint16 spriteId, Common::Point pos); + Common::Rect *getSpriteRect(uint16 spriteId); void executeImmediateScripts(); diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp index 948c503e5b..09b8c11ca3 100644 --- a/engines/director/lingo/lingo-builtins.cpp +++ b/engines/director/lingo/lingo-builtins.cpp @@ -1278,9 +1278,55 @@ void Lingo::b_unLoadCast(int nargs) { } void Lingo::b_zoomBox(int nargs) { + // zoomBox startSprite, endSprite [, delatTicks] + // ticks are in 1/60th, default 1 + g_lingo->printSTUBWithArglist("b_zoomBox", nargs); - g_lingo->dropStack(nargs); + if (nargs < 2 || nargs > 3) { + warning("b_zoomBox: expected 2 or 3 arguments, got %d", nargs); + + g_lingo->dropStack(nargs); + + return; + } + + int delayTicks = 1; + if (nargs > 2) { + Datum d = g_lingo->pop(); + d.toInt(); + + delayTicks = d.u.i; + } + + Datum endSprite = g_lingo->pop(); + Datum startSprite = g_lingo->pop(); + + startSprite.toInt(); + endSprite.toInt(); + + Frame *frame = g_director->getCurrentScore()->_frames[g_director->getCurrentScore()->getCurrentFrame()]; + Frame *frame2 = nullptr; + if (g_director->getCurrentScore()->_frames.size() > g_director->getCurrentScore()->getCurrentFrame()) + frame2 = g_director->getCurrentScore()->_frames[g_director->getCurrentScore()->getCurrentFrame() + 1]; + + Common::Rect *startRect = frame->getSpriteRect(startSprite.u.i); + if (!startRect) { + warning("b_zoomBox: unknown start sprite #%d", startSprite.u.i); + return; + } + + Common::Rect *endRect = frame->getSpriteRect(endSprite.u.i); + if (!endRect && frame2) + endRect = frame2->getSpriteRect(endSprite.u.i); + + if (!endRect) { + warning("b_zoomBox: unknown end sprite #%d", endSprite.u.i); + return; + } + + startRect->debugPrint(0, "b_zoomBox: start: "); + endRect->debugPrint(0, "b_zoomBox: end: "); } void Lingo::b_updateStage(int nargs) { |