Ian wrote:That's a classic problem with emulation. Normally processors etc work in parallel off the same clock or similar clocks. But in emulation things are generally run serially.
Does irq5 trigger the send/receive functions? I see in scud it sends two distinct packets every frame.
We already know that the master netboard waits for IRQ5 before starting the test data loop - or at least it's supposed to. In our current implementation, the master netboard doesn't actually wait for IRQ5 because the flag is already set; IRQ5 was already fired twice in the previous frame!
At the moment we only fire IRQ4 after an IRQ5 ack, rather than after sending data which would be the correct behaviour, but this is actually what manages to keep the netboards from desynchronizing altogether. Each netboard waits for IRQ4 twice per loop (once for the test data, once more for the game data), meaning they effectively wait for IRQ5 twice per loop as well. Because IRQ5 is fired twice before the loop ends, the IRQ5 flag is already set when the master netboard checks it.
Here's the main master loop as currently implemented:
wait for IRQ5 flag to be set (no wait, as IRQ5 already happened twice)
clear IRQ5 flag
send/receive test data
wait for IRQ4 (happens after IRQ5)
wait for IRQ6
send/receive game data
wait for IRQ4 (happens after IRQ5)
wait for IRQ6
Here's the main slave loop:
receive test data
wait for IRQ6
send test data
wait for IRQ4 (happens after IRQ5)
send/receive game data
wait for IRQ4 (happens after IRQ5)
wait for IRQ6
I was actually able to get Daytona 2 running at full speed (almost; Daytona 2 single-threaded is quite demanding) by hacking the netboard code to skip a couple of IRQ5 waits, thus ensuring the netboards remained properly synchronized.
Back when I was trying to improve the emulated netboard (before starting work on the simulated netboard), I made it so that all of the IRQs were fired accurately (IRQ4 after sending, IRQ6 after receiving) but it ended up breaking the emulation; the netboards would desynchronize because the slave netboard never waited for IRQ5. The issue was how to get the slave to wait for data if it was not due to arrive until the next IRQ5, and that's what
my latest idea is meant to address.
At the moment I'm busy working on the simulated netboard to make it SVN-ready, but at some point afterwards I might try implementing my idea.