From 7e05f5884c0da79243774198a219fb5ad653c280 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 15 Sep 2012 15:28:30 +0000 Subject: [PATCH] With SDL 1.2 builds, make the profiling be cancelable by pressing any key. git-svn-id: https://svn.eduke32.com/eduke32@3022 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/baselayer.h | 1 + polymer/eduke32/build/src/sdlayer.c | 11 +++++++++++ polymer/eduke32/build/src/winlayer.c | 5 +++++ polymer/eduke32/source/demo.c | 5 ++++- polymer/eduke32/source/demo.h | 1 - polymer/eduke32/source/osdcmds.c | 3 ++- 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/build/include/baselayer.h b/polymer/eduke32/build/include/baselayer.h index 367c8d1fe..088546b90 100644 --- a/polymer/eduke32/build/include/baselayer.h +++ b/polymer/eduke32/build/include/baselayer.h @@ -106,6 +106,7 @@ void initprintf(const char *, ...) ATTRIBUTE((format(printf,1,2))); void debugprintf(const char *,...) ATTRIBUTE((format(printf,1,2))); int32_t handleevents(void); +int32_t handleevents_peekkeys(void); extern inline void idle(void); extern inline void idle_waitevent(void); extern inline void idle_waitevent_timeout(uint32_t timeout); diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 6dc89b387..10a87d5e6 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -1862,6 +1862,17 @@ static SDL_Surface *loadappicon(void) // // +int32_t handleevents_peekkeys(void) +{ +#if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION == 2) + SDL_PumpEvents(); + return SDL_PeepEvents(NULL, 1, SDL_PEEKEVENT, SDL_EVENTMASK(SDL_KEYDOWN)); +#else + // SDL 1.3 up has not been tested to compile. + return 0; +#endif +} + // // handleevents() -- process the SDL message queue diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index 6922ecbbd..d4c30e613 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -799,6 +799,11 @@ void debugprintf(const char *f, ...) } +int32_t handleevents_peekkeys(void) +{ + return 0; +} + // // handleevents() -- process the Windows message queue // returns !0 if there was an important event worth checking (like quitting) diff --git a/polymer/eduke32/source/demo.c b/polymer/eduke32/source/demo.c index e79cb9656..7f5bad2b5 100644 --- a/polymer/eduke32/source/demo.c +++ b/polymer/eduke32/source/demo.c @@ -371,7 +371,7 @@ int32_t Demo_IsProfiling(void) return (g_demo_profile > 0); } -void Demo_StopProfiling(void) +static void Demo_StopProfiling(void) { g_demo_stopProfile = 1; } @@ -821,6 +821,9 @@ nextdemo_nomenu: // draw status Demo_DisplayProfStatus(); + + if (handleevents_peekkeys()) + Demo_StopProfiling(); } else if (r_maxfps == 0 || tt >= nextrender) { diff --git a/polymer/eduke32/source/demo.h b/polymer/eduke32/source/demo.h index fead43a26..57b7852ed 100644 --- a/polymer/eduke32/source/demo.h +++ b/polymer/eduke32/source/demo.h @@ -51,7 +51,6 @@ void G_OpenDemoWrite(void); void Demo_PlayFirst(int32_t prof); int32_t Demo_IsProfiling(void); -void Demo_StopProfiling(void); #if KRANDDEBUG int32_t krd_print(const char *filename); diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 0935cfbed..d105398be 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -296,7 +296,8 @@ static int32_t osdcmd_map(const osdfuncparm_t *parm) // Notes: // * The demos should be recorded with demorec_diffs set to 0, so that the // game state updates are actually computed. -// * There's currently no way to abort the profiling. +// * Currently, the profiling can only be aborted on SDL 1.2 builds by +// pressing any key. // * With greater than 1, interpolation should be calculated properly, // though this has not been verified by looking at the frames. // * When testing whether a change in the source has an effect on performance,