diff --git a/cgdoom/cgdoom.c b/cgdoom/cgdoom.c index 0974b0f..33922bd 100644 --- a/cgdoom/cgdoom.c +++ b/cgdoom/cgdoom.c @@ -384,6 +384,7 @@ int CGD_TrustUnalignedLumps = 1; int CGD_EnableDemos = 0; int CGD_SingleEpisodeUltimate = 0; int CGD_2MBLineMemory = 0; +int CGD_Frameskip = 1; /* Performance counters */ struct CGD_Perf CGD_Perf; diff --git a/cgdoom/cgdoom.h b/cgdoom/cgdoom.h index 8bf7e2c..4f3f345 100644 --- a/cgdoom/cgdoom.h +++ b/cgdoom/cgdoom.h @@ -30,6 +30,8 @@ extern int CGD_EnableDemos; /* The selected WAD is a split Ultimate Doom WAD with a single episode (this exists on the fx-CG 50 and is incorrectly detected by normal logic) */ extern int CGD_SingleEpisodeUltimate; +/* Skip this amount of frames after every rendered frame (default 1) */ +extern int CGD_Frameskip; // Global variables interfacing with Doom itself. @@ -56,6 +58,17 @@ void UpdateKeyboardState(void); int KeyWasJustPressed(int key); int KeyWasJustReleased(int key); +//--- +// Control systems +//--- + +void CGD_Cheat(); +void CGD_SwitchClip(); +void CGD_FreeMem(); +void CGD_CycleFrameskip(); +void CGD_CycleGamma(); +void CGD_ProfilerResults(); + //--- // Performance metrics //--- diff --git a/cgdoom/d_main.c b/cgdoom/d_main.c index 5cd0394..f3394a7 100644 --- a/cgdoom/d_main.c +++ b/cgdoom/d_main.c @@ -255,7 +255,7 @@ void D_Display (void) // D_DoomLoop // extern boolean demorecording; -extern int giRefreshMask; + void D_DoomLoop (void) { I_InitGraphics (); @@ -275,11 +275,8 @@ void D_DoomLoop (void) gametic++; // Update display, next frame, with current state - if(!(gametic & giRefreshMask)) - { + if(!(gametic % (CGD_Frameskip + 1))) D_Display (); - } - } // I_ShutdownGraphics(); free(lumpinfo); diff --git a/cgdoom/doomdef.h b/cgdoom/doomdef.h index adb37f6..257cec2 100644 --- a/cgdoom/doomdef.h +++ b/cgdoom/doomdef.h @@ -304,14 +304,6 @@ typedef enum // The utility was written by Dave Taylor. //#include "sounds.h" -/// -void CGCheat(); -void CGSwitchClip(); -void CGFreeMem(); -void CGRefreshSwitch(); -void CGCycleGamma(); -void CGProfilerResults(); - #endif // __DOOMDEF__ //----------------------------------------------------------------------------- diff --git a/cgdoom/i_system.c b/cgdoom/i_system.c index 32a68d8..f8ca97f 100644 --- a/cgdoom/i_system.c +++ b/cgdoom/i_system.c @@ -243,8 +243,6 @@ static void R_SetViewSizeChange(int iDiff) void I_StartTic (void) { - extern int giRefreshMask; - //--- // Rate limiter //--- @@ -254,12 +252,12 @@ void I_StartTic (void) /* Rate limit the game at 35 tics per second, but only extend tics where we display frames, because that's when all the work is done */ - if(!(gametic & giRefreshMask)) { + if(!(gametic % (CGD_Frameskip + 1))) { if(ratelimit_started) { while(1) { prof_t temp = ratelimit_ctx; prof_leave(temp); - if(prof_time(temp) >= 28571 * (giRefreshMask + 1)) break; + if(prof_time(temp) >= 28571 * (CGD_Frameskip + 1)) break; } ratelimit_ctx = prof_make(); } @@ -288,7 +286,7 @@ void I_StartTic (void) if (now == fps_ticks) fpscounter_data = -1; else - fpscounter_data = 128 * fps_frames / ((now - fps_ticks) * (giRefreshMask + 1)); + fpscounter_data = 128 * fps_frames / ((now - fps_ticks) * (CGD_Frameskip + 1)); fps_ticks = now; fps_frames = 0; @@ -307,21 +305,21 @@ void I_StartTic (void) { /* Capture events for special keys */ if(KeyWasJustPressed(SKEY_CHEAT)) - CGCheat(); + CGD_Cheat(); if(KeyWasJustPressed(SKEY_DECVP)) R_SetViewSizeChange(-1); if(KeyWasJustPressed(SKEY_INCVP)) R_SetViewSizeChange(1); if(KeyWasJustPressed(SKEY_NOCLIP)) - CGSwitchClip(); + CGD_SwitchClip(); if(KeyWasJustPressed(SKEY_GAMMA)) - CGCycleGamma(); + CGD_CycleGamma(); if(KeyWasJustPressed(SKEY_FREEMEM)) - CGFreeMem(); + CGD_FreeMem(); if(KeyWasJustPressed(SKEY_FPSCOUNTER)) fpscounteractive = !fpscounteractive; if(KeyWasJustPressed(SKEY_FRAMESKIP)) - CGRefreshSwitch(); + CGD_CycleFrameskip(); } //--- @@ -341,7 +339,7 @@ void I_StartTic (void) else { profiler_ticks--; if(profiler_ticks == 0) { - CGProfilerResults(); + CGD_ProfilerResults(); profiler_ticks = -1; } } diff --git a/cgdoom/st_stuff.c b/cgdoom/st_stuff.c index 4ed51c6..f9e7609 100644 --- a/cgdoom/st_stuff.c +++ b/cgdoom/st_stuff.c @@ -431,7 +431,7 @@ void ST_refreshBackground(void) } -void CGCheat() +void CGD_Cheat() { int i; plyr->cheats ^= CF_GODMODE; @@ -461,7 +461,7 @@ void CGCheat() } -void CGSwitchClip() +void CGD_SwitchClip() { plyr->cheats ^= CF_NOCLIP; if(plyr->cheats & CF_NOCLIP) @@ -474,7 +474,7 @@ void CGSwitchClip() } } -void CGFreeMem() +void CGD_FreeMem() { static char message[64]; sprintf(message, "Free: "); @@ -493,21 +493,16 @@ void CGFreeMem() plyr->message = message; } -int giRefreshMask = 1; -void CGRefreshSwitch() +void CGD_CycleFrameskip() { - giRefreshMask ^= 2; - if(giRefreshMask & 2) - { - plyr->message = "Fast"; - } - else - { - plyr->message = "Smooth"; - } + CGD_Frameskip = (CGD_Frameskip + 1) % 4; + + static char message[16]; + sprintf(message, "Frameskip: %d", CGD_Frameskip); + plyr->message = message; } -void CGCycleGamma() +void CGD_CycleGamma() { extern int usegamma; usegamma = (usegamma + 1) % 5; @@ -517,7 +512,7 @@ void CGCycleGamma() plyr->message = gammamsg[usegamma]; } -void CGProfilerResults() +void CGD_ProfilerResults() { static char message[72]; sprintf(message, "DA:%ums GR:%ums DI:%ums LL:%ums ULL:%ums",