aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2010-06-03 10:16:21 +0000
committerFilippos Karapetis2010-06-03 10:16:21 +0000
commit86b452d36cb781c24e1b167dd6cef768b7c6286b (patch)
tree97a66ac538ca14982f082d4ca93c5c90c98f4a6c /engines/sci
parent86dcc28342021933f04ff3542932fc8823ff2360 (diff)
downloadscummvm-rg350-86b452d36cb781c24e1b167dd6cef768b7c6286b.tar.gz
scummvm-rg350-86b452d36cb781c24e1b167dd6cef768b7c6286b.tar.bz2
scummvm-rg350-86b452d36cb781c24e1b167dd6cef768b7c6286b.zip
Moved several object-related defines inside vm.h into segment.h, where the Object class resides. Also, removed several unused defines
svn-id: r49406
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/console.cpp2
-rw-r--r--engines/sci/engine/kscripts.cpp4
-rw-r--r--engines/sci/engine/script.cpp2
-rw-r--r--engines/sci/engine/segment.cpp12
-rw-r--r--engines/sci/engine/segment.h21
-rw-r--r--engines/sci/engine/vm.h40
6 files changed, 31 insertions, 50 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 3b237f44ed..bad39d3065 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -3067,7 +3067,7 @@ int Console::printObject(reg_t pos) {
DebugPrintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(pos), s->_segMan->getObjectName(pos),
obj->getVarCount(), obj->getMethodCount());
- if (!(obj->getInfoSelector().offset & SCRIPT_INFO_CLASS))
+ if (!obj->isClass())
var_container = s->_segMan->getObject(obj->getSuperClassSelector());
DebugPrintf(" -- member variables:\n");
for (i = 0; (uint)i < obj->getVarCount(); i++) {
diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp
index 2f260bc03a..722d0175d1 100644
--- a/engines/sci/engine/kscripts.cpp
+++ b/engines/sci/engine/kscripts.cpp
@@ -132,7 +132,7 @@ reg_t kClone(EngineState *s, int argc, reg_t *argv) {
*clone_obj = *parent_obj;
// Mark as clone
- clone_obj->setInfoSelector(make_reg(0, SCRIPT_INFO_CLONE));
+ clone_obj->markAsClone();
clone_obj->setSpeciesSelector(clone_obj->getPos());
if (parent_obj->isClass())
clone_obj->setSuperClassSelector(parent_obj->getPos());
@@ -154,7 +154,7 @@ reg_t kDisposeClone(EngineState *s, int argc, reg_t *argv) {
return s->r_acc;
}
- if (victim_obj->getInfoSelector().offset != SCRIPT_INFO_CLONE) {
+ if (!victim_obj->isClone()) {
//warning("Attempt to dispose something other than a clone at %04x", offset);
// SCI silently ignores this behaviour; some games actually depend on it
return s->r_acc;
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index 3fb8a5763e..1f32e50b67 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -205,7 +205,7 @@ void SegManager::scriptInitialiseObjectsSci11(SegmentId seg) {
const byte *seeker = scr->_heapStart + 4 + READ_SCI11ENDIAN_UINT16(scr->_heapStart + 2) * 2;
while (READ_SCI11ENDIAN_UINT16(seeker) == SCRIPT_OBJECT_MAGIC_NUMBER) {
- if (READ_SCI11ENDIAN_UINT16(seeker + 14) & SCRIPT_INFO_CLASS) { // -info- selector
+ if (READ_SCI11ENDIAN_UINT16(seeker + 14) & kInfoFlagClass) { // -info- selector
int classpos = seeker - scr->_buf;
int species = READ_SCI11ENDIAN_UINT16(seeker + 10);
diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp
index 988ee67741..0e0a759d4b 100644
--- a/engines/sci/engine/segment.cpp
+++ b/engines/sci/engine/segment.cpp
@@ -240,7 +240,7 @@ Object *Script::scriptObjInit(reg_t obj_pos, bool fullObjectInit) {
obj = allocateObject(obj_pos.offset);
- VERIFY(obj_pos.offset + SCRIPT_FUNCTAREAPTR_OFFSET < (int)_bufSize, "Function area pointer stored beyond end of script\n");
+ VERIFY(obj_pos.offset + kOffsetFunctionArea < (int)_bufSize, "Function area pointer stored beyond end of script\n");
obj->init(_buf, obj_pos, fullObjectInit);
@@ -693,9 +693,9 @@ void Object::init(byte *buf, reg_t obj_pos, bool initVariables) {
_pos = obj_pos;
if (getSciVersion() < SCI_VERSION_1_1) {
- _variables.resize(READ_LE_UINT16(data + SCRIPT_SELECTORCTR_OFFSET));
+ _variables.resize(READ_LE_UINT16(data + kOffsetSelectorCounter));
_baseVars = (const uint16 *)(_baseObj + _variables.size() * 2);
- _baseMethod = (const uint16 *)(data + READ_LE_UINT16(data + SCRIPT_FUNCTAREAPTR_OFFSET));
+ _baseMethod = (const uint16 *)(data + READ_LE_UINT16(data + kOffsetFunctionArea));
_methodCount = READ_LE_UINT16(_baseMethod - 1);
} else {
_variables.resize(READ_SCI11ENDIAN_UINT16(data + 2));
@@ -720,7 +720,7 @@ int Object::locateVarSelector(SegManager *segMan, Selector slc) const {
if (getSciVersion() < SCI_VERSION_1_1) {
varnum = getVarCount();
- int selector_name_offset = varnum * 2 + SCRIPT_SELECTOR_OFFSET;
+ int selector_name_offset = varnum * 2 + kOffsetSelectorSegment;
buf = _baseObj + selector_name_offset;
} else {
const Object *obj = getClass(segMan);
@@ -749,11 +749,11 @@ int Object::propertyOffsetToId(SegManager *segMan, int propertyOffset) const {
}
if (getSciVersion() < SCI_VERSION_1_1) {
- const byte *selectoroffset = ((const byte *)(_baseObj)) + SCRIPT_SELECTOR_OFFSET + selectors * 2;
+ const byte *selectoroffset = ((const byte *)(_baseObj)) + kOffsetSelectorSegment + selectors * 2;
return READ_SCI11ENDIAN_UINT16(selectoroffset + propertyOffset);
} else {
const Object *obj = this;
- if (!(getInfoSelector().offset & SCRIPT_INFO_CLASS))
+ if (!isClass())
obj = segMan->getObject(getSuperClassSelector());
return READ_SCI11ENDIAN_UINT16((const byte *)obj->_baseVars + propertyOffset);
diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h
index 051354bf7a..d89f54fbe2 100644
--- a/engines/sci/engine/segment.h
+++ b/engines/sci/engine/segment.h
@@ -205,6 +205,22 @@ enum {
OBJECT_FLAG_FREED = (1 << 0)
};
+enum infoSelectorFlags {
+ kInfoFlagClone = 0x0001,
+ kInfoFlagClass = 0x8000
+};
+
+enum ObjectOffsets {
+ kOffsetLocalVariables = -6,
+ kOffsetFunctionArea = -4,
+ kOffsetSelectorCounter = -2,
+ kOffsetSelectorSegment = 0,
+ kOffsetInfoSelectorSci0 = 4,
+ kOffsetNamePointerSci0 = 6,
+ kOffsetInfoSelectorSci11 = 14,
+ kOffsetNamePointerSci11 = 16,
+};
+
class Object {
public:
Object() {
@@ -264,9 +280,12 @@ public:
*/
int locateVarSelector(SegManager *segMan, Selector slc) const;
- bool isClass() const { return (getInfoSelector().offset & SCRIPT_INFO_CLASS); }
+ bool isClass() const { return (getInfoSelector().offset & kInfoFlagClass); }
const Object *getClass(SegManager *segMan) const;
+ void markAsClone() { setInfoSelector(make_reg(0, kInfoFlagClone)); }
+ bool isClone() const { return (getInfoSelector().offset & kInfoFlagClone); }
+
void markAsFreed() { _flags |= OBJECT_FLAG_FREED; }
bool isFreed() const { return _flags & OBJECT_FLAG_FREED; }
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index 7ea0b2e548..dd1294b59c 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -43,44 +43,9 @@ class ResourceManager;
/** Number of bytes to be allocated for the stack */
#define VM_STACK_SIZE 0x1000
-/** Maximum number of calls residing on the stack */
-#define SCRIPT_MAX_EXEC_STACK 256
-/** Maximum number of entries in the class table */
-#define SCRIPT_MAX_classTable_SIZE 256
-/** Maximum number of cloned objects on the heap */
-#define SCRIPT_MAX_CLONES 256
-
-
-/** Object-relative offset of the selector area inside a script */
-#define SCRIPT_SELECTOR_OFFSET 8 -8
-
-/** Object-relative offset of the pointer to the underlying script's local variables */
-#define SCRIPT_LOCALVARPTR_OFFSET 2 -8
-
-/** Object-relative offset of the selector counter */
-#define SCRIPT_SELECTORCTR_OFFSET 6 -8
-
-/** Object-relative offset of the offset of the function area */
-#define SCRIPT_FUNCTAREAPTR_OFFSET 4 -8
-
-/** Offset that has to be added to the function area pointer */
-#define SCRIPT_FUNCTAREAPTR_MAGIC 8 -8
-
-/** Offset of the name pointer */
-#define SCRIPT_NAME_OFFSET (getSciVersion() < SCI_VERSION_1_1 ? 14 -8 : 16)
-
-/** Object-relative offset of the -info- selector */
-#define SCRIPT_INFO_OFFSET (getSciVersion() < SCI_VERSION_1_1 ? 12 -8 : 14)
-
-/** Flag fo the -info- selector */
-#define SCRIPT_INFO_CLONE 0x0001
-
-/** Flag for the -info- selector */
-#define SCRIPT_INFO_CLASS 0x8000
-
-
/** Magical object identifier */
#define SCRIPT_OBJECT_MAGIC_NUMBER 0x1234
+
/** Offset of this identifier */
#define SCRIPT_OBJECT_MAGIC_OFFSET (getSciVersion() < SCI_VERSION_1_1 ? -8 : 0)
@@ -89,9 +54,6 @@ class ResourceManager;
#define SCRIPT_SUPERCLASS_OFFSET (getSciVersion() < SCI_VERSION_1_1 ? 10 -8 : 12)
-/** Magic adjustment value for lofsa and lofss */
-#define SCRIPT_LOFS_MAGIC 3
-
/** Stack pointer value: Use predecessor's value */
#define CALL_SP_CARRY NULL