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
{
retry = 0;
for (c = 0; c < timers_present; c++) for (c = 0; c < timers_present; c++)
{ {
enable[c] = *timers[c].enable;
if (*timers[c].enable) if (*timers[c].enable)
{ {
*timers[c].count = *timers[c].count - (diff << TIMER_SHIFT); *timers[c].count = *timers[c].count - (diff << TIMER_SHIFT);
if (*timers[c].count <= 0) if (*timers[c].count <= 0)
timers[c].callback(timers[c].priv); process = 1;
if (*timers[c].count <= 0)
retry = 1;
} }
} }
diff = 0;
if (!process)
return;
while (1)
{
int lowest = 1, lowest_c;
for (c = 0; c < timers_present; c++)
{
if (enable[c])
{
if (*timers[c].count < lowest)
{
lowest = *timers[c].count;
lowest_c = c;
}
}
}
if (lowest > 0)
break;
timers[lowest_c].callback(timers[lowest_c].priv);
enable[lowest_c] = *timers[lowest_c].enable;
} }
while (retry);
} }
void timer_update_outstanding() void timer_update_outstanding()