[Scummvm-cvs-logs] SF.net SVN: scummvm:[45019] scummvm/trunk/engines/sci/gui

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Tue Oct 13 17:28:28 CEST 2009


Revision: 45019
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45019&view=rev
Author:   m_kiewitz
Date:     2009-10-13 15:28:27 +0000 (Tue, 13 Oct 2009)

Log Message:
-----------
SCI/newgui: SciGuiAnimate class created

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gui/gui.cpp
    scummvm/trunk/engines/sci/gui/gui.h
    scummvm/trunk/engines/sci/gui/gui_gfx.cpp
    scummvm/trunk/engines/sci/gui/gui_gfx.h
    scummvm/trunk/engines/sci/gui/gui_windowmgr.cpp
    scummvm/trunk/engines/sci/gui/gui_windowmgr.h

Added Paths:
-----------
    scummvm/trunk/engines/sci/gui/gui_animate.cpp
    scummvm/trunk/engines/sci/gui/gui_animate.h

Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-13 14:59:06 UTC (rev 45018)
+++ scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-13 15:28:27 UTC (rev 45019)
@@ -36,6 +36,7 @@
 #include "sci/gui/gui_cursor.h"
 #include "sci/gui/gui_gfx.h"
 #include "sci/gui/gui_windowmgr.h"
+#include "sci/gui/gui_animate.h"
 #include "sci/gui/gui_view.h"
 
 #include "sci/gfx/operations.h"
@@ -53,7 +54,8 @@
 	: _s(state), _screen(screen), _palette(palette), _cursor(cursor) {
 
 	_gfx = new SciGuiGfx(_s, _screen, _palette);
-	_windowMgr = new SciGuiWindowMgr(_screen, _gfx);
+	_animate = new SciGuiAnimate(_s, _gfx, _screen, _palette);
+	_windowMgr = new SciGuiWindowMgr(_screen, _gfx, _animate);
 // 	_gui32 = new SciGui32(_s, _screen, _palette, _cursor); // for debug purposes
 }
 
@@ -437,7 +439,7 @@
 }
 
 void SciGui::graphRedrawBox(Common::Rect rect) {
-	_gfx->ReAnimate(rect);
+	_animate->reAnimate(rect);
 }
 
 int16 SciGui::picNotValid(int16 newPicNotValid) {
@@ -496,7 +498,7 @@
 	byte old_picNotValid = _screen->_picNotValid;
 
 	if (listReference.isNull()) {
-		_gfx->AnimateDisposeLastCast();
+		_animate->disposeLastCast();
 		if (_screen->_picNotValid)
 			_gfx->ShowPic();
 		return;
@@ -507,28 +509,28 @@
 		error("kAnimate called with non-list as parameter");
 
 	if (cycle)
-		_gfx->AnimateInvoke(list, argc, argv);
+		_animate->invoke(list, argc, argv);
 
 	GuiPort *oldPort = _gfx->SetPort((GuiPort *)_windowMgr->_picWind);
-	_gfx->AnimateDisposeLastCast();
+	_animate->disposeLastCast();
 
-	_gfx->AnimateMakeSortedList(list);
-	_gfx->AnimateFill(old_picNotValid);
+	_animate->makeSortedList(list);
+	_animate->fill(old_picNotValid);
 
 	if (old_picNotValid) {
 		_windowMgr->BeginUpdate(_windowMgr->_picWind);
-		_gfx->AnimateUpdate();
+		_animate->update();
 		_windowMgr->EndUpdate(_windowMgr->_picWind);
 	}
 
-	_gfx->AnimateDrawCels();
+	_animate->drawCels();
 
 	if (_screen->_picNotValid) {
 		_gfx->ShowPic();
 	}
 
-	_gfx->AnimateUpdateScreen(old_picNotValid);
-	_gfx->AnimateRestoreAndDelete(argc, argv);
+	_animate->updateScreen(old_picNotValid);
+	_animate->restoreAndDelete(argc, argv);
 
 	_gfx->SetPort(oldPort);
 }
@@ -542,15 +544,15 @@
 	if (!list)
 		error("kAddToPic called with non-list as parameter");
 
-	_gfx->AnimateMakeSortedList(list);
-	_gfx->AddToPicDrawCels(list);
+	_animate->makeSortedList(list);
+	_animate->addToPicDrawCels(list);
 
 	_screen->_picNotValid = 2;
 }
 
 void SciGui::addToPicView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control) {
 	_gfx->SetPort((GuiPort *)_windowMgr->_picWind);
-	_gfx->AddToPicDrawView(viewId, loopNo, celNo, leftPos, topPos, priority, control);
+	_animate->addToPicDrawView(viewId, loopNo, celNo, leftPos, topPos, priority, control);
 }
 
 void SciGui::setNowSeen(reg_t objectReference) {

Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h	2009-10-13 14:59:06 UTC (rev 45018)
+++ scummvm/trunk/engines/sci/gui/gui.h	2009-10-13 15:28:27 UTC (rev 45019)
@@ -36,6 +36,7 @@
 class SciGuiGfx;
 class SciGuiresources;
 class SciGuiWindowMgr;
+class SciGuiAnimate;
 class SciGui32; // for debug purposes
 
 class SciGui {
@@ -121,6 +122,7 @@
 	SciGuiGfx *_gfx;
 	SciGuiresources *_resources;
 	SciGuiWindowMgr *_windowMgr;
+	SciGuiAnimate *_animate;
 
 // 	SciGui32 *_gui32; // for debug purposes
 };

Copied: scummvm/trunk/engines/sci/gui/gui_animate.cpp (from rev 45010, scummvm/trunk/engines/sci/gui/gui_gfx.cpp)
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_animate.cpp	                        (rev 0)
+++ scummvm/trunk/engines/sci/gui/gui_animate.cpp	2009-10-13 15:28:27 UTC (rev 45019)
@@ -0,0 +1,482 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/util.h"
+#include "common/stack.h"
+#include "graphics/primitives.h"
+
+#include "sci/sci.h"
+#include "sci/engine/state.h"
+#include "sci/tools.h"
+#include "sci/gui/gui_gfx.h"
+#include "sci/gui/gui_view.h"
+#include "sci/gui/gui_screen.h"
+#include "sci/gui/gui_animate.h"
+
+namespace Sci {
+
+SciGuiAnimate::SciGuiAnimate(EngineState *state, SciGuiGfx *gfx, SciGuiScreen *screen, SciGuiPalette *palette)
+	: _s(state), _gfx(gfx), _screen(screen), _palette(palette) {
+	init();
+}
+
+SciGuiAnimate::~SciGuiAnimate() {
+}
+
+void SciGuiAnimate::init() {
+	_listData = NULL;
+	_listSize = 0;
+}
+
+void SciGuiAnimate::disposeLastCast() {
+	// FIXME
+	//if (!_lastCast->first.isNull())
+		//_lastCast->DeleteList();
+}
+
+void SciGuiAnimate::invoke(List *list, int argc, reg_t *argv) {
+	SegManager *segMan = _s->_segMan;
+	reg_t curAddress = list->first;
+	Node *curNode = _s->_segMan->lookupNode(curAddress);
+	reg_t curObject;
+	uint16 signal;
+
+	while (curNode) {
+		curObject = curNode->value;
+		signal = GET_SEL32V(curObject, signal);
+		if (!(signal & SCI_ANIMATE_SIGNAL_FROZEN)) {
+			// Call .doit method of that object
+			invoke_selector(_s, curObject, _s->_kernel->_selectorCache.doit, kContinueOnInvalidSelector, argv, argc, __FILE__, __LINE__, 0);
+			// Lookup node again, since the nodetable it was in may have been reallocated
+			curNode = _s->_segMan->lookupNode(curAddress);
+		}
+		curAddress = curNode->succ;
+		curNode = _s->_segMan->lookupNode(curAddress);
+	}
+}
+
+bool sortHelper(const GuiAnimateEntry* entry1, const GuiAnimateEntry* entry2) {
+	return (entry1->y == entry2->y) ? (entry1->z < entry2->z) : (entry1->y < entry2->y);
+}
+
+void SciGuiAnimate::makeSortedList(List *list) {
+	SegManager *segMan = _s->_segMan;
+	reg_t curAddress = list->first;
+	Node *curNode = _s->_segMan->lookupNode(curAddress);
+	reg_t curObject;
+	GuiAnimateEntry *listEntry;
+	int16 listNr, listCount = 0;
+
+	// Count the list entries
+	while (curNode) {
+		listCount++;
+		curAddress = curNode->succ;
+		curNode = _s->_segMan->lookupNode(curAddress);
+	}
+
+	_list.clear();
+
+	// No entries -> exit immediately
+	if (listCount == 0)
+		return;
+
+	// Adjust list size, if needed
+	if ((_listData == NULL) || (_listSize < listCount)) {
+		if (_listData)
+			free(_listData);
+		_listData = (GuiAnimateEntry *)malloc(listCount * sizeof(GuiAnimateEntry));
+		if (!_listData)
+			error("Could not allocate memory for _animateList");
+		_listSize = listCount;
+	}
+
+	// Fill the list
+	curAddress = list->first;
+	curNode = _s->_segMan->lookupNode(curAddress);
+	listEntry = _listData;
+	for (listNr = 0; listNr < listCount; listNr++) {
+		curObject = curNode->value;
+		listEntry->object = curObject;
+
+		// Get data from current object
+		listEntry->viewId = GET_SEL32V(curObject, view);
+		listEntry->loopNo = GET_SEL32V(curObject, loop);
+		listEntry->celNo = GET_SEL32V(curObject, cel);
+		listEntry->paletteNo = GET_SEL32V(curObject, palette);
+		listEntry->x = GET_SEL32V(curObject, x);
+		listEntry->y = GET_SEL32V(curObject, y);
+		listEntry->z = GET_SEL32V(curObject, z);
+		listEntry->priority = GET_SEL32V(curObject, priority);
+		listEntry->signal = GET_SEL32V(curObject, signal);
+		// listEntry->celRect is filled in AnimateFill()
+		listEntry->showBitsFlag = false;
+
+		_list.push_back(listEntry);
+
+		listEntry++;
+		curAddress = curNode->succ;
+		curNode = _s->_segMan->lookupNode(curAddress);
+	}
+
+	// Now sort the list according y and z (descending)
+	GuiAnimateList::iterator listBegin = _list.begin();
+	GuiAnimateList::iterator listEnd = _list.end();
+
+	Common::sort(_list.begin(), _list.end(), sortHelper);
+}
+
+void SciGuiAnimate::fill(byte &old_picNotValid) {
+	SegManager *segMan = _s->_segMan;
+	reg_t curObject;
+	GuiAnimateEntry *listEntry;
+	uint16 signal;
+	SciGuiView *view = NULL;
+	GuiAnimateList::iterator listIterator;
+	GuiAnimateList::iterator listEnd = _list.end();
+
+	listIterator = _list.begin();
+	while (listIterator != listEnd) {
+		listEntry = *listIterator;
+		curObject = listEntry->object;
+
+		// Get the corresponding view
+		view = new SciGuiView(_s->resMan, _screen, _palette, listEntry->viewId);
+		
+		// adjust loop and cel, if any of those is invalid
+		if (listEntry->loopNo >= view->getLoopCount()) {
+			listEntry->loopNo = 0;
+			PUT_SEL32V(curObject, loop, listEntry->loopNo);
+		}
+		if (listEntry->celNo >= view->getCelCount(listEntry->loopNo)) {
+			listEntry->celNo = 0;
+			PUT_SEL32V(curObject, cel, listEntry->celNo);
+		}
+
+		// Create rect according to coordinates and given cel
+		view->getCelRect(listEntry->loopNo, listEntry->celNo, listEntry->x, listEntry->y, listEntry->z, &listEntry->celRect);
+		PUT_SEL32V(curObject, nsLeft, listEntry->celRect.left);
+		PUT_SEL32V(curObject, nsTop, listEntry->celRect.top);
+		PUT_SEL32V(curObject, nsRight, listEntry->celRect.right);
+		PUT_SEL32V(curObject, nsBottom, listEntry->celRect.bottom);
+
+		signal = listEntry->signal;
+
+		// Calculate current priority according to y-coordinate
+		if (!(signal & SCI_ANIMATE_SIGNAL_FIXEDPRIORITY)) {
+			listEntry->priority = _gfx->CoordinateToPriority(listEntry->y);
+			PUT_SEL32V(curObject, priority, listEntry->priority);
+		}
+		
+		if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) {
+			if (signal & (SCI_ANIMATE_SIGNAL_FORCEUPDATE | SCI_ANIMATE_SIGNAL_VIEWUPDATED)
+				|| (signal & SCI_ANIMATE_SIGNAL_HIDDEN && !(signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW))
+				|| (!(signal & SCI_ANIMATE_SIGNAL_HIDDEN) && signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW)
+				|| (signal & SCI_ANIMATE_SIGNAL_ALWAYSUPDATE))
+				old_picNotValid++;
+			signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_STOPUPDATE;
+		} else {
+			if (signal & SCI_ANIMATE_SIGNAL_STOPUPDATE || signal & SCI_ANIMATE_SIGNAL_ALWAYSUPDATE)
+				old_picNotValid++;
+			signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_FORCEUPDATE;
+		}
+		listEntry->signal = signal;
+
+		listIterator++;
+	}
+}
+
+void SciGuiAnimate::update() {
+	SegManager *segMan = _s->_segMan;
+	reg_t curObject;
+	GuiAnimateEntry *listEntry;
+	uint16 signal;
+	reg_t bitsHandle;
+	Common::Rect rect;
+	GuiAnimateList::iterator listIterator;
+	GuiAnimateList::iterator listBegin = _list.begin();
+	GuiAnimateList::iterator listEnd = _list.end();
+
+	// Remove all no-update cels, if requested
+	listIterator = _list.reverse_begin();
+	while (listIterator != listEnd) {
+		listEntry = *listIterator;
+		curObject = listEntry->object;
+		signal = listEntry->signal;
+
+		if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) {
+			if (!(signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW)) {
+				bitsHandle = GET_SEL32(curObject, underBits);
+				if (_screen->_picNotValid != 1) {
+					_gfx->BitsRestore(bitsHandle);
+					listEntry->showBitsFlag = true;
+				} else	{
+					_gfx->BitsFree(bitsHandle);
+				}
+				PUT_SEL32V(curObject, underBits, 0);
+			}
+			signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_FORCEUPDATE;
+			signal &= signal & SCI_ANIMATE_SIGNAL_VIEWUPDATED ? 0xFFFF ^ (SCI_ANIMATE_SIGNAL_VIEWUPDATED | SCI_ANIMATE_SIGNAL_NOUPDATE) : 0xFFFF;
+		} else if (signal & SCI_ANIMATE_SIGNAL_STOPUPDATE) {
+			signal =  (signal & (0xFFFF ^ SCI_ANIMATE_SIGNAL_STOPUPDATE)) | SCI_ANIMATE_SIGNAL_NOUPDATE;
+		}
+		listEntry->signal = signal;
+		listIterator--;
+	}
+
+	// Draw always-update cels
+	listIterator = listBegin;
+	while (listIterator != listEnd) {
+		listEntry = *listIterator;
+		curObject = listEntry->object;
+		signal = listEntry->signal;
+
+		if (signal & SCI_ANIMATE_SIGNAL_ALWAYSUPDATE) {
+			// draw corresponding cel
+			_gfx->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
+			listEntry->showBitsFlag = true;
+
+			signal &= 0xFFFF ^ (SCI_ANIMATE_SIGNAL_STOPUPDATE | SCI_ANIMATE_SIGNAL_VIEWUPDATED | SCI_ANIMATE_SIGNAL_NOUPDATE | SCI_ANIMATE_SIGNAL_FORCEUPDATE);
+			if ((signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
+				rect = listEntry->celRect;
+				rect.top = CLIP<int16>(_gfx->PriorityToCoordinate(listEntry->priority) - 1, rect.top, rect.bottom - 1);  
+				_gfx->FillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
+			}
+			listEntry->signal = signal;
+		}
+		listIterator++;
+	}
+
+	// Saving background for all NoUpdate-cels
+	listIterator = listBegin;
+	while (listIterator != listEnd) {
+		listEntry = *listIterator;
+		curObject = listEntry->object;
+		signal = listEntry->signal;
+
+		if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) {
+			if (signal & SCI_ANIMATE_SIGNAL_HIDDEN) {
+				signal |= SCI_ANIMATE_SIGNAL_REMOVEVIEW;
+			} else {
+				signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_REMOVEVIEW;
+				if (signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR)
+					bitsHandle = _gfx->BitsSave(listEntry->celRect, SCI_SCREEN_MASK_VISUAL|SCI_SCREEN_MASK_PRIORITY);
+				else
+					bitsHandle = _gfx->BitsSave(listEntry->celRect, SCI_SCREEN_MASK_ALL);
+				PUT_SEL32(curObject, underBits, bitsHandle);
+			}
+			listEntry->signal = signal;
+		}
+		listIterator++;
+	}
+
+	// Draw NoUpdate cels
+	listIterator = listBegin;
+	while (listIterator != listEnd) {
+		listEntry = *listIterator;
+		curObject = listEntry->object;
+		signal = listEntry->signal;
+
+		if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE && !(signal & SCI_ANIMATE_SIGNAL_HIDDEN)) {
+			// draw corresponding cel
+			_gfx->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
+			listEntry->showBitsFlag = true;
+
+			if ((signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
+				rect = listEntry->celRect;
+				rect.top = CLIP<int16>(_gfx->PriorityToCoordinate(listEntry->priority) - 1, rect.top, rect.bottom - 1);  
+				_gfx->FillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
+			}
+		}
+		listIterator++;
+	}
+}
+
+void SciGuiAnimate::drawCels() {
+	SegManager *segMan = _s->_segMan;
+	reg_t curObject;
+	GuiAnimateEntry *listEntry;
+	uint16 signal;
+	reg_t bitsHandle;
+	GuiAnimateList::iterator listIterator;
+	GuiAnimateList::iterator listEnd = _list.end();
+
+	listIterator = _list.begin();
+	while (listIterator != listEnd) {
+		listEntry = *listIterator;
+		curObject = listEntry->object;
+		signal = listEntry->signal;
+
+		if (!(signal & (SCI_ANIMATE_SIGNAL_NOUPDATE | SCI_ANIMATE_SIGNAL_HIDDEN | SCI_ANIMATE_SIGNAL_ALWAYSUPDATE))) {
+			// Save background
+			bitsHandle = _gfx->BitsSave(listEntry->celRect, SCI_SCREEN_MASK_ALL);
+			PUT_SEL32(curObject, underBits, bitsHandle);
+
+			// draw corresponding cel
+			_gfx->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
+			listEntry->showBitsFlag = true;
+
+			if (signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW) {
+				signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_REMOVEVIEW;
+			}
+			listEntry->signal = signal;
+			
+//			HEAPHANDLE hNewCast = heapNewPtr(sizeof(sciCast), kDataCast);
+//			sciCast *pNewCast = (sciCast *)heap2Ptr(hNewCast);
+//			pNewCast->view = view;
+//			pNewCast->loop = loop;
+//			pNewCast->cel = cel;
+//			pNewCast->z = z;
+//			pNewCast->pal = pal;
+//			pNewCast->hSaved = 0;
+//			pNewCast->rect = *rect;
+//			_lastCast->AddToEnd(hNewCast);
+		}
+		listIterator++;
+	}
+}
+
+void SciGuiAnimate::updateScreen(byte oldPicNotValid) {
+	GuiAnimateEntry *listEntry;
+	uint16 signal;
+	GuiAnimateList::iterator listIterator;
+	GuiAnimateList::iterator listEnd = _list.end();
+
+	listIterator = _list.begin();
+	while (listIterator != listEnd) {
+		listEntry = *listIterator;
+		signal = listEntry->signal;
+
+		if (listEntry->showBitsFlag || !(signal & (SCI_ANIMATE_SIGNAL_REMOVEVIEW | SCI_ANIMATE_SIGNAL_NOUPDATE) ||
+										(!(signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW) && (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) && oldPicNotValid))) {
+// TODO: code finish
+//			rect = (Common::Rect *)&cobj[_objOfs[7]];
+//			rect1 = (Common::Rect *)&cobj[_objOfs[8]];
+//
+//			Common::Rect ro(rect->left, rect->top, rect->right, rect->bottom);
+//			ro.clip(*rect1);
+//
+//			if (!ro.isEmpty()) {
+//				ro = *rect; 
+//				ro.extend(*rect1);
+//			} else {
+//				_gfx->ShowBits(*rect, _showMap);
+//			//	ro = *rect1;
+//			//}
+//			//*rect  = *rect1;
+//			_gfx->ShowBits(ro, _showMap);
+			if (signal & SCI_ANIMATE_SIGNAL_HIDDEN) {
+				listEntry->signal |= SCI_ANIMATE_SIGNAL_REMOVEVIEW;
+			}
+		}
+
+		listIterator++;
+	}
+	_screen->copyToScreen();
+}
+
+void SciGuiAnimate::restoreAndDelete(int argc, reg_t *argv) {
+	SegManager *segMan = _s->_segMan;
+	reg_t curObject;
+	GuiAnimateEntry *listEntry;
+	uint16 signal;
+	GuiAnimateList::iterator listIterator;
+	GuiAnimateList::iterator listEnd = _list.end();
+
+	listIterator = _list.reverse_begin();
+	while (listIterator != listEnd) {
+		listEntry = *listIterator;
+		curObject = listEntry->object;
+		signal = listEntry->signal;
+
+		// FIXME: this is supposed to go into the loop above (same method)
+		if (signal & SCI_ANIMATE_SIGNAL_HIDDEN) {
+			signal |= SCI_ANIMATE_SIGNAL_REMOVEVIEW;
+		}
+
+		if ((signal & (SCI_ANIMATE_SIGNAL_NOUPDATE | SCI_ANIMATE_SIGNAL_REMOVEVIEW)) == 0) {
+			_gfx->BitsRestore(GET_SEL32(curObject, underBits));
+			PUT_SEL32V(curObject, underBits, 0);
+		}
+
+		// Finally update signal
+		PUT_SEL32V(curObject, signal, signal);
+
+		if (signal & SCI_ANIMATE_SIGNAL_DISPOSEME) {
+			// Call .delete_ method of that object
+			invoke_selector(_s, curObject, _s->_kernel->_selectorCache.delete_, kContinueOnInvalidSelector, argv, argc, __FILE__, __LINE__, 0);
+		}
+		listIterator--;
+	}
+}
+
+void SciGuiAnimate::reAnimate(Common::Rect rect) {
+	// TODO: implement ReAnimate
+	_gfx->BitsShow(rect);
+}
+
+void SciGuiAnimate::addToPicDrawCels(List *list) {
+	reg_t curObject;
+	GuiAnimateEntry *listEntry;
+	SciGuiView *view = NULL;
+	GuiAnimateList::iterator listIterator;
+	GuiAnimateList::iterator listEnd = _list.end();
+
+	listIterator = _list.begin();
+	while (listIterator != listEnd) {
+		listEntry = *listIterator;
+		curObject = listEntry->object;
+
+		if (listEntry->priority == -1)
+			listEntry->priority = _gfx->CoordinateToPriority(listEntry->y);
+
+		// Get the corresponding view
+		view = new SciGuiView(_s->resMan, _screen, _palette, listEntry->viewId);
+
+		// Create rect according to coordinates and given cel
+		view->getCelRect(listEntry->loopNo, listEntry->celNo, listEntry->x, listEntry->y, listEntry->z, &listEntry->celRect);
+
+		// draw corresponding cel
+		_gfx->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
+		if ((listEntry->signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
+			listEntry->celRect.top = CLIP<int16>(_gfx->PriorityToCoordinate(listEntry->priority) - 1, listEntry->celRect.top, listEntry->celRect.bottom - 1);
+			_gfx->FillRect(listEntry->celRect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
+		}
+
+		listIterator++;
+	}
+}
+
+void SciGuiAnimate::addToPicDrawView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control) {
+	SciGuiView *view = NULL;
+	Common::Rect celRect;
+
+	view = new SciGuiView(_s->resMan, _screen, _palette, viewId);
+
+	// Create rect according to coordinates and given cel
+	view->getCelRect(loopNo, celNo, leftPos, topPos, priority, &celRect);
+	_gfx->drawCel(view, loopNo, celNo, celRect, priority, 0);
+}
+
+} // End of namespace Sci

Copied: scummvm/trunk/engines/sci/gui/gui_animate.h (from rev 45010, scummvm/trunk/engines/sci/gui/gui_gfx.h)
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_animate.h	                        (rev 0)
+++ scummvm/trunk/engines/sci/gui/gui_animate.h	2009-10-13 15:28:27 UTC (rev 45019)
@@ -0,0 +1,84 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef SCI_GUI_ANIMATE_H
+#define SCI_GUI_ANIMATE_H
+
+#include "sci/gui/gui_helpers.h"
+
+namespace Sci {
+
+#if 0
+enum {
+	SCI_ANIMATE_SIGNAL_STOPUPDATE    = 0x0001,
+	SCI_ANIMATE_SIGNAL_VIEWUPDATED   = 0x0002,
+	SCI_ANIMATE_SIGNAL_NOUPDATE      = 0x0004,
+	SCI_ANIMATE_SIGNAL_HIDDEN        = 0x0008,
+	SCI_ANIMATE_SIGNAL_FIXEDPRIORITY = 0x0010,
+	SCI_ANIMATE_SIGNAL_ALWAYSUPDATE  = 0x0020,
+	SCI_ANIMATE_SIGNAL_FORCEUPDATE   = 0x0040,
+	SCI_ANIMATE_SIGNAL_REMOVEVIEW    = 0x0080,
+	SCI_ANIMATE_SIGNAL_FROZEN        = 0x0100,
+	SCI_ANIMATE_SIGNAL_IGNOREACTOR   = 0x4000,
+	SCI_ANIMATE_SIGNAL_DISPOSEME     = 0x8000
+};
+#endif
+
+class SciGuiScreen;
+class SciGuiView;
+class SciGuiAnimate {
+public:
+	SciGuiAnimate(EngineState *state, SciGuiGfx *gfx, SciGuiScreen *screen, SciGuiPalette *palette);
+	~SciGuiAnimate();
+
+	void disposeLastCast();
+	void invoke(List *list, int argc, reg_t *argv);
+	void makeSortedList(List *list);
+	void fill(byte &oldPicNotValid);
+	void update();
+	void drawCels();
+	void updateScreen(byte oldPicNotValid);
+	void restoreAndDelete(int argc, reg_t *argv);
+	void reAnimate(Common::Rect rect);
+	void addToPicDrawCels(List *list);
+	void addToPicDrawView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control);
+
+private:
+	void init(void);
+
+	EngineState *_s;
+	SciGuiGfx *_gfx;
+	SciGuiScreen *_screen;
+	SciGuiPalette *_palette;
+
+	uint16 _listSize;
+	GuiAnimateEntry *_listData;
+	GuiAnimateList _list;
+	//List *_lastCast;
+};
+
+} // End of namespace Sci
+
+#endif

Modified: scummvm/trunk/engines/sci/gui/gui_gfx.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_gfx.cpp	2009-10-13 14:59:06 UTC (rev 45018)
+++ scummvm/trunk/engines/sci/gui/gui_gfx.cpp	2009-10-13 15:28:27 UTC (rev 45019)
@@ -56,9 +56,6 @@
 
 	_texteditCursorVisible = false;
 
-	_animateListData = NULL;
-	_animateListSize = 0;
-
 	// _mainPort is not known to windowmanager, that's okay according to sierra sci
 	//  its not even used currently in our engine
 	_mainPort = new GuiPort(0);
@@ -165,11 +162,11 @@
 	FillRect(rect, 1, _curPort->penClr, _curPort->backClr);
 	_curPort->penMode = oldpenmode;
 }
-//-----------------------------
+
 void SciGuiGfx::EraseRect(const Common::Rect &rect) {
 	FillRect(rect, 1, _curPort->backClr);
 }
-//-----------------------------
+
 void SciGuiGfx::PaintRect(const Common::Rect &rect) {
 	FillRect(rect, 1, _curPort->penClr);
 }
@@ -982,435 +979,6 @@
 	_screen->_picNotValid = 0;
 }
 
-void SciGuiGfx::AnimateDisposeLastCast() {
-	// FIXME
-	//if (!_lastCast->first.isNull())
-		//_lastCast->DeleteList();
-}
-
-void SciGuiGfx::AnimateInvoke(List *list, int argc, reg_t *argv) {
-	SegManager *segMan = _s->_segMan;
-	reg_t curAddress = list->first;
-	Node *curNode = _s->_segMan->lookupNode(curAddress);
-	reg_t curObject;
-	uint16 signal;
-
-	while (curNode) {
-		curObject = curNode->value;
-		signal = GET_SEL32V(curObject, signal);
-		if (!(signal & SCI_ANIMATE_SIGNAL_FROZEN)) {
-			// Call .doit method of that object
-			invoke_selector(_s, curObject, _s->_kernel->_selectorCache.doit, kContinueOnInvalidSelector, argv, argc, __FILE__, __LINE__, 0);
-			// Lookup node again, since the nodetable it was in may have been reallocated
-			curNode = _s->_segMan->lookupNode(curAddress);
-		}
-		curAddress = curNode->succ;
-		curNode = _s->_segMan->lookupNode(curAddress);
-	}
-}
-
-bool AnimateSortHelper(const GuiAnimateEntry* entry1, const GuiAnimateEntry* entry2) {
-	return (entry1->y == entry2->y) ? (entry1->z < entry2->z) : (entry1->y < entry2->y);
-}
-
-void SciGuiGfx::AnimateMakeSortedList(List *list) {
-	SegManager *segMan = _s->_segMan;
-	reg_t curAddress = list->first;
-	Node *curNode = _s->_segMan->lookupNode(curAddress);
-	reg_t curObject;
-	GuiAnimateEntry *listEntry;
-	int16 listNr, listCount = 0;
-
-	// Count the list entries
-	while (curNode) {
-		listCount++;
-		curAddress = curNode->succ;
-		curNode = _s->_segMan->lookupNode(curAddress);
-	}
-
-	_animateList.clear();
-
-	// No entries -> exit immediately
-	if (listCount == 0)
-		return;
-
-	// Adjust list size, if needed
-	if ((_animateListData == NULL) || (_animateListSize < listCount)) {
-		if (_animateListData)
-			free(_animateListData);
-		_animateListData = (GuiAnimateEntry *)malloc(listCount * sizeof(GuiAnimateEntry));
-		if (!_animateListData)
-			error("Could not allocate memory for _animateList");
-		_animateListSize = listCount;
-	}
-
-	// Fill the list
-	curAddress = list->first;
-	curNode = _s->_segMan->lookupNode(curAddress);
-	listEntry = _animateListData;
-	for (listNr = 0; listNr < listCount; listNr++) {
-		curObject = curNode->value;
-		listEntry->object = curObject;
-
-		// Get data from current object
-		listEntry->viewId = GET_SEL32V(curObject, view);
-		listEntry->loopNo = GET_SEL32V(curObject, loop);
-		listEntry->celNo = GET_SEL32V(curObject, cel);
-		listEntry->paletteNo = GET_SEL32V(curObject, palette);
-		listEntry->x = GET_SEL32V(curObject, x);
-		listEntry->y = GET_SEL32V(curObject, y);
-		listEntry->z = GET_SEL32V(curObject, z);
-		listEntry->priority = GET_SEL32V(curObject, priority);
-		listEntry->signal = GET_SEL32V(curObject, signal);
-		// listEntry->celRect is filled in AnimateFill()
-		listEntry->showBitsFlag = false;
-
-		_animateList.push_back(listEntry);
-
-		listEntry++;
-		curAddress = curNode->succ;
-		curNode = _s->_segMan->lookupNode(curAddress);
-	}
-
-	// Now sort the list according y and z (descending)
-	GuiAnimateList::iterator listBegin = _animateList.begin();
-	GuiAnimateList::iterator listEnd = _animateList.end();
-
-	Common::sort(_animateList.begin(), _animateList.end(), AnimateSortHelper);
-}
-
-void SciGuiGfx::AnimateFill(byte &old_picNotValid) {
-	SegManager *segMan = _s->_segMan;
-	reg_t curObject;
-	GuiAnimateEntry *listEntry;
-	uint16 signal;
-	SciGuiView *view = NULL;
-	GuiAnimateList::iterator listIterator;
-	GuiAnimateList::iterator listEnd = _animateList.end();
-
-	listIterator = _animateList.begin();
-	while (listIterator != listEnd) {
-		listEntry = *listIterator;
-		curObject = listEntry->object;
-
-		// Get the corresponding view
-		view = new SciGuiView(_s->resMan, _screen, _palette, listEntry->viewId);
-		
-		// adjust loop and cel, if any of those is invalid
-		if (listEntry->loopNo >= view->getLoopCount()) {
-			listEntry->loopNo = 0;
-			PUT_SEL32V(curObject, loop, listEntry->loopNo);
-		}
-		if (listEntry->celNo >= view->getCelCount(listEntry->loopNo)) {
-			listEntry->celNo = 0;
-			PUT_SEL32V(curObject, cel, listEntry->celNo);
-		}
-
-		// Create rect according to coordinates and given cel
-		view->getCelRect(listEntry->loopNo, listEntry->celNo, listEntry->x, listEntry->y, listEntry->z, &listEntry->celRect);
-		PUT_SEL32V(curObject, nsLeft, listEntry->celRect.left);
-		PUT_SEL32V(curObject, nsTop, listEntry->celRect.top);
-		PUT_SEL32V(curObject, nsRight, listEntry->celRect.right);
-		PUT_SEL32V(curObject, nsBottom, listEntry->celRect.bottom);
-
-		signal = listEntry->signal;
-
-		// Calculate current priority according to y-coordinate
-		if (!(signal & SCI_ANIMATE_SIGNAL_FIXEDPRIORITY)) {
-			listEntry->priority = CoordinateToPriority(listEntry->y);
-			PUT_SEL32V(curObject, priority, listEntry->priority);
-		}
-		
-		if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) {
-			if (signal & (SCI_ANIMATE_SIGNAL_FORCEUPDATE | SCI_ANIMATE_SIGNAL_VIEWUPDATED)
-				|| (signal & SCI_ANIMATE_SIGNAL_HIDDEN && !(signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW))
-				|| (!(signal & SCI_ANIMATE_SIGNAL_HIDDEN) && signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW)
-				|| (signal & SCI_ANIMATE_SIGNAL_ALWAYSUPDATE))
-				old_picNotValid++;
-			signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_STOPUPDATE;
-		} else {
-			if (signal & SCI_ANIMATE_SIGNAL_STOPUPDATE || signal & SCI_ANIMATE_SIGNAL_ALWAYSUPDATE)
-				old_picNotValid++;
-			signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_FORCEUPDATE;
-		}
-		listEntry->signal = signal;
-
-		listIterator++;
-	}
-}
-
-void SciGuiGfx::AnimateUpdate() {
-	SegManager *segMan = _s->_segMan;
-	reg_t curObject;
-	GuiAnimateEntry *listEntry;
-	uint16 signal;
-	reg_t bitsHandle;
-	Common::Rect rect;
-	GuiAnimateList::iterator listIterator;
-	GuiAnimateList::iterator listBegin = _animateList.begin();
-	GuiAnimateList::iterator listEnd = _animateList.end();
-
-	// Remove all no-update cels, if requested
-	listIterator = _animateList.reverse_begin();
-	while (listIterator != listEnd) {
-		listEntry = *listIterator;
-		curObject = listEntry->object;
-		signal = listEntry->signal;
-
-		if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) {
-			if (!(signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW)) {
-				bitsHandle = GET_SEL32(curObject, underBits);
-				if (_screen->_picNotValid != 1) {
-					BitsRestore(bitsHandle);
-					listEntry->showBitsFlag = true;
-				} else	{
-					BitsFree(bitsHandle);
-				}
-				PUT_SEL32V(curObject, underBits, 0);
-			}
-			signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_FORCEUPDATE;
-			signal &= signal & SCI_ANIMATE_SIGNAL_VIEWUPDATED ? 0xFFFF ^ (SCI_ANIMATE_SIGNAL_VIEWUPDATED | SCI_ANIMATE_SIGNAL_NOUPDATE) : 0xFFFF;
-		} else if (signal & SCI_ANIMATE_SIGNAL_STOPUPDATE) {
-			signal =  (signal & (0xFFFF ^ SCI_ANIMATE_SIGNAL_STOPUPDATE)) | SCI_ANIMATE_SIGNAL_NOUPDATE;
-		}
-		listEntry->signal = signal;
-		listIterator--;
-	}
-
-	// Draw always-update cels
-	listIterator = listBegin;
-	while (listIterator != listEnd) {
-		listEntry = *listIterator;
-		curObject = listEntry->object;
-		signal = listEntry->signal;
-
-		if (signal & SCI_ANIMATE_SIGNAL_ALWAYSUPDATE) {
-			// draw corresponding cel
-			drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
-			listEntry->showBitsFlag = true;
-
-			signal &= 0xFFFF ^ (SCI_ANIMATE_SIGNAL_STOPUPDATE | SCI_ANIMATE_SIGNAL_VIEWUPDATED | SCI_ANIMATE_SIGNAL_NOUPDATE | SCI_ANIMATE_SIGNAL_FORCEUPDATE);
-			if ((signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
-				rect = listEntry->celRect;
-				rect.top = CLIP<int16>(PriorityToCoordinate(listEntry->priority) - 1, rect.top, rect.bottom - 1);  
-				FillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
-			}
-			listEntry->signal = signal;
-		}
-		listIterator++;
-	}
-
-	// Saving background for all NoUpdate-cels
-	listIterator = listBegin;
-	while (listIterator != listEnd) {
-		listEntry = *listIterator;
-		curObject = listEntry->object;
-		signal = listEntry->signal;
-
-		if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) {
-			if (signal & SCI_ANIMATE_SIGNAL_HIDDEN) {
-				signal |= SCI_ANIMATE_SIGNAL_REMOVEVIEW;
-			} else {
-				signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_REMOVEVIEW;
-				if (signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR)
-					bitsHandle = BitsSave(listEntry->celRect, SCI_SCREEN_MASK_VISUAL|SCI_SCREEN_MASK_PRIORITY);
-				else
-					bitsHandle = BitsSave(listEntry->celRect, SCI_SCREEN_MASK_ALL);
-				PUT_SEL32(curObject, underBits, bitsHandle);
-			}
-			listEntry->signal = signal;
-		}
-		listIterator++;
-	}
-
-	// Draw NoUpdate cels
-	listIterator = listBegin;
-	while (listIterator != listEnd) {
-		listEntry = *listIterator;
-		curObject = listEntry->object;
-		signal = listEntry->signal;
-
-		if (signal & SCI_ANIMATE_SIGNAL_NOUPDATE && !(signal & SCI_ANIMATE_SIGNAL_HIDDEN)) {
-			// draw corresponding cel
-			drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
-			listEntry->showBitsFlag = true;
-
-			if ((signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
-				rect = listEntry->celRect;
-				rect.top = CLIP<int16>(PriorityToCoordinate(listEntry->priority) - 1, rect.top, rect.bottom - 1);  
-				FillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
-			}
-		}
-		listIterator++;
-	}
-}
-
-void SciGuiGfx::AnimateDrawCels() {
-	SegManager *segMan = _s->_segMan;
-	reg_t curObject;
-	GuiAnimateEntry *listEntry;
-	uint16 signal;
-	reg_t bitsHandle;
-	GuiAnimateList::iterator listIterator;
-	GuiAnimateList::iterator listEnd = _animateList.end();
-
-	listIterator = _animateList.begin();
-	while (listIterator != listEnd) {
-		listEntry = *listIterator;
-		curObject = listEntry->object;
-		signal = listEntry->signal;
-
-		if (!(signal & (SCI_ANIMATE_SIGNAL_NOUPDATE | SCI_ANIMATE_SIGNAL_HIDDEN | SCI_ANIMATE_SIGNAL_ALWAYSUPDATE))) {
-			// Save background
-			bitsHandle = BitsSave(listEntry->celRect, SCI_SCREEN_MASK_ALL);
-			PUT_SEL32(curObject, underBits, bitsHandle);
-
-			// draw corresponding cel
-			drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
-			listEntry->showBitsFlag = true;
-
-			if (signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW) {
-				signal &= 0xFFFF ^ SCI_ANIMATE_SIGNAL_REMOVEVIEW;
-			}
-			listEntry->signal = signal;
-			
-//			HEAPHANDLE hNewCast = heapNewPtr(sizeof(sciCast), kDataCast);
-//			sciCast *pNewCast = (sciCast *)heap2Ptr(hNewCast);
-//			pNewCast->view = view;
-//			pNewCast->loop = loop;
-//			pNewCast->cel = cel;
-//			pNewCast->z = z;
-//			pNewCast->pal = pal;
-//			pNewCast->hSaved = 0;
-//			pNewCast->rect = *rect;
-//			_lastCast->AddToEnd(hNewCast);
-		}
-		listIterator++;
-	}
-}
-
-void SciGuiGfx::AnimateUpdateScreen(byte oldPicNotValid) {
-	GuiAnimateEntry *listEntry;
-	uint16 signal;
-	GuiAnimateList::iterator listIterator;
-	GuiAnimateList::iterator listEnd = _animateList.end();
-
-	listIterator = _animateList.begin();
-	while (listIterator != listEnd) {
-		listEntry = *listIterator;
-		signal = listEntry->signal;
-
-		if (listEntry->showBitsFlag || !(signal & (SCI_ANIMATE_SIGNAL_REMOVEVIEW | SCI_ANIMATE_SIGNAL_NOUPDATE) ||
-										(!(signal & SCI_ANIMATE_SIGNAL_REMOVEVIEW) && (signal & SCI_ANIMATE_SIGNAL_NOUPDATE) && oldPicNotValid))) {
-// TODO: code finish
-//			rect = (Common::Rect *)&cobj[_objOfs[7]];
-//			rect1 = (Common::Rect *)&cobj[_objOfs[8]];
-//
-//			Common::Rect ro(rect->left, rect->top, rect->right, rect->bottom);
-//			ro.clip(*rect1);
-//
-//			if (!ro.isEmpty()) {
-//				ro = *rect; 
-//				ro.extend(*rect1);
-//			} else {
-//				_gfx->ShowBits(*rect, _showMap);
-//			//	ro = *rect1;
-//			//}
-//			//*rect  = *rect1;
-//			_gfx->ShowBits(ro, _showMap);
-			if (signal & SCI_ANIMATE_SIGNAL_HIDDEN) {
-				listEntry->signal |= SCI_ANIMATE_SIGNAL_REMOVEVIEW;
-			}
-		}
-
-		listIterator++;
-	}
-	_screen->copyToScreen();
-}
-
-void SciGuiGfx::AnimateRestoreAndDelete(int argc, reg_t *argv) {
-	SegManager *segMan = _s->_segMan;
-	reg_t curObject;
-	GuiAnimateEntry *listEntry;
-	uint16 signal;
-	GuiAnimateList::iterator listIterator;
-	GuiAnimateList::iterator listEnd = _animateList.end();
-
-	listIterator = _animateList.reverse_begin();
-	while (listIterator != listEnd) {
-		listEntry = *listIterator;
-		curObject = listEntry->object;
-		signal = listEntry->signal;
-
-		// FIXME: this is supposed to go into the loop above (same method)
-		if (signal & SCI_ANIMATE_SIGNAL_HIDDEN) {
-			signal |= SCI_ANIMATE_SIGNAL_REMOVEVIEW;
-		}
-
-		if ((signal & (SCI_ANIMATE_SIGNAL_NOUPDATE | SCI_ANIMATE_SIGNAL_REMOVEVIEW)) == 0) {
-			BitsRestore(GET_SEL32(curObject, underBits));
-			PUT_SEL32V(curObject, underBits, 0);
-		}
-
-		// Finally update signal
-		PUT_SEL32V(curObject, signal, signal);
-
-		if (signal & SCI_ANIMATE_SIGNAL_DISPOSEME) {
-			// Call .delete_ method of that object
-			invoke_selector(_s, curObject, _s->_kernel->_selectorCache.delete_, kContinueOnInvalidSelector, argv, argc, __FILE__, __LINE__, 0);
-		}
-		listIterator--;
-	}
-}
-
-void SciGuiGfx::ReAnimate(Common::Rect rect) {
-	// TODO: implement ReAnimate
-	BitsShow(rect);
-}
-
-void SciGuiGfx::AddToPicDrawCels(List *list) {
-	reg_t curObject;
-	GuiAnimateEntry *listEntry;
-	SciGuiView *view = NULL;
-	GuiAnimateList::iterator listIterator;
-	GuiAnimateList::iterator listEnd = _animateList.end();
-
-	listIterator = _animateList.begin();
-	while (listIterator != listEnd) {
-		listEntry = *listIterator;
-		curObject = listEntry->object;
-
-		if (listEntry->priority == -1)
-			listEntry->priority = CoordinateToPriority(listEntry->y);
-
-		// Get the corresponding view
-		view = new SciGuiView(_s->resMan, _screen, _palette, listEntry->viewId);
-
-		// Create rect according to coordinates and given cel
-		view->getCelRect(listEntry->loopNo, listEntry->celNo, listEntry->x, listEntry->y, listEntry->z, &listEntry->celRect);
-
-		// draw corresponding cel
-		drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
-		if ((listEntry->signal & SCI_ANIMATE_SIGNAL_IGNOREACTOR) == 0) {
-			listEntry->celRect.top = CLIP<int16>(PriorityToCoordinate(listEntry->priority) - 1, listEntry->celRect.top, listEntry->celRect.bottom - 1);
-			FillRect(listEntry->celRect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
-		}
-
-		listIterator++;
-	}
-}
-
-void SciGuiGfx::AddToPicDrawView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control) {
-	SciGuiView *view = NULL;
-	Common::Rect celRect;
-
-	view = new SciGuiView(_s->resMan, _screen, _palette, viewId);
-
-	// Create rect according to coordinates and given cel
-	view->getCelRect(loopNo, celNo, leftPos, topPos, priority, &celRect);
-	drawCel(view, loopNo, celNo, celRect, priority, 0);
-}
-
 bool SciGuiGfx::CanBeHereCheckRectList(reg_t checkObject, Common::Rect checkRect, List *list) {
 	SegManager *segMan = _s->_segMan;
 	reg_t curAddress = list->first;

Modified: scummvm/trunk/engines/sci/gui/gui_gfx.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_gfx.h	2009-10-13 14:59:06 UTC (rev 45018)
+++ scummvm/trunk/engines/sci/gui/gui_gfx.h	2009-10-13 15:28:27 UTC (rev 45019)
@@ -127,17 +127,6 @@
 
 	void ShowPic();
 
-	void AnimateDisposeLastCast();
-	void AnimateInvoke(List *list, int argc, reg_t *argv);
-	void AnimateMakeSortedList(List *list);
-	void AnimateFill(byte &oldPicNotValid);
-	void AnimateUpdate();
-	void AnimateDrawCels();
-	void AnimateUpdateScreen(byte oldPicNotValid);
-	void AnimateRestoreAndDelete(int argc, reg_t *argv);
-	void ReAnimate(Common::Rect rect);
-	void AddToPicDrawCels(List *list);
-	void AddToPicDrawView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control);
 	bool CanBeHereCheckRectList(reg_t checkObject, Common::Rect checkRect, List *list);
 
 	void SetNowSeen(reg_t objectReference);
@@ -177,12 +166,6 @@
 	bool _texteditCursorVisible;
 	uint32 _texteditBlinkTime;
 
-	// Animate* related variables
-	uint16 _animateListSize;
-	GuiAnimateEntry *_animateListData;
-	GuiAnimateList _animateList;
-	//List *_lastCast;
-
 	SciGuiFont *_font;
 };
 

Modified: scummvm/trunk/engines/sci/gui/gui_windowmgr.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_windowmgr.cpp	2009-10-13 14:59:06 UTC (rev 45018)
+++ scummvm/trunk/engines/sci/gui/gui_windowmgr.cpp	2009-10-13 15:28:27 UTC (rev 45019)
@@ -30,6 +30,7 @@
 #include "sci/tools.h"
 #include "sci/gui/gui_screen.h"
 #include "sci/gui/gui_gfx.h"
+#include "sci/gui/gui_animate.h"
 #include "sci/gui/gui_windowmgr.h"
 
 namespace Sci {
@@ -43,8 +44,8 @@
 	SCI_WINDOWMGR_STYLE_USER        = (1 << 7)
 };
 
-SciGuiWindowMgr::SciGuiWindowMgr(SciGuiScreen *screen, SciGuiGfx *gfx)
-	: _screen(screen), _gfx(gfx) {
+SciGuiWindowMgr::SciGuiWindowMgr(SciGuiScreen *screen, SciGuiGfx *gfx, SciGuiAnimate *animate)
+	: _screen(screen), _gfx(gfx), _animate(animate) {
 
 	_wmgrPort = new GuiPort(1);
 	_windowsById.resize(2);
@@ -250,7 +251,7 @@
 	if (arg2)
 		_gfx->BitsShow(pWnd->restoreRect);
 	else
-		_gfx->ReAnimate(pWnd->restoreRect);
+		_animate->reAnimate(pWnd->restoreRect);
 	_windowList.remove(pWnd);
 	_gfx->SetPort(_windowList.back());
 	_windowsById[pWnd->id] = 0;

Modified: scummvm/trunk/engines/sci/gui/gui_windowmgr.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_windowmgr.h	2009-10-13 14:59:06 UTC (rev 45018)
+++ scummvm/trunk/engines/sci/gui/gui_windowmgr.h	2009-10-13 15:28:27 UTC (rev 45019)
@@ -33,7 +33,7 @@
 
 class SciGuiWindowMgr {
 public:
-	SciGuiWindowMgr(SciGuiScreen *screen, SciGuiGfx *gfx);
+	SciGuiWindowMgr(SciGuiScreen *screen, SciGuiGfx *gfx, SciGuiAnimate *animate);
 	~SciGuiWindowMgr();
 
 	int16 isFrontWindow(GuiWindow *wnd);
@@ -54,6 +54,7 @@
 
 	SciGuiScreen *_screen;
 	SciGuiGfx *_gfx;
+	SciGuiAnimate *_animate;
 
 	/** The list of open 'windows' (and ports), in visual order. */
 	PortList _windowList;


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