From: kub Date: Mon, 3 Oct 2022 08:41:37 +0000 (+0000) Subject: core, add TH pad pin latency (regression after 5 min) X-Git-Tag: v2.00~286 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e05680a2b9bd5e079aa29a0c39c03cc9b90c5911;p=picodrive.git core, add TH pad pin latency (regression after 5 min) --- diff --git a/pico/memory.c b/pico/memory.c index 860dfed1..2ca6f2c2 100644 --- a/pico/memory.c +++ b/pico/memory.c @@ -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. // Decap Attack reportedly doesn't work on Nomad but works on must // 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; in = port_readers[i](i, out); @@ -407,10 +411,13 @@ NOINLINE void io_ports_write(u32 a, u32 d) Pico.m.padTHPhase[a - 1]++; } - // after pulling down TH there's a latency before the new value can be read - // back as input (see Decap Attack, not in Samurai Showdown, 32x WWF Raw) - if (a >= 4 && a <= 5 && !(d & 0x40)) - padTHLatency[a - 4] = SekCyclesDone() + 25; + // after switching TH to input there's a latency before the pullup value is + // read back as input (see Decap Attack, not in Samurai Showdown, 32x WWF Raw) + if (a >= 4 && a <= 5) { + 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 PicoMem.ioports[a] = d;