From 6054bf7e907a2cb9507ea3246e18ef177eae61c0 Mon Sep 17 00:00:00 2001 From: zicodxx <> Date: Tue, 30 Sep 2008 00:18:39 +0000 Subject: [PATCH] Added new function to calculate common timesteps; Increased MAXIMUM_FPS to 200 for release and 1000 for debug; Used fixed sim_time for do_physics_sim and Interpolating to ensure collisions stay accurate at high FPS; New code and faster code for dot products by The_Lion; Disabled Nice-FPS and common Frame-Loop if VSync is active; More accurate delta timer for mouse (consider overhead); Added SDL_(Un)LockAudio for old SDL Audio interface; General support for up to 16 mouse buttons; Code cleanup; Made some AI movement and Player shaking FPS-independent --- arch/sdl/timer.c | 8 +++----- main/game.c | 13 +++++-------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/arch/sdl/timer.c b/arch/sdl/timer.c index e3c427d05..8daba5e1a 100644 --- a/arch/sdl/timer.c +++ b/arch/sdl/timer.c @@ -38,12 +38,10 @@ void timer_delay2(int fps) static u_int32_t FrameStart=0; u_int32_t FrameLoop=0; - if (GameCfg.VSync) - return; - - while (FrameLoop < 1000/fps) + while (FrameLoop < 1000/(GameCfg.VSync?MAXIMUM_FPS:fps)) { - SDL_Delay(1); + if (!GameCfg.VSync) + SDL_Delay(1); FrameLoop=SDL_GetTicks()-FrameStart; } diff --git a/main/game.c b/main/game.c index 3a3227f29..1a1fa58c4 100644 --- a/main/game.c +++ b/main/game.c @@ -736,15 +736,12 @@ void calc_frame_time() timer_value = timer_get_fixed_seconds(); FrameTime = timer_value - last_timer_value; - if (!GameCfg.VSync) + while (FrameTime < f1_0 / (GameCfg.VSync?MAXIMUM_FPS:GameArg.SysMaxFPS)) { - while (FrameTime < f1_0 / GameArg.SysMaxFPS) - { - if (GameArg.SysUseNiceFPS) - timer_delay(f1_0 / GameArg.SysMaxFPS - FrameTime); - timer_value = timer_get_fixed_seconds(); - FrameTime = timer_value - last_timer_value; - } + if (GameArg.SysUseNiceFPS && !GameCfg.VSync) + timer_delay(f1_0 / GameArg.SysMaxFPS - FrameTime); + timer_value = timer_get_fixed_seconds(); + FrameTime = timer_value - last_timer_value; } if ( Game_turbo_mode )