Timers now always processed in correct order. Fixes sound in Lion King and probably some other timing related issues.

This commit is contained in:
TomW 2015-09-12 14:54:40 +01:00
commit 276650c145

View file

@ -31,29 +31,49 @@ void timer_process()
{ {
int c; int c;
int retry; int retry;
int process = 0;
/*Get actual elapsed time*/ /*Get actual elapsed time*/
int diff = timer_latch - timer_count; int diff = timer_latch - timer_count;
int enable[TIMERS_MAX];
timer_latch = 0; timer_latch = 0;
do for (c = 0; c < timers_present; c++)
{ {
retry = 0; enable[c] = *timers[c].enable;
for (c = 0; c < timers_present; c++) if (*timers[c].enable)
{ {
if (*timers[c].enable) *timers[c].count = *timers[c].count - (diff << TIMER_SHIFT);
if (*timers[c].count <= 0)
process = 1;
}
}
if (!process)
return;
while (1)
{
int lowest = 1, lowest_c;
for (c = 0; c < timers_present; c++)
{
if (enable[c])
{ {
*timers[c].count = *timers[c].count - (diff << TIMER_SHIFT); if (*timers[c].count < lowest)
if (*timers[c].count <= 0) {
timers[c].callback(timers[c].priv); lowest = *timers[c].count;
if (*timers[c].count <= 0) lowest_c = c;
retry = 1; }
} }
} }
diff = 0;
} if (lowest > 0)
while (retry); break;
timers[lowest_c].callback(timers[lowest_c].priv);
enable[lowest_c] = *timers[lowest_c].enable;
}
} }
void timer_update_outstanding() void timer_update_outstanding()