From 353b0d29938690b0cff4c032febcc8375b1c17d8 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sat, 24 Jul 2010 17:43:56 +0000 Subject: SCI: support useInsetRect in kFrameout svn-id: r51251 --- engines/sci/engine/selector.cpp | 5 +++ engines/sci/engine/selector.h | 3 ++ engines/sci/graphics/frameout.cpp | 83 ++++++++++++++++++++++----------------- 3 files changed, 55 insertions(+), 36 deletions(-) diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp index befa7c38a2..f5eb9eb73a 100644 --- a/engines/sci/engine/selector.cpp +++ b/engines/sci/engine/selector.cpp @@ -180,6 +180,11 @@ void Kernel::mapSelectors() { FIND_SELECTOR(back); FIND_SELECTOR(fixPriority); FIND_SELECTOR(mirrored); + FIND_SELECTOR(useInsetRect); + FIND_SELECTOR(inTop); + FIND_SELECTOR(inLeft); + FIND_SELECTOR(inBottom); + FIND_SELECTOR(inRight); #endif } diff --git a/engines/sci/engine/selector.h b/engines/sci/engine/selector.h index 7e13c18e4a..661290f58c 100644 --- a/engines/sci/engine/selector.h +++ b/engines/sci/engine/selector.h @@ -145,6 +145,9 @@ struct SelectorCache { Selector fixPriority; Selector mirrored; + + Selector useInsetRect; + Selector inTop, inLeft, inBottom, inRight; #endif }; diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp index 6eee71004d..0ace3c8e62 100644 --- a/engines/sci/graphics/frameout.cpp +++ b/engines/sci/graphics/frameout.cpp @@ -298,45 +298,56 @@ void GfxFrameout::kernelFrameout() { // warning("view %s %d", _segMan->getObjectName(itemEntry->object), itemEntry->priority); - switch (getSciVersion()) { - case SCI_VERSION_2: - if (view->isSci2Hires()) - _screen->adjustToUpscaledCoordinates(itemEntry->y, itemEntry->x); - break; - case SCI_VERSION_2_1: - itemEntry->y = (itemEntry->y * _screen->getHeight()) / planeResY; - itemEntry->x = (itemEntry->x * _screen->getWidth()) / planeResX; - break; - default: - break; - } + uint16 useInsetRect = readSelectorValue(_segMan, itemEntry->object, SELECTOR(useInsetRect)); + if (useInsetRect) { + itemEntry->celRect.top = readSelectorValue(_segMan, itemEntry->object, SELECTOR(inTop)); + itemEntry->celRect.left = readSelectorValue(_segMan, itemEntry->object, SELECTOR(inLeft)); + itemEntry->celRect.bottom = readSelectorValue(_segMan, itemEntry->object, SELECTOR(inBottom)) + 1; + itemEntry->celRect.right = readSelectorValue(_segMan, itemEntry->object, SELECTOR(inRight)) + 1; + itemEntry->celRect.translate(itemEntry->x, itemEntry->y); + // TODO: maybe we should clip the cels rect with this, i'm not sure + // the only currently known usage is game menu of gk1 + } else { + switch (getSciVersion()) { + case SCI_VERSION_2: + if (view->isSci2Hires()) + _screen->adjustToUpscaledCoordinates(itemEntry->y, itemEntry->x); + break; + case SCI_VERSION_2_1: + itemEntry->y = (itemEntry->y * _screen->getHeight()) / planeResY; + itemEntry->x = (itemEntry->x * _screen->getWidth()) / planeResX; + break; + default: + break; + } - if ((itemEntry->scaleX == 128) && (itemEntry->scaleY == 128)) - view->getCelRect(itemEntry->loopNo, itemEntry->celNo, itemEntry->x, itemEntry->y, itemEntry->z, itemEntry->celRect); - else - view->getCelScaledRect(itemEntry->loopNo, itemEntry->celNo, itemEntry->x, itemEntry->y, itemEntry->z, itemEntry->scaleX, itemEntry->scaleY, itemEntry->celRect); - - Common::Rect nsRect = itemEntry->celRect; - switch (getSciVersion()) { - case SCI_VERSION_2: - if (view->isSci2Hires()) { - _screen->adjustBackUpscaledCoordinates(nsRect.top, nsRect.left); - _screen->adjustBackUpscaledCoordinates(nsRect.bottom, nsRect.right); + if ((itemEntry->scaleX == 128) && (itemEntry->scaleY == 128)) + view->getCelRect(itemEntry->loopNo, itemEntry->celNo, itemEntry->x, itemEntry->y, itemEntry->z, itemEntry->celRect); + else + view->getCelScaledRect(itemEntry->loopNo, itemEntry->celNo, itemEntry->x, itemEntry->y, itemEntry->z, itemEntry->scaleX, itemEntry->scaleY, itemEntry->celRect); + + Common::Rect nsRect = itemEntry->celRect; + switch (getSciVersion()) { + case SCI_VERSION_2: + if (view->isSci2Hires()) { + _screen->adjustBackUpscaledCoordinates(nsRect.top, nsRect.left); + _screen->adjustBackUpscaledCoordinates(nsRect.bottom, nsRect.right); + } + break; + case SCI_VERSION_2_1: + nsRect.top = (nsRect.top * planeResY) / _screen->getHeight(); + nsRect.left = (nsRect.left * planeResX) / _screen->getWidth(); + nsRect.bottom = (nsRect.bottom * planeResY) / _screen->getHeight(); + nsRect.right = (nsRect.right * planeResX) / _screen->getWidth(); + break; + default: + break; } - break; - case SCI_VERSION_2_1: - nsRect.top = (nsRect.top * planeResY) / _screen->getHeight(); - nsRect.left = (nsRect.left * planeResX) / _screen->getWidth(); - nsRect.bottom = (nsRect.bottom * planeResY) / _screen->getHeight(); - nsRect.right = (nsRect.right * planeResX) / _screen->getWidth(); - break; - default: - break; + writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsLeft), nsRect.left); + writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsTop), nsRect.top); + writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsRight), nsRect.right); + writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsBottom), nsRect.bottom); } - writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsLeft), nsRect.left); - writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsTop), nsRect.top); - writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsRight), nsRect.right); - writeSelectorValue(_segMan, itemEntry->object, SELECTOR(nsBottom), nsRect.bottom); int16 screenHeight = _screen->getHeight(); int16 screenWidth = _screen->getWidth(); -- cgit v1.2.3