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