gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > multiplayer questions

#28706 - greyboy - Thu Nov 04, 2004 9:01 pm

Hello,

I just have a few questions about multiplayer which I thought I'd toss out there. I was taking a look at sgade's multiplayer module.

1) Now, this might be just how sgade chose to implement their multiplayer library, but...are packets broadcast to every gba (assume 4 connected), or are they sent specifically to targetted receivers?

2) at 60 fps, and 4 players, how many bytes of data can I anticipate sending each frame, i.e. how much data can each gba package up and send per frame.

3) If I want to make a 4-player twitch game, is the general correct approach to record the input of your gba on frame 0 and transmit that data at the end of your processing loop (before the vsync() to copy your data to hardware just before rendering). Then, process the resultant effect of everyone's (including your) input in frame zero at once during frame 1? Does my question make sense? :)

Pointers to good tutorials on this (i've found sgade, thanks) would be great.

Thanks.

#28738 - ScottLininger - Fri Nov 05, 2004 6:08 am

greyboy wrote:
1) Now, this might be just how sgade chose to implement their multiplayer library, but...are packets broadcast to every gba (assume 4 connected), or are they sent specifically to targetted receivers?


At the hardware level there are four 16bit registers that handle the data transfer. Each gameboy in the chain has write access to one of these (via a fifth register), and read access to the other three. But only the master gameboy can send the "update all" command that shares the values out to everyone.

So yeah, anytime a value is broadcast it goes to all of the other gameboys.

A "packet" is really a higher level construct... your software could be written to handle it as a "send from A to B" or "send to all" or even a client/server model. SGADE is the "send to all" model, if I remember right.

Quote:
2) at 60 fps, and 4 players, how many bytes of data can I anticipate sending each frame, i.e. how much data can each gba package up and send per frame.


I really don't know. My multiplayer code performs fast enough to exchange about 20bytes of data between two gameboys at a rate that's okay for twitch games like pong... but it's definitely not exhanging that 60 times per second. I haven't actually tested to see how many wasted frames happen during the transfer.

Anyway, my code doesn't even use proper packets with checksums and stuff... it will only transfer a byte once it's been echoed back from every client. That's considerably slower than doing it "the right way," and yet it's fast enough that it works for pong.

My point is that you can exchange a fair amount of data at a rate that's perfectly acceptable for twitch games.

Quote:
3) If I want to make a 4-player twitch game, is the general correct approach to record the input of your gba on frame 0 and transmit that data at the end of your processing loop (before the vsync() to copy your data to hardware just before rendering). Then, process the resultant effect of everyone's (including your) input in frame zero at once during frame 1? Does my question make sense? :)


Good question. Personally, I think it makes more sense for the master gameboy to maintain the game state, period. The other gameboys just send their button states back to the master, and the master updates everything and sends back out the status of the game.

No matter what library you're using, you're going to have challenges with dropped packets and gameboys that run slightly out of sync. If every gameboy is running it's own engine based on its own input, you'll have a nightmare getting it all to sync up perfectly.

I hope I understood the question. ;)

-Scott

#28743 - greyboy - Fri Nov 05, 2004 7:46 am

That's an awesome bit of info. I checked out the registers and it makes more sense now, but what is the baud rate used for? Why would you want to transfer anything at a slower rate ever?

#28744 - Krakken - Fri Nov 05, 2004 7:51 am

I have just opened a thread for a proposed packet management system. I'm waiting to get some feedback. Feel free to use it, it should go pretty fast as long as my thoerey is correct.

http://forum.gbadev.org/viewtopic.php?t=4342

#28751 - ScottLininger - Fri Nov 05, 2004 3:17 pm

greyboy wrote:
That's an awesome bit of info. I checked out the registers and it makes more sense now, but what is the baud rate used for? Why would you want to transfer anything at a slower rate ever?


This came up some time ago, and I think the conclusion was that the slower baud rates are only for serial communication with devices other than connected gameboys.

For multiplayer, max speed is best.

-Scott

#28813 - Miked0801 - Sat Nov 06, 2004 9:00 pm

Agreed. SLowing it down didn't improve error handling or error occurance, so we left it at highest.