aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorColin Snover2016-03-10 18:25:05 -0600
committerColin Snover2016-03-10 18:28:53 -0600
commit41b3d9ff46dacb4cd1d7edff57f719af9b35113c (patch)
treed41d203bd57de2a51dea849a392be4f7a48cc3a5 /engines
parentac403ac746760409ccea33da51e1c51566e67e21 (diff)
downloadscummvm-rg350-41b3d9ff46dacb4cd1d7edff57f719af9b35113c.tar.gz
scummvm-rg350-41b3d9ff46dacb4cd1d7edff57f719af9b35113c.tar.bz2
scummvm-rg350-41b3d9ff46dacb4cd1d7edff57f719af9b35113c.zip
SCI32: Use separate function for SCI32 version of kCantBeHere
Requested by @m-kiewitz.
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/kgraphics.cpp11
-rw-r--r--engines/sci/graphics/compare.cpp75
-rw-r--r--engines/sci/graphics/compare.h3
3 files changed, 47 insertions, 42 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index c79ffa9dd5..f18d2643bc 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -441,8 +441,15 @@ reg_t kCantBeHere(EngineState *s, int argc, reg_t *argv) {
reg_t curObject = argv[0];
reg_t listReference = (argc > 1) ? argv[1] : NULL_REG;
- reg_t canBeHere = g_sci->_gfxCompare->kernelCanBeHere(curObject, listReference);
- return canBeHere;
+#ifdef ENABLE_SCI32
+ if (getSciVersion() >= SCI_VERSION_2) {
+ return g_sci->_gfxCompare->kernelCanBeHere32(curObject, listReference);
+ } else {
+#endif
+ return g_sci->_gfxCompare->kernelCanBeHere(curObject, listReference);
+#ifdef ENABLE_SCI32
+ }
+#endif
}
reg_t kIsItSkip(EngineState *s, int argc, reg_t *argv) {
diff --git a/engines/sci/graphics/compare.cpp b/engines/sci/graphics/compare.cpp
index 2f83017915..04cf85966d 100644
--- a/engines/sci/graphics/compare.cpp
+++ b/engines/sci/graphics/compare.cpp
@@ -67,29 +67,18 @@ uint16 GfxCompare::isOnControl(uint16 screenMask, const Common::Rect &rect) {
return result;
}
-reg_t GfxCompare::canBeHereCheckRectList(reg_t checkObject, const Common::Rect &checkRect, List *list) {
+reg_t GfxCompare::canBeHereCheckRectList(const reg_t checkObject, const Common::Rect &checkRect, const List *list, const uint16 signalFlags) const {
reg_t curAddress = list->first;
Node *curNode = _segMan->lookupNode(curAddress);
reg_t curObject;
uint16 signal;
Common::Rect curRect;
- uint16 flags;
-#ifdef ENABLE_SCI32
- if (getSciVersion() >= SCI_VERSION_2) {
- flags = kSignalIgnoreActor | kSignalHidden;
- } else {
-#endif
- flags = kSignalIgnoreActor | kSignalRemoveView | kSignalNoUpdate;
-#ifdef ENABLE_SCI32
- }
-#endif
-
while (curNode) {
curObject = curNode->value;
if (curObject != checkObject) {
signal = readSelectorValue(_segMan, curObject, SELECTOR(signal));
- if (!(signal & flags)) {
+ if (!(signal & signalFlags)) {
curRect.left = readSelectorValue(_segMan, curObject, SELECTOR(brLeft));
curRect.top = readSelectorValue(_segMan, curObject, SELECTOR(brTop));
curRect.right = readSelectorValue(_segMan, curObject, SELECTOR(brRight));
@@ -149,36 +138,44 @@ reg_t GfxCompare::kernelCanBeHere(reg_t curObject, reg_t listReference) {
checkRect.bottom = readSelectorValue(_segMan, curObject, SELECTOR(brBottom));
uint16 signal = readSelectorValue(_segMan, curObject, SELECTOR(signal));
-#ifdef ENABLE_SCI32
- if (getSciVersion() >= SCI_VERSION_2) {
- result = 0;
- if ((signal & (kSignalIgnoreActor | kSignalHidden)) == 0) {
- List *list = _segMan->lookupList(listReference);
- if (!list) {
- error("kCanBeHere called with non-list as parameter");
- }
- result = !canBeHereCheckRectList(curObject, checkRect, list).isNull();
- }
- } else {
-#endif
- if (!checkRect.isValidRect()) { // can occur in Iceman and Mother Goose - HACK? TODO: is this really occuring in sierra sci? check this
- warning("kCan(t)BeHere - invalid rect %d, %d -> %d, %d", checkRect.left, checkRect.top, checkRect.right, checkRect.bottom);
- return NULL_REG; // this means "can be here"
- }
+ if (!checkRect.isValidRect()) { // can occur in Iceman and Mother Goose - HACK? TODO: is this really occuring in sierra sci? check this
+ warning("kCan(t)BeHere - invalid rect %d, %d -> %d, %d", checkRect.left, checkRect.top, checkRect.right, checkRect.bottom);
+ return NULL_REG; // this means "can be here"
+ }
+
+ Common::Rect adjustedRect = _coordAdjuster->onControl(checkRect);
+ uint16 controlMask = readSelectorValue(_segMan, curObject, SELECTOR(illegalBits));
+ result = isOnControl(GFX_SCREEN_MASK_CONTROL, adjustedRect) & controlMask;
+ if ((!result) && (signal & (kSignalIgnoreActor | kSignalRemoveView)) == 0) {
+ List *list = _segMan->lookupList(listReference);
+ if (!list)
+ error("kCanBeHere called with non-list as parameter");
- Common::Rect adjustedRect = _coordAdjuster->onControl(checkRect);
- uint16 controlMask = readSelectorValue(_segMan, curObject, SELECTOR(illegalBits));
- result = isOnControl(GFX_SCREEN_MASK_CONTROL, adjustedRect) & controlMask;
- if ((!result) && (signal & (kSignalIgnoreActor | kSignalRemoveView)) == 0) {
- List *list = _segMan->lookupList(listReference);
- if (!list)
- error("kCanBeHere called with non-list as parameter");
+ return canBeHereCheckRectList(curObject, checkRect, list, kSignalIgnoreActor | kSignalRemoveView | kSignalNoUpdate);
+ }
+
+ return make_reg(0, result);
+}
+
+reg_t GfxCompare::kernelCanBeHere32(const reg_t curObject, const reg_t listReference) const {
+ Common::Rect checkRect(
+ readSelectorValue(_segMan, curObject, SELECTOR(brLeft)),
+ readSelectorValue(_segMan, curObject, SELECTOR(brTop)),
+ readSelectorValue(_segMan, curObject, SELECTOR(brRight)),
+ readSelectorValue(_segMan, curObject, SELECTOR(brBottom))
+ );
+
+ uint16 result = 0;
+ uint16 signal = readSelectorValue(_segMan, curObject, SELECTOR(signal));
+ const uint16 signalFlags = kSignalIgnoreActor | kSignalHidden;
- return canBeHereCheckRectList(curObject, checkRect, list);
+ if ((signal & signalFlags) == 0) {
+ List *list = _segMan->lookupList(listReference);
+ if (!list) {
+ error("kCanBeHere called with non-list as parameter");
}
-#ifdef ENABLE_SCI32
+ result = !canBeHereCheckRectList(curObject, checkRect, list, signalFlags).isNull();
}
-#endif
return make_reg(0, result);
}
diff --git a/engines/sci/graphics/compare.h b/engines/sci/graphics/compare.h
index 88b44aeeb1..94aacbfed1 100644
--- a/engines/sci/graphics/compare.h
+++ b/engines/sci/graphics/compare.h
@@ -40,6 +40,7 @@ public:
uint16 kernelOnControl(byte screenMask, const Common::Rect &rect);
void kernelSetNowSeen(reg_t objectReference);
reg_t kernelCanBeHere(reg_t curObject, reg_t listReference);
+ reg_t kernelCanBeHere32(const reg_t curObject, const reg_t listReference) const;
bool kernelIsItSkip(GuiResourceId viewId, int16 loopNo, int16 celNo, Common::Point position);
void kernelBaseSetter(reg_t object);
Common::Rect getNSRect(reg_t object);
@@ -58,7 +59,7 @@ private:
* *different* from checkObject, has a brRect which is contained inside
* checkRect.
*/
- reg_t canBeHereCheckRectList(reg_t checkObject, const Common::Rect &checkRect, List *list);
+ reg_t canBeHereCheckRectList(const reg_t checkObject, const Common::Rect &checkRect, const List *list, const uint16 signalFlags) const;
};
} // End of namespace Sci