core, add TH pad pin latency (regression after 5 min)

This commit is contained in:
kub 2022-10-03 08:41:37 +00:00
parent 66e9abff6d
commit e05680a2b9

View file

@ -328,7 +328,11 @@ static NOINLINE u32 port_read(int i)
// disables output before doing TH-low read, so don't emulate it for TH. // disables output before doing TH-low read, so don't emulate it for TH.
// Decap Attack reportedly doesn't work on Nomad but works on must // Decap Attack reportedly doesn't work on Nomad but works on must
// other MD revisions (different pull-up strength?). // other MD revisions (different pull-up strength?).
u32 mask = 0x3f | (padTHLatency[i] < SekCyclesDone() ? 0x40 : 0); u32 mask = 0x3f;
if (CYCLES_GE(SekCyclesDone(), padTHLatency[i])) {
mask |= 0x40;
padTHLatency[i] = SekCyclesDone();
}
out |= mask & ~ctrl_reg; out |= mask & ~ctrl_reg;
in = port_readers[i](i, out); in = port_readers[i](i, out);
@ -407,10 +411,13 @@ NOINLINE void io_ports_write(u32 a, u32 d)
Pico.m.padTHPhase[a - 1]++; Pico.m.padTHPhase[a - 1]++;
} }
// after pulling down TH there's a latency before the new value can be read // after switching TH to input there's a latency before the pullup value is
// back as input (see Decap Attack, not in Samurai Showdown, 32x WWF Raw) // read back as input (see Decap Attack, not in Samurai Showdown, 32x WWF Raw)
if (a >= 4 && a <= 5 && !(d & 0x40)) if (a >= 4 && a <= 5) {
padTHLatency[a - 4] = SekCyclesDone() + 25; padTHLatency[a - 4] = SekCyclesDone(); // if output, effective immediately
if ((PicoMem.ioports[a] & 0x40) && !(d & 0x40))
padTHLatency[a - 4] += 25; // latency after switching to input
}
// certain IO ports can be used as RAM // certain IO ports can be used as RAM
PicoMem.ioports[a] = d; PicoMem.ioports[a] = d;