22 #ifndef SCI_ENGINE_OBJECT_H 23 #define SCI_ENGINE_OBJECT_H 25 #include "common/array.h" 26 #include "common/serializer.h" 27 #include "common/textconsole.h" 29 #include "sci/engine/vm_types.h" 31 #include "sci/version.h" 38 enum infoSelectorFlags {
39 kInfoFlagClone = 0x0001,
45 kInfoFlagViewVisible = 0x0008,
51 kInfoFlagViewInserted = 0x0010,
53 kInfoFlagClass = 0x8000
57 kOffsetHeaderSize = 6,
58 kOffsetHeaderLocalVariables = 0,
59 kOffsetHeaderFunctionArea = 2,
60 kOffsetHeaderSelectorCounter = 4,
62 kOffsetSelectorSegment = 0,
63 kOffsetInfoSelectorSci0 = 4,
64 kOffsetNamePointerSci0 = 6,
65 kOffsetInfoSelectorSci11 = 14,
66 kOffsetNamePointerSci11 = 16
73 _offset(getSciVersion() < SCI_VERSION_1_1 ? 0 : 5),
79 _infoSelectorSci3(NULL_REG),
80 _speciesSelectorSci3(NULL_REG),
81 _superClassPosSci3(NULL_REG)
87 _baseObj = other._baseObj;
88 _baseMethod = other._baseMethod;
89 _variables = other._variables;
90 _methodCount = other._methodCount;
91 _isFreed = other._isFreed;
92 _offset = other._offset;
94 _baseVars = other._baseVars;
97 if (getSciVersion() == SCI_VERSION_3) {
98 _propertyOffsetsSci3 = other._propertyOffsetsSci3;
99 _superClassPosSci3 = other._superClassPosSci3;
100 _speciesSelectorSci3 = other._speciesSelectorSci3;
101 _infoSelectorSci3 = other._infoSelectorSci3;
102 _mustSetViewVisible = other._mustSetViewVisible;
109 reg_t getSpeciesSelector()
const {
111 if (getSciVersion() == SCI_VERSION_3)
112 return _speciesSelectorSci3;
115 return _variables[_offset];
118 void setSpeciesSelector(
reg_t value) {
120 if (getSciVersion() == SCI_VERSION_3)
121 _speciesSelectorSci3 = value;
124 _variables[_offset] = value;
127 reg_t getSuperClassSelector()
const {
129 if (getSciVersion() == SCI_VERSION_3)
130 return _superClassPosSci3;
133 return _variables[_offset + 1];
136 void setSuperClassSelector(
reg_t value) {
138 if (getSciVersion() == SCI_VERSION_3)
139 _superClassPosSci3 = value;
142 _variables[_offset + 1] = value;
145 reg_t getInfoSelector()
const {
147 if (getSciVersion() == SCI_VERSION_3)
148 return _infoSelectorSci3;
151 return _variables[_offset + 2];
154 void setInfoSelector(
reg_t info) {
156 if (getSciVersion() == SCI_VERSION_3)
157 _infoSelectorSci3 = info;
160 _variables[_offset + 2] = info;
164 void setInfoSelectorFlag(infoSelectorFlags flag) {
165 if (getSciVersion() == SCI_VERSION_3) {
166 _infoSelectorSci3 |= flag;
168 _variables[_offset + 2] |= flag;
172 void clearInfoSelectorFlag(infoSelectorFlags flag) {
173 if (getSciVersion() == SCI_VERSION_3) {
174 _infoSelectorSci3 &= ~flag;
176 _variables[_offset + 2] &= ~flag;
180 bool isInserted()
const {
181 return getInfoSelector().toUint16() & kInfoFlagViewInserted;
185 reg_t getNameSelector()
const {
191 reg_t getPropDictSelector()
const {
193 if (getSciVersion() == SCI_VERSION_3)
195 error(
"getPropDictSelector called for SCI3");
198 return _variables[2];
201 void setPropDictSelector(
reg_t value) {
203 if (getSciVersion() == SCI_VERSION_3)
205 error(
"setPropDictSelector called for SCI3");
208 _variables[2] = value;
211 reg_t getClassScriptSelector()
const {
213 if (getSciVersion() == SCI_VERSION_3)
214 return make_reg(0, _baseObj.getUint16SEAt(6));
217 return _variables[4];
220 void setClassScriptSelector(
reg_t value) {
222 if (getSciVersion() == SCI_VERSION_3)
224 error(
"setClassScriptSelector called for SCI3");
227 _variables[4] = value;
230 Selector getVarSelector(uint16 i)
const {
return _baseVars[i]; }
236 return make_reg32(_pos.getSegment(), _baseMethod[index * 2 + 1]);
243 return _baseMethod[index * 2];
253 for (uint i = 0; i < _methodCount; i++)
266 bool isClass()
const {
return (getInfoSelector().getOffset() & kInfoFlagClass); }
269 void markAsFreed() { _isFreed =
true; }
270 bool isFreed()
const {
return _isFreed; }
272 uint getVarCount()
const {
return _variables.
size(); }
274 void init(
const Script &owner,
reg_t obj_pos,
bool initVariables =
true);
276 reg_t getVariable(uint var)
const {
return _variables[var]; }
277 reg_t &getVariableRef(uint var) {
return _variables[var]; }
279 uint16 getMethodCount()
const {
return _methodCount; }
280 reg_t getPos()
const {
return _pos; }
284 void cloneFromObject(
const Object *obj) {
285 _name = obj ? obj->_name : NULL_REG;
290 if (getSciVersion() == SCI_VERSION_3) {
296 bool relocateSci0Sci21(SegmentId segment,
int location, uint32 heapOffset);
298 bool relocateSci3(SegmentId segment, uint32 location,
int offset, uint32 scriptSize);
301 int propertyOffsetToId(
SegManager *segMan,
int propertyOffset)
const;
303 void initSpecies(
SegManager *segMan,
reg_t addr,
bool applyScriptPatches);
304 void initSuperClass(
SegManager *segMan,
reg_t addr,
bool applyScriptPatches);
305 bool initBaseObject(
SegManager *segMan,
reg_t addr,
bool doInitSuperClass =
true,
bool applyScriptPatches =
true);
308 bool mustSetViewVisible(
const int index,
const bool fromPropertyOp)
const;
372 reg_t _superClassPosSci3;
373 reg_t _speciesSelectorSci3;
374 reg_t _infoSelectorSci3;
382 #endif // SCI_ENGINE_OBJECT_H int funcSelectorPosition(Selector sel) const
Definition: object.h:252
Definition: serializer.h:79
int locateVarSelector(SegManager *segMan, Selector slc) const
Definition: serializer.h:308
size_type size() const
Definition: array.h:315
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: seg_manager.h:48
Selector getFuncSelector(const uint16 index) const
Definition: object.h:242
reg_t getFunction(const uint16 index) const
Definition: object.h:235
Definition: vm_types.h:39