aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2010-05-26 14:25:51 +0000
committerFilippos Karapetis2010-05-26 14:25:51 +0000
commitbfaba64c6a3aee6875bf135147c2f29a621c876b (patch)
tree865ac5f5ccb5c802bb57fc681e903a56aec42b32
parentd502bdf982410dfc0e5731fa9a83f543f08bd744 (diff)
downloadscummvm-rg350-bfaba64c6a3aee6875bf135147c2f29a621c876b.tar.gz
scummvm-rg350-bfaba64c6a3aee6875bf135147c2f29a621c876b.tar.bz2
scummvm-rg350-bfaba64c6a3aee6875bf135147c2f29a621c876b.zip
Made find_unique_script_block() a member of the Script class
svn-id: r49241
-rw-r--r--engines/sci/engine/savegame.cpp24
-rw-r--r--engines/sci/engine/segment.cpp24
-rw-r--r--engines/sci/engine/segment.h5
3 files changed, 31 insertions, 22 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index ff51f4015c..8f341895c6 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -748,26 +748,6 @@ int gamestate_save(EngineState *s, Common::WriteStream *fh, const char* savename
return 0;
}
-static byte *find_unique_script_block(EngineState *s, byte *buf, int type) {
- bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY);
-
- if (oldScriptHeader)
- buf += 2;
-
- do {
- int seeker_type = READ_LE_UINT16(buf);
-
- if (seeker_type == 0) break;
- if (seeker_type == type) return buf;
-
- int seeker_size = READ_LE_UINT16(buf + 2);
- assert(seeker_size > 0);
- buf += seeker_size;
- } while (1);
-
- return NULL;
-}
-
// TODO: This should probably be turned into an EngineState or DataStack method.
static void reconstruct_stack(EngineState *retval) {
SegmentId stack_seg = retval->_segMan->findSegmentByType(SEG_TYPE_STACK);
@@ -821,8 +801,8 @@ void SegManager::reconstructScripts(EngineState *s) {
s->_segMan->scriptRelocateExportsSci11(i);
}
} else {
- scr->_exportTable = (uint16 *) find_unique_script_block(s, scr->_buf, SCI_OBJ_EXPORTS);
- scr->_synonyms = find_unique_script_block(s, scr->_buf, SCI_OBJ_SYNONYMS);
+ scr->_exportTable = (uint16 *) scr->findBlock(SCI_OBJ_EXPORTS);
+ scr->_synonyms = scr->findBlock(SCI_OBJ_SYNONYMS);
scr->_exportTable += 3;
}
scr->_codeBlocks.clear();
diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp
index 0c468a3cc2..b26ac4f78e 100644
--- a/engines/sci/engine/segment.cpp
+++ b/engines/sci/engine/segment.cpp
@@ -395,6 +395,30 @@ int Script::getSynonymsNr() const {
return _numSynonyms;
}
+byte *Script::findBlock(int type) {
+ byte *buf = _buf;
+ bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY);
+
+ if (oldScriptHeader)
+ buf += 2;
+
+ do {
+ int seekerType = READ_LE_UINT16(buf);
+
+ if (seekerType == 0)
+ break;
+ if (seekerType == type)
+ return buf;
+
+ int seekerSize = READ_LE_UINT16(buf + 2);
+ assert(seekerSize > 0);
+ buf += seekerSize;
+ } while (1);
+
+ return NULL;
+}
+
+
// memory operations
void Script::mcpyInOut(int dst, const void *src, size_t n) {
diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h
index 876a081295..764d235e54 100644
--- a/engines/sci/engine/segment.h
+++ b/engines/sci/engine/segment.h
@@ -498,6 +498,11 @@ public:
*/
int16 getHeap(uint16 offset) const;
+ /**
+ * Finds the pointer where a block of a specific type starts from
+ */
+ byte *Script::findBlock(int type);
+
private:
void setScriptSize(int script_nr, ResourceManager *resMan);
};