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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Fri Oct 30 10:26:16 CET 2009


Revision: 45527
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45527&view=rev
Author:   m_kiewitz
Date:     2009-10-30 09:26:14 +0000 (Fri, 30 Oct 2009)

Log Message:
-----------
SCI/newgui: Reanimate implemented

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

Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-30 08:22:53 UTC (rev 45526)
+++ scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-30 09:26:14 UTC (rev 45527)
@@ -59,7 +59,7 @@
 	_transitions = new SciGuiTransitions(this, _screen, _palette, _s->resMan->isVGA());
 	_animate = new SciGuiAnimate(_s, _gfx, _screen, _palette);
 	_text = new SciGuiText(_s->resMan, _gfx, _screen);
-	_windowMgr = new SciGuiWindowMgr(_screen, _gfx, _animate, _text);
+	_windowMgr = new SciGuiWindowMgr(this, _screen, _gfx, _text);
 	_controls = new SciGuiControls(_s->_segMan, _gfx, _text);
 //  	_gui32 = new SciGui32(_s, _screen, _palette, _cursor); // for debug purposes
 }
@@ -232,7 +232,7 @@
 			_gfx->BitsGetRect(argv[0], &rect);
 			rect.translate(-_gfx->GetPort()->left, -_gfx->GetPort()->top);
 			_gfx->BitsRestore(argv[0]);
-			_animate->reAnimate(rect);
+			graphRedrawBox(rect);
 			// finishing loop
 			argc = 0;
 			break;
@@ -452,7 +452,15 @@
 }
 
 void SciGui::graphRedrawBox(Common::Rect rect) {
+	localToGlobal(&rect.left, &rect.top);
+	localToGlobal(&rect.right, &rect.bottom);
+	GuiPort *oldPort = _gfx->SetPort((GuiPort *)_windowMgr->_picWind);
+	globalToLocal(&rect.left, &rect.top);
+	globalToLocal(&rect.right, &rect.bottom);
+
 	_animate->reAnimate(rect);
+
+	_gfx->SetPort(oldPort);
 }
 
 int16 SciGui::picNotValid(int16 newPicNotValid) {

Modified: scummvm/trunk/engines/sci/gui/gui_animate.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_animate.cpp	2009-10-30 08:22:53 UTC (rev 45526)
+++ scummvm/trunk/engines/sci/gui/gui_animate.cpp	2009-10-30 09:26:14 UTC (rev 45527)
@@ -44,11 +44,17 @@
 }
 
 SciGuiAnimate::~SciGuiAnimate() {
+	if (_listData)
+		free(_listData);
+	if (_lastCastData)
+		free(_lastCastData);
 }
 
 void SciGuiAnimate::init() {
 	_listData = NULL;
-	_listSize = 0;
+	_listCount = 0;
+	_lastCastData = NULL;
+	_lastCastCount = 0;
 
 	_ignoreFastCast = false;
 	// fastCast object is not found in any SCI games prior SCI1
@@ -61,9 +67,7 @@
 }
 
 void SciGuiAnimate::disposeLastCast() {
-	// FIXME
-	//if (!_lastCast->first.isNull())
-		//_lastCast->DeleteList();
+	_lastCastCount = 0;
 }
 
 bool SciGuiAnimate::invoke(List *list, int argc, reg_t *argv) {
@@ -126,13 +130,20 @@
 		return;
 
 	// Adjust list size, if needed
-	if ((_listData == NULL) || (_listSize < listCount)) {
+	if ((_listData == NULL) || (_listCount < listCount)) {
 		if (_listData)
 			free(_listData);
 		_listData = (GuiAnimateEntry *)malloc(listCount * sizeof(GuiAnimateEntry));
 		if (!_listData)
-			error("Could not allocate memory for _animateList");
-		_listSize = listCount;
+			error("Could not allocate memory for _listData");
+		_listCount = listCount;
+
+		if (_lastCastData)
+			free(_lastCastData);
+		_lastCastData = (GuiAnimateEntry *)malloc(listCount * sizeof(GuiAnimateEntry));
+		if (!_lastCastData)
+			error("Could not allocate memory for _lastCastData");
+		_lastCastCount = 0;
 	}
 
 	// Fill the list
@@ -342,11 +353,14 @@
 	SegManager *segMan = _s->_segMan;
 	reg_t curObject;
 	GuiAnimateEntry *listEntry;
+	GuiAnimateEntry *lastCastEntry = _lastCastData;
 	uint16 signal;
 	reg_t bitsHandle;
 	GuiAnimateList::iterator listIterator;
 	GuiAnimateList::iterator listEnd = _list.end();
 
+	_lastCastCount = 0;
+
 	listIterator = _list.begin();
 	while (listIterator != listEnd) {
 		listEntry = *listIterator;
@@ -366,17 +380,10 @@
 				signal &= 0xFFFF ^ kSignalRemoveView;
 			}
 			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);
+
+			// Remember that entry in lastCast
+			memcpy(lastCastEntry, listEntry, sizeof(GuiAnimateEntry));
+			lastCastEntry++; _lastCastCount++;
 		}
 		listIterator++;
 	}
@@ -475,16 +482,30 @@
 }
 
 void SciGuiAnimate::reAnimate(Common::Rect rect) {
-	// TODO: implement ReAnimate
-	_gfx->BitsShow(rect);
+	GuiAnimateEntry *lastCastEntry;
+	uint16 lastCastCount;
 
+	if (_lastCastCount > 0) {
+		lastCastEntry = _lastCastData;
+		lastCastCount = _lastCastCount;
+		while (lastCastCount > 0) {
+			lastCastEntry->castHandle = _gfx->BitsSave(lastCastEntry->celRect, SCI_SCREEN_MASK_VISUAL|SCI_SCREEN_MASK_PRIORITY);
+			_gfx->drawCel(lastCastEntry->viewId, lastCastEntry->loopNo, lastCastEntry->celNo, lastCastEntry->celRect, lastCastEntry->priority, lastCastEntry->paletteNo);
+			lastCastEntry++; lastCastCount--;
+		}
+		_gfx->BitsShow(rect);
+		// restoring
+		lastCastCount = _lastCastCount;
+		while (lastCastCount > 0) {
+			lastCastEntry--;
+			_gfx->BitsRestore(lastCastEntry->castHandle);
+			lastCastCount--;
+		}
+	} else {
+		_gfx->BitsShow(rect);
+	}
+
 	/*
-	_s->_gui->localToGlobal(rect.left, rect.top);
-	_s->_gui->localToGlobal(rect.right, rect.bottom);
-	GuiPort *oldPort = _gfx->SetPort((GuiPort *)_picWind);
-	_s->_gui->globalToLocal(rect.left, rect.top);
-	_s->_gui->globalToLocal(rect.right, rect.bottom);
-
 	if (!_lastCast->isEmpty()) {
 		HEAPHANDLE hnode = _lastCast->getFirst();
 		sciCast *pCast;
@@ -504,10 +525,6 @@
 			_gfx->BitsShow(pCast->hSaved);
 			hnode = pCast->node.prev;
 		}
-	} else
-		_gfx->BitsShow(rect);
-
-	_gfx->SetPort(oldPort);
 	*/
 }
 

Modified: scummvm/trunk/engines/sci/gui/gui_animate.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_animate.h	2009-10-30 08:22:53 UTC (rev 45526)
+++ scummvm/trunk/engines/sci/gui/gui_animate.h	2009-10-30 09:26:14 UTC (rev 45527)
@@ -84,11 +84,13 @@
 	SciGuiScreen *_screen;
 	SciGuiPalette *_palette;
 
-	uint16 _listSize;
+	uint16 _listCount;
 	GuiAnimateEntry *_listData;
 	GuiAnimateList _list;
-	//List *_lastCast;
 
+	uint16 _lastCastCount;
+	GuiAnimateEntry *_lastCastData;
+
 	bool _ignoreFastCast;
 };
 

Modified: scummvm/trunk/engines/sci/gui/gui_helpers.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_helpers.h	2009-10-30 08:22:53 UTC (rev 45526)
+++ scummvm/trunk/engines/sci/gui/gui_helpers.h	2009-10-30 09:26:14 UTC (rev 45527)
@@ -87,6 +87,7 @@
 	uint16 signal;
 	Common::Rect celRect;
 	bool showBitsFlag;
+	GuiMemoryHandle castHandle;
 };
 typedef Common::List<GuiAnimateEntry *> GuiAnimateList;
 

Modified: scummvm/trunk/engines/sci/gui/gui_windowmgr.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_windowmgr.cpp	2009-10-30 08:22:53 UTC (rev 45526)
+++ scummvm/trunk/engines/sci/gui/gui_windowmgr.cpp	2009-10-30 09:26:14 UTC (rev 45527)
@@ -44,8 +44,8 @@
 	SCI_WINDOWMGR_STYLE_USER        = (1 << 7)
 };
 
-SciGuiWindowMgr::SciGuiWindowMgr(SciGuiScreen *screen, SciGuiGfx *gfx, SciGuiAnimate *animate, SciGuiText *text)
-	: _screen(screen), _gfx(gfx), _animate(animate), _text(text) {
+SciGuiWindowMgr::SciGuiWindowMgr(SciGui *gui, SciGuiScreen *screen, SciGuiGfx *gfx, SciGuiText *text)
+	: _gui(gui), _screen(screen), _gfx(gfx), _text(text) {
 }
 
 SciGuiWindowMgr::~SciGuiWindowMgr() {
@@ -257,7 +257,7 @@
 	if (arg2)
 		_gfx->BitsShow(pWnd->restoreRect);
 	else
-		_animate->reAnimate(pWnd->restoreRect);
+		_gui->graphRedrawBox(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-30 08:22:53 UTC (rev 45526)
+++ scummvm/trunk/engines/sci/gui/gui_windowmgr.h	2009-10-30 09:26:14 UTC (rev 45527)
@@ -33,7 +33,7 @@
 
 class SciGuiWindowMgr {
 public:
-	SciGuiWindowMgr(SciGuiScreen *screen, SciGuiGfx *gfx, SciGuiAnimate *animate, SciGuiText *text);
+	SciGuiWindowMgr(SciGui *gui, SciGuiScreen *screen, SciGuiGfx *gfx, SciGuiText *text);
 	~SciGuiWindowMgr();
 
 	void init(Common::String gameName);
@@ -54,9 +54,9 @@
 private:
 	typedef Common::List<GuiPort *> PortList;
 
+	SciGui *_gui;
 	SciGuiScreen *_screen;
 	SciGuiGfx *_gfx;
-	SciGuiAnimate *_animate;
 	SciGuiText *_text;
 
 	/** The list of open 'windows' (and ports), in visual order. */


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