The SGADE Documentation

the SGADE 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.


Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

SoMultiPlayer.c File Reference

#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.


Detailed Description

Copyright (C) 2002 by the SGADE authors For conditions of distribution and use, see copyright notice in SoLicense.txt

Author:
Jaap Suter
Date:
March 7 2002
See the SoMultiPlayer module for more information.


Define Documentation

#define SO_MULTI_PLAYER_REG_RCNT
 

Used in this file only.

For internal use only.

#define SO_MULTI_PLAYER_REG_SIO_CNT
 

Used in this file only.

For internal use only.

#define SO_MULTI_PLAYER_REG_SIO_RECEIVE
 

Used in this file only.

For internal use only.

#define SO_MULTI_PLAYER_REG_SIO_SEND
 

Used in this file only.

For internal use only.

#define SO_MULTI_PLAYER_REG_SIO_TIMER_CNT
 

Used in this file only.

For internal use only.

#define SO_MULTI_PLAYER_REG_SIO_TIMER_DATA
 

Used in this file only.

For internal use only.


Function Documentation

void SoInterruptMultiPlayerSetup void   
 

Communication interrupt handler used during setup;.

For internal use only.

void SoInterruptMultiPlayerTransfer void   
 

Communication transfer interrupt routine.

For internal use only.

This routine is called everytime a single register transfer is finished.


Variable Documentation

u16* m_CurrentIncomingPacket[ 4 ]
 

These are the four packets that will be filled with the incoming data.

u16* m_CurrentOutGoingPacket
 

This is the packet that is send away during a transfer;.

SoMultiPlayerFailureCallback m_FailureCallback
 

Function that is called when communication fails;.

s8 m_ID
 

Identifier of the GBA, 0 for the master, 1, 2 or 3 for slaves, negative when no multiplayer s_Session is active;.

u16 m_IncomingPackets[ 2 ][ 4 ][ SO_MULTI_PLAYER_PACKET_TRANSFER_SIZE ]
 

The previous two arrays of pointers will point in this buffer, and swapped everytime a packet transfer is complete;.

u16* m_NextOutGoingPacket
 

This is the packet that is loaded with the data you want to send;.

u8 m_NumPlayers
 

Number of AGB's connected to eachother. Can be 0, 2, 3 or 4.

u16 m_OutGoingPackets[ 2 ][ SO_MULTI_PLAYER_PACKET_TRANSFER_SIZE ]
 

The previous two pointers will point into this array, and be every time a packet transfer is completed.

u16* m_PrevIncomingPacket[ 4 ]
 

These are the four packets that were filled during a previous transfer.

s32 m_TransferCount
 

Number of transfers done for current packet, -1 if no transfer is going on;.

bool s_Initialized [static]
 

To prevent multiple initialization.

For internal use only.

struct { ... } s_Session [static]
 

Structure containing info about a multiplayer s_Session, for a particular GBA;.

For internal use only.

const u16 SO_MULTI_PLAYER_MAGIC_NUMBER [static]
 

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;

const u16 SO_MULTI_PLAYER_SIO_TIMER_COUNT [static]
 

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;


Copyright 2002 by the SGADE authors. See SoLicense.h or Visit the SGADE page for more information.