diff options
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/gc.cpp | 47 | ||||
-rw-r--r-- | engines/sci/engine/gc.h | 9 | ||||
-rw-r--r-- | engines/sci/graphics/ports.cpp | 11 | ||||
-rw-r--r-- | engines/sci/graphics/ports.h | 4 |
4 files changed, 38 insertions, 33 deletions
diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp index d205763051..e395eeab94 100644 --- a/engines/sci/engine/gc.cpp +++ b/engines/sci/engine/gc.cpp @@ -49,28 +49,23 @@ const char *segmentTypeNames[] = { }; #endif -struct WorklistManager { - Common::Array<reg_t> _worklist; - AddrSet _map; // used for 2 contains() calls, inside push() and run_gc() +void WorklistManager::push(reg_t reg) { + if (!reg.segment) // No numbers + return; - void push(reg_t reg) { - if (!reg.segment) // No numbers - return; + debugC(kDebugLevelGC, "[GC] Adding %04x:%04x", PRINT_REG(reg)); - debugC(kDebugLevelGC, "[GC] Adding %04x:%04x", PRINT_REG(reg)); + if (_map.contains(reg)) + return; // already dealt with it - if (_map.contains(reg)) - return; // already dealt with it - - _map.setVal(reg, true); - _worklist.push_back(reg); - } + _map.setVal(reg, true); + _worklist.push_back(reg); +} - void pushArray(const Common::Array<reg_t> &tmp) { - for (Common::Array<reg_t>::const_iterator it = tmp.begin(); it != tmp.end(); ++it) - push(*it); - } -}; +void WorklistManager::pushArray(const Common::Array<reg_t> &tmp) { + for (Common::Array<reg_t>::const_iterator it = tmp.begin(); it != tmp.end(); ++it) + push(*it); +} static AddrSet *normalizeAddresses(SegManager *segMan, const AddrSet &nonnormal_map) { AddrSet *normal_map = new AddrSet(); @@ -103,18 +98,6 @@ static void processWorkList(SegManager *segMan, WorklistManager &wm, const Commo } } -static void processEngineHunkList(WorklistManager &wm) { - PortList windowList = g_sci->_gfxPorts->_windowList; - - for (PortList::const_iterator it = windowList.begin(); it != windowList.end(); ++it) { - if ((*it)->isWindow()) { - Window *wnd = ((Window *)*it); - wm.push(wnd->hSaved1); - wm.push(wnd->hSaved2); - } - } -} - AddrSet *findAllActiveReferences(EngineState *s) { assert(!s->_executionStack.empty()); @@ -174,8 +157,8 @@ AddrSet *findAllActiveReferences(EngineState *s) { processWorkList(s->_segMan, wm, heap); - if (getSciVersion() <= SCI_VERSION_1_1) - processEngineHunkList(wm); + if (g_sci->_gfxPorts) + g_sci->_gfxPorts->processEngineHunkList(wm); return normalizeAddresses(s->_segMan, wm._map); } diff --git a/engines/sci/engine/gc.h b/engines/sci/engine/gc.h index f4318a1453..48e1c6b482 100644 --- a/engines/sci/engine/gc.h +++ b/engines/sci/engine/gc.h @@ -58,6 +58,15 @@ AddrSet *findAllActiveReferences(EngineState *s); */ void run_gc(EngineState *s); +struct WorklistManager { + Common::Array<reg_t> _worklist; + AddrSet _map; // used for 2 contains() calls, inside push() and run_gc() + + void push(reg_t reg); + void pushArray(const Common::Array<reg_t> &tmp); +}; + + } // End of namespace Sci #endif // SCI_ENGINE_GC_H diff --git a/engines/sci/graphics/ports.cpp b/engines/sci/graphics/ports.cpp index aca278fe4a..cc206bd5b9 100644 --- a/engines/sci/graphics/ports.cpp +++ b/engines/sci/graphics/ports.cpp @@ -28,6 +28,7 @@ #include "sci/console.h" #include "sci/sci.h" #include "sci/engine/features.h" +#include "sci/engine/gc.h" #include "sci/engine/kernel.h" #include "sci/engine/state.h" #include "sci/engine/selector.h" @@ -708,6 +709,16 @@ int16 GfxPorts::kernelPriorityToCoordinate(byte priority) { return _priorityBottom; } +void GfxPorts::processEngineHunkList(WorklistManager &wm) { + for (PortList::const_iterator it = _windowList.begin(); it != _windowList.end(); ++it) { + if ((*it)->isWindow()) { + Window *wnd = ((Window *)*it); + wm.push(wnd->hSaved1); + wm.push(wnd->hSaved2); + } + } +} + void GfxPorts::printWindowList(Console *con) { for (PortList::const_iterator it = _windowList.begin(); it != _windowList.end(); ++it) { if ((*it)->isWindow()) { diff --git a/engines/sci/graphics/ports.h b/engines/sci/graphics/ports.h index d14272791f..31ed671daf 100644 --- a/engines/sci/graphics/ports.h +++ b/engines/sci/graphics/ports.h @@ -35,6 +35,7 @@ namespace Sci { class GfxPaint16; class GfxScreen; class GfxText16; +struct WorklistManager; // window styles enum { @@ -102,6 +103,7 @@ public: void kernelGraphAdjustPriority(int top, int bottom); byte kernelCoordinateToPriority(int16 y); int16 kernelPriorityToCoordinate(byte priority); + void processEngineHunkList(WorklistManager &wm); void printWindowList(Console *con); Port *_wmgrPort; @@ -115,10 +117,10 @@ public: virtual void saveLoadWithSerializer(Common::Serializer &ser); +private: /** The list of open 'windows' (and ports), in visual order. */ PortList _windowList; -private: /** The list of all open 'windows' (and ports), ordered by their id. */ PortArray _windowsById; |