aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2009-02-24 20:33:31 +0000
committerMax Horn2009-02-24 20:33:31 +0000
commit220270586c5a42f7352277bc338c54b22e8b7372 (patch)
treecf852a571555bce9fc9d0cd8f5fab326976397bf /engines
parent241340a07ea138c6badd3727683097e863ef35f0 (diff)
downloadscummvm-rg350-220270586c5a42f7352277bc338c54b22e8b7372.tar.gz
scummvm-rg350-220270586c5a42f7352277bc338c54b22e8b7372.tar.bz2
scummvm-rg350-220270586c5a42f7352277bc338c54b22e8b7372.zip
SCI: Removed usec_sleep from gfx_driver_t (call OSystem::delayMillis directly instead); added remarks that busy-waiting like this with delayMillis is maybe not the best way, and that gfx_driver_t should be either removed or turned into a class
svn-id: r38851
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/gfx/gfx_driver.cpp6
-rw-r--r--engines/sci/gfx/gfx_driver.h16
-rw-r--r--engines/sci/gfx/operations.cpp22
3 files changed, 14 insertions, 30 deletions
diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp
index b3bb8813f1..a142de162c 100644
--- a/engines/sci/gfx/gfx_driver.cpp
+++ b/engines/sci/gfx/gfx_driver.cpp
@@ -463,11 +463,6 @@ static sci_event_t scummvm_get_event(gfx_driver_t *drv) {
return input;
}
-static int scummvm_usec_sleep(gfx_driver_t *drv, long usecs) {
- g_system->delayMillis(usecs / 1000);
- return GFX_OK;
-}
-
gfx_driver_t gfx_driver_scummvm = {
NULL,
0, 0,
@@ -486,7 +481,6 @@ gfx_driver_t gfx_driver_scummvm = {
scummvm_set_pointer,
scummvm_set_palette,
scummvm_get_event,
- scummvm_usec_sleep,
NULL
};
diff --git a/engines/sci/gfx/gfx_driver.h b/engines/sci/gfx/gfx_driver.h
index 3ecdaa80cf..343d0199d0 100644
--- a/engines/sci/gfx/gfx_driver.h
+++ b/engines/sci/gfx/gfx_driver.h
@@ -31,11 +31,11 @@
namespace Sci {
-typedef enum {
+enum gfx_buffer_t {
GFX_BUFFER_FRONT = 0,
GFX_BUFFER_BACK = 1,
GFX_BUFFER_STATIC = 2
-} gfx_buffer_t;
+};
/* graphics driver hints */
@@ -71,6 +71,7 @@ typedef enum {
** must use a reasonable default value.
*/
+// FIXME: Turn this into a class, or get rid of it completely.
struct gfx_driver_t { /* Graphics driver */
gfx_mode_t *mode; /* Currently active mode, NULL if no mode is active */
@@ -302,17 +303,6 @@ struct gfx_driver_t { /* Graphics driver */
** queue, or the null event if there is none.
*/
- int (*usec_sleep)(gfx_driver_t *drv, long usecs);
- /* Sleeps the specified amount of microseconds, or until the mouse moves
- ** Parameters: (gfx_driver_t *) drv: The relevant driver
- ** (long) usecs: Amount of microseconds to sleep
- ** Returns : (int) GFX_OK or GFX_FATAL
- ** This function returns when the specified amount of microseconds has
- ** elapsed, or when the mouse pointer has been moved and needs to be redrawn.
- ** Only targets that can handle colored mouse pointers may choose to handle
- ** all mouse management internally.
- */
-
void *state; /* Reserved for internal use */
};
diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp
index d4190353a1..26b0207695 100644
--- a/engines/sci/gfx/operations.cpp
+++ b/engines/sci/gfx/operations.cpp
@@ -1363,24 +1363,24 @@ static int _gfxop_full_pointer_refresh(gfx_state_t *state) {
}
int gfxop_usleep(gfx_state_t *state, long usecs) {
- uint32 time, wakeup_time;
- int retval = GFX_OK;
-
BASIC_CHECKS(GFX_FATAL);
- wakeup_time = g_system->getMillis() + usecs / 1000;
+ uint32 time;
+ const uint32 wakeup_time = g_system->getMillis() + usecs / 1000;
- do {
+ while (true) {
GFXOP_FULL_POINTER_REFRESH;
time = g_system->getMillis();
- usecs = 1000 * ((long)wakeup_time - (long)time);
- } while ((usecs > 0) && !(retval = state->driver->usec_sleep(state->driver, usecs)));
-
- if (retval) {
- GFXWARN("Waiting failed\n");
+ if (time >= wakeup_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 retval;
+ return GFX_OK;
}
int _gfxop_set_pointer(gfx_state_t *state, gfx_pixmap_t *pxm) {