diff options
author | Max Horn | 2009-05-18 12:34:56 +0000 |
---|---|---|
committer | Max Horn | 2009-05-18 12:34:56 +0000 |
commit | 5170acd00c9ca7cdeebc72ac172292e9dc3b69fe (patch) | |
tree | 9ce2484671b490ad0d7d0259d6f5043b5369e360 /engines/sci/engine | |
parent | f59456274530175e6b41d78d29c95b6db1c4299a (diff) | |
download | scummvm-rg350-5170acd00c9ca7cdeebc72ac172292e9dc3b69fe.tar.gz scummvm-rg350-5170acd00c9ca7cdeebc72ac172292e9dc3b69fe.tar.bz2 scummvm-rg350-5170acd00c9ca7cdeebc72ac172292e9dc3b69fe.zip |
SCI: Removed the unused member SegManager::gc_mark_bits; changed some int params to SegmentId
svn-id: r40685
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/savegame.cpp | 7 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 34 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.h | 25 |
3 files changed, 27 insertions, 39 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 72e96c6e8f..ef1738b06d 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -160,7 +160,7 @@ void syncWithSerializer(Common::Serializer &s, reg_t &obj) { void MenuItem::saveLoadWithSerializer(Common::Serializer &s) { s.syncAsSint32LE(_type); s.syncString(_keytext); - s.skip(4); // Used to be keytext_size (an already unused field) + s.skip(4); // Obsolete: Used to be keytext_size s.syncAsSint32LE(_flags); s.syncBytes(_said, MENU_SAID_SPEC_SIZE); @@ -189,7 +189,7 @@ void Menubar::saveLoadWithSerializer(Common::Serializer &s) { void SegManager::saveLoadWithSerializer(Common::Serializer &s) { s.syncAsSint32LE(reserved_id); s.syncAsSint32LE(exports_wide); - s.syncAsSint32LE(gc_mark_bits); + s.skip(4); // Obsolete: Used to be gc_mark_bits id_seg_map->saveLoadWithSerializer(s); @@ -587,8 +587,7 @@ static void reconstruct_scripts(EngineState *s, SegManager *self) { scr->export_table = 0; scr->synonyms = 0; if (READ_LE_UINT16(scr->buf + 6) > 0) { - scr->export_table = (uint16 *)(scr->buf + 8); - scr->exports_nr = READ_LE_UINT16((byte *)(scr->export_table - 1)); + scr->setExportTableOffset(6); } } else { scr->export_table = (uint16 *) find_unique_script_block(s, scr->buf, SCI_OBJ_EXPORTS); diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index b4b50d4b1e..e034515aae 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -92,9 +92,6 @@ SegManager::SegManager(bool sci1_1) { exports_wide = 0; isSci1_1 = sci1_1; - - // gc initialisation - gc_mark_bits = 0; } // Destroy the object, free the memorys if allocated before @@ -114,25 +111,22 @@ SegManager::~SegManager() { // Returns : 0 - allocation failure // 1 - allocated successfully // seg_id - allocated segment id -Script *SegManager::allocateScript(EngineState *s, int script_nr, int* seg_id) { - int seg; +Script *SegManager::allocateScript(EngineState *s, int script_nr, SegmentId *seg_id) { bool was_added; - MemObject* mem; + MemObject *mem; - seg = id_seg_map->checkKey(script_nr, true, &was_added); + *seg_id = id_seg_map->checkKey(script_nr, true, &was_added); if (!was_added) { - *seg_id = seg; return (Script *)_heap[*seg_id]; } // allocate the MemObject - mem = memObjAllocate(seg, script_nr, MEM_OBJ_SCRIPT); + mem = memObjAllocate(*seg_id, script_nr, MEM_OBJ_SCRIPT); if (!mem) { sciprintf("%s, %d, Not enough memory, ", __FILE__, __LINE__); return NULL; } - *seg_id = seg; return (Script *)mem; } @@ -206,7 +200,7 @@ int SegManager::initialiseScript(Script &scr, EngineState *s, int script_nr) { return 1; } -int SegManager::deallocate(int seg, bool recursive) { +int SegManager::deallocate(SegmentId seg, bool recursive) { MemObject *mobj; VERIFY(check(seg), "invalid seg id"); @@ -267,7 +261,7 @@ bool SegManager::scriptIsMarkedAsDeleted(SegmentId seg) { int SegManager::deallocateScript(int script_nr) { - int seg = segGet(script_nr); + SegmentId seg = segGet(script_nr); deallocate(seg, true); @@ -370,11 +364,11 @@ int16 Script::getHeap(uint16 offset) const { } // return the seg if script_id is valid and in the map, else -1 -int SegManager::segGet(int script_id) const { +SegmentId SegManager::segGet(int script_id) const { return id_seg_map->lookupKey(script_id); } -Script *SegManager::getScript(const int seg) { +Script *SegManager::getScript(const SegmentId seg) { if (seg < 0 || (uint)seg >= _heap.size()) { error("SegManager::getScript(): seg id %x out of bounds", seg); } @@ -387,7 +381,7 @@ Script *SegManager::getScript(const int seg) { return (Script *)_heap[seg]; } -Script *SegManager::getScriptIfLoaded(const int seg) { +Script *SegManager::getScriptIfLoaded(const SegmentId seg) { if (seg < 0 || (uint)seg >= _heap.size() || !_heap[seg] || _heap[seg]->getType() != MEM_OBJ_SCRIPT) return 0; return (Script *)_heap[seg]; @@ -397,7 +391,7 @@ Script *SegManager::getScriptIfLoaded(const int seg) { // return: // false - invalid seg // true - valid seg -bool SegManager::check(int seg) { +bool SegManager::check(SegmentId seg) { if (seg < 0 || (uint)seg >= _heap.size()) { return false; } @@ -408,7 +402,7 @@ bool SegManager::check(int seg) { return true; } -bool SegManager::scriptIsLoaded(int seg) { +bool SegManager::scriptIsLoaded(SegmentId seg) { return getScriptIfLoaded(seg) != 0; } @@ -768,7 +762,7 @@ void SegManager::scriptInitialiseLocals(reg_t location) { } } -void SegManager::scriptRelocateExportsSci11(int seg) { +void SegManager::scriptRelocateExportsSci11(SegmentId seg) { Script *scr = getScript(seg); for (int i = 0; i < scr->exports_nr; i++) { /* We are forced to use an ugly heuristic here to distinguish function @@ -784,7 +778,7 @@ void SegManager::scriptRelocateExportsSci11(int seg) { } } -void SegManager::scriptInitialiseObjectsSci11(EngineState *s, int seg) { +void SegManager::scriptInitialiseObjectsSci11(EngineState *s, SegmentId seg) { Script *scr = getScript(seg); byte *seeker = scr->heap_start + 4 + READ_LE_UINT16(scr->heap_start + 2) * 2; @@ -875,7 +869,7 @@ SegmentId SegManager::allocateStringFrags() { return segid; } -uint16 SegManager::validateExportFunc(int pubfunct, int seg) { +uint16 SegManager::validateExportFunc(int pubfunct, SegmentId seg) { Script *scr = getScript(seg); if (scr->exports_nr <= pubfunct) { sciprintf("pubfunct is invalid"); diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h index c1d245c1c6..643385fd74 100644 --- a/engines/sci/engine/seg_manager.h +++ b/engines/sci/engine/seg_manager.h @@ -60,7 +60,7 @@ public: // script data // Returns : (int) 0 on failure, 1 on success // (int) *seg_id: The segment ID of the newly allocated segment, on success - Script *allocateScript(EngineState *s, int script_nr, int* seg_id); + Script *allocateScript(EngineState *s, int script_nr, SegmentId *seg_id); // The script must then be initialised; see section (1b.), below. @@ -73,19 +73,19 @@ public: * Determines whether a script has been loaded yet. * @param seg ID of the script segment to check for */ - bool scriptIsLoaded(int seg); + bool scriptIsLoaded(SegmentId seg); // Validate whether the specified public function is exported by the script in the specified segment // Parameters: (int) pubfunct: Index of the function to validate // (int) seg: Segment ID of the script the check is to be performed for // Returns : (uint16) 0 if the public function is invalid, its offset into the script's segment // otherwise - uint16 validateExportFunc(int pubfunct, int seg); + uint16 validateExportFunc(int pubfunct, SegmentId seg); // Get the segment ID associated with a script number // Parameters: (int) script_nr: Number of the script to look up // Returns : (int) The associated segment ID, or -1 if no matching segment exists - int segGet(int script_nr) const; + SegmentId segGet(int script_nr) const; /** * Return a pointer to the specified script. If the id is invalid, does not refer @@ -93,14 +93,14 @@ public: * @param seg ID of the script segment to check for * @return pointer to the Script object */ - Script *getScript(int seg); + Script *getScript(SegmentId seg); /** * Return a pointer to the specified script. If the id is invalid, does not refer * @param seg ID of the script segment to check for * @return pointer to the Script object, or NULL */ - Script *getScriptIfLoaded(int seg); + Script *getScriptIfLoaded(SegmentId seg); @@ -260,8 +260,8 @@ public: void heapRelocate(reg_t block); - void scriptRelocateExportsSci11(int seg); - void scriptInitialiseObjectsSci11(EngineState *s, int seg); + void scriptRelocateExportsSci11(SegmentId seg); + void scriptInitialiseObjectsSci11(EngineState *s, SegmentId seg); int initialiseScript(Script &scr, EngineState *s, int script_nr); private: @@ -272,11 +272,6 @@ public: // TODO: make private int exports_wide; bool isSci1_1; - int gc_mark_bits; - // For standard Mark&Sweep: - // 1 or 0, depending on what unreachable/freshly allocated - // memory is tagged as - SegmentId Clones_seg_id; // ID of the (a) clones segment SegmentId Lists_seg_id; // ID of the (a) list segment SegmentId Nodes_seg_id; // ID of the (a) node segment @@ -286,7 +281,7 @@ private: MemObject *allocNonscriptSegment(MemObjectType type, SegmentId *segid); LocalVariables *allocLocalsSegment(Script *scr, int count); MemObject *memObjAllocate(SegmentId segid, int hash_id, MemObjectType type); - int deallocate(int seg, bool recursive); + int deallocate(SegmentId seg, bool recursive); Hunk *alloc_Hunk(reg_t *); @@ -304,7 +299,7 @@ private: ** Returns : (bool) false if 'seg' is an invalid segment ** true if 'seg' is a valid segment */ - bool check(int seg); + bool check(SegmentId seg); void dbgPrint(const char* msg, void *i); // for debug only |