-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renewing design to support retransmission and multiple messages per f…
…rame
- Loading branch information
Showing
46 changed files
with
7,888 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
build/ | ||
# Directories | ||
build | ||
.vscode | ||
|
||
# Files | ||
*.elf | ||
*.gba | ||
*.sav | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../lib/LinkConnection.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include <tonc.h> | ||
|
||
#include <string> | ||
|
||
// (0) Include the header | ||
#include "../lib/LinkConnection.h" | ||
|
||
void log(std::string text); | ||
|
||
// (1) Create a LinkConnection instance | ||
LinkConnection* linkConnection = new LinkConnection(); | ||
|
||
void init() { | ||
REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; | ||
tte_init_se_default(0, BG_CBB(0) | BG_SBB(31)); | ||
|
||
irq_init(NULL); | ||
|
||
// (2) Add the interrupt service routines | ||
irq_add(II_VBLANK, LINK_ISR_VBLANK); | ||
irq_add(II_SERIAL, LINK_ISR_SERIAL); | ||
} | ||
|
||
int main() { | ||
init(); | ||
|
||
u16 data[LINK_MAX_PLAYERS]; | ||
|
||
while (1) { | ||
// (3) Send/read messages messages | ||
u16 keys = ~REG_KEYS & KEY_ANY; | ||
u16 message = (keys << 1) | 1; | ||
linkConnection->send(message); | ||
auto linkState = linkConnection->linkState.get(); | ||
|
||
std::string output = ""; | ||
if (linkState->isConnected()) { | ||
output += "Players: " + std::to_string(linkState->playerCount) + "\n"; | ||
|
||
for (u32 i = 0; i < linkState->playerCount; i++) { | ||
while (linkState->hasMessage(i)) | ||
data[i] = linkState->readMessage(i) >> 1; | ||
|
||
output += "Player " + std::to_string(i) + ": " + | ||
std::to_string(data[i]) + "\n"; | ||
} | ||
|
||
output += "_sent: " + std::to_string(message) + "\n"; | ||
output += "_self pID: " + std::to_string(linkState->currentPlayerId); | ||
} else | ||
output += std::string("Waiting..."); | ||
log(output); | ||
|
||
VBlankIntrWait(); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
void log(std::string text) { | ||
tte_erase_screen(); | ||
tte_write("#{P:0,0}"); | ||
tte_write(text.c_str()); | ||
} |
Oops, something went wrong.