From ca54405c4e4d8c0ed7989f857dcbe2b206a59946 Mon Sep 17 00:00:00 2001 From: Tuomas Virtanen Date: Tue, 8 Oct 2024 21:05:40 +0300 Subject: [PATCH] More warp! --- src/engine.c | 30 +++++++++++++++++------------- src/video/video.c | 3 --- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/engine.c b/src/engine.c index d4a1edc8..b09f2aee 100644 --- a/src/engine.c +++ b/src/engine.c @@ -237,20 +237,24 @@ void engine_run(engine_init_flags *init_flags) { debugger_proceed = 0; } - // Tick static features. This is a fixed with-rate tick, and is meant for running things - // that are not dependent on game speed (such as menus). - if(static_wait > STATIC_TICKS) { - game_state_static_tick(gs, false); - console_tick(); - static_wait -= STATIC_TICKS; - } + // In warp mode, allow more ticks to happen per vsync period. + int tick_limit = gs->warp_speed ? 10 : 1; + while(tick_limit--) { + // Tick static features. This is a fixed with-rate tick, and is meant for running things + // that are not dependent on game speed (such as menus). + if(static_wait > STATIC_TICKS) { + game_state_static_tick(gs, false); + console_tick(); + static_wait -= STATIC_TICKS; + } - // Tick dynamic features. This is a dynamically changing tick, and it depends on things such as - // hit-pause, hit slowdown and game-speed slider. It is meant for ticking everything that has to do - // with the actual gameplay stuff. - if(dynamic_wait > game_state_ms_per_dyntick(gs)) { - game_state_dynamic_tick(gs, false); - dynamic_wait -= game_state_ms_per_dyntick(gs); + // Tick dynamic features. This is a dynamically changing tick, and it depends on things such as + // hit-pause, hit slowdown and game-speed slider. It is meant for ticking everything that has to do + // with the actual gameplay stuff. + if(dynamic_wait > game_state_ms_per_dyntick(gs)) { + game_state_dynamic_tick(gs, false); + dynamic_wait -= game_state_ms_per_dyntick(gs); + } } // Do the actual video rendering jobs diff --git a/src/video/video.c b/src/video/video.c index 38a991fe..e7b9e180 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -208,9 +208,6 @@ void video_render_finish(void) { // Flip buffers. If vsync is off, we should sleep here // so hat our main loop doesn't eat up all cpu :) SDL_GL_SwapWindow(g_video_state.window); - if(!g_video_state.vsync) { - SDL_Delay(1); - } } void video_close(void) {