mirror of
https://github.com/afska/gba-link-connection.git
synced 2026-04-24 23:47:51 -05:00
LinkWireless: ISR optimizations, stop copying values!
This commit is contained in:
parent
996eb824d4
commit
084b18284a
|
|
@ -1094,6 +1094,16 @@ class LinkRawWireless {
|
|||
this->sessionState.isServerClosed = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a pointer to the internal result of the last async command
|
||||
* and switches the state back to `IDLE`.
|
||||
* \warning This is internal API!
|
||||
*/
|
||||
[[nodiscard]] CommandResult* _getAsyncCommandResultRef() {
|
||||
asyncState = IDLE;
|
||||
return &asyncCommand.result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This method is called by the SERIAL interrupt handler.
|
||||
* \warning This is internal API!
|
||||
|
|
|
|||
|
|
@ -860,7 +860,7 @@ class LinkWireless {
|
|||
if (status <= -4) {
|
||||
return (void)abort(ACKNOWLEDGE_FAILED);
|
||||
} else if (status > 0) {
|
||||
auto result = linkRawWireless.getAsyncCommandResult();
|
||||
auto result = linkRawWireless._getAsyncCommandResultRef();
|
||||
processAsyncCommand(result);
|
||||
}
|
||||
|
||||
|
|
@ -995,21 +995,21 @@ class LinkWireless {
|
|||
#endif
|
||||
|
||||
void processAsyncCommand(
|
||||
LinkRawWireless::CommandResult commandResult) { // (irq only)
|
||||
u8 commandId = commandResult.commandId;
|
||||
if (!commandResult.success) {
|
||||
return (void)abort(commandId == LinkRawWireless::COMMAND_SEND_DATA
|
||||
? SEND_DATA_FAILED
|
||||
: commandId == LinkRawWireless::COMMAND_RECEIVE_DATA
|
||||
? RECEIVE_DATA_FAILED
|
||||
: COMMAND_FAILED);
|
||||
const LinkRawWireless::CommandResult* commandResult) { // (irq only)
|
||||
if (!commandResult->success) {
|
||||
return (void)abort(
|
||||
commandResult->commandId == LinkRawWireless::COMMAND_SEND_DATA
|
||||
? SEND_DATA_FAILED
|
||||
: commandResult->commandId == LinkRawWireless::COMMAND_RECEIVE_DATA
|
||||
? RECEIVE_DATA_FAILED
|
||||
: COMMAND_FAILED);
|
||||
}
|
||||
|
||||
switch (commandId) {
|
||||
switch (commandResult->commandId) {
|
||||
case LinkRawWireless::COMMAND_ACCEPT_CONNECTIONS: {
|
||||
// AcceptConnections (end)
|
||||
linkRawWireless.sessionState.playerCount =
|
||||
Link::_min(1 + commandResult.dataSize, config.maxPlayers);
|
||||
Link::_min(1 + commandResult->dataSize, config.maxPlayers);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -1037,7 +1037,7 @@ class LinkWireless {
|
|||
sessionState.shouldWaitForServer || !sessionState.sendReceiveLatch;
|
||||
#endif
|
||||
|
||||
if (commandResult.dataSize == 0)
|
||||
if (commandResult->dataSize == 0)
|
||||
break;
|
||||
|
||||
sessionState.recvFlag = true;
|
||||
|
|
@ -1133,9 +1133,9 @@ class LinkWireless {
|
|||
return lastPacketId;
|
||||
}
|
||||
|
||||
void addIncomingMessagesFromData(CommandResult& result) { // (irq only)
|
||||
for (u32 i = 1; i < result.dataSize; i++) {
|
||||
u32 rawMessage = result.data[i];
|
||||
void addIncomingMessagesFromData(const CommandResult* result) { // (irq only)
|
||||
for (u32 i = 1; i < result->dataSize; i++) {
|
||||
u32 rawMessage = result->data[i];
|
||||
u16 headerInt = Link::msB32(rawMessage);
|
||||
u16 data = Link::lsB32(rawMessage);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user