diff --git a/src/include/86box/timer.h b/src/include/86box/timer.h index e4e163a08..586e3d2fe 100644 --- a/src/include/86box/timer.h +++ b/src/include/86box/timer.h @@ -7,8 +7,7 @@ #define MAX_USEC64 1000000ULL #define MAX_USEC 1000000.0 -#define TIMER_PROCESS 8 -#define TIMER_ENABLE 4 +#define TIMER_PROCESS 4 #define TIMER_SPLIT 2 #define TIMER_ENABLED 1 @@ -119,7 +118,7 @@ timer_is_enabled(pc_timer_t *timer) return !!(timer->flags & TIMER_ENABLED); } -/*True if timer currently enabled*/ +/*True if timer currently on*/ static __inline int timer_is_on(pc_timer_t *timer) { @@ -213,17 +212,12 @@ timer_process_inline(void) timer_head->prev = NULL; timer->next = timer->prev = NULL; - timer->flags |= TIMER_PROCESS; + timer->flags &= ~TIMER_ENABLED; if (timer->flags & TIMER_SPLIT) timer_advance_ex(timer, 0); /* We're splitting a > 1 s period into multiple <= 1 s periods. */ else if (timer->callback != NULL) /* Make sure it's no NULL, so that we can have a NULL callback when no operation is needed. */ timer->callback(timer->priv); - - if (timer->flags |= TIMER_ENABLE) - timer->flags = (timer->flags & ~TIMER_ENABLE) | TIMER_ENABLED; - else - timer->flags &= ~TIMER_ENABLED; } timer_target = timer_head->ts.ts32.integer; diff --git a/src/timer.c b/src/timer.c index a2a4dc87a..90ee3ca49 100644 --- a/src/timer.c +++ b/src/timer.c @@ -29,10 +29,7 @@ timer_enable(pc_timer_t *timer) if (timer->next || timer->prev) fatal("timer_enable - timer->next\n"); - if (timer->flags & TIMER_PROCESS) - timer->flags = (timer->flags & ~TIMER_PROCESS) | TIMER_ENABLE; - else - timer->flags |= TIMER_ENABLED; + timer->flags |= TIMER_ENABLED; /*List currently empty - add to head*/ if (!timer_head) { @@ -121,17 +118,15 @@ timer_process(void) timer_head->prev = NULL; timer->next = timer->prev = NULL; - timer->flags |= TIMER_PROCESS; + timer->flags &= ~TIMER_ENABLED; if (timer->flags & TIMER_SPLIT) timer_advance_ex(timer, 0); /* We're splitting a > 1 s period into multiple <= 1 s periods. */ - else if (timer->callback != NULL) /* Make sure it's no NULL, so that we can have a NULL callback when no operation is needed. */ + else if (timer->callback != NULL) {/* Make sure it's no NULL, so that we can have a NULL callback when no operation is needed. */ + timer->flags |= TIMER_PROCESS; timer->callback(timer->priv); - - if (timer->flags |= TIMER_ENABLE) - timer->flags = (timer->flags & ~TIMER_ENABLE) | TIMER_ENABLED; - else - timer->flags &= ~TIMER_ENABLED; + timer->flags &= ~TIMER_PROCESS; + } } timer_target = timer_head->ts.ts32.integer; @@ -240,7 +235,7 @@ timer_on_auto(pc_timer_t *timer, double period) return; if (period > 0.0) - timer_on(timer, period, !(timer->flags & TIMER_ENABLED) && (timer->period == 0.0)); + timer_on(timer, period, !(timer->flags & TIMER_PROCESS) && (timer->period <= 0.0)); else timer_stop(timer); }