mirror of
https://github.com/afska/gba-link-connection.git
synced 2026-10-02 22:06:45 -05:00
d58f24c6d2a6c844ac1a5d0fef105b35165a8286
gba-link-connection
A Game Boy Advance (GBA) Link Cable library to add multiplayer support to homebrew games. It provides easy-to-use C++ classes to interact with the Serial Port:
- 🎮 LinkCable.h: The classic 16-bit Multi-Player mode (up to 4 players)!
- 💻 LinkCableMultiboot.h: Send Multiboot software (small 256KiB ROMs) to other GBAs with no cartridge!
- 🔌 LinkGPIO.h: Use the Link Port however you want to control any device (like LEDs, rumble motors, and that kind of stuff)!
- 🔗 LinkSPI.h: Connect with a PC (like a Raspberry Pi) using this mode. Transfer up to 2Mbit/s!
- 📻 LinkWireless.h: Connect up to 5 consoles with the Wireless Adapter!
- 📡 LinkWirelessMultiboot.h: Send Multiboot software to other GBAs over the air!
LinkCable
The library uses message queues to send/receive data and transmits when it's possible. As it uses CPU interrupts, the connection is alive even if a console drops a frame or gets stucked in a long iteration loop. After such event, all nodes end up receiving all the pending messages, so a lockstep communication protocol can be used.
Usage
- Include LinkCable.h in your game code, and read its comment for instructions.
- Check out the examples folder
- Builds are available in Releases.
- They can be tested on real GBAs or using emulators (NO$GBA, mGBA, or VBA-M).
Constructor options
new LinkCable(...) accepts these optional parameters:
| Name | Type | Default | Description |
|---|---|---|---|
baudRate |
BaudRate | BaudRate::BAUD_RATE_1 |
Sets a specific baud rate. |
timeout |
u32 | 3 |
Number of frames without an II_SERIAL IRQ to reset the connection. |
remoteTimeout |
u32 | 5 |
Number of messages with 0xFFFF to mark a player as disconnected. |
bufferSize |
u32 | 30 |
Number of messages that the queues will be able to store. |
interval |
u16 | 50 |
Number of 1024cycles (61.04μs) ticks between messages (50 = 3,052ms). It's the interval of Timer #sendTimerId. |
sendTimerId |
u8 (0~3) | 3 |
GBA Timer to use for sending. |
Methods
| Name | Return type | Description |
|---|---|---|
isActive() |
bool | Returns whether the library is active or not. |
activate() |
- | Activates the library. |
deactivate() |
- | Deactivates the library. |
isConnected() |
bool | Returns true if there are at least 2 connected players. |
playerCount() |
u8 (0~4) | Returns the number of connected players. |
currentPlayerId() |
u8 (0~3) | Returns the current player id. |
canRead(playerId) |
bool | Returns true if there are pending messages from player #playerId. |
read(playerId) |
u16 | Returns one message from player #playerId. |
consume() |
- | Marks the current data as processed, enabling the library to fetch more. |
send(data) |
- | Sends data to all connected players. |
Makefile actions
make cleanmake buildmake startmake rebuildmake restart
Description
🔗 A set of Game Boy Advance (GBA) C++ libraries to interact with the Serial Port. Its main purpose is to provide multiplayer support to homebrew games.
adaptercablegameboy-advancegbagpiohomebrewhomebrew-gameslinkmultibootmultiplayerserialserialportspiuartwirelesswireless-adapter
Readme
MIT
10 MiB
Languages
C++
89.7%
C
10.3%
