From 7030588e2208d14df275f871f272de068cff6335 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 4 Nov 2009 13:26:43 +0000 Subject: [PATCH] Removed the reference to EngineState from the SciGuiGfx class svn-id: r45664 --- engines/sci/gui/gui.cpp | 4 +-- engines/sci/gui/gui_gfx.cpp | 59 ++++++++++++++++++------------------- engines/sci/gui/gui_gfx.h | 9 +++--- engines/sci/gui32/gui32.cpp | 4 +-- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index 6f7ab143e71..992b66e5dd2 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -56,7 +56,7 @@ namespace Sci { SciGui::SciGui(EngineState *state, SciGuiScreen *screen, SciGuiPalette *palette, SciGuiCursor *cursor) : _s(state), _screen(screen), _palette(palette), _cursor(cursor) { - _gfx = new SciGuiGfx(_s, _screen, _palette); + _gfx = new SciGuiGfx(_s->resMan, _s->_segMan, _s->_kernel, _screen, _palette); _transitions = new SciGuiTransitions(this, _screen, _palette, _s->resMan->isVGA()); _animate = new SciGuiAnimate(_s, _gfx, _screen, _palette); _text = new SciGuiText(_s->resMan, _gfx, _screen); @@ -81,7 +81,7 @@ SciGui::~SciGui() { void SciGui::resetEngineState(EngineState *s) { _s = s; - _gfx->resetEngineState(s); + _gfx->resetSegMan(s->_segMan); _animate->resetEngineState(s); } diff --git a/engines/sci/gui/gui_gfx.cpp b/engines/sci/gui/gui_gfx.cpp index 1a73d54ebe4..e30e61107e4 100644 --- a/engines/sci/gui/gui_gfx.cpp +++ b/engines/sci/gui/gui_gfx.cpp @@ -40,8 +40,8 @@ namespace Sci { -SciGuiGfx::SciGuiGfx(EngineState *state, SciGuiScreen *screen, SciGuiPalette *palette) - : _s(state), _screen(screen), _palette(palette) { +SciGuiGfx::SciGuiGfx(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, SciGuiScreen *screen, SciGuiPalette *palette) + : _resMan(resMan), _segMan(segMan), _kernel(kernel), _screen(screen), _palette(palette) { } SciGuiGfx::~SciGuiGfx() { @@ -82,7 +82,7 @@ SciGuiView *SciGuiGfx::getView(GuiResourceId viewNum) { purgeCache(); if (!_cachedViews.contains(viewNum)) - _cachedViews[viewNum] = new SciGuiView(_s->resMan, _screen, _palette, viewNum); + _cachedViews[viewNum] = new SciGuiView(_resMan, _screen, _palette, viewNum); return _cachedViews[viewNum]; } @@ -280,8 +280,8 @@ GuiMemoryHandle SciGuiGfx::BitsSave(const Common::Rect &rect, byte screenMask) { // now actually ask _screen how much space it will need for saving size = _screen->bitsGetDataSize(workerRect, screenMask); - memoryId = kalloc(_s->_segMan, "SaveBits()", size); - memoryPtr = kmem(_s->_segMan, memoryId); + memoryId = kalloc(_segMan, "SaveBits()", size); + memoryPtr = kmem(_segMan, memoryId); _screen->bitsSave(workerRect, screenMask, memoryPtr); return memoryId; } @@ -290,7 +290,7 @@ void SciGuiGfx::BitsGetRect(GuiMemoryHandle memoryHandle, Common::Rect *destRect byte *memoryPtr = NULL; if (!memoryHandle.isNull()) { - memoryPtr = kmem(_s->_segMan, memoryHandle);; + memoryPtr = kmem(_segMan, memoryHandle);; if (memoryPtr) { _screen->bitsGetRect(memoryPtr, destRect); @@ -302,25 +302,25 @@ void SciGuiGfx::BitsRestore(GuiMemoryHandle memoryHandle) { byte *memoryPtr = NULL; if (!memoryHandle.isNull()) { - memoryPtr = kmem(_s->_segMan, memoryHandle);; + memoryPtr = kmem(_segMan, memoryHandle);; if (memoryPtr) { _screen->bitsRestore(memoryPtr); - kfree(_s->_segMan, memoryHandle); + kfree(_segMan, memoryHandle); } } } void SciGuiGfx::BitsFree(GuiMemoryHandle memoryHandle) { if (!memoryHandle.isNull()) { - kfree(_s->_segMan, memoryHandle); + kfree(_segMan, memoryHandle); } } void SciGuiGfx::drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, GuiResourceId paletteId) { SciGuiPicture *picture; - picture = new SciGuiPicture(_s->resMan, this, _screen, _palette, pictureId); + picture = new SciGuiPicture(_resMan, this, _screen, _palette, pictureId); // do we add to a picture? if not -> clear screen with white if (!addToFlag) { ClearScreen(_screen->_colorWhite); @@ -477,7 +477,7 @@ int16 SciGuiGfx::PriorityToCoordinate(byte priority) { bool SciGuiGfx::CanBeHereCheckRectList(reg_t checkObject, Common::Rect checkRect, List *list) { reg_t curAddress = list->first; - Node *curNode = _s->_segMan->lookupNode(curAddress); + Node *curNode = _segMan->lookupNode(curAddress); reg_t curObject; uint16 signal; Common::Rect curRect; @@ -485,12 +485,12 @@ bool SciGuiGfx::CanBeHereCheckRectList(reg_t checkObject, Common::Rect checkRect while (curNode) { curObject = curNode->value; if (curObject != checkObject) { - signal = GET_SEL32V(_s->_segMan, curObject, signal); + signal = GET_SEL32V(_segMan, curObject, signal); if ((signal & (kSignalIgnoreActor | kSignalRemoveView | kSignalNoUpdate)) == 0) { - curRect.left = GET_SEL32V(_s->_segMan, curObject, brLeft); - curRect.top = GET_SEL32V(_s->_segMan, curObject, brTop); - curRect.right = GET_SEL32V(_s->_segMan, curObject, brRight); - curRect.bottom = GET_SEL32V(_s->_segMan, curObject, brBottom); + curRect.left = GET_SEL32V(_segMan, curObject, brLeft); + curRect.top = GET_SEL32V(_segMan, curObject, brTop); + curRect.right = GET_SEL32V(_segMan, curObject, brRight); + curRect.bottom = GET_SEL32V(_segMan, curObject, brBottom); // Check if curRect is within checkRect if (curRect.right > checkRect.left && curRect.left < checkRect.right && curRect.bottom > checkRect.top && curRect.top < checkRect.bottom) { return false; @@ -498,7 +498,7 @@ bool SciGuiGfx::CanBeHereCheckRectList(reg_t checkObject, Common::Rect checkRect } } curAddress = curNode->succ; - curNode = _s->_segMan->lookupNode(curAddress); + curNode = _segMan->lookupNode(curAddress); } return true; } @@ -506,26 +506,25 @@ bool SciGuiGfx::CanBeHereCheckRectList(reg_t checkObject, Common::Rect checkRect void SciGuiGfx::SetNowSeen(reg_t objectReference) { SciGuiView *view = NULL; Common::Rect celRect(0, 0); - GuiResourceId viewId = (GuiResourceId)GET_SEL32V(_s->_segMan, objectReference, view); - GuiViewLoopNo loopNo = sign_extend_byte((GuiViewLoopNo)GET_SEL32V(_s->_segMan, objectReference, loop)); - GuiViewCelNo celNo = sign_extend_byte((GuiViewCelNo)GET_SEL32V(_s->_segMan, objectReference, cel)); - int16 x = (int16)GET_SEL32V(_s->_segMan, objectReference, x); - int16 y = (int16)GET_SEL32V(_s->_segMan, objectReference, y); + GuiResourceId viewId = (GuiResourceId)GET_SEL32V(_segMan, objectReference, view); + GuiViewLoopNo loopNo = sign_extend_byte((GuiViewLoopNo)GET_SEL32V(_segMan, objectReference, loop)); + GuiViewCelNo celNo = sign_extend_byte((GuiViewCelNo)GET_SEL32V(_segMan, objectReference, cel)); + int16 x = (int16)GET_SEL32V(_segMan, objectReference, x); + int16 y = (int16)GET_SEL32V(_segMan, objectReference, y); int16 z = 0; - if (_s->_kernel->_selectorCache.z > -1) { - z = (int16)GET_SEL32V(_s->_segMan, objectReference, z); - } + if (_kernel->_selectorCache.z > -1) + z = (int16)GET_SEL32V(_segMan, objectReference, z); // now get cel rectangle view = getView(viewId); view->getCelRect(loopNo, celNo, x, y, z, &celRect); // TODO: sometimes loop is negative. Check what it means - if (lookup_selector(_s->_segMan, objectReference, _s->_kernel->_selectorCache.nsTop, NULL, NULL) == kSelectorVariable) { - PUT_SEL32V(_s->_segMan, objectReference, nsLeft, celRect.left); - PUT_SEL32V(_s->_segMan, objectReference, nsRight, celRect.right); - PUT_SEL32V(_s->_segMan, objectReference, nsTop, celRect.top); - PUT_SEL32V(_s->_segMan, objectReference, nsBottom, celRect.bottom); + if (lookup_selector(_segMan, objectReference, _kernel->_selectorCache.nsTop, NULL, NULL) == kSelectorVariable) { + PUT_SEL32V(_segMan, objectReference, nsLeft, celRect.left); + PUT_SEL32V(_segMan, objectReference, nsRight, celRect.right); + PUT_SEL32V(_segMan, objectReference, nsTop, celRect.top); + PUT_SEL32V(_segMan, objectReference, nsBottom, celRect.bottom); } } diff --git a/engines/sci/gui/gui_gfx.h b/engines/sci/gui/gui_gfx.h index a5d1d35cee7..516fa5466d1 100644 --- a/engines/sci/gui/gui_gfx.h +++ b/engines/sci/gui/gui_gfx.h @@ -48,13 +48,12 @@ typedef Common::HashMap ViewCache; class SciGuiGfx { public: - SciGuiGfx(EngineState *state, SciGuiScreen *screen, SciGuiPalette *palette); + SciGuiGfx(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, SciGuiScreen *screen, SciGuiPalette *palette); ~SciGuiGfx(); void init(SciGuiText *text); - // FIXME: Don't store EngineState - void resetEngineState(EngineState *newState) { _s = newState; } + void resetSegMan(SegManager *segMan) { _segMan = segMan; } byte *GetSegment(byte seg); void ResetScreen(); @@ -111,7 +110,9 @@ public: private: void purgeCache(); - EngineState *_s; + ResourceManager *_resMan; + SegManager *_segMan; + Kernel *_kernel; SciGuiScreen *_screen; SciGuiPalette *_palette; SciGuiText *_text; diff --git a/engines/sci/gui32/gui32.cpp b/engines/sci/gui32/gui32.cpp index 41bb52ccdc1..4b67e16f1e6 100644 --- a/engines/sci/gui32/gui32.cpp +++ b/engines/sci/gui32/gui32.cpp @@ -392,7 +392,7 @@ SciGui32::SciGui32( EngineState *state, SciGuiScreen *screen, SciGuiPalette *pal _screen = screen; _palette = palette; _cursor = cursor; - _gfx = new SciGuiGfx(_s, _screen, _palette); + _gfx = new SciGuiGfx(_s->resMan, _s->_segMan, _s->_kernel, _screen, _palette); } SciGui32::~SciGui32() { @@ -408,7 +408,7 @@ void SciGui32::init(bool oldGfxFunctions) { void SciGui32::resetEngineState(EngineState *s) { _s = s; - _gfx->resetEngineState(s); + _gfx->resetSegMan(s->_segMan); } void SciGui32::wait(int16 ticks) {