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
This commit is contained in:
helixhorned 2009-08-05 22:37:48 +00:00
parent 53418727e9
commit b2e2ba8868
7 changed files with 41 additions and 17 deletions

View file

@ -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);

View file

@ -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
{

View file

@ -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

View file

@ -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

View file

@ -695,6 +695,10 @@ inline void idle(void)
Sleep(1);
}
inline void idle_waitevent(void)
{
Sleep(1);
}
//-------------------------------------------------------------------------------------------------

View file

@ -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 <Esc> 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 <Esc> 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 <Esc> 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 <Esc> 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 <Esc> 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 <Esc> to exit");
if (keystatus[KEYSC_DOWN])
{

View file

@ -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;
}