From b2e2ba8868c20198d48e02b9a64ebcea1c98f47c Mon Sep 17 00:00:00 2001 From: helixhorned Date: Wed, 5 Aug 2009 22:37:48 +0000 Subject: [PATCH] make mapster slightly less cpu-hungry under linux. Also a (temporary?) fix for a crash git-svn-id: https://svn.eduke32.com/eduke32@1486 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/baselayer.h | 1 + polymer/eduke32/build/src/build.c | 4 +-- polymer/eduke32/build/src/config.c | 6 +++- polymer/eduke32/build/src/sdlayer.c | 7 +++- polymer/eduke32/build/src/winlayer.c | 4 +++ polymer/eduke32/source/astub.c | 32 ++++++++++++------- .../eduke32/source/jaudiolib/src/multivoc.c | 4 ++- 7 files changed, 41 insertions(+), 17 deletions(-) diff --git a/polymer/eduke32/build/include/baselayer.h b/polymer/eduke32/build/include/baselayer.h index 40f329665..a1d3fb388 100644 --- a/polymer/eduke32/build/include/baselayer.h +++ b/polymer/eduke32/build/include/baselayer.h @@ -95,6 +95,7 @@ void debugprintf(const char *,...); int32_t handleevents(void); extern inline void idle(void); +extern inline void idle_waitevent(void); typedef void (*KeyPressCallback)(int32_t,int32_t); typedef void (*MousePressCallback)(int32_t,int32_t); diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 65b7e04a3..fd580bb0c 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -541,6 +541,7 @@ CANCEL: while ((keystatus[1]|keystatus[0x1c]|keystatus[0x39]|keystatus[0x31]) == 0) { + idle_waitevent(); if (handleevents()) { if (quitevent) @@ -549,7 +550,6 @@ CANCEL: break; } } - idle(); if (keystatus[0x15]||keystatus[0x1c]) // Y or ENTER { @@ -575,8 +575,8 @@ CANCEL: while ((keystatus[1]|keystatus[0x1c]|keystatus[0x39]|keystatus[0x31]|keystatus[0x2e]) == 0) { + idle_waitevent(); if (handleevents()) { if (quitevent) break; } // like saying no - idle(); if (keystatus[0x15] || keystatus[0x1c]) // Y or ENTER { diff --git a/polymer/eduke32/build/src/config.c b/polymer/eduke32/build/src/config.c index 8226ac964..c910b16cd 100644 --- a/polymer/eduke32/build/src/config.c +++ b/polymer/eduke32/build/src/config.c @@ -56,6 +56,7 @@ static int32_t readconfig(BFILE *fp, const char *key, char *value, uint32_t len) } extern int16_t brightness; +extern int32_t vsync; extern char game_executable[BMAX_PATH]; extern int32_t fullscreen; extern char option[8]; @@ -136,6 +137,7 @@ int32_t loadsetup(const char *fn) if (readconfig(fp, "music", val, VL) > 0) { if (Batoi(val) != 0) option[2] = 1; else option[2] = 0; } if (readconfig(fp, "mouse", val, VL) > 0) { if (Batoi(val) != 0) option[3] = 1; else option[3] = 0; } if (readconfig(fp, "bpp", val, VL) > 0) bppgame = Batoi(val); + if (readconfig(fp, "vsync", val, VL) > 0) vsync = Batoi(val)?1:0; if (readconfig(fp, "editorgridextent", val, VL) > 0) editorgridextent = max(min(524288,Batoi(val)),65536); #ifdef POLYMER if (readconfig(fp, "rendmode", val, VL) > 0) { i = Batoi(val); glrendmode = i; } @@ -298,6 +300,8 @@ int32_t writesetup(const char *fn) "; 3D-mode colour depth\n" "bpp = %d\n" "\n" + "vsync = %d\n" + "\n" #ifdef POLYMER "; Rendering mode\n" "rendmode = %d\n" @@ -447,7 +451,7 @@ int32_t writesetup(const char *fn) "; remap = 10-3A,52-4C,53-B8\n" "remap = ", - forcesetup, fullscreen, xdim2d, ydim2d, xdimgame, ydimgame, bppgame, + forcesetup, fullscreen, xdim2d, ydim2d, xdimgame, ydimgame, bppgame, vsync, #ifdef POLYMER glrendmode, #endif diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index d8d1a4d77..16ef70f72 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -1809,7 +1809,12 @@ int32_t handleevents(void) inline void idle(void) { - usleep(1); + usleep(1000); +} + +inline void idle_waitevent(void) +{ + SDL_WaitEvent(NULL); } #if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3) // SDL 1.2 diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index b8e85ece5..7078957c1 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -695,6 +695,10 @@ inline void idle(void) Sleep(1); } +inline void idle_waitevent(void) +{ + Sleep(1); +} //------------------------------------------------------------------------------------------------- diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index b84078514..397833fd1 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -1682,11 +1682,11 @@ static void IntegratedHelp() while (keystatus[KEYSC_ESC]==0 && keystatus[KEYSC_Q]==0 && keystatus[KEYSC_F1]==0) { + idle_waitevent(); if (handleevents()) { if (quitevent) quitevent = 0; } - idle(); // printmessage16("Help mode, press to exit"); if (keystatus[KEYSC_T]) // goto table of contents @@ -1796,11 +1796,11 @@ static void IntegratedHelp() _printmessage16(tempbuf); showframe(1); + idle_waitevent(); if (handleevents()) { if (quitevent) quitevent = 0; } - idle(); ch = bgetchar(); @@ -2077,11 +2077,11 @@ static void SoundDisplay() while (keystatus[KEYSC_ESC]==0 && keystatus[KEYSC_Q]==0 && keystatus[KEYSC_F2]==0 && keystatus[buildkeys[BK_MODE2D_3D]]==0) // quickjump to 3d mode { + idle_waitevent(); if (handleevents()) { if (quitevent) quitevent = 0; } - idle(); { int32_t col = whitecol-21; @@ -2195,11 +2195,11 @@ static void SoundDisplay() _printmessage16(tempbuf); showframe(1); + idle_waitevent(); if (handleevents()) { if (quitevent) quitevent = 0; } - idle(); ch = bgetchar(); @@ -3197,11 +3197,14 @@ static int32_t m32gettile(int32_t idInitialTile) mtile=iTile; } + if (bpp==8) // no idea why, but it breaks the mousewheel else :/ + idle_waitevent(); + else + idle(); if (handleevents()) { if (quitevent) quitevent = 0; } - idle(); // These two lines are so obvious I don't need to comment them ...;-) synctics = totalclock-lockclock; @@ -10791,11 +10794,12 @@ static void EditSectorData(int16_t sectnum) begindrawing(); while (keystatus[KEYSC_ESC] == 0) { + idle_waitevent(); if (handleevents()) { if (quitevent) quitevent = 0; } - idle(); + _printmessage16("Edit mode, press to exit"); if (keystatus[KEYSC_DOWN]) { @@ -11043,11 +11047,12 @@ static void EditWallData(int16_t wallnum) begindrawing(); while (keystatus[KEYSC_ESC] == 0) { + idle_waitevent(); if (handleevents()) { if (quitevent) quitevent = 0; } - idle(); + _printmessage16("Edit mode, press to exit"); if (keystatus[KEYSC_DOWN]) { @@ -11194,12 +11199,13 @@ static void EditSpriteData(int16_t spritenum) while (keystatus[KEYSC_ESC] == 0) { + idle_waitevent(); begindrawing(); if (handleevents()) { if (quitevent) quitevent = 0; } - idle(); + _printmessage16("Edit mode, press to exit"); if (keystatus[KEYSC_DOWN]) { @@ -11609,12 +11615,13 @@ static void GenSearchSprite() while (keystatus[KEYSC_ESC] == 0) { - begindrawing(); + idle_waitevent(); if (handleevents()) { if (quitevent) quitevent = 0; } - idle(); + + begindrawing(); printmessage16("Sprite search, press to exit"); if (keystatus[KEYSC_DOWN]) @@ -11781,12 +11788,13 @@ static void FuncMenu(void) while (!editval && keystatus[KEYSC_ESC] == 0) { - begindrawing(); + idle_waitevent(); if (handleevents()) { if (quitevent) quitevent = 0; } - idle(); + + begindrawing(); _printmessage16("Select an option, press to exit"); if (keystatus[KEYSC_DOWN]) { diff --git a/polymer/eduke32/source/jaudiolib/src/multivoc.c b/polymer/eduke32/source/jaudiolib/src/multivoc.c index 113f538bf..799d062d4 100644 --- a/polymer/eduke32/source/jaudiolib/src/multivoc.c +++ b/polymer/eduke32/source/jaudiolib/src/multivoc.c @@ -278,7 +278,9 @@ static void MV_Mix uint32_t rate; uint32_t FixedPointBufferSize; - if ((voice->length == 0) && (voice->GetSound(voice) != KeepPlaying)) + // cheap fix for a crash under 64-bit linux --\ + // v + if ((voice->length == 0) && ((voice->GetSound == NULL) || (voice->GetSound(voice) != KeepPlaying))) { return; }