Still more documentation of RFU

This commit is contained in:
PikalaxALT
2020-01-30 14:54:21 -05:00
parent 78196be41e
commit e3307a5b7a
5 changed files with 192 additions and 192 deletions
+3 -2
View File
@@ -90,8 +90,9 @@
#define RFU_MBOOT_DOWNLOADER_SERIAL_NO 0x0000 // The game serial number of the multi-boot downloader (programs that boot without a Game Pak) #define RFU_MBOOT_DOWNLOADER_SERIAL_NO 0x0000 // The game serial number of the multi-boot downloader (programs that boot without a Game Pak)
#define RFU_API_BUFF_SIZE_RAM 0x0e8c // Necessary size for buffer specified by rfu_initializeAPI (fast communication version that operates the library SIO interrupt routines in RAM) // Sizes are 0x28 larger in v1028
#define RFU_API_BUFF_SIZE_ROM 0x052c // Necessary size for buffer specified by rfu_initializeAPI (fast communication version that operates the library SIO interrupt routines in ROM) #define RFU_API_BUFF_SIZE_RAM 0x0e64 // Necessary size for buffer specified by rfu_initializeAPI (fast communication version that operates the library SIO interrupt routines in RAM)
#define RFU_API_BUFF_SIZE_ROM 0x0504 // Necessary size for buffer specified by rfu_initializeAPI (fast communication version that operates the library SIO interrupt routines in ROM)
#define RFU_CHILD_MAX 4 // Maximum number of slaves that can be connected to one parent device #define RFU_CHILD_MAX 4 // Maximum number of slaves that can be connected to one parent device
+31 -32
View File
@@ -198,7 +198,6 @@ typedef struct linkManagerTag
/* 0x00f */ u8 msc_exe_flag; /* 0x00f */ u8 msc_exe_flag;
/* 0x010 */ u8 child_slot; /* 0x010 */ u8 child_slot;
/* 0x011 */ u8 state_bak[2]; /* 0x011 */ u8 state_bak[2];
// aligned
/* 0x014 */ u16 param[2]; /* 0x014 */ u16 param[2];
/* 0x018 */ u16 NI_failCounter_limit; /* 0x018 */ u16 NI_failCounter_limit;
/* 0x01a */ u16 connect_period; /* 0x01a */ u16 connect_period;
@@ -215,48 +214,48 @@ typedef struct linkManagerTag
struct UnkRfuStruct_2_Sub_6c struct UnkRfuStruct_2_Sub_6c
{ {
/* 0x00 */ u16 unk_00; /* 0x00 */ u16 unk_00;
/* 0x02 */ u16 unk_02; /* 0x02 */ u16 count;
/* 0x04 */ const u8 *unk_04; /* 0x04 */ const u8 *payload;
/* 0x08 */ u32 unk_08; /* 0x08 */ u32 unk_08;
/* 0x0c */ u32 unk_0c; /* 0x0c */ u32 unk_0c;
/* 0x10 */ u8 unk_10; /* 0x10 */ u8 unk_10;
/* 0x11 */ u8 unk_11; /* 0x11 */ u8 owner;
/* 0x12 */ u8 unk_12; /* 0x12 */ u8 unk_12;
}; };
struct UnkRfuStruct_2_Sub_124 struct UnkRfuStruct_2_Sub_124
{ {
/* 0x000 */ u8 unk_00[20][70]; /* 0x000 */ u8 slots[20][70];
/* 0x578 */ vu8 unk_8c0; /* 0x578 */ vu8 recv_slot;
/* 0x579 */ vu8 unk_8c1; /* 0x579 */ vu8 send_slot;
/* 0x57a */ vu8 unk_8c2; /* 0x57a */ vu8 count;
/* 0x57b */ vu8 unk_8c3; /* 0x57b */ vu8 full;
}; };
struct UnkRfuStruct_2_Sub_9e8 struct UnkRfuStruct_2_Sub_9e8
{ {
/* 0x000 */ u8 unk_00[40][14]; /* 0x000 */ u8 slots[40][14];
/* 0x230 */ vu8 unk_230; /* 0x230 */ vu8 recv_slot;
/* 0x231 */ vu8 unk_231; /* 0x231 */ vu8 send_slot;
/* 0x232 */ vu8 unk_232; /* 0x232 */ vu8 count;
/* 0x233 */ vu8 unk_233; /* 0x233 */ vu8 full;
}; };
struct UnkRfuStruct_2_Sub_c1c struct UnkRfuStruct_2_Sub_c1c
{ {
/* 0x00 */ u8 unk_00[2][14]; /* 0x00 */ u8 slots[2][14];
/* 0x1c */ vu8 unk_1c; /* 0x1c */ vu8 recv_slot;
/* 0x1d */ vu8 unk_1d; /* 0x1d */ vu8 send_slot;
/* 0x1e */ vu8 unk_1e; /* 0x1e */ vu8 count;
}; };
struct UnkRfuStruct_Sub_Unused struct UnkRfuStruct_Sub_Unused
{ {
/* 0x000 */ u8 unk_00[2][256]; /* 0x000 */ u8 slots[2][256];
/* 0x200 */ vu8 unk_200; /* 0x200 */ vu8 recv_slot;
/* 0x201 */ vu8 unk_201; /* 0x201 */ vu8 send_slot;
/* 0x202 */ vu8 unk_202; /* 0x202 */ vu8 count;
/* 0x203 */ vu8 unk_203; /* 0x203 */ vu8 full;
}; };
typedef struct UnkRfuStruct_2 typedef struct UnkRfuStruct_2
@@ -297,7 +296,7 @@ typedef struct UnkRfuStruct_2
/* 0x8d4 */ struct UnkRfuStruct_2_Sub_c1c unk_c1c; /* 0x8d4 */ struct UnkRfuStruct_2_Sub_c1c unk_c1c;
/* 0x8f4 */ vu8 unk_c3c; /* 0x8f4 */ vu8 unk_c3c;
/* 0x8f5 */ u8 unk_c3d; /* 0x8f5 */ u8 unk_c3d;
/* 0x8f6 */ vu8 unk_c3e; /* 0x8f6 */ vu8 child_slot;
/* 0x8f7 */ u8 unk_c3f[70]; /* 0x8f7 */ u8 unk_c3f[70];
/* 0x93d */ u8 unk_c85; /* 0x93d */ u8 unk_c85;
/* 0x93e */ u8 unk_c86; /* 0x93e */ u8 unk_c86;
@@ -387,17 +386,17 @@ void UpdateWirelessStatusIndicatorSprite(void);
void InitRFU(void); void InitRFU(void);
bool32 sub_80FBA00(void); bool32 sub_80FBA00(void);
void sub_80FC478(struct UnkRfuStruct_2_Sub_124 *ptr); void RFU_queue_20_70_reset(struct UnkRfuStruct_2_Sub_124 *ptr);
void sub_80FC4D4(struct UnkRfuStruct_2_Sub_9e8 *ptr); void RFU_queue_40_14_reset(struct UnkRfuStruct_2_Sub_9e8 *ptr);
void sub_80FB9E4(u8 a0, u16 msg); void sub_80FB9E4(u8 a0, u16 msg);
u8 sub_80FB9F4(void); u8 sub_80FB9F4(void);
void sub_80FC588(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2); void RFU_queue_20_70_recv(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2);
bool8 sub_80FC79C(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2); bool8 RFU_queue_40_14_send(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2);
bool8 sub_80FC888(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); bool8 RFU_queue_2_14_send(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2);
void sub_80FC828(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2); void RFU_queue_2_14_recv(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2);
bool8 sub_80FC6E8(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); bool8 RFU_queue_20_70_send(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1);
void sub_80FC63C(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); void RFU_queue_40_14_recv(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1);
void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3); void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3);
void sub_80FAFE0(u8 a0); void sub_80FAFE0(u8 a0);
bool32 RfuSerialNumberIsValid(u32 a0); bool32 RfuSerialNumberIsValid(u32 a0);
+2 -2
View File
@@ -109,13 +109,13 @@ u16 rfu_initializeAPI(u32 *APIBuffer, u16 buffByteSize, IntrFunc *sioIntrTable_p
// An assert/debug print may have existed before, ie // An assert/debug print may have existed before, ie
// printf("%s %u < %u", "somefile.c:12345", buffByteSize, num) // printf("%s %u < %u", "somefile.c:12345", buffByteSize, num)
// to push this into r3? // to push this into r3?
r3 = RFU_API_BUFF_SIZE_RAM - 0x28; r3 = RFU_API_BUFF_SIZE_RAM;
if (buffByteSize < r3) if (buffByteSize < r3)
return ERR_RFU_API_BUFF_SIZE; return ERR_RFU_API_BUFF_SIZE;
} }
if (!copyInterruptToRam) if (!copyInterruptToRam)
{ {
r3 = RFU_API_BUFF_SIZE_ROM - 0x28; // same issue as above r3 = RFU_API_BUFF_SIZE_ROM; // same issue as above
if (buffByteSize < r3) if (buffByteSize < r3)
return ERR_RFU_API_BUFF_SIZE; return ERR_RFU_API_BUFF_SIZE;
} }
+72 -72
View File
@@ -24,7 +24,7 @@ struct UnkRfuStruct_8010A14{
static EWRAM_DATA struct InitializeParametersTag sRfuReqConfig = {}; static EWRAM_DATA struct InitializeParametersTag sRfuReqConfig = {};
static EWRAM_DATA struct UnkLinkRfuStruct_02022B44 gUnknown_203AC08 = {}; static EWRAM_DATA struct UnkLinkRfuStruct_02022B44 gUnknown_203AC08 = {};
static u32 gf_rfu_REQ_api[(RFU_API_BUFF_SIZE_RAM - 0x28) / 4]; static u32 gf_rfu_REQ_api[RFU_API_BUFF_SIZE_RAM / 4];
static u8 gUnknown_3001FF8[14]; static u8 gUnknown_3001FF8[14];
static u16 gUnknown_3002008[7]; static u16 gUnknown_3002008[7];
@@ -38,7 +38,7 @@ static void sub_80F8D20(u16 a0);
static void sub_80F8DA8(u16 a0); static void sub_80F8DA8(u16 a0);
static void sub_80F906C(void); static void sub_80F906C(void);
static void sub_80F9868(u8 unused); static void sub_80F9868(u8 unused);
static void sub_80F9CB4(struct UnkRfuStruct_2_Sub_6c *data); static void ResetSendDataManager(struct UnkRfuStruct_2_Sub_6c *data);
static void sub_80F9D04(u16 command); static void sub_80F9D04(u16 command);
static void rfufunc_80F9F44(void); static void rfufunc_80F9F44(void);
static void sub_80F9FA8(void); static void sub_80F9FA8(void);
@@ -195,11 +195,11 @@ void sub_80F85F8(void)
} }
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
{ {
sub_80F9CB4(Rfu.unk_80 + i); ResetSendDataManager(Rfu.unk_80 + i);
} }
sub_80F9CB4(&Rfu.unk_6c); ResetSendDataManager(&Rfu.unk_6c);
sub_80FC478(&Rfu.unk_124); RFU_queue_20_70_reset(&Rfu.unk_124);
sub_80FC4D4(&Rfu.unk_9e8); RFU_queue_40_14_reset(&Rfu.unk_9e8);
CpuFill16(0, gSendCmd, sizeof gSendCmd); CpuFill16(0, gSendCmd, sizeof gSendCmd);
CpuFill16(0, gRecvCmds, sizeof gRecvCmds); CpuFill16(0, gRecvCmds, sizeof gRecvCmds);
CpuFill16(0, gLinkPlayers, sizeof gLinkPlayers); CpuFill16(0, gLinkPlayers, sizeof gLinkPlayers);
@@ -220,7 +220,7 @@ void InitRFU(void)
void sub_80F86F4(void) void sub_80F86F4(void)
{ {
if (!rfu_initializeAPI(gf_rfu_REQ_api, RFU_API_BUFF_SIZE_RAM - 0x28, gIntrTable + 1, TRUE)) if (!rfu_initializeAPI(gf_rfu_REQ_api, RFU_API_BUFF_SIZE_RAM, gIntrTable + 1, TRUE))
{ {
gLinkType = 0; gLinkType = 0;
sub_80FB128(FALSE); sub_80FB128(FALSE);
@@ -353,9 +353,9 @@ static void sub_80F893C(u8 taskId)
break; break;
case 12: case 12:
{ {
u8 r5 = 1 << Rfu.unk_c3e; u8 r5 = 1 << Rfu.child_slot;
rfu_clearSlot(TYPE_NI_SEND | TYPE_NI_RECV, Rfu.unk_c3e); rfu_clearSlot(TYPE_NI_SEND | TYPE_NI_RECV, Rfu.child_slot);
rfu_setRecvBuffer(TYPE_UNI, Rfu.unk_c3e, Rfu.unk_c3f, sizeof(Rfu.unk_c3f)); rfu_setRecvBuffer(TYPE_UNI, Rfu.child_slot, Rfu.unk_c3f, sizeof(Rfu.unk_c3f));
rfu_UNI_setSendData(r5, Rfu.unk_4c, sizeof(Rfu.unk_4c)); rfu_UNI_setSendData(r5, Rfu.unk_4c, sizeof(Rfu.unk_4c));
gTasks[taskId].data[1] = 8; gTasks[taskId].data[1] = 8;
DestroyTask(taskId); DestroyTask(taskId);
@@ -420,7 +420,7 @@ static void sub_80F8B34(u8 taskId)
case 18: case 18:
break; break;
case 13: case 13:
if (rfu_UNI_setSendData(1 << Rfu.unk_c3e, Rfu.unk_4c, sizeof(Rfu.unk_4c)) == 0) if (rfu_UNI_setSendData(1 << Rfu.child_slot, Rfu.unk_4c, sizeof(Rfu.unk_4c)) == 0)
{ {
Rfu.unk_0c = 0; Rfu.unk_0c = 0;
DestroyTask(taskId); DestroyTask(taskId);
@@ -476,14 +476,14 @@ static void sub_80F8D20(u16 unused)
} }
rfu_REQ_recvData(); rfu_REQ_recvData();
rfu_waitREQComplete(); rfu_waitREQComplete();
if (gRfuSlotStatusUNI[Rfu.unk_c3e]->recv.newDataFlag) if (gRfuSlotStatusUNI[Rfu.child_slot]->recv.newDataFlag)
{ {
Rfu.unk_cd0++; Rfu.unk_cd0++;
sub_80FC588(&Rfu.unk_124, Rfu.unk_c3f); RFU_queue_20_70_recv(&Rfu.unk_124, Rfu.unk_c3f);
gUnknown_203AC08.unk_06++; gUnknown_203AC08.unk_06++;
sub_80F906C(); sub_80F906C();
rfu_UNI_readySendData(Rfu.unk_c3e); rfu_UNI_readySendData(Rfu.child_slot);
rfu_UNI_clearRecvNewDataFlag(Rfu.unk_c3e); rfu_UNI_clearRecvNewDataFlag(Rfu.child_slot);
} }
rfu_LMAN_REQ_sendData(TRUE); rfu_LMAN_REQ_sendData(TRUE);
} }
@@ -645,8 +645,8 @@ static void sub_80F906C(void)
{ {
if (Rfu.unk_c3c) if (Rfu.unk_c3c)
{ {
u8 r2 = sub_80FC888(&Rfu.unk_c1c, Rfu.unk_4c); u8 r2 = RFU_queue_2_14_send(&Rfu.unk_c1c, Rfu.unk_4c);
if (Rfu.unk_c1c.unk_1e == 0) if (Rfu.unk_c1c.count == 0)
{ {
Rfu.unk_c3c = 0; Rfu.unk_c3c = 0;
} }
@@ -657,8 +657,8 @@ static void sub_80F906C(void)
} }
if (Rfu.unk_c3c == 0) if (Rfu.unk_c3c == 0)
{ {
sub_80FC79C(&Rfu.unk_9e8, Rfu.unk_4c); RFU_queue_40_14_send(&Rfu.unk_9e8, Rfu.unk_4c);
sub_80FC828(&Rfu.unk_c1c, Rfu.unk_4c); RFU_queue_2_14_recv(&Rfu.unk_c1c, Rfu.unk_4c);
} }
} }
@@ -847,7 +847,7 @@ static bool32 sub_80F9514(void)
u8 sp48[2 * (CMD_LENGTH - 1)]; u8 sp48[2 * (CMD_LENGTH - 1)];
u8 switchval; u8 switchval;
sub_80FC6E8(&Rfu.unk_124, sp00); RFU_queue_20_70_send(&Rfu.unk_124, sp00);
for (i = 0; i < MAX_RFU_PLAYERS; i++) for (i = 0; i < MAX_RFU_PLAYERS; i++)
{ {
for (j = 0; j < CMD_LENGTH - 1; j++) for (j = 0; j < CMD_LENGTH - 1; j++)
@@ -879,7 +879,7 @@ static bool32 sub_80F9514(void)
Rfu.unk_cd0--; Rfu.unk_cd0--;
CallRfuFunc(); CallRfuFunc();
sub_80F94BC(gSendCmd, sp48); sub_80F94BC(gSendCmd, sp48);
sub_80FC63C(&Rfu.unk_9e8, sp48); RFU_queue_40_14_recv(&Rfu.unk_9e8, sp48);
for (i = 0; i < CMD_LENGTH - 1; i++) for (i = 0; i < CMD_LENGTH - 1; i++)
gSendCmd[i] = 0; gSendCmd[i] = 0;
} }
@@ -890,8 +890,8 @@ static void sub_80F965C(u8 unused, u32 flags)
{ {
s32 i, j; s32 i, j;
const u8 *r10 = Rfu.unk_6c.unk_04; const u8 *r10 = Rfu.unk_6c.payload;
for (i = 0; i < Rfu.unk_6c.unk_02; i++) for (i = 0; i < Rfu.unk_6c.count; i++)
{ {
if (!(flags & 1)) if (!(flags & 1))
{ {
@@ -907,7 +907,7 @@ static void sub_80F965C(u8 unused, u32 flags)
j++;j--; // Needed to match; j++;j--; // Needed to match;
} }
sub_80FC63C(&Rfu.unk_9e8, gUnknown_3001FF8); RFU_queue_40_14_recv(&Rfu.unk_9e8, gUnknown_3001FF8);
Rfu.unk_6c.unk_0c |= (1 << i); Rfu.unk_6c.unk_0c |= (1 << i);
} }
flags >>= 1; flags >>= 1;
@@ -938,7 +938,7 @@ static u8 sub_80F9770(const u8 *a0)
{ {
Rfu.unk_cde[i] = a0[i]; Rfu.unk_cde[i] = a0[i];
} }
return a0[Rfu.unk_c3e]; return a0[Rfu.child_slot];
} }
static void RfuFunc_SendKeysToRfu(void) static void RfuFunc_SendKeysToRfu(void)
@@ -999,8 +999,8 @@ static void sub_80F9868(u8 unused)
if (Rfu.unk_80[i].unk_12 == 0) if (Rfu.unk_80[i].unk_12 == 0)
{ {
Rfu.unk_80[i].unk_00 = 0; Rfu.unk_80[i].unk_00 = 0;
Rfu.unk_80[i].unk_02 = gRecvCmds[i][1]; Rfu.unk_80[i].count = gRecvCmds[i][1];
Rfu.unk_80[i].unk_11 = gRecvCmds[i][2]; Rfu.unk_80[i].owner = gRecvCmds[i][2];
Rfu.unk_80[i].unk_08 = 0; Rfu.unk_80[i].unk_08 = 0;
Rfu.unk_80[i].unk_12 = 1; Rfu.unk_80[i].unk_12 = 1;
Rfu.unk_5c[i] = 0; Rfu.unk_5c[i] = 0;
@@ -1013,7 +1013,7 @@ static void sub_80F9868(u8 unused)
Rfu.unk_80[i].unk_08 |= (1 << Rfu.unk_80[i].unk_00); Rfu.unk_80[i].unk_08 |= (1 << Rfu.unk_80[i].unk_00);
for (j = 0; j < 6; j++) for (j = 0; j < 6; j++)
gBlockRecvBuffer[i][Rfu.unk_80[i].unk_00 * 6 + j] = gRecvCmds[i][j + 1]; gBlockRecvBuffer[i][Rfu.unk_80[i].unk_00 * 6 + j] = gRecvCmds[i][j + 1];
if (Rfu.unk_80[i].unk_08 == gUnknown_843EBD4[Rfu.unk_80[i].unk_02]) if (Rfu.unk_80[i].unk_08 == gUnknown_843EBD4[Rfu.unk_80[i].count])
{ {
Rfu.unk_80[i].unk_12 = 2; Rfu.unk_80[i].unk_12 = 2;
Rfu_SetBlockReceivedFlag(i); Rfu_SetBlockReceivedFlag(i);
@@ -1104,14 +1104,14 @@ static bool8 sub_80F9C78(void)
return TRUE; return TRUE;
} }
static void sub_80F9CB4(struct UnkRfuStruct_2_Sub_6c *data) static void ResetSendDataManager(struct UnkRfuStruct_2_Sub_6c *data)
{ {
data->unk_00 = 0; data->unk_00 = 0;
data->unk_02 = 0; data->count = 0;
data->unk_04 = NULL; data->payload = NULL;
data->unk_08 = 0; data->unk_08 = 0;
data->unk_10 = 0; data->unk_10 = 0;
data->unk_11 = 0; data->owner = 0;
data->unk_12 = 0; data->unk_12 = 0;
} }
@@ -1140,8 +1140,8 @@ static void sub_80F9D04(u16 command)
switch (command) switch (command)
{ {
case 0x8800: case 0x8800:
gSendCmd[1] = Rfu.unk_6c.unk_02; gSendCmd[1] = Rfu.unk_6c.count;
gSendCmd[2] = Rfu.unk_6c.unk_11 + 0x80; gSendCmd[2] = Rfu.unk_6c.owner + 0x80;
break; break;
case 0xa100: case 0xa100:
if (sub_80F9C50()) if (sub_80F9C50())
@@ -1174,11 +1174,11 @@ static void sub_80F9D04(u16 command)
} }
} }
void sub_80F9E2C(void *a0) void sub_80F9E2C(void * data)
{ {
if (gSendCmd[0] == 0 && !sub_80FBA00()) if (gSendCmd[0] == 0 && !sub_80FBA00())
{ {
memcpy(Rfu.unk_f2, a0, sizeof(Rfu.unk_f2)); memcpy(Rfu.unk_f2, data, sizeof(Rfu.unk_f2));
sub_80F9D04(0x2f00); sub_80F9D04(0x2f00);
} }
} }
@@ -1197,17 +1197,17 @@ bool32 Rfu_InitBlockSend(const u8 *src, size_t size)
return FALSE; return FALSE;
} }
r4 = (size % 12) != 0; r4 = (size % 12) != 0;
Rfu.unk_6c.unk_11 = GetMultiplayerId(); Rfu.unk_6c.owner = GetMultiplayerId();
Rfu.unk_6c.unk_10 = 1; Rfu.unk_6c.unk_10 = 1;
Rfu.unk_6c.unk_02 = (size / 12) + r4; Rfu.unk_6c.count = (size / 12) + r4;
Rfu.unk_6c.unk_00 = 0; Rfu.unk_6c.unk_00 = 0;
if (size > 0x100) if (size > 0x100)
Rfu.unk_6c.unk_04 = src; Rfu.unk_6c.payload = src;
else else
{ {
if (src != gBlockSendBuffer) if (src != gBlockSendBuffer)
memcpy(gBlockSendBuffer, src, size); memcpy(gBlockSendBuffer, src, size);
Rfu.unk_6c.unk_04 = gBlockSendBuffer; Rfu.unk_6c.payload = gBlockSendBuffer;
} }
sub_80F9D04(0x8800); sub_80F9D04(0x8800);
Rfu.RfuFunc = rfufunc_80F9F44; Rfu.RfuFunc = rfufunc_80F9F44;
@@ -1235,12 +1235,12 @@ static void rfufunc_80F9F44(void)
static void sub_80F9FA8(void) static void sub_80F9FA8(void)
{ {
s32 i; s32 i;
const u8 *src = Rfu.unk_6c.unk_04; const u8 *src = Rfu.unk_6c.payload;
gSendCmd[0] = 0x8900 | Rfu.unk_6c.unk_00; gSendCmd[0] = 0x8900 | Rfu.unk_6c.unk_00;
for (i = 0; i < 7; i++) for (i = 0; i < 7; i++)
gSendCmd[i + 1] = (src[(i << 1) + Rfu.unk_6c.unk_00 * 12 + 1] << 8) | src[(i << 1) + Rfu.unk_6c.unk_00 * 12 + 0]; gSendCmd[i + 1] = (src[(i << 1) + Rfu.unk_6c.unk_00 * 12 + 1] << 8) | src[(i << 1) + Rfu.unk_6c.unk_00 * 12 + 0];
Rfu.unk_6c.unk_00++; Rfu.unk_6c.unk_00++;
if (Rfu.unk_6c.unk_02 <= Rfu.unk_6c.unk_00) if (Rfu.unk_6c.count <= Rfu.unk_6c.unk_00)
{ {
Rfu.unk_6c.unk_10 = 0; Rfu.unk_6c.unk_10 = 0;
Rfu.RfuFunc = rfufunc_80FA020; Rfu.RfuFunc = rfufunc_80FA020;
@@ -1249,17 +1249,17 @@ static void sub_80F9FA8(void)
static void rfufunc_80FA020(void) static void rfufunc_80FA020(void)
{ {
const u8 *src = Rfu.unk_6c.unk_04; const u8 *src = Rfu.unk_6c.payload;
u8 mpId = GetMultiplayerId(); u8 mpId = GetMultiplayerId();
s32 i; s32 i;
if (Rfu.unk_0c == 0) if (Rfu.unk_0c == 0)
{ {
gSendCmd[0] = (~0x76ff) | (Rfu.unk_6c.unk_02 - 1); gSendCmd[0] = (~0x76ff) | (Rfu.unk_6c.count - 1);
for (i = 0; i < 7; i++) for (i = 0; i < 7; i++)
gSendCmd[i + 1] = (src[(i << 1) + (Rfu.unk_6c.unk_02 - 1) * 12 + 1] << 8) | src[(i << 1) + (Rfu.unk_6c.unk_02 - 1) * 12 + 0]; gSendCmd[i + 1] = (src[(i << 1) + (Rfu.unk_6c.count - 1) * 12 + 1] << 8) | src[(i << 1) + (Rfu.unk_6c.count - 1) * 12 + 0];
if ((u8)gRecvCmds[mpId][0] == Rfu.unk_6c.unk_02 - 1) if ((u8)gRecvCmds[mpId][0] == Rfu.unk_6c.count - 1)
{ {
if (Rfu.unk_80[mpId].unk_08 != gUnknown_843EBD4[Rfu.unk_80[mpId].unk_02]) if (Rfu.unk_80[mpId].unk_08 != gUnknown_843EBD4[Rfu.unk_80[mpId].count])
{ {
sub_80F965C(mpId, Rfu.unk_80[mpId].unk_08); sub_80F965C(mpId, Rfu.unk_80[mpId].unk_08);
gUnknown_203AC08.unk_64++; gUnknown_203AC08.unk_64++;
@@ -1369,7 +1369,7 @@ static void sub_80FA2B0(void)
if (GetMultiplayerId() != 0) if (GetMultiplayerId() != 0)
{ {
if (Rfu.unk_124.unk_8c2 == 0 && Rfu.unk_fe > 0x3c) if (Rfu.unk_124.count == 0 && Rfu.unk_fe > 0x3c)
{ {
sub_80F9D04(0x6600); sub_80F9D04(0x6600);
Rfu.unk_fe = 0; Rfu.unk_fe = 0;
@@ -1393,7 +1393,7 @@ static void sub_80FA2B0(void)
static void sub_80FA350(void) static void sub_80FA350(void)
{ {
if (Rfu.unk_124.unk_8c2 == 0 && gSendCmd[0] == 0) if (Rfu.unk_124.count == 0 && gSendCmd[0] == 0)
{ {
sub_80F9D04(0x6600); sub_80F9D04(0x6600);
Rfu.RfuFunc = sub_80FA2B0; Rfu.RfuFunc = sub_80FA2B0;
@@ -1407,7 +1407,7 @@ static void sub_80FA388(void)
if (GetMultiplayerId() != 0) if (GetMultiplayerId() != 0)
{ {
if (Rfu.unk_124.unk_8c2 == 0 && gSendCmd[0] == 0) if (Rfu.unk_124.count == 0 && gSendCmd[0] == 0)
{ {
sub_80F9D04(0x6600); sub_80F9D04(0x6600);
Rfu.RfuFunc = sub_80FA2B0; Rfu.RfuFunc = sub_80FA2B0;
@@ -1423,7 +1423,7 @@ static void sub_80FA388(void)
} }
if (i == playerCount) if (i == playerCount)
{ {
if (Rfu.unk_124.unk_8c2 == 0 && gSendCmd[0] == 0) if (Rfu.unk_124.count == 0 && gSendCmd[0] == 0)
{ {
sub_80F9D04(0x6600); sub_80F9D04(0x6600);
Rfu.RfuFunc = sub_80FA350; Rfu.RfuFunc = sub_80FA350;
@@ -1509,7 +1509,7 @@ static bool8 sub_80FA528(void)
} }
} }
else if (gRfuSlotStatusNI[Rfu.unk_c3e]->recv.state == SLOT_STATE_RECV_FAILED) else if (gRfuSlotStatusNI[Rfu.child_slot]->recv.state == SLOT_STATE_RECV_FAILED)
{ {
rfu_clearSlot(TYPE_NI_RECV, i); rfu_clearSlot(TYPE_NI_RECV, i);
} }
@@ -1564,8 +1564,8 @@ void sub_80FA670(u8 a0, u16 a1, const u8 *a2)
void sub_80FA6BC(void) void sub_80FA6BC(void)
{ {
Rfu.unk_c85 = 8; Rfu.unk_c85 = 8;
rfu_clearSlot(TYPE_NI_SEND, Rfu.unk_c3e); rfu_clearSlot(TYPE_NI_SEND, Rfu.child_slot);
rfu_NI_setSendData(1 << Rfu.unk_c3e, 8, &Rfu.unk_c85, 1); rfu_NI_setSendData(1 << Rfu.child_slot, 8, &Rfu.unk_c85, 1);
} }
u32 sub_80FA6FC(u16 trainerId, const u8 *trainerName) u32 sub_80FA6FC(u16 trainerId, const u8 *trainerName)
@@ -1599,18 +1599,18 @@ static s32 sub_80FA788(void)
s32 retval = 0; s32 retval = 0;
if (Rfu.unk_c85 == 8) if (Rfu.unk_c85 == 8)
{ {
if (gRfuSlotStatusNI[Rfu.unk_c3e]->send.state == SLOT_STATE_SEND_SUCCESS || gRfuSlotStatusNI[Rfu.unk_c3e]->send.state == SLOT_STATE_SEND_FAILED) if (gRfuSlotStatusNI[Rfu.child_slot]->send.state == SLOT_STATE_SEND_SUCCESS || gRfuSlotStatusNI[Rfu.child_slot]->send.state == SLOT_STATE_SEND_FAILED)
rfu_clearSlot(TYPE_NI_SEND, Rfu.unk_c3e); rfu_clearSlot(TYPE_NI_SEND, Rfu.child_slot);
} }
if (gRfuSlotStatusNI[Rfu.unk_c3e]->recv.state == SLOT_STATE_RECV_SUCCESS || gRfuSlotStatusNI[Rfu.unk_c3e]->recv.state == SLOT_STATE_RECV_SUCCESS_AND_SENDSIDE_UNKNOWN) if (gRfuSlotStatusNI[Rfu.child_slot]->recv.state == SLOT_STATE_RECV_SUCCESS || gRfuSlotStatusNI[Rfu.child_slot]->recv.state == SLOT_STATE_RECV_SUCCESS_AND_SENDSIDE_UNKNOWN)
{ {
rfu_clearSlot(TYPE_NI_RECV, Rfu.unk_c3e); rfu_clearSlot(TYPE_NI_RECV, Rfu.child_slot);
sub_80FB9E4(Rfu.unk_c86, 0); sub_80FB9E4(Rfu.unk_c86, 0);
retval = Rfu.unk_c86; retval = Rfu.unk_c86;
} }
else if (gRfuSlotStatusNI[Rfu.unk_c3e]->recv.state == SLOT_STATE_RECV_FAILED) else if (gRfuSlotStatusNI[Rfu.child_slot]->recv.state == SLOT_STATE_RECV_FAILED)
{ {
rfu_clearSlot(TYPE_NI_RECV, Rfu.unk_c3e); rfu_clearSlot(TYPE_NI_RECV, Rfu.child_slot);
retval = 6; retval = 6;
} }
return retval; return retval;
@@ -1850,11 +1850,11 @@ static void RfuCheckErrorStatus(void)
gWirelessCommType = 2; gWirelessCommType = 2;
SetMainCallback2(CB2_LinkError); SetMainCallback2(CB2_LinkError);
gMain.savedCallback = CB2_LinkError; gMain.savedCallback = CB2_LinkError;
SetLinkErrorFromRfu((Rfu.linkman_msg << 16) | (Rfu.linkman_param[0] << 8) | Rfu.linkman_param[1], Rfu.unk_124.unk_8c2, Rfu.unk_9e8.unk_232, sub_80FB9F4() == 2); SetLinkErrorFromRfu((Rfu.linkman_msg << 16) | (Rfu.linkman_param[0] << 8) | Rfu.linkman_param[1], Rfu.unk_124.count, Rfu.unk_9e8.count, sub_80FB9F4() == 2);
Rfu.errorState = 2; Rfu.errorState = 2;
CloseLink(); CloseLink();
} }
else if (Rfu.unk_9e8.unk_233 == 1 || Rfu.unk_124.unk_8c3 == 1) else if (Rfu.unk_9e8.full == 1 || Rfu.unk_124.full == 1)
{ {
if (lman.childClockSlave_flag) if (lman.childClockSlave_flag)
rfu_LMAN_requestChangeAgbClockMaster(); rfu_LMAN_requestChangeAgbClockMaster();
@@ -2116,7 +2116,7 @@ static void sub_80FB37C(u8 msg, u8 param_count)
case LMAN_MSG_SEARCH_PARENT_PERIOD_EXPIRED: case LMAN_MSG_SEARCH_PARENT_PERIOD_EXPIRED:
break; break;
case LMAN_MSG_CONNECT_PARENT_SUCCESSED: case LMAN_MSG_CONNECT_PARENT_SUCCESSED:
Rfu.unk_c3e = lman.param[0]; Rfu.child_slot = lman.param[0];
break; break;
case LMAN_MSG_CONNECT_PARENT_FAILED: case LMAN_MSG_CONNECT_PARENT_FAILED:
sub_80FB9E4(2, msg); sub_80FB9E4(2, msg);
@@ -2125,8 +2125,8 @@ static void sub_80FB37C(u8 msg, u8 param_count)
Rfu.unk_04 = 11; Rfu.unk_04 = 11;
Rfu.unk_c85 = 0; Rfu.unk_c85 = 0;
Rfu.unk_c86 = 0; Rfu.unk_c86 = 0;
rfu_setRecvBuffer(TYPE_NI, Rfu.unk_c3e, &Rfu.unk_c86, 1); rfu_setRecvBuffer(TYPE_NI, Rfu.child_slot, &Rfu.unk_c86, 1);
rfu_setRecvBuffer(TYPE_UNI, Rfu.unk_c3e, Rfu.unk_c3f, 70); rfu_setRecvBuffer(TYPE_UNI, Rfu.child_slot, Rfu.unk_c3f, sizeof(Rfu.unk_c3f));
break; break;
case LMAN_MSG_CHILD_NAME_SEND_FAILED_AND_DISCONNECTED: case LMAN_MSG_CHILD_NAME_SEND_FAILED_AND_DISCONNECTED:
sub_80FB9E4(2, msg); sub_80FB9E4(2, msg);
@@ -2269,7 +2269,7 @@ static void sub_80FB5EC(u8 msg, u8 param_count)
case LMAN_MSG_SEARCH_PARENT_PERIOD_EXPIRED: case LMAN_MSG_SEARCH_PARENT_PERIOD_EXPIRED:
break; break;
case LMAN_MSG_CONNECT_PARENT_SUCCESSED: case LMAN_MSG_CONNECT_PARENT_SUCCESSED:
Rfu.unk_c3e = lman.param[0]; Rfu.child_slot = lman.param[0];
break; break;
case LMAN_MSG_CONNECT_PARENT_FAILED: case LMAN_MSG_CONNECT_PARENT_FAILED:
Rfu.unk_04 = 0x12; Rfu.unk_04 = 0x12;
@@ -2286,7 +2286,7 @@ static void sub_80FB5EC(u8 msg, u8 param_count)
case LMAN_MSG_CHILD_NAME_SEND_COMPLETED: case LMAN_MSG_CHILD_NAME_SEND_COMPLETED:
Rfu.unk_04 = 0xD; Rfu.unk_04 = 0xD;
sub_80FB9E4(3, 0); sub_80FB9E4(3, 0);
rfu_setRecvBuffer(TYPE_UNI, Rfu.unk_c3e, Rfu.unk_c3f, sizeof(Rfu.unk_c3f)); rfu_setRecvBuffer(TYPE_UNI, Rfu.child_slot, Rfu.unk_c3f, sizeof(Rfu.unk_c3f));
break; break;
case LMAN_MSG_CHILD_NAME_SEND_FAILED_AND_DISCONNECTED: case LMAN_MSG_CHILD_NAME_SEND_FAILED_AND_DISCONNECTED:
sub_80FB9E4(2, msg); sub_80FB9E4(2, msg);
@@ -2806,9 +2806,9 @@ static void sub_80FC228(void)
nullsub_87(gUnknown_843EE47, 6, i + 3); nullsub_87(gUnknown_843EE47, 6, i + 3);
nullsub_87(gUnknown_843EE57, 0x16, i + 3); nullsub_87(gUnknown_843EE57, 0x16, i + 3);
} }
nullsub_88(gRfuLinkStatus->partner[Rfu.unk_c3e].serialNo, 1, 3, 4); nullsub_88(gRfuLinkStatus->partner[Rfu.child_slot].serialNo, 1, 3, 4);
nullsub_87(gRfuLinkStatus->partner[Rfu.unk_c3e].gname, 6, 3); nullsub_87(gRfuLinkStatus->partner[Rfu.child_slot].gname, 6, 3);
nullsub_87(gRfuLinkStatus->partner[Rfu.unk_c3e].uname, 0x16, 3); nullsub_87(gRfuLinkStatus->partner[Rfu.child_slot].uname, 0x16, 3);
} }
else else
{ {
@@ -2846,12 +2846,12 @@ static const char gUnknown_843EEA8[][8] = {
static u32 sub_80FC44C(void) static u32 sub_80FC44C(void)
{ {
return Rfu.unk_9e8.unk_232; return Rfu.unk_9e8.count;
} }
u32 GetRfuRecvQueueLength(void) u32 GetRfuRecvQueueLength(void)
{ {
return Rfu.unk_124.unk_8c2; return Rfu.unk_124.count;
} }
static void nullsub_89(u8 taskId) static void nullsub_89(u8 taskId)
+84 -84
View File
@@ -166,7 +166,7 @@ static const struct SpriteTemplate sWirelessStatusIndicatorSpriteTemplate = {
SpriteCallbackDummy SpriteCallbackDummy
}; };
void sub_80FC478(struct UnkRfuStruct_2_Sub_124 *ptr) void RFU_queue_20_70_reset(struct UnkRfuStruct_2_Sub_124 *queue)
{ {
s32 i; s32 i;
s32 j; s32 j;
@@ -175,16 +175,16 @@ void sub_80FC478(struct UnkRfuStruct_2_Sub_124 *ptr)
{ {
for (j = 0; j < 70; j++) for (j = 0; j < 70; j++)
{ {
ptr->unk_00[i][j] = 0; queue->slots[i][j] = 0;
} }
} }
ptr->unk_8c1 = 0; queue->send_slot = 0;
ptr->unk_8c0 = 0; queue->recv_slot = 0;
ptr->unk_8c2 = 0; queue->count = 0;
ptr->unk_8c3 = 0; queue->full = 0;
} }
void sub_80FC4D4(struct UnkRfuStruct_2_Sub_9e8 *ptr) void RFU_queue_40_14_reset(struct UnkRfuStruct_2_Sub_9e8 *ptr)
{ {
s32 i; s32 i;
s32 j; s32 j;
@@ -193,16 +193,16 @@ void sub_80FC4D4(struct UnkRfuStruct_2_Sub_9e8 *ptr)
{ {
for (j = 0; j < 14; j++) for (j = 0; j < 14; j++)
{ {
ptr->unk_00[i][j] = 0; ptr->slots[i][j] = 0;
} }
} }
ptr->unk_231 = 0; ptr->send_slot = 0;
ptr->unk_230 = 0; ptr->recv_slot = 0;
ptr->unk_232 = 0; ptr->count = 0;
ptr->unk_233 = 0; ptr->full = 0;
} }
static void sub_80FC530(struct UnkRfuStruct_Sub_Unused *ptr) static void RFU_queue_2_256_reset(struct UnkRfuStruct_Sub_Unused *ptr)
{ {
s32 i; s32 i;
s32 j; s32 j;
@@ -211,29 +211,29 @@ static void sub_80FC530(struct UnkRfuStruct_Sub_Unused *ptr)
{ {
for (j = 0; j < 256; j++) for (j = 0; j < 256; j++)
{ {
ptr->unk_00[i][j] = 0; ptr->slots[i][j] = 0;
} }
} }
ptr->unk_201 = 0; ptr->send_slot = 0;
ptr->unk_200 = 0; ptr->recv_slot = 0;
ptr->unk_202 = 0; ptr->count = 0;
ptr->unk_203 = 0; ptr->full = 0;
} }
void sub_80FC588(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2) void RFU_queue_20_70_recv(struct UnkRfuStruct_2_Sub_124 *queue, u8 *data)
{ {
s32 i; s32 i;
u16 imeBak; u16 imeBak;
u8 count; u8 count;
if (q1->unk_8c2 < 20) if (queue->count < 20)
{ {
imeBak = REG_IME; imeBak = REG_IME;
REG_IME = 0; REG_IME = 0;
count = 0; count = 0;
for (i = 0; i < 70; i += 14) for (i = 0; i < 70; i += 14)
{ {
if (q2[i] == 0 && q2[i + 1] == 0) if (data[i] == 0 && data[i + 1] == 0)
{ {
count++; count++;
} }
@@ -242,36 +242,36 @@ void sub_80FC588(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2)
{ {
for (i = 0; i < 70; i++) for (i = 0; i < 70; i++)
{ {
q1->unk_00[q1->unk_8c0][i] = q2[i]; queue->slots[queue->recv_slot][i] = data[i];
} }
q1->unk_8c0++; queue->recv_slot++;
q1->unk_8c0 %= 20; queue->recv_slot %= 20;
q1->unk_8c2++; queue->count++;
for (i = 0; i < 70; i++) for (i = 0; i < 70; i++)
{ {
q2[i] = 0; data[i] = 0;
} }
} }
REG_IME = imeBak; REG_IME = imeBak;
} }
else else
{ {
q1->unk_8c3 = 1; queue->full = 1;
} }
} }
void sub_80FC63C(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2) void RFU_queue_40_14_recv(struct UnkRfuStruct_2_Sub_9e8 *queue, u8 *data)
{ {
s32 i; s32 i;
u16 imeBak; u16 imeBak;
if (q1->unk_232 < 40) if (queue->count < 40)
{ {
imeBak = REG_IME; imeBak = REG_IME;
REG_IME = 0; REG_IME = 0;
for (i = 0; i < 14; i++) for (i = 0; i < 14; i++)
{ {
if (q2[i] != 0) if (data[i] != 0)
{ {
break; break;
} }
@@ -280,57 +280,57 @@ void sub_80FC63C(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2)
{ {
for (i = 0; i < 14; i++) for (i = 0; i < 14; i++)
{ {
q1->unk_00[q1->unk_230][i] = q2[i]; queue->slots[queue->recv_slot][i] = data[i];
} }
q1->unk_230++; queue->recv_slot++;
q1->unk_230 %= 40; queue->recv_slot %= 40;
q1->unk_232++; queue->count++;
for (i = 0; i < 14; i++) for (i = 0; i < 14; i++)
{ {
q2[i] = 0; data[i] = 0;
} }
} }
REG_IME = imeBak; REG_IME = imeBak;
} }
else else
{ {
q1->unk_233 = 1; queue->full = 1;
} }
} }
bool8 sub_80FC6E8(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2) bool8 RFU_queue_20_70_send(struct UnkRfuStruct_2_Sub_124 *queue, u8 *dest)
{ {
u16 imeBak; u16 imeBak;
s32 i; s32 i;
imeBak = REG_IME; imeBak = REG_IME;
REG_IME = 0; REG_IME = 0;
if (q1->unk_8c0 == q1->unk_8c1 || q1->unk_8c3 != 0) if (queue->recv_slot == queue->send_slot || queue->full)
{ {
for (i = 0; i < 70; i++) for (i = 0; i < 70; i++)
{ {
q2[i] = 0; dest[i] = 0;
} }
REG_IME = imeBak; REG_IME = imeBak;
return FALSE; return FALSE;
} }
for (i = 0; i < 70; i++) for (i = 0; i < 70; i++)
{ {
q2[i] = q1->unk_00[q1->unk_8c1][i]; dest[i] = queue->slots[queue->send_slot][i];
} }
q1->unk_8c1++; queue->send_slot++;
q1->unk_8c1 %= 20; queue->send_slot %= 20;
q1->unk_8c2--; queue->count--;
REG_IME = imeBak; REG_IME = imeBak;
return TRUE; return TRUE;
} }
bool8 sub_80FC79C(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2) bool8 RFU_queue_40_14_send(struct UnkRfuStruct_2_Sub_9e8 *queue, u8 *dest)
{ {
s32 i; s32 i;
u16 imeBak; u16 imeBak;
if (q1->unk_230 == q1->unk_231 || q1->unk_233 != 0) if (queue->recv_slot == queue->send_slot || queue->full != 0)
{ {
return FALSE; return FALSE;
} }
@@ -338,98 +338,98 @@ bool8 sub_80FC79C(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2)
REG_IME = 0; REG_IME = 0;
for (i = 0; i < 14; i++) for (i = 0; i < 14; i++)
{ {
q2[i] = q1->unk_00[q1->unk_231][i]; dest[i] = queue->slots[queue->send_slot][i];
} }
q1->unk_231++; queue->send_slot++;
q1->unk_231 %= 40; queue->send_slot %= 40;
q1->unk_232--; queue->count--;
REG_IME = imeBak; REG_IME = imeBak;
return TRUE; return TRUE;
} }
void sub_80FC828(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2) void RFU_queue_2_14_recv(struct UnkRfuStruct_2_Sub_c1c *queue, const u8 *data)
{ {
s32 i; s32 i;
if (q2[1] == 0) if (data[1] == 0)
{ {
sub_80FC888(q1, NULL); RFU_queue_2_14_send(queue, NULL);
} }
else else
{ {
for (i = 0; i < 14; i++) for (i = 0; i < 14; i++)
{ {
q1->unk_00[q1->unk_1c][i] = q2[i]; queue->slots[queue->recv_slot][i] = data[i];
} }
q1->unk_1c++; queue->recv_slot++;
q1->unk_1c %= 2; queue->recv_slot %= 2;
if (q1->unk_1e < 2) if (queue->count < 2)
{ {
q1->unk_1e++; queue->count++;
} }
else else
{ {
q1->unk_1d = q1->unk_1c; queue->send_slot = queue->recv_slot;
} }
} }
} }
bool8 sub_80FC888(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2) bool8 RFU_queue_2_14_send(struct UnkRfuStruct_2_Sub_c1c *queue, u8 *dest)
{ {
s32 i; s32 i;
if (q1->unk_1e == 0) if (queue->count == 0)
{ {
return FALSE; return FALSE;
} }
if (q2 != NULL) if (dest != NULL)
{ {
for (i = 0; i < 14; i++) for (i = 0; i < 14; i++)
{ {
q2[i] = q1->unk_00[q1->unk_1d][i]; dest[i] = queue->slots[queue->send_slot][i];
} }
} }
q1->unk_1d++; queue->send_slot++;
q1->unk_1d %= 2; queue->send_slot %= 2;
q1->unk_1e--; queue->count--;
return TRUE; return TRUE;
} }
static void sub_80FC8D8(struct UnkRfuStruct_Sub_Unused *q1, u8 *q2) static void RFU_queue_2_256_recv(struct UnkRfuStruct_Sub_Unused *queue, u8 *data)
{ {
s32 i; s32 i;
if (q1->unk_202 < 2) if (queue->count < 2)
{ {
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
q1->unk_00[q1->unk_200][i] = q2[i]; queue->slots[queue->recv_slot][i] = data[i];
} }
q1->unk_200++; queue->recv_slot++;
q1->unk_200 %= 2; queue->recv_slot %= 2;
q1->unk_202++; queue->count++;
} }
else else
{ {
q1->unk_203 = 1; queue->full = 1;
} }
} }
static bool8 sub_80FC944(struct UnkRfuStruct_Sub_Unused *q1, u8 *q2) static bool8 RFU_queue_2_256_send(struct UnkRfuStruct_Sub_Unused *queue, u8 *send)
{ {
s32 i; s32 i;
if (q1->unk_200 == q1->unk_201 || q1->unk_203) if (queue->recv_slot == queue->send_slot || queue->full)
{ {
return FALSE; return FALSE;
} }
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
q2[i] = q1->unk_00[q1->unk_201][i]; send[i] = queue->slots[queue->send_slot][i];
} }
q1->unk_201++; queue->send_slot++;
q1->unk_201 %= 2; queue->send_slot %= 2;
q1->unk_202--; queue->count--;
return TRUE; return TRUE;
} }
@@ -438,7 +438,7 @@ static void sub_80FC9B8(u8 *q1, u8 mode)
s32 i; s32 i;
u8 rval; u8 rval;
u16 r5 = 0; u16 r5 = 0;
static u8 _3002018; static u8 counter;
switch (mode) switch (mode)
{ {
@@ -470,11 +470,11 @@ static void sub_80FC9B8(u8 *q1, u8 mode)
case 3: case 3:
for (i = 0; i < 200; i++) for (i = 0; i < 200; i++)
{ {
q1[i] = i + 1 + _3002018; q1[i] = i + 1 + counter;
r5 += (i + 1 + _3002018) & 0xFF; r5 += (i + 1 + counter) & 0xFF;
} }
*((u16 *)(q1 + i)) = r5; *((u16 *)(q1 + i)) = r5;
_3002018++; counter++;
break; break;
} }
} }
@@ -892,7 +892,7 @@ void RecordMixTrainerNames(void)
s32 connectedTrainerRecordIndices[5]; s32 connectedTrainerRecordIndices[5];
struct TrainerNameRecord *newRecords = AllocZeroed(20 * sizeof(struct TrainerNameRecord)); struct TrainerNameRecord *newRecords = AllocZeroed(20 * sizeof(struct TrainerNameRecord));
// Check if we already have a record saved for connected trainers. // Check if we alsendy have a record saved for connected trainers.
for (i = 0; i < GetLinkPlayerCount(); i++) for (i = 0; i < GetLinkPlayerCount(); i++)
{ {
connectedTrainerRecordIndices[i] = -1; connectedTrainerRecordIndices[i] = -1;
@@ -913,7 +913,7 @@ void RecordMixTrainerNames(void)
{ {
CopyTrainerRecord(&newRecords[nextSpace], (u16)gLinkPlayers[i].trainerId, gLinkPlayers[i].name); CopyTrainerRecord(&newRecords[nextSpace], (u16)gLinkPlayers[i].trainerId, gLinkPlayers[i].name);
// If we already had a record for this trainer, wipe it so that the next step doesn't duplicate it. // If we alsendy had a record for this trainer, wipe it so that the next step doesn't duplicate it.
if (connectedTrainerRecordIndices[i] >= 0) if (connectedTrainerRecordIndices[i] >= 0)
{ {
ZeroName(gSaveBlock1Ptr->trainerNameRecords[connectedTrainerRecordIndices[i]].trainerName); ZeroName(gSaveBlock1Ptr->trainerNameRecords[connectedTrainerRecordIndices[i]].trainerName);