[Scummvm-cvs-logs] SF.net SVN: scummvm:[49308] scummvm/trunk/engines/sci
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Sat May 29 16:03:08 CEST 2010
Revision: 49308
http://scummvm.svn.sourceforge.net/scummvm/?rev=49308&view=rev
Author: thebluegr
Date: 2010-05-29 14:03:08 +0000 (Sat, 29 May 2010)
Log Message:
-----------
Added a method to the resource manager, to limit the places where script exports are accessed, since for SCI11 and newer exports can be functions and objects (first step in removing scriptRelocateExportsSci11(), which is a gross hack and it fails in QFG1VGA)
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/game.cpp
scummvm/trunk/engines/sci/engine/seg_manager.h
scummvm/trunk/engines/sci/resource.cpp
scummvm/trunk/engines/sci/resource.h
Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp 2010-05-29 08:14:50 UTC (rev 49307)
+++ scummvm/trunk/engines/sci/engine/game.cpp 2010-05-29 14:03:08 UTC (rev 49308)
@@ -127,9 +127,7 @@
srand(g_system->getMillis()); // Initialize random number generator
-// script_dissect(0, s->_selectorNames);
- // The first entry in the export table of script 0 points to the game object
- s->_gameObj = s->_segMan->lookupScriptExport(0, 0);
+ s->_gameObj = g_sci->getResMan()->findGameObject();
#ifdef USE_OLD_MUSIC_FUNCTIONS
if (s->sfx_init_flags & SFX_STATE_FLAG_NOSOUND)
Modified: scummvm/trunk/engines/sci/engine/seg_manager.h
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.h 2010-05-29 08:14:50 UTC (rev 49307)
+++ scummvm/trunk/engines/sci/engine/seg_manager.h 2010-05-29 14:03:08 UTC (rev 49308)
@@ -112,12 +112,6 @@
SegmentId getScriptSegment(int script_nr, ScriptLoadType load);
// TODO: document this
- reg_t lookupScriptExport(int script_nr, int export_index) {
- SegmentId seg = getScriptSegment(script_nr, SCRIPT_GET_DONT_LOAD);
- return make_reg(seg, getScript(seg)->validateExportFunc(export_index));
- }
-
- // TODO: document this
reg_t getClassAddress(int classnr, ScriptLoadType lock, reg_t caller);
/**
Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp 2010-05-29 08:14:50 UTC (rev 49307)
+++ scummvm/trunk/engines/sci/resource.cpp 2010-05-29 14:03:08 UTC (rev 49308)
@@ -1913,26 +1913,37 @@
#define READ_UINT16(ptr) (!isSci11Mac() ? READ_LE_UINT16(ptr) : READ_BE_UINT16(ptr))
+reg_t ResourceManager::findGameObject(bool addSci11ScriptOffset) {
+ Resource *script = findResource(ResourceId(kResourceTypeScript, 0), false);
+ int extraBytes = 0;
+ if (getSciVersion() == SCI_VERSION_0_EARLY || getSciVersion() >= SCI_VERSION_1_1)
+ extraBytes = 2;
+
+ int16 offset = READ_UINT16(script->data + extraBytes + 4 + 2);
+
+ // In SCI1.1 and newer, the heap is appended at the end of the script,
+ // so adjust the offset accordingly
+ if (getSciVersion() >= SCI_VERSION_1_1 && addSci11ScriptOffset)
+ offset += script->size;
+
+ return make_reg(1, offset);
+}
+
Common::String ResourceManager::findSierraGameId() {
- Resource *script = findResource(ResourceId(kResourceTypeScript, 0), false);
// In SCI0-SCI1, the heap is embedded in the script. In SCI1.1+, it's separated
Resource *heap = 0;
- byte *seeker = 0;
- Common::String sierraId;
+ int nameSelector = 3;
- // Seek to the name selector of the first export
if (getSciVersion() < SCI_VERSION_1_1) {
- const int nameSelector = 3;
- int extraSci0EarlyBytes = (getSciVersion() == SCI_VERSION_0_EARLY) ? 2 : 0;
- byte *exportPtr = script->data + extraSci0EarlyBytes + 4 + 2;
- seeker = script->data + READ_UINT16(script->data + READ_UINT16(exportPtr) + nameSelector * 2);
+ heap = findResource(ResourceId(kResourceTypeScript, 0), false);
} else {
- const int nameSelector = 5 + 3;
heap = findResource(ResourceId(kResourceTypeHeap, 0), false);
- byte *exportPtr = script->data + 4 + 2 + 2;
- seeker = heap->data + READ_UINT16(heap->data + READ_UINT16(exportPtr) + nameSelector * 2);
+ nameSelector += 5;
}
+ // Seek to the name selector of the first export
+ byte *seeker = heap->data + READ_UINT16(heap->data + findGameObject(false).offset + nameSelector * 2);
+ Common::String sierraId;
sierraId += (const char *)seeker;
return sierraId;
Modified: scummvm/trunk/engines/sci/resource.h
===================================================================
--- scummvm/trunk/engines/sci/resource.h 2010-05-29 08:14:50 UTC (rev 49307)
+++ scummvm/trunk/engines/sci/resource.h 2010-05-29 14:03:08 UTC (rev 49308)
@@ -296,6 +296,14 @@
*/
Common::String findSierraGameId();
+ /**
+ * Finds the location of the game object from script 0
+ * @param addSci11ScriptOffset: Adjust the return value for SCI1.1 and newer
+ * games. Needs to be false when the heap is accessed directly inside
+ * findSierraGameId().
+ */
+ reg_t findGameObject(bool addSci11ScriptOffset = true);
+
protected:
// Maximum number of bytes to allow being allocated for resources
// Note: maxMemory will not be interpreted as a hard limit, only as a restriction
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