[Scummvm-cvs-logs] SF.net SVN: scummvm: [29561] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun Nov 18 22:16:28 CET 2007


Revision: 29561
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29561&view=rev
Author:   peres001
Date:     2007-11-18 13:16:27 -0800 (Sun, 18 Nov 2007)

Log Message:
-----------
Partly decoupled rendering from game data update. Graphics routines to draw/erase animations and labels are now invoked explicitly instead of being handled in the job list.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/exec_ns.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2007-11-18 21:13:08 UTC (rev 29560)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2007-11-18 21:16:27 UTC (rev 29561)
@@ -847,71 +847,64 @@
 
 void Parallaction_ns::jobDisplayLabel(void *parm, Job *j) {
 
-	Label *label = (Label*)parm;
-	debugC(9, kDebugExec, "jobDisplayLabel (%p)", (const void*) label);
+	if (!_label)
+		return;
 
-	_gfx->drawLabel(*label);
+	if (_deletingLabel)
+		return;
 
+	debugC(9, kDebugExec, "jobDisplayLabel (%p)", _label);
+
+	_gfx->drawLabel(*_label);
+
 	return;
 }
 
 void Parallaction_ns::jobEraseLabel(void *parm, Job *j) {
-	Label *label = (Label*)parm;
 
-	debugC(9, kDebugExec, "jobEraseLabel (%p)", (const void*) label);
+	static uint16 count = 0;
 
+	if (!_label)
+		return;
+
+	debugC(9, kDebugExec, "jobEraseLabel (%p)", _label);
+
 	int16 _si, _di;
 
 	if (_activeItem._id != 0) {
-		_si = _mousePos.x + 16 - label->_cnv.w/2;
+		_si = _mousePos.x + 16 - _label->_cnv.w/2;
 		_di = _mousePos.y + 34;
 	} else {
-		_si = _mousePos.x + 8 - label->_cnv.w/2;
+		_si = _mousePos.x + 8 - _label->_cnv.w/2;
 		_di = _mousePos.y + 21;
 	}
 
 	if (_si < 0) _si = 0;
 	if (_di > 190) _di = 190;
 
-	if (label->_cnv.w + _si > _screenWidth)
-		_si = _screenWidth - label->_cnv.w;
+	if (_label->_cnv.w + _si > _screenWidth)
+		_si = _screenWidth - _label->_cnv.w;
 
 	Common::Rect r;
-	label->getRect(r, true);
+	_label->getRect(r, true);
 	_gfx->restoreBackground(r);
 
-	label->_old = label->_pos;
-	label->_pos.x = _si;
-	label->_pos.y = _di;
+	_label->_old = _label->_pos;
+	_label->_pos.x = _si;
+	_label->_pos.y = _di;
 
-	return;
-}
-
-
-
-// this Job uses a static counter to delay removal
-// and is in fact only used to remove jEraseLabel jobs
-//
-void Parallaction_ns::jobWaitRemoveJob(void *parm, Job *j) {
-	Job *arg = (Job*)parm;
-
-	static uint16 count = 0;
-
-	debugC(9, kDebugExec, "jobWaitRemoveJob: count = %i", count);
-
-	_engineFlags |= kEngineBlockInput;
-
-	count++;
-	if (count == 2) {
-		count = 0;
-		removeJob(arg);
-		_engineFlags &= ~kEngineBlockInput;
-		j->_finished = 1;
+	if (_deletingLabel) {
+		count++;
+		if (count == 2) {
+			count = 0;
+			_engineFlags &= ~kEngineBlockInput;
+			_deletingLabel = false;
+			_label = 0;
+		}
 	}
 
 	return;
 }
 
 
-
 }	// namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2007-11-18 21:13:08 UTC (rev 29560)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2007-11-18 21:16:27 UTC (rev 29561)
@@ -159,6 +159,8 @@
 	_location._startFrame = 0;
 	_location._comment = NULL;
 	_location._endComment = NULL;
+	_label = 0;
+	_deletingLabel = false;
 
 	_backgroundInfo = 0;
 	_pathBuffer = 0;
@@ -285,8 +287,18 @@
 			changeLocation(_location._name);
 		}
 
+		jobEraseLabel(0, 0);
+		jobEraseAnimations((void*)1, 0);
+
 		runJobs();
 
+		jobDisplayAnimations(0, 0);
+		jobDisplayLabel(0, 0);
+
+		if (_engineFlags & kEngineInventory) {
+			jobShowInventory(0, 0);
+		}
+
 		updateView();
 
 	}
@@ -306,25 +318,20 @@
 
 void Parallaction::showLabel(Label &label) {
 	label.resetPosition();
-	_jDrawLabel = addJob(kJobDisplayLabel, (void*)&label, kPriority0);
-	_jEraseLabel = addJob(kJobEraseLabel, (void*)&label, kPriority20);
+	_label = &label;
 }
 
 void Parallaction::hideLabel(uint priority) {
 
-	if (!_jDrawLabel)
+	if (!_label)
 		return;
 
-	removeJob(_jDrawLabel);
-	_jDrawLabel = 0;
-
 	if (priority == kPriority99) {
-		// remove job immediately
-		removeJob(_jEraseLabel);
-		_jEraseLabel = 0;
+		_label = 0;
 	} else {
 		// schedule job for deletion
-		addJob(kJobWaitRemoveJob, _jEraseLabel, priority);
+		_deletingLabel = true;
+		_engineFlags |= kEngineBlockInput;
 	}
 
 }
@@ -360,7 +367,7 @@
 			setArrowCursor();
 		}
 		removeJob(_jRunScripts);
-		_jDrawInventory = addJob(kJobShowInventory, 0, kPriority2);
+//		_jDrawInventory = addJob(kJobShowInventory, 0, kPriority2);
 		openInventory();
 		break;
 
@@ -369,7 +376,6 @@
 		setInventoryCursor(data->_inventoryIndex);
 		_jRunScripts = addJob(kJobRunScripts, 0, kPriority15);
 		addJob(kJobHideInventory, 0, kPriority20);
-		removeJob(_jDrawInventory);
 		break;
 
 	case kEvHoverInventory:

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2007-11-18 21:13:08 UTC (rev 29560)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2007-11-18 21:16:27 UTC (rev 29561)
@@ -438,7 +438,8 @@
 	Table		*_callableNames;
 	Table		*_localFlagNames;
 
-
+	bool		_deletingLabel;
+	Label		*_label;
 	void showLabel(Label &label);
 	void hideLabel(uint priority);
 
@@ -487,6 +488,10 @@
 
 	Common::RandomSource _rnd;
 
+	virtual void jobShowInventory(void*, Job*) = 0;
+	virtual void jobHideInventory(void*, Job*) = 0;
+
+
 protected:		// data
 
 	Debugger	*_debugger;
@@ -587,7 +592,6 @@
 	virtual void jobWalk(void*, Job *j) = 0;
 	virtual void jobDisplayLabel(void *parm, Job *j) = 0;
 	virtual void jobEraseLabel(void *parm, Job *j) = 0;
-	virtual void jobWaitRemoveJob(void *parm, Job *j) = 0;
 
 	void		beep();
 
@@ -742,7 +746,6 @@
 	void jobWalk(void*, Job *j);
 	void jobDisplayLabel(void *parm, Job *j);
 	void jobEraseLabel(void *parm, Job *j);
-	void jobWaitRemoveJob(void *parm, Job *j);
 	void jobShowInventory(void *parm, Job *j);
 	void jobHideInventory(void *parm, Job *j);
 

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2007-11-18 21:13:08 UTC (rev 29560)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2007-11-18 21:16:27 UTC (rev 29561)
@@ -256,9 +256,9 @@
 
 	changeLocation(_location._name);
 
-	addJob(kJobEraseAnimations, (void*)1, kPriority20);
+//	addJob(kJobEraseAnimations, (void*)1, kPriority20);
 	_jRunScripts = addJob(kJobRunScripts, 0, kPriority15);
-	addJob(kJobDisplayAnimations, 0, kPriority3);
+//	addJob(kJobDisplayAnimations, 0, kPriority3);
 
 	runGame();
 
@@ -444,17 +444,17 @@
 void Parallaction_ns::initJobs() {
 
 	static const JobFn jobs[] = {
-		&Parallaction_ns::jobDisplayAnimations,
-		&Parallaction_ns::jobEraseAnimations,
+		0,
+		0,
 		&Parallaction_ns::jobDisplayDroppedItem,
 		&Parallaction_ns::jobRemovePickedItem,
 		&Parallaction_ns::jobRunScripts,
 		&Parallaction_ns::jobWalk,
-		&Parallaction_ns::jobDisplayLabel,
-		&Parallaction_ns::jobEraseLabel,
-		&Parallaction_ns::jobWaitRemoveJob,
+		0,
+		0,
+		0,
 		&Parallaction_ns::jobToggleDoor,
-		&Parallaction_ns::jobShowInventory,
+		0,
 		&Parallaction_ns::jobHideInventory
 	};
 


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