diff --git a/src/newgal/video.c b/src/newgal/video.c index d1a1dcb7..a339016b 100644 --- a/src/newgal/video.c +++ b/src/newgal/video.c @@ -40,7 +40,7 @@ #include "common.h" #include "minigui.h" -#include "newgal.h" +#include "gal.h" #include "sysvideo.h" #include "blit.h" #include "pixels_c.h" diff --git a/src/standalone/standalone.c b/src/standalone/standalone.c index c1d09ba6..7192b605 100644 --- a/src/standalone/standalone.c +++ b/src/standalone/standalone.c @@ -64,6 +64,35 @@ #include "menu.h" #include "ourhdr.h" +#ifndef __NOUNIX__ + +#include +#include +#include + +static struct timeval timeval_startup; +static DWORD get_timer_count(const struct timeval* current) +{ + DWORD ds = (current->tv_sec - timeval_startup.tv_sec); + DWORD dms; + + if (current->tv_sec == timeval_startup.tv_sec) { + dms = (current->tv_usec - timeval_startup.tv_usec) / 1000L; + } + else if (current->tv_usec >= timeval_startup.tv_usec) { + dms = (current->tv_usec - timeval_startup.tv_usec) / 1000L; + } + else { + assert(ds > 0); + + ds--; + dms = 1000L - (timeval_startup.tv_usec - current->tv_usec) / 1000L; + } + + return ds * 100 + dms / 10; +} +#endif + extern DWORD __mg_timer_counter; static DWORD old_timer_counter = 0; @@ -164,16 +193,20 @@ BOOL GUIAPI salone_StandAloneStartup (void) mg_fd_zero (&mg_rfdset); mg_maxfd = 0; -#ifndef _MGGAL_BF533 +#if 0 /* VW: do not use signal based interval timer; since 4.0 */ mg_InstallIntervalTimer (); #endif +#ifndef __NOUNIX__ + gettimeofday(&timeval_startup, NULL); +#endif + return TRUE; } void salone_StandAloneCleanup (void) { -#ifndef _MGGAL_BF533 +#if 0 /* VW: do not use signal based interval timer; since 4.0 */ mg_UninstallIntervalTimer (); #endif } @@ -190,6 +223,8 @@ BOOL salone_IdleHandler4StandAlone (PMSGQUEUE msg_queue) struct timeval sel_timeout = {0, 10000}; #elif defined (_MGGAL_BF533) struct timeval sel_timeout = {0, 100000}; +#else + struct timeval sel_timeout = {0, 10000}; #endif struct timeval sel_timeout_nd = {0, 0}; fd_set rset, wset, eset; @@ -197,6 +232,11 @@ BOOL salone_IdleHandler4StandAlone (PMSGQUEUE msg_queue) fd_set* esetptr = NULL; EXTRA_INPUT_EVENT extra; // Since 4.0.0; for extra input events +#ifndef __NOUNIX__ + struct timeval timeval_current; + gettimeofday(&timeval_current, NULL); +#endif + if (old_timer_counter != __mg_timer_counter) { old_timer_counter = __mg_timer_counter; SetDesktopTimerFlag (); @@ -212,6 +252,7 @@ BOOL salone_IdleHandler4StandAlone (PMSGQUEUE msg_queue) esetptr = &eset; } + extra.params_mask = 0; #ifdef __NOUNIX__ n = IAL_WaitEvent (mg_maxfd, &rset, wsetptr, esetptr, msg_queue?&sel_timeout:&sel_timeout_nd, &extra); @@ -234,7 +275,9 @@ BOOL salone_IdleHandler4StandAlone (PMSGQUEUE msg_queue) } #else n = IAL_WaitEvent (mg_maxfd, &rset, wsetptr, esetptr, - msg_queue?NULL:&sel_timeout_nd, &extra); + msg_queue?&sel_timeout:&sel_timeout_nd, &extra); + /* update __mg_timer_counter */ + __mg_timer_counter = get_timer_count(&timeval_current); #endif if (msg_queue == NULL)