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.
#include "SoMultiPlayer.h"#include "SoDMA.h"#include "SoIntManager.h"#include "SoSystem.h"#include "SoDebug.h"Defines | |
| #define | SO_MULTI_PLAYER_REG_RCNT |
| Used in this file only. | |
| #define | SO_MULTI_PLAYER_REG_SIO_CNT |
| Used in this file only. | |
| #define | SO_MULTI_PLAYER_REG_SIO_SEND |
| Used in this file only. | |
| #define | SO_MULTI_PLAYER_REG_SIO_RECEIVE |
| Used in this file only. | |
| #define | SO_MULTI_PLAYER_REG_SIO_TIMER_CNT |
| Used in this file only. | |
| #define | SO_MULTI_PLAYER_REG_SIO_TIMER_DATA |
| Used in this file only. | |
Functions | |
| void | SoInterruptMultiPlayerSetup (void) |
| Communication interrupt handler used during setup;. | |
| void | SoInterruptMultiPlayerTransfer (void) |
| Communication transfer interrupt routine. | |
| void | SoMultiPlayerInitialize (void) |
| Initializes the multi player system;. | |
| 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. | |
| 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. | |
| u32 | SoMultiPlayerGetID (void) |
| Returns the ID of this GBA in a multiplayer session. | |
| u32 | SoMultiPlayerGetNumPlayers (void) |
| Returns the number of players in this s_Session. | |
Variables | |
| const u16 | SO_MULTI_PLAYER_MAGIC_NUMBER |
| const u16 | SO_MULTI_PLAYER_SIO_TIMER_COUNT |
| Master communciation interrupt timer-wait setting;. | |
| struct { | |
| s32 m_TransferCount | |
| u8 m_NumPlayers | |
| s8 m_ID | |
| SoMultiPlayerFailureCallback m_FailureCallback | |
| u16 * m_CurrentOutGoingPacket | |
| u16 * m_NextOutGoingPacket | |
| u16 m_OutGoingPackets [2][SO_MULTI_PLAYER_PACKET_TRANSFER_SIZE] | |
| u16 * m_CurrentIncomingPacket [4] | |
| u16 * m_PrevIncomingPacket [4] | |
| u16 m_IncomingPackets [2][4][SO_MULTI_PLAYER_PACKET_TRANSFER_SIZE] | |
| } | s_Session |
| Structure containing info about a multiplayer s_Session, for a particular GBA;. | |
| bool | s_Initialized |
| To prevent multiple initialization. | |
|
|
Used in this file only.
For internal use only.
|
|
|
Used in this file only.
For internal use only.
|
|
|
Used in this file only.
For internal use only.
|
|
|
Used in this file only.
For internal use only.
|
|
|
Used in this file only.
For internal use only.
|
|
|
Used in this file only.
For internal use only.
|
|
|
Communication interrupt handler used during setup;.
For internal use only.
|
|
|
Communication transfer interrupt routine.
For internal use only.
This routine is called everytime a single register transfer is finished. |
|
|
These are the four packets that will be filled with the incoming data.
|
|
|
This is the packet that is send away during a transfer;.
|
|
|
Function that is called when communication fails;.
|
|
|
Identifier of the GBA, 0 for the master, 1, 2 or 3 for slaves, negative when no multiplayer s_Session is active;.
|
|
|
The previous two arrays of pointers will point in this buffer, and swapped everytime a packet transfer is complete;.
|
|
|
This is the packet that is loaded with the data you want to send;.
|
|
|
Number of AGB's connected to eachother. Can be 0, 2, 3 or 4.
|
|
|
The previous two pointers will point into this array, and be every time a packet transfer is completed.
|
|
|
These are the four packets that were filled during a previous transfer.
|
|
|
Number of transfers done for current packet, -1 if no transfer is going on;.
|
|
|
To prevent multiple initialization.
For internal use only.
|
|
|
Structure containing info about a multiplayer s_Session, for a particular GBA;.
For internal use only.
|
|
|
For internal use only. The following magic number is send to all AGB's when the s_Session starts (to decipher what m_ID each GBA has), or when a packet transfer starts (to synchronize). Number can't be 0xFFFF or 0x0; |
|
|
Master communciation interrupt timer-wait setting;.
For internal use only.
This number specifies the amount of clockcyles the master waits before it initiates another 16 bit transfer; |