Formatting code

This commit is contained in:
Rodrigo Alfonso 2025-01-20 03:55:14 -03:00
parent 21a2b63618
commit 4da4c4996d
24 changed files with 165 additions and 142 deletions

View File

@ -304,19 +304,19 @@ https://github.com/afska/gba-link-connection/assets/1631752/9a648bff-b14f-4a85-9
- `startHost` = `0x19`
- `getSignalLevel` = `0x11`
- `getSlotStatus` = `0x14`
- `acceptConnections` = `0x1a`
- `endHost` = `0x1b`
- `broadcastReadStart` = `0x1c`
- `broadcastReadPoll` = `0x1d`
- `broadcastReadEnd` = `0x1e`
- `connect` = `0x1f`
- `acceptConnections` = `0x1A`
- `endHost` = `0x1B`
- `broadcastReadStart` = `0x1C`
- `broadcastReadPoll` = `0x1D`
- `broadcastReadEnd` = `0x1E`
- `connect` = `0x1F`
- `keepConnecting` = `0x20`
- `finishConnection` = `0x21`
- `sendData` = `0x24`
- `sendDataAndWait` = `0x25`
- `receiveData` = `0x26`
- `wait` = `0x27`
- `bye` = `0x3d`
- `bye` = `0x3D`
- Use `sendCommand(...)` to send arbitrary commands.
- Use `sendCommandAsync(...)` to send arbitrary commands asynchronously.
- This requires setting `LINK_RAW_WIRELESS_ISR_SERIAL` as the `SERIAL` interrupt handler.
@ -368,7 +368,7 @@ https://github.com/afska/gba-link-connection/assets/1631752/d1f49a48-6b17-4954-9
You can also change these compile-time constants:
- `LINK_UNIVERSAL_MAX_PLAYERS`: to set a maximum number of players. The default value is `5`, but since LinkCable's limit is `4`, you might want to decrease it.
- `LINK_UNIVERSAL_GAME_ID_FILTER`: to restrict wireless connections to rooms with a specific game ID (`0x0000` ~ `0x7fff`). The default value (`0`) connects to any game ID and uses `0x7fff` when serving.
- `LINK_UNIVERSAL_GAME_ID_FILTER`: to restrict wireless connections to rooms with a specific game ID (`0x0000` ~ `0x7FFF`). The default value (`0`) connects to any game ID and uses `0x7FFF` when serving.
## Methods

View File

@ -165,7 +165,7 @@ void handleP2P() {
outgoingData = linkMobile->getRole() == LinkMobile::Role::CALLER
? "caller!!!"
: "receiver!!!";
transfer(dataTransfer, outgoingData, 0xff, true);
transfer(dataTransfer, outgoingData, 0xFF, true);
}
if (dataTransfer.completed) {
@ -194,7 +194,7 @@ void handleP2P() {
if (frameCounter >= TRANSFER_FREQUENCY) {
// Transfer every N frames
frameCounter = 0;
transfer(dataTransfer, outgoingData, 0xff, true);
transfer(dataTransfer, outgoingData, 0xFF, true);
}
if (lastCompletedTransfer.completed) {
@ -605,6 +605,6 @@ template <typename I>
static const char* digits = "0123456789ABCDEF";
std::string rc(hex_len, '0');
for (size_t i = 0, j = (hex_len - 1) * 4; i < hex_len; ++i, j -= 4)
rc[i] = digits[(w >> j) & 0x0f];
rc[i] = digits[(w >> j) & 0x0F];
return rc;
}

View File

@ -213,17 +213,17 @@ void DebugScene::addCommandMenuOptions() {
commandMenuOptions.push_back(
CommandMenuOption{.name = "0x19 (StartHost)", .command = 0x19});
commandMenuOptions.push_back(
CommandMenuOption{.name = "0x1a (AcceptConnections)", .command = 0x1a});
CommandMenuOption{.name = "0x1A (AcceptConnections)", .command = 0x1A});
commandMenuOptions.push_back(
CommandMenuOption{.name = "0x1b (EndHost)", .command = 0x1b});
CommandMenuOption{.name = "0x1B (EndHost)", .command = 0x1B});
commandMenuOptions.push_back(
CommandMenuOption{.name = "0x1c (BroadcastReadStart)", .command = 0x1c});
CommandMenuOption{.name = "0x1C (BroadcastReadStart)", .command = 0x1C});
commandMenuOptions.push_back(
CommandMenuOption{.name = "0x1d (BroadcastReadPoll)", .command = 0x1d});
CommandMenuOption{.name = "0x1D (BroadcastReadPoll)", .command = 0x1D});
commandMenuOptions.push_back(
CommandMenuOption{.name = "0x1e (BroadcastReadEnd)", .command = 0x1e});
CommandMenuOption{.name = "0x1E (BroadcastReadEnd)", .command = 0x1E});
commandMenuOptions.push_back(
CommandMenuOption{.name = "0x1f (Connect)", .command = 0x1f});
CommandMenuOption{.name = "0x1F (Connect)", .command = 0x1F});
commandMenuOptions.push_back(CommandMenuOption{
.name = "0x20 (IsConnectionComplete)", .command = 0x20});
commandMenuOptions.push_back(
@ -253,7 +253,7 @@ void DebugScene::addCommandMenuOptions() {
commandMenuOptions.push_back(
CommandMenuOption{.name = "0x39 (?)", .command = 0x39});
commandMenuOptions.push_back(
CommandMenuOption{.name = "0x3d (Bye)", .command = 0x3d});
CommandMenuOption{.name = "0x3D (Bye)", .command = 0x3D});
}
void DebugScene::processKeys(u16 keys) {
@ -582,7 +582,7 @@ void DebugScene::processCommand(u32 selectedCommandIndex) {
return logOperation("sending " + name,
[]() { return linkRawWireless->startHost(); });
}
case 0x1a: {
case 0x1A: {
return logOperation("sending " + name, []() {
LinkRawWireless::AcceptConnectionsResponse response;
bool success = linkRawWireless->acceptConnections(response);
@ -600,7 +600,7 @@ void DebugScene::processCommand(u32 selectedCommandIndex) {
return success;
});
}
case 0x1b: {
case 0x1B: {
return logOperation("sending " + name, []() {
LinkRawWireless::AcceptConnectionsResponse response;
bool success = linkRawWireless->endHost(response);
@ -618,17 +618,17 @@ void DebugScene::processCommand(u32 selectedCommandIndex) {
return success;
});
}
case 0x1c: {
case 0x1C: {
return logOperation("sending " + name, []() {
bool success = linkRawWireless->broadcastReadStart();
if (success)
log("NOW CALL 0x1d!");
log("NOW CALL 0x1D!");
return success;
});
}
case 0x1d: {
case 0x1D: {
return logOperation("sending " + name, [this]() {
LinkRawWireless::BroadcastReadPollResponse response;
bool success = linkRawWireless->broadcastReadPoll(response);
@ -651,25 +651,25 @@ void DebugScene::processCommand(u32 selectedCommandIndex) {
}
if (response.serversSize > 0)
log("NOW CALL 0x1e!");
log("NOW CALL 0x1E!");
else
log("No rooms? NOW CALL 0x1e!");
log("No rooms? NOW CALL 0x1E!");
}
return success;
});
}
case 0x1e: {
case 0x1E: {
return logOperation("sending " + name, []() {
bool success = linkRawWireless->broadcastReadEnd();
if (success)
log("NOW CALL 0x1f!");
log("NOW CALL 0x1F!");
return success;
});
}
case 0x1f: {
case 0x1F: {
u16 serverId = selectServerId();
if (serverId == -1)
return;
@ -820,7 +820,7 @@ void DebugScene::processCommand(u32 selectedCommandIndex) {
case 0x38:
case 0x39:
goto generic;
case 0x3d:
case 0x3D:
goto simple;
default:
return;
@ -873,7 +873,7 @@ int DebugScene::selectGameId() {
"GameID?",
std::vector<std::string>{"0x7FFF", "0x1234", "<random>", "<pick>"})) {
case 0: {
return 0x7fff;
return 0x7FFF;
}
case 1: {
return 0x1234;

View File

@ -13,10 +13,10 @@ void setup() {
}
uint32_t transfer(uint32_t value) {
uint8_t a = (value >> 24) & 0xff;
uint8_t b = (value >> 16) & 0xff;
uint8_t c = (value >> 8) & 0xff;
uint8_t d = (value >> 0) & 0xff;
uint8_t a = (value >> 24) & 0xFF;
uint8_t b = (value >> 16) & 0xFF;
uint8_t c = (value >> 8) & 0xFF;
uint8_t d = (value >> 0) & 0xFF;
a = SPI.transfer(a);
b = SPI.transfer(b);
@ -28,7 +28,7 @@ uint32_t transfer(uint32_t value) {
}
void loop() {
uint32_t received = transfer(0xaabbccdd); // (2864434397)
uint32_t received = transfer(0xAABBCCDD); // (2864434397)
Serial.println(received);

View File

@ -21,10 +21,10 @@ uint8_t transferByte(uint8_t value) {
}
uint32_t transfer(uint32_t value) {
uint8_t a = (value >> 24) & 0xff;
uint8_t b = (value >> 16) & 0xff;
uint8_t c = (value >> 8) & 0xff;
uint8_t d = (value >> 0) & 0xff;
uint8_t a = (value >> 24) & 0xFF;
uint8_t b = (value >> 16) & 0xFF;
uint8_t c = (value >> 8) & 0xFF;
uint8_t d = (value >> 0) & 0xFF;
a = transferByte(a);
b = transferByte(b);
@ -36,7 +36,7 @@ uint32_t transfer(uint32_t value) {
}
void loop() {
uint32_t received = transfer(0xaabbccdd); // (2864434397)
uint32_t received = transfer(0xAABBCCDD); // (2864434397)
Serial.println(received);
}

View File

@ -257,7 +257,7 @@ void MultibootScene::processButtons() {
// (2) Send the ROM
auto result = linkWirelessMultiboot->sendRom(
romToSend, fileLength, "Multiboot", "Test", 0xffff, players,
romToSend, fileLength, "Multiboot", "Test", 0xFFFF, players,
[](LinkWirelessMultiboot::MultibootProgress progress) {
u16 keys = ~REG_KEYS & KEY_ANY;
if (keys & KEY_SELECT) {

View File

@ -58,7 +58,7 @@ class LinkCableMultiboot {
using u16 = Link::u16;
using u8 = Link::u8;
static constexpr int MIN_ROM_SIZE = 0x100 + 0xc0;
static constexpr int MIN_ROM_SIZE = 0x100 + 0xC0;
static constexpr int MAX_ROM_SIZE = 256 * 1024;
static constexpr int FRAME_LINES = 228;
static constexpr int INITIAL_WAIT_MIN_FRAMES = 4;
@ -67,7 +67,7 @@ class LinkCableMultiboot {
FRAME_LINES * INITIAL_WAIT_MIN_FRAMES;
static constexpr int DETECTION_TRIES = 16;
static constexpr int MAX_CLIENTS = 3;
static constexpr int CLIENT_NO_DATA = 0xff;
static constexpr int CLIENT_NO_DATA = 0xFF;
static constexpr int CMD_HANDSHAKE = 0x6200;
static constexpr int ACK_HANDSHAKE = 0x7200;
static constexpr int CMD_CONFIRM_CLIENTS = 0x6100;
@ -75,9 +75,10 @@ class LinkCableMultiboot {
static constexpr int HANDSHAKE_DATA = 0x11;
static constexpr int CMD_CONFIRM_HANDSHAKE_DATA = 0x6400;
static constexpr int ACK_RESPONSE = 0x7300;
static constexpr int ACK_RESPONSE_MASK = 0xff00;
static constexpr int HEADER_SIZE = 0xc0;
static constexpr int ACK_RESPONSE_MASK = 0xFF00;
static constexpr int HEADER_SIZE = 0xC0;
static constexpr int HEADER_PARTS = HEADER_SIZE / 2;
static constexpr int WAIT_BEFORE_MAIN_TRANSFER_FRAMES = 4;
static constexpr auto MAX_BAUD_RATE = LinkRawCable::BaudRate::BAUD_RATE_3;
struct Response {
@ -182,8 +183,8 @@ class LinkCableMultiboot {
success =
validateResponse(response, [&multiBootParameters](u32 i, u16 value) {
if ((value & 0xfff0) == ACK_HANDSHAKE) {
u8 clientId = value & 0xf;
if ((value & 0xFFF0) == ACK_HANDSHAKE) {
u8 clientId = value & 0xF;
u8 expectedClientId = 1 << (i + 1);
if (clientId == expectedClientId) {
multiBootParameters.client_bit |= clientId;
@ -277,7 +278,7 @@ class LinkCableMultiboot {
u8 clientBit = 1 << (i + 1);
if ((multiBootParameters.client_bit & clientBit) &&
((value & ACK_RESPONSE_MASK) == ACK_RESPONSE)) {
multiBootParameters.client_data[i] = value & 0xff;
multiBootParameters.client_data[i] = value & 0xFF;
sendMask &= ~clientBit;
return true;
}
@ -412,8 +413,8 @@ class LinkCableMultiboot {
SENDING_HEADER,
SENDING_PALETTE,
CONFIRM_HANDSHAKE_DATA,
// TODO: WAIT_BEFORE_MAIN_TRANSFER
MAIN_TRANSFER
WAIT_BEFORE_MAIN_TRANSFER,
CALCULATE_CRCB
};
enum Result {
@ -498,6 +499,8 @@ class LinkCableMultiboot {
volatile Result result = NONE;
void processNewFrame() {
// TODO: Add global state timeout
switch (state) {
case WAITING: {
dynamicData.wait++;
@ -508,6 +511,14 @@ class LinkCableMultiboot {
}
break;
}
case WAIT_BEFORE_MAIN_TRANSFER: {
dynamicData.wait++;
if (dynamicData.wait >= dynamicData.waitFrames) {
state = CALCULATE_CRCB;
transferAsync((fixedData.size - 0x190) >> 2);
}
break;
}
default: {
}
}
@ -519,8 +530,8 @@ class LinkCableMultiboot {
dynamicData.clientMask = 0;
bool success = validateResponse(response, [this](u32 i, u16 value) {
if ((value & 0xfff0) == ACK_HANDSHAKE) {
u8 clientId = value & 0xf;
if ((value & 0xFFF0) == ACK_HANDSHAKE) {
u8 clientId = value & 0xF;
u8 expectedClientId = 1 << (i + 1);
if (clientId == expectedClientId) {
dynamicData.clientMask |= clientId;
@ -586,7 +597,7 @@ class LinkCableMultiboot {
u8 clientBit = 1 << (i + 1);
if ((dynamicData.clientMask & clientBit) &&
((value & ACK_RESPONSE_MASK) == ACK_RESPONSE)) {
clientData[i] = value & 0xff;
clientData[i] = value & 0xFF;
sendMask &= ~clientBit;
return true;
}
@ -623,8 +634,20 @@ class LinkCableMultiboot {
return;
}
// TODO: TRANSFER SOMETHING
state = MAIN_TRANSFER;
state = WAIT_BEFORE_MAIN_TRANSFER;
dynamicData.waitFrames = WAIT_BEFORE_MAIN_TRANSFER_FRAMES;
break;
}
case CALCULATE_CRCB: {
// for (int i = 0; i < MAX_CLIENTS; i++) {
// u8 contribute = 0xFF;
// u8 client_bit = 1 << (i + 1);
// if (mb_dyn_data->client_mask & client_bit)
// contribute = recv_data[i] & 0xFF;
// mb_dyn_data->crcB |= contribute << (8 * (i + 1));
// }
// TODO
break;
}
default: {

View File

@ -107,18 +107,18 @@ class LinkMobile {
static constexpr int INIT_WAIT_FRAMES = 7;
static constexpr int INIT_TIMEOUT_FRAMES = 60 * 3;
static constexpr int PING_FREQUENCY_FRAMES = 60;
static constexpr int ADAPTER_WAITING = 0xd2;
static constexpr u32 ADAPTER_WAITING_32BIT = 0xd2d2d2d2;
static constexpr int GBA_WAITING = 0x4b;
static constexpr u32 GBA_WAITING_32BIT = 0x4b4b4b4b;
static constexpr int ADAPTER_WAITING = 0xD2;
static constexpr u32 ADAPTER_WAITING_32BIT = 0xD2D2D2D2;
static constexpr int GBA_WAITING = 0x4B;
static constexpr u32 GBA_WAITING_32BIT = 0x4B4B4B4B;
static constexpr int OR_VALUE = 0x80;
static constexpr int COMMAND_MAGIC_VALUE1 = 0x99;
static constexpr int COMMAND_MAGIC_VALUE2 = 0x66;
static constexpr int DEVICE_GBA = 0x1;
static constexpr int DEVICE_ADAPTER_BLUE = 0x8;
static constexpr int DEVICE_ADAPTER_YELLOW = 0x9;
static constexpr int DEVICE_ADAPTER_GREEN = 0xa;
static constexpr int DEVICE_ADAPTER_RED = 0xb;
static constexpr int DEVICE_ADAPTER_GREEN = 0xA;
static constexpr int DEVICE_ADAPTER_RED = 0xB;
static constexpr int ACK_SENDER = 0;
static constexpr int CONFIGURATION_DATA_SIZE = 192;
static constexpr int CONFIGURATION_DATA_CHUNK = CONFIGURATION_DATA_SIZE / 2;
@ -140,12 +140,12 @@ class LinkMobile {
static constexpr int COMMAND_OPEN_UDP_CONNECTION = 0x25;
static constexpr int COMMAND_CLOSE_UDP_CONNECTION = 0x26;
static constexpr int COMMAND_DNS_QUERY = 0x28;
static constexpr int COMMAND_CONNECTION_CLOSED = 0x1f;
static constexpr int COMMAND_ERROR_STATUS = 0x6e | OR_VALUE;
static constexpr int COMMAND_CONNECTION_CLOSED = 0x1F;
static constexpr int COMMAND_ERROR_STATUS = 0x6E | OR_VALUE;
static constexpr u8 WAIT_TICKS[] = {4, 8};
static constexpr int LOGIN_PARTS_SIZE = 8;
static constexpr u8 LOGIN_PARTS[] = {0x4e, 0x49, 0x4e, 0x54,
0x45, 0x4e, 0x44, 0x4f};
static constexpr u8 LOGIN_PARTS[] = {0x4E, 0x49, 0x4E, 0x54,
0x45, 0x4E, 0x44, 0x4F};
static constexpr int SUPPORTED_DEVICES_SIZE = 4;
static constexpr u8 SUPPORTED_DEVICES[] = {
DEVICE_ADAPTER_BLUE, DEVICE_ADAPTER_YELLOW, DEVICE_ADAPTER_GREEN,
@ -494,13 +494,13 @@ class LinkMobile {
* reuse the struct. When the transfer is completed, the `completed` field
* will be `true`. If the transfer was successful, the `success` field will be
* `true`.
* @param connectionId The ID of the connection (or `0xff` for P2P).
* @param connectionId The ID of the connection (or `0xFF` for P2P).
* \warning Non-blocking. Returns `true` immediately, or `false` if
* there's no active call or available request slots.
*/
bool transfer(DataTransfer dataToSend,
DataTransfer* result,
u8 connectionId = 0xff) {
u8 connectionId = 0xFF) {
if ((state != CALL_ESTABLISHED && state != PPP_ACTIVE) ||
userRequests.isFull())
return result->fail();

View File

@ -91,7 +91,7 @@ class LinkPS2Mouse {
setClockHigh();
setDataHigh();
waitMilliseconds(20);
write(0xff); // send reset to the mouse
write(0xFF); // send reset to the mouse
readByte(); // read ack byte
waitMilliseconds(20); // not sure why this needs the delay
readByte(); // blank
@ -122,7 +122,7 @@ class LinkPS2Mouse {
* @param data The array to be filled with data.
*/
void report(int (&data)[3]) {
write(0xeb); // send read data
write(0xEB); // send read data
readByte(); // read ack byte
data[0] = readByte(); // status bit
data[1] = readMovementX(data[0]); // X movement packet
@ -134,7 +134,7 @@ class LinkPS2Mouse {
volatile bool isEnabled = false;
void enableDataReporting() {
write(0xf4); // send enable data reporting
write(0xF4); // send enable data reporting
readByte(); // read ack byte
}

View File

@ -48,7 +48,7 @@
LINK_VERSION_TAG LINK_RAW_CABLE_VERSION = "vLinkRawCable/v8.0.0";
#define LINK_RAW_CABLE_MAX_PLAYERS 4
#define LINK_RAW_CABLE_DISCONNECTED 0xffff
#define LINK_RAW_CABLE_DISCONNECTED 0xFFFF
/**
* @brief A low level handler for the Link Port (Multi-Play Mode).

View File

@ -12,19 +12,19 @@
// - `startHost` = `0x19`
// - `getSignalLevel` = `0x11`
// - `getSlotStatus` = `0x14`
// - `acceptConnections` = `0x1a`
// - `endHost` = `0x1b`
// - `broadcastReadStart` = `0x1c`
// - `broadcastReadPoll` = `0x1d`
// - `broadcastReadEnd` = `0x1e`
// - `connect` = `0x1f`
// - `acceptConnections` = `0x1A`
// - `endHost` = `0x1B`
// - `broadcastReadStart` = `0x1C`
// - `broadcastReadPoll` = `0x1D`
// - `broadcastReadEnd` = `0x1E`
// - `connect` = `0x1F`
// - `keepConnecting` = `0x20`
// - `finishConnection` = `0x21`
// - `sendData` = `0x24`
// - `sendDataAndWait` = `0x25`
// - `receiveData` = `0x26`
// - `wait` = `0x27`
// - `bye` = `0x3d`
// - `bye` = `0x3D`
// - Use `sendCommand(...)` to send arbitrary commands.
// - Use `sendCommandAsync(...)` to send arbitrary commands asynchronously.
// - This requires setting `LINK_RAW_WIRELESS_ISR_SERIAL` as the `SERIAL`
@ -62,7 +62,7 @@ LINK_VERSION_TAG LINK_RAW_WIRELESS_VERSION = "vLinkRawWireless/v8.0.0";
#define LINK_RAW_WIRELESS_MAX_PLAYERS 5
#define LINK_RAW_WIRELESS_MAX_COMMAND_RESPONSE_LENGTH 30
#define LINK_RAW_WIRELESS_MAX_CLIENT_TRANSFER_LENGTH 4
#define LINK_RAW_WIRELESS_MAX_GAME_ID 0x7fff
#define LINK_RAW_WIRELESS_MAX_GAME_ID 0x7FFF
#define LINK_RAW_WIRELESS_MAX_GAME_NAME_LENGTH 14
#define LINK_RAW_WIRELESS_MAX_USER_NAME_LENGTH 8
#define LINK_RAW_WIRELESS_MAX_COMMAND_TRANSFER_LENGTH 23
@ -111,12 +111,12 @@ class LinkRawWireless {
static constexpr int COMMAND_START_HOST = 0x19;
static constexpr int COMMAND_SIGNAL_LEVEL = 0x11;
static constexpr int COMMAND_SLOT_STATUS = 0x14;
static constexpr int COMMAND_ACCEPT_CONNECTIONS = 0x1a;
static constexpr int COMMAND_END_HOST = 0x1b;
static constexpr int COMMAND_BROADCAST_READ_START = 0x1c;
static constexpr int COMMAND_BROADCAST_READ_POLL = 0x1d;
static constexpr int COMMAND_BROADCAST_READ_END = 0x1e;
static constexpr int COMMAND_CONNECT = 0x1f;
static constexpr int COMMAND_ACCEPT_CONNECTIONS = 0x1A;
static constexpr int COMMAND_END_HOST = 0x1B;
static constexpr int COMMAND_BROADCAST_READ_START = 0x1C;
static constexpr int COMMAND_BROADCAST_READ_POLL = 0x1D;
static constexpr int COMMAND_BROADCAST_READ_END = 0x1E;
static constexpr int COMMAND_CONNECT = 0x1F;
static constexpr int COMMAND_IS_FINISHED_CONNECT = 0x20;
static constexpr int COMMAND_FINISH_CONNECTION = 0x21;
static constexpr int COMMAND_SEND_DATA = 0x24;
@ -128,8 +128,8 @@ class LinkRawWireless {
static constexpr int EVENT_DATA_AVAILABLE = 0x28;
static constexpr int EVENT_DISCONNECTED = 0x29;
static constexpr u16 LOGIN_PARTS[] = {0x494e, 0x494e, 0x544e, 0x544e, 0x4e45,
0x4e45, 0x4f44, 0x4f44, 0x8001};
static constexpr u16 LOGIN_PARTS[] = {0x494E, 0x494E, 0x544E, 0x544E, 0x4E45,
0x4E45, 0x4F44, 0x4F44, 0x8001};
#ifdef LINK_RAW_WIRELESS_ENABLE_LOGGING
typedef void (*Logger)(std::string);
@ -159,7 +159,7 @@ class LinkRawWireless {
char userName[LINK_RAW_WIRELESS_MAX_USER_NAME_LENGTH + 1];
u8 nextClientNumber;
bool isFull() { return nextClientNumber == 0xff; }
bool isFull() { return nextClientNumber == 0xFF; }
};
struct ConnectedClient {
@ -297,7 +297,7 @@ class LinkRawWireless {
* @param waitTimeout Timeout of the *waiting commands*, in frames (16.6ms).
* `0` means no timeout.
* @param magic A part of the protocol that hasn't been reverse-engineered
* yet. For now, it's magic (`0x003c0000`).
* yet. For now, it's magic (`0x003C0000`).
*/
bool setup(u8 maxPlayers = LINK_RAW_WIRELESS_MAX_PLAYERS,
u8 maxTransmissions = 4,
@ -461,7 +461,7 @@ class LinkRawWireless {
u32 levels = result.data[0];
for (u32 i = 1; i < LINK_RAW_WIRELESS_MAX_PLAYERS; i++)
response.signalLevels[i] = (levels >> ((i - 1) * 8)) & 0xff;
response.signalLevels[i] = (levels >> ((i - 1) * 8)) & 0xFF;
return true;
}
@ -498,7 +498,7 @@ class LinkRawWireless {
}
/**
* @brief Calls the AcceptConnections (`0x1a`) command.
* @brief Calls the AcceptConnections (`0x1A`) command.
* @param response A structure that will be filled with the response data.
*/
bool acceptConnections(AcceptConnectionsResponse& response) {
@ -525,7 +525,7 @@ class LinkRawWireless {
}
/**
* @brief Calls the EndHost (`0x1b`) command.
* @brief Calls the EndHost (`0x1B`) command.
* @param response A structure that will be filled with the response data.
*/
bool endHost(AcceptConnectionsResponse& response) {
@ -555,7 +555,7 @@ class LinkRawWireless {
}
/**
* @brief Calls the BroadcastReadStart (`0x1c`) command.
* @brief Calls the BroadcastReadStart (`0x1C`) command.
*/
bool broadcastReadStart() {
bool success = sendCommand(COMMAND_BROADCAST_READ_START).success;
@ -572,7 +572,7 @@ class LinkRawWireless {
}
/**
* @brief Calls the BroadcastReadPoll (`0x1d`) command.
* @brief Calls the BroadcastReadPoll (`0x1D`) command.
* @param response A structure that will be filled with the response data.
*/
bool broadcastReadPoll(BroadcastReadPollResponse& response) {
@ -605,7 +605,7 @@ class LinkRawWireless {
recoverName(server.userName, userI, result.data[start + 6]);
server.gameName[gameI] = '\0';
server.userName[userI] = '\0';
server.nextClientNumber = (result.data[start] >> 16) & 0xff;
server.nextClientNumber = (result.data[start] >> 16) & 0xFF;
response.servers[response.serversSize++] = server;
}
@ -614,7 +614,7 @@ class LinkRawWireless {
}
/**
* @brief Calls the BroadcastReadEnd (`0x1e`) command.
* @brief Calls the BroadcastReadEnd (`0x1E`) command.
*/
bool broadcastReadEnd() {
bool success = sendCommand(COMMAND_BROADCAST_READ_END).success;
@ -631,7 +631,7 @@ class LinkRawWireless {
}
/**
* @brief Calls the Connect (`0x1f`) command.
* @brief Calls the Connect (`0x1F`) command.
* @param serverId Device ID of the server.
*/
bool connect(u16 serverId) {
@ -892,7 +892,7 @@ class LinkRawWireless {
return result;
}
if (ack != type + RESPONSE_ACK) {
if (ack == 0xee && responses == 1 && !invertsClock) {
if (ack == 0xEE && responses == 1 && !invertsClock) {
u8 __attribute__((unused)) code = (u8)transfer(DATA_REQUEST_VALUE);
_LRWLOG_("! error received");
_LRWLOG_(code == 1 ? "! invalid state" : "! unknown cmd");
@ -969,7 +969,7 @@ class LinkRawWireless {
_LRWLOG_("sending ack");
command = linkSPI.transfer(
(COMMAND_HEADER_VALUE << 16) | ((commandId + RESPONSE_ACK) & 0xff),
(COMMAND_HEADER_VALUE << 16) | ((commandId + RESPONSE_ACK) & 0xFF),
[this, &lines, &vCount]() { return cmdTimeout(lines, vCount); }, false,
true);
if (!reverseAcknowledge(true)) {
@ -1167,7 +1167,7 @@ class LinkRawWireless {
static const char* digits = "0123456789ABCDEF";
std::string rc(hex_len, '0');
for (size_t i = 0, j = (hex_len - 1) * 4; i < hex_len; ++i, j -= 4)
rc[i] = digits[(w >> j) & 0x0f];
rc[i] = digits[(w >> j) & 0x0F];
return rc;
}
#endif
@ -1185,8 +1185,8 @@ class LinkRawWireless {
private:
struct LoginMemory {
u16 previousGBAData = 0xffff;
u16 previousAdapterData = 0xffff;
u16 previousGBAData = 0xFFFF;
u16 previousAdapterData = 0xFFFF;
};
struct AsyncCommand {
@ -1467,7 +1467,7 @@ class LinkRawWireless {
_LRWLOG_("! but received 0x" + toHex(header));
}
if (ack != asyncCommand.type + RESPONSE_ACK) {
if (ack == 0xee) {
if (ack == 0xEE) {
_LRWLOG_("! error received");
} else {
_LRWLOG_("! expected ACK 0x" +
@ -1619,7 +1619,7 @@ class LinkRawWireless {
_LRWLOG_("sending ack");
asyncCommand.step = AsyncCommand::Step::DATA_REQUEST;
u32 ack = (COMMAND_HEADER_VALUE << 16) |
((asyncCommand.type + RESPONSE_ACK) & 0xff);
((asyncCommand.type + RESPONSE_ACK) & 0xFF);
transferAsync(ack, true);
}

View File

@ -48,8 +48,8 @@
LINK_VERSION_TAG LINK_SPI_VERSION = "vLinkSPI/v8.0.0";
#define LINK_SPI_NO_DATA_32 0xffffffff
#define LINK_SPI_NO_DATA_8 0xff
#define LINK_SPI_NO_DATA_32 0xFFFFFFFF
#define LINK_SPI_NO_DATA_8 0xFF
#define LINK_SPI_NO_DATA LINK_SPI_NO_DATA_32
/**
@ -319,12 +319,12 @@ class LinkSPI {
if (dataSize == SIZE_32BIT)
Link::_REG_SIODATA32 = data;
else
Link::_REG_SIODATA8 = data & 0xff;
Link::_REG_SIODATA8 = data & 0xFF;
}
u32 getData() {
return dataSize == SIZE_32BIT ? Link::_REG_SIODATA32
: Link::_REG_SIODATA8 & 0xff;
: Link::_REG_SIODATA8 & 0xFF;
}
u32 noData() {

View File

@ -62,9 +62,9 @@
#ifndef LINK_UNIVERSAL_GAME_ID_FILTER
/**
* @brief Game ID Filter (`0x0000` ~ `0x7fff`). Default = 0 (no filter)
* @brief Game ID Filter (`0x0000` ~ `0x7FFF`). Default = 0 (no filter)
* This restricts wireless connections to rooms with a specific game ID.
* When disabled, it connects to any game ID and uses `0x7fff` when serving.
* When disabled, it connects to any game ID and uses `0x7FFF` when serving.
*/
#define LINK_UNIVERSAL_GAME_ID_FILTER 0
#endif

View File

@ -141,7 +141,7 @@ LINK_VERSION_TAG LINK_WIRELESS_VERSION = "vLinkWireless/v8.0.0";
#define LINK_WIRELESS_MIN_PLAYERS 2
#define LINK_WIRELESS_END 0
#define LINK_WIRELESS_MAX_SERVERS LINK_RAW_WIRELESS_MAX_SERVERS
#define LINK_WIRELESS_MAX_GAME_ID 0x7fff
#define LINK_WIRELESS_MAX_GAME_ID 0x7FFF
#define LINK_WIRELESS_MAX_GAME_NAME_LENGTH 14
#define LINK_WIRELESS_MAX_USER_NAME_LENGTH 8
#define LINK_WIRELESS_DEFAULT_TIMEOUT 10
@ -176,7 +176,7 @@ class LinkWireless {
#endif
static constexpr int MAX_PACKET_IDS = 1 << PACKET_ID_BITS;
static constexpr int PACKET_ID_MASK = MAX_PACKET_IDS - 1;
static constexpr int MSG_PING = 0xffff;
static constexpr int MSG_PING = 0xFFFF;
static constexpr int BROADCAST_SEARCH_WAIT_FRAMES = 60;
static constexpr int MAX_COMMAND_TRANSFER_LENGTH = 22;
@ -535,7 +535,7 @@ class LinkWireless {
server.userName[j] = foundServers[i].userName[j];
u8 nextClientNumber = foundServers[i].nextClientNumber;
server.currentPlayerCount =
nextClientNumber == 0xff ? 0 : 1 + nextClientNumber;
nextClientNumber == 0xFF ? 0 : 1 + nextClientNumber;
servers[i] = server;
}
@ -1022,7 +1022,7 @@ class LinkWireless {
u32 levels = commandResult->dataSize > 0 ? commandResult->data[0] : 0;
u32 players = 1;
for (u32 i = 1; i < LINK_WIRELESS_MAX_PLAYERS; i++) {
u32 level = (levels >> ((i - 1) * 8)) & 0xff;
u32 level = (levels >> ((i - 1) * 8)) & 0xFF;
sessionState.signalLevel.level[i] = level;
if (level > 0)
players++;
@ -1261,7 +1261,7 @@ class LinkWireless {
sessionState.lastPacketIdFromClients[4] == 0)) {
u32 lastPacketId = sessionState.lastPacketId;
u16 header = buildConfirmationHeader(0, lastPacketId);
u32 rawMessage = Link::buildU32(header, lastPacketId & 0xffff);
u32 rawMessage = Link::buildU32(header, lastPacketId & 0xFFFF);
addAsyncData(rawMessage);
}
#endif
@ -1269,14 +1269,14 @@ class LinkWireless {
for (int i = 0; i < linkRawWireless.sessionState.playerCount - 1; i++) {
u32 confirmationData = sessionState.lastPacketIdFromClients[1 + i];
u16 header = buildConfirmationHeader(1 + i, confirmationData);
u32 rawMessage = Link::buildU32(header, confirmationData & 0xffff);
u32 rawMessage = Link::buildU32(header, confirmationData & 0xFFFF);
addAsyncData(rawMessage);
}
} else {
u32 confirmationData = sessionState.lastPacketIdFromServer;
u16 header = buildConfirmationHeader(
linkRawWireless.sessionState.currentPlayerId, confirmationData);
u32 rawMessage = Link::buildU32(header, confirmationData & 0xffff);
u32 rawMessage = Link::buildU32(header, confirmationData & 0xFFFF);
addAsyncData(rawMessage);
}
}
@ -1311,13 +1311,13 @@ class LinkWireless {
u8 playerId) { // (irq only)
sessionState.lastConfirmationFromClients[playerId] = confirmationData;
u32 min = 0xffffffff;
u32 min = 0xFFFFFFFF;
for (int i = 0; i < config.maxPlayers - 1; i++) {
u32 _confirmationData = sessionState.lastConfirmationFromClients[1 + i];
if (_confirmationData > 0 && _confirmationData < min)
min = _confirmationData;
}
if (min < 0xffffffff)
if (min < 0xFFFFFFFF)
removeConfirmedMessages(min);
}
@ -1333,7 +1333,7 @@ class LinkWireless {
// packetId => high 6 bits of confirmation
// data => low 16 bits of confirmation
u8 highPart = (confirmationData >> 16) & PACKET_ID_MASK;
u16 lowPart = confirmationData & 0xffff;
u16 lowPart = confirmationData & 0xFFFF;
return buildMessageHeader(playerId, highPart, buildChecksum(lowPart), true);
}

View File

@ -14,7 +14,7 @@
// romLength, // in bytes
// "Multiboot", // game name
// "Test", // user name
// 0xffff, // game ID
// 0xFFFF, // game ID
// 2, // number of players
// [](LinkWirelessMultiboot::MultibootProgress progress) {
// // check progress.[state,connectedClients,percentage]
@ -47,7 +47,7 @@
LINK_VERSION_TAG LINK_WIRELESS_MULTIBOOT_VERSION =
"vLinkWirelessMultiboot/v8.0.0";
#define LINK_WIRELESS_MULTIBOOT_MIN_ROM_SIZE (0x100 + 0xc0)
#define LINK_WIRELESS_MULTIBOOT_MIN_ROM_SIZE (0x100 + 0xC0)
#define LINK_WIRELESS_MULTIBOOT_MAX_ROM_SIZE (256 * 1024)
#define LINK_WIRELESS_MULTIBOOT_MIN_PLAYERS 2
#define LINK_WIRELESS_MULTIBOOT_MAX_PLAYERS 5
@ -96,11 +96,11 @@ class LinkWirelessMultiboot {
static constexpr u8 CMD_START[] = {0x00, 0x54, 0x00, 0x00, 0x00, 0x02, 0x00};
static constexpr u8 CMD_START_SIZE = 7;
static constexpr u8 BOOTLOADER_HANDSHAKE[][6] = {
{0x00, 0x00, 0x52, 0x46, 0x55, 0x2d},
{0x4d, 0x42, 0x2d, 0x44, 0x4c, 0x00}};
{0x00, 0x00, 0x52, 0x46, 0x55, 0x2D},
{0x4D, 0x42, 0x2D, 0x44, 0x4C, 0x00}};
static constexpr u8 BOOTLOADER_HANDSHAKE_SIZE = 6;
static constexpr u8 ROM_HEADER_PATCH[] = {0x52, 0x46, 0x55, 0x2d, 0x4d, 0x42,
0x4f, 0x4f, 0x54, 0x00, 0x00, 0x00};
static constexpr u8 ROM_HEADER_PATCH[] = {0x52, 0x46, 0x55, 0x2D, 0x4D, 0x42,
0x4F, 0x4F, 0x54, 0x00, 0x00, 0x00};
static constexpr u8 ROM_HEADER_PATCH_OFFSET = 4;
static constexpr u8 ROM_HEADER_PATCH_SIZE = 12;
@ -601,7 +601,7 @@ class LinkWirelessMultiboot {
static const char* digits = "0123456789ABCDEF";
std::string rc(hex_len, '0');
for (size_t i = 0, j = (hex_len - 1) * 4; i < hex_len; ++i, j -= 4)
rc[i] = digits[(w >> j) & 0x0f];
rc[i] = digits[(w >> j) & 0x0F];
return rc;
}
#endif

View File

@ -447,7 +447,7 @@ class LinkWirelessOpenSDK {
[[nodiscard]]
PendingTransfer* minWithoutAck() {
u32 minCursor = 0xffffffff;
u32 minCursor = 0xFFFFFFFF;
int minI = -1;
for (u32 i = 0; i < MaxInflightPackets; i++) {
if (transfers[i].isActive && transfers[i].cursor < minCursor &&
@ -682,7 +682,7 @@ class LinkWirelessOpenSDK {
[[nodiscard]]
u32 findMinClient() {
u32 minTransferredBytes = 0xffffffff;
u32 minTransferredBytes = 0xFFFFFFFF;
u32 minClient = 0;
for (u32 i = 0; i < connectedClients; i++) {
@ -698,7 +698,7 @@ class LinkWirelessOpenSDK {
[[nodiscard]]
u32 findMinCursor() {
u32 minNextCursor = 0xffffffff;
u32 minNextCursor = 0xFFFFFFFF;
bool canSendInflightPackets = true;
for (u32 i = 0; i < connectedClients; i++) {

View File

@ -105,7 +105,7 @@ inline vu16& _REG_KEYS = *reinterpret_cast<vu16*>(_REG_BASE + 0x0130);
inline vu16& _REG_TM1CNT_L = *reinterpret_cast<vu16*>(_REG_BASE + 0x0104);
inline vu16& _REG_TM1CNT_H = *reinterpret_cast<vu16*>(_REG_BASE + 0x0106);
inline vu16& _REG_TM2CNT_L = *reinterpret_cast<vu16*>(_REG_BASE + 0x0108);
inline vu16& _REG_TM2CNT_H = *reinterpret_cast<vu16*>(_REG_BASE + 0x010a);
inline vu16& _REG_TM2CNT_H = *reinterpret_cast<vu16*>(_REG_BASE + 0x010A);
inline vu16& _REG_IME = *reinterpret_cast<vu16*>(_REG_BASE + 0x0208);
inline volatile _TMR_REC* const _REG_TM =
@ -182,7 +182,7 @@ static inline u16 msB32(u32 value) {
}
static inline u16 lsB32(u32 value) {
return value & 0xffff;
return value & 0xFFFF;
}
static inline u8 msB16(u16 value) {
@ -190,7 +190,7 @@ static inline u8 msB16(u16 value) {
}
static inline u8 lsB16(u16 value) {
return value & 0xff;
return value & 0xFF;
}
static inline int _max(int a, int b) {

View File

@ -13,7 +13,7 @@ typedef void* C_LinkCableHandle;
#define C_LINK_CABLE_DEFAULT_TIMEOUT 3
#define C_LINK_CABLE_DEFAULT_INTERVAL 50
#define C_LINK_CABLE_DEFAULT_SEND_TIMER_ID 3
#define C_LINK_CABLE_DISCONNECTED 0xffff
#define C_LINK_CABLE_DISCONNECTED 0xFFFF
#define C_LINK_CABLE_NO_DATA 0x0
typedef enum {

View File

@ -10,7 +10,7 @@ extern "C" {
typedef void* C_LinkRawCableHandle;
#define C_LINK_RAW_CABLE_MAX_PLAYERS 4
#define C_LINK_RAW_CABLE_DISCONNECTED 0xffff
#define C_LINK_RAW_CABLE_DISCONNECTED 0xFFFF
typedef enum {
C_LINK_RAW_CABLE_BAUD_RATE_0, // 9600 bps

View File

@ -12,11 +12,11 @@ typedef void* C_LinkRawWirelessHandle;
#define C_LINK_RAW_WIRELESS_MAX_PLAYERS 5
#define C_LINK_RAW_WIRELESS_MAX_COMMAND_RESPONSE_LENGTH 30
#define C_LINK_RAW_WIRELESS_MAX_CLIENT_TRANSFER_LENGTH 4
#define C_LINK_RAW_WIRELESS_MAX_GAME_ID 0x7fff
#define C_LINK_RAW_WIRELESS_MAX_GAME_ID 0x7FFF
#define C_LINK_RAW_WIRELESS_MAX_GAME_NAME_LENGTH 14
#define C_LINK_RAW_WIRELESS_MAX_USER_NAME_LENGTH 8
#define C_LINK_RAW_WIRELESS_MAX_COMMAND_TRANSFER_LENGTH 23
#define C_LINK_RAW_WIRELESS_SETUP_MAGIC 0x003c0000
#define C_LINK_RAW_WIRELESS_SETUP_MAGIC 0x003C0000
#define C_LINK_RAW_WIRELESS_MAX_SERVERS 4

View File

@ -9,8 +9,8 @@ extern "C" {
typedef void* C_LinkSPIHandle;
#define C_LINK_SPI_NO_DATA_32 0xffffffff
#define C_LINK_SPI_NO_DATA_8 0xff
#define C_LINK_SPI_NO_DATA_32 0xFFFFFFFF
#define C_LINK_SPI_NO_DATA_8 0xFF
#define C_LINK_SPI_NO_DATA LINK_SPI_NO_DATA_32
typedef enum {

View File

@ -11,7 +11,7 @@ extern "C" {
typedef void* C_LinkUniversalHandle;
#define C_LINK_UNIVERSAL_DISCONNECTED 0xffff
#define C_LINK_UNIVERSAL_DISCONNECTED 0xFFFF
#define C_LINK_UNIVERSAL_NO_DATA 0x0
typedef enum {

View File

@ -20,7 +20,7 @@ typedef void* C_LinkWirelessHandle;
#define C_LINK_WIRELESS_MAX_SERVERS \
(C_LINK_WIRELESS_MAX_COMMAND_RESPONSE_LENGTH / \
C_LINK_WIRELESS_BROADCAST_RESPONSE_LENGTH)
#define C_LINK_WIRELESS_MAX_GAME_ID 0x7fff
#define C_LINK_WIRELESS_MAX_GAME_ID 0x7FFF
#define C_LINK_WIRELESS_MAX_GAME_NAME_LENGTH 14
#define C_LINK_WIRELESS_MAX_USER_NAME_LENGTH 8
#define C_LINK_WIRELESS_DEFAULT_TIMEOUT 10

View File

@ -9,7 +9,7 @@ extern "C" {
typedef void* C_LinkWirelessMultibootHandle;
#define C_LINK_WIRELESS_MULTIBOOT_MIN_ROM_SIZE (0x100 + 0xc0)
#define C_LINK_WIRELESS_MULTIBOOT_MIN_ROM_SIZE (0x100 + 0xC0)
#define C_LINK_WIRELESS_MULTIBOOT_MAX_ROM_SIZE (256 * 1024)
#define C_LINK_WIRELESS_MULTIBOOT_MIN_PLAYERS 2
#define C_LINK_WIRELESS_MULTIBOOT_MAX_PLAYERS 5