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.
Matias26157 says:
Aug 28th 2022
Great Progress.
Silvertimmy26 says:
Aug 28th 2022
Great to hear! Very excited for the future of DS emulator multiplayer.
Jay says:
Aug 28th 2022
Another update, another day happy.
Nixel says:
Aug 29th 2022
Would the BSD socket add a lot of additional "maintenance"? Usually, when it comes to emulators, I think it's best to make any trade-off a choice for the user, but if that means future development would be much harder or slower, then I understand if you might only choose one to implement.
J.J. says:
Aug 29th 2022
Awesome! im looking for to playing some diddy kong racing DS with a group of friends sometime in the future and i appreciate all the hard work your putting into this project
carla:3 says:
Aug 30th 2022
yes , another day happy
https://www.youtube.com/watch?v=UhTl62q2o5k
bu says:
Aug 30th 2022
so happy for the progress, and good work, you have some serious skill Ari
poudink says:
Aug 31st 2022
I check in to find half a dozen brand new wifi progress reports and apparently stable wifi having finally been achieved. To me this always kinda felt like the final boss for melonDS, since the support introduced in 0.4 was really clunky and yet nobody seemed to really be able to improve it, but it's finally been done. Amazing work.
shade-lich says:
Aug 31st 2022
oh god my dream before i die is to be able to play megaman battle network 5 double team ds online tell me that dream is about to come true 😖 😭
YoungNutJC says:
Sep 2nd 2022
Once this update is released will it be available for Android?
Generic aka RSDuck says:
Sep 2nd 2022
the Android port is done by someone else, we don't have any control over it.
Trajan says:
Sep 3rd 2022
Cool!1! qB^)>@
somelinuxer says:
Sep 6th 2022
I have to ask, what about DLP? I think mario party DS only supports DLP and not same-cart local multiplayer, as well as some other games.
poudink says:
Sep 6th 2022
This local multiplayer upgrade should improve both dlp and multicart multiplayer the same.
somelinuxer says:
Sep 6th 2022
sick, ty for the info poud
Post a comment
Name:
DO NOT TOUCH