Combine link slot length constants

This commit is contained in:
GriffinR 2021-10-07 16:19:02 -04:00
parent a2655ba9ab
commit 7c5c41f23c
3 changed files with 28 additions and 38 deletions

View file

@ -25,14 +25,10 @@
#define RFU_SERIAL_UNKNOWN 0x0000 // Unreferenced acceptable serial number. Gamecube?
#define RFU_SERIAL_END 0xFFFF
#define COMM_SLOT_LENGTH 14
#define RECV_QUEUE_NUM_SLOTS 32
#define RECV_QUEUE_SLOT_LENGTH (14 * MAX_RFU_PLAYERS)
#define SEND_QUEUE_NUM_SLOTS 40
#define SEND_QUEUE_SLOT_LENGTH 14
#define BACKUP_QUEUE_NUM_SLOTS 2
#define BACKUP_QUEUE_SLOT_LENGTH 14
#define RFU_PACKET_SIZE 6
@ -50,8 +46,6 @@
#define RFU_STATUS_CHILD_LEAVE 11
#define RFU_STATUS_ACK_JOIN_GROUP 12
#define CHILD_DATA_LENGTH 14
// Values for disconnectMode
enum {
RFU_DISCONNECT_NONE,
@ -143,7 +137,7 @@ struct RfuBlockSend
struct RfuRecvQueue
{
/* 0x000 */ u8 slots[RECV_QUEUE_NUM_SLOTS][RECV_QUEUE_SLOT_LENGTH];
/* 0x000 */ u8 slots[RECV_QUEUE_NUM_SLOTS][COMM_SLOT_LENGTH * MAX_RFU_PLAYERS];
/* 0x8c0 */ vu8 recvSlot;
/* 0x8c1 */ vu8 sendSlot;
/* 0x8c2 */ vu8 count;
@ -152,7 +146,7 @@ struct RfuRecvQueue
struct RfuSendQueue
{
/* 0x000 */ u8 slots[SEND_QUEUE_NUM_SLOTS][SEND_QUEUE_SLOT_LENGTH];
/* 0x000 */ u8 slots[SEND_QUEUE_NUM_SLOTS][COMM_SLOT_LENGTH];
/* 0x230 */ vu8 recvSlot;
/* 0x231 */ vu8 sendSlot;
/* 0x232 */ vu8 count;
@ -161,7 +155,7 @@ struct RfuSendQueue
struct RfuBackupQueue
{
/* 0x00 */ u8 slots[BACKUP_QUEUE_NUM_SLOTS][BACKUP_QUEUE_SLOT_LENGTH];
/* 0x00 */ u8 slots[BACKUP_QUEUE_NUM_SLOTS][COMM_SLOT_LENGTH];
/* 0x1c */ vu8 recvSlot;
/* 0x1d */ vu8 sendSlot;
/* 0x1e */ vu8 count;
@ -180,8 +174,8 @@ struct RfuManager
/* 0x00f */ u8 unused2;
/* 0x010 */ u16 errorParam0;
/* 0x012 */ u16 errorParam1;
/* 0x014 */ u8 childRecvBuffer[RFU_CHILD_MAX][CHILD_DATA_LENGTH];
/* 0x04c */ u8 childSendBuffer[CHILD_DATA_LENGTH];
/* 0x014 */ u8 childRecvBuffer[RFU_CHILD_MAX][COMM_SLOT_LENGTH];
/* 0x04c */ u8 childSendBuffer[COMM_SLOT_LENGTH];
/* 0x05a */ u8 blockRequestType;
/* 0x05b */ u8 blockSendAttempts;
/* 0x05c */ bool8 blockReceived[MAX_RFU_PLAYERS];
@ -211,7 +205,7 @@ struct RfuManager
/* 0xc3c */ vu8 linkRecovered;
/* 0xc3d */ u8 reconnectParentId;
/* 0xc3e */ vu8 childSlot;
/* 0xc3f */ u8 childRecvQueue[RECV_QUEUE_SLOT_LENGTH];
/* 0xc3f */ u8 childRecvQueue[COMM_SLOT_LENGTH * MAX_RFU_PLAYERS];
/* 0xc85 */ u8 leaveGroupStatus;
/* 0xc86 */ u8 childRecvStatus;
/* 0xc87 */ u8 recvCmds[MAX_RFU_PLAYERS][CMD_LENGTH - 1][2];

View file

@ -579,7 +579,7 @@ static void MSCCallback_Child(u16 REQ_commandID)
{
s32 i;
for (i = 0; i < CHILD_DATA_LENGTH; i++)
for (i = 0; i < COMM_SLOT_LENGTH; i++)
gRfu.childSendBuffer[i] = 0;
rfu_REQ_recvData();
@ -922,7 +922,7 @@ static void ChildBuildSendCmd(u16 *sendCmd, u8 *dst)
}
else
{
for (i = 0; i < SEND_QUEUE_SLOT_LENGTH; i++)
for (i = 0; i < COMM_SLOT_LENGTH; i++)
dst[i] = 0;
}
}
@ -939,8 +939,8 @@ static bool32 RfuMain1_Child(void)
for (i = 0; i < MAX_RFU_PLAYERS; i++)
{
for (j = 0; j < CMD_LENGTH - 1; j++)
gRecvCmds[i][j] = (recv[i * SEND_QUEUE_SLOT_LENGTH + (j * 2) + 1] << 8)
| recv[i * SEND_QUEUE_SLOT_LENGTH + (j * 2) + 0];
gRecvCmds[i][j] = (recv[i * COMM_SLOT_LENGTH + (j * 2) + 1] << 8)
| recv[i * COMM_SLOT_LENGTH + (j * 2) + 0];
}
RfuHandleReceiveCommand(0);
if (lman.childClockSlave_flag == 0 && gRfu.disconnectMode != RFU_DISCONNECT_NONE)
@ -986,8 +986,8 @@ static void HandleSendFailure(u8 unused, u32 flags)
for (j = 0; j < CMD_LENGTH - 1; j++)
{
temp = j * 2;
sResendBlock16[j + 1] = (payload[(SEND_QUEUE_SLOT_LENGTH - 2) * i + temp + 1] << 8)
| payload[(SEND_QUEUE_SLOT_LENGTH - 2) * i + temp + 0];
sResendBlock16[j + 1] = (payload[(COMM_SLOT_LENGTH - 2) * i + temp + 1] << 8)
| payload[(COMM_SLOT_LENGTH - 2) * i + temp + 0];
}
for (j = 0; j < CMD_LENGTH - 1; j++)
{
@ -2953,7 +2953,7 @@ static void Debug_PrintStatus(void)
}
for (i = 0; i < RFU_CHILD_MAX; i++)
{
for (j = 0; j < CHILD_DATA_LENGTH; j++)
for (j = 0; j < COMM_SLOT_LENGTH; j++)
Debug_PrintNum(gRfu.childRecvBuffer[i][j], j * 2, i + 11, 2);
}
Debug_PrintString(sASCII_NowSlot, 1, 15);

View file

@ -317,10 +317,8 @@ void RfuRecvQueue_Reset(struct RfuRecvQueue *queue)
for (i = 0; i < RECV_QUEUE_NUM_SLOTS; i++)
{
for (j = 0; j < RECV_QUEUE_SLOT_LENGTH; j++)
{
for (j = 0; j < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; j++)
queue->slots[i][j] = 0;
}
}
queue->sendSlot = 0;
queue->recvSlot = 0;
@ -335,7 +333,7 @@ void RfuSendQueue_Reset(struct RfuSendQueue *queue)
for (i = 0; i < SEND_QUEUE_NUM_SLOTS; i++)
{
for (j = 0; j < SEND_QUEUE_SLOT_LENGTH; j++)
for (j = 0; j < COMM_SLOT_LENGTH; j++)
queue->slots[i][j] = 0;
}
queue->sendSlot = 0;
@ -371,21 +369,21 @@ void RfuRecvQueue_Enqueue(struct RfuRecvQueue *queue, u8 *data)
imeBak = REG_IME;
REG_IME = 0;
count = 0;
for (i = 0; i < RECV_QUEUE_SLOT_LENGTH; i += RECV_QUEUE_SLOT_LENGTH / MAX_RFU_PLAYERS)
for (i = 0; i < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; i += COMM_SLOT_LENGTH)
{
if (data[i] == 0 && data[i + 1] == 0)
count++;
}
if (count != MAX_RFU_PLAYERS)
{
for (i = 0; i < RECV_QUEUE_SLOT_LENGTH; i++)
for (i = 0; i < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; i++)
queue->slots[queue->recvSlot][i] = data[i];
queue->recvSlot++;
queue->recvSlot %= RECV_QUEUE_NUM_SLOTS;
queue->count++;
for (i = 0; i < RECV_QUEUE_SLOT_LENGTH; i++)
for (i = 0; i < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; i++)
data[i] = 0;
}
REG_IME = imeBak;
@ -405,22 +403,20 @@ void RfuSendQueue_Enqueue(struct RfuSendQueue *queue, u8 *data)
{
imeBak = REG_IME;
REG_IME = 0;
for (i = 0; i < SEND_QUEUE_SLOT_LENGTH; i++)
for (i = 0; i < COMM_SLOT_LENGTH; i++)
{
if (data[i] != 0)
break;
}
if (i != SEND_QUEUE_SLOT_LENGTH)
if (i != COMM_SLOT_LENGTH)
{
for (i = 0; i < SEND_QUEUE_SLOT_LENGTH; i++)
{
for (i = 0; i < COMM_SLOT_LENGTH; i++)
queue->slots[queue->recvSlot][i] = data[i];
}
queue->recvSlot++;
queue->recvSlot %= SEND_QUEUE_NUM_SLOTS;
queue->count++;
for (i = 0; i < SEND_QUEUE_SLOT_LENGTH; i++)
for (i = 0; i < COMM_SLOT_LENGTH; i++)
data[i] = 0;
}
REG_IME = imeBak;
@ -440,13 +436,13 @@ bool8 RfuRecvQueue_Dequeue(struct RfuRecvQueue *queue, u8 *src)
REG_IME = 0;
if (queue->recvSlot == queue->sendSlot || queue->full)
{
for (i = 0; i < RECV_QUEUE_SLOT_LENGTH; i++)
for (i = 0; i < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; i++)
src[i] = 0;
REG_IME = imeBak;
return FALSE;
}
for (i = 0; i < RECV_QUEUE_SLOT_LENGTH; i++)
for (i = 0; i < COMM_SLOT_LENGTH * MAX_RFU_PLAYERS; i++)
{
src[i] = queue->slots[queue->sendSlot][i];
}
@ -467,7 +463,7 @@ bool8 RfuSendQueue_Dequeue(struct RfuSendQueue *queue, u8 *src)
imeBak = REG_IME;
REG_IME = 0;
for (i = 0; i < SEND_QUEUE_SLOT_LENGTH; i++)
for (i = 0; i < COMM_SLOT_LENGTH; i++)
src[i] = queue->slots[queue->sendSlot][i];
queue->sendSlot++;
@ -487,7 +483,7 @@ void RfuBackupQueue_Enqueue(struct RfuBackupQueue *queue, const u8 *data)
}
else
{
for (i = 0; i < BACKUP_QUEUE_SLOT_LENGTH; i++)
for (i = 0; i < COMM_SLOT_LENGTH; i++)
queue->slots[queue->recvSlot][i] = data[i];
queue->recvSlot++;
@ -509,7 +505,7 @@ bool8 RfuBackupQueue_Dequeue(struct RfuBackupQueue *queue, u8 *src)
if (src != NULL)
{
for (i = 0; i < BACKUP_QUEUE_SLOT_LENGTH; i++)
for (i = 0; i < COMM_SLOT_LENGTH; i++)
src[i] = queue->slots[queue->sendSlot][i];
}
queue->sendSlot++;