The Socrates Gameboy Advance Development Engine
The SGADE is a development library for the Nintendo Gameboy
Advance. It's free for all uses and is distributed without guarantees.
For more information visit
the SGADE page.
Files | |
| file | SoMultiPlayer.c |
| file | SoMultiPlayer.h |
Defines | |
| #define | SO_MULTI_PLAYER_PACKET_TRANSFER_SIZE |
| Number of 16 bit transfers in a single packet. | |
| #define | SO_MULTIPLAYER_FRAME_RATE |
| Frame rate at which you want each packet transfer to be complete. | |
| #define | SO_MULTI_PLAYER_9600_BPS |
| Baud rate: 9600 bps. | |
| #define | SO_MULTI_PLAYER_38400_BPS |
| Baud rate: 38400 bps. | |
| #define | SO_MULTI_PLAYER_57600_BPS |
| Baud rate: 57600 bps. | |
| #define | SO_MULTI_PLAYER_115200_BPS |
| Baud rate: 115200 bps. | |
Typedefs | |
| typedef bool(* | SoMultiPlayerFailureCallback )(void) |
| Callback routine that is called whenever something is wrong with the communication. | |
Functions | |
| void | SoMultiPlayerInitialize (void) |
| Initializes the multi player system;. | |
| bool | SoMultiPlayerStart (u32 a_BaudRate, u32 a_NumPlayers) |
| Starts a multiplayer session. | |
| void | SoMultiPlayerStop () |
| Stops the current multiplayer s_Session. | |
| void | SoMultiPlayerUpdate (u16 a_OutGoingPacket[SO_MULTI_PLAYER_PACKET_TRANSFER_SIZE], u16 a_IncomingPackets[4][SO_MULTI_PLAYER_PACKET_TRANSFER_SIZE]) |
| Just call this every frame to handle all communication. | |
| void | SoMultiPlayerSetFailureCallback (SoMultiPlayerFailureCallback a_FailureCallback) |
| Sets the callback routine that is called whenever something is wrong with the communication either during setup, or during communication. | |
| u32 | SoMultiPlayerGetNumPlayers (void) |
| Returns the number of players in this s_Session. | |
| u32 | SoMultiPlayerGetID (void) |
| Returns the ID of this GBA in a multiplayer session. | |
This module is for the GBA's multiplayer system where you can transfer packets from and to up to three other GBAs. It supports extensive error detection, and handles all possible failure cases. You can send a fair amount of bytes each frame, and it's very stable. If you lose a packet, it's because a cable got disconnected, or because you connected a third GBA in a 2 player session (for example).
In short, it rocks, it's Nintendo guideline-compatible, and I suggest you use it. Cheers.
|
|
Number of 16 bit transfers in a single packet.
The packet size in bytes is twice this number. Don't make this package too big please, otherwise you won't be able to complete a single packet transfer in a single frame. At a framerate of 60hz, I've had success with transfer sizes up to 16 (32 bytes). Of course you should always be sending as few bits as possible anyway. |
|
|
Frame rate at which you want each packet transfer to be complete.
Of course this is related to the packet size you are using. If you have a large packet size you might not be able to complete it at 60 hz. Just fiddle with this value, and the SO_MULTI_PLAYER_PACKET_TRANSFER_SIZE value until you have a satisfactory result. I've sent up to 32 bytes (16 transfers) stable at 60 hz. But don't qoute me on that :) hehe. |
|
|
Callback routine that is called whenever something is wrong with the communication.
|
|
|
Returns the ID of this GBA in a multiplayer session.
|
|
|
Returns the number of players in this s_Session.
|
|
|
Initializes the multi player system;.
This should be the first SoMultiPlayer function you call. Multiple calls don't matter. |
|
|
Sets the callback routine that is called whenever something is wrong with the communication either during setup, or during communication.
|
|
||||||||||||
|
Starts a multiplayer session.
|
|
||||||||||||
|
Just call this every frame to handle all communication.
|