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"
34struct SciScriptPatcherEntry;
36enum ScriptObjectTypes {
52enum 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;
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);
158 Object *getObject(uint32 offset);
159 const Object *getObject(uint32 offset)
const;
253 _markedAsDeleted =
true;
260 return _markedAsDeleted;
279 int relocateOffsetSci3(uint32 offset)
const;
292 uint16 getOffsetObjectCount() {
return _offsetLookupObjectCount; };
293 uint16 getOffsetStringCount() {
return _offsetLookupStringCount; };
294 uint16 getOffsetSaidCount() {
return _offsetLookupSaidCount; };
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();
iterator begin()
Definition: array.h:375
Definition: serializer.h:80
Definition: resource.h:327
uint32 getRelocationOffset(const uint32 offset) const
SciSpan< const byte > findBlockSCI0(ScriptObjectTypes type, bool findLastBlock=false) const
void initializeLocals(SegManager *segMan)
bool isValidOffset(uint32 offset) const override
const SciSpan< const byte > & getSynonyms() const
Definition: script.h:227
void initializeClass(SegManager *segMan, uint16 species, uint32 position)
Common::Array< reg_t > listAllOutgoingReferences(reg_t object) const override
bool isMarkedAsDeleted() const
Definition: script.h:259
int getCodeBlockOffset()
Definition: script.h:286
void freeAtAddress(SegManager *segMan, reg_t sub_addr) override
Common::Array< reg_t > listAllDeallocatable(SegmentId segId) const override
void markDeleted()
Definition: script.h:252
void syncStringHeap(Common::Serializer &ser)
void setLockers(uint lockers)
uint16 getExportsNr() const
Definition: script.h:221
Object * scriptObjInit(reg_t obj_pos, bool fullObjectInit=true)
uint16 getSynonymsNr() const
Definition: script.h:233
reg_t findCanonicAddress(SegManager *segMan, reg_t sub_addr) const override
uint getExportsOffset() const
Definition: script.h:215
const offsetLookupArrayType * getOffsetArray()
Definition: script.h:291
void initializeObjects(SegManager *segMan, SegmentId segmentId, bool applyScriptPatches)
uint32 validateExportFunc(int pubfunct, bool relocSci3)
SegmentRef dereference(reg_t pointer) override
Common::Array< reg_t > listObjectReferences() const
Definition: script_patches.h:91
Definition: seg_manager.h:48
Definition: segment.h:147
Definition: vm_types.h:39