From df0721076ff03dbeceede11c0955c62924dd0584 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Thu, 28 Aug 2014 07:27:55 +0200 Subject: [PATCH] atari:timer: Throttles calls to BackgroundTask function, to avoid it being called too frequently. --- src/timer/mint/SDL_systimer.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/timer/mint/SDL_systimer.c b/src/timer/mint/SDL_systimer.c index 3038212d2..8b1e7d0aa 100644 --- a/src/timer/mint/SDL_systimer.c +++ b/src/timer/mint/SDL_systimer.c @@ -55,8 +55,6 @@ static Uint32 readHz200Timer(void); /* The first ticks value of the application */ static Uint32 start; -static int mint_present; /* can we use Syield() ? */ - /* Timer SDL_arraysize(Timer ),start/reset time */ static Uint32 timerStart; @@ -66,8 +64,6 @@ void SDL_StartTicks(void) /* Set first ticks value, one _hz_200 tic is 5ms */ start = readHz200Timer() * 5; - - mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); } Uint32 SDL_GetTicks (void) @@ -79,23 +75,32 @@ Uint32 SDL_GetTicks (void) void SDL_Delay (Uint32 ms) { - Uint32 now; + static Uint32 prev_now = 0; + Uint32 now, cur_tick; + int ran_bg_task = 0; + + now = cur_tick = SDL_GetTicks(); /* No need to loop for delay below resolution */ if (ms<5) { - SDL_AtariMint_BackgroundTasks(); - if (mint_present) { - Syield(); + if (prev_now != now) { + SDL_AtariMint_BackgroundTasks(); + prev_now = now; } return; } - now = SDL_GetTicks(); - while ((SDL_GetTicks()-now)