From a4ca7824d148d3dea70d222711cc05977a6ccd2b Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 19 May 2006 20:01:59 +0000 Subject: Add a config file setting to allow a delay to be specified on startup. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 484 --- src/d_main.c | 6 ++++-- src/d_net.c | 16 ++++++++++++++-- src/d_net.h | 4 +++- src/i_video.c | 20 +++++++++++++++++--- src/i_video.h | 3 ++- src/m_misc.c | 5 +++-- 6 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index d7d94145..78ceac49 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: d_main.c 475 2006-05-05 19:49:34Z fraggle $ +// $Id: d_main.c 484 2006-05-19 20:01:59Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -184,7 +184,7 @@ //----------------------------------------------------------------------------- -static const char rcsid[] = "$Id: d_main.c 475 2006-05-05 19:49:34Z fraggle $"; +static const char rcsid[] = "$Id: d_main.c 484 2006-05-19 20:01:59Z fraggle $"; #define BGCOLOR 7 #define FGCOLOR 8 @@ -571,6 +571,8 @@ void D_DoomLoop (void) I_InitGraphics (); + D_StartGameLoop(); + while (1) { // frame syncronous IO operations diff --git a/src/d_net.c b/src/d_net.c index 5370e623..ba433c9f 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: d_net.c 475 2006-05-05 19:49:34Z fraggle $ +// $Id: d_net.c 484 2006-05-19 20:01:59Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -117,7 +117,7 @@ //----------------------------------------------------------------------------- -static const char rcsid[] = "$Id: d_net.c 475 2006-05-05 19:49:34Z fraggle $"; +static const char rcsid[] = "$Id: d_net.c 484 2006-05-19 20:01:59Z fraggle $"; #include "doomfeatures.h" @@ -221,6 +221,7 @@ void NetUpdate (void) // check time nowtime = GetAdjustedTime() / ticdup; newtics = nowtime - lasttime; + lasttime = nowtime; if (skiptics <= newtics) @@ -286,6 +287,16 @@ void NetUpdate (void) } } +// +// Start game loop +// +// Called after the screen is set but before the game starts running. +// + +void D_StartGameLoop(void) +{ + lasttime = GetAdjustedTime() / ticdup; +} // @@ -574,6 +585,7 @@ void TryRunTics (void) I_Error ("gametic>lowtic"); if (advancedemo) D_DoAdvanceDemo (); + G_Ticker (); gametic++; diff --git a/src/d_net.h b/src/d_net.h index 48bbcde1..ce10aeb3 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: d_net.h 388 2006-02-24 19:14:22Z fraggle $ +// $Id: d_net.h 484 2006-05-19 20:01:59Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -49,6 +49,8 @@ void D_QuitNetGame (void); //? how many ticks to run? void TryRunTics (void); +// Called at start of game loop to initialise timers +void D_StartGameLoop(void); #endif diff --git a/src/i_video.c b/src/i_video.c index 50d0515c..09976afa 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: i_video.c 478 2006-05-08 21:54:32Z fraggle $ +// $Id: i_video.c 484 2006-05-19 20:01:59Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -175,7 +175,7 @@ //----------------------------------------------------------------------------- static const char -rcsid[] = "$Id: i_video.c 478 2006-05-08 21:54:32Z fraggle $"; +rcsid[] = "$Id: i_video.c 484 2006-05-19 20:01:59Z fraggle $"; #include #include @@ -234,6 +234,10 @@ static boolean native_surface; // Run in full screen mode? (int type for config code) int fullscreen = FULLSCREEN_ON; +// Time to wait for the screen to settle on startup before starting the +// game (ms) +int startup_delay = 0; + // Grab the mouse? (int type for config code) int grabmouse = true; @@ -868,7 +872,7 @@ void I_FinishUpdate (void) // If we have a palette to set, the act of setting the palette // updates the screen - if (palette_to_set) + if (palette_to_set ||true) { SDL_SetColors(screen, palette, 0, 256); palette_to_set = 0; @@ -1139,6 +1143,16 @@ void I_InitGraphics(void) UpdateFocus(); UpdateGrab(); + // On some systems, it takes a second or so for the screen to settle + // after changing modes. We include the option to add a delay when + // setting the screen mode, so that the game doesn't start immediately + // with the player unable to see anything. + + if (fullscreen || true) + { + SDL_Delay(startup_delay); + } + // Check if we have a native surface we can use // If we have to lock the screen, draw to a buffer and copy // Likewise if the screen pitch is not the same as the width diff --git a/src/i_video.h b/src/i_video.h index 3be10b4b..d3ca7376 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: i_video.h 147 2005-10-02 03:16:29Z fraggle $ +// $Id: i_video.h 484 2006-05-19 20:01:59Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -65,6 +65,7 @@ extern int screenmultiply; extern boolean fullscreen; extern boolean grabmouse; extern float mouse_acceleration; +extern int startup_delay; #endif //----------------------------------------------------------------------------- diff --git a/src/m_misc.c b/src/m_misc.c index 5392248d..898c087b 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: m_misc.c 444 2006-03-25 21:50:32Z fraggle $ +// $Id: m_misc.c 484 2006-05-19 20:01:59Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -106,7 +106,7 @@ //----------------------------------------------------------------------------- static const char -rcsid[] = "$Id: m_misc.c 444 2006-03-25 21:50:32Z fraggle $"; +rcsid[] = "$Id: m_misc.c 484 2006-05-19 20:01:59Z fraggle $"; #include #include @@ -402,6 +402,7 @@ static default_t extra_defaults_list[] = {"mouse_acceleration", &mouse_acceleration, DEFAULT_FLOAT}, {"show_endoom", &show_endoom}, {"vanilla_savegame_limit", &vanilla_savegame_limit}, + {"startup_delay", &startup_delay}, #ifdef FEATURE_MULTIPLAYER {"player_name", &net_player_name, DEFAULT_STRING}, #endif -- cgit v1.2.3