22 #ifndef SCI_ENGINE_SCRIPT_H 23 #define SCI_ENGINE_SCRIPT_H 25 #include "common/str.h" 27 #include "sci/engine/segment.h" 28 #include "sci/engine/script_patches.h" 33 class ResourceManager;
34 struct SciScriptPatcherEntry;
36 enum ScriptObjectTypes {
52 enum ScriptOffsetEntryTypes {
53 SCI_SCR_OFFSET_TYPE_OBJECT = 0,
54 SCI_SCR_OFFSET_TYPE_STRING,
55 SCI_SCR_OFFSET_TYPE_SAID
59 kNoRelocation = 0xFFFFFFFF
90 bool _markedAsDeleted;
91 SegmentId _localsSegment;
97 offsetLookupArrayType _offsetLookupArray;
100 uint16 _offsetLookupObjectCount;
101 uint16 _offsetLookupStringCount;
102 uint16 _offsetLookupSaidCount;
105 int getLocalsOffset()
const {
return _localsOffset; }
106 uint16 getLocalsCount()
const {
return _localsCount; }
108 uint32 getScriptSize()
const {
return _script.size(); }
109 uint32 getHeapSize()
const {
return _heap.size(); }
110 uint32 getBufSize()
const {
return _buf->size(); }
111 inline uint32 getHeapOffset()
const {
112 if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1_LATE) {
113 return _script.size();
119 const byte *getBuf(uint offset = 0)
const {
return _buf->getUnsafeDataAt(offset); }
122 int getScriptNumber()
const {
return _nr; }
123 SegmentId getLocalsSegment()
const {
return _localsSegment; }
124 reg_t *getLocalsBegin() {
return _localsBlock ? _localsBlock->_locals.
begin() : NULL; }
126 ObjMap &getObjectMap() {
return _objects; }
127 const ObjMap &getObjectMap()
const {
return _objects; }
130 bool offsetIsObject(uint32 offset)
const {
131 return _buf->getUint16SEAt(offset + SCRIPT_OBJECT_MAGIC_OFFSET) == SCRIPT_OBJECT_MAGIC_NUMBER;
138 void freeScript(
const bool keepLocalsSegment =
false);
141 bool isValidOffset(uint32 offset)
const override;
158 Object *getObject(uint32 offset);
159 const Object *getObject(uint32 offset)
const;
170 Object *scriptObjInit(
reg_t obj_pos,
bool fullObjectInit =
true);
184 void initializeClass(
SegManager *segMan, uint16 species, uint32 position);
192 void initializeObjects(
SegManager *segMan, SegmentId segmentId,
bool applyScriptPatches);
197 void incrementLockers();
200 void decrementLockers();
206 uint getLockers()
const;
209 void setLockers(uint lockers);
243 uint32 validateExportFunc(
int pubfunct,
bool relocSci3);
253 _markedAsDeleted =
true;
260 return _markedAsDeleted;
267 SciSpan<const byte> findBlockSCI0(ScriptObjectTypes type,
bool findLastBlock =
false)
const;
279 int relocateOffsetSci3(uint32 offset)
const;
292 uint16 getOffsetObjectCount() {
return _offsetLookupObjectCount; };
293 uint16 getOffsetStringCount() {
return _offsetLookupStringCount; };
294 uint16 getOffsetSaidCount() {
return _offsetLookupSaidCount; };
300 uint32 getRelocationOffset(
const uint32 offset)
const;
316 void relocateSci0Sci21(
const SegmentId segmentId);
324 void relocateSci3(
const SegmentId segmentId);
327 bool relocateLocal(SegmentId segment,
int location, uint32 offset);
342 void initializeObjectsSci0(
SegManager *segMan, SegmentId segmentId,
bool applyScriptPatches);
350 void initializeObjectsSci11(
SegManager *segMan, SegmentId segmentId,
bool applyScriptPatches);
358 void initializeObjectsSci3(
SegManager *segMan, SegmentId segmentId,
bool applyScriptPatches);
366 void identifyOffsets();
371 void applySaidWorkarounds();
376 #endif // SCI_ENGINE_SCRIPT_H uint16 getSynonymsNr() const
Definition: script.h:233
iterator begin()
Definition: array.h:374
const SciSpan< const byte > & getSynonyms() const
Definition: script.h:227
uint getExportsOffset() const
Definition: script.h:215
Definition: serializer.h:79
Definition: resource.h:327
void markDeleted()
Definition: script.h:252
Definition: segment.h:147
int getCodeBlockOffset()
Definition: script.h:286
uint16 getExportsNr() const
Definition: script.h:221
Definition: seg_manager.h:48
Definition: script_patches.h:91
const offsetLookupArrayType * getOffsetArray()
Definition: script.h:291
Definition: vm_types.h:39
bool isMarkedAsDeleted() const
Definition: script.h:259