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

wjpalenstijn at users.sourceforge.net wjpalenstijn at users.sourceforge.net
Wed Feb 25 19:23:34 CET 2009


Revision: 38880
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38880&view=rev
Author:   wjpalenstijn
Date:     2009-02-25 18:23:28 +0000 (Wed, 25 Feb 2009)

Log Message:
-----------
Interpret NONBLOCK as PEEK; poll while sleeping.
Also use Common::List for internal event queue.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gfx/operations.cpp
    scummvm/trunk/engines/sci/gfx/operations.h
    scummvm/trunk/engines/sci/include/uinput.h

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-02-25 17:53:44 UTC (rev 38879)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-02-25 18:23:28 UTC (rev 38880)
@@ -551,7 +551,7 @@
 	state->options = options;
 	state->mouse_pointer_in_hw = 0;
 	state->disable_dirty = 0;
-	state->events = NULL;
+	state->events.clear();
 
 	state->pic = state->pic_unscaled = NULL;
 
@@ -1368,15 +1368,18 @@
 	const uint32 wakeup_time = g_system->getMillis() + msecs;
 
 	while (true) {
-		GFXOP_FULL_POINTER_REFRESH;
+		// let backend process events and update the screen
+		gfxop_get_event(state, SCI_EVT_PEEK);
+		g_system->updateScreen();
 		time = g_system->getMillis();
-		if (time >= wakeup_time)
+		if (time + 10 < wakeup_time) {
+			g_system->delayMillis(10);
+		} else {
+			if (time < wakeup_time)
+				g_system->delayMillis(wakeup_time - time);
 			break;
-		// FIXME: Busy waiting like this is usually not a good idea if it is for
-		// more than a few milliseconds. One should invoke OSystem::pollEvent during longer
-		// waits, else the mouse cursor might not be updated properly, and the system
-		// will seem sluggish to the user.
-		g_system->delayMillis(wakeup_time - time);
+		}
+
 	}
 
 	return GFX_OK;
@@ -1616,37 +1619,32 @@
 
 sci_event_t gfxop_get_event(gfx_state_t *state, unsigned int mask) {
 	sci_event_t error_event = { SCI_EVT_ERROR, 0, 0, 0 };
-	sci_event_t event = { 0, 0, 0, 0 };;
-	gfx_input_event_t **seekerp = &(state->events);
+	sci_event_t event = { 0, 0, 0, 0 };
 
 	BASIC_CHECKS(error_event);
 	if (_gfxop_remove_pointer(state)) {
 		GFXERROR("Failed to remove pointer before processing event!\n");
 	}
 
-	while (*seekerp && !((*seekerp)->event.type & mask))
-		seekerp = &((*seekerp)->next);
+	// Get all queued events from graphics driver
+	do {
+		event = state->driver->get_event(state->driver);
+		if (event.type)
+			state->events.push_back(event);
+	} while (event.type);
 
-	if (*seekerp) {
-		gfx_input_event_t *goner = *seekerp;
-		event = goner->event;
-		*seekerp = goner->next;
-		free(goner);
-	} else {
-		event.type = 0;
+	// Search for matching event in queue
+	Common::List<sci_event_t>::iterator iter = state->events.begin();
+	while (iter != state->events.end() && !((*iter).type & mask))
+		++iter;
 
-		if (!(mask & SCI_EVT_NONBLOCK)) {
-			do {
-				if (event.type) {
-					*seekerp = (gfx_input_event_t *)sci_malloc(sizeof(gfx_input_event_t));
-					(*seekerp)->next = NULL;
+	if (iter != state->events.end()) {
+		// Event found
+		event = *iter;
 
-					(*seekerp)->event = event;
-					seekerp = &((*seekerp)->next);
-				}
-				event = state->driver->get_event(state->driver);
-
-			} while (event.type && !(event.type & mask));
+		// If not peeking at the queue, remove the event
+		if (!(mask & SCI_EVT_PEEK)) {
+			state->events.erase(iter);
 		}
 	}
 

Modified: scummvm/trunk/engines/sci/gfx/operations.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.h	2009-02-25 17:53:44 UTC (rev 38879)
+++ scummvm/trunk/engines/sci/gfx/operations.h	2009-02-25 18:23:28 UTC (rev 38880)
@@ -34,6 +34,8 @@
 #include "sci/gfx/gfx_system.h"
 #include "sci/include/uinput.h"
 
+#include "common/list.h"
+
 namespace Sci {
 
 #define GFXOP_NO_POINTER -1
@@ -87,11 +89,6 @@
 };
 
 
-struct gfx_input_event_t {
-	sci_event_t event;
-	gfx_input_event_t *next;
-};
-
 struct gfx_state_t {
 	int version; /* Interpreter version */
 
@@ -135,7 +132,7 @@
 	int pic_nr; /* Number of the current pic */
 	int palette_nr; /* Palette number of the current pic */
 
-	gfx_input_event_t *events;
+	Common::List<sci_event_t> events;
 
 	gfx_pixmap_t *fullscreen_override; /* An optional override picture which must have unscaled
 					   ** full-screen size, which overrides all other visibility, and

Modified: scummvm/trunk/engines/sci/include/uinput.h
===================================================================
--- scummvm/trunk/engines/sci/include/uinput.h	2009-02-25 17:53:44 UTC (rev 38879)
+++ scummvm/trunk/engines/sci/include/uinput.h	2009-02-25 18:23:28 UTC (rev 38880)
@@ -61,7 +61,7 @@
 /*Fake values for other events*/
 #define SCI_EVT_ERROR           (1<<10)
 #define SCI_EVT_QUIT            (1<<11)
-#define SCI_EVT_NONBLOCK	(1<<15)
+#define SCI_EVT_PEEK            (1<<15)
 /* The QUIT event may be used to signal an external 'quit' command being
 ** issued to the gfx driver.  */
 #define SCI_EVT_ANY             0x7fff


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