The local multiplayer saga, ep 9
In the previous post I said the slowdown problems in multiplayer games were fixed, but actually, they weren't. Oops.

I looked deeper into the issue. I couldn't let that slip. But I also didn't really have an idea what could be causing it or where to begin looking.

I thought about bit0 in USCOMPARE, again. Basically, when they're connected to a host and receiving beacons from it, games do that weird little dance where they take the beacon's timestamp value, add some offset to it, and write that to USCOMPARE, with bit0 set.

A bit of background. In the DS wifi module, there are two ways of triggering IRQ14: BEACON_COUNT and USCOMPARE. The former triggers IRQ14 every time the BEACON_COUNT timer reaches zero, the latter triggers it when USCOUNT matches USCOMPARE. All fine and dandy.

Back then, I had done hardware tests to figure out what bit0 in USCOMPARE does, given it's a special write-only bit. I had observed that it blocks BEACON_COUNT from triggering IRQ14 until USCOUNT matches USCOMPARE, effectively ensuring that the next IRQ14 will be triggered by USCOMPARE.

But that still didn't quite make sense. Here, the value written to USCOMPARE was based off the beacon's timestamp, which was basically the host's USCOUNT register, which was obviously different than the client's. So I couldn't really see what that was supposed to achieve.

Yesterday, as I went to bed, I had an idea. What if, when receiving a beacon frame with the right BSSID, the DS automatically sets its USCOUNT register to the beacon's timestamp?

But you'd think that sounds far-fetched? I thought so too.

I tested it anyway this morning. Guess what I found out?

The DS does exactly that.

Hahah.

And implementing that in melonDS got rid of the slowdown problem. Local multiplayer connections are now smooth as butter.

To make the whole experience equally smooth, I'm also in the process of ironing out the kinks that may happen when trying to connect multiple games together. Turns out, some games do a bunch of weird shit, and I need to make my comm layer resilient to that.

Also, since the BSD-socket interface was brought up in the comments to the last post: I'm thinking of bringing it back, but now there are some issues to that. The shared-memory interface was originally a simple dumb comm layer akin to the BSD-socket interface. But, as I worked to iron out the kinks in multiplayer connections, I had to add in some extra intelligence to avoid hitting timeouts and causing lag as much as possible. A lot of it works due to the availability of a shared memory space, and would be difficult to port to the BSD-socket interface. So, while it could be brought back and updated to work again, it may be suboptimal under certain circumstances.
s7_ says:
Sep 6th 2022
Mario Party DS has a debug mode that you can find on the cutting room floor website that you can enable on MelonDS where you can start a multiplayer game through MultiCart, the big downside and the reason why I think it wasn't in the final game is because it replaces all of the connecting players' saves with the Host's. Although it comes with the benefit of having load times being near instantaneous.
Guest says:
Sep 6th 2022
Looking at the CMake build flags, I see an option for enabling JIT profiling with Intel's VTune.

Would there be any point in enabling this flag if I am not going to analyze the runtime code?
hoangson says:
Sep 7th 2022
If local multiplayer is the final boss, then DSi-enhanced games/running TWiLightMenu would be the true final boss.
poudink says:
Sep 7th 2022
Do both of those things not already work? I thought most of the work remaining for DSi emulation had to do with the camera and the DSP.
EDIT: I can't test it right now, but a recent melonDS commit says
basic implementation of SNDExCnt

isn't hooked up to the DSP or microphone though
fixes memory abort in TwilightMenu

so if it is broken it might have bern fixed by that
EDIT2: yeah, seems like it's working at least partially now according to this https://github.com/melonDS-emu/melonDS/issues/1098
also, what did you mean by DSi enhanced games? think melonDS has been able to launch games in DSi mode since DSi emulation was introduced in 0.9. Though, most DSi enhanced titles use the DSi camera which isn't supported yet.
Mith says:
Sep 28th 2022
For the last couple of days I've been able to enjoy dragon quest IX with 2 of my friends via parsec. We've been wanting to play this game together since over a year ago, but haven't been able to. So far it's working surprisingly well for us, especially considering that this feature is still in development. Thank you for all the work that made this possible!
Post a comment
Name:
DO NOT TOUCH