aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorColin Snover2017-04-17 21:07:23 -0500
committerColin Snover2017-04-23 13:07:25 -0500
commitd53f3f6095975405558c2902a870ff3fa8c01a8b (patch)
treee84fca0e08f70a8a4c6ef19448b784fdad2e72bf /engines/sci/engine
parent6f95b1a440c8579a5010c39ca84e2c5fcdfac682 (diff)
downloadscummvm-rg350-d53f3f6095975405558c2902a870ff3fa8c01a8b.tar.gz
scummvm-rg350-d53f3f6095975405558c2902a870ff3fa8c01a8b.tar.bz2
scummvm-rg350-d53f3f6095975405558c2902a870ff3fa8c01a8b.zip
SCI32: Exclude SCI3 code from compilation when SCI32 is disabled
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/object.cpp16
-rw-r--r--engines/sci/engine/object.h118
-rw-r--r--engines/sci/engine/script.cpp23
-rw-r--r--engines/sci/engine/script.h8
-rw-r--r--engines/sci/engine/vm.cpp2
5 files changed, 118 insertions, 49 deletions
diff --git a/engines/sci/engine/object.cpp b/engines/sci/engine/object.cpp
index 9861e02a16..2875c8b041 100644
--- a/engines/sci/engine/object.cpp
+++ b/engines/sci/engine/object.cpp
@@ -96,16 +96,22 @@ void Object::init(const SciSpan<const byte> &buf, reg_t obj_pos, bool initVariab
for (int i = 0; i < _methodCount * 2 + 3; ++i) {
_baseMethod.push_back(buf.getUint16SEAt(data.getUint16SEAt(6) + i * 2));
}
+#ifdef ENABLE_SCI32
} else if (getSciVersion() == SCI_VERSION_3) {
initSelectorsSci3(buf, initVariables);
+#endif
}
if (initVariables) {
- if (getSciVersion() <= SCI_VERSION_2_1_LATE) {
+#ifdef ENABLE_SCI32
+ if (getSciVersion() == SCI_VERSION_3) {
+ _infoSelectorSci3 = make_reg(0, data.getUint16SEAt(10));
+ } else {
+#else
+ {
+#endif
for (uint i = 0; i < _variables.size(); i++)
_variables[i] = make_reg(0, data.getUint16SEAt(i * 2));
- } else {
- _infoSelectorSci3 = make_reg(0, data.getUint16SEAt(10));
}
}
}
@@ -136,6 +142,7 @@ bool Object::relocateSci0Sci21(SegmentId segment, int location, size_t scriptSiz
return relocateBlock(_variables, getPos().getOffset(), segment, location, scriptSize);
}
+#ifdef ENABLE_SCI32
bool Object::relocateSci3(SegmentId segment, uint32 location, int offset, size_t scriptSize) {
assert(_propertyOffsetsSci3.size());
assert(offset >= 0 && (uint)offset < scriptSize);
@@ -150,6 +157,7 @@ bool Object::relocateSci3(SegmentId segment, uint32 location, int offset, size_t
return false;
}
+#endif
int Object::propertyOffsetToId(SegManager *segMan, int propertyOffset) const {
int selectors = getVarCount();
@@ -305,7 +313,6 @@ bool Object::mustSetViewVisible(int index, const bool fromPropertyOp) const {
return index >= minIndex && index <= maxIndex;
}
}
-#endif
void Object::initSelectorsSci3(const SciSpan<const byte> &buf, const bool initVariables) {
enum {
@@ -398,5 +405,6 @@ void Object::initSelectorsSci3(const SciSpan<const byte> &buf, const bool initVa
_superClassPosSci3 = make_reg(0, _baseObj.getUint16SEAt(8));
}
}
+#endif
} // End of namespace Sci
diff --git a/engines/sci/engine/object.h b/engines/sci/engine/object.h
index 75ab128de5..136a831636 100644
--- a/engines/sci/engine/object.h
+++ b/engines/sci/engine/object.h
@@ -73,8 +73,12 @@ public:
_isFreed(false),
_baseObj(),
_baseVars(),
- _methodCount(0),
- _propertyOffsetsSci3() {}
+ _methodCount(0)
+#ifdef ENABLE_SCI32
+ ,
+ _propertyOffsetsSci3()
+#endif
+ {}
Object &operator=(const Object &other) {
_baseObj = other._baseObj;
@@ -86,6 +90,7 @@ public:
_pos = other._pos;
_baseVars = other._baseVars;
+#ifdef ENABLE_SCI32
if (getSciVersion() == SCI_VERSION_3) {
_propertyOffsetsSci3 = other._propertyOffsetsSci3;
_superClassPosSci3 = other._superClassPosSci3;
@@ -93,67 +98,80 @@ public:
_infoSelectorSci3 = other._infoSelectorSci3;
_mustSetViewVisible = other._mustSetViewVisible;
}
+#endif
return *this;
}
reg_t getSpeciesSelector() const {
- if (getSciVersion() < SCI_VERSION_3)
- return _variables[_offset];
- else // SCI3
+#ifdef ENABLE_SCI32
+ if (getSciVersion() == SCI_VERSION_3)
return _speciesSelectorSci3;
+ else
+#endif
+ return _variables[_offset];
}
void setSpeciesSelector(reg_t value) {
- if (getSciVersion() < SCI_VERSION_3)
- _variables[_offset] = value;
- else // SCI3
+#ifdef ENABLE_SCI32
+ if (getSciVersion() == SCI_VERSION_3)
_speciesSelectorSci3 = value;
+ else
+#endif
+ _variables[_offset] = value;
}
reg_t getSuperClassSelector() const {
- if (getSciVersion() < SCI_VERSION_3)
- return _variables[_offset + 1];
- else // SCI3
+#ifdef ENABLE_SCI32
+ if (getSciVersion() == SCI_VERSION_3)
return _superClassPosSci3;
+ else
+#endif
+ return _variables[_offset + 1];
}
void setSuperClassSelector(reg_t value) {
- if (getSciVersion() < SCI_VERSION_3)
- _variables[_offset + 1] = value;
- else // SCI3
+#ifdef ENABLE_SCI32
+ if (getSciVersion() == SCI_VERSION_3)
_superClassPosSci3 = value;
+ else
+#endif
+ _variables[_offset + 1] = value;
}
reg_t getInfoSelector() const {
- if (getSciVersion() < SCI_VERSION_3)
- return _variables[_offset + 2];
- else // SCI3
+#ifdef ENABLE_SCI32
+ if (getSciVersion() == SCI_VERSION_3)
return _infoSelectorSci3;
+ else
+#endif
+ return _variables[_offset + 2];
}
void setInfoSelector(reg_t info) {
- if (getSciVersion() < SCI_VERSION_3)
- _variables[_offset + 2] = info;
- else // SCI3
+#ifdef ENABLE_SCI32
+ if (getSciVersion() == SCI_VERSION_3)
_infoSelectorSci3 = info;
+ else
+#endif
+ _variables[_offset + 2] = info;
}
#ifdef ENABLE_SCI32
void setInfoSelectorFlag(infoSelectorFlags flag) {
- if (getSciVersion() < SCI_VERSION_3) {
- _variables[_offset + 2] |= flag;
- } else {
+ if (getSciVersion() == SCI_VERSION_3) {
_infoSelectorSci3 |= flag;
+ } else {
+ _variables[_offset + 2] |= flag;
}
}
// NOTE: In real engine, -info- is treated as byte size
void clearInfoSelectorFlag(infoSelectorFlags flag) {
- if (getSciVersion() < SCI_VERSION_3) {
- _variables[_offset + 2] &= ~flag;
- } else {
+ if (getSciVersion() == SCI_VERSION_3) {
_infoSelectorSci3 &= ~flag;
+ } else {
+ _variables[_offset + 2] &= ~flag;
}
}
@@ -163,43 +181,53 @@ public:
#endif
reg_t getNameSelector() const {
- if (getSciVersion() < SCI_VERSION_3)
- return _offset + 3 < (uint16)_variables.size() ? _variables[_offset + 3] : NULL_REG;
- else // SCI3
+#ifdef ENABLE_SCI32
+ if (getSciVersion() == SCI_VERSION_3)
return _variables.size() ? _variables[0] : NULL_REG;
+ else
+#endif
+ return _offset + 3 < (uint16)_variables.size() ? _variables[_offset + 3] : NULL_REG;
}
// No setter for the name selector
reg_t getPropDictSelector() const {
- if (getSciVersion() < SCI_VERSION_3)
- return _variables[2];
- else
+#ifdef ENABLE_SCI32
+ if (getSciVersion() == SCI_VERSION_3)
// This should never occur, this is called from a SCI1.1 - SCI2.1 only function
error("getPropDictSelector called for SCI3");
+ else
+#endif
+ return _variables[2];
}
void setPropDictSelector(reg_t value) {
- if (getSciVersion() < SCI_VERSION_3)
- _variables[2] = value;
- else
+#ifdef ENABLE_SCI32
+ if (getSciVersion() == SCI_VERSION_3)
// This should never occur, this is called from a SCI1.1 - SCI2.1 only function
error("setPropDictSelector called for SCI3");
+ else
+#endif
+ _variables[2] = value;
}
reg_t getClassScriptSelector() const {
- if (getSciVersion() < SCI_VERSION_3)
- return _variables[4];
- else // SCI3
+#ifdef ENABLE_SCI32
+ if (getSciVersion() == SCI_VERSION_3)
return make_reg(0, _baseObj.getUint16SEAt(6));
+ else
+#endif
+ return _variables[4];
}
void setClassScriptSelector(reg_t value) {
- if (getSciVersion() < SCI_VERSION_3)
- _variables[4] = value;
- else // SCI3
+#ifdef ENABLE_SCI32
+ if (getSciVersion() == SCI_VERSION_3)
// This should never occur, this is called from a SCI1.1 - SCI2.1 only function
error("setClassScriptSelector called for SCI3");
+ else
+#endif
+ _variables[4] = value;
}
Selector getVarSelector(uint16 i) const { return _baseVars[i]; }
@@ -272,7 +300,9 @@ public:
}
bool relocateSci0Sci21(SegmentId segment, int location, size_t scriptSize);
+#ifdef ENABLE_SCI32
bool relocateSci3(SegmentId segment, uint32 location, int offset, size_t scriptSize);
+#endif
int propertyOffsetToId(SegManager *segMan, int propertyOffset) const;
@@ -286,7 +316,9 @@ public:
#endif
private:
+#ifdef ENABLE_SCI32
void initSelectorsSci3(const SciSpan<const byte> &buf, const bool initVariables);
+#endif
/**
* A pointer to the raw object data within the object's owner script.
@@ -310,6 +342,7 @@ private:
*/
Common::Array<reg_t> _variables;
+#ifdef ENABLE_SCI32
/**
* A lookup table from a property index to the property's original absolute
* offset within the raw script data. This absolute offset is coded into the
@@ -318,6 +351,7 @@ private:
* barrier, since the script format still only holds 16-bit values inline).
*/
Common::Array<uint32> _propertyOffsetsSci3;
+#endif
/**
* The number of methods on the object.
@@ -336,10 +370,12 @@ private:
uint16 _offset;
reg_t _pos; /**< Object offset within its script; for clones, this is their base */
+#ifdef ENABLE_SCI32
reg_t _superClassPosSci3; /**< reg_t pointing to superclass for SCI3 */
reg_t _speciesSelectorSci3; /**< reg_t containing species "selector" for SCI3 */
reg_t _infoSelectorSci3; /**< reg_t containing info "selector" for SCI3 */
Common::Array<bool> _mustSetViewVisible; /** cached bit of info to make lookup fast, SCI3 only */
+#endif
};
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index cd75a97969..0a2d7e5ef4 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -496,6 +496,7 @@ void Script::identifyOffsets() {
_offsetLookupStringCount++;
}
+#ifdef ENABLE_SCI32
} else if (getSciVersion() == SCI_VERSION_3) {
// SCI3
uint32 sci3StringOffset = 0;
@@ -607,9 +608,11 @@ void Script::identifyOffsets() {
}
}
}
+#endif
}
}
+#ifdef ENABLE_SCI32
SciSpan<const byte> Script::getSci3ObjectsPointer() {
SciSpan<const byte> ptr;
@@ -627,6 +630,7 @@ SciSpan<const byte> Script::getSci3ObjectsPointer() {
return ptr;
}
+#endif
Object *Script::getObject(uint32 offset) {
if (_objects.contains(offset))
@@ -681,6 +685,7 @@ static bool relocateBlock(Common::Array<reg_t> &block, int block_location, Segme
return true;
}
+#ifdef ENABLE_SCI32
int Script::relocateOffsetSci3(uint32 offset) const {
int relocStart = _buf->getUint32LEAt(8);
int relocCount = _buf->getUint16LEAt(18);
@@ -695,6 +700,7 @@ int Script::relocateOffsetSci3(uint32 offset) const {
return -1;
}
+#endif
bool Script::relocateLocal(SegmentId segment, int location) {
if (_localsBlock)
@@ -750,6 +756,7 @@ void Script::relocateSci0Sci21(reg_t block) {
}
}
+#ifdef ENABLE_SCI32
void Script::relocateSci3(reg_t block) {
SciSpan<const byte> relocStart = _buf->subspan(_buf->getUint32SEAt(8));
const uint relocCount = _buf->getUint16SEAt(18);
@@ -766,6 +773,7 @@ void Script::relocateSci3(reg_t block) {
}
}
}
+#endif
void Script::incrementLockers() {
assert(!_markedAsDeleted);
@@ -799,9 +807,8 @@ uint32 Script::validateExportFunc(int pubfunct, bool relocSci3) {
int offset;
- if (getSciVersion() != SCI_VERSION_3) {
- offset = _exports.getUint16SEAt(pubfunct);
- } else {
+#ifdef ENABLE_SCI32
+ if (getSciVersion() == SCI_VERSION_3) {
if (!relocSci3) {
offset = _exports.getUint16SEAt(pubfunct) + getCodeBlockOffset();
} else {
@@ -812,7 +819,9 @@ uint32 Script::validateExportFunc(int pubfunct, bool relocSci3) {
offset = _exports.getUint16SEAt(pubfunct) + getCodeBlockOffset();
}
}
- }
+ } else
+#endif
+ offset = _exports.getUint16SEAt(pubfunct);
// TODO: Check if this should be done for SCI1.1 games as well
if (getSciVersion() >= SCI_VERSION_2 && offset == 0) {
@@ -934,9 +943,11 @@ void Script::initializeClasses(SegManager *segMan) {
} else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1_LATE) {
seeker = _heap.subspan(4 + _heap.getUint16SEAt(2) * 2);
mult = 2;
+#ifdef ENABLE_SCI32
} else if (getSciVersion() == SCI_VERSION_3) {
seeker = getSci3ObjectsPointer();
mult = 1;
+#endif
}
if (!seeker)
@@ -1092,6 +1103,7 @@ void Script::initializeObjectsSci11(SegManager *segMan, SegmentId segmentId) {
relocateSci0Sci21(make_reg(segmentId, _heap.getUint16SEAt(0)));
}
+#ifdef ENABLE_SCI32
void Script::initializeObjectsSci3(SegManager *segMan, SegmentId segmentId) {
SciSpan<const byte> seeker = getSci3ObjectsPointer();
@@ -1110,14 +1122,17 @@ void Script::initializeObjectsSci3(SegManager *segMan, SegmentId segmentId) {
relocateSci3(make_reg(segmentId, 0));
}
+#endif
void Script::initializeObjects(SegManager *segMan, SegmentId segmentId) {
if (getSciVersion() <= SCI_VERSION_1_LATE)
initializeObjectsSci0(segMan, segmentId);
else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1_LATE)
initializeObjectsSci11(segMan, segmentId);
+#ifdef ENABLE_SCI32
else if (getSciVersion() == SCI_VERSION_3)
initializeObjectsSci3(segMan, segmentId);
+#endif
}
reg_t Script::findCanonicAddress(SegManager *segMan, reg_t addr) const {
diff --git a/engines/sci/engine/script.h b/engines/sci/engine/script.h
index f63b312647..e0faa11575 100644
--- a/engines/sci/engine/script.h
+++ b/engines/sci/engine/script.h
@@ -253,11 +253,13 @@ public:
*/
void syncStringHeap(Common::Serializer &ser);
+#ifdef ENABLE_SCI32
/**
* Resolve a relocation in an SCI3 script
* @param offset The offset to relocate from
*/
int relocateOffsetSci3(uint32 offset) const;
+#endif
/**
* Gets an offset to the beginning of the code block in a SCI1.1 or later
@@ -282,6 +284,7 @@ private:
*/
void relocateSci0Sci21(reg_t block);
+#ifdef ENABLE_SCI32
/**
* Processes a relocation block within a SCI3 script
* This function is idempotent, but it must only be called after all
@@ -289,13 +292,16 @@ private:
* @param obj_pos Location (segment, offset) of the block
*/
void relocateSci3(reg_t block);
+#endif
bool relocateLocal(SegmentId segment, int location);
+#ifdef ENABLE_SCI32
/**
* Gets a pointer to the beginning of the objects in a SCI3 script
*/
SciSpan<const byte> getSci3ObjectsPointer();
+#endif
/**
* Initializes the script's objects (SCI0)
@@ -311,12 +317,14 @@ private:
*/
void initializeObjectsSci11(SegManager *segMan, SegmentId segmentId);
+#ifdef ENABLE_SCI32
/**
* Initializes the script's objects (SCI3)
* @param segMan A reference to the segment manager
* @param segmentId The script's segment id
*/
void initializeObjectsSci3(SegManager *segMan, SegmentId segmentId);
+#endif
LocalVariables *allocLocalsSegment(SegManager *segMan);
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 1df3c601ee..1d86948fdd 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -572,11 +572,13 @@ uint32 findOffset(const int16 relOffset, const Script *scr, const uint32 pcOffse
case SCI_VERSION_1_1:
offset = relOffset + scr->getScriptSize();
break;
+#ifdef ENABLE_SCI32
case SCI_VERSION_3:
// In theory this can break if the variant with a one-byte argument is
// used. For now, assume it doesn't happen.
offset = scr->relocateOffsetSci3(pcOffset - 2);
break;
+#endif
default:
error("Unknown lofs type");
}