Tweaked PIT GATE handling, fixes Lemmings 2.

This commit is contained in:
TomW 2015-10-18 15:35:56 +01:00
commit 71a2af82c4

View file

@ -139,7 +139,7 @@ static void pit_load(int t)
break; break;
} }
pit.initial[t] = 0; pit.initial[t] = 0;
pit.running[t] = pit.enabled[t] && pit.using_timer[t]; pit.running[t] = pit.enabled[t] && pit.using_timer[t] && !pit.disabled[t];
timer_update_outstanding(); timer_update_outstanding();
// pclog("pit_load: t=%i running=%i thit=%i enabled=%i m=%i l=%x c=%g gate=%i\n", t, pit.running[t], pit.thit[t], pit.enabled[t], pit.m[t], pit.l[t], pit.c[t], pit.gate[t]); // pclog("pit_load: t=%i running=%i thit=%i enabled=%i m=%i l=%x c=%g gate=%i\n", t, pit.running[t], pit.thit[t], pit.enabled[t], pit.m[t], pit.l[t], pit.c[t], pit.gate[t]);
} }
@ -149,8 +149,11 @@ void pit_set_gate(int t, int gate)
int l = pit.l[t] ? pit.l[t] : 0x10000; int l = pit.l[t] ? pit.l[t] : 0x10000;
if (pit.disabled[t]) if (pit.disabled[t])
{
pit.gate[t] = gate;
return; return;
}
timer_process(); timer_process();
switch (pit.m[t]) switch (pit.m[t])
{ {
@ -191,7 +194,7 @@ void pit_set_gate(int t, int gate)
break; break;
} }
pit.gate[t] = gate; pit.gate[t] = gate;
pit.running[t] = pit.enabled[t] && pit.using_timer[t]; pit.running[t] = pit.enabled[t] && pit.using_timer[t] && !pit.disabled[t];
timer_update_outstanding(); timer_update_outstanding();
// pclog("pit_set_gate: t=%i gate=%i\n", t, gate); // pclog("pit_set_gate: t=%i gate=%i\n", t, gate);
} }
@ -268,7 +271,7 @@ static void pit_over(int t)
pit.c[t] += (int)((0xffff << TIMER_SHIFT) * PITCONST); pit.c[t] += (int)((0xffff << TIMER_SHIFT) * PITCONST);
break; break;
} }
pit.running[t] = pit.enabled[t] && pit.using_timer[t]; pit.running[t] = pit.enabled[t] && pit.using_timer[t] && !pit.disabled[t];
} }
int pit_get_timer_0() int pit_get_timer_0()
@ -519,7 +522,7 @@ void pit_set_using_timer(int t, int using_timer)
if (!pit.using_timer[t] && using_timer) if (!pit.using_timer[t] && using_timer)
pit.c[t] = (int)((pit.count[t] << TIMER_SHIFT) * PITCONST); pit.c[t] = (int)((pit.count[t] << TIMER_SHIFT) * PITCONST);
pit.using_timer[t] = using_timer; pit.using_timer[t] = using_timer;
pit.running[t] = pit.enabled[t] && pit.using_timer[t]; pit.running[t] = pit.enabled[t] && pit.using_timer[t] && !pit.disabled[t];
timer_update_outstanding(); timer_update_outstanding();
} }