aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2016-11-27 10:53:06 -0600
committerColin Snover2016-12-19 14:46:59 -0600
commit4cff1e400f7e1e885b12990a5a34772d05eb2285 (patch)
treea9e85d62fa6fd48bd2cc19d0d6a55d855fc5a6f4
parent5220ce1e4f9090d0e6272d680dbfa3813233399b (diff)
downloadscummvm-rg350-4cff1e400f7e1e885b12990a5a34772d05eb2285.tar.gz
scummvm-rg350-4cff1e400f7e1e885b12990a5a34772d05eb2285.tar.bz2
scummvm-rg350-4cff1e400f7e1e885b12990a5a34772d05eb2285.zip
SCI32: Add support for alternate graphics selectors
Used by at least Phantasmagoria 2.
-rw-r--r--engines/sci/engine/features.h4
-rw-r--r--engines/sci/engine/kgraphics32.cpp16
-rw-r--r--engines/sci/engine/selector.cpp17
-rw-r--r--engines/sci/engine/selector.h9
-rw-r--r--engines/sci/graphics/celobj32.cpp4
-rw-r--r--engines/sci/graphics/frameout.cpp17
-rw-r--r--engines/sci/graphics/plane32.cpp31
-rw-r--r--engines/sci/graphics/screen_item32.cpp27
8 files changed, 92 insertions, 33 deletions
diff --git a/engines/sci/engine/features.h b/engines/sci/engine/features.h
index 36b0d06360..ee978be033 100644
--- a/engines/sci/engine/features.h
+++ b/engines/sci/engine/features.h
@@ -128,6 +128,10 @@ public:
g_sci->getGameId() != GID_SQ6 &&
g_sci->getGameId() != GID_GK2;
}
+
+ inline bool usesAlternateSelectors() const {
+ return g_sci->getGameId() == GID_PHANTASMAGORIA2;
+ }
#endif
/**
diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index d4377417a8..880ea0f559 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -484,10 +484,18 @@ reg_t kScrollWindowCreate(EngineState *s, int argc, reg_t *argv) {
const reg_t plane = readSelector(segMan, object, SELECTOR(plane));
Common::Rect rect;
- rect.left = readSelectorValue(segMan, object, SELECTOR(nsLeft));
- rect.top = readSelectorValue(segMan, object, SELECTOR(nsTop));
- rect.right = readSelectorValue(segMan, object, SELECTOR(nsRight)) + 1;
- rect.bottom = readSelectorValue(segMan, object, SELECTOR(nsBottom)) + 1;
+
+ if (g_sci->_features->usesAlternateSelectors()) {
+ rect.left = readSelectorValue(segMan, object, SELECTOR(left));
+ rect.top = readSelectorValue(segMan, object, SELECTOR(top));
+ rect.right = readSelectorValue(segMan, object, SELECTOR(right)) + 1;
+ rect.bottom = readSelectorValue(segMan, object, SELECTOR(bottom)) + 1;
+ } else {
+ rect.left = readSelectorValue(segMan, object, SELECTOR(nsLeft));
+ rect.top = readSelectorValue(segMan, object, SELECTOR(nsTop));
+ rect.right = readSelectorValue(segMan, object, SELECTOR(nsRight)) + 1;
+ rect.bottom = readSelectorValue(segMan, object, SELECTOR(nsBottom)) + 1;
+ }
const Common::Point position(rect.left, rect.top);
return g_sci->_gfxControls32->makeScrollWindow(rect, position, plane, foreColor, backColor, fontId, alignment, borderColor, maxNumEntries);
diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp
index 585b0ef2c2..2bc4051a79 100644
--- a/engines/sci/engine/selector.cpp
+++ b/engines/sci/engine/selector.cpp
@@ -21,6 +21,7 @@
*/
#include "sci/sci.h"
+#include "sci/engine/features.h"
#include "sci/engine/kernel.h"
#include "sci/engine/state.h"
#include "sci/engine/selector.h"
@@ -57,11 +58,11 @@ void Kernel::mapSelectors() {
FIND_SELECTOR(nsTop);
FIND_SELECTOR(nsLeft);
FIND_SELECTOR(nsBottom);
+ FIND_SELECTOR(nsRight);
FIND_SELECTOR(lsTop);
FIND_SELECTOR(lsLeft);
FIND_SELECTOR(lsBottom);
FIND_SELECTOR(lsRight);
- FIND_SELECTOR(nsRight);
FIND_SELECTOR(signal);
FIND_SELECTOR(illegalBits);
FIND_SELECTOR(brTop);
@@ -173,6 +174,7 @@ void Kernel::mapSelectors() {
FIND_SELECTOR(left);
FIND_SELECTOR(bottom);
FIND_SELECTOR(right);
+ FIND_SELECTOR(seenRect);
FIND_SELECTOR(resY);
FIND_SELECTOR(resX);
FIND_SELECTOR(dimmed);
@@ -214,9 +216,16 @@ reg_t readSelector(SegManager *segMan, reg_t object, Selector selectorId) {
#ifdef ENABLE_SCI32
void updateInfoFlagViewVisible(Object *obj, int index) {
- // TODO: Make this correct for all SCI versions
- // Selectors 26 through 44 are selectors for View script objects in SQ6
- if (index >= 26 && index <= 44 && getSciVersion() >= SCI_VERSION_2) {
+ int minIndex, maxIndex;
+ if (g_sci->_features->usesAlternateSelectors()) {
+ minIndex = 24;
+ maxIndex = 43;
+ } else {
+ minIndex = 26;
+ maxIndex = 44;
+ }
+
+ if (index >= minIndex && index <= maxIndex && getSciVersion() >= SCI_VERSION_2) {
obj->setInfoSelectorFlag(kInfoFlagViewVisible);
}
}
diff --git a/engines/sci/engine/selector.h b/engines/sci/engine/selector.h
index f2d06d1cf4..8d1edeb489 100644
--- a/engines/sci/engine/selector.h
+++ b/engines/sci/engine/selector.h
@@ -135,12 +135,8 @@ struct SelectorCache {
Selector bitmap; // Used to hold the text bitmap for SCI32 texts
Selector plane;
- Selector top;
- Selector left;
- Selector bottom;
- Selector right;
- Selector resX;
- Selector resY;
+ Selector top, left, bottom, right;
+ Selector resX, resY;
Selector fore;
Selector back;
@@ -153,6 +149,7 @@ struct SelectorCache {
Selector mirrored;
Selector visible;
+ Selector seenRect;
Selector useInsetRect;
Selector inTop, inLeft, inBottom, inRight;
Selector textTop, textLeft, textBottom, textRight;
diff --git a/engines/sci/graphics/celobj32.cpp b/engines/sci/graphics/celobj32.cpp
index 09ea05bd59..fe0fbf7cc4 100644
--- a/engines/sci/graphics/celobj32.cpp
+++ b/engines/sci/graphics/celobj32.cpp
@@ -21,6 +21,7 @@
*/
#include "sci/resource.h"
+#include "sci/engine/features.h"
#include "sci/engine/seg_manager.h"
#include "sci/engine/state.h"
#include "sci/graphics/celobj32.h"
@@ -949,6 +950,9 @@ CelObjView::CelObjView(const GuiResourceId viewId, const int16 loopNo, const int
_width = READ_SCI11ENDIAN_UINT16(celHeader);
_height = READ_SCI11ENDIAN_UINT16(celHeader + 2);
_origin.x = _width / 2 - (int16)READ_SCI11ENDIAN_UINT16(celHeader + 4);
+ if (g_sci->_features->usesAlternateSelectors() && _mirrorX) {
+ _origin.x = _width - _origin.x - 1;
+ }
_origin.y = _height - (int16)READ_SCI11ENDIAN_UINT16(celHeader + 6) - 1;
_skipColor = celHeader[8];
_compressionType = (CelCompressionType)celHeader[9];
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index bf43c8b63b..fe43c75e5a 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -35,6 +35,7 @@
#include "sci/sci.h"
#include "sci/console.h"
+#include "sci/engine/features.h"
#include "sci/engine/kernel.h"
#include "sci/engine/state.h"
#include "sci/engine/selector.h"
@@ -1368,10 +1369,18 @@ bool GfxFrameout::kernelSetNowSeen(const reg_t screenItemObject) const {
}
Common::Rect result = screenItem->getNowSeenRect(*plane);
- writeSelectorValue(_segMan, screenItemObject, SELECTOR(nsLeft), result.left);
- writeSelectorValue(_segMan, screenItemObject, SELECTOR(nsTop), result.top);
- writeSelectorValue(_segMan, screenItemObject, SELECTOR(nsRight), result.right - 1);
- writeSelectorValue(_segMan, screenItemObject, SELECTOR(nsBottom), result.bottom - 1);
+
+ if (g_sci->_features->usesAlternateSelectors()) {
+ writeSelectorValue(_segMan, screenItemObject, SELECTOR(left), result.left);
+ writeSelectorValue(_segMan, screenItemObject, SELECTOR(top), result.top);
+ writeSelectorValue(_segMan, screenItemObject, SELECTOR(right), result.right - 1);
+ writeSelectorValue(_segMan, screenItemObject, SELECTOR(bottom), result.bottom - 1);
+ } else {
+ writeSelectorValue(_segMan, screenItemObject, SELECTOR(nsLeft), result.left);
+ writeSelectorValue(_segMan, screenItemObject, SELECTOR(nsTop), result.top);
+ writeSelectorValue(_segMan, screenItemObject, SELECTOR(nsRight), result.right - 1);
+ writeSelectorValue(_segMan, screenItemObject, SELECTOR(nsBottom), result.bottom - 1);
+ }
return true;
}
diff --git a/engines/sci/graphics/plane32.cpp b/engines/sci/graphics/plane32.cpp
index 46622261f5..aa8cd52d42 100644
--- a/engines/sci/graphics/plane32.cpp
+++ b/engines/sci/graphics/plane32.cpp
@@ -80,10 +80,17 @@ _moved(0) {
_vanishingPoint.x = readSelectorValue(segMan, object, SELECTOR(vanishingX));
_vanishingPoint.y = readSelectorValue(segMan, object, SELECTOR(vanishingY));
- _gameRect.left = readSelectorValue(segMan, object, SELECTOR(inLeft));
- _gameRect.top = readSelectorValue(segMan, object, SELECTOR(inTop));
- _gameRect.right = readSelectorValue(segMan, object, SELECTOR(inRight)) + 1;
- _gameRect.bottom = readSelectorValue(segMan, object, SELECTOR(inBottom)) + 1;
+ if (g_sci->_features->usesAlternateSelectors()) {
+ _gameRect.left = readSelectorValue(segMan, object, SELECTOR(left));
+ _gameRect.top = readSelectorValue(segMan, object, SELECTOR(top));
+ _gameRect.right = readSelectorValue(segMan, object, SELECTOR(right)) + 1;
+ _gameRect.bottom = readSelectorValue(segMan, object, SELECTOR(bottom)) + 1;
+ } else {
+ _gameRect.left = readSelectorValue(segMan, object, SELECTOR(inLeft));
+ _gameRect.top = readSelectorValue(segMan, object, SELECTOR(inTop));
+ _gameRect.right = readSelectorValue(segMan, object, SELECTOR(inRight)) + 1;
+ _gameRect.bottom = readSelectorValue(segMan, object, SELECTOR(inBottom)) + 1;
+ }
convertGameRectToPlaneRect();
_back = readSelectorValue(segMan, object, SELECTOR(back));
@@ -829,10 +836,18 @@ void Plane::update(const reg_t object) {
SegManager *segMan = g_sci->getEngineState()->_segMan;
_vanishingPoint.x = readSelectorValue(segMan, object, SELECTOR(vanishingX));
_vanishingPoint.y = readSelectorValue(segMan, object, SELECTOR(vanishingY));
- _gameRect.left = readSelectorValue(segMan, object, SELECTOR(inLeft));
- _gameRect.top = readSelectorValue(segMan, object, SELECTOR(inTop));
- _gameRect.right = readSelectorValue(segMan, object, SELECTOR(inRight)) + 1;
- _gameRect.bottom = readSelectorValue(segMan, object, SELECTOR(inBottom)) + 1;
+
+ if (g_sci->_features->usesAlternateSelectors()) {
+ _gameRect.left = readSelectorValue(segMan, object, SELECTOR(left));
+ _gameRect.top = readSelectorValue(segMan, object, SELECTOR(top));
+ _gameRect.right = readSelectorValue(segMan, object, SELECTOR(right)) + 1;
+ _gameRect.bottom = readSelectorValue(segMan, object, SELECTOR(bottom)) + 1;
+ } else {
+ _gameRect.left = readSelectorValue(segMan, object, SELECTOR(inLeft));
+ _gameRect.top = readSelectorValue(segMan, object, SELECTOR(inTop));
+ _gameRect.right = readSelectorValue(segMan, object, SELECTOR(inRight)) + 1;
+ _gameRect.bottom = readSelectorValue(segMan, object, SELECTOR(inBottom)) + 1;
+ }
convertGameRectToPlaneRect();
_priority = readSelectorValue(segMan, object, SELECTOR(priority));
diff --git a/engines/sci/graphics/screen_item32.cpp b/engines/sci/graphics/screen_item32.cpp
index a70f25fd6b..3c12a673a7 100644
--- a/engines/sci/graphics/screen_item32.cpp
+++ b/engines/sci/graphics/screen_item32.cpp
@@ -22,6 +22,7 @@
#include "sci/console.h"
#include "sci/resource.h"
+#include "sci/engine/features.h"
#include "sci/engine/kernel.h"
#include "sci/engine/selector.h"
#include "sci/engine/state.h"
@@ -238,14 +239,26 @@ void ScreenItem::setFromObject(SegManager *segMan, const reg_t object, const boo
_z = readSelectorValue(segMan, object, SELECTOR(z));
_position.y -= _z;
- if (readSelectorValue(segMan, object, SELECTOR(useInsetRect))) {
- _useInsetRect = true;
- _insetRect.left = readSelectorValue(segMan, object, SELECTOR(inLeft));
- _insetRect.top = readSelectorValue(segMan, object, SELECTOR(inTop));
- _insetRect.right = readSelectorValue(segMan, object, SELECTOR(inRight)) + 1;
- _insetRect.bottom = readSelectorValue(segMan, object, SELECTOR(inBottom)) + 1;
+ if (g_sci->_features->usesAlternateSelectors()) {
+ if (readSelectorValue(segMan, object, SELECTOR(seenRect))) {
+ _useInsetRect = true;
+ _insetRect.left = readSelectorValue(segMan, object, SELECTOR(left));
+ _insetRect.top = readSelectorValue(segMan, object, SELECTOR(top));
+ _insetRect.right = readSelectorValue(segMan, object, SELECTOR(right)) + 1;
+ _insetRect.bottom = readSelectorValue(segMan, object, SELECTOR(bottom)) + 1;
+ } else {
+ _useInsetRect = false;
+ }
} else {
- _useInsetRect = false;
+ if (readSelectorValue(segMan, object, SELECTOR(useInsetRect))) {
+ _useInsetRect = true;
+ _insetRect.left = readSelectorValue(segMan, object, SELECTOR(inLeft));
+ _insetRect.top = readSelectorValue(segMan, object, SELECTOR(inTop));
+ _insetRect.right = readSelectorValue(segMan, object, SELECTOR(inRight)) + 1;
+ _insetRect.bottom = readSelectorValue(segMan, object, SELECTOR(inBottom)) + 1;
+ } else {
+ _useInsetRect = false;
+ }
}
segMan->getObject(object)->clearInfoSelectorFlag(kInfoFlagViewVisible);