diff options
author | Max Horn | 2010-02-03 01:32:59 +0000 |
---|---|---|
committer | Max Horn | 2010-02-03 01:32:59 +0000 |
commit | bb5e34a014c0ae868de86fcea484bc9671ce18b9 (patch) | |
tree | 09bb25253478180fd6069a21789f75fe8104a98c /engines | |
parent | b2d69649f7e4c484dcf3810e11cd644699b78d2c (diff) | |
download | scummvm-rg350-bb5e34a014c0ae868de86fcea484bc9671ce18b9.tar.gz scummvm-rg350-bb5e34a014c0ae868de86fcea484bc9671ce18b9.tar.bz2 scummvm-rg350-bb5e34a014c0ae868de86fcea484bc9671ce18b9.zip |
SCI: Get rid of EngineState::stack_segment
svn-id: r47833
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/game.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/gc.cpp | 3 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 1 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 22 | ||||
-rw-r--r-- | engines/sci/engine/state.cpp | 1 | ||||
-rw-r--r-- | engines/sci/engine/state.h | 1 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 2 |
7 files changed, 16 insertions, 16 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 9572fb89c5..9baa9f7c6e 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -239,7 +239,7 @@ int game_init(EngineState *s) { // FIXME Use new VM instantiation code all over the place DataStack *stack; - stack = s->_segMan->allocateStack(VM_STACK_SIZE, &s->stack_segment); + stack = s->_segMan->allocateStack(VM_STACK_SIZE, NULL); s->stack_base = stack->_entries; s->stack_top = stack->_entries + stack->_capacity; diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp index b3fbabdb06..bcc3ba34f6 100644 --- a/engines/sci/engine/gc.cpp +++ b/engines/sci/engine/gc.cpp @@ -130,10 +130,11 @@ reg_t_hash_map *find_all_used_references(EngineState *s) { debugC(2, kDebugLevelGC, "[GC] -- Finished explicitly loaded scripts, done with root set"); // Run Worklist Algorithm + SegmentId stack_seg = segMan->findSegmentByType(SEG_TYPE_STACK); while (!wm._worklist.empty()) { reg_t reg = wm._worklist.back(); wm._worklist.pop_back(); - if (reg.segment != s->stack_segment) { // No need to repeat this one + if (reg.segment != stack_seg) { // No need to repeat this one debugC(2, kDebugLevelGC, "[GC] Checking %04x:%04x", PRINT_REG(reg)); if (reg.segment < segMan->_heap.size() && segMan->_heap[reg.segment]) segMan->_heap[reg.segment]->listAllOutgoingReferences(reg, &wm, add_outgoing_refs); diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index e8253bb93b..ab7f19d423 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -765,7 +765,6 @@ static void reconstruct_stack(EngineState *retval) { SegmentId stack_seg = retval->_segMan->findSegmentByType(SEG_TYPE_STACK); DataStack *stack = (DataStack *)(retval->_segMan->_heap[stack_seg]); - retval->stack_segment = stack_seg; retval->stack_base = stack->_entries; retval->stack_top = stack->_entries + stack->_capacity; } diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 15de668610..430a58fb1f 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -113,34 +113,36 @@ SegmentId SegManager::findFreeSegment() const { SegmentObj *SegManager::allocSegment(SegmentObj *mem, SegmentId *segid) { // Find a free segment - *segid = findFreeSegment(); + SegmentId id = findFreeSegment(); + if (segid) + *segid = id; if (!mem) error("SegManager: invalid mobj"); // ... and put it into the (formerly) free segment. - if (*segid >= (int)_heap.size()) { - assert(*segid == (int)_heap.size()); + if (id >= (int)_heap.size()) { + assert(id == (int)_heap.size()); _heap.push_back(0); } - _heap[*segid] = mem; + _heap[id] = mem; return mem; } -Script *SegManager::allocateScript(int script_nr, SegmentId *seg_id) { +Script *SegManager::allocateScript(int script_nr, SegmentId *segid) { // Check if the script already has an allocated segment. If it // does, return that segment. - *seg_id = _scriptSegMap.getVal(script_nr, 0); - if (*seg_id > 0) { - return (Script *)_heap[*seg_id]; + *segid = _scriptSegMap.getVal(script_nr, 0); + if (*segid > 0) { + return (Script *)_heap[*segid]; } // allocate the SegmentObj - SegmentObj *mem = allocSegment(new Script(), seg_id); + SegmentObj *mem = allocSegment(new Script(), segid); // Add the script to the "script id -> segment id" hashmap - _scriptSegMap[script_nr] = *seg_id; + _scriptSegMap[script_nr] = *segid; return (Script *)mem; } diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index 7eff388df1..dbbbb9d499 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -53,7 +53,6 @@ EngineState::EngineState(ResourceManager *res, Kernel *kernel, Vocabulary *voc, restAdjust = 0; r_prev = NULL_REG; - stack_segment = 0; stack_base = 0; stack_top = 0; diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index a4232f27b7..a956fd9563 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -205,7 +205,6 @@ public: int16 restAdjust; /**< &rest register (only used for save games) */ reg_t r_prev; /**< previous comparison result */ - SegmentId stack_segment; /**< Heap area for the stack to use */ StackPtr stack_base; /**< Pointer to the least stack element */ StackPtr stack_top; /**< First invalid stack element */ diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index ce9e2b8f02..d26405069b 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -568,7 +568,7 @@ void run_vm(EngineState *s, int restoring) { #endif scriptState.variables_seg[VAR_GLOBAL] = s->script_000->_localsSegment; - scriptState.variables_seg[VAR_TEMP] = scriptState.variables_seg[VAR_PARAM] = s->stack_segment; + scriptState.variables_seg[VAR_TEMP] = scriptState.variables_seg[VAR_PARAM] = s->_segMan->findSegmentByType(SEG_TYPE_STACK); scriptState.variables_base[VAR_TEMP] = scriptState.variables_base[VAR_PARAM] = s->stack_base; // SCI code reads the zeroth argument to determine argc |