[Scummvm-cvs-logs] SF.net SVN: scummvm:[49330] scummvm/trunk/engines/sci
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Sun May 30 20:45:07 CEST 2010
Revision: 49330
http://scummvm.svn.sourceforge.net/scummvm/?rev=49330&view=rev
Author: thebluegr
Date: 2010-05-30 18:45:07 +0000 (Sun, 30 May 2010)
Log Message:
-----------
Moved setScriptSize() inside Script::init(), and removed a FIXME - the SCI1.1 word-align is done inside Script::init()
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/script.cpp
scummvm/trunk/engines/sci/engine/segment.cpp
scummvm/trunk/engines/sci/engine/segment.h
scummvm/trunk/engines/sci/resource.cpp
Modified: scummvm/trunk/engines/sci/engine/script.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/script.cpp 2010-05-30 17:02:21 UTC (rev 49329)
+++ scummvm/trunk/engines/sci/engine/script.cpp 2010-05-30 18:45:07 UTC (rev 49330)
@@ -437,13 +437,6 @@
scr->setExportTableOffset(6);
int heapStart = scr->getScriptSize();
-
- // FIXME: This code was used to ensure that the heap address is word-aligned
- // Make sure that this is used in all places where the heap is referenced,
- // not just here...
- //if (heapStart & 2)
- // heapStart++;
-
segMan->scriptInitialiseLocals(make_reg(seg_id, heapStart + 4));
segMan->scriptInitialiseObjectsSci11(seg_id);
scr->heapRelocate(make_reg(seg_id, READ_SCI11ENDIAN_UINT16(scr->_heapStart)));
Modified: scummvm/trunk/engines/sci/engine/segment.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.cpp 2010-05-30 17:02:21 UTC (rev 49329)
+++ scummvm/trunk/engines/sci/engine/segment.cpp 2010-05-30 18:45:07 UTC (rev 49330)
@@ -117,8 +117,8 @@
_codeBlocks.clear();
}
-bool Script::init(int script_nr, ResourceManager *resMan) {
- setScriptSize(script_nr, resMan);
+void Script::init(int script_nr, ResourceManager *resMan) {
+ Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, script_nr), 0);
_localsOffset = 0;
_localsBlock = NULL;
@@ -132,7 +132,25 @@
_buf = 0;
_heapStart = 0;
- return true;
+ _scriptSize = script->size;
+ _bufSize = script->size;
+ _heapSize = 0;
+
+ if (getSciVersion() == SCI_VERSION_0_EARLY) {
+ _bufSize += READ_LE_UINT16(script->data) * 2;
+ } else if (getSciVersion() >= SCI_VERSION_1_1) {
+ Resource *heap = resMan->findResource(ResourceId(kResourceTypeHeap, script_nr), 0);
+ _bufSize += heap->size;
+ _heapSize = heap->size;
+
+ // Ensure that the start of the heap resource can be word-aligned.
+ if (script->size & 2) {
+ _bufSize++;
+ _scriptSize++;
+ }
+
+ assert(_bufSize <= 65535);
+ }
}
void Script::load(ResourceManager *resMan) {
@@ -156,42 +174,6 @@
}
}
-void Script::setScriptSize(int script_nr, ResourceManager *resMan) {
- Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, script_nr), 0);
- Resource *heap = resMan->findResource(ResourceId(kResourceTypeHeap, script_nr), 0);
- bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY);
-
- _scriptSize = script->size;
- _heapSize = 0; // Set later
-
- if (!script || (getSciVersion() >= SCI_VERSION_1_1 && !heap)) {
- error("SegManager::setScriptSize: failed to load %s", !script ? "script" : "heap");
- }
- if (oldScriptHeader) {
- _bufSize = script->size + READ_LE_UINT16(script->data) * 2;
- //locals_size = READ_LE_UINT16(script->data) * 2;
- } else if (getSciVersion() < SCI_VERSION_1_1) {
- _bufSize = script->size;
- } else {
- _bufSize = script->size + heap->size;
- _heapSize = heap->size;
-
- // Ensure that the start of the heap resource can be word-aligned.
- if (script->size & 2) {
- _bufSize++;
- _scriptSize++;
- }
-
- if (_bufSize > 65535) {
- error("Script and heap sizes combined exceed 64K."
- "This means a fundamental design bug was made in SCI\n"
- "regarding SCI1.1 games.\nPlease report this so it can be"
- "fixed in the next major version");
- return;
- }
- }
-}
-
Object *Script::allocateObject(uint16 offset) {
return &_objects[offset];
}
Modified: scummvm/trunk/engines/sci/engine/segment.h
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.h 2010-05-30 17:02:21 UTC (rev 49329)
+++ scummvm/trunk/engines/sci/engine/segment.h 2010-05-30 18:45:07 UTC (rev 49330)
@@ -363,7 +363,7 @@
~Script();
void freeScript();
- bool init(int script_nr, ResourceManager *resMan);
+ void init(int script_nr, ResourceManager *resMan);
void load(ResourceManager *resMan);
virtual bool isValidOffset(uint16 offset) const;
@@ -512,9 +512,6 @@
* Finds the pointer where a block of a specific type starts from
*/
byte *findBlock(int type);
-
-private:
- void setScriptSize(int script_nr, ResourceManager *resMan);
};
/** Data stack */
Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp 2010-05-30 17:02:21 UTC (rev 49329)
+++ scummvm/trunk/engines/sci/resource.cpp 2010-05-30 18:45:07 UTC (rev 49330)
@@ -1926,6 +1926,7 @@
if (getSciVersion() >= SCI_VERSION_1_1 && addSci11ScriptOffset) {
offset += script->size;
+ // Ensure that the start of the heap is word-aligned - same as in Script::init()
if (script->size & 2)
offset++;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list